@arcgis/core 4.24.0-next.20220604 → 4.24.0-next.20220607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/analysis/LineOfSightAnalysis.js +1 -1
  3. package/arcade/featureset/support/sqlUtils.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/471beeb6924599209567.js +1 -0
  6. package/assets/esri/core/workers/chunks/{8102bb78fe96e6197e4e.js → 5da1b3dacc6c8c080a1c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/b780228a520e1a0b100b.js +1 -0
  8. package/assets/esri/themes/base/widgets/_Daylight.scss +31 -32
  9. package/assets/esri/themes/base/widgets/_FloorFilter.scss +1 -0
  10. package/assets/esri/themes/base/widgets/_SnappingControls.scss +14 -0
  11. package/assets/esri/themes/dark/main.css +1 -1
  12. package/assets/esri/themes/light/main.css +1 -1
  13. package/assets/esri/themes/light/view.css +1 -1
  14. package/core/unitUtils.js +1 -1
  15. package/interfaces.d.ts +19 -41
  16. package/layers/LineOfSightLayer.js +1 -1
  17. package/networks/support/typeUtils.js +1 -1
  18. package/package.json +1 -1
  19. package/properties/defaultUnit.js +1 -1
  20. package/rest/networks/queryAssociations.js +5 -0
  21. package/rest/networks/support/Association.js +1 -1
  22. package/rest/networks/support/QueryAssociationsParameters.js +5 -0
  23. package/rest/networks/support/QueryAssociationsResult.js +5 -0
  24. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  25. package/support/revision.js +1 -1
  26. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  27. package/views/2d/engine/webgl/mesh/templates/WGLLabelTemplate.js +1 -1
  28. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  29. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  30. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  31. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  32. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  33. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  34. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  35. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  36. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  37. package/views/draw/DrawOperation.js +1 -1
  38. package/views/interactive/SegmentLabels.js +1 -1
  39. package/views/interactive/tooltip/Tooltip.js +1 -1
  40. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  41. package/views/support/lengthMeasurementUtils.js +1 -1
  42. package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
  43. package/widgets/Slider.js +1 -1
  44. package/widgets/support/AnalysisViewModel.js +1 -1
  45. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  46. package/widgets/support/SnappingControls/SnappingControlsViewModel.js +1 -1
  47. package/widgets/support/SnappingControls/SnappingListItem.js +1 -1
  48. package/widgets/support/SnappingControls.js +1 -1
  49. package/assets/esri/core/workers/chunks/0832c0f5e61b7b354a17.js +0 -1
  50. package/assets/esri/core/workers/chunks/6f41f039226a043a2d18.js +0 -1
package/core/unitUtils.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import"./has.js";import{strict as e}from"./jsonMap.js";import{unwrapOr as s,isSome as t,isNone as r}from"./maybe.js";import{getReferenceEllipsoid as i}from"../geometry/projectionEllipsoid.js";import n from"../geometry/SpatialReference.js";import{earth as a,mars as u,moon as c}from"../geometry/support/Ellipsoid.js";import{isEarth as o,isWKIDFromMars as l,isWKIDFromMoon as m}from"../geometry/support/spatialReferenceUtils.js";import f from"../geometry/support/WKIDUnitConversion.js";const d=39.37,U=a.radius*Math.PI/200,q=/UNIT\[([^\]]+)\]\]$/i,p=f,B=/UNIT\[([^\]]+)\]/i,h=new Set([4261,4305,4807,4810,4811,4812,4816,4819,4821,4901,4902,37225,104139,104140]),k=e()({meter:"meters",foot:"feet",foot_us:"us-feet",foot_clarke:"clarke-feet",yard_clarke:"clarke-yards",link_clarke:"clarke-links",yard_sears:"sears-yards",foot_sears:"sears-feet",chain_sears:"sears-chains",chain_benoit_1895_b:"benoit-1895-b-chains",yard_indian:"indian-yards",yard_indian_1937:"indian-1937-yards",foot_gold_coast:"gold-coast-feet",chain_sears_1922_truncated:"sears-1922-truncated-chains","50_kilometers":"50-kilometers","150_kilometers":"150-kilometers"}),y=e=>e*e,b=e=>e*e*e,_={length:{baseUnit:"meters",units:{millimeters:{inBaseUnits:.001},centimeters:{inBaseUnits:.01},decimeters:{inBaseUnits:.1},meters:{inBaseUnits:1},kilometers:{inBaseUnits:1e3},inches:{inBaseUnits:.0254},feet:{inBaseUnits:.3048},yards:{inBaseUnits:.9144},miles:{inBaseUnits:1609.344},"nautical-miles":{inBaseUnits:1852},"us-feet":{inBaseUnits:1200/3937}}},area:{baseUnit:"square-meters",units:{"square-millimeters":{inBaseUnits:y(.001)},"square-centimeters":{inBaseUnits:y(.01)},"square-decimeters":{inBaseUnits:y(.1)},"square-meters":{inBaseUnits:1},"square-kilometers":{inBaseUnits:y(1e3)},"square-inches":{inBaseUnits:y(.0254)},"square-feet":{inBaseUnits:y(.3048)},"square-yards":{inBaseUnits:y(.9144)},"square-miles":{inBaseUnits:y(1609.344)},"square-us-feet":{inBaseUnits:y(1200/3937)},acres:{inBaseUnits:.0015625*y(1609.344)},ares:{inBaseUnits:100},hectares:{inBaseUnits:1e4}}},volume:{baseUnit:"liters",units:{liters:{inBaseUnits:1},"cubic-millimeters":{inBaseUnits:1e3*b(.001)},"cubic-centimeters":{inBaseUnits:1e3*b(.01)},"cubic-decimeters":{inBaseUnits:1e3*b(.1)},"cubic-meters":{inBaseUnits:1e3},"cubic-kilometers":{inBaseUnits:1e3*b(1e3)},"cubic-inches":{inBaseUnits:1e3*b(.0254)},"cubic-feet":{inBaseUnits:1e3*b(.3048)},"cubic-yards":{inBaseUnits:1e3*b(.9144)},"cubic-miles":{inBaseUnits:1e3*b(1609.344)}}},angle:{baseUnit:"radians",units:{radians:{inBaseUnits:1},degrees:{inBaseUnits:Math.PI/180}}}},g=(()=>{const e={};for(const s in _)for(const t in _[s].units)e[t]=s;return e})();function w(e,s,t){return e*_[t].units[s].inBaseUnits}function S(e,s,t){return e/_[t].units[s].inBaseUnits}const j=["metric","imperial","square-inches","square-feet","square-yards","square-miles","square-us-feet","square-meters","square-kilometers","acres","ares","hectares"],M=["metric","imperial","inches","feet","yards","miles","nautical-miles","us-feet","meters","kilometers"],I=new Map([["meters","square-meters"],["feet","square-feet"],["us-feet","square-us-feet"]]);function P(e){return"imperial"===e||"metric"===e}function C(e){const s=g[e];if(!s)throw new Error("unknown type");return s}function D(e){return _[e].baseUnit}function x(e){return D(C(e))}function E(e,s=null){return s=s||C(e),_[s].baseUnit===e}function N(e,s,t){if(s===t)return e;const r=C(s);if(r!==C(t))throw new Error("incompatible units");const i=E(s,r)?e:w(e,s,r);return E(t,r)?i:S(i,t,r)}function v(e,s,t){switch(t){case"metric":return J(e,s);case"imperial":return R(e,s);default:return t}}function F(e,s,t){switch(t){case"metric":return K(e,s);case"imperial":return A(e,s);default:return t}}function O(e,s,t){switch(t){case"metric":return T(e,s);case"imperial":return Y(e,s);default:return t}}function J(e,s){return N(e,s,"meters")<3e3?"meters":"kilometers"}function K(e,s){return N(e,s,"meters")<1e5?"meters":"kilometers"}function R(e,s){return N(e,s,"feet")<1e3?"feet":"miles"}function A(e,s){return N(e,s,"feet")<1e5?"feet":"miles"}function T(e,s){return N(e,s,"square-meters")<3e6?"square-meters":"square-kilometers"}function Y(e,s){return N(e,s,"square-feet")<1e6?"square-feet":"square-miles"}function G(e,s,t){return N(e,s,"meters")/(t*Math.PI/180)}function H(e){return k.fromJSON(e.toLowerCase())||null}function L(e){return k.toJSON(e)||null}function W(e){if(e&&"object"==typeof e&&!o(e))return 1;const s=z(e);return s>1e5?1:s}function $(e){return z(e)>=(e instanceof n?i(e).metersPerDegree:1e5)?"meters":Z(e)}function z(e,t=a.metersPerDegree){return s(Q(e,!0),t)}function Q(e,s=!1){let t,r,i=null;if(null!=e&&("object"==typeof e?(t=e.wkid,r=e.wkt):"number"==typeof e?t=e:"string"==typeof e&&(r=e)),t){if(l(t))return u.metersPerDegree;if(m(t))return c.metersPerDegree;i=p.values[p[t]],!i&&s&&h.has(t)&&(i=U)}else r&&(re(r)?i=V(q.exec(r),i):te(r)&&(i=V(B.exec(r),i)));return i}function V(e,s){return e&&e[1]?X(e[1]):s}function X(e){return parseFloat(e.split(",")[1])}function Z(e){let s,r,i=null;if(null!=e&&("object"==typeof e?(s=e.wkid,r=e.wkt):"number"==typeof e?s=e:"string"==typeof e&&(r=e)),s)i=p.units[p[s]];else if(r){const e=re(r)?q:te(r)?B:null;if(e){const s=e.exec(r);s&&s[1]&&(i=ne(s[1]))}}return t(i)?H(i):null}function ee(e){const s=Z(e);return r(s)||!M.includes(s)?null:s}function se(e){const s=Z(e);return r(s)?null:I.get(s)}function te(e){return/^GEOCCS/i.test(e)}function re(e){return/^PROJCS/i.test(e)}const ie=1e-7;function ne(e){const s=/[\\"\\']{1}([^\\"\\']+)/.exec(e);let t=s&&s[1];if(!t||!p.units.includes(t)){const s=X(e);t=null;const r=p.values;for(let e=0;e<r.length;++e)if(Math.abs(s-r[e])<ie){t=p.units[e];break}}return t}function ae(e){const s=Z(e);if(r(s))return null;switch(s){case"feet":case"us-feet":case"clarke-feet":case"clarke-yards":case"clarke-links":case"sears-yards":case"sears-feet":case"sears-chains":case"benoit-1895-b-chains":case"indian-yards":case"indian-1937-yards":case"gold-coast-feet":case"sears-1922-truncated-chains":return"imperial";case"50-kilometers":case"150-kilometers":case"meters":return"metric"}return null}const ue={esriAcres:"acres",esriAres:"ares",esriHectares:"hectares",esriSquareCentimeters:"square-centimeters",esriSquareDecimeters:"square-decimeters",esriSquareFeet:"square-feet",esriSquareInches:"square-inches",esriSquareKilometers:"square-kilometers",esriSquareMeters:"square-meters",esriSquareMiles:"square-miles",esriSquareMillimeters:"square-millimeters",esriSquareUsFeet:"square-us-feet",esriSquareYards:"square-yards"},ce={esriCentimeters:"centimeters",esriDecimeters:"decimeters",esriFeet:"feet",esriInches:"inches",esriKilometers:"kilometers",esriMeters:"meters",esriMiles:"miles",esriMillimeters:"millimeters",esriNauticalMiles:"nautical-miles",esriYards:"yards"},oe=e()(ue),le=e()(ce),me=e()({...ue,...ce});export{se as areaUnitFromSpatialReference,oe as areaUnitsJSONMap,x as baseUnitForUnit,D as baseUnitForUnitType,N as convertUnit,ae as getDefaultUnitSystem,Q as getMetersPerUnit,z as getMetersPerUnitForSR,W as getMetersPerVerticalUnitForSR,Z as getUnitString,$ as getVerticalUnitStringForSR,d as inchesPerMeter,E as isBaseUnit,P as isMeasurementSystem,G as lengthToDegrees,ee as lengthUnitFromSpatialReference,le as lengthUnitsJSONMap,j as measurementAreaUnits,M as measurementLengthUnits,O as preferredAreaUnit,Y as preferredImperialAreaUnit,R as preferredImperialLengthUnit,A as preferredImperialVerticalLengthUnit,v as preferredLengthUnit,T as preferredMetricAreaUnit,J as preferredMetricLengthUnit,K as preferredMetricVerticalLengthUnit,F as preferredVerticalLengthUnit,H as unitFromRESTJSON,L as unitToRESTJSON,C as unitType,me as unitsJSONMap};
5
+ import"./has.js";import{strict as e}from"./jsonMap.js";import{unwrapOr as s,isSome as t,isNone as r}from"./maybe.js";import{getReferenceEllipsoid as i}from"../geometry/projectionEllipsoid.js";import n from"../geometry/SpatialReference.js";import{earth as a,mars as u,moon as c}from"../geometry/support/Ellipsoid.js";import{isEarth as o,isWKIDFromMars as l,isWKIDFromMoon as m}from"../geometry/support/spatialReferenceUtils.js";import f from"../geometry/support/WKIDUnitConversion.js";const d=39.37,U=a.radius*Math.PI/200,q=/UNIT\[([^\]]+)\]\]$/i,p=f,B=/UNIT\[([^\]]+)\]/i,h=new Set([4261,4305,4807,4810,4811,4812,4816,4819,4821,4901,4902,37225,104139,104140]),k=e()({meter:"meters",foot:"feet",foot_us:"us-feet",foot_clarke:"clarke-feet",yard_clarke:"clarke-yards",link_clarke:"clarke-links",yard_sears:"sears-yards",foot_sears:"sears-feet",chain_sears:"sears-chains",chain_benoit_1895_b:"benoit-1895-b-chains",yard_indian:"indian-yards",yard_indian_1937:"indian-1937-yards",foot_gold_coast:"gold-coast-feet",chain_sears_1922_truncated:"sears-1922-truncated-chains","50_kilometers":"50-kilometers","150_kilometers":"150-kilometers"}),y=e=>e*e,b=e=>e*e*e,g={length:{baseUnit:"meters",units:{millimeters:{inBaseUnits:.001},centimeters:{inBaseUnits:.01},decimeters:{inBaseUnits:.1},meters:{inBaseUnits:1},kilometers:{inBaseUnits:1e3},inches:{inBaseUnits:.0254},feet:{inBaseUnits:.3048},yards:{inBaseUnits:.9144},miles:{inBaseUnits:1609.344},"nautical-miles":{inBaseUnits:1852},"us-feet":{inBaseUnits:1200/3937}}},area:{baseUnit:"square-meters",units:{"square-millimeters":{inBaseUnits:y(.001)},"square-centimeters":{inBaseUnits:y(.01)},"square-decimeters":{inBaseUnits:y(.1)},"square-meters":{inBaseUnits:1},"square-kilometers":{inBaseUnits:y(1e3)},"square-inches":{inBaseUnits:y(.0254)},"square-feet":{inBaseUnits:y(.3048)},"square-yards":{inBaseUnits:y(.9144)},"square-miles":{inBaseUnits:y(1609.344)},"square-us-feet":{inBaseUnits:y(1200/3937)},acres:{inBaseUnits:.0015625*y(1609.344)},ares:{inBaseUnits:100},hectares:{inBaseUnits:1e4}}},volume:{baseUnit:"liters",units:{liters:{inBaseUnits:1},"cubic-millimeters":{inBaseUnits:1e3*b(.001)},"cubic-centimeters":{inBaseUnits:1e3*b(.01)},"cubic-decimeters":{inBaseUnits:1e3*b(.1)},"cubic-meters":{inBaseUnits:1e3},"cubic-kilometers":{inBaseUnits:1e3*b(1e3)},"cubic-inches":{inBaseUnits:1e3*b(.0254)},"cubic-feet":{inBaseUnits:1e3*b(.3048)},"cubic-yards":{inBaseUnits:1e3*b(.9144)},"cubic-miles":{inBaseUnits:1e3*b(1609.344)}}},angle:{baseUnit:"radians",units:{radians:{inBaseUnits:1},degrees:{inBaseUnits:Math.PI/180}}}},_=(()=>{const e={};for(const s in g)for(const t in g[s].units)e[t]=s;return e})();function w(e,s,t){return e*g[t].units[s].inBaseUnits}function S(e,s,t){return e/g[t].units[s].inBaseUnits}const j=["metric","imperial","square-inches","square-feet","square-yards","square-miles","square-us-feet","square-meters","square-kilometers","acres","ares","hectares"],M=["metric","imperial","inches","feet","yards","miles","nautical-miles","us-feet","meters","kilometers"],I=new Map([["meters","square-meters"],["feet","square-feet"],["us-feet","square-us-feet"]]);function P(e){return"imperial"===e||"metric"===e}function C(e){const s=_[e];if(!s)throw new Error("unknown type");return s}function D(e){return g[e].baseUnit}function x(e){return D(C(e))}function E(e,s=null){return s=s||C(e),g[s].baseUnit===e}function N(e,s,t){if(s===t)return e;const r=C(s);if(r!==C(t))throw new Error("incompatible units");const i=E(s,r)?e:w(e,s,r);return E(t,r)?i:S(i,t,r)}function v(e,s,t){switch(t){case"metric":return R(e,s);case"imperial":return K(e,s);default:return t}}function F(e,s,t){switch(t){case"metric":return J(e,s);case"imperial":return A(e,s);default:return t}}function O(e,s,t){switch(t){case"metric":return T(e,s);case"imperial":return Y(e,s);default:return t}}function R(e,s){return N(e,s,"meters")<3e3?"meters":"kilometers"}function J(e,s){return N(e,s,"meters")<1e5?"meters":"kilometers"}function K(e,s){return N(e,s,"feet")<1e3?"feet":"miles"}function A(e,s){return N(e,s,"feet")<1e5?"feet":"miles"}function T(e,s){return N(e,s,"square-meters")<3e6?"square-meters":"square-kilometers"}function Y(e,s){return N(e,s,"square-feet")<1e6?"square-feet":"square-miles"}function G(e,s,t){return N(e,s,"meters")/(t*Math.PI/180)}function H(e){return k.fromJSON(e.toLowerCase())||null}function L(e){return k.toJSON(e)||null}function W(e){if(e&&"object"==typeof e&&!o(e))return 1;const s=z(e);return s>1e5?1:s}function $(e){return z(e)>=(e instanceof n?i(e).metersPerDegree:1e5)?"meters":Z(e)}function z(e,t=a.metersPerDegree){return s(Q(e,!0),t)}function Q(e,s=!1){let t,r,i=null;if(null!=e&&("object"==typeof e?(t=e.wkid,r=e.wkt):"number"==typeof e?t=e:"string"==typeof e&&(r=e)),t){if(l(t))return u.metersPerDegree;if(m(t))return c.metersPerDegree;i=p.values[p[t]],!i&&s&&h.has(t)&&(i=U)}else r&&(ie(r)?i=V(q.exec(r),i):re(r)&&(i=V(B.exec(r),i)));return i}function V(e,s){return e&&e[1]?X(e[1]):s}function X(e){return parseFloat(e.split(",")[1])}function Z(e){let s,r,i=null;if(null!=e&&("object"==typeof e?(s=e.wkid,r=e.wkt):"number"==typeof e?s=e:"string"==typeof e&&(r=e)),s)i=p.units[p[s]];else if(r){const e=ie(r)?q:re(r)?B:null;if(e){const s=e.exec(r);s&&s[1]&&(i=ae(s[1]))}}return t(i)?H(i):null}function ee(e){const s=Z(e);return r(s)||!M.includes(s)?null:s}function se(e){const s=$(e);return r(s)||!M.includes(s)?null:s}function te(e){const s=Z(e);return r(s)?null:I.get(s)}function re(e){return/^GEOCCS/i.test(e)}function ie(e){return/^PROJCS/i.test(e)}const ne=1e-7;function ae(e){const s=/[\\"\\']{1}([^\\"\\']+)/.exec(e);let t=s&&s[1];if(!t||!p.units.includes(t)){const s=X(e);t=null;const r=p.values;for(let e=0;e<r.length;++e)if(Math.abs(s-r[e])<ne){t=p.units[e];break}}return t}function ue(e){const s=Z(e);if(r(s))return null;switch(s){case"feet":case"us-feet":case"clarke-feet":case"clarke-yards":case"clarke-links":case"sears-yards":case"sears-feet":case"sears-chains":case"benoit-1895-b-chains":case"indian-yards":case"indian-1937-yards":case"gold-coast-feet":case"sears-1922-truncated-chains":return"imperial";case"50-kilometers":case"150-kilometers":case"meters":return"metric"}return null}function ce(e){const t="metric";if(r(e))return t;const i=e.map,n=i&&"portalItem"in i?i.portalItem?.portal:null;if(n){switch(n?.user?.units??n.units){case t:return t;case"english":return"imperial"}}return s(ue(e.spatialReference),t)}const oe={esriAcres:"acres",esriAres:"ares",esriHectares:"hectares",esriSquareCentimeters:"square-centimeters",esriSquareDecimeters:"square-decimeters",esriSquareFeet:"square-feet",esriSquareInches:"square-inches",esriSquareKilometers:"square-kilometers",esriSquareMeters:"square-meters",esriSquareMiles:"square-miles",esriSquareMillimeters:"square-millimeters",esriSquareUsFeet:"square-us-feet",esriSquareYards:"square-yards"},le={esriCentimeters:"centimeters",esriDecimeters:"decimeters",esriFeet:"feet",esriInches:"inches",esriKilometers:"kilometers",esriMeters:"meters",esriMiles:"miles",esriMillimeters:"millimeters",esriNauticalMiles:"nautical-miles",esriYards:"yards"},me=e()(oe),fe=e()(le),de=e()({...oe,...le});export{te as areaUnitFromSpatialReference,me as areaUnitsJSONMap,x as baseUnitForUnit,D as baseUnitForUnitType,N as convertUnit,ce as getDefaultUnitForView,ue as getDefaultUnitSystem,Q as getMetersPerUnit,z as getMetersPerUnitForSR,W as getMetersPerVerticalUnitForSR,Z as getUnitString,$ as getVerticalUnitStringForSR,d as inchesPerMeter,E as isBaseUnit,P as isMeasurementSystem,G as lengthToDegrees,ee as lengthUnitFromSpatialReference,fe as lengthUnitsJSONMap,j as measurementAreaUnits,M as measurementLengthUnits,O as preferredAreaUnit,Y as preferredImperialAreaUnit,K as preferredImperialLengthUnit,A as preferredImperialVerticalLengthUnit,v as preferredLengthUnit,T as preferredMetricAreaUnit,R as preferredMetricLengthUnit,J as preferredMetricVerticalLengthUnit,F as preferredVerticalLengthUnit,H as unitFromRESTJSON,L as unitToRESTJSON,C as unitType,de as unitsJSONMap,se as verticalLengthUnitFromSpatialReference};
package/interfaces.d.ts CHANGED
@@ -37352,6 +37352,8 @@ declare namespace __esri {
37352
37352
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networks-support-Association.html#associationType)
37353
37353
  */
37354
37354
  associationType: "attachment" | "connectivity" | "containment";
37355
+ errorCode: number;
37356
+ errorMessage: string;
37355
37357
  /**
37356
37358
  * The from side network element of the association.
37357
37359
  *
@@ -37364,12 +37366,15 @@ declare namespace __esri {
37364
37366
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networks-support-Association.html#globalId)
37365
37367
  */
37366
37368
  globalId: string;
37369
+ isContentVisible: boolean;
37367
37370
  /**
37368
37371
  * The synthesized [polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) geometry created between the two network elements.
37369
37372
  *
37370
37373
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networks-support-Association.html#line)
37371
37374
  */
37372
37375
  line: Polyline;
37376
+ percentAlong: number;
37377
+ status: number;
37373
37378
  /**
37374
37379
  * The to side network element of the association.
37375
37380
  *
@@ -37397,6 +37402,8 @@ declare namespace __esri {
37397
37402
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networks-support-Association.html#associationType)
37398
37403
  */
37399
37404
  associationType?: "attachment" | "connectivity" | "containment";
37405
+ errorCode?: number;
37406
+ errorMessage?: string;
37400
37407
  /**
37401
37408
  * The from side network element of the association.
37402
37409
  *
@@ -37409,12 +37416,15 @@ declare namespace __esri {
37409
37416
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networks-support-Association.html#globalId)
37410
37417
  */
37411
37418
  globalId?: string;
37419
+ isContentVisible?: boolean;
37412
37420
  /**
37413
37421
  * The synthesized [polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) geometry created between the two network elements.
37414
37422
  *
37415
37423
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-networks-support-Association.html#line)
37416
37424
  */
37417
37425
  line?: PolylineProperties;
37426
+ percentAlong?: number;
37427
+ status?: number;
37418
37428
  /**
37419
37429
  * The to side network element of the association.
37420
37430
  *
@@ -67889,7 +67899,7 @@ declare namespace __esri {
67889
67899
  */
67890
67900
  goTo(target: GoToTarget2D, options?: GoToOptions2D): Promise<any>;
67891
67901
  /**
67892
- * Returns [hit test results](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) from each layer that intersect the specified screen coordinates.
67902
+ * Returns [hit test results](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) from each layer that intersects the specified screen coordinates.
67893
67903
  *
67894
67904
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest)
67895
67905
  */
@@ -68100,7 +68110,7 @@ declare namespace __esri {
68100
68110
  export type HitTestItem = Layer | Graphic | Collection<Layer> | Collection<Graphic> | Layer[] | Graphic[];
68101
68111
 
68102
68112
  /**
68103
- * Object specification for the results returned from various layers in [HitTestResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) of the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) method.
68113
+ * Object specification for the result of the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) method.
68104
68114
  *
68105
68115
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult)
68106
68116
  */
@@ -68721,7 +68731,7 @@ declare namespace __esri {
68721
68731
  */
68722
68732
  goTo(target: GoToTarget3D, options?: GoToOptions3D): Promise<any>;
68723
68733
  /**
68724
- * Returns [hit test results](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) from each layer that intersect the specified screen coordinates.
68734
+ * Returns [hit test results](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) from each layer that intersects the specified screen coordinates.
68725
68735
  *
68726
68736
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest)
68727
68737
  */
@@ -80935,18 +80945,6 @@ declare namespace __esri {
80935
80945
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html#valid)
80936
80946
  */
80937
80947
  valid: boolean;
80938
- /**
80939
- * Takes a set of existing inputFields and reconciles them with an updated set of sources (layer fields).
80940
- *
80941
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html#_updateInputFieldsFromLayerFields)
80942
- */
80943
- _updateInputFieldsFromLayerFields(inputFields: void, fields: void, sharedInitializationProperties: void): any;
80944
- /**
80945
- * The typings for this method's signature are a little convoluted, but it boils down to these two cases: 1.
80946
- *
80947
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html#_updateInputFieldsRecursive)
80948
- */
80949
- _updateInputFieldsRecursive(): void;
80950
80948
  /**
80951
80949
  * Convenience method to find input fields.
80952
80950
  *
@@ -80971,7 +80969,6 @@ declare namespace __esri {
80971
80969
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm-FeatureFormViewModel.html#submit)
80972
80970
  */
80973
80971
  submit(): void;
80974
- validateContingencyConstraints(values: void, options: void): any;
80975
80972
  on(name: "value-change", eventHandler: FeatureFormViewModelValueChangeEventHandler): IHandle;
80976
80973
  on(name: "submit", eventHandler: FeatureFormViewModelSubmitEventHandler): IHandle;
80977
80974
  }
@@ -81957,12 +81954,6 @@ declare namespace __esri {
81957
81954
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#state)
81958
81955
  */
81959
81956
  readonly state: "disabled" | "loading" | "loaded" | "ready";
81960
- /**
81961
- * TODO description
81962
- *
81963
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#tableTemplate)
81964
- */
81965
- tableTemplate: any;
81966
81957
  /**
81967
81958
  * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html).
81968
81959
  *
@@ -82127,12 +82118,6 @@ declare namespace __esri {
82127
82118
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#multiSortEnabled)
82128
82119
  */
82129
82120
  multiSortEnabled?: boolean;
82130
- /**
82131
- * TODO description
82132
- *
82133
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FeatureTableViewModel.html#tableTemplate)
82134
- */
82135
- tableTemplate?: any;
82136
82121
  /**
82137
82122
  * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html).
82138
82123
  *
@@ -82278,12 +82263,6 @@ declare namespace __esri {
82278
82263
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FieldColumn.html#sortable)
82279
82264
  */
82280
82265
  readonly sortable: boolean;
82281
- /**
82282
- * TODO - update type? Initial configuration template for the FieldColumn.
82283
- *
82284
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FieldColumn.html#template)
82285
- */
82286
- template: any;
82287
82266
  }
82288
82267
 
82289
82268
  interface FieldColumnConstructor {
@@ -82328,12 +82307,6 @@ declare namespace __esri {
82328
82307
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FieldColumn.html#layer)
82329
82308
  */
82330
82309
  layer?: (FeatureLayerProperties & { type: "feature" }) | (SceneLayerProperties & { type: "scene" });
82331
- /**
82332
- * TODO - update type? Initial configuration template for the FieldColumn.
82333
- *
82334
- * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-FieldColumn.html#template)
82335
- */
82336
- template?: any;
82337
82310
  }
82338
82311
 
82339
82312
  interface FieldColumnConfig extends FieldConfig {
@@ -82751,7 +82724,7 @@ declare namespace __esri {
82751
82724
  *
82752
82725
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#ButtonMenuConfig)
82753
82726
  */
82754
- iconClass?: boolean;
82727
+ iconClass?: string;
82755
82728
  /**
82756
82729
  * An array of [ButtonMenuItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable-Grid-support-ButtonMenuItem.html).
82757
82730
  *
@@ -84659,6 +84632,11 @@ declare namespace __esri {
84659
84632
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#childrenSortable)
84660
84633
  */
84661
84634
  childrenSortable: boolean;
84635
+ /**
84636
+ * Only valid when the list item represents a [StreamLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html).
84637
+ *
84638
+ * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#connectionStatus)
84639
+ */
84662
84640
  readonly connectionStatus: "connected" | "disconnected";
84663
84641
  /**
84664
84642
  * The Error object returned if an error occurred.
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import r from"../analysis/LineOfSightAnalysis.js";import t from"../analysis/LineOfSightAnalysisObserver.js";import s from"../analysis/LineOfSightAnalysisTarget.js";import i from"../core/Collection.js";import{HandleOwnerMixin as o}from"../core/HandleOwner.js";import{applySome as a,isSome as n}from"../core/maybe.js";import{MultiOriginJSONMixin as l}from"../core/MultiOriginJSONSupport.js";import{watch as p,syncAndInitial as y}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import h from"./Layer.js";import{OperationalLayer as f}from"./mixins/OperationalLayer.js";const u=i.ofType(s);let d=class extends(f(l(o(h)))){constructor(e){super(e),this.type="line-of-sight",this.operationalLayerType="LineOfSightLayer",this.analysis=new r}initialize(){this.handles.add(p((()=>this.analysis),((e,r)=>{n(r)&&r.parent===this&&(r.parent=null),n(e)&&(e.parent=this)}),y))}get observer(){return a(this.analysis,(e=>e.observer))}set observer(e){a(this.analysis,(r=>r.observer=e))}get targets(){return n(this.analysis)?this.analysis.targets:null}set targets(e){a(this.analysis,(r=>r.targets=e))}get fullExtent(){return n(this.analysis)?this.analysis.extent:null}get spatialReference(){return n(this.analysis)?this.analysis.spatialReference:null}};e([c({json:{read:!1},readOnly:!0})],d.prototype,"type",void 0),e([c({type:["LineOfSightLayer"]})],d.prototype,"operationalLayerType",void 0),e([c({type:t,json:{read:!0,write:{ignoreOrigin:!0}}})],d.prototype,"observer",null),e([c({type:u,json:{read:!0,write:{ignoreOrigin:!0}}})],d.prototype,"targets",null),e([c({nonNullable:!0})],d.prototype,"analysis",void 0),e([c({readOnly:!0})],d.prototype,"fullExtent",null),e([c({readOnly:!0})],d.prototype,"spatialReference",null),e([c({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}}})],d.prototype,"opacity",void 0),e([c({type:["show","hide"]})],d.prototype,"listMode",void 0),d=e([m("esri.layers.LineOfSightLayer")],d);const g=d;export{g as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import r from"../analysis/LineOfSightAnalysis.js";import t from"../analysis/LineOfSightAnalysisObserver.js";import s from"../analysis/LineOfSightAnalysisTarget.js";import i from"../core/Collection.js";import{HandleOwnerMixin as o}from"../core/HandleOwner.js";import{applySome as a,isSome as n}from"../core/maybe.js";import{MultiOriginJSONMixin as l}from"../core/MultiOriginJSONSupport.js";import{watch as p,syncAndInitial as y}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import h from"./Layer.js";import{OperationalLayer as d}from"./mixins/OperationalLayer.js";const f=i.ofType(s);let u=class extends(d(l(o(h)))){constructor(e){super(e),this.type="line-of-sight",this.operationalLayerType="LineOfSightLayer",this.analysis=new r}initialize(){this.handles.add(p((()=>this.analysis),((e,r)=>{n(r)&&r.parent===this&&(r.parent=null),n(e)&&(e.parent=this)}),y))}get observer(){return a(this.analysis,(e=>e.observer))}set observer(e){a(this.analysis,(r=>r.observer=e))}get targets(){return n(this.analysis)?this.analysis.targets:null}set targets(e){a(this.analysis,(r=>r.targets=e))}get fullExtent(){return n(this.analysis)?this.analysis.extent:null}get spatialReference(){return n(this.analysis)?this.analysis.spatialReference:null}};e([c({json:{read:!1},readOnly:!0})],u.prototype,"type",void 0),e([c({type:["LineOfSightLayer"]})],u.prototype,"operationalLayerType",void 0),e([c({type:t,json:{read:!0,write:{ignoreOrigin:!0}}})],u.prototype,"observer",null),e([c({type:f,json:{read:!0,write:{ignoreOrigin:!0}}})],u.prototype,"targets",null),e([c({nonNullable:!0,json:{read:!1,write:!1}})],u.prototype,"analysis",void 0),e([c({readOnly:!0})],u.prototype,"fullExtent",null),e([c({readOnly:!0})],u.prototype,"spatialReference",null),e([c({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}}})],u.prototype,"opacity",void 0),e([c({type:["show","hide"]})],u.prototype,"listMode",void 0),u=e([m("esri.layers.LineOfSightLayer")],u);const g=u;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{JSONMap as n}from"../../core/jsonMap.js";var t;!function(n){n[n.RTJunctionJunctionConnectivity=1]="RTJunctionJunctionConnectivity",n[n.RTContainment=2]="RTContainment",n[n.RTAttachment=3]="RTAttachment",n[n.RTJunctionEdgeConnectivity=4]="RTJunctionEdgeConnectivity",n[n.RTEdgeJunctionEdgeConnectivity=5]="RTEdgeJunctionEdgeConnectivity"}(t||(t={}));const o=new n({connected:"connected",upstream:"upstream",downstream:"downstream",shortestPath:"shortest-path",subnetwork:"subnetwork","subnetwork controllers":"subnetwork-controllers",loops:"loops",isolation:"isolation"});export{t as RuleType,o as traceTypeKebabDict};
5
+ import{JSONMap as n}from"../../core/jsonMap.js";var t;!function(n){n[n.RTJunctionJunctionConnectivity=1]="RTJunctionJunctionConnectivity",n[n.RTContainment=2]="RTContainment",n[n.RTAttachment=3]="RTAttachment",n[n.RTJunctionEdgeConnectivity=4]="RTJunctionEdgeConnectivity",n[n.RTEdgeJunctionEdgeConnectivity=5]="RTEdgeJunctionEdgeConnectivity"}(t||(t={}));const o=new n({connected:"connected",upstream:"upstream",downstream:"downstream",shortestPath:"shortest-path",subnetwork:"subnetwork",subnetworkController:"subnetwork-controller",loops:"loops",isolation:"isolation"}),e=new n({connectivity:"connectivity",attachment:"attachment",containment:"containment",junctionEdgeFromConnectivity:"junction-edge-from-connectivity",junctionMidspanConnectivity:"junction-midspan-connectivity",junctionEdgeToConnectivity:"junction-edge-to-connectivity"});export{t as RuleType,e as associationTypeKebabDict,o as traceTypeKebabDict};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.24.0-next.20220604",
3
+ "version": "4.24.0-next.20220607",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{unwrapOr as e}from"../core/maybe.js";import{getDefaultUnitSystem as t}from"../core/unitUtils.js";const r={readOnly:!0,get(){const r="metric",{view:i}=this;if(!i)return r;const s=i.get("map.portalItem.portal");if(s){switch(s.get("user.units")||s.units){case r:return r;case"english":return"imperial"}}return e(t(i.spatialReference),r)}};export{r as defaultUnitPropertyMetadata};
5
+ import{getDefaultUnitForView as t}from"../core/unitUtils.js";const r={readOnly:!0,get(){return t(this.view)}};export{r as defaultUnitPropertyMetadata};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
+ */
5
+ import t from"../../request.js";import{associationTypeKebabDict as e}from"../../networks/support/typeUtils.js";import{parseUrl as o,encode as r,asValidOptions as s}from"../utils.js";import n from"./support/QueryAssociationsResult.js";function i(t){const{returnDeletes:o,elements:r,gdbVersion:s,moment:n}=t.toJSON();return{returnDeletes:o,elements:JSON.stringify(r.map((t=>({globalId:t.globalId,networkSourceId:t.networkSourceId,terminalId:t.terminalId})))),types:JSON.stringify(t.associationTypes.map((t=>e.toJSON(t)))),gdbVersion:s,moment:n}}async function m(e,m,u){const a=o(e),p={...i(m),f:"json"},l=r({...a.query,...p}),f=s(l,{...u,method:"post"}),c=`${a.path}/associations/query`,{data:d}=await t(c,f);if(!d)return null;return n.fromJSON(d)}export{m as queryAssociations};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{JSONSupport as e}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{reader as t}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{writer as m}from"../../../core/accessorSupport/decorators/writer.js";import n from"./NetworkElement.js";import s from"../../../geometry/Polyline.js";let p=class extends e{constructor(o){super(o),this.globalId=null,this.associationType=null,this.fromNetworkElement=null,this.toNetworkElement=null,this.geometry=null}readFromNetworkElement(o,e){const r=new n;return r.globalId=e.fromGlobalId,r.networkSourceId=e.fromNetworkSourceId,r.terminalId=e.fromTerminalId,r}writeFromNetworkElement(o,e){o&&(e.fromGlobalId=o.globalId,e.fromNetworkSourceId=o.networkSourceId,e.fromTerminalId=o.terminalId)}readToNetworkElement(o,e){const r=new n;return r.globalId=e.toGlobalId,r.networkSourceId=e.toNetworkSourceId,r.terminalId=e.toTerminalId,r}writeToNetworkElement(o,e){o&&(e.toGlobalId=o.globalId,e.toNetworkSourceId=o.networkSourceId,e.toTerminalId=o.terminalId)}};o([r({type:String,json:{write:!0}})],p.prototype,"globalId",void 0),o([r({type:["attachment","connectivity","containment"],json:{write:!0}})],p.prototype,"associationType",void 0),o([r({type:n,json:{write:{target:{fromGlobalId:{type:String},fromNetworkSourceId:{type:Number},fromTerminalId:{type:Number}}},read:{source:["fromGlobalId","fromNetworkSourceId","fromTerminalId"]}}})],p.prototype,"fromNetworkElement",void 0),o([t("fromNetworkElement")],p.prototype,"readFromNetworkElement",null),o([m("fromNetworkElement")],p.prototype,"writeFromNetworkElement",null),o([r({type:n,json:{write:{target:{toGlobalId:{type:String},toNetworkSourceId:{type:Number},toTerminalId:{type:Number}}},read:{source:["toGlobalId","toNetworkSourceId","toTerminalId"]}}})],p.prototype,"toNetworkElement",void 0),o([t("toNetworkElement")],p.prototype,"readToNetworkElement",null),o([m("toNetworkElement")],p.prototype,"writeToNetworkElement",null),o([r({type:s,json:{write:!0}})],p.prototype,"geometry",void 0),p=o([l("esri.rest.networks.support.Association")],p);const a=p;export{a as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{JSONSupport as e}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{reader as t}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{writer as n}from"../../../core/accessorSupport/decorators/writer.js";import s from"./NetworkElement.js";import i from"../../../geometry/Polyline.js";let m=class extends e{constructor(o){super(o),this.globalId=null,this.associationType=null,this.fromNetworkElement=null,this.toNetworkElement=null,this.geometry=null,this.errorMessage=null,this.percentAlong=null,this.errorCode=null,this.isContentVisible=null,this.status=null}readFromNetworkElement(o,e){const r=new s;return r.globalId=e.fromGlobalId,r.networkSourceId=e.fromNetworkSourceId,r.terminalId=e.fromTerminalId,r}writeFromNetworkElement(o,e){o&&(e.fromGlobalId=o.globalId,e.fromNetworkSourceId=o.networkSourceId,e.fromTerminalId=o.terminalId)}readToNetworkElement(o,e){const r=new s;return r.globalId=e.toGlobalId,r.networkSourceId=e.toNetworkSourceId,r.terminalId=e.toTerminalId,r}writeToNetworkElement(o,e){o&&(e.toGlobalId=o.globalId,e.toNetworkSourceId=o.networkSourceId,e.toTerminalId=o.terminalId)}};o([r({type:String,json:{write:!0}})],m.prototype,"globalId",void 0),o([r({type:["attachment","connectivity","containment"],json:{write:!0}})],m.prototype,"associationType",void 0),o([r({type:s,json:{write:{target:{fromGlobalId:{type:String},fromNetworkSourceId:{type:Number},fromTerminalId:{type:Number}}},read:{source:["fromGlobalId","fromNetworkSourceId","fromTerminalId"]}}})],m.prototype,"fromNetworkElement",void 0),o([t("fromNetworkElement")],m.prototype,"readFromNetworkElement",null),o([n("fromNetworkElement")],m.prototype,"writeFromNetworkElement",null),o([r({type:s,json:{write:{target:{toGlobalId:{type:String},toNetworkSourceId:{type:Number},toTerminalId:{type:Number}}},read:{source:["toGlobalId","toNetworkSourceId","toTerminalId"]}}})],m.prototype,"toNetworkElement",void 0),o([t("toNetworkElement")],m.prototype,"readToNetworkElement",null),o([n("toNetworkElement")],m.prototype,"writeToNetworkElement",null),o([r({type:i,json:{write:!0}})],m.prototype,"geometry",void 0),o([r({type:String,json:{write:!0}})],m.prototype,"errorMessage",void 0),o([r({type:Number,json:{write:!0}})],m.prototype,"percentAlong",void 0),o([r({type:Number,json:{write:!0}})],m.prototype,"errorCode",void 0),o([r({type:Boolean,json:{write:!0}})],m.prototype,"isContentVisible",void 0),o([r({type:Number,json:{write:!0}})],m.prototype,"status",void 0),m=o([l("esri.rest.networks.support.Association")],m);const p=m;export{p as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{JSONSupport as t}from"../../../core/JSONSupport.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{associationTypeKebabDict as s}from"../../../networks/support/typeUtils.js";import p from"./NetworkElement.js";let i=class extends t{constructor(e){super(e),this.returnDeletes=!1,this.elements=[],this.associationTypes=[],this.gdbVersion=null,this.moment=null}};e([o({type:Boolean,json:{write:!0}})],i.prototype,"returnDeletes",void 0),e([o({type:[p],json:{write:!0}})],i.prototype,"elements",void 0),e([o({type:[s.apiValues],json:{type:s.jsonValues,read:s.read,write:s.write}})],i.prototype,"associationTypes",void 0),e([o({type:String,json:{write:!0}})],i.prototype,"gdbVersion",void 0),e([o({type:Date,json:{type:Number,write:{writer:(e,t)=>{t.moment=e?.getTime()}}}})],i.prototype,"moment",void 0),i=e([r("esri.rest.networks.support.QueryAssociationsParameters")],i);const n=i;export{n as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
+ */
5
+ import{_ as s}from"../../../chunks/tslib.es6.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import e from"./Association.js";let p=class extends o{constructor(s){super(s),this.associations=[]}};s([r({type:[e],json:{write:!0}})],p.prototype,"associations",void 0),p=s([t("esri.rest.networks.support.QueryAssociationsResult")],p);const c=p;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{pickRandom as t}from"../../../core/arrayUtils.js";import r from"../../../core/Error.js";import a from"../../../core/Logger.js";import{unwrap as i}from"../../../core/maybe.js";import{timeout as s,eachAlways as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{whenOnce as l}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{toQuantizationTransform as c}from"../../../geometry/support/quantizationUtils.js";import{isHostedAgolService as p}from"../../../layers/support/arcgisLayerUrl.js";import{kebabDict as h}from"../../../layers/support/fieldType.js";import{isStringField as d,isNumericField as y,isDateField as f}from"../../../layers/support/fieldUtils.js";import F from"../../../rest/support/GenerateRendererParameters.js";import g from"../../../rest/support/QuantizationParameters.js";import S from"../../../rest/support/StatisticDefinition.js";import w from"../../../rest/support/UniqueValueDefinition.js";import{getArcadeForPredominantCategory as v,getSQLForPredominantCategoryName as x}from"../../statistics/support/predominanceUtils.js";import{summaryStatistics as _,uniqueValues as z,histogram as q,classBreaks as V,heatmapStatistics as T}from"../../statistics/support/statsWorker.js";import{getRangeExpr as E,getSQLFilterForNormalization as L,mergeWhereClauses as j}from"../../statistics/support/utils.js";import{WorkerClient as C}from"../../statistics/support/WorkerClient.js";import{getFieldsList as Q}from"../utils.js";import M from"./LayerAdapter.js";import{ensureFeaturesJSON as N,msSinceUnixEpochSQL as b,getFieldExpr as B,getSummaryStatisticsFromFeatureSet as k,getViewInfoParams as P,getMissingFields as O,getUniqueValuesFromFeatureSet as I,getHistogramFromFeatureSet as R,generateBinParams as D,getPredominantCategoriesFromUVInfos as G}from"./support/utils.js";import{processSummaryStatisticsResult as J,isNullCountSupported as U,statisticTypes as A,createUVResult as W,getEqualIntervalBins as $,createClassBreaksDefinition as H,resolveCBResult as Z}from"../../../statistics/utils.js";import K from"../../../tasks/GenerateRendererTask.js";const X=a.getLogger("esri.smartMapping.support.adapters.FeatureLayerAdapter"),Y=5,ee=10,te=2e4,re=4e5;let ae=class extends M{constructor(e){super(e)}destroy(){this._hasLocalSource=null,this.workerClient?.destroy()}_isStatsSupportedOnService(){const e=this.layer;return!e.get("capabilities.query.supportsStatistics")||"multipatch"===this.geometryType&&!p(e.url)&&e.version<10.5?Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support statistics query")):Promise.resolve()}async _waitForLayerViewUpdate(e){if(!e)throw new r("feature-layer-adapter:insufficient-data","layerView is required to fetch the features");const t=new AbortController,a=l((()=>!e.updating),t.signal);await s(a,5e3,t).catch((e=>{throw X.warn("LayerView is taking too long to update. Aborting fetch from layerView."),e}))}async _fetchFeaturesFromMemory(e,t,r,a){const i=this.layer,s="json"===a;if(this._hasLocalSource){const e=await i.queryFeatures(t);return s?N(e.features):e.features}if(await this._waitForLayerViewUpdate(e),s&&"queryFeaturesJSON"in e&&e.queryFeaturesJSON){const{features:a}=await e.queryFeaturesJSON(t,{signal:r});return a}const n=await e.queryFeatures(t,{signal:r});return s?N(n.features):n.features}_fetchFeaturesFromService(e,t){return this.layer.queryFeatures(e,{signal:t}).then((e=>e.features))}_fetchFeaturesJSONFromService(e,t){return this._fetchFeaturesFromService(e,t).then(N)}_fetchFeaturesForStats(e,t){return Q({field:e.field,normalizationField:e.normalizationField,valueExpression:e.valueExpression}).then((r=>this.getSampleFeatures({sampleSize:-1,view:e.view,returnGeometry:e.returnGeometry,requiredFields:r,signal:e.signal},t)))}_summaryStatsFromGenRend(e){const t=e.normalizationType,r=e.normalizationField;return this.classBreaks({field:e.field,numClasses:Y,classificationMethod:"standard-deviation",standardDeviationInterval:.25,normalizationType:t,normalizationField:"field"===t?r:void 0,minValue:e.minValue,maxValue:e.maxValue,signal:e.signal}).then((e=>{let t,r,a;if(e.classBreakInfos.some((e=>(e.hasAvg&&(t=e),!!t))),t){const e=t.maxValue-t.minValue;r=t.minValue+e/2,a=4*e}const i={min:e.minValue,max:e.maxValue,avg:r,stddev:a};return J(i)}))}_getSummaryStatsQuery(e,t){const{field:r,normalizationType:a,normalizationField:i,normalizationTotal:s,minValue:n,maxValue:o}=e,l=this.supportsSQLExpression&&t?b(this,r):e.sqlExpression,u=B({field:r,normalizationType:a,normalizationField:i,normalizationTotal:s,layer:this}),m=l||u,c=m?E(m,n,o):null,p=L({field:r,normalizationField:i,normalizationType:a}),h=j(e.sqlWhere,p),y=j(h,c),f=U({normalizationField:i,normalizationType:a,sqlExpression:l,supportsSQLExpression:this.supportsSQLExpression,minValue:n,maxValue:o}),F=d(this.getField(r)),g=A.filter((e=>"nullcount"===e?f:!F||"count"===e)),w=this.layer.createQuery();return w.where=j(w.where,y),w.sqlFormat=l?"standard":null,w.outStatistics=g.map((e=>{const t=new S;let r=null,a=null,i=`${e}_value`;return"variance"===e?(r="var",a=m):"nullcount"===e?(r="count",a=this.layer.objectIdField,i="totalcount_value"):"median"===e?(r="percentile-continuous",a=m,t.statisticParameters={value:.5}):(r=e,a=m),t.statisticType=r,t.onStatisticField=a,t.outStatisticFieldName=i,t})),w}async _summaryStatsFromServiceQuery(e,t){await this._isStatsSupportedOnService(),"percent-of-total"===e.normalizationType&&(e.normalizationTotal=await this._getNormalizationTotal(e.field,e.normalizationType));const r=this._getSummaryStatsQuery(e,t),a=await this.layer.queryFeatures(r,{signal:e.signal}),i=k(a,t);return J(i)}async _summaryStatsFromClientQuery(e,t){const r=this._getSummaryStatsQuery(e,t),a=await this.layer.queryFeatures(r,{signal:e.signal}),i=k(a,t);return J(i)}async _getNormalizationTotalFromMemory(e,t,a){const{featuresJSON:i,graphics:s,layerView:n,query:o}=t,l=(!i&&!s&&n&&"querySummaryStatistics"in n?await n.querySummaryStatistics(o,{field:e},{signal:a}):i?await this.workerClient.summaryStatistics({field:e},i):await _({attribute:{field:e},features:s})).sum;if(null==l)throw new r("feature-layer-adapter:invalid","invalid normalizationTotal");return l}async _summaryStatsFromMemory(e,t){const{view:r,field:a,valueExpression:i,normalizationType:s,signal:n}=e,o={field:a,valueExpression:i,normalizationType:s,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue},{featuresJSON:l,graphics:u,layerView:m,query:c}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"querySummaryStatistics"});return i&&r&&(l||u)&&(o.fieldType=t?.type?h.toJSON(t.type):null,o.viewInfoParams=P(r)),"percent-of-total"===s&&null==e.normalizationTotal&&(o.normalizationTotal=await this._getNormalizationTotalFromMemory(a,{featuresJSON:l,graphics:u,layerView:m,query:c},n)),!l&&!u&&m&&"querySummaryStatistics"in m?m.querySummaryStatistics(c,o,{signal:n}):l?this.workerClient.summaryStatistics(o,l):_({attribute:o,features:u})}async _processStatsFromMemoryParams(e){const t=e.features;if(t?.length){return t.length&&"declaredClass"in t[0]&&"esri.Graphic"===t[0].declaredClass?{graphics:t}:{featuresJSON:t}}const{view:a,field:i,normalizationField:s,valueExpression:n,returnGeometry:o,layerViewFunc:l,signal:u}=e;let m=null,c=null,p=null,h=null;if(a)try{m=await a.whenLayerView(this.layer),c=l in m&&"function"==typeof m[l]}catch{c=!1}if(c)try{await this._waitForLayerViewUpdate(m);const e=await Q({field:i,normalizationField:s,valueExpression:n});(await O(this,e,m)).length?c=!1:(p=this.layer.createQuery(),p.outFields=e,p.returnGeometry=!1),m.suspended&&(c=!1)}catch{c=!1}if(!c&&(h=await this._fetchFeaturesForStats({field:i,valueExpression:n,normalizationField:s,returnGeometry:o,view:a,signal:u},"json"),!h?.length))throw new r("feature-layer-adapter:insufficient-data","No features are available to calculate statistics");return{layerView:m,query:p,featuresJSON:h}}_uvFromGenRenderer(e,t){const r=e.field,a=new w;a.attributeField=r;const i=new F;return i.classificationDefinition=a,this.generateRenderer(i,e.signal).then((e=>{const t={},a=this.getField(r);return e.uniqueValues.forEach((e=>{let r=e.value;null!=r&&""!==r&&("string"!=typeof r||""!==r.trim()&&"<null>"!==r.toLowerCase())||(r=null),null==t[r]?t[r]={count:e.count,data:y(a)&&r?Number(r):r}:t[r].count=t[r].count+e.count})),{count:t}})).then((r=>W(r,t,e.returnAllCodedValues)))}_getUVQuery(e){const t=e.field,r=e.sqlExpression,a="countOF"+(t||"Expr"),i=new S;i.statisticType="count",i.onStatisticField=r?"1":t,i.outStatisticFieldName=a;const s=this.layer.createQuery();return s.where=j(s.where,e.sqlWhere),s.sqlFormat=r?"standard":null,s.outStatistics=[i],s.groupByFieldsForStatistics=[t||r],s}_uvFromServiceQuery(e,t){return this._isStatsSupportedOnService().then((()=>this.layer.queryFeatures(this._getUVQuery(e),{signal:e.signal}))).then((t=>I(t,this,e.field,e.view,null,e.signal))).then((r=>W(r,t,e.returnAllCodedValues)))}async _uvFromClientQuery(e,t){const{signal:r}=e,a=this._getUVQuery(e),i=await this.layer.queryFeatures(a,{signal:r}),s=await I(i,this,e.field,e.view,null,r);return W(s,t,e.returnAllCodedValues)}async _uvFromMemory(e,t){const{view:r,field:a,valueExpression:i,returnAllCodedValues:s,signal:n}=e,{featuresJSON:o,graphics:l,layerView:u,query:m}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryUniqueValues"}),c={field:a,valueExpression:i,domain:t,returnAllCodedValues:s};return i&&r&&o&&(c.viewInfoParams=P(r)),!o&&!l&&u&&"queryUniqueValues"in u?u.queryUniqueValues(m,c,{signal:n}):o?this.workerClient.uniqueValues(c,o):z({attribute:c,features:l})}_calcBinsSQL(e,t,r){const a=[],i=t.length;return t.forEach(((t,s)=>{const[n,o]=t;let l=null;l=0!==s||r?s!==i-1||r?j(`${e} >= ${n}`,`${e} ${s===i-1?" <= ":" < "} ${o}`):`${e} >= ${n}`:`${e} < ${o}`,a.push("WHEN ("+l+") THEN "+(s+1))})),["CASE",a.join(" "),"ELSE 0","END"].join(" ")}_getNormalizationTotal(e,t,r){return e&&"percent-of-total"===t?this.summaryStatistics({field:e,signal:r}).then((e=>e.sum)):Promise.resolve(null)}_getQueryParamsForExpr(e,t){const r=e.valueExpression||e.sqlExpression,a=e.signal;if(!r){const{field:r,normalizationType:i,normalizationField:s}=e,n=r?this.getField(r):null,o=f(n),l={field:r,normalizationType:i,normalizationField:s,normalizationTotal:t,layer:this};return{sqlExpression:o?b(this,r):B(l),sqlWhere:o?null:e.sqlWhere||L({field:r,normalizationType:i,normalizationField:s}),signal:a}}return{valueExpression:e.valueExpression,sqlExpression:e.sqlExpression,sqlWhere:e.sqlWhere,signal:a}}_getDataRange(e,t,r){return null!=t&&null!=r?Promise.resolve({min:t,max:r}):this.summaryStatistics(e).then((e=>({min:e.min,max:e.max})))}_histogramForExpr(e){return this._getNormalizationTotal(e.field,e.normalizationType,e.signal).then((t=>{const r=this._getQueryParamsForExpr(e,t);return this._getDataRange(r,e.minValue,e.maxValue).then((a=>{const{min:i,max:s}=a,n=e.numBins||ee,o=$(i,s,n),l=this._calcBinsSQL(r.sqlExpression,o,null!=e.minValue&&null!=e.maxValue),u=new S({statisticType:"count",outStatisticFieldName:"countOFExpr",onStatisticField:"1"}),m=this.layer.createQuery();return m.where=j(m.where,r.sqlWhere),m.sqlFormat="standard",m.outStatistics=[u],m.groupByFieldsForStatistics=[l],m.orderByFields=[l],this._isStatsSupportedOnService().then((()=>this.layer.queryFeatures(m,{signal:r.signal}))).then((e=>R(e,i,s,n,t)))}))}))}_histogramForField(e){let t=null;return t=null!=e.minValue&&null!=e.maxValue?Promise.resolve({min:e.minValue,max:e.maxValue}):this.summaryStatistics(e).then((e=>{if(!e.count)throw new r("feature-layer-adapter:insufficient-data","Either the layer has no features or none of the features have data for the field");return{min:e.min,max:e.max}})),t.then((t=>this._getBins({min:t.min,max:t.max},e.field,e.numBins,e.view,e.signal)))}_getBins(e,t,r=ee,a,i){const{min:s,max:n,normTotal:o,excludeZerosExpr:l}=e,u=e.intervals||$(s,n,r),m=e.sqlExpr||t;return this._queryBins(u,m,l,a,i).then((e=>({bins:e.map(((e,t)=>({minValue:u[t][0],maxValue:u[t][1],count:e.value}))),minValue:s,maxValue:n,normalizationTotal:o})))}_queryBins(e,t,r,a,i){const s=[],o=e.length;for(let n=0;n<o;n++){const a=j(r,j(t+" >= "+e[n][0],null!==e[n][1]?t+(n===o-1?" <= ":" < ")+e[n][1]:""));s.push(a)}return n(s.map((e=>this.queryFeatureCount({whereClause:e,view:a,signal:i}))))}_binParamsFromGenRend(e,t){const{field:r,normalizationType:a,normalizationField:i,signal:s}=e,n=L({field:r,normalizationType:a,normalizationField:i}),o=new F({classificationDefinition:H({field:r,normalizationType:a,normalizationField:i,classificationMethod:e.classificationMethod,standardDeviationInterval:e.standardDeviationInterval,breakCount:e.numBins||ee}),where:j(n,t)});return this.generateRenderer(o,s).then((e=>{const{normalizationTotal:t,classBreaks:s}=e;return D({field:r,normalizationType:a,normalizationField:i,normalizationTotal:t,classBreaks:s,where:n,layer:this})}))}async _histogramFromMemory(e){const{view:t,field:r,signal:a}=e,{featuresJSON:i,graphics:s,layerView:n,query:o}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryHistogram"}),l={field:r,valueExpression:e.valueExpression,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numBins:e.numBins};return e.valueExpression&&t&&i&&(l.viewInfoParams=P(t)),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(l.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:i,graphics:s,layerView:n,query:o},a)),!i&&!s&&n&&"queryHistogram"in n?n.queryHistogram(o,l,{signal:a}):i?this.workerClient.histogram(l,i):q({attribute:l,features:s})}_classBreaksFromGenRend(e){const{field:t,normalizationType:r,normalizationField:a,normalizationTotal:i,signal:s}=e,n=L({field:t,normalizationType:r,normalizationField:a}),o=B({field:t,normalizationType:r,normalizationField:a,normalizationTotal:i,layer:this}),l=E(o,e.minValue,e.maxValue),u=H({field:t,normalizationType:r,normalizationField:a,classificationMethod:e.classificationMethod,standardDeviationInterval:e.standardDeviationInterval,breakCount:e.numClasses||Y}),m=new F;return m.classificationDefinition=u,m.where=j(n,l),this.generateRenderer(m,s).then((t=>Z(t,e.classificationMethod)))}_classBreaksFromInterpolation(e){const{minValue:t,maxValue:r}=e,a=e.numClasses||Y,i=[],s=(r-t)/a;for(let l=0;l<a;l++){const e=t+l*s;i.push({minValue:e,maxValue:e+s})}i[a-1].maxValue=r;const n={classBreaks:i,normalizationTotal:e.normalizationTotal},o=Z(n,e.classificationMethod);return Promise.resolve(o)}async _classBreaksFromMemory(e){const{view:t,field:r,signal:a}=e,{featuresJSON:i,graphics:s,layerView:n,query:o}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryClassBreaks"}),l={field:r,valueExpression:e.valueExpression,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numClasses:e.numClasses};return e.valueExpression&&t&&i&&(l.viewInfoParams=P(t)),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(l.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:i,graphics:s,layerView:n,query:o},a)),!i&&!s&&n&&"queryClassBreaks"in n?n.queryClassBreaks(o,l,{signal:a}):i?this.workerClient.classBreaks(l,i):V({attribute:l,features:s})}async _heatmapStatsFromMemory(e,t){const{view:r,field:a,radius:i}=e,{featuresJSON:s,graphics:n}=await this._processStatsFromMemoryParams({...e,returnGeometry:!0}),o=new g({extent:r.extent,tolerance:"2d"===r.type?r.state.resolution:1}),l={field:a,fieldOffset:t,radius:i,transform:c(o),spatialReference:r.spatialReference?.toJSON(),size:r.size};return s?.length||n?.length?s?this.workerClient.heatmapStatistics(l,s):T({attribute:l,features:n}):{count:0,min:null,max:null,avg:null,stddev:null}}getField(e=""){return this.layer.getField(e)}getFieldUsageInfo(e){return this.getField(e)?{supportsLabelingInfo:!0,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:!0,supportsStatistics:!0}:null}getFieldDomain(e,t){return this.layer.getFieldDomain(e,t)}summaryStatistics(e){const{field:t,normalizationType:a,sqlExpression:i,view:s,features:n,useFeaturesInView:l}=e,u=t?this.getField(t):null,m=f(u),c=e.valueExpression||i,p=c&&!i,h=this._hasLocalSource||n||l,d=s&&"3d"===s.type;if(h||p)return p||n||l||d?this._summaryStatsFromMemory(e,u):this._summaryStatsFromClientQuery(e,m);if(!this.supportsSQLExpression&&(m||c||"natural-log"===a||"square-root"===a))return Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support standardized SQL expression for queries"));return(a&&!this.supportsSQLExpression?this._summaryStatsFromGenRend(e):this._summaryStatsFromServiceQuery(e,m)).catch((()=>(o(e.signal),this._summaryStatsFromMemory(e,u))))}uniqueValues(e){const{field:t,valueExpression:r,sqlExpression:a,features:i,useFeaturesInView:s,signal:n}=e,l=(t?this.getField(t):null)&&this.getFieldDomain(t),u=r&&(!a||!this.supportsSQLExpression),m=this._hasLocalSource||i||s||u,c=e.view,p=c&&"3d"===c.type;return m?u||i||s||p?this._uvFromMemory(e,l):this._uvFromClientQuery(e,l):this._uvFromServiceQuery(e,l).catch((t=>(o(n),e.field?this._uvFromGenRenderer(e,l):t))).catch((()=>(o(n),p?this._uvFromMemory(e,l):this._uvFromClientQuery(e,l))))}histogram(e){const{field:t,normalizationType:a,normalizationField:i,classificationMethod:s,view:n,signal:o}=e,l=t?this.getField(t):null,u=f(l),m=e.valueExpression||e.sqlExpression,c=m&&!e.sqlExpression,p=this._hasLocalSource||e.features||e.useFeaturesInView||c,h=this.supportsSQLExpression,d=!s||"equal-interval"===s,y=e.minValue,F=e.maxValue,g=null!=y&&null!=F,S=e.numBins||ee;return p?this._histogramFromMemory(e):(m||h)&&d?h||!m&&"natural-log"!==a&&"square-root"!==a?this._histogramForExpr(e):Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support standardized SQL expression for queries")):u&&d?Promise.reject(new r("feature-layer-adapter:not-supported","Normalization and date field are not allowed when layer does not support standardized SQL expression for queries")):a||!d?this._binParamsFromGenRend(e).then((s=>{if(!g)return this._getBins(s,t,S,n,o);if(y>s.max||F<s.min)throw new r("histogram:insufficient-data","Range defined by 'minValue' and 'maxValue' does not intersect available data range of the field");if(d)return this._getBins({min:y,max:F,sqlExpr:s.sqlExpr,excludeZerosExpr:s.excludeZerosExpr},t,S,n,o);{const r={field:t,normalizationType:a,normalizationField:i,normalizationTotal:s.normTotal,layer:this},l=B(r),u=E(l,y,F);return this._binParamsFromGenRend(e,u).then((e=>this._getBins(e,t,S,n,o)))}})):this._histogramForField(e)}classBreaks(e){const t=!1!==e.analyzeData,r=this._hasLocalSource||e.features||e.useFeaturesInView||e.valueExpression;if(t&&r)return this._classBreaksFromMemory(e);return(t?this._classBreaksFromGenRend(e):this._classBreaksFromInterpolation(e)).catch((()=>(o(e.signal),this._classBreaksFromMemory(e))))}queryFeatureCount(e){if(this._hasLocalSource)return Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support count query"));const t=this.layer,a=t.createQuery();return a.where=j(a.where,e.whereClause),t.queryFeatureCount(a,{signal:e.signal})}generateRenderer(e,t){const a=this.layer;if(this._hasLocalSource||a.version<10.1)return Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support generateRenderer operation (requires ArcGIS Server version 10.1+)"));const i=new K({url:a.parsedUrl.path,source:a.dynamicDataSource,gdbVersion:a.gdbVersion}),s=a.createQuery();return e.where=j(e.where,s.where),i.execute(e,{signal:t})}heatmapStatistics(e){const{field:t,fieldOffset:r,view:a,signal:i}=e;return(t&&null==r?this.summaryStatistics({field:t,view:a,signal:i}):Promise.resolve(null)).then((t=>{let a=r||0;if(t){const{count:e,min:r,max:i}=t;e?r===i&&0===r?a=1:i<=0?a="abs":r<0&&(a=-1.01*r):a=1}return this._heatmapStatsFromMemory(e,a).then((e=>({...e,summaryStatistics:t,fieldOffset:a})))}))}async predominantCategories(e){if(!this._hasLocalSource&&!this.supportsSQLExpression)throw new r("feature-layer-adapter:not-supported","Layer does not support advanced SQL expressions and standardized queries");const{fields:t,view:a,signal:i}=e,s=v(t),n=x(t),o=a&&this._hasLocalSource?await this._uvFromMemory({valueExpression:s,view:a,signal:i}):await this._uvFromServiceQuery({sqlExpression:n.expression,valueExpression:s,signal:i});return G(o.uniqueValueInfos,t)}async getSampleFeatures(e,r){const{view:a,sampleSize:i,requiredFields:s,returnGeometry:n,signal:l}=e,u=this.layer.createQuery(),m=1,c="json"===r;u.outSpatialReference=e.spatialReference||a&&a.spatialReference,u.returnGeometry=!!n,u.outFields=s;let p=[],h=!1;if(a)try{const e=await a.whenLayerView(this.layer);if(h=!(await O(this,s,e)).length,h&&(p=await this._fetchFeaturesFromMemory(e,u,l,r),p.length&&i>0&&i<=p.length))return t(p,i,m)}catch(d){o(l)}try{if(this._hasLocalSource)return h?p:c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l);const r=await this.queryFeatureCount({view:a,signal:l}),s=this.layer.capabilities.query.maxRecordCount;let n=-1===i?r:i;if(n=s&&n>s?s:n,r<=p.length||p.length>=s)return p;const o=a.extent.width/a.width/a.scale*re;if(u.maxAllowableOffset=e.resolution||o,r<=n)return c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l);if(r<=te){const e=await this.layer.queryObjectIds();return u.objectIds=t(e,n,m),c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l)}return this.layer.get("capabilities.query.supportsPagination")&&(u.num=Math.min(n,te)),c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l)}catch(d){return o(l),p}}load(e){const t=this.layer.load(e).then((async t=>{this.geometryType=t.geometryType,this.objectIdField=t.objectIdField,this.supportsSQLExpression=t.get("capabilities.query.supportsSqlExpression"),this._hasLocalSource=!t.url&&!!t.source,this.hasQueryEngine=this._hasLocalSource,this.minScale=t.minScale,this.maxScale=t.maxScale,this.fullExtent=t.fullExtent,this.workerClient=C.getInstance(),await this.workerClient.open(i(i(e).signal))}));return this.addResolvingPromise(t),Promise.resolve(this)}};e([u({constructOnly:!0})],ae.prototype,"layer",void 0),ae=e([m("esri.smartMapping.support.adapters.FeatureLayerAdapter")],ae);const ie=ae;export{ie as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{pickRandom as t}from"../../../core/arrayUtils.js";import r from"../../../core/Error.js";import a from"../../../core/Logger.js";import{unwrap as i}from"../../../core/maybe.js";import{timeout as s,eachAlways as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{whenOnce as l}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{toQuantizationTransform as c}from"../../../geometry/support/quantizationUtils.js";import{isHostedAgolService as p}from"../../../layers/support/arcgisLayerUrl.js";import{kebabDict as h}from"../../../layers/support/fieldType.js";import{isStringField as d,isNumericField as y,isDateField as f}from"../../../layers/support/fieldUtils.js";import F from"../../../rest/support/GenerateRendererParameters.js";import g from"../../../rest/support/QuantizationParameters.js";import S from"../../../rest/support/StatisticDefinition.js";import w from"../../../rest/support/UniqueValueDefinition.js";import{getArcadeForPredominantCategory as v,getSQLForPredominantCategoryName as x}from"../../statistics/support/predominanceUtils.js";import{summaryStatistics as _,uniqueValues as z,histogram as q,classBreaks as V,heatmapStatistics as T}from"../../statistics/support/statsWorker.js";import{getRangeExpr as E,getSQLFilterForNormalization as L,mergeWhereClauses as j}from"../../statistics/support/utils.js";import{WorkerClient as C}from"../../statistics/support/WorkerClient.js";import{getFieldsList as Q}from"../utils.js";import M from"./LayerAdapter.js";import{ensureFeaturesJSON as N,msSinceUnixEpochSQL as b,getFieldExpr as B,getSummaryStatisticsFromFeatureSet as O,getViewInfoParams as P,getMissingFields as k,getUniqueValuesFromFeatureSet as I,getHistogramFromFeatureSet as R,generateBinParams as D,getPredominantCategoriesFromUVInfos as G}from"./support/utils.js";import{processSummaryStatisticsResult as J,isNullCountSupported as U,statisticTypes as A,createUVResult as W,getEqualIntervalBins as $,createClassBreaksDefinition as H,resolveCBResult as Z}from"../../../statistics/utils.js";import K from"../../../tasks/GenerateRendererTask.js";const X=a.getLogger("esri.smartMapping.support.adapters.FeatureLayerAdapter"),Y=5,ee=10,te=2e4,re=4e5;let ae=class extends M{constructor(e){super(e)}destroy(){this._hasLocalSource=null,this.workerClient?.destroy()}_isStatsSupportedOnService(){const e=this.layer;return!e.get("capabilities.query.supportsStatistics")||"multipatch"===this.geometryType&&!p(e.url)&&e.version<10.5?Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support statistics query")):Promise.resolve()}async _waitForLayerViewUpdate(e){if(!e)throw new r("feature-layer-adapter:insufficient-data","layerView is required to fetch the features");const t=new AbortController,a=l((()=>!e.updating),t.signal);await s(a,5e3,t).catch((e=>{throw X.warn("LayerView is taking too long to update. Aborting fetch from layerView."),e}))}async _fetchFeaturesFromMemory(e,t,r,a){const i=this.layer,s="json"===a;if(this._hasLocalSource){const e=await i.queryFeatures(t);return s?N(e.features):e.features}if(await this._waitForLayerViewUpdate(e),s&&"queryFeaturesJSON"in e&&e.queryFeaturesJSON){const{features:a}=await e.queryFeaturesJSON(t,{signal:r});return a}const n=await e.queryFeatures(t,{signal:r});return s?N(n.features):n.features}_fetchFeaturesFromService(e,t){return this.layer.queryFeatures(e,{signal:t}).then((e=>e.features))}_fetchFeaturesJSONFromService(e,t){return this._fetchFeaturesFromService(e,t).then(N)}_fetchFeaturesForStats(e,t){return Q({field:e.field,normalizationField:e.normalizationField,valueExpression:e.valueExpression}).then((r=>this.getSampleFeatures({sampleSize:-1,view:e.view,returnGeometry:e.returnGeometry,requiredFields:r,signal:e.signal},t)))}_summaryStatsFromGenRend(e){const t=e.normalizationType,r=e.normalizationField;return this.classBreaks({field:e.field,numClasses:Y,classificationMethod:"standard-deviation",standardDeviationInterval:.25,normalizationType:t,normalizationField:"field"===t?r:void 0,minValue:e.minValue,maxValue:e.maxValue,signal:e.signal}).then((e=>{let t,r,a;if(e.classBreakInfos.some((e=>(e.hasAvg&&(t=e),!!t))),t){const e=t.maxValue-t.minValue;r=t.minValue+e/2,a=4*e}const i={min:e.minValue,max:e.maxValue,avg:r,stddev:a};return J(i)}))}_getSummaryStatsQuery(e,t){const{field:r,normalizationType:a,normalizationField:i,normalizationTotal:s,minValue:n,maxValue:o}=e,l=this.supportsSQLExpression&&t?b(this,r):e.sqlExpression,u=B({field:r,normalizationType:a,normalizationField:i,normalizationTotal:s,layer:this}),m=l||u,c=m?E(m,n,o):null,p=L({field:r,normalizationField:i,normalizationType:a}),h=j(e.sqlWhere,p),y=j(h,c),f=U({normalizationField:i,normalizationType:a,sqlExpression:l,supportsSQLExpression:this.supportsSQLExpression,minValue:n,maxValue:o}),F=d(this.getField(r)),g=A.filter((e=>"nullcount"===e?f:!F||"count"===e)),w=this.layer.createQuery();return w.where=j(w.where,y),w.sqlFormat=l?"standard":null,w.outStatistics=g.map((e=>{const t=new S;let r=null,a=null,i=`${e}_value`;return"variance"===e?(r="var",a=m):"nullcount"===e?(r="count",a=this.layer.objectIdField,i="totalcount_value"):"median"===e?(r="percentile-continuous",a=m,t.statisticParameters={value:.5}):(r=e,a=m),t.statisticType=r,t.onStatisticField=a,t.outStatisticFieldName=i,t})),w}async _summaryStatsFromServiceQuery(e,t){await this._isStatsSupportedOnService(),"percent-of-total"===e.normalizationType&&(e.normalizationTotal=await this._getNormalizationTotal(e.field,e.normalizationType));const r=this._getSummaryStatsQuery(e,t),a=await this.layer.queryFeatures(r,{signal:e.signal}),i=O(a,t);return J(i)}async _summaryStatsFromClientQuery(e,t){const r=this._getSummaryStatsQuery(e,t),a=await this.layer.queryFeatures(r,{signal:e.signal}),i=O(a,t);return J(i)}async _getNormalizationTotalFromMemory(e,t,a){const{featuresJSON:i,graphics:s,layerView:n,query:o}=t,l=(!i&&!s&&n&&"querySummaryStatistics"in n?await n.querySummaryStatistics(o,{field:e},{signal:a}):i?await this.workerClient.summaryStatistics({field:e},i):await _({attribute:{field:e},features:s})).sum;if(null==l)throw new r("feature-layer-adapter:invalid","invalid normalizationTotal");return l}async _summaryStatsFromMemory(e,t){const{view:r,field:a,valueExpression:i,normalizationType:s,signal:n}=e,o={field:a,valueExpression:i,normalizationType:s,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue},{featuresJSON:l,graphics:u,layerView:m,query:c}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"querySummaryStatistics"});return i&&r&&(l||u)&&(o.fieldType=t?.type?h.toJSON(t.type):null,o.viewInfoParams=P(r)),"percent-of-total"===s&&null==e.normalizationTotal&&(o.normalizationTotal=await this._getNormalizationTotalFromMemory(a,{featuresJSON:l,graphics:u,layerView:m,query:c},n)),!l&&!u&&m&&"querySummaryStatistics"in m?m.querySummaryStatistics(c,o,{signal:n}):l?this.workerClient.summaryStatistics(o,l):_({attribute:o,features:u})}async _processStatsFromMemoryParams(e){const t=e.features;if(t?.length){return t.length&&"declaredClass"in t[0]&&"esri.Graphic"===t[0].declaredClass?{graphics:t}:{featuresJSON:t}}const{view:a,field:i,normalizationField:s,valueExpression:n,returnGeometry:o,layerViewFunc:l,signal:u}=e;let m=null,c=null,p=null,h=null;if(a)try{m=await a.whenLayerView(this.layer),c=l in m&&"function"==typeof m[l]}catch{c=!1}if(c)try{await this._waitForLayerViewUpdate(m);const e=await Q({field:i,normalizationField:s,valueExpression:n});(await k(this,e,m)).length?c=!1:(p=this.layer.createQuery(),p.outFields=e,p.returnGeometry=!1),m.suspended&&(c=!1)}catch{c=!1}if(!c&&(h=await this._fetchFeaturesForStats({field:i,valueExpression:n,normalizationField:s,returnGeometry:o,view:a,signal:u},"json"),!h?.length))throw new r("feature-layer-adapter:insufficient-data","No features are available to calculate statistics");return{layerView:m,query:p,featuresJSON:h}}_uvFromGenRenderer(e,t){const r=e.field,a=new w;a.attributeField=r;const i=new F;return i.classificationDefinition=a,this.generateRenderer(i,e.signal).then((e=>{const t={},a=this.getField(r);return e.uniqueValues.forEach((e=>{let r=e.value;null!=r&&""!==r&&("string"!=typeof r||""!==r.trim()&&"<null>"!==r.toLowerCase())||(r=null),null==t[r]?t[r]={count:e.count,data:y(a)&&r?Number(r):r}:t[r].count=t[r].count+e.count})),{count:t}})).then((r=>W(r,t,e.returnAllCodedValues)))}_getUVQuery(e){const t=e.field,r=e.sqlExpression,a="countOF"+(t||"Expr"),i=new S;i.statisticType="count",i.onStatisticField=r?"1":t,i.outStatisticFieldName=a;const s=this.layer.createQuery();return s.where=j(s.where,e.sqlWhere),s.sqlFormat=r?"standard":null,s.outStatistics=[i],s.groupByFieldsForStatistics=[t||r],s}_uvFromServiceQuery(e,t){return this._isStatsSupportedOnService().then((()=>this.layer.queryFeatures(this._getUVQuery(e),{signal:e.signal}))).then((t=>I(t,this,e.field,e.view,null,e.signal))).then((r=>W(r,t,e.returnAllCodedValues)))}async _uvFromClientQuery(e,t){const{signal:r}=e,a=this._getUVQuery(e),i=await this.layer.queryFeatures(a,{signal:r}),s=await I(i,this,e.field,e.view,null,r);return W(s,t,e.returnAllCodedValues)}async _uvFromMemory(e,t){const{view:r,field:a,valueExpression:i,returnAllCodedValues:s,signal:n}=e,{featuresJSON:o,graphics:l,layerView:u,query:m}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryUniqueValues"}),c={field:a,valueExpression:i,domain:t,returnAllCodedValues:s};return i&&r&&o&&(c.viewInfoParams=P(r)),!o&&!l&&u&&"queryUniqueValues"in u?u.queryUniqueValues(m,c,{signal:n}):o?this.workerClient.uniqueValues(c,o):z({attribute:c,features:l})}_calcBinsSQL(e,t,r){const a=[],i=t.length;return t.forEach(((t,s)=>{const[n,o]=t;let l=null;l=0!==s||r?s!==i-1||r?j(`${e} >= ${n}`,`${e} ${s===i-1?" <= ":" < "} ${o}`):`${e} >= ${n}`:`${e} < ${o}`,a.push("WHEN ("+l+") THEN "+(s+1))})),["CASE",a.join(" "),"ELSE 0","END"].join(" ")}_getNormalizationTotal(e,t,r){return e&&"percent-of-total"===t?this.summaryStatistics({field:e,signal:r}).then((e=>e.sum)):Promise.resolve(null)}_getQueryParamsForExpr(e,t){const r=e.valueExpression||e.sqlExpression,a=e.signal;if(!r){const{field:r,normalizationType:i,normalizationField:s}=e,n=r?this.getField(r):null,o=f(n),l={field:r,normalizationType:i,normalizationField:s,normalizationTotal:t,layer:this};return{sqlExpression:o?b(this,r):B(l),sqlWhere:o?null:e.sqlWhere||L({field:r,normalizationType:i,normalizationField:s}),signal:a}}return{valueExpression:e.valueExpression,sqlExpression:e.sqlExpression,sqlWhere:e.sqlWhere,signal:a}}_getDataRange(e,t,r){return null!=t&&null!=r?Promise.resolve({min:t,max:r}):this.summaryStatistics(e).then((e=>({min:e.min,max:e.max})))}_histogramForExpr(e){return this._getNormalizationTotal(e.field,e.normalizationType,e.signal).then((t=>{const r=this._getQueryParamsForExpr(e,t);return this._getDataRange(r,e.minValue,e.maxValue).then((a=>{const{min:i,max:s}=a,n=e.numBins||ee,o=$(i,s,n),l=this._calcBinsSQL(r.sqlExpression,o,null!=e.minValue&&null!=e.maxValue),u=new S({statisticType:"count",outStatisticFieldName:"countOFExpr",onStatisticField:"1"}),m=this.layer.createQuery();return m.where=j(m.where,r.sqlWhere),m.sqlFormat="standard",m.outStatistics=[u],m.groupByFieldsForStatistics=[l],m.orderByFields=[l],this._isStatsSupportedOnService().then((()=>this.layer.queryFeatures(m,{signal:r.signal}))).then((e=>R(e,i,s,n,t)))}))}))}_histogramForField(e){let t=null;return t=null!=e.minValue&&null!=e.maxValue?Promise.resolve({min:e.minValue,max:e.maxValue}):this.summaryStatistics(e).then((e=>{if(!e.count)throw new r("feature-layer-adapter:insufficient-data","Either the layer has no features or none of the features have data for the field");return{min:e.min,max:e.max}})),t.then((t=>this._getBins({min:t.min,max:t.max},e.field,e.numBins,e.view,e.signal)))}_getBins(e,t,r=ee,a,i){const{min:s,max:n,normTotal:o,excludeZerosExpr:l}=e,u=e.intervals||$(s,n,r),m=e.sqlExpr||t;return this._queryBins(u,m,l,a,i).then((e=>({bins:e.map(((e,t)=>({minValue:u[t][0],maxValue:u[t][1],count:e.value}))),minValue:s,maxValue:n,normalizationTotal:o})))}_queryBins(e,t,r,a,i){const s=[],o=e.length;for(let n=0;n<o;n++){const a=j(r,j(t+" >= "+e[n][0],null!==e[n][1]?t+(n===o-1?" <= ":" < ")+e[n][1]:""));s.push(a)}return n(s.map((e=>this.queryFeatureCount({whereClause:e,view:a,signal:i}))))}_binParamsFromGenRend(e,t){const{field:r,normalizationType:a,normalizationField:i,signal:s}=e,n=L({field:r,normalizationType:a,normalizationField:i}),o=new F({classificationDefinition:H({field:r,normalizationType:a,normalizationField:i,classificationMethod:e.classificationMethod,standardDeviationInterval:e.standardDeviationInterval,breakCount:e.numBins||ee}),where:j(n,t)});return this.generateRenderer(o,s).then((e=>{const{normalizationTotal:t,classBreaks:s}=e;return D({field:r,normalizationType:a,normalizationField:i,normalizationTotal:t,classBreaks:s,where:n,layer:this})}))}async _histogramFromMemory(e){const{view:t,field:r,signal:a}=e,{featuresJSON:i,graphics:s,layerView:n,query:o}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryHistogram"}),l={field:r,valueExpression:e.valueExpression,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numBins:e.numBins};return e.valueExpression&&t&&i&&(l.viewInfoParams=P(t)),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(l.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:i,graphics:s,layerView:n,query:o},a)),!i&&!s&&n&&"queryHistogram"in n?n.queryHistogram(o,l,{signal:a}):i?this.workerClient.histogram(l,i):q({attribute:l,features:s})}_classBreaksFromGenRend(e){const{field:t,normalizationType:r,normalizationField:a,normalizationTotal:i,signal:s}=e,n=L({field:t,normalizationType:r,normalizationField:a}),o=B({field:t,normalizationType:r,normalizationField:a,normalizationTotal:i,layer:this}),l=E(o,e.minValue,e.maxValue),u=H({field:t,normalizationType:r,normalizationField:a,classificationMethod:e.classificationMethod,standardDeviationInterval:e.standardDeviationInterval,breakCount:e.numClasses||Y}),m=new F;return m.classificationDefinition=u,m.where=j(n,l),this.generateRenderer(m,s).then((t=>Z(t,e.classificationMethod)))}_classBreaksFromInterpolation(e){const{minValue:t,maxValue:r}=e,a=e.numClasses||Y,i=[],s=(r-t)/a;for(let l=0;l<a;l++){const e=t+l*s;i.push({minValue:e,maxValue:e+s})}i[a-1].maxValue=r;const n={classBreaks:i,normalizationTotal:e.normalizationTotal},o=Z(n,e.classificationMethod);return Promise.resolve(o)}async _classBreaksFromMemory(e){const{view:t,field:r,signal:a}=e,{featuresJSON:i,graphics:s,layerView:n,query:o}=await this._processStatsFromMemoryParams({...e,layerViewFunc:"queryClassBreaks"}),l={field:r,valueExpression:e.valueExpression,normalizationType:e.normalizationType,normalizationField:e.normalizationField,normalizationTotal:e.normalizationTotal,minValue:e.minValue,maxValue:e.maxValue,standardDeviationInterval:e.standardDeviationInterval,classificationMethod:e.classificationMethod,numClasses:e.numClasses};return e.valueExpression&&t&&i&&(l.viewInfoParams=P(t)),"percent-of-total"===e.normalizationType&&null==e.normalizationTotal&&(l.normalizationTotal=await this._getNormalizationTotalFromMemory(r,{featuresJSON:i,graphics:s,layerView:n,query:o},a)),!i&&!s&&n&&"queryClassBreaks"in n?n.queryClassBreaks(o,l,{signal:a}):i?this.workerClient.classBreaks(l,i):V({attribute:l,features:s})}async _heatmapStatsFromMemory(e,t){const{view:r,field:a,radius:i}=e,{featuresJSON:s,graphics:n}=await this._processStatsFromMemoryParams({...e,returnGeometry:!0}),o=new g({extent:r.extent,tolerance:"2d"===r.type?r.state.resolution:r.overlayPixelSizeInMapUnits(r.pointsOfInterest.centerOnSurfaceFrequent.location)}),l={field:a,fieldOffset:t,radius:i,transform:c(o),spatialReference:r.spatialReference?.toJSON(),size:r.size};return s?.length||n?.length?s?this.workerClient.heatmapStatistics(l,s):T({attribute:l,features:n}):{count:0,min:null,max:null,avg:null,stddev:null}}getField(e=""){return this.layer.getField(e)}getFieldUsageInfo(e){return this.getField(e)?{supportsLabelingInfo:!0,supportsRenderer:!0,supportsPopupTemplate:!0,supportsLayerQuery:!0,supportsStatistics:!0}:null}getFieldDomain(e,t){return this.layer.getFieldDomain(e,t)}summaryStatistics(e){const{field:t,normalizationType:a,sqlExpression:i,view:s,features:n,useFeaturesInView:l}=e,u=t?this.getField(t):null,m=f(u),c=e.valueExpression||i,p=c&&!i,h=this._hasLocalSource||n||l,d=s&&"3d"===s.type;if(h||p)return p||n||l||d?this._summaryStatsFromMemory(e,u):this._summaryStatsFromClientQuery(e,m);if(!this.supportsSQLExpression&&(m||c||"natural-log"===a||"square-root"===a))return Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support standardized SQL expression for queries"));return(a&&!this.supportsSQLExpression?this._summaryStatsFromGenRend(e):this._summaryStatsFromServiceQuery(e,m)).catch((()=>(o(e.signal),this._summaryStatsFromMemory(e,u))))}uniqueValues(e){const{field:t,valueExpression:r,sqlExpression:a,features:i,useFeaturesInView:s,signal:n}=e,l=(t?this.getField(t):null)&&this.getFieldDomain(t),u=r&&(!a||!this.supportsSQLExpression),m=this._hasLocalSource||i||s||u,c=e.view,p=c&&"3d"===c.type;return m?u||i||s||p?this._uvFromMemory(e,l):this._uvFromClientQuery(e,l):this._uvFromServiceQuery(e,l).catch((t=>(o(n),e.field?this._uvFromGenRenderer(e,l):t))).catch((()=>(o(n),p?this._uvFromMemory(e,l):this._uvFromClientQuery(e,l))))}histogram(e){const{field:t,normalizationType:a,normalizationField:i,classificationMethod:s,view:n,signal:o}=e,l=t?this.getField(t):null,u=f(l),m=e.valueExpression||e.sqlExpression,c=m&&!e.sqlExpression,p=this._hasLocalSource||e.features||e.useFeaturesInView||c,h=this.supportsSQLExpression,d=!s||"equal-interval"===s,y=e.minValue,F=e.maxValue,g=null!=y&&null!=F,S=e.numBins||ee;return p?this._histogramFromMemory(e):(m||h)&&d?h||!m&&"natural-log"!==a&&"square-root"!==a?this._histogramForExpr(e):Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support standardized SQL expression for queries")):u&&d?Promise.reject(new r("feature-layer-adapter:not-supported","Normalization and date field are not allowed when layer does not support standardized SQL expression for queries")):a||!d?this._binParamsFromGenRend(e).then((s=>{if(!g)return this._getBins(s,t,S,n,o);if(y>s.max||F<s.min)throw new r("histogram:insufficient-data","Range defined by 'minValue' and 'maxValue' does not intersect available data range of the field");if(d)return this._getBins({min:y,max:F,sqlExpr:s.sqlExpr,excludeZerosExpr:s.excludeZerosExpr},t,S,n,o);{const r={field:t,normalizationType:a,normalizationField:i,normalizationTotal:s.normTotal,layer:this},l=B(r),u=E(l,y,F);return this._binParamsFromGenRend(e,u).then((e=>this._getBins(e,t,S,n,o)))}})):this._histogramForField(e)}classBreaks(e){const t=!1!==e.analyzeData,r=this._hasLocalSource||e.features||e.useFeaturesInView||e.valueExpression;if(t&&r)return this._classBreaksFromMemory(e);return(t?this._classBreaksFromGenRend(e):this._classBreaksFromInterpolation(e)).catch((()=>(o(e.signal),this._classBreaksFromMemory(e))))}queryFeatureCount(e){if(this._hasLocalSource)return Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support count query"));const t=this.layer,a=t.createQuery();return a.where=j(a.where,e.whereClause),t.queryFeatureCount(a,{signal:e.signal})}generateRenderer(e,t){const a=this.layer;if(this._hasLocalSource||a.version<10.1)return Promise.reject(new r("feature-layer-adapter:not-supported","Layer does not support generateRenderer operation (requires ArcGIS Server version 10.1+)"));const i=new K({url:a.parsedUrl.path,source:a.dynamicDataSource,gdbVersion:a.gdbVersion}),s=a.createQuery();return e.where=j(e.where,s.where),i.execute(e,{signal:t})}heatmapStatistics(e){const{field:t,fieldOffset:r,view:a,signal:i}=e;return(t&&null==r?this.summaryStatistics({field:t,view:a,signal:i}):Promise.resolve(null)).then((t=>{let a=r||0;if(t){const{count:e,min:r,max:i}=t;e?r===i&&0===r?a=1:i<=0?a="abs":r<0&&(a=-1.01*r):a=1}return this._heatmapStatsFromMemory(e,a).then((e=>({...e,summaryStatistics:t,fieldOffset:a})))}))}async predominantCategories(e){if(!this._hasLocalSource&&!this.supportsSQLExpression)throw new r("feature-layer-adapter:not-supported","Layer does not support advanced SQL expressions and standardized queries");const{fields:t,view:a,signal:i}=e,s=v(t),n=x(t),o=a&&this._hasLocalSource?await this._uvFromMemory({valueExpression:s,view:a,signal:i}):await this._uvFromServiceQuery({sqlExpression:n.expression,valueExpression:s,signal:i});return G(o.uniqueValueInfos,t)}async getSampleFeatures(e,r){const{view:a,sampleSize:i,requiredFields:s,returnGeometry:n,signal:l}=e,u=this.layer.createQuery(),m=1,c="json"===r;u.outSpatialReference=e.spatialReference||a&&a.spatialReference,u.returnGeometry=!!n,u.outFields=s;let p=[],h=!1;if(a)try{const e=await a.whenLayerView(this.layer);if(h=!(await k(this,s,e)).length,h&&(p=await this._fetchFeaturesFromMemory(e,u,l,r),p.length&&i>0&&i<=p.length))return t(p,i,m)}catch(d){o(l)}try{if(this._hasLocalSource)return h?p:c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l);const r=await this.queryFeatureCount({view:a,signal:l}),s=this.layer.capabilities.query.maxRecordCount;let n=-1===i?r:i;if(n=s&&n>s?s:n,r<=p.length||p.length>=s)return p;const o=a.extent.width/a.width/a.scale*re;if(u.maxAllowableOffset=e.resolution||o,r<=n)return c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l);if(r<=te){const e=await this.layer.queryObjectIds();return u.objectIds=t(e,n,m),c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l)}return this.layer.get("capabilities.query.supportsPagination")&&(u.num=Math.min(n,te)),c?this._fetchFeaturesJSONFromService(u,l):this._fetchFeaturesFromService(u,l)}catch(d){return o(l),p}}load(e){const t=this.layer.load(e).then((async t=>{this.geometryType=t.geometryType,this.objectIdField=t.objectIdField,this.supportsSQLExpression=t.get("capabilities.query.supportsSqlExpression"),this._hasLocalSource=!t.url&&!!t.source,this.hasQueryEngine=this._hasLocalSource,this.minScale=t.minScale,this.maxScale=t.maxScale,this.fullExtent=t.fullExtent,this.workerClient=C.getInstance(),await this.workerClient.open(i(i(e).signal))}));return this.addResolvingPromise(t),Promise.resolve(this)}};e([u({constructOnly:!0})],ae.prototype,"layer",void 0),ae=e([m("esri.smartMapping.support.adapters.FeatureLayerAdapter")],ae);const ie=ae;export{ie as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- const d="20220604",c="6dfed0f27f13090629bb2ad0c2ec54f6cddcd091";export{d as buildDate,c as commitHash};
5
+ const e="20220607",f="d70e0fb3837987b8a498fbcad96f0c3949fee255";export{e as buildDate,f as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{bidiText as t}from"../../core/BidiText.js";import e from"../../core/Logger.js";import{isNone as s,isSome as i}from"../../core/maybe.js";import r from"../../core/ObjectPool.js";import{pt2px as n}from"../../core/screenUtils.js";import{create as o,fromValues as a}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as l}from"../../geometry/support/centroid.js";import{isPoint as c,isPolygon as m,isPolyline as f,isExtent as u,isMultipoint as _}from"../../geometry/support/jsonUtils.js";import{SimpleGeometryCursor as d}from"./CIMEffects.js";import{getEffectOperator as p,getPlacementOperator as y}from"./CIMOperators.js";import{Placement as g}from"./CIMPlacements.js";import x from"./CIMResourceManager.js";import{LineCapStyle as P,LineJoinStyle as w}from"./enums.js";import M from"./Rect.js";import b from"./TextRasterizer.js";import{HAlign as S,VAlign as k}from"../../views/2d/engine/webgl/alignmentUtils.js";import{GLYPH_SIZE as C,MAGIC_LABEL_LINE_HEIGHT as R}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as T}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const I=Math.PI/180,v=10,z=e.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class L{constructor(t){this._t=t}static createIdentity(){return new L([1,0,0,0,1,0])}clone(){const t=this._t;return new L(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new L([t,0,0,0,e,0])}scale(t,e){const s=this._t;return s[0]*=t,s[1]*=t,s[2]*=t,s[3]*=e,s[4]*=e,s[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new L([0,0,t,0,0,e])}translate(t,e){const s=this._t;return s[2]+=t,s[5]+=e,this}static createRotate(t){const e=Math.cos(t),s=Math.sin(t);return new L([e,-s,0,s,e,0])}rotate(t){return L.multiply(this,L.createRotate(t),this)}static multiply(t,e,s){const i=t._t,r=e._t,n=i[0]*r[0]+i[3]*r[1],o=i[1]*r[0]+i[4]*r[1],a=i[2]*r[0]+i[5]*r[1]+r[2],h=i[0]*r[3]+i[3]*r[4],l=i[1]*r[3]+i[4]*r[4],c=i[2]*r[3]+i[5]*r[4]+r[5],m=s._t;return m[0]=n,m[1]=o,m[2]=a,m[3]=h,m[4]=l,m[5]=c,s}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new L([0,0,0,0,0,0]);e=1/e;const s=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,r=t[4]*e,n=-t[1]*e,o=-t[3]*e,a=t[0]*e;return new L([r,n,s,o,a,i])}}class F{constructor(t,e){this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new r(g,null,null,100),this._earlyReturn=!1,this._mapRotation=0,this._resourceManager=t||new x,this._transfos.push(e||L.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||L.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;L.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(s,e),e=t.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new d(e);for(const r of t){const t=p(r);t&&(i=t.execute(i,r,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||!1===i.enable)continue;const r=i.effects;if(r&&r.length>0){const t=this.executeEffects(r,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=y(s);if(i){const r="CIMMarkerPlacementInsidePolygon"===s.type;r&&this.pushClipPath(e);const n=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(n){let e=null;for(;(e=n.next())&&(this.drawMarker(t,e),!this._earlyReturn););}r&&this.popClipPath()}}else{const s=this._placementPool.acquire();if(c(e))s.tx=e.x,s.ty=e.y,this.drawMarker(t,s);else if(m(e))[s.tx,s.ty]=l(e),this.drawMarker(t,s);else for(const i of e.points)if(s.tx=i[0],s.ty=i[1],this.drawMarker(t,s),this._earlyReturn)break;this._placementPool.release(s)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const i=this._resourceManager.getResource(t.url),r=t.size??10;if(s(i)||r<=0)return;const n=i.width,o=i.height;if(!n||!o)return;const a=n/o,h=t.scaleX??1,l=L.createIdentity(),c=t.anchorPoint;if(c){let e=c.x,s=c.y;"Absolute"!==t.anchorPointUnits&&(e*=r*a*h,s*=r),l.translate(-e,-s)}let m=t.rotation??0;t.rotateClockwise&&(m=-m),this._mapRotation&&(m+=this._mapRotation),m&&l.rotate(m*I);let f=t.offsetX??0,u=t.offsetY??0;if(f||u){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=f*s+u*e;f=f*e-u*s,u=i}l.translate(f,u)}const _=this.geomUnitsPerPoint();1!==_&&l.scale(_,_);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t.url,r,t.scaleX),this.pop()}drawVectorMarker(t,e){if(!t)return;const s=t.markerGraphics;if(!s)return;const i=t.size??10,r=t.frame,n=r?r.ymax-r.ymin:0,o=i&&n?i/n:1,a=L.createIdentity();r&&a.translate(.5*-(r.xmax+r.xmin),.5*-(r.ymax+r.ymin));const h=t.anchorPoint;if(h){let e=h.x,s=h.y;"Absolute"!==t.anchorPointUnits?r&&(e*=r.xmax-r.xmin,s*=r.ymax-r.ymin):(e/=o,s/=o),a.translate(-e,-s)}1!==o&&a.scale(o,o);let l=t.rotation??0;t.rotateClockwise&&(l=-l),this._mapRotation&&(l+=this._mapRotation),l&&a.rotate(l*I);let c=t.offsetX??0,m=t.offsetY??0;if(c||m){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=c*s+m*e;c=c*e-m*s,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const _ of s)if(_&&_.symbol&&_.geometry||z.error("Invalid marker graphic",_),this.drawSymbol(_.symbol,_.geometry),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e){if(!t)return;if(!c(e))return;if((t.height??10)<=0)return;const s=L.createIdentity();let i=t.angle??0;i=-i,i&&s.rotate(i*I);const r=t.offsetX??0,n=t.offsetY??0;(r||n)&&s.translate(r,n);const o=this.geomUnitsPerPoint();1!==o&&s.scale(o,o),s.translate(e.x,e.y),this.push(s,!1),this.drawText(t),this.pop()}_buildHatchPolyline(t,e,s){let i=(void 0!==t.separation?t.separation:4)*s,r=void 0!==t.rotation?t.rotation:0;if(0===i)return null;i<0&&(i=-i);let n=0;const a=.5*i;for(;n>a;)n-=i;for(;n<-a;)n+=i;const l=o();h(l,e),l[0]-=a,l[1]-=a,l[2]+=a,l[3]+=a;const c=[[l[0],l[1]],[l[0],l[3]],[l[2],l[3]],[l[2],l[1]]];for(;r>180;)r-=180;for(;r<0;)r+=180;const m=Math.cos(r*I),f=Math.sin(r*I),u=-i*f,_=i*m;let d,p,y,g;n=(void 0!==t.offsetX?t.offsetX*s:0)*f-(void 0!==t.offsetY?t.offsetY*s:0)*m,d=y=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const o of c){const t=o[0],e=o[1],s=m*t+f*e,i=-f*t+m*e;d=Math.min(d,s),y=Math.min(y,i),p=Math.max(p,s),g=Math.max(g,i)}y=Math.floor(y/i)*i;let x=m*d-f*y-u*n/i,P=f*d+m*y-_*n/i,w=m*p-f*y-u*n/i,M=f*p+m*y-_*n/i;const b=1+Math.round((g-y)/i),S=[];for(let o=0;o<b;o++)x+=u,P+=_,w+=u,M+=_,S.push([[x,P],[w,M]]);return{paths:S}}}class U extends F{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new M(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return a(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(m(t))this._processPath(t.rings,0);else if(f(t))this._processPath(t.paths,0);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(m(t))this._processPath(t.rings,i);else if(f(t))this._processPath(t.paths,i);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}pushClipPath(t){this.drawSolidFill(t),++this._clipCount}popClipPath(){--this._clipCount}drawImage(t,e,s){let r=s*e,n=e;const o=this._resourceManager.getResource(t);!e&&i(o)&&(r=s*o.width,n=o.height),this._merge(this.transformPt([-r/2,-n/2]),0),this._merge(this.transformPt([-r/2,n/2]),0),this._merge(this.transformPt([r/2,-n/2]),0),this._merge(this.transformPt([r/2,n/2]),0)}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_processPath(t,e){if(t)for(const s of t){const t=s?s.length:0;if(t>1){this._merge(this.transformPt(s[0]),e);for(let i=1;i<t;++i)this._merge(this.transformPt(s[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class j extends F{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,r,o){const a=o*n(1);this.setTransform(),this.setGeomUnitsPerPoint(a),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/a,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);return this._mapRotation=h?r:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,r,n){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}pushClipPath(t){}popClipPath(){}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r)||0===r.height||0===e)return;const n=e*this.geomUnitsPerPoint(),o=n*i*(r.width/r.height),a=this.reverseTransformPt(this._searchPoint),h=this._searchDistPoint;Math.abs(a[0])<o/2+h&&Math.abs(a[1])<n/2+h&&(this._earlyReturn=!0)}drawText(e){const s=this._textInfo;if(!s)return;const i=s.get(e);if(!i)return;const{text:r,mosaicItem:n}=i;if(!n||0===n.glyphMosaicItems.length)return;const o=e.height??v,a=B(e.lineGapType,e.lineGap??0,o),h=t(r)[1],l=n.glyphMosaicItems,c=T(l,h,{scale:o/C,angle:0,xOffset:0,yOffset:0,hAlign:E(e.horizontalAlignment),vAlign:H(e.verticalAlignment),maxLineWidth:512,lineHeight:R*Math.max(.25,Math.min(a||1,4)),decoration:e.font.decoration||"none",isCIM:!0}),m=this.reverseTransformPt(this._searchPoint),f=m[0],u=m[1];for(const t of c.glyphs)if(f>t.xTopLeft&&f<t.xBottomRight&&u>-t.yBottomRight&&u<-t.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(u(t)){const s=t;e=[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]}else if(m(t))e=t.rings;else{if(!f(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);this._pointInPolygon(s,e)&&(this._earlyReturn=!0);const i=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,i)&&(this._earlyReturn=!0)}_hitTestStroke(t,e){let s=null;if(u(t)){const e=t;s=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(m(t))s=t.rings;else{if(!f(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),r=e*this.geomUnitsPerPoint(),n=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,r/2+n)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];if(e[1]>t[1]==n[1]>t[1])continue;(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0])>0?s++:s--}}return 0!==s}_nearLine(t,e,s){for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];let o=(n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1]);if(0===o)continue;o=Math.sqrt(o);const a=((n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]))/o;if(Math.abs(a)<s){const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/o;if(i>-s&&i<o+s)return!0}}}return!1}}class A extends F{constructor(t,e,s){super(e,s),this._ctx=t}drawSolidFill(t,e){if(!t)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else if(u(t))this._buildPath(G(t).rings,!0);else{if(!_(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const s=this._ctx;s.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",s.fill("evenodd")}drawSolidStroke(t,e,s,i,r,n){if(!t||!e||0===s)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!1);else{if(!u(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(G(t).rings,!0)}const o=this._ctx;o.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",o.lineWidth=this.transformSize(s)+.5,this._setCapStyle(i),this._setJoinStyle(r),o.miterLimit=n,o.stroke()}pushClipPath(t){if(this._ctx.save(),m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else{if(!u(t))return;this._buildPath(G(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r))return;const n=this._ctx,o=n.canvas.width,a=n.canvas.height;let h=e*i*(r.width/r.height),l=i*e;e||(h=i*r.width,l=i*r.height);const c=this.transformPt([0,0]),m=this.transformSize(h),f=this.transformSize(l);this._ctx.drawImage(r,0,0,r.width,r.height,c[0]-m/2,c[1]-f/2,Math.min(m,o),Math.min(f,a))}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_buildPath(t,e){const s=this._ctx;if(s.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let r=this.transformPt(i[0]);s.moveTo(r[0],r[1]);for(let e=1;e<t;++e)r=this.transformPt(i[e]),s.lineTo(r[0],r[1]);e&&s.closePath()}}}_setCapStyle(t){switch(t){case P.Butt:this._ctx.lineCap="butt";break;case P.Round:this._ctx.lineCap="round";break;case P.Square:this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case w.Bevel:this._ctx.lineJoin="bevel";break;case w.Round:this._ctx.lineJoin="round";break;case w.Miter:this._ctx.lineJoin="miter"}}}const G=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,E=t=>{switch(t){case"Left":return S.Left;case"Right":return S.Right;case"Center":return S.Center;case"Justify":return z.warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),S.Center}},H=t=>{switch(t){case"Top":return k.Top;case"Center":return k.Center;case"Bottom":return k.Bottom;case"Baseline":return k.Baseline}},B=(t,e,s)=>{switch(t){case"ExtraLeading":return 1+e/s;case"Multiple":return e;case"Exact":return e/s}};export{F as CIMSymbolDrawHelper,I as C_DEG_TO_RAD,A as CanvasDrawHelper,U as EnvDrawHelper,j as HittestDrawHelper,L as Transformation,E as horizontalAlignment2HAlign,B as lineGapType2LineHeight,H as verticalAlignment2VAlign};
5
+ import{bidiText as t}from"../../core/BidiText.js";import e from"../../core/Logger.js";import{isNone as s,isSome as i}from"../../core/maybe.js";import r from"../../core/ObjectPool.js";import{pt2px as n}from"../../core/screenUtils.js";import{create as o,fromValues as a}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as h}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as l}from"../../geometry/support/centroid.js";import{isPoint as c,isPolygon as m,isPolyline as f,isExtent as u,isMultipoint as _}from"../../geometry/support/jsonUtils.js";import{SimpleGeometryCursor as d}from"./CIMEffects.js";import{getEffectOperator as p,getPlacementOperator as y}from"./CIMOperators.js";import{Placement as g}from"./CIMPlacements.js";import P from"./CIMResourceManager.js";import{LineCapStyle as x,LineJoinStyle as w}from"./enums.js";import M from"./Rect.js";import b from"./TextRasterizer.js";import{HAlign as S,VAlign as k}from"../../views/2d/engine/webgl/alignmentUtils.js";import{GLYPH_SIZE as C,MAGIC_LABEL_LINE_HEIGHT as R}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as T}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";const I=Math.PI/180,v=10,L=e.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class z{constructor(t){this._t=t}static createIdentity(){return new z([1,0,0,0,1,0])}clone(){const t=this._t;return new z(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new z([t,0,0,0,e,0])}scale(t,e){const s=this._t;return s[0]*=t,s[1]*=t,s[2]*=t,s[3]*=e,s[4]*=e,s[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new z([0,0,t,0,0,e])}translate(t,e){const s=this._t;return s[2]+=t,s[5]+=e,this}static createRotate(t){const e=Math.cos(t),s=Math.sin(t);return new z([e,-s,0,s,e,0])}rotate(t){return z.multiply(this,z.createRotate(t),this)}static multiply(t,e,s){const i=t._t,r=e._t,n=i[0]*r[0]+i[3]*r[1],o=i[1]*r[0]+i[4]*r[1],a=i[2]*r[0]+i[5]*r[1]+r[2],h=i[0]*r[3]+i[3]*r[4],l=i[1]*r[3]+i[4]*r[4],c=i[2]*r[3]+i[5]*r[4]+r[5],m=s._t;return m[0]=n,m[1]=o,m[2]=a,m[3]=h,m[4]=l,m[5]=c,s}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new z([0,0,0,0,0,0]);e=1/e;const s=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,r=t[4]*e,n=-t[1]*e,o=-t[3]*e,a=t[0]*e;return new z([r,n,s,o,a,i])}}class F{constructor(t,e){this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new r(g,null,null,100),this._earlyReturn=!1,this._mapRotation=0,this._resourceManager=t||new P,this._transfos.push(e||z.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||z.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const s=e?t.scaleRatio():1;z.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*s)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e)}}drawMultiLayerSymbol(t,e){if(!t)return;const s=t.symbolLayers;if(!s)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(s,e),e=t.next()}}else this.drawSymbolLayers(s,e)}executeEffects(t,e){const s=this._resourceManager.geometryEngine;let i=new d(e);for(const r of t){const t=p(r);t&&(i=t.execute(i,r,this.geomUnitsPerPoint(),s))}return i}drawSymbolLayers(t,e){let s=t.length;for(;s--;){const i=t[s];if(!i||!1===i.enable)continue;const r=i.effects;if(r&&r.length>0){const t=this.executeEffects(r,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const s=this._buildHatchPolyline(e,t,this.geomUnitsPerPoint());s&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,s),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const s=t.markerPlacement;if(s){const i=y(s);if(i){const r="CIMMarkerPlacementInsidePolygon"===s.type;r&&this.pushClipPath(e);const n=i.execute(e,s,this.geomUnitsPerPoint(),this._resourceManager.geometryEngine);if(n){let e=null;for(;(e=n.next())&&(this.drawMarker(t,e),!this._earlyReturn););}r&&this.popClipPath()}}else{const s=this._placementPool.acquire();if(c(e))s.tx=e.x,s.ty=e.y,this.drawMarker(t,s);else if(m(e))[s.tx,s.ty]=l(e),this.drawMarker(t,s);else for(const i of e.points)if(s.tx=i[0],s.ty=i[1],this.drawMarker(t,s),this._earlyReturn)break;this._placementPool.release(s)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const i=this._resourceManager.getResource(t.url),r=t.size??10;if(s(i)||r<=0)return;const n=i.width,o=i.height;if(!n||!o)return;const a=n/o,h=t.scaleX??1,l=z.createIdentity(),c=t.anchorPoint;if(c){let e=c.x,s=c.y;"Absolute"!==t.anchorPointUnits&&(e*=r*a*h,s*=r),l.translate(-e,-s)}let m=t.rotation??0;t.rotateClockwise&&(m=-m),this._mapRotation&&(m+=this._mapRotation),m&&l.rotate(m*I);let f=t.offsetX??0,u=t.offsetY??0;if(f||u){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=f*s+u*e;f=f*e-u*s,u=i}l.translate(f,u)}const _=this.geomUnitsPerPoint();1!==_&&l.scale(_,_);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t.url,r,t.scaleX),this.pop()}drawVectorMarker(t,e){if(!t)return;const s=t.markerGraphics;if(!s)return;const i=t.size??10,r=t.frame,n=r?r.ymax-r.ymin:0,o=i&&n?i/n:1,a=z.createIdentity();r&&a.translate(.5*-(r.xmax+r.xmin),.5*-(r.ymax+r.ymin));const h=t.anchorPoint;if(h){let e=h.x,s=h.y;"Absolute"!==t.anchorPointUnits?r&&(e*=r.xmax-r.xmin,s*=r.ymax-r.ymin):(e/=o,s/=o),a.translate(-e,-s)}1!==o&&a.scale(o,o);let l=t.rotation??0;t.rotateClockwise&&(l=-l),this._mapRotation&&(l+=this._mapRotation),l&&a.rotate(l*I);let c=t.offsetX??0,m=t.offsetY??0;if(c||m){if(this._mapRotation){const t=I*this._mapRotation,e=Math.cos(t),s=Math.sin(t),i=c*s+m*e;c=c*e-m*s,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const _ of s)if(_&&_.symbol&&_.geometry||L.error("Invalid marker graphic",_),this.drawSymbol(_.symbol,_.geometry),this._earlyReturn)break;this.pop()}drawTextSymbol(t,e){if(!t)return;if(!c(e))return;if((t.height??10)<=0)return;const s=z.createIdentity();let i=t.angle??0;i=-i,i&&s.rotate(i*I);const r=t.offsetX??0,n=t.offsetY??0;(r||n)&&s.translate(r,n);const o=this.geomUnitsPerPoint();1!==o&&s.scale(o,o),s.translate(e.x,e.y),this.push(s,!1),this.drawText(t),this.pop()}_buildHatchPolyline(t,e,s){let i=(void 0!==t.separation?t.separation:4)*s,r=void 0!==t.rotation?t.rotation:0;if(0===i)return null;i<0&&(i=-i);let n=0;const a=.5*i;for(;n>a;)n-=i;for(;n<-a;)n+=i;const l=o();h(l,e),l[0]-=a,l[1]-=a,l[2]+=a,l[3]+=a;const c=[[l[0],l[1]],[l[0],l[3]],[l[2],l[3]],[l[2],l[1]]];for(;r>180;)r-=180;for(;r<0;)r+=180;const m=Math.cos(r*I),f=Math.sin(r*I),u=-i*f,_=i*m;let d,p,y,g;n=(void 0!==t.offsetX?t.offsetX*s:0)*f-(void 0!==t.offsetY?t.offsetY*s:0)*m,d=y=Number.MAX_VALUE,p=g=-Number.MAX_VALUE;for(const o of c){const t=o[0],e=o[1],s=m*t+f*e,i=-f*t+m*e;d=Math.min(d,s),y=Math.min(y,i),p=Math.max(p,s),g=Math.max(g,i)}y=Math.floor(y/i)*i;let P=m*d-f*y-u*n/i,x=f*d+m*y-_*n/i,w=m*p-f*y-u*n/i,M=f*p+m*y-_*n/i;const b=1+Math.round((g-y)/i),S=[];for(let o=0;o<b;o++)P+=u,x+=_,w+=u,M+=_,S.push([[P,x],[w,M]]);return{paths:S}}}class U extends F{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new M(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return a(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(m(t))this._processPath(t.rings,0);else if(f(t))this._processPath(t.paths,0);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,s){if(!t||this._clipCount>0)return;const i=.5*this.transformSize(s);if(m(t))this._processPath(t.rings,i);else if(f(t))this._processPath(t.paths,i);else if(u(t)){const e=G(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}pushClipPath(t){this.drawSolidFill(t),++this._clipCount}popClipPath(){--this._clipCount}drawImage(t,e,s){let r=s*e,n=e;const o=this._resourceManager.getResource(t);!e&&i(o)&&(r=s*o.width,n=o.height),this._merge(this.transformPt([-r/2,-n/2]),0),this._merge(this.transformPt([-r/2,n/2]),0),this._merge(this.transformPt([r/2,-n/2]),0),this._merge(this.transformPt([r/2,n/2]),0)}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_processPath(t,e){if(t)for(const s of t){const t=s?s.length:0;if(t>1){this._merge(this.transformPt(s[0]),e);for(let i=1;i<t;++i)this._merge(this.transformPt(s[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class j extends F{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0}hitTest(t,e,s,i,r,o){const a=o*n(1);this.setTransform(),this.setGeomUnitsPerPoint(a),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/a,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type);return this._mapRotation=h?r:0,this._earlyReturn=!1,this.drawSymbol(e,s),this._earlyReturn}drawSolidFill(t,e){this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,s,i,r,n){this._hitTestStroke(t,s)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&"CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r)||0===r.height||0===e)return;const n=e*this.geomUnitsPerPoint(),o=n*i*(r.width/r.height),a=this.reverseTransformPt(this._searchPoint),h=this._searchDistPoint;Math.abs(a[0])<o/2+h&&Math.abs(a[1])<n/2+h&&(this._earlyReturn=!0)}drawText(e){const s=this._textInfo;if(!s)return;const i=s.get(e);if(!i)return;const{text:r,mosaicItem:n}=i;if(!n||0===n.glyphMosaicItems.length)return;const o=e.height??v,a=B(e.lineGapType,e.lineGap??0,o),h=t(r)[1],l=n.glyphMosaicItems,c=T(l,h,{scale:o/C,angle:0,xOffset:0,yOffset:0,hAlign:E(e.horizontalAlignment),vAlign:H(e.verticalAlignment),maxLineWidth:512,lineHeight:R*Math.max(.25,Math.min(a||1,4)),decoration:e.font.decoration||"none",isCIM:!0}),m=this.reverseTransformPt(this._searchPoint),f=m[0],u=m[1];for(const t of c.glyphs)if(f>t.xTopLeft&&f<t.xBottomRight&&u>-t.yBottomRight&&u<-t.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(u(t)){const s=t;e=[[[s.xmin,s.ymin],[s.xmin,s.ymax],[s.xmax,s.ymax],[s.xmax,s.ymin],[s.xmin,s.ymin]]]}else if(m(t))e=t.rings;else{if(!f(t))return;e=t.paths}const s=this.reverseTransformPt(this._searchPoint);if(this._pointInPolygon(s,e)&&(this._earlyReturn=!0),!this._earlyReturn){const t=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(s,e,t)&&(this._earlyReturn=!0)}}_hitTestStroke(t,e){let s=null;if(u(t)){const e=t;s=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(m(t))s=t.rings;else{if(!f(t))return;s=t.paths}const i=this.reverseTransformPt(this._searchPoint),r=e*this.geomUnitsPerPoint(),n=this.reverseTransformSize(this._searchDistPoint)*this.geomUnitsPerPoint();this._nearLine(i,s,r/2+n)&&(this._earlyReturn=!0)}_pointInPolygon(t,e){let s=0;for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];if(e[1]>t[1]==n[1]>t[1])continue;(n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0])>0?s++:s--}}return 0!==s}_nearLine(t,e,s){for(const i of e){const e=i.length;for(let r=1;r<e;++r){const e=i[r-1],n=i[r];let o=(n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1]);if(0===o)continue;o=Math.sqrt(o);const a=((n[0]-e[0])*(t[1]-e[1])-(n[1]-e[1])*(t[0]-e[0]))/o;if(Math.abs(a)<s){const i=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/o;if(i>-s&&i<o+s)return!0}}}return!1}}class A extends F{constructor(t,e,s){super(e,s),this._ctx=t}drawSolidFill(t,e){if(!t)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else if(u(t))this._buildPath(G(t).rings,!0);else{if(!_(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const s=this._ctx;s.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",s.fill("evenodd")}drawSolidStroke(t,e,s,i,r,n){if(!t||!e||0===s)return;if(m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!1);else{if(!u(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(G(t).rings,!0)}const o=this._ctx;o.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+e[3]/255+")",o.lineWidth=this.transformSize(s)+.5,this._setCapStyle(i),this._setJoinStyle(r),o.miterLimit=n,o.stroke()}pushClipPath(t){if(this._ctx.save(),m(t))this._buildPath(t.rings,!0);else if(f(t))this._buildPath(t.paths,!0);else{if(!u(t))return;this._buildPath(G(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e,i){const r=this._resourceManager.getResource(t);if(s(r))return;const n=this._ctx,o=n.canvas.width,a=n.canvas.height;let h=e*i*(r.width/r.height),l=i*e;e||(h=i*r.width,l=i*r.height);const c=this.transformPt([0,0]),m=this.transformSize(h),f=this.transformSize(l);this._ctx.drawImage(r,0,0,r.width,r.height,c[0]-m/2,c[1]-f/2,Math.min(m,o),Math.min(f,a))}drawText(t){this._textRasterizer||(this._textRasterizer=new b)}_buildPath(t,e){const s=this._ctx;if(s.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let r=this.transformPt(i[0]);s.moveTo(r[0],r[1]);for(let e=1;e<t;++e)r=this.transformPt(i[e]),s.lineTo(r[0],r[1]);e&&s.closePath()}}}_setCapStyle(t){switch(t){case x.Butt:this._ctx.lineCap="butt";break;case x.Round:this._ctx.lineCap="round";break;case x.Square:this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case w.Bevel:this._ctx.lineJoin="bevel";break;case w.Round:this._ctx.lineJoin="round";break;case w.Miter:this._ctx.lineJoin="miter"}}}const G=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,E=t=>{switch(t){case"Left":return S.Left;case"Right":return S.Right;case"Center":return S.Center;case"Justify":return L.warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),S.Center}},H=t=>{switch(t){case"Top":return k.Top;case"Center":return k.Center;case"Bottom":return k.Bottom;case"Baseline":return k.Baseline}},B=(t,e,s)=>{switch(t){case"ExtraLeading":return 1+e/s;case"Multiple":return e;case"Exact":return e/s}};export{F as CIMSymbolDrawHelper,I as C_DEG_TO_RAD,A as CanvasDrawHelper,U as EnvDrawHelper,j as HittestDrawHelper,z as Transformation,E as horizontalAlignment2HAlign,B as lineGapType2LineHeight,H as verticalAlignment2VAlign};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../core/Error.js";import t from"../../../../../../core/Logger.js";import{clamp as i}from"../../../../../../core/mathUtils.js";import{unwrap as o,isNone as n}from"../../../../../../core/maybe.js";import{pt2px as s}from"../../../../../../core/screenUtils.js";import{Alignment as r}from"../../../../../../symbols/cim/enums.js";import{isMapAligned as a,getAlignmentFromPlacement as l,getXDirection as h,getYDirection as c}from"../../alignmentUtils.js";import{premultiplyAlphaRGBAArray as m}from"../../color.js";import{TEXT_PLACEMENT_PADDING as f}from"../../definitions.js";import{WGLGeometryType as _}from"../../enums.js";import{i8888to32 as p}from"../../number.js";import{LabelMaterialKey as g}from"../../materialKey/MaterialKey.js";import{smoothPaths as u,pathDivide as d}from"./segmentUtils.js";import x from"./WGLTextTemplate.js";const y=t.getLogger("esri.views.2d.engine.webgl.WGLLabelTemplate"),b=(t,i="mapview-labeling")=>y.error(new e(i,t)),L=1,P=0,S=4;function w(e,t){const o=!!e.minScale&&t.scaleToZoom(e.minScale)||0;return i(o,0,25.5)}function v(e,t){const o=!!e.maxScale&&t.scaleToZoom(e.maxScale)||255;return i(o,0,25.5)}function M(e){const t=new Map;return i=>(t.has(i)||t.set(i,e(i)),t.get(i))}const Z=M((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t})),A=e=>Math.floor(127*e+127),O=e=>Math.floor(10*e),z=e=>Math.round(e*(254/360));class I extends x{constructor(e,t,i,o){super(e,i.font.size,i.haloSize||0,i.font.size,i.color&&m(i.color)||0,i.haloColor&&m(i.haloColor)||0,i.horizontalAlignment,i.verticalAlignment,a(t.labelPlacement)?r.MAP:r.SCREEN,i.font.decoration,!1,i.angle||0,i.xoffset,i.yoffset,i.lineWidth,i.lineHeight,null,null,null,null,null),this._outLineLabelAngle=0,this._refPlacementPadding=0,this._refPlacementDirX=0,this._refPlacementDirY=0,this._refOffsetX=0,this._refOffsetY=0,this._zoomLevel=0,this.geometryType=_.LABEL,this._allowOverrun=t.allowOverrun??!1,this._repeatLabel=t.repeatLabel??!0,this._labelPosition=t.labelPosition??"curved";const n=w(t,o),h=v(t,o),c=t.labelPlacement,[p,u]=l(c);this._xAlignD=p,this._yAlignD=u,this._minZoom=n,this._maxZoom=h,this._refPlacementPadding=s(i.haloSize)+f,this._repeatLabelDistance=t.repeatLabelDistance?s(t.repeatLabelDistance):128;const d=g.load(e);d.sdf=!0,this._materialKey=d.data}static fromLabelClass(e,t){if("esriServerLinePlacementCenterAlong"===e.labelPlacement){const t=e.symbol;t.xoffset=0,t.yoffset=0,t.angle=0,t.font.decoration="none"}return new I(e.materialKey,e,e.symbol,t)}get _shapedBox(){return o(this._shapingInfo).bounds}setZoomLevel(e){this._zoomLevel=e}bindReferenceTemplate(e){let t=h(this._xAlignD),i=c(this._yAlignD);if(this._refOffsetX=0,this._refOffsetY=0,n(e))return void(this._refSymbolAndPlacementOffset=p(0,0,A(t),A(i)));if("circle"===e.boundsType&&(t||i)){const e=Math.sqrt(t*t+i*i);t/=e,i/=e}const o=Math.max(e.height,e.width),s=this._refPlacementPadding*S;this._refSymbolAndPlacementOffset=p(s,o,A(t),A(i)),this._referenceSize=o,this._refPlacementDirX=t,this._refPlacementDirY=i,this._refOffsetX=e.xOffset,this._refOffsetY=e.yOffset}_write(e,t){if(n(this._shapingInfo))return;const i=this._shapingInfo,o=t.getDisplayId(),s="esriGeometryPolygon"===t.geometryType?t.readLegacyCentroid():t.readLegacyGeometry();if(s)switch(this.current={out:e,inId:o,inShaping:i,zoomLevel:this._zoomLevel},t.geometryType){case"esriGeometryPolyline":this._placeLineLabels(s);break;case"esriGeometryPoint":case"esriGeometryPolygon":this._placePointLabels(s);break;default:b("mapview-labeling",`Geometry of type ${t.geometryType} is not supported`)}}_isVisible(e,t){const i=O(this.current.zoomLevel);return O(e)<=i&&i<=O(t)}_placePointLabels(e){const{out:t,inId:i,inShaping:o}=this.current;this._writeGlyphs(t,i,e,o)}_placeLineLabels(e){const t=u(e.paths,this.current.inShaping.bounds.width),i=this._placeSubdivGlyphs.bind(this),o=(this._shapedBox.width+this._repeatLabelDistance)/(1<<L);for(const n of t)d(n,o,i,this._repeatLabel)}_placeSubdivGlyphs(e,t,i,o){const n=Z(t),s=this._shapedBox.width/(1<<L),r=Math.sqrt(this._repeatLabelDistance)/(1<<L),a=Math.min(i,o-i),l=Math.log2(a/(r+s/2)),h=0===t?l:Math.min(n,l),c=Math.max(this._minZoom,this.current.zoomLevel+L-h),m=this.current.zoomLevel-c,f=this._shapedBox.width/2*2**m;this.current.inShaping.isMultiline?0===t&&this._placeStraight(e,c):this._allowOverrun&&m<0?this._placeStraightAlong(e,this._minZoom):"parallel"===this._labelPosition?this._placeStraightAlong(e,c):"curved"===this._labelPosition&&this._placeCurved(e,c,f)}_placeStraight(e,t){const{out:i,inId:o,inShaping:n}=this.current;this._writeGlyphs(i,o,e,n,t)}_placeCurved(e,t,i){const{out:o,inId:n}=this.current;o.metricStart(n,t,e.x,e.y,0,0,0,0);const s=e.clone(),r=e.angle*(180/Math.PI)%360,a=(e.angle*(180/Math.PI)+180)%360;this._outLineLabelAngle=z(r),this._placeFirst(s,t,1),this._placeBack(e,s,t,i,1),this._placeForward(e,s,t,i,1),this._outLineLabelAngle=z(a),this._placeFirst(s,t,0),this._placeBack(e,s,t,i,0),this._placeForward(e,s,t,i,0),o.metricEnd()}_placeStraightAlong(e,t){const{out:i,inId:o}=this.current;i.metricStart(o,t,e.x,e.y,0,0,0,0);const n=e.clone(),s=e.angle*(180/Math.PI)%360,r=(e.angle*(180/Math.PI)+180)%360;this._outLineLabelAngle=z(s),this._placeFirst(n,t,1,!0),this._outLineLabelAngle=z(r),this._placeFirst(n,t,0,!0),i.metricEnd()}_placeBack(e,t,i,o,n){const s=e.clone();let r=e.backwardLength+P;for(;s.prev()&&!(r>=o);)this._placeOnSegment(s,t,r,i,-1,n),r+=s.length+P}_placeForward(e,t,i,o,n){const s=e.clone();let r=e.remainingLength+P;for(;s.next()&&!(r>=o);)this._placeOnSegment(s,t,r,i,1,n),r+=s.length+P}_placeFirst(e,t,i,o=!1){const n=e,s=this.current.inShaping,r=s.glyphs,a=this.current.zoomLevel,{out:l,inId:h}=this.current;for(const c of r){const r=c.x>s.bounds.x?i:1-i,m=r*e.remainingLength+(1-r)*e.backwardLength,f=Math.abs(c.x+c.width/2-s.bounds.x),_=Math.max(0,a+Math.log2(f/(m+P))),p=Math.max(t,o?0:_);if(c.maxZoom=25,c.angle=e.angle+(1-i)*Math.PI,c.minZoom=p,this._writeGlyph(l,h,n.x,n.y,c),i&&this._isVisible(c.minZoom,c.maxZoom)){const e=c.bounds;l.metricBoxWrite(e.center[0],e.center[1],e.width,e.height)}}}_placeOnSegment(e,t,i,o,n,s){const r=this.current.inShaping.glyphs,{out:a,inId:l}=this.current,h=this.current.inShaping,c=this.current.zoomLevel,m=e.dx/e.length,f=e.dy/e.length,_={x:e.x+i*-n*m,y:e.y+i*-n*f};for(const p of r){const r=p.x>h.bounds.x?s:1-s;if(!(r&&1===n||!r&&-1===n))continue;const m=Math.abs(p.x+p.width/2-h.bounds.x),f=Math.max(0,c+Math.log2(m/i)-.1),g=Math.max(o,c+Math.log2(m/(i+e.length+P)));if(0!==f&&(p.angle=e.angle+(1-s)*Math.PI,p.minZoom=g,p.maxZoom=f,this._writeGlyph(a,l,_.x,_.y,p),s&&this._isVisible(p.minZoom,p.maxZoom))){const i=p.bounds,o=e.x-t.x,n=e.y-t.y;a.metricBoxWrite(i.center[0]+o,i.center[1]+n,i.width,i.height)}}}_writeGlyphs(e,t,i,o,n=this._minZoom){if(i.x<0||i.x>=512||i.y<0||i.y>=512)return;const s=i.x+this._refOffsetX,r=i.y-this._refOffsetY;for(const c of o.glyphs)c.minZoom=n,c.maxZoom=this._maxZoom,this._writeGlyph(e,t,s,r,c);const a=this._refPlacementDirX,l=this._refPlacementDirY,h=o.boundsT;e.metricStart(t,n,s,r,a,l,this._referenceSize,this._materialKey),e.metricBoxWrite(h.center[0],h.center[1],h.width,h.height),e.metricEnd()}_writeVertexCommon(e,t,i,o){const n=this._color,s=this._haloColor,r=p(0,0,this._size,this._haloSize),a=Math.max(o.minZoom,this._minZoom),l=Math.min(o.maxZoom,this._maxZoom),h=p(O(a),O(l),this._outLineLabelAngle,0);e.vertexWrite(i),e.vertexWrite(t),e.vertexWrite(n),e.vertexWrite(s),e.vertexWrite(r),e.vertexWrite(this._refSymbolAndPlacementOffset),e.vertexWrite(h)}}export{I as default};
5
+ import e from"../../../../../../core/Error.js";import t from"../../../../../../core/Logger.js";import{clamp as i}from"../../../../../../core/mathUtils.js";import{unwrap as n,isNone as o}from"../../../../../../core/maybe.js";import{pt2px as s}from"../../../../../../core/screenUtils.js";import{Alignment as r}from"../../../../../../symbols/cim/enums.js";import{isMapAligned as a,getAlignmentFromPlacement as l,getXDirection as h,getYDirection as c}from"../../alignmentUtils.js";import{premultiplyAlphaRGBAArray as m}from"../../color.js";import{TEXT_PLACEMENT_PADDING as f}from"../../definitions.js";import{WGLGeometryType as _}from"../../enums.js";import{i8888to32 as g}from"../../number.js";import{LabelMaterialKey as p}from"../../materialKey/MaterialKey.js";import{smoothPaths as u,pathDivide as d}from"./segmentUtils.js";import b from"./WGLTextTemplate.js";const y=t.getLogger("esri.views.2d.engine.webgl.WGLLabelTemplate"),x=(t,i="mapview-labeling")=>y.error(new e(i,t)),L=1,P=0,M=4,S=25;function w(e,t){const n=!!e.minScale&&t.scaleToZoom(e.minScale)||0;return i(n,0,25.5)}function v(e,t){const n=!!e.maxScale&&t.scaleToZoom(e.maxScale)||255;return i(n,0,25.5)}function A(e){const t=new Map;return i=>(t.has(i)||t.set(i,e(i)),t.get(i))}const Z=A((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t})),I=e=>Math.floor(127*e+127),O=e=>Math.floor(10*e),z=e=>Math.round(e*(254/360));class G extends b{constructor(e,t,i,n){super(e,i.font.size,i.haloSize||0,i.font.size,i.color&&m(i.color)||0,i.haloColor&&m(i.haloColor)||0,i.horizontalAlignment,i.verticalAlignment,a(t.labelPlacement)?r.MAP:r.SCREEN,i.font.decoration,!1,i.angle||0,i.xoffset,i.yoffset,i.lineWidth,i.lineHeight,null,null,null,null,null),this._outLineLabelAngle=0,this._refPlacementPadding=0,this._refPlacementDirX=0,this._refPlacementDirY=0,this._refOffsetX=0,this._refOffsetY=0,this._zoomLevel=0,this.geometryType=_.LABEL,this._allowOverrun=t.allowOverrun??!1,this._repeatLabel=t.repeatLabel??!0,this._labelPosition=t.labelPosition??"curved";const o=w(t,n),h=v(t,n),c=t.labelPlacement,[g,u]=l(c);this._xAlignD=g,this._yAlignD=u,this._minZoom=o,this._maxZoom=h,this._refPlacementPadding=s(i.haloSize)+f,this._repeatLabelDistance=t.repeatLabelDistance?s(t.repeatLabelDistance):128;const d=p.load(e);d.sdf=!0,this._materialKey=d.data}static fromLabelClass(e,t){if("esriServerLinePlacementCenterAlong"===e.labelPlacement){const t=e.symbol;t.xoffset=0,t.yoffset=0,t.angle=0,t.font.decoration="none"}return new G(e.materialKey,e,e.symbol,t)}get _shapedBox(){return n(this._shapingInfo).bounds}setZoomLevel(e){this._zoomLevel=e}bindReferenceTemplate(e){let t=h(this._xAlignD),i=c(this._yAlignD);if(this._refOffsetX=0,this._refOffsetY=0,o(e))return void(this._refSymbolAndPlacementOffset=g(0,0,I(t),I(i)));if("circle"===e.boundsType&&(t||i)){const e=Math.sqrt(t*t+i*i);t/=e,i/=e}const n=Math.max(e.height,e.width),s=this._refPlacementPadding*M;this._refSymbolAndPlacementOffset=g(s,n,I(t),I(i)),this._referenceSize=n,this._refPlacementDirX=t,this._refPlacementDirY=i,this._refOffsetX=e.xOffset,this._refOffsetY=e.yOffset}_write(e,t){if(o(this._shapingInfo))return;const i=this._shapingInfo,n=t.getDisplayId(),s="esriGeometryPolygon"===t.geometryType?t.readLegacyCentroid():t.readLegacyGeometry();if(s)switch(this.current={out:e,inId:n,inShaping:i,zoomLevel:this._zoomLevel},t.geometryType){case"esriGeometryPolyline":this._placeLineLabels(s);break;case"esriGeometryPoint":case"esriGeometryPolygon":this._placePointLabels(s);break;default:x("mapview-labeling",`Geometry of type ${t.geometryType} is not supported`)}}_isVisible(e,t){const i=O(this.current.zoomLevel);return O(e)<=i&&i<=O(t)}_placePointLabels(e){const{out:t,inId:i,inShaping:n}=this.current;this._writeGlyphs(t,i,e,n)}_placeLineLabels(e){const t=u(e.paths,this.current.inShaping.bounds.width),i=this._placeSubdivGlyphs.bind(this),n=(this._shapedBox.width+this._repeatLabelDistance)/(1<<L);for(const o of t)d(o,n,i,this._repeatLabel)}_placeSubdivGlyphs(e,t,i,n){const o=Z(t),s=this._shapedBox.width/(1<<L),r=Math.sqrt(this._repeatLabelDistance)/(1<<L),a=Math.min(i,n-i),l=this.current.inShaping.isMultiline?S:Math.log2(a/(r+s/2)),h=0===t?l:Math.min(o,l),c=Math.max(this._minZoom,this.current.zoomLevel+L-h),m=this.current.zoomLevel-c,f=this._shapedBox.width/2*2**m;this.current.inShaping.isMultiline?0===t&&this._placeStraight(e,c):this._allowOverrun&&m<0?this._placeStraightAlong(e,this._minZoom):"parallel"===this._labelPosition?this._placeStraightAlong(e,c):"curved"===this._labelPosition&&this._placeCurved(e,c,f)}_placeStraight(e,t){const{out:i,inId:n,inShaping:o}=this.current,s=Math.ceil(e.angle*(180/Math.PI)%360),r=Math.ceil((e.angle*(180/Math.PI)+180)%360);this._outLineLabelAngle=z(s),this._writeGlyphs(i,n,e,o,t),this._outLineLabelAngle=z(r),this._writeGlyphs(i,n,e,o,t)}_placeCurved(e,t,i){const{out:n,inId:o}=this.current;n.metricStart(o,t,e.x,e.y,0,0,0,0);const s=e.clone(),r=e.angle*(180/Math.PI)%360,a=(e.angle*(180/Math.PI)+180)%360;this._outLineLabelAngle=z(r),this._placeFirst(s,t,1),this._placeBack(e,s,t,i,1),this._placeForward(e,s,t,i,1),this._outLineLabelAngle=z(a),this._placeFirst(s,t,0),this._placeBack(e,s,t,i,0),this._placeForward(e,s,t,i,0),n.metricEnd()}_placeStraightAlong(e,t){const{out:i,inId:n}=this.current;i.metricStart(n,t,e.x,e.y,0,0,0,0);const o=e.clone(),s=e.angle*(180/Math.PI)%360,r=(e.angle*(180/Math.PI)+180)%360;this._outLineLabelAngle=z(s),this._placeFirst(o,t,1,!0),this._outLineLabelAngle=z(r),this._placeFirst(o,t,0,!0),i.metricEnd()}_placeBack(e,t,i,n,o){const s=e.clone();let r=e.backwardLength+P;for(;s.prev()&&!(r>=n);)this._placeOnSegment(s,t,r,i,-1,o),r+=s.length+P}_placeForward(e,t,i,n,o){const s=e.clone();let r=e.remainingLength+P;for(;s.next()&&!(r>=n);)this._placeOnSegment(s,t,r,i,1,o),r+=s.length+P}_placeFirst(e,t,i,n=!1){const o=e,s=this.current.inShaping,r=s.glyphs,a=this.current.zoomLevel,{out:l,inId:h}=this.current;for(const c of r){const r=c.x>s.bounds.x?i:1-i,m=r*e.remainingLength+(1-r)*e.backwardLength,f=Math.abs(c.x+c.width/2-s.bounds.x),_=Math.max(0,a+Math.log2(f/(m+P))),g=Math.max(t,n?0:_);if(c.maxZoom=S,c.angle=e.angle+(1-i)*Math.PI,c.minZoom=g,this._writeGlyph(l,h,o.x,o.y,c),i&&this._isVisible(c.minZoom,c.maxZoom)){const e=c.bounds;l.metricBoxWrite(e.center[0],e.center[1],e.width,e.height)}}}_placeOnSegment(e,t,i,n,o,s){const r=this.current.inShaping.glyphs,{out:a,inId:l}=this.current,h=this.current.inShaping,c=this.current.zoomLevel,m=e.dx/e.length,f=e.dy/e.length,_={x:e.x+i*-o*m,y:e.y+i*-o*f};for(const g of r){const r=g.x>h.bounds.x?s:1-s;if(!(r&&1===o||!r&&-1===o))continue;const m=Math.abs(g.x+g.width/2-h.bounds.x),f=Math.max(0,c+Math.log2(m/i)-.1),p=Math.max(n,c+Math.log2(m/(i+e.length+P)));if(0!==f&&(g.angle=e.angle+(1-s)*Math.PI,g.minZoom=p,g.maxZoom=f,this._writeGlyph(a,l,_.x,_.y,g),s&&this._isVisible(g.minZoom,g.maxZoom))){const i=g.bounds,n=e.x-t.x,o=e.y-t.y;a.metricBoxWrite(i.center[0]+n,i.center[1]+o,i.width,i.height)}}}_writeGlyphs(e,t,i,n,o=this._minZoom){if(i.x<0||i.x>=512||i.y<0||i.y>=512)return;const s=i.x+this._refOffsetX,r=i.y-this._refOffsetY;for(const c of n.glyphs)c.minZoom=o,c.maxZoom=this._maxZoom,this._writeGlyph(e,t,s,r,c);const a=this._refPlacementDirX,l=this._refPlacementDirY,h=n.boundsT;e.metricStart(t,o,s,r,a,l,this._referenceSize,this._materialKey),e.metricBoxWrite(h.center[0],h.center[1],h.width,h.height),e.metricEnd()}_writeVertexCommon(e,t,i,n){const o=this._color,s=this._haloColor,r=g(0,0,this._size,this._haloSize),a=Math.max(n.minZoom,this._minZoom),l=Math.min(n.maxZoom,this._maxZoom),h=g(O(a),O(l),this._outLineLabelAngle,0);e.vertexWrite(i),e.vertexWrite(t),e.vertexWrite(o),e.vertexWrite(s),e.vertexWrite(r),e.vertexWrite(this._refSymbolAndPlacementOffset),e.vertexWrite(h)}}export{G as default};