@arcgis/core 4.27.1 → 4.27.2

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.
package/interfaces.d.ts CHANGED
@@ -79831,19 +79831,19 @@ declare namespace __esri {
79831
79831
 
79832
79832
  export interface PopupViewOpenPopupOptions {
79833
79833
  /**
79834
- * Sets the [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#title) of the popup.
79834
+ * Sets the [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) of the popup.
79835
79835
  *
79836
79836
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79837
79837
  */
79838
79838
  title?: string;
79839
79839
  /**
79840
- * Sets the [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#content) of the popup.
79840
+ * Sets the [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) of the popup.
79841
79841
  *
79842
79842
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79843
79843
  */
79844
79844
  content?: string | HTMLElement | Widget;
79845
79845
  /**
79846
- * Sets the popup's [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#location), which is the geometry used to position the popup.
79846
+ * Sets the popup's [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location), which is the geometry used to position the popup.
79847
79847
  *
79848
79848
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79849
79849
  */
@@ -79855,37 +79855,37 @@ declare namespace __esri {
79855
79855
  */
79856
79856
  fetchFeatures?: boolean;
79857
79857
  /**
79858
- * Sets the popup's [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#features), which populate the title and content of the popup based on each graphic's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html).
79858
+ * Sets the popup's [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features), which populate the title and content of the popup based on each graphic's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html).
79859
79859
  *
79860
79860
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79861
79861
  */
79862
79862
  features?: Graphic[];
79863
79863
  /**
79864
- * Sets pending [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#promises) on the popup.
79864
+ * Sets pending [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#promises) on the popup.
79865
79865
  *
79866
79866
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79867
79867
  */
79868
79868
  promises?: Promise<any>[];
79869
79869
  /**
79870
- * **Since:** 4.5 This property enables multiple features in a popup to display in a list rather than displaying the first selected feature.
79870
+ * This property enables multiple features in a popup to display in a list rather than displaying the first selected feature.
79871
79871
  *
79872
79872
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79873
79873
  */
79874
79874
  featureMenuOpen?: boolean;
79875
79875
  /**
79876
- * When `true` indicates the popup should update its [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#location) for each paginated feature based on the [selected feature's](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#selectedFeature) geometry.
79876
+ * When `true`, indicates the popup should update its [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) for each paginated feature based on the [selectedFeature's](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) geometry.
79877
79877
  *
79878
79878
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79879
79879
  */
79880
79880
  updateLocationEnabled?: boolean;
79881
79881
  /**
79882
- * **Since:** 4.5 When `true`, indicates that only the popup header will display.
79882
+ * When `true`, indicates that only the popup header will display.
79883
79883
  *
79884
79884
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79885
79885
  */
79886
79886
  collapsed?: boolean;
79887
79887
  /**
79888
- * **Since:** 4.23 When `true`, indicates that the focus should be on the popup after it has been opened.
79888
+ * When `true`, indicates that the focus should be on the popup after it has been opened.
79889
79889
  *
79890
79890
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-PopupView.html#openPopup)
79891
79891
  */
package/kernel.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.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"./core/has.js";import{getInterceptor as t,addQueryParameter as e}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";const a="4.27";let s=a;s="4.27.1";const r={async request(e,a){const{default:s}=await import("./request.js"),r=e.options,n=r.responseType;r.signal=a?.signal,r.responseType="native"===n||"native-request-init"===n?"native-request-init":n&&["blob","json","text"].includes(n)&&t(e.url)?.after?n:"array-buffer";const o=await s(e.url,r),i={data:o.data,httpStatus:o.httpStatus,ssl:o.ssl};switch(o.requestOptions?.responseType){case"native-request-init":return delete i.data.signal,i;case"blob":i.data=await i.data.arrayBuffer();break;case"json":i.data=(new TextEncoder).encode(JSON.stringify(i.data)).buffer;break;case"text":i.data=(new TextEncoder).encode(i.data).buffer}return{result:i,transferList:[i.data]}}};let n;function o(t){n=t}function i(t){const a=n?.findCredential(t);return a?.token?e(t,"token",a.token):t}has("host-webworker");export{i as addTokenParameter,s as fullVersion,n as id,o as setId,a as version,r as workerMessages};
5
+ import has from"./core/has.js";import{getInterceptor as t,addQueryParameter as e}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";const a="4.27";let s=a;s="4.27.2";const r={async request(e,a){const{default:s}=await import("./request.js"),r=e.options,n=r.responseType;r.signal=a?.signal,r.responseType="native"===n||"native-request-init"===n?"native-request-init":n&&["blob","json","text"].includes(n)&&t(e.url)?.after?n:"array-buffer";const o=await s(e.url,r),i={data:o.data,httpStatus:o.httpStatus,ssl:o.ssl};switch(o.requestOptions?.responseType){case"native-request-init":return delete i.data.signal,i;case"blob":i.data=await i.data.arrayBuffer();break;case"json":i.data=(new TextEncoder).encode(JSON.stringify(i.data)).buffer;break;case"text":i.data=(new TextEncoder).encode(i.data).buffer}return{result:i,transferList:[i.data]}}};let n;function o(t){n=t}function i(t){const a=n?.findCredential(t);return a?.token?e(t,"token",a.token):t}has("host-webworker");export{i as addTokenParameter,s as fullVersion,n as id,o as setId,a as version,r as workerMessages};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../core/lang.js";import n from"./RasterFunction.js";import{schema as t}from"./rasterFunctionUtils.js";import{getPixelValueRange as r}from"./rasterFormats/pixelRangeUtils.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,convertRGBATo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c=new Set(["u1","u2","u4","u8","s8","u16","s16"]),m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function p(e){return f.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.functionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.functionDefinition.arguments,t),r.rasterFunctionDefinition=r.functionDefinition.toJSON()}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const r=e(t[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(r.arguments[e]=h(o[e]),r.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(r.arguments[e].value=V(o[e]),r.arguments.ColorSchemeType.value=0):r.arguments[e].value=o[e];return r}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return w(e,n);case"class-breaks":return x(e,n);case"unique-value":return A(e,n);case"raster-colormap":return F(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,t){const r=new n;r.functionName="VectorFieldRenderer";const{dataType:o,bandNames:a}=t,i="vector-uv"===o;let s,u;if(a&&2===a.length){const e=a.map((e=>e.toLowerCase()));s=e.indexOf("magnitude"),u=e.indexOf("direction")}-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,f="flow-from"===e.flowRepresentation?0:1,p=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:f,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:p.minDataValue,maximumMagnitude:p.maxDataValue,minimumSymbolSize:p.minSize,maximumSymbolSize:p.maxSize};r.functionArguments=g;const d=h(r);return t.convertToRFT?n.fromJSON({rasterFunctionDefinition:d}):r}function v(e,t){const r=t.convertToRFT;if("elevation"!==t.dataType&&("generic"!==t.dataType||1!==t.bandCount||"s16"!==t.pixelType&&"s32"!==t.pixelType&&"f32"!==t.pixelType&&"f64"!==t.pixelType))return new n;const i=new n;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new n({rasterFunctionDefinition:h(i)}):i}function w(e,t){const r=t.convertToRFT,s=new n;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new n;if(r)l.functionArguments={ColorRamp:o(u)};else{const n=i(u);if(n)l.functionArguments={colorRamp:n};else if(!t.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new n({rasterFunctionDefinition:h(l)}):l}return r?new n({rasterFunctionDefinition:h(s)}):s}function x(e,t){const r=[],o=[],a=[],i=[],s=1e-6,{pixelType:u,rasterAttributeTable:l}=t,c=null==l?null:l.features,m=C(l);if(m&&c&&Array.isArray(c)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&c.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&i.push([a.attributes[m],r.r,r.g,r.b]))}))}));const r=u?S(i,u):i,o=new n;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=r,o.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?r.push(e.minValue,e.maxValue+s):r.push(e.minValue+s,e.maxValue+s),o.push(n),i.push([n,t.r,t.g,t.b])):a.push(e.minValue,e.maxValue)}));const f=u?S(i,u):i,p=new n;p.functionName="Remap",p.functionArguments={InputRanges:r,OutputValues:o,NoDataRanges:a},p.variableName="Raster";const g=new n;return g.functionName="Colormap",g.functionArguments={Colormap:f,Raster:p},t.convertToRFT?new n({rasterFunctionDefinition:h(g)}):g}function S(e,n){const t=c.has(n)?r(n):null;return t&&e.push([Math.floor(t[0]-1),0,0,0],[Math.ceil(t[1]+1),0,0,0]),e}function C(e){if(null==e)return;const{fields:n}=e,t=n&&n.find((e=>e&&e.name&&"value"===e.name.toLowerCase()));return t&&t.name}function A(e,t){const r=[],{pixelType:o,rasterAttributeTable:a}=t,i=null==a?null:a.features,s=C(a),u=e.defaultSymbol?.color?.toRgb(),l=e.uniqueValueInfos;if(l)if(i){if(s){const n=new Map;l.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r&&r.a&&n.set(String(t),r.toRgb())}));const t=e.field;i.forEach((({attributes:e})=>{const o=String(e[t]),a=e[s],i=n.get(o);i?r.push([a,...i]):u&&r.push([a,...u])}))}}else for(let n=0;n<l.length;n++){const e=l[n],t=e.symbol?.color,o=+e.value;if(t?.a){if(isNaN(o))return null;r.push([o,t.r,t.g,t.b])}}const c=o&&r.length>0?S(r,o):r,m=new n;return m.functionName="Colormap",m.functionArguments={},m.functionArguments.Colormap=c,m.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(m)}):m}function F(e,t){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=t,a=o?S(r,o):r,i=new n;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,t.convertToRFT?new n({rasterFunctionDefinition:h(i)}):i}function N(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function V(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(s([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{g as combineRenderingRules,y as convertRendererToRenderingRule,h as convertRenderingRuleToRFT,p as isSupportedRendererType};
5
+ import{clone as e}from"../../core/lang.js";import n from"./RasterFunction.js";import{schema as t}from"./rasterFunctionUtils.js";import{getPixelValueRange as r}from"./rasterFormats/pixelRangeUtils.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,convertRGBATo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c=new Set(["u1","u2","u4","u8","s8","u16","s16"]),m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function p(e){return f.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.functionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.functionDefinition.arguments,t),r.rasterFunctionDefinition=r.functionDefinition.toJSON()}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const r=e(t[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(r.arguments[e]=h(o[e]),r.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(r.arguments[e].value=V(o[e]),r.arguments.ColorSchemeType.value=0):r.arguments[e].value=o[e];return r}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return w(e,n);case"class-breaks":return x(e,n);case"unique-value":return A(e,n);case"raster-colormap":return F(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,t){const r=new n;r.functionName="VectorFieldRenderer";const{dataType:o,bandNames:a}=t,i="vector-uv"===o;let s,u;if(a&&2===a.length){const e=a.map((e=>e.toLowerCase()));s=e.indexOf("magnitude"),u=e.indexOf("direction")}-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,f="flow-from"===e.flowRepresentation?0:1,p=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:f,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:p.minDataValue,maximumMagnitude:p.maxDataValue,minimumSymbolSize:p.minSize,maximumSymbolSize:p.maxSize};r.functionArguments=g;const d=h(r);return t.convertToRFT?n.fromJSON({rasterFunctionDefinition:d}):r}function v(e,t){const r=t.convertToRFT;if("elevation"!==t.dataType&&("generic"!==t.dataType||1!==t.bandCount||"s16"!==t.pixelType&&"s32"!==t.pixelType&&"f32"!==t.pixelType&&"f64"!==t.pixelType))return new n;const i=new n;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new n({rasterFunctionDefinition:h(i)}):i}function w(e,t){const r=t.convertToRFT,s=new n;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new n;if(r)l.functionArguments={ColorRamp:o(u)};else{const n=i(u,!0);if(n)l.functionArguments={colorRamp:n};else if(!t.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new n({rasterFunctionDefinition:h(l)}):l}return r?new n({rasterFunctionDefinition:h(s)}):s}function x(e,t){const r=[],o=[],a=[],i=[],s=1e-6,{pixelType:u,rasterAttributeTable:l}=t,c=null==l?null:l.features,m=C(l);if(m&&c&&Array.isArray(c)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&c.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&i.push([a.attributes[m],r.r,r.g,r.b]))}))}));const r=u?S(i,u):i,o=new n;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=r,o.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?r.push(e.minValue,e.maxValue+s):r.push(e.minValue+s,e.maxValue+s),o.push(n),i.push([n,t.r,t.g,t.b])):a.push(e.minValue,e.maxValue)}));const f=u?S(i,u):i,p=new n;p.functionName="Remap",p.functionArguments={InputRanges:r,OutputValues:o,NoDataRanges:a},p.variableName="Raster";const g=new n;return g.functionName="Colormap",g.functionArguments={Colormap:f,Raster:p},t.convertToRFT?new n({rasterFunctionDefinition:h(g)}):g}function S(e,n){const t=c.has(n)?r(n):null;return t&&e.push([Math.floor(t[0]-1),0,0,0],[Math.ceil(t[1]+1),0,0,0]),e}function C(e){if(null==e)return;const{fields:n}=e,t=n&&n.find((e=>e&&e.name&&"value"===e.name.toLowerCase()));return t&&t.name}function A(e,t){const r=[],{pixelType:o,rasterAttributeTable:a}=t,i=null==a?null:a.features,s=C(a),u=e.defaultSymbol?.color?.toRgb(),l=e.uniqueValueInfos;if(l)if(i){if(s){const n=new Map;l.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r&&r.a&&n.set(String(t),r.toRgb())}));const t=e.field;i.forEach((({attributes:e})=>{const o=String(e[t]),a=e[s],i=n.get(o);i?r.push([a,...i]):u&&r.push([a,...u])}))}}else for(let n=0;n<l.length;n++){const e=l[n],t=e.symbol?.color,o=+e.value;if(t?.a){if(isNaN(o))return null;r.push([o,t.r,t.g,t.b])}}const c=o&&r.length>0?S(r,o):r,m=new n;return m.functionName="Colormap",m.functionArguments={},m.functionArguments.Colormap=c,m.variableName="Raster",t.convertToRFT?new n({rasterFunctionDefinition:h(m)}):m}function F(e,t){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=t,a=o?S(r,o):r,i=new n;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,t.convertToRFT?new n({rasterFunctionDefinition:h(i)}):i}function N(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function V(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(s([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{g as combineRenderingRules,y as convertRendererToRenderingRule,h as convertRenderingRuleToRFT,p as isSupportedRendererType};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.27.1",
3
+ "version": "4.27.2",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK 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.27/esri/copyright.txt for details.
4
4
  */
5
- import o from"../../Color.js";import{toLAB as r,toHSV as t,toLCH as l,toRGB as e}from"../../core/colorUtils.js";import{JSONMap as i}from"../../core/jsonMap.js";const n=["random","ndvi","ndvi2","ndvi3","elevation","gray","hillshade"],C=[{id:"aspect",type:"multipart",colorRamps:[{fromColor:[190,190,190],toColor:[255,45,8]},{fromColor:[255,45,8],toColor:[255,181,61]},{fromColor:[255,181,61],toColor:[255,254,52]},{fromColor:[255,254,52],toColor:[0,251,50]},{fromColor:[0,251,50],toColor:[255,254,52]},{fromColor:[0,253,255],toColor:[0,181,255]},{fromColor:[0,181,255],toColor:[26,35,253]},{fromColor:[26,35,253],toColor:[255,57,251]},{fromColor:[255,57,251],toColor:[255,45,8]}]},{id:"black-to-white",fromColor:[0,0,0],toColor:[255,255,255]},{id:"blue-bright",fromColor:[204,204,255],toColor:[0,0,224]},{id:"blue-light-to-dark",fromColor:[211,229,232],toColor:[46,100,140]},{id:"blue-green-bright",fromColor:[203,245,234],toColor:[48,207,146]},{id:"blue-green-light-to-dark",fromColor:[216,242,237],toColor:[21,79,74]},{id:"brown-light-to-dark",fromColor:[240,236,170],toColor:[102,72,48]},{id:"brown-to-blue-green-diverging-right",type:"multipart",colorRamps:[{fromColor:[156,85,31],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[33,130,145]}]},{id:"brown-to-blue-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[110,70,45],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[48,100,102]}]},{id:"coefficient-bias",fromColor:[214,214,255],toColor:[0,57,148]},{id:"cold-to-hot-diverging",type:"multipart",colorRamps:[{fromColor:[69,117,181],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[214,47,39]}]},{id:"condition-number",type:"multipart",colorRamps:[{fromColor:[0,97,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,34,0]}]},{id:"cyan-to-purple",type:"multipart",colorRamps:[{fromColor:[0,245,245],toColor:[0,0,245]},{fromColor:[0,0,245],toColor:[245,0,245]}]},{id:"cyan-light-to-blue-dark",type:"multipart",colorRamps:[{fromColor:[182,237,240],toColor:[31,131,224]},{fromColor:[31,131,224],toColor:[9,9,145]}]},{id:"distance",fromColor:[255,200,0],toColor:[0,0,255]},{id:"elevation1",type:"multipart",colorRamps:[{fromColor:[175,240,233],toColor:[255,255,179]},{fromColor:[255,255,179],toColor:[0,128,64]},{fromColor:[0,128,64],toColor:[252,186,3]},{fromColor:[252,186,3],toColor:[128,0,0]},{fromColor:[120,0,0],toColor:[105,48,13]},{fromColor:[105,48,13],toColor:[171,171,171]},{fromColor:[171,171,171],toColor:[255,252,255]}]},{id:"elevation2",type:"multipart",colorRamps:[{fromColor:[118,219,211],toColor:[255,255,199]},{fromColor:[255,255,199],toColor:[255,255,128]},{fromColor:[255,255,128],toColor:[217,194,121]},{fromColor:[217,194,121],toColor:[135,96,38]},{fromColor:[135,96,38],toColor:[150,150,181]},{fromColor:[150,150,181],toColor:[181,150,181]},{fromColor:[181,150,181],toColor:[255,252,255]}]},{id:"errors",fromColor:[255,235,214],toColor:[196,10,10]},{id:"gray-light-to-dark",fromColor:[219,219,219],toColor:[69,69,69]},{id:"green-bright",fromColor:[204,255,204],toColor:[14,204,14]},{id:"green-light-to-dark",fromColor:[220,245,233],toColor:[34,102,51]},{id:"green-to-blue",type:"multipart",colorRamps:[{fromColor:[32,204,16],toColor:[0,242,242]},{fromColor:[0,242,242],toColor:[2,33,227]}]},{id:"orange-bright",fromColor:[255,235,204],toColor:[240,118,5]},{id:"orange-light-to-dark",fromColor:[250,233,212],toColor:[171,65,36]},{id:"partial-spectrum",type:"multipart",colorRamps:[{fromColor:[242,241,162],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]},{fromColor:[252,3,69],toColor:[176,7,237]},{fromColor:[176,7,237],toColor:[2,29,173]}]},{id:"partial-spectrum-1-diverging",type:"multipart",colorRamps:[{fromColor:[135,38,38],toColor:[240,149,12]},{fromColor:[240,149,12],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[74,80,181]},{fromColor:[74,80,181],toColor:[39,32,122]}]},{id:"partial-spectrum-2-diverging",type:"multipart",colorRamps:[{fromColor:[115,77,42],toColor:[201,137,52]},{fromColor:[201,137,52],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[91,63,176]},{fromColor:[91,63,176],toColor:[81,13,97]}]},{id:"pink-to-yellow-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[158,30,113],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[99,110,45]}]},{id:"pink-to-yellow-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,47,73],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[22,59,15]}]},{id:"precipitation",type:"multipart",colorRamps:[{fromColor:[194,82,60],toColor:[237,161,19]},{fromColor:[237,161,19],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,219,0]},{fromColor:[0,219,0],toColor:[32,153,143]},{fromColor:[32,153,143],toColor:[11,44,122]}]},{id:"prediction",type:"multipart",colorRamps:[{fromColor:[40,146,199],toColor:[250,250,100]},{fromColor:[250,250,100],toColor:[232,16,20]}]},{id:"purple-bright",fromColor:[255,204,255],toColor:[199,0,199]},{id:"purple-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[77,32,150],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[20,122,11]}]},{id:"purple-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[67,14,89],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[24,79,15]}]},{id:"purple-blue-bright",fromColor:[223,184,230],toColor:[112,12,242]},{id:"purple-blue-light-to-dark",fromColor:[229,213,242],toColor:[93,44,112]},{id:"purple-red-bright",fromColor:[255,204,225],toColor:[199,0,99]},{id:"purple-red-light-to-dark",fromColor:[250,215,246],toColor:[143,17,57]},{id:"red-bright",fromColor:[255,204,204],toColor:[219,0,0]},{id:"red-light-to-dark",fromColor:[255,224,224],toColor:[143,10,10]},{id:"red-to-blue-diverging-bright",type:"multipart",colorRamps:[{fromColor:[196,69,57],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[48,95,207]}]},{id:"red-to-blue-diverging-dark",type:"multipart",colorRamps:[{fromColor:[107,13,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[13,53,97]}]},{id:"red-to-green",type:"multipart",colorRamps:[{fromColor:[245,0,0],toColor:[245,245,0]},{fromColor:[245,245,0],toColor:[0,245,0]}]},{id:"red-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[186,20,20],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[54,145,33]}]},{id:"red-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,21,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[16,69,16]}]},{id:"slope",type:"multipart",colorRamps:[{fromColor:[56,168,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]},{id:"spectrum-full-bright",type:"multipart",colorRamps:[{fromColor:[255,0,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,0,255]}]},{id:"spectrum-full-dark",type:"multipart",colorRamps:[{fromColor:[153,0,0],toColor:[153,153,0]},{fromColor:[153,153,0],toColor:[0,153,153]},{fromColor:[0,153,153],toColor:[0,0,153]}]},{id:"spectrum-full-light",type:"multipart",colorRamps:[{fromColor:[255,153,153],toColor:[255,255,153]},{fromColor:[255,255,153],toColor:[153,255,255]},{fromColor:[153,255,255],toColor:[153,153,255]}]},{id:"surface",type:"multipart",colorRamps:[{fromColor:[112,153,89],toColor:[242,238,162]},{fromColor:[242,238,162],toColor:[242,206,133]},{fromColor:[242,206,133],toColor:[194,140,124]},{fromColor:[194,140,124],toColor:[255,242,255]}]},{id:"temperature",type:"multipart",colorRamps:[{fromColor:[255,252,255],toColor:[255,0,255]},{fromColor:[255,0,255],toColor:[0,0,255]},{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,255,0]},{fromColor:[0,255,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,128,0]},{fromColor:[255,128,0],toColor:[128,0,0]}]},{id:"white-to-black",fromColor:[255,255,255],toColor:[0,0,0]},{id:"yellow-to-dark-red",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[242,167,46]},{fromColor:[242,167,46],toColor:[107,0,0]}]},{id:"yellow-to-green-to-dark-blue",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[56,224,9]},{fromColor:[56,224,9],toColor:[26,147,171]},{fromColor:[26,147,171],toColor:[12,16,120]}]},{id:"yellow-to-red",fromColor:[245,245,0],toColor:[255,0,0]},{id:"yellow-green-bright",fromColor:[236,252,204],toColor:[157,204,16]},{id:"yellow-green-light-to-dark",fromColor:[215,240,175],toColor:[96,107,45]}],a=new i({Aspect:"aspect","Black to White":"black-to-white","Blue Bright":"blue-bright","Blue Light to Dark":"blue-light-to-dark","Blue-Green Bright":"blue-green-bright","Blue-Green Light to Dark":"blue-green-light-to-dark","Brown Light to Dark":"brown-light-to-dark","Brown to Blue Green Diverging, Bright":"brown-to-blue-green-diverging-right","Brown to Blue Green Diverging, Dark":"brown-to-blue-green-diverging-dark","Coefficient Bias":"coefficient-bias","Cold to Hot Diverging":"cold-to-hot-diverging","Condition Number":"condition-number","Cyan to Purple":"cyan-to-purple","Cyan-Light to Blue-Dark":"cyan-light-to-blue-dark",Distance:"distance","Elevation #1":"elevation1","Elevation #2":"elevation2",Errors:"errors","Gray Light to Dark":"gray-light-to-dark","Green Bright":"green-bright","Green Light to Dark":"green-light-to-dark","Green to Blue":"green-to-blue","Orange Bright":"orange-bright","Orange Light to Dark":"orange-light-to-dark","Partial Spectrum":"partial-spectrum","Partial Spectrum 1 Diverging":"partial-spectrum-1-diverging","Partial Spectrum 2 Diverging":"partial-spectrum-2-diverging","Pink to YellowGreen Diverging, Bright":"pink-to-yellow-green-diverging-bright","Pink to YellowGreen Diverging, Dark":"pink-to-yellow-green-diverging-dark",Precipitation:"precipitation",Prediction:"prediction","Purple Bright":"purple-bright","Purple to Green Diverging, Bright":"purple-to-green-diverging-bright","Purple to Green Diverging, Dark":"purple-to-green-diverging-dark","Purple-Blue Bright":"purple-blue-bright","Purple-Blue Light to Dark":"purple-blue-light-to-dark","Purple-Red Bright":"purple-red-bright","Purple-Red Light to Dark":"purple-red-light-to-dark","Red Bright":"red-bright","Red Light to Dark":"red-light-to-dark","Red to Blue Diverging, Bright":"red-to-blue-diverging-bright","Red to Blue Diverging, Dark":"red-to-blue-diverging-dark","Red to Green":"red-to-green","Red to Green Diverging, Bright":"red-to-green-diverging-bright","Red to Green Diverging, Dark":"red-to-green-diverging-dark",Slope:"slope","Spectrum-Full Bright":"spectrum-full-bright","Spectrum-Full Dark":"spectrum-full-dark","Spectrum-Full Light":"spectrum-full-light",Surface:"surface",Temperature:"temperature","White to Black":"white-to-black","Yellow to Dark Red":"yellow-to-dark-red","Yellow to Green to Dark Blue":"yellow-to-green-to-dark-blue","Yellow to Red":"yellow-to-red","Yellow-Green Bright":"yellow-green-bright","Yellow-Green Light to Dark":"yellow-green-light-to-dark"});function m(o,r){if(!o||!r||o.length!==r.length)return!1;for(let t=0;t<o.length;t++)if(o[t]>r[t]+2||o[t]<r[t]-2)return!1;return!0}function g(o){const r=o.clone();return r.fromColor=o.toColor,r.toColor=o.fromColor,r.algorithm=o.algorithm,r}function p(o){if("multipart"===o.type){const r=o.clone();return r.colorRamps?.length?(r.colorRamps=r.colorRamps.reverse().map((o=>g(o))),r):r}return g(o)}function u(r,t){if(!r)return;const l=t??C;let e=null;return"algorithmic"===r.type?l.some((o=>{if(m(r.fromColor.toRgb(),o.fromColor)&&m(r.toColor.toRgb(),o.toColor))return e=o.id,!0})):"multipart"===r.type&&l.some((t=>{const l=r.colorRamps,i=t.colorRamps;if(l&&i&&l.length===i.length&&!i.some(((r,t)=>{if(!m(l[t].fromColor.toRgb(),new o(r.fromColor).toRgb())||!m(l[t].toColor.toRgb(),new o(r.toColor).toRgb()))return!0}))){if(e)return!0;e=t.id}})),e}function f(o,r){if(!o)return;let t=u(o,r);return null==t&&(t=u(o=p(o),r)),t}function s(o){const r="string"==typeof o?o:f(o);return r?a.toJSON(r):null}function c(o,r="esriCIELabAlgorithm"){const t=C.find((({id:r})=>r===o));return t?t.colorRamps?{type:"multipart",colorRamps:t.colorRamps.map((o=>({type:"algorithmic",algorithm:r,fromColor:[...o.fromColor],toColor:[...o.toColor]})))}:{type:"algorithmic",algorithm:r,fromColor:[...t.fromColor],toColor:[...t.toColor]}:null}function d(o){const r=(o=o||{}).numColors||256,t=o.distanceOffset||0,l=null!=o.isCustomInterval?o.isCustomInterval:null!==o.distanceInterval&&o.distanceInterval!==1/(r-1),e=o.distanceInterval||1/(r-1);return{...o,numColors:r,distanceOffset:t,interpolateAlpha:!!o.interpolateAlpha,distanceInterval:e,isCustomInterval:l,weights:o.weights}}function h(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=0===o.s,a=0===r.s;let m=o.h,g=r.h;C&&!a?m=g:a&&!C&&(r={...r,h:m},g=m);let p,u=Math.abs(g-m);const f=360;u<f/2?p=(g-m)*i:(u=f-u,p=m>g?u*i:-u*i);const s=(r.s-o.s)*i,c=(r.v-o.v)*i;let{s:d,v:h}=o,b=m;if(e){const o=e/i;b=(b+o*p+f)%f,d+=o*s,h+=o*c}const v=[];for(let k=0;k<l-1;k++)v.push({h:b,s:d,v:h}),b=(b+p+f)%f,d+=s,h+=c;return v.push(n?{h:b,s:d,v:h}:r),v}function b(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t;let{l:C,a,b:m}=o;const g=(r.l-C)*i,p=(r.a-a)*i,u=(r.b-m)*i,f=[];if(e){const o=e/i;C+=o*g,a+=o*p,m+=o*u}for(let s=0;s<l-1;s++)f.push({l:C,a,b:m}),C+=g,a+=p,m+=u;return f.push(n?{l:C,a,b:m}:r),f}function v(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=o.h,a=r.h,m=2*Math.PI;let g;if(C<=a){const o=a-C,r=a-C-m;g=Math.abs(r)<Math.abs(o)?r:o}else{const o=a+m-C,r=a-C;g=Math.abs(r)<Math.abs(o)?r:o}const p=g*i,u=(r.l-o.l)*i,f=(r.c-o.c)*i;let{l:s,c,h:d}=o;if(e){const o=e/i;s+=o*u,c+=o*f,d=(d+o*p+m)%m}const h=[];for(let b=0;b<l-1;b++)h.push({l:s,c,h:d}),s+=u,c+=f,d=(d+p+m)%m;return h.push(n?{l:s,c,h:d}:r),h}function k(o,i){let{fromColor:n,toColor:C}=o;n=[...n],C=[...C],3===n.length&&(n=n.concat([255])),3===C.length&&(C=C.concat([255]));const a=o.algorithm||"esriCIELabAlgorithm",m=d(i),{numColors:g,distanceOffset:p,isCustomInterval:u,interpolateAlpha:f}=m;if(1===g&&0===p)return[n];if(2===g&&0===p&&!u)return[n,C];const s={r:n[0],g:n[1],b:n[2]},c={r:C[0],g:C[1],b:C[2]},k="esriCIELabAlgorithm"===a?b(r(s),r(c),m):"esriHSVAlgorithm"===a?h(t(s),t(c),m):v(l(s),l(c),m),y=[],R=n[3]??255,w=((C[3]??255)-R)/(g-1);for(let r=0;r<g;r++){const{r:o,g:t,b:l}=e(k[r]),i=f?Math.round(R+w*r):255;y.push([o,t,l,i])}return y}function y(o,r){const{numColors:t,interpolateAlpha:l}=d(r);let e=r?.weights;const{colorRamps:i}=o;if(e){const o=e.reduce(((o,r)=>o+r));e=e.map((r=>r/o))}else{e=[];for(let o=0;o<i.length;o++)e[o]=1/i.length}const n=[];let C=0,a=0;const m=1/(t-1);let g=!1;for(let u=0;u<i.length;u++){let o=g?0:C*m-a,r=u===i.length-1?t-1-C:(e[u]-o)/m;if(g=Math.ceil(r)===r,r=Math.ceil(r),0===r)continue;o/=e[u];const p=k(i[u],{numColors:r,interpolateAlpha:l,distanceOffset:o,distanceInterval:m/e[u]});C+=p.length,n.push(...p),a+=e[u]}const p=[...i[i.length-1].toColor];return 3===p.length&&p.push(255),n.push(p),n}function R(o,r){const t="toJSON"in o?o.toJSON():o;return"multipart"===t.type?y(t,r):k(t,r)}function w(o,r){const t=R(o,r),l=r?.interpolateAlpha;return t.forEach(((o,r)=>{o.unshift(r),l||o.pop()})),t}function B(o){const r=t(o);return{type:"HsvColor",Hue:r.h,Saturation:r.s,Value:r.v,AlphaValue:255}}function D(o){const r=o.toJSON();return{Algorithm:r?.Algorithm||"esriHSVAlgorithm",type:"AlgorithmicColorRamp",FromColor:B(o.fromColor),ToColor:B(o.toColor)}}function I(o){const r=s(o);if(!r)return null;if("algorithmic"===o.type)return{...D(o),Name:r};if(o.colorRamps){const t=o.colorRamps.map(D);return{type:"MultiPartColorRamp",NumColorRamps:t.length,ArrayOfColorRamp:t,Name:r}}return null}function G(o){const r=o.reverse().map((o=>{const r=o.toString(16);return r.length<2?"0"+r:r}));return 4294967295&Number.parseInt(r.join(""),16)}export{C as PREDEFINED_JSON_COLOR_RAMPS,a as colorRampDict,w as convertColorRampToColormap,R as convertColorRampToColors,G as convertRGBATo32Bit,f as getColorRampId,c as getColorRampJSON,s as getColorRampName,I as getRFxArgColorRampValue,n as rasterColormapNames};
5
+ import o from"../../Color.js";import{toLAB as r,toHSV as t,toLCH as l,toRGB as e}from"../../core/colorUtils.js";import{JSONMap as i}from"../../core/jsonMap.js";const n=["random","ndvi","ndvi2","ndvi3","elevation","gray","hillshade"],C=[{id:"aspect",type:"multipart",colorRamps:[{fromColor:[190,190,190],toColor:[255,45,8]},{fromColor:[255,45,8],toColor:[255,181,61]},{fromColor:[255,181,61],toColor:[255,254,52]},{fromColor:[255,254,52],toColor:[0,251,50]},{fromColor:[0,251,50],toColor:[255,254,52]},{fromColor:[0,253,255],toColor:[0,181,255]},{fromColor:[0,181,255],toColor:[26,35,253]},{fromColor:[26,35,253],toColor:[255,57,251]},{fromColor:[255,57,251],toColor:[255,45,8]}]},{id:"black-to-white",fromColor:[0,0,0],toColor:[255,255,255]},{id:"blue-bright",fromColor:[204,204,255],toColor:[0,0,224]},{id:"blue-light-to-dark",fromColor:[211,229,232],toColor:[46,100,140]},{id:"blue-green-bright",fromColor:[203,245,234],toColor:[48,207,146]},{id:"blue-green-light-to-dark",fromColor:[216,242,237],toColor:[21,79,74]},{id:"brown-light-to-dark",fromColor:[240,236,170],toColor:[102,72,48]},{id:"brown-to-blue-green-diverging-right",type:"multipart",colorRamps:[{fromColor:[156,85,31],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[33,130,145]}]},{id:"brown-to-blue-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[110,70,45],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[48,100,102]}]},{id:"coefficient-bias",fromColor:[214,214,255],toColor:[0,57,148]},{id:"cold-to-hot-diverging",type:"multipart",colorRamps:[{fromColor:[69,117,181],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[214,47,39]}]},{id:"condition-number",type:"multipart",colorRamps:[{fromColor:[0,97,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,34,0]}]},{id:"cyan-to-purple",type:"multipart",colorRamps:[{fromColor:[0,245,245],toColor:[0,0,245]},{fromColor:[0,0,245],toColor:[245,0,245]}]},{id:"cyan-light-to-blue-dark",type:"multipart",colorRamps:[{fromColor:[182,237,240],toColor:[31,131,224]},{fromColor:[31,131,224],toColor:[9,9,145]}]},{id:"distance",fromColor:[255,200,0],toColor:[0,0,255]},{id:"elevation1",type:"multipart",colorRamps:[{fromColor:[175,240,233],toColor:[255,255,179]},{fromColor:[255,255,179],toColor:[0,128,64]},{fromColor:[0,128,64],toColor:[252,186,3]},{fromColor:[252,186,3],toColor:[128,0,0]},{fromColor:[120,0,0],toColor:[105,48,13]},{fromColor:[105,48,13],toColor:[171,171,171]},{fromColor:[171,171,171],toColor:[255,252,255]}]},{id:"elevation2",type:"multipart",colorRamps:[{fromColor:[118,219,211],toColor:[255,255,199]},{fromColor:[255,255,199],toColor:[255,255,128]},{fromColor:[255,255,128],toColor:[217,194,121]},{fromColor:[217,194,121],toColor:[135,96,38]},{fromColor:[135,96,38],toColor:[150,150,181]},{fromColor:[150,150,181],toColor:[181,150,181]},{fromColor:[181,150,181],toColor:[255,252,255]}]},{id:"errors",fromColor:[255,235,214],toColor:[196,10,10]},{id:"gray-light-to-dark",fromColor:[219,219,219],toColor:[69,69,69]},{id:"green-bright",fromColor:[204,255,204],toColor:[14,204,14]},{id:"green-light-to-dark",fromColor:[220,245,233],toColor:[34,102,51]},{id:"green-to-blue",type:"multipart",colorRamps:[{fromColor:[32,204,16],toColor:[0,242,242]},{fromColor:[0,242,242],toColor:[2,33,227]}]},{id:"orange-bright",fromColor:[255,235,204],toColor:[240,118,5]},{id:"orange-light-to-dark",fromColor:[250,233,212],toColor:[171,65,36]},{id:"partial-spectrum",type:"multipart",colorRamps:[{fromColor:[242,241,162],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]},{fromColor:[252,3,69],toColor:[176,7,237]},{fromColor:[176,7,237],toColor:[2,29,173]}]},{id:"partial-spectrum-1-diverging",type:"multipart",colorRamps:[{fromColor:[135,38,38],toColor:[240,149,12]},{fromColor:[240,149,12],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[74,80,181]},{fromColor:[74,80,181],toColor:[39,32,122]}]},{id:"partial-spectrum-2-diverging",type:"multipart",colorRamps:[{fromColor:[115,77,42],toColor:[201,137,52]},{fromColor:[201,137,52],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[91,63,176]},{fromColor:[91,63,176],toColor:[81,13,97]}]},{id:"pink-to-yellow-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[158,30,113],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[99,110,45]}]},{id:"pink-to-yellow-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,47,73],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[22,59,15]}]},{id:"precipitation",type:"multipart",colorRamps:[{fromColor:[194,82,60],toColor:[237,161,19]},{fromColor:[237,161,19],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,219,0]},{fromColor:[0,219,0],toColor:[32,153,143]},{fromColor:[32,153,143],toColor:[11,44,122]}]},{id:"prediction",type:"multipart",colorRamps:[{fromColor:[40,146,199],toColor:[250,250,100]},{fromColor:[250,250,100],toColor:[232,16,20]}]},{id:"purple-bright",fromColor:[255,204,255],toColor:[199,0,199]},{id:"purple-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[77,32,150],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[20,122,11]}]},{id:"purple-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[67,14,89],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[24,79,15]}]},{id:"purple-blue-bright",fromColor:[223,184,230],toColor:[112,12,242]},{id:"purple-blue-light-to-dark",fromColor:[229,213,242],toColor:[93,44,112]},{id:"purple-red-bright",fromColor:[255,204,225],toColor:[199,0,99]},{id:"purple-red-light-to-dark",fromColor:[250,215,246],toColor:[143,17,57]},{id:"red-bright",fromColor:[255,204,204],toColor:[219,0,0]},{id:"red-light-to-dark",fromColor:[255,224,224],toColor:[143,10,10]},{id:"red-to-blue-diverging-bright",type:"multipart",colorRamps:[{fromColor:[196,69,57],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[48,95,207]}]},{id:"red-to-blue-diverging-dark",type:"multipart",colorRamps:[{fromColor:[107,13,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[13,53,97]}]},{id:"red-to-green",type:"multipart",colorRamps:[{fromColor:[245,0,0],toColor:[245,245,0]},{fromColor:[245,245,0],toColor:[0,245,0]}]},{id:"red-to-green-diverging-bright",type:"multipart",colorRamps:[{fromColor:[186,20,20],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[54,145,33]}]},{id:"red-to-green-diverging-dark",type:"multipart",colorRamps:[{fromColor:[97,21,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[16,69,16]}]},{id:"slope",type:"multipart",colorRamps:[{fromColor:[56,168,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]},{id:"spectrum-full-bright",type:"multipart",colorRamps:[{fromColor:[255,0,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,0,255]}]},{id:"spectrum-full-dark",type:"multipart",colorRamps:[{fromColor:[153,0,0],toColor:[153,153,0]},{fromColor:[153,153,0],toColor:[0,153,153]},{fromColor:[0,153,153],toColor:[0,0,153]}]},{id:"spectrum-full-light",type:"multipart",colorRamps:[{fromColor:[255,153,153],toColor:[255,255,153]},{fromColor:[255,255,153],toColor:[153,255,255]},{fromColor:[153,255,255],toColor:[153,153,255]}]},{id:"surface",type:"multipart",colorRamps:[{fromColor:[112,153,89],toColor:[242,238,162]},{fromColor:[242,238,162],toColor:[242,206,133]},{fromColor:[242,206,133],toColor:[194,140,124]},{fromColor:[194,140,124],toColor:[255,242,255]}]},{id:"temperature",type:"multipart",colorRamps:[{fromColor:[255,252,255],toColor:[255,0,255]},{fromColor:[255,0,255],toColor:[0,0,255]},{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,255,0]},{fromColor:[0,255,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,128,0]},{fromColor:[255,128,0],toColor:[128,0,0]}]},{id:"white-to-black",fromColor:[255,255,255],toColor:[0,0,0]},{id:"yellow-to-dark-red",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[242,167,46]},{fromColor:[242,167,46],toColor:[107,0,0]}]},{id:"yellow-to-green-to-dark-blue",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[56,224,9]},{fromColor:[56,224,9],toColor:[26,147,171]},{fromColor:[26,147,171],toColor:[12,16,120]}]},{id:"yellow-to-red",fromColor:[245,245,0],toColor:[255,0,0]},{id:"yellow-green-bright",fromColor:[236,252,204],toColor:[157,204,16]},{id:"yellow-green-light-to-dark",fromColor:[215,240,175],toColor:[96,107,45]}],a=new i({Aspect:"aspect","Black to White":"black-to-white","Blue Bright":"blue-bright","Blue Light to Dark":"blue-light-to-dark","Blue-Green Bright":"blue-green-bright","Blue-Green Light to Dark":"blue-green-light-to-dark","Brown Light to Dark":"brown-light-to-dark","Brown to Blue Green Diverging, Bright":"brown-to-blue-green-diverging-right","Brown to Blue Green Diverging, Dark":"brown-to-blue-green-diverging-dark","Coefficient Bias":"coefficient-bias","Cold to Hot Diverging":"cold-to-hot-diverging","Condition Number":"condition-number","Cyan to Purple":"cyan-to-purple","Cyan-Light to Blue-Dark":"cyan-light-to-blue-dark",Distance:"distance","Elevation #1":"elevation1","Elevation #2":"elevation2",Errors:"errors","Gray Light to Dark":"gray-light-to-dark","Green Bright":"green-bright","Green Light to Dark":"green-light-to-dark","Green to Blue":"green-to-blue","Orange Bright":"orange-bright","Orange Light to Dark":"orange-light-to-dark","Partial Spectrum":"partial-spectrum","Partial Spectrum 1 Diverging":"partial-spectrum-1-diverging","Partial Spectrum 2 Diverging":"partial-spectrum-2-diverging","Pink to YellowGreen Diverging, Bright":"pink-to-yellow-green-diverging-bright","Pink to YellowGreen Diverging, Dark":"pink-to-yellow-green-diverging-dark",Precipitation:"precipitation",Prediction:"prediction","Purple Bright":"purple-bright","Purple to Green Diverging, Bright":"purple-to-green-diverging-bright","Purple to Green Diverging, Dark":"purple-to-green-diverging-dark","Purple-Blue Bright":"purple-blue-bright","Purple-Blue Light to Dark":"purple-blue-light-to-dark","Purple-Red Bright":"purple-red-bright","Purple-Red Light to Dark":"purple-red-light-to-dark","Red Bright":"red-bright","Red Light to Dark":"red-light-to-dark","Red to Blue Diverging, Bright":"red-to-blue-diverging-bright","Red to Blue Diverging, Dark":"red-to-blue-diverging-dark","Red to Green":"red-to-green","Red to Green Diverging, Bright":"red-to-green-diverging-bright","Red to Green Diverging, Dark":"red-to-green-diverging-dark",Slope:"slope","Spectrum-Full Bright":"spectrum-full-bright","Spectrum-Full Dark":"spectrum-full-dark","Spectrum-Full Light":"spectrum-full-light",Surface:"surface",Temperature:"temperature","White to Black":"white-to-black","Yellow to Dark Red":"yellow-to-dark-red","Yellow to Green to Dark Blue":"yellow-to-green-to-dark-blue","Yellow to Red":"yellow-to-red","Yellow-Green Bright":"yellow-green-bright","Yellow-Green Light to Dark":"yellow-green-light-to-dark"});function m(o,r){if(!o||!r||o.length!==r.length)return!1;for(let t=0;t<o.length;t++)if(o[t]>r[t]+2||o[t]<r[t]-2)return!1;return!0}function g(o){const r=o.clone();return r.fromColor=o.toColor,r.toColor=o.fromColor,r.algorithm=o.algorithm,r}function p(o){if("multipart"===o.type){const r=o.clone();return r.colorRamps?.length?(r.colorRamps=r.colorRamps.reverse().map((o=>g(o))),r):r}return g(o)}function u(r,t){if(!r)return;const l=t??C;let e=null;return"algorithmic"===r.type?l.some((o=>{if(m(r.fromColor.toRgb(),o.fromColor)&&m(r.toColor.toRgb(),o.toColor))return e=o.id,!0})):"multipart"===r.type&&l.some((t=>{const l=r.colorRamps,i=t.colorRamps;if(l&&i&&l.length===i.length&&!i.some(((r,t)=>{if(!m(l[t].fromColor.toRgb(),new o(r.fromColor).toRgb())||!m(l[t].toColor.toRgb(),new o(r.toColor).toRgb()))return!0}))){if(e)return!0;e=t.id}})),e}function f(o,r,t=!1){if(!o)return;let l=u(o,r);return null!=l||t||(l=u(o=p(o),r)),l}function s(o,r=!1){const t="string"==typeof o?o:f(o,void 0,r);return t?a.toJSON(t):null}function c(o,r="esriCIELabAlgorithm"){const t=C.find((({id:r})=>r===o));return t?t.colorRamps?{type:"multipart",colorRamps:t.colorRamps.map((o=>({type:"algorithmic",algorithm:r,fromColor:[...o.fromColor],toColor:[...o.toColor]})))}:{type:"algorithmic",algorithm:r,fromColor:[...t.fromColor],toColor:[...t.toColor]}:null}function d(o){const r=(o=o||{}).numColors||256,t=o.distanceOffset||0,l=null!=o.isCustomInterval?o.isCustomInterval:null!==o.distanceInterval&&o.distanceInterval!==1/(r-1),e=o.distanceInterval||1/(r-1);return{...o,numColors:r,distanceOffset:t,interpolateAlpha:!!o.interpolateAlpha,distanceInterval:e,isCustomInterval:l,weights:o.weights}}function h(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=0===o.s,a=0===r.s;let m=o.h,g=r.h;C&&!a?m=g:a&&!C&&(r={...r,h:m},g=m);let p,u=Math.abs(g-m);const f=360;u<f/2?p=(g-m)*i:(u=f-u,p=m>g?u*i:-u*i);const s=(r.s-o.s)*i,c=(r.v-o.v)*i;let{s:d,v:h}=o,b=m;if(e){const o=e/i;b=(b+o*p+f)%f,d+=o*s,h+=o*c}const v=[];for(let k=0;k<l-1;k++)v.push({h:b,s:d,v:h}),b=(b+p+f)%f,d+=s,h+=c;return v.push(n?{h:b,s:d,v:h}:r),v}function b(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t;let{l:C,a,b:m}=o;const g=(r.l-C)*i,p=(r.a-a)*i,u=(r.b-m)*i,f=[];if(e){const o=e/i;C+=o*g,a+=o*p,m+=o*u}for(let s=0;s<l-1;s++)f.push({l:C,a,b:m}),C+=g,a+=p,m+=u;return f.push(n?{l:C,a,b:m}:r),f}function v(o,r,t){const{numColors:l,distanceOffset:e,distanceInterval:i,isCustomInterval:n}=t,C=o.h,a=r.h,m=2*Math.PI;let g;if(C<=a){const o=a-C,r=a-C-m;g=Math.abs(r)<Math.abs(o)?r:o}else{const o=a+m-C,r=a-C;g=Math.abs(r)<Math.abs(o)?r:o}const p=g*i,u=(r.l-o.l)*i,f=(r.c-o.c)*i;let{l:s,c,h:d}=o;if(e){const o=e/i;s+=o*u,c+=o*f,d=(d+o*p+m)%m}const h=[];for(let b=0;b<l-1;b++)h.push({l:s,c,h:d}),s+=u,c+=f,d=(d+p+m)%m;return h.push(n?{l:s,c,h:d}:r),h}function k(o,i){let{fromColor:n,toColor:C}=o;n=[...n],C=[...C],3===n.length&&(n=n.concat([255])),3===C.length&&(C=C.concat([255]));const a=o.algorithm||"esriCIELabAlgorithm",m=d(i),{numColors:g,distanceOffset:p,isCustomInterval:u,interpolateAlpha:f}=m;if(1===g&&0===p)return[n];if(2===g&&0===p&&!u)return[n,C];const s={r:n[0],g:n[1],b:n[2]},c={r:C[0],g:C[1],b:C[2]},k="esriCIELabAlgorithm"===a?b(r(s),r(c),m):"esriHSVAlgorithm"===a?h(t(s),t(c),m):v(l(s),l(c),m),y=[],R=n[3]??255,w=((C[3]??255)-R)/(g-1);for(let r=0;r<g;r++){const{r:o,g:t,b:l}=e(k[r]),i=f?Math.round(R+w*r):255;y.push([o,t,l,i])}return y}function y(o,r){const{numColors:t,interpolateAlpha:l}=d(r);let e=r?.weights;const{colorRamps:i}=o;if(e){const o=e.reduce(((o,r)=>o+r));e=e.map((r=>r/o))}else{e=[];for(let o=0;o<i.length;o++)e[o]=1/i.length}const n=[];let C=0,a=0;const m=1/(t-1);let g=!1;for(let u=0;u<i.length;u++){let o=g?0:C*m-a,r=u===i.length-1?t-1-C:(e[u]-o)/m;if(g=Math.ceil(r)===r,r=Math.ceil(r),0===r)continue;o/=e[u];const p=k(i[u],{numColors:r,interpolateAlpha:l,distanceOffset:o,distanceInterval:m/e[u]});C+=p.length,n.push(...p),a+=e[u]}const p=[...i[i.length-1].toColor];return 3===p.length&&p.push(255),n.push(p),n}function R(o,r){const t="toJSON"in o?o.toJSON():o;return"multipart"===t.type?y(t,r):k(t,r)}function w(o,r){const t=R(o,r),l=r?.interpolateAlpha;return t.forEach(((o,r)=>{o.unshift(r),l||o.pop()})),t}function B(o){const r=t(o);return{type:"HsvColor",Hue:r.h,Saturation:r.s,Value:r.v,AlphaValue:255}}function D(o){const r=o.toJSON();return{Algorithm:r?.Algorithm||"esriHSVAlgorithm",type:"AlgorithmicColorRamp",FromColor:B(o.fromColor),ToColor:B(o.toColor)}}function I(o){const r=s(o);if(!r)return null;if("algorithmic"===o.type)return{...D(o),Name:r};if(o.colorRamps){const t=o.colorRamps.map(D);return{type:"MultiPartColorRamp",NumColorRamps:t.length,ArrayOfColorRamp:t,Name:r}}return null}function G(o){const r=o.reverse().map((o=>{const r=o.toString(16);return r.length<2?"0"+r:r}));return 4294967295&Number.parseInt(r.join(""),16)}export{C as PREDEFINED_JSON_COLOR_RAMPS,a as colorRampDict,w as convertColorRampToColormap,R as convertColorRampToColors,G as convertRGBATo32Bit,f as getColorRampId,c as getColorRampJSON,s as getColorRampName,I as getRFxArgColorRampValue,n as rasterColormapNames};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- const f="20230615",d="1f5db620f7f53ad9484d45c023aeb6d5fbf0f873";export{f as buildDate,d as commitHash};
5
+ const d="20230620",a="e278b6f97f6144b8b48dea4d47d999980aa8fcd9";export{d as buildDate,a 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Error.js";import{on as s,watch as i,initial as a}from"../core/reactiveUtils.js";import{formatFileSize as n}from"../core/unitFormatUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import c from"./Attachments/AttachmentsViewModel.js";import{getIconPath as m,isSupportedImage as h}from"./Attachments/support/attachmentUtils.js";import{loadCalciteComponents as u}from"./support/componentsUtils.js";import{storeNode as p,discardNode as g,isRTL as b}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{tsx as _}from"./support/jsxFactory.js";const v={addButton:!0,addSubmitButton:!0,cancelAddButton:!0,cancelUpdateButton:!0,deleteButton:!0,errorMessage:!0,progressBar:!0,updateButton:!0},y="esri-attachments",w="esri-button",A={base:y,loaderContainer:`${y}__loader-container`,loader:`${y}__loader`,fadeIn:`${y}--fade-in`,container:`${y}__container`,containerList:`${y}__container--list`,containerPreview:`${y}__container--preview`,actions:`${y}__actions`,deleteButton:`${y}__delete-button`,addAttachmentButton:`${y}__add-attachment-button`,errorMessage:`${y}__error-message`,items:`${y}__items`,item:`${y}__item`,itemButton:`${y}__item-button`,itemMask:`${y}__item-mask`,itemMaskIcon:`${y}__item-mask--icon`,itemImage:`${y}__image`,itemImageResizable:`${y}__image--resizable`,itemLabel:`${y}__label`,itemFilename:`${y}__filename`,itemChevronIcon:`${y}__item-chevron-icon`,itemLink:`${y}__item-link`,itemLinkOverlay:`${y}__item-link-overlay`,itemLinkOverlayIcon:`${y}__item-link-overlay-icon`,itemEditIcon:`${y}__item-edit-icon`,itemAddIcon:`${y}__item-add-icon`,itemAddButton:`${y}__item-add-button`,formNode:`${y}__form-node`,fileFieldset:`${y}__file-fieldset`,fileLabel:`${y}__file-label`,fileName:`${y}__file-name`,fileInput:`${y}__file-input`,metadata:`${y}__metadata`,metadataFieldset:`${y}__metadata-fieldset`,progressBar:`${y}__progress-bar`,esriWidget:"esri-widget",esriButton:w,buttonDisabled:`${w}--disabled`,esriButtonSecondary:`${w}--secondary`,esriButtonTertiary:`${w}--tertiary`,esriButtonThird:`${w}--third`,esriButtonSmall:`${w}--small`,esriButtonHalf:`${w}--half`,empty:"esri-widget__content--empty",iconExternalLink:"esri-icon-link-external",iconEdit:"esri-icon-edit",iconRight:"esri-icon-right",iconLeft:"esri-icon-left",iconPlus:"esri-icon-plus"},F=window.CSS;let k=class extends d{constructor(e,t){super(e,t),this.displayType="auto",this.messages=null,this.messagesUnits=null,this.selectedFile=null,this.submitting=!1,this.viewModel=null,this.visibleElements={...v},this._supportsImageOrientation=F&&F.supports&&F.supports("image-orientation","from-image"),this._addAttachmentForm=null,this._updateAttachmentForm=null}initialize(){this.viewModel||(this.viewModel=new c),this.addHandles([s((()=>this.viewModel?.attachmentInfos),"change",(()=>this.scheduleRender())),s((()=>this.viewModel?.fileInfos),"change",(()=>this.scheduleRender())),i((()=>this.viewModel?.mode),(()=>this._modeChanged()),a)])}loadDependencies(){return u({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")})}get capabilities(){return this.viewModel.capabilities}set capabilities(e){this.viewModel.capabilities=e}get effectiveDisplayType(){const{displayType:e}=this;return e&&"auto"!==e?e:this.viewModel.supportsResizeAttachments?"preview":"list"}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}castVisibleElements(e){return{...v,...e}}addAttachment(){const{_addAttachmentForm:e,viewModel:s}=this;return this._set("submitting",!0),this._set("error",null),s.addAttachment(e).then((e=>(this._set("submitting",!1),this._set("error",null),s.mode="view",e))).catch((e=>{throw this._set("submitting",!1),this._set("error",new t("attachments:add-attachment",this.messages.addErrorMessage,e)),e}))}deleteAttachment(e){const{viewModel:s}=this;return this._set("submitting",!0),this._set("error",null),s.deleteAttachment(e).then((e=>(this._set("submitting",!1),this._set("error",null),s.mode="view",e))).catch((e=>{throw this._set("submitting",!1),this._set("error",new t("attachments:delete-attachment",this.messages.deleteErrorMessage,e)),e}))}updateAttachment(){const{viewModel:e}=this,{_updateAttachmentForm:s}=this;return this._set("submitting",!0),this._set("error",null),e.updateAttachment(s).then((t=>(this._set("submitting",!1),this._set("error",null),e.mode="view",t))).catch((e=>{throw this._set("submitting",!1),this._set("error",new t("attachments:update-attachment",this.messages.updateErrorMessage,e)),e}))}addFile(){const e=this.viewModel.addFile(this.selectedFile,this._addAttachmentForm);return this.viewModel.mode="view",e}updateFile(){const{viewModel:e}=this,t=e.updateFile(this.selectedFile,this._updateAttachmentForm,e.activeFileInfo);return e.mode="view",t}deleteFile(e){const t=this.viewModel.deleteFile(e||this.viewModel.activeFileInfo?.file);return this.viewModel.mode="view",t}render(){const{submitting:e,viewModel:t}=this,{state:s}=t;return _("div",{class:this.classes(A.base,A.esriWidget)},e?this.renderProgressBar():null,"loading"===s?this.renderLoading():this.renderAttachments(),this.renderErrorMessage())}renderErrorMessage(){const{error:e,visibleElements:t}=this;return e&&t.errorMessage?_("div",{key:"error-message",class:A.errorMessage},e.message):null}renderAttachments(){const{activeFileInfo:e,mode:t,activeAttachmentInfo:s}=this.viewModel;return"add"===t?this.renderAddForm():"edit"===t?this.renderDetailsForm(s||e):this.renderAttachmentContainer()}renderLoading(){return _("div",{class:A.loaderContainer,key:"loader"},_("div",{class:A.loader}))}renderProgressBar(){return this.visibleElements.progressBar?_("div",{class:A.progressBar,key:"progress-bar"}):null}renderAddForm(){const{submitting:e,selectedFile:t}=this,s=e||!t,i=this.visibleElements.cancelAddButton?_("button",{type:"button",bind:this,disabled:e,onclick:this._cancelForm,class:this.classes(A.esriButton,A.esriButtonTertiary,A.esriButtonSmall,A.esriButtonHalf,e&&A.buttonDisabled)},this.messages.cancel):null,a=this.visibleElements.addSubmitButton?_("button",{type:"submit",disabled:s,class:this.classes(A.esriButton,A.esriButtonSecondary,A.esriButtonSmall,A.esriButtonHalf,{[A.buttonDisabled]:s})},this.messages.add):null,n=t?_("span",{key:"file-name",class:A.fileName},t.name):null,r=_("form",{bind:this,afterCreate:p,afterRemoved:g,"data-node-ref":"_addAttachmentForm",onsubmit:this._submitAddAttachment},_("fieldset",{class:A.fileFieldset},n,_("label",{class:this.classes(A.fileLabel,A.esriButton,A.esriButtonSecondary)},t?this.messages.changeFile:this.messages.selectFile,_("input",{class:A.fileInput,type:"file",name:"attachment",bind:this,onchange:this._handleFileInputChange}))),a,i);return _("div",{key:"add-form-container",class:A.formNode},r)}renderDetailsForm(e){const{visibleElements:t,viewModel:s,selectedFile:i,submitting:a}=this,{capabilities:r}=s,l=a||!i;let o,d,c,m;i?(o=i.type,d=i.name,c=i.size):e&&"file"in e?(o=e.file.type,d=e.file.name,c=e.file.size):e&&"contentType"in e&&(o=e.contentType,d=e.name,c=e.size,m=e.url);const h=r.editing&&r.operations?.delete&&t.deleteButton?_("button",{key:"delete-button",type:"button",disabled:a,bind:this,onclick:t=>this._submitDeleteAttachment(t,e),class:this.classes(A.esriButton,A.esriButtonSmall,A.esriButtonTertiary,A.deleteButton,{[A.buttonDisabled]:a})},this.messages.delete):void 0,u=r.editing&&r.operations?.update&&t.updateButton?_("button",{disabled:l,key:"update-button",type:"submit",class:this.classes(A.esriButton,A.esriButtonSmall,A.esriButtonThird,{[A.buttonDisabled]:l})},this.messages.update):void 0,b=this.visibleElements.cancelUpdateButton?_("button",{disabled:a,key:"cancel-button",type:"button",bind:this,onclick:this._cancelForm,class:this.classes(A.esriButton,A.esriButtonSmall,A.esriButtonTertiary,A.esriButtonThird,{[A.buttonDisabled]:a})},this.messages.cancel):void 0,f=r.editing&&r.operations?.update?_("fieldset",{key:"file",class:A.fileFieldset},_("span",{key:"file-name",class:A.fileName},d),_("label",{class:this.classes(A.fileLabel,A.esriButton,A.esriButtonSecondary)},this.messages.changeFile,_("input",{class:A.fileInput,type:"file",name:"attachment",bind:this,onchange:this._handleFileInputChange}))):void 0,v=_("fieldset",{key:"size",class:A.metadataFieldset},_("label",null,n(this.messagesUnits,c??0))),y=_("fieldset",{key:"content-type",class:A.metadataFieldset},_("label",null,o)),w=null!=m?_("a",{class:A.itemLink,href:m,rel:"noreferrer",target:"_blank"},this.renderImageMask(e,400),_("div",{class:A.itemLinkOverlay},_("span",{class:A.itemLinkOverlayIcon},_("calcite-icon",{icon:"launch"})))):this.renderImageMask(e,400),F=_("form",{bind:this,afterCreate:p,afterRemoved:g,"data-node-ref":"_updateAttachmentForm",onsubmit:t=>this._submitUpdateAttachment(t,e)},_("div",{class:A.metadata},v,y),f,_("div",{class:A.actions},h,b,u));return _("div",{key:"edit-form-container",class:A.formNode},w,F)}renderImageMask(e,t){return e?"file"in e?this.renderGenericImageMask(e.file.name,e.file.type):this.renderImageMaskForAttachment(e,t):null}renderGenericImageMask(e,t){const{supportsResizeAttachments:s}=this.viewModel,i=m(t),a={[A.itemImageResizable]:s};return _("div",{class:this.classes(A.itemMaskIcon,A.itemMask)},_("img",{title:e,alt:e,src:i,class:this.classes(a,A.itemImage)}))}renderImageMaskForAttachment(e,t){const{supportsResizeAttachments:s}=this.viewModel;if(!e)return null;const{contentType:i,name:a,url:n}=e;if(!s||!h(i))return this.renderGenericImageMask(a,i);const r=this._getCSSTransform(e),l=r?{transform:r,"image-orientation":"none"}:{},o=`${n}${n?.includes("?")?"&":"?"}w=${t}`,d={[A.itemImageResizable]:s};return _("div",{class:this.classes(A.itemMask)},_("img",{styles:l,alt:a,title:a,src:o,class:this.classes(d,A.itemImage)}))}renderFile(e){const{file:t}=e;return _("li",{class:A.item,key:t},_("button",{key:"details-button",bind:this,class:A.itemButton,title:this.messages.attachmentDetails,"aria-label":this.messages.attachmentDetails,onclick:()=>this._startEditFile(e),type:"button"},this.renderImageMask(e),_("label",{class:A.itemLabel},_("span",{class:A.itemFilename},t.name||this.messages.noTitle),_("span",{"aria-hidden":"true",class:this.classes(A.itemChevronIcon,b(this.container)?A.iconLeft:A.iconRight)}))))}renderAttachmentInfo({attachmentInfo:e,displayType:t}){const{viewModel:s,effectiveDisplayType:i}=this,{capabilities:a,supportsResizeAttachments:n}=s,{contentType:r,name:l,url:o}=e,d=this.renderImageMask(e,"list"===t?48:400),c=a.editing?_("span",{"aria-hidden":"true",class:this.classes(A.itemChevronIcon,b(this.container)?A.iconLeft:A.iconRight)}):null,m=[d,"preview"===i&&n&&h(r)?null:_("label",{class:A.itemLabel},_("span",{class:A.itemFilename},l||this.messages.noTitle),c)],u=a.editing?_("button",{key:"details-button",bind:this,class:A.itemButton,title:this.messages.attachmentDetails,"aria-label":this.messages.attachmentDetails,"data-attachment-info-id":e.id,onclick:()=>this._startEditAttachment(e),type:"button"},m):_("a",{key:"details-link",class:A.itemButton,href:o??void 0,target:"_blank"},m);return _("li",{class:A.item,key:e},u)}renderAttachmentContainer(){const{effectiveDisplayType:e,viewModel:t,visibleElements:s}=this,{attachmentInfos:i,capabilities:a,fileInfos:n}=t,r=!!i?.length,l=!!n?.length,o={[A.containerList]:"preview"!==e,[A.containerPreview]:"preview"===e},d=a.editing&&a.operations?.add&&s.addButton?_("button",{bind:this,onclick:()=>this._startAddAttachment(),class:this.classes(A.esriButton,A.esriButtonTertiary,A.addAttachmentButton),type:"button"},_("span",{"aria-hidden":"true",class:this.classes(A.itemAddIcon,A.iconPlus)}),this.messages.add):void 0,c=r?_("ul",{key:"attachments-list",class:A.items},i.toArray().map((t=>this.renderAttachmentInfo({attachmentInfo:t,displayType:e})))):void 0,m=l?_("ul",{key:"file-list",class:A.items},n.toArray().map((e=>this.renderFile(e)))):void 0,h=l||r?void 0:_("div",{class:A.empty},this.messages.noAttachments);return _("div",{key:"attachments-container",class:this.classes(A.container,o)},c,m,h,d)}_modeChanged(){this._set("error",null),this._set("selectedFile",null)}_handleFileInputChange(e){const t=e.target,s=t&&t.files&&t.files.item(0);this._set("selectedFile",s)}_submitDeleteAttachment(e,t){e.preventDefault(),t&&("file"in t?this.deleteFile(t.file):t&&this.deleteAttachment(t))}_submitAddAttachment(e){e.preventDefault(),this.viewModel.filesEnabled?this.addFile():this.addAttachment()}_submitUpdateAttachment(e,t){e.preventDefault(),t&&"file"in t?this.updateFile():this.updateAttachment()}_startEditAttachment(e){const{viewModel:t}=this;t.activeFileInfo=null,t.activeAttachmentInfo=e,t.mode="edit"}_startEditFile(e){const{viewModel:t}=this;t.activeAttachmentInfo=null,t.activeFileInfo=e,t.mode="edit"}_startAddAttachment(){this.viewModel.mode="add"}_cancelForm(e){e.preventDefault(),this.viewModel.mode="view"}_getCSSTransform(e){const{orientationInfo:t}=e;return!this._supportsImageOrientation&&t?[t.rotation?`rotate(${t.rotation}deg)`:"",t.mirrored?"scaleX(-1)":""].join(" "):""}};e([r()],k.prototype,"capabilities",null),e([r()],k.prototype,"displayType",void 0),e([r({readOnly:!0})],k.prototype,"effectiveDisplayType",null),e([r()],k.prototype,"graphic",null),e([r()],k.prototype,"label",null),e([r(),f("esri/widgets/Attachments/t9n/Attachments")],k.prototype,"messages",void 0),e([r(),f("esri/core/t9n/Units")],k.prototype,"messagesUnits",void 0),e([r({readOnly:!0})],k.prototype,"selectedFile",void 0),e([r({readOnly:!0})],k.prototype,"submitting",void 0),e([r({readOnly:!0})],k.prototype,"error",void 0),e([r({type:c})],k.prototype,"viewModel",void 0),e([r()],k.prototype,"visibleElements",void 0),e([l("visibleElements")],k.prototype,"castVisibleElements",null),k=e([o("esri.widgets.Attachments")],k);const B=k;export{B as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Error.js";import{on as s,watch as i,initial as a}from"../core/reactiveUtils.js";import{formatFileSize as n}from"../core/unitFormatUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{cast as l}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as o}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import c from"./Attachments/AttachmentsViewModel.js";import{getIconPath as m,isSupportedImage as h}from"./Attachments/support/attachmentUtils.js";import{loadCalciteComponents as u}from"./support/componentsUtils.js";import{storeNode as p,discardNode as g,isRTL as b}from"./support/widgetUtils.js";import{messageBundle as f}from"./support/decorators/messageBundle.js";import{tsx as _}from"./support/jsxFactory.js";const v={addButton:!0,addSubmitButton:!0,cancelAddButton:!0,cancelUpdateButton:!0,deleteButton:!0,errorMessage:!0,progressBar:!0,updateButton:!0},y="esri-attachments",w="esri-button",A={base:y,loaderContainer:`${y}__loader-container`,loader:`${y}__loader`,fadeIn:`${y}--fade-in`,container:`${y}__container`,containerList:`${y}__container--list`,containerPreview:`${y}__container--preview`,actions:`${y}__actions`,deleteButton:`${y}__delete-button`,addAttachmentButton:`${y}__add-attachment-button`,errorMessage:`${y}__error-message`,items:`${y}__items`,item:`${y}__item`,itemButton:`${y}__item-button`,itemMask:`${y}__item-mask`,itemMaskIcon:`${y}__item-mask--icon`,itemImage:`${y}__image`,itemImageResizable:`${y}__image--resizable`,itemLabel:`${y}__label`,itemFilename:`${y}__filename`,itemChevronIcon:`${y}__item-chevron-icon`,itemLink:`${y}__item-link`,itemLinkOverlay:`${y}__item-link-overlay`,itemLinkOverlayIcon:`${y}__item-link-overlay-icon`,itemEditIcon:`${y}__item-edit-icon`,itemAddIcon:`${y}__item-add-icon`,itemAddButton:`${y}__item-add-button`,formNode:`${y}__form-node`,fileFieldset:`${y}__file-fieldset`,fileLabel:`${y}__file-label`,fileName:`${y}__file-name`,fileInput:`${y}__file-input`,metadata:`${y}__metadata`,metadataFieldset:`${y}__metadata-fieldset`,progressBar:`${y}__progress-bar`,esriWidget:"esri-widget",esriButton:w,buttonDisabled:`${w}--disabled`,esriButtonSecondary:`${w}--secondary`,esriButtonTertiary:`${w}--tertiary`,esriButtonThird:`${w}--third`,esriButtonSmall:`${w}--small`,esriButtonHalf:`${w}--half`,empty:"esri-widget__content--empty",iconExternalLink:"esri-icon-link-external",iconEdit:"esri-icon-edit",iconRight:"esri-icon-right",iconLeft:"esri-icon-left",iconPlus:"esri-icon-plus"},k=window.CSS;let F=class extends d{constructor(e,t){super(e,t),this.displayType="auto",this.messages=null,this.messagesUnits=null,this.selectedFile=null,this.submitting=!1,this.viewModel=null,this.visibleElements={...v},this._supportsImageOrientation=k&&k.supports&&k.supports("image-orientation","from-image"),this._addAttachmentForm=null,this._updateAttachmentForm=null}initialize(){this.viewModel||(this.viewModel=new c),this.addHandles([s((()=>this.viewModel?.attachmentInfos),"change",(()=>this.scheduleRender())),s((()=>this.viewModel?.fileInfos),"change",(()=>this.scheduleRender())),i((()=>this.viewModel?.mode),(()=>this._modeChanged()),a)])}loadDependencies(){return u({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js")})}get capabilities(){return this.viewModel.capabilities}set capabilities(e){this.viewModel.capabilities=e}get effectiveDisplayType(){const{displayType:e}=this;return e&&"auto"!==e?e:this.viewModel.supportsResizeAttachments?"preview":"list"}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}castVisibleElements(e){return{...v,...e}}addAttachment(){const{_addAttachmentForm:e,viewModel:s}=this;return this._set("submitting",!0),this._set("error",null),s.addAttachment(e).then((e=>(this._set("submitting",!1),this._set("error",null),s.mode="view",e))).catch((e=>{throw this._set("submitting",!1),this._set("error",new t("attachments:add-attachment",this.messages.addErrorMessage,e)),e}))}deleteAttachment(e){const{viewModel:s}=this;return this._set("submitting",!0),this._set("error",null),s.deleteAttachment(e).then((e=>(this._set("submitting",!1),this._set("error",null),s.mode="view",e))).catch((e=>{throw this._set("submitting",!1),this._set("error",new t("attachments:delete-attachment",this.messages.deleteErrorMessage,e)),e}))}updateAttachment(){const{viewModel:e}=this,{_updateAttachmentForm:s}=this;return this._set("submitting",!0),this._set("error",null),e.updateAttachment(s).then((t=>(this._set("submitting",!1),this._set("error",null),e.mode="view",t))).catch((e=>{throw this._set("submitting",!1),this._set("error",new t("attachments:update-attachment",this.messages.updateErrorMessage,e)),e}))}addFile(){const e=this.viewModel.addFile(this.selectedFile,this._addAttachmentForm);return this.viewModel.mode="view",e}updateFile(){const{viewModel:e}=this,t=e.updateFile(this.selectedFile,this._updateAttachmentForm,e.activeFileInfo);return e.mode="view",t}deleteFile(e){const t=this.viewModel.deleteFile(e||this.viewModel.activeFileInfo?.file);return this.viewModel.mode="view",t}render(){const{submitting:e,viewModel:t}=this,{state:s}=t;return _("div",{class:this.classes(A.base,A.esriWidget)},e?this.renderProgressBar():null,"loading"===s?this.renderLoading():this.renderAttachments(),this.renderErrorMessage())}renderErrorMessage(){const{error:e,visibleElements:t}=this;return e&&t.errorMessage?_("div",{key:"error-message",class:A.errorMessage},e.message):null}renderAttachments(){const{activeFileInfo:e,mode:t,activeAttachmentInfo:s}=this.viewModel;return"add"===t?this.renderAddForm():"edit"===t?this.renderDetailsForm(s||e):this.renderAttachmentContainer()}renderLoading(){return _("div",{class:A.loaderContainer,key:"loader"},_("div",{class:A.loader}))}renderProgressBar(){return this.visibleElements.progressBar?_("div",{class:A.progressBar,key:"progress-bar"}):null}renderAddForm(){const{submitting:e,selectedFile:t}=this,s=e||!t,i=this.visibleElements.cancelAddButton?_("button",{type:"button",bind:this,disabled:e,onclick:this._cancelForm,class:this.classes(A.esriButton,A.esriButtonTertiary,A.esriButtonSmall,A.esriButtonHalf,e&&A.buttonDisabled)},this.messages.cancel):null,a=this.visibleElements.addSubmitButton?_("button",{type:"submit",disabled:s,class:this.classes(A.esriButton,A.esriButtonSecondary,A.esriButtonSmall,A.esriButtonHalf,{[A.buttonDisabled]:s})},this.messages.add):null,n=t?_("span",{key:"file-name",class:A.fileName},t.name):null,r=_("form",{bind:this,afterCreate:p,afterRemoved:g,"data-node-ref":"_addAttachmentForm",onsubmit:this._submitAddAttachment},_("fieldset",{class:A.fileFieldset},n,_("label",{class:this.classes(A.fileLabel,A.esriButton,A.esriButtonSecondary)},t?this.messages.changeFile:this.messages.selectFile,_("input",{class:A.fileInput,type:"file",name:"attachment",bind:this,onchange:this._handleFileInputChange}))),a,i);return _("div",{key:"add-form-container",class:A.formNode},r)}renderDetailsForm(e){const{visibleElements:t,viewModel:s,selectedFile:i,submitting:a}=this,{capabilities:r}=s,l=a||!i;let o,d,c,m;i?(o=i.type,d=i.name,c=i.size):e&&"file"in e?(o=e.file.type,d=e.file.name,c=e.file.size):e&&"contentType"in e&&(o=e.contentType,d=e.name,c=e.size,m=e.url);const h=r.editing&&r.operations?.delete&&t.deleteButton?_("button",{key:"delete-button",type:"button",disabled:a,bind:this,onclick:t=>this._submitDeleteAttachment(t,e),class:this.classes(A.esriButton,A.esriButtonSmall,A.esriButtonTertiary,A.deleteButton,{[A.buttonDisabled]:a})},this.messages.delete):void 0,u=r.editing&&r.operations?.update&&t.updateButton?_("button",{disabled:l,key:"update-button",type:"submit",class:this.classes(A.esriButton,A.esriButtonSmall,A.esriButtonThird,{[A.buttonDisabled]:l})},this.messages.update):void 0,b=this.visibleElements.cancelUpdateButton?_("button",{disabled:a,key:"cancel-button",type:"button",bind:this,onclick:this._cancelForm,class:this.classes(A.esriButton,A.esriButtonSmall,A.esriButtonTertiary,A.esriButtonThird,{[A.buttonDisabled]:a})},this.messages.cancel):void 0,f=r.editing&&r.operations?.update?_("fieldset",{key:"file",class:A.fileFieldset},_("span",{key:"file-name",class:A.fileName},d),_("label",{class:this.classes(A.fileLabel,A.esriButton,A.esriButtonSecondary)},this.messages.changeFile,_("input",{class:A.fileInput,type:"file",name:"attachment",bind:this,onchange:this._handleFileInputChange}))):void 0,v=_("fieldset",{key:"size",class:A.metadataFieldset},_("label",null,n(this.messagesUnits,c??0))),y=_("fieldset",{key:"content-type",class:A.metadataFieldset},_("label",null,o)),w=null!=m?_("a",{class:A.itemLink,href:m,rel:"noreferrer",target:"_blank"},this.renderImageMask(e,400),_("div",{class:A.itemLinkOverlay},_("span",{class:A.itemLinkOverlayIcon},_("calcite-icon",{icon:"launch"})))):this.renderImageMask(e,400),k=_("form",{bind:this,afterCreate:p,afterRemoved:g,"data-node-ref":"_updateAttachmentForm",onsubmit:t=>this._submitUpdateAttachment(t,e)},_("div",{class:A.metadata},v,y),f,_("div",{class:A.actions},h,b,u));return _("div",{key:"edit-form-container",class:A.formNode},w,k)}renderImageMask(e,t){return e?"file"in e?this.renderGenericImageMask(e.file.name,e.file.type):this.renderImageMaskForAttachment(e,t):null}renderGenericImageMask(e,t){const{supportsResizeAttachments:s}=this.viewModel,i=m(t),a={[A.itemImageResizable]:s};return _("div",{key:i,class:this.classes(A.itemMaskIcon,A.itemMask)},_("img",{title:e,alt:e,src:i,class:this.classes(a,A.itemImage)}))}renderImageMaskForAttachment(e,t){const{supportsResizeAttachments:s}=this.viewModel;if(!e)return null;const{contentType:i,name:a,url:n}=e;if(!s||!h(i))return this.renderGenericImageMask(a,i);const r=this._getCSSTransform(e),l=r?{transform:r,"image-orientation":"none"}:{},o=`${n}${n?.includes("?")?"&":"?"}w=${t}`,d={[A.itemImageResizable]:s};return _("div",{key:o,class:this.classes(A.itemMask)},_("img",{styles:l,alt:a,title:a,src:o,class:this.classes(d,A.itemImage)}))}renderFile(e){const{file:t}=e;return _("li",{class:A.item,key:t},_("button",{key:"details-button",bind:this,class:A.itemButton,title:this.messages.attachmentDetails,"aria-label":this.messages.attachmentDetails,onclick:()=>this._startEditFile(e),type:"button"},this.renderImageMask(e),_("label",{class:A.itemLabel},_("span",{class:A.itemFilename},t.name||this.messages.noTitle),_("span",{"aria-hidden":"true",class:this.classes(A.itemChevronIcon,b(this.container)?A.iconLeft:A.iconRight)}))))}renderAttachmentInfo({attachmentInfo:e,displayType:t}){const{viewModel:s,effectiveDisplayType:i}=this,{capabilities:a,supportsResizeAttachments:n}=s,{contentType:r,name:l,url:o}=e,d=this.renderImageMask(e,"list"===t?48:400),c=a.editing?_("span",{"aria-hidden":"true",class:this.classes(A.itemChevronIcon,b(this.container)?A.iconLeft:A.iconRight)}):null,m=[d,"preview"===i&&n&&h(r)?null:_("label",{class:A.itemLabel},_("span",{class:A.itemFilename},l||this.messages.noTitle),c)],u=a.editing?_("button",{key:"details-button",bind:this,class:A.itemButton,title:this.messages.attachmentDetails,"aria-label":this.messages.attachmentDetails,"data-attachment-info-id":e.id,onclick:()=>this._startEditAttachment(e),type:"button"},m):_("a",{key:"details-link",class:A.itemButton,href:o??void 0,target:"_blank"},m);return _("li",{class:A.item,key:e},u)}renderAttachmentContainer(){const{effectiveDisplayType:e,viewModel:t,visibleElements:s}=this,{attachmentInfos:i,capabilities:a,fileInfos:n}=t,r=!!i?.length,l=!!n?.length,o={[A.containerList]:"preview"!==e,[A.containerPreview]:"preview"===e},d=a.editing&&a.operations?.add&&s.addButton?_("button",{bind:this,onclick:()=>this._startAddAttachment(),class:this.classes(A.esriButton,A.esriButtonTertiary,A.addAttachmentButton),type:"button"},_("span",{"aria-hidden":"true",class:this.classes(A.itemAddIcon,A.iconPlus)}),this.messages.add):void 0,c=r?_("ul",{key:"attachments-list",class:A.items},i.toArray().map((t=>this.renderAttachmentInfo({attachmentInfo:t,displayType:e})))):void 0,m=l?_("ul",{key:"file-list",class:A.items},n.toArray().map((e=>this.renderFile(e)))):void 0,h=l||r?void 0:_("div",{class:A.empty},this.messages.noAttachments);return _("div",{key:"attachments-container",class:this.classes(A.container,o)},c,m,h,d)}_modeChanged(){this._set("error",null),this._set("selectedFile",null)}_handleFileInputChange(e){const t=e.target,s=t&&t.files&&t.files.item(0);this._set("selectedFile",s)}_submitDeleteAttachment(e,t){e.preventDefault(),t&&("file"in t?this.deleteFile(t.file):t&&this.deleteAttachment(t))}_submitAddAttachment(e){e.preventDefault(),this.viewModel.filesEnabled?this.addFile():this.addAttachment()}_submitUpdateAttachment(e,t){e.preventDefault(),t&&"file"in t?this.updateFile():this.updateAttachment()}_startEditAttachment(e){const{viewModel:t}=this;t.activeFileInfo=null,t.activeAttachmentInfo=e,t.mode="edit"}_startEditFile(e){const{viewModel:t}=this;t.activeAttachmentInfo=null,t.activeFileInfo=e,t.mode="edit"}_startAddAttachment(){this.viewModel.mode="add"}_cancelForm(e){e.preventDefault(),this.viewModel.mode="view"}_getCSSTransform(e){const{orientationInfo:t}=e;return!this._supportsImageOrientation&&t?[t.rotation?`rotate(${t.rotation}deg)`:"",t.mirrored?"scaleX(-1)":""].join(" "):""}};e([r()],F.prototype,"capabilities",null),e([r()],F.prototype,"displayType",void 0),e([r({readOnly:!0})],F.prototype,"effectiveDisplayType",null),e([r()],F.prototype,"graphic",null),e([r()],F.prototype,"label",null),e([r(),f("esri/widgets/Attachments/t9n/Attachments")],F.prototype,"messages",void 0),e([r(),f("esri/core/t9n/Units")],F.prototype,"messagesUnits",void 0),e([r({readOnly:!0})],F.prototype,"selectedFile",void 0),e([r({readOnly:!0})],F.prototype,"submitting",void 0),e([r({readOnly:!0})],F.prototype,"error",void 0),e([r({type:c})],F.prototype,"viewModel",void 0),e([r()],F.prototype,"visibleElements",void 0),e([l("visibleElements")],F.prototype,"castVisibleElements",null),F=e([o("esri.widgets.Attachments")],F);const B=F;export{B 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as i}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Attachments.js";import a from"../Widget.js";import p from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import n from"./support/FeatureElementInfo.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";const d={base:"esri-feature-attachments"};let c=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attachmentsWidget=new o,this.headingLevel=2,this.viewModel=new p}initialize(){this._featureElementInfo=new n,this.addHandles([t((()=>[this.viewModel?.description,this.viewModel?.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),i),t((()=>this.viewModel),(e=>this.attachmentsWidget.viewModel=e),i)])}destroy(){this.attachmentsWidget.destroy(),this._featureElementInfo?.destroy()}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get displayType(){return this.attachmentsWidget.displayType}set displayType(e){this.attachmentsWidget.displayType=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){const{attachmentsWidget:e}=this;return l("div",{class:d.base},this._featureElementInfo?.render(),e?.render())}_setupFeatureElementInfo(){const{description:e,title:t,headingLevel:i}=this;this._featureElementInfo?.set({description:e,title:t,headingLevel:i})}};e([s({readOnly:!0})],c.prototype,"attachmentsWidget",void 0),e([s()],c.prototype,"description",null),e([s()],c.prototype,"displayType",null),e([s()],c.prototype,"graphic",null),e([s()],c.prototype,"headingLevel",void 0),e([s()],c.prototype,"title",null),e([s({type:p})],c.prototype,"viewModel",void 0),c=e([r("esri.widgets.Feature.FeatureAttachments")],c);const h=c;export{h as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as i}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Attachments.js";import a from"../Widget.js";import n from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import p from"./support/FeatureElementInfo.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";const d={base:"esri-feature-attachments"};let c=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attachmentsWidget=new o,this.headingLevel=2,this.viewModel=new n}initialize(){this._featureElementInfo=new p,this.addHandles([t((()=>[this.viewModel?.description,this.viewModel?.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),i),t((()=>this.viewModel),(e=>this.attachmentsWidget.viewModel=e),i)])}destroy(){this.attachmentsWidget.viewModel=null,this.attachmentsWidget.destroy(),this._featureElementInfo?.destroy()}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get displayType(){return this.attachmentsWidget.displayType}set displayType(e){this.attachmentsWidget.displayType=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){const{attachmentsWidget:e}=this;return l("div",{class:d.base},this._featureElementInfo?.render(),e?.render())}_setupFeatureElementInfo(){const{description:e,title:t,headingLevel:i}=this;this._featureElementInfo?.set({description:e,title:t,headingLevel:i})}};e([s({readOnly:!0})],c.prototype,"attachmentsWidget",void 0),e([s()],c.prototype,"description",null),e([s()],c.prototype,"displayType",null),e([s()],c.prototype,"graphic",null),e([s()],c.prototype,"headingLevel",void 0),e([s()],c.prototype,"title",null),e([s({type:n})],c.prototype,"viewModel",void 0),c=e([r("esri.widgets.Feature.FeatureAttachments")],c);const h=c;export{h 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{HandleOwner as l}from"../../core/HandleOwner.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{when as o,watch as a,initial as n,syncAndInitial as h}from"../../core/reactiveUtils.js";import{Milliseconds as d}from"../../core/time.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../webdoc/Widgets.js";import y from"../../webdoc/widgets/FloorFilter.js";import{GoToMixin as p}from"../support/GoTo.js";function v(e){return"esri.WebMap"===e.declaredClass}function m(e){return"esri.WebScene"===e.declaredClass}let F=class extends(p(l)){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType="site",this.filterMode="base-floors",this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([o((()=>this.view?.map),(e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=t((async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)}))}),n),a((()=>this.view),((e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)}),h),a((()=>this.view?.widthBreakpoint??null),(e=>{this._viewWidthBreakpoint=e})),a((()=>this.view?.heightBreakpoint??null),(e=>{this._viewHeightBreakpoint=e}))])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride("facility",e)}set filterFeatures(e){this._callOverride("filterFeatures",e)}set filterLayers(e){this._callOverride("filterLayers",e)}get hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const s=e?.split("--");if(s?.length>1&&"all"===s[0]?(i=s[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.siteId||null),this.setFloors(t)):this._isOverridden("level")&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType="site"),this.setFloors(null)),this._callOverride("level",e);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}set site(e){this._callOverride("site",e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?"ready":this.view&&!this.filterFeatures?"loading":"disabled"}filterFacilities(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}))),this.site&&(t=t.filter((e=>e.siteId===this.site)));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}filterSites(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:s}=e;if(t&&t.length>0&&(t.forEach((e=>{0===e.verticalOrder&&e.facilityId===s&&(i=e)})),!i)){let e=null;t.forEach((t=>{t.facilityId===s&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)})),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find((t=>t.id===e))??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter((t=>t.facilityId===e)).sort(((e,t)=>{const i=e.verticalOrder??0,s=t.verticalOrder??0;return i>s?-1:i===s?0:1}))}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find((t=>t.id===e))??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find((t=>t.id===e))??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:d(1e3),easing:"in-out-quad"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach((e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)})),t.floors=new i(this._computeFloors(e)))}updateWebDocument(e){if(v(e)){const t=new y({enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null});e.widgets?e.widgets.floorFilter=t:e.widgets=new f({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&t.push(e.id)}))}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:l,verticalOrder:r}=e;(s||0!==r||i.includes(t))&&(l===s||0!==r||i.includes(t))||i.push(t)})),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[],s=e?.id.split("--")??[];if(s?.length>1&&"all"===s[0]){this.getFacilityLevels(e?.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const l=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:s}=e;(l||i.includes(t))&&(s===l||i.includes(t))||i.push(t)})),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!v(e.map)&&!m(e.map))throw new s("Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},s=t.floorInfo?.siteLayer?.layerId,l=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!l||!r)return;const a=i.items.filter((e=>"feature"===e.type||"scene"===e.type)),n=i.items.filter((e=>"map-image"===e.type));if(n?.length>0&&o){await Promise.all(n.map((e=>e.load())));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach((t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===s||n===l||n===r)&&d?.length>0&&h.items.forEach((t=>{const l=t.id;n===s&&l===i?e.siteLayer=t:l===o?e.facilityLayer=t:l===a&&(e.levelLayer=t)}))}))}a?.length>0&&a.forEach((t=>{const i=t.id;i===s?e.siteLayer=t:i===l?e.facilityLayer=t:i===r&&(e.levelLayer=t)})),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,s=i?.map,{siteLayer:l}=t;if(!l||!s?.floorInfo?.siteLayer)return e;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=s.floorInfo.siteLayer,n=await l.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=l?.fieldsIndex.get(o)?.name||o,s=l?.fieldsIndex.get(a)?.name||a;null!=i&&null!=s&&t.forEach((t=>{const l=t.attributes,r=t.geometry,o=l[i],a=l[s];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})}))}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:s}=e,l={facilitiesInfo:[]};if(!s||!i?.floorInfo?.facilityLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await s.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach((e=>{const s=e.attributes,o=e.geometry,a=s[t],n=s[i],h=s[r];a&&n&&h&&l.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})}))}return l}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:s}=e,l={levelsInfo:[]};if(!s||!i?.floorInfo?.levelLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,u=await s.queryFeatures(r);if(u?.features?.length>0){const e=u.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n,f=s?.fieldsIndex.get(h)?.name||h,y=s?.fieldsIndex.get(d)?.name||d,p=s?.fieldsIndex.get(c)?.name||c;t&&i&&r&&f&&y&&p&&e.forEach((e=>{const s=e.attributes,o=s[t],a=s[i],n=s[r],h=s[f],d=s[y],c=s[p];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&l.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})}))}return l}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",(e=>{const t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))}))}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!v(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!v(e))return;const t=e?.widgets?.floorFilter;t&&(this._isOverridden("enabled")||(this.enabled=t.enabled),this._isOverridden("longNames")||(this.longNames=t.longNames),this._isOverridden("minimized")||(this.minimized=t.minimized),this._isOverridden("pinnedLevels")||(this.pinnedLevels=t.pinnedLevels),this._isOverridden("site")||(this.site=t.site),this._isOverridden("facility")||(this.facility=t.facility),this._isOverridden("level")||(this.level=t.level))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:s,facility:l}=this,r=[];t.levels.levelsInfo.forEach((e=>{const{id:t,facilityId:i}=e;l&&i===l?s&&t===s&&r.push(t):r.push(t)})),e.floorInfo.viewAllLevelIds=new i(r)}}};e([c({value:!1})],F.prototype,"enabled",null),e([c({value:void 0})],F.prototype,"facility",null),e([c({value:null})],F.prototype,"filterFeatures",null),e([c({value:null})],F.prototype,"filterLayers",null),e([c()],F.prototype,"filterMenuOpen",void 0),e([c()],F.prototype,"filterMenuType",void 0),e([c()],F.prototype,"filterMode",void 0),e([c()],F.prototype,"hasFacilities",null),e([c()],F.prototype,"hasLevels",null),e([c()],F.prototype,"hasMultipleSites",null),e([c({readOnly:!0})],F.prototype,"isNormalMode",null),e([c({value:void 0})],F.prototype,"level",null),e([c({value:!1})],F.prototype,"longNames",null),e([c()],F.prototype,"levelsExpanded",void 0),e([c({value:!1})],F.prototype,"minimized",null),e([c({value:!1})],F.prototype,"pinnedLevels",null),e([c()],F.prototype,"searchTerm",void 0),e([c({value:void 0})],F.prototype,"site",null),e([c({readOnly:!0})],F.prototype,"state",null),e([c()],F.prototype,"view",void 0),e([c()],F.prototype,"_viewHeightBreakpoint",void 0),e([c()],F.prototype,"_viewWidthBreakpoint",void 0),e([c()],F.prototype,"updateWebDocument",null),F=e([u("esri/widgets/FloorFilter/FloorFilterViewModel")],F);const g=F;export{g as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{HandleOwner as l}from"../../core/HandleOwner.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../core/reactiveUtils.js";import{Milliseconds as h}from"../../core/time.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../webdoc/Widgets.js";import f from"../../webdoc/widgets/FloorFilter.js";import{GoToMixin as y}from"../support/GoTo.js";function p(e){return"esri.WebMap"===e.declaredClass}function v(e){return"esri.WebScene"===e.declaredClass}let m=class extends(y(l)){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType="site",this.filterMode="base-floors",this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([o((()=>this.view?.map),(e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=t((async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)}))}),a),o((()=>this.view),((e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)}),n),o((()=>this.view?.widthBreakpoint??null),(e=>{this._viewWidthBreakpoint=e})),o((()=>this.view?.heightBreakpoint??null),(e=>{this._viewHeightBreakpoint=e}))])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride("facility",e)}set filterFeatures(e){this._callOverride("filterFeatures",e)}set filterLayers(e){this._callOverride("filterLayers",e)}get hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const s=e?.split("--");if(s?.length>1&&"all"===s[0]?(i=s[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.siteId||null),this.setFloors(t)):this._isOverridden("level")&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType="site"),this.setFloors(null)),this._callOverride("level",e);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}set site(e){this._callOverride("site",e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?"ready":this.view&&!this.filterFeatures?"loading":"disabled"}filterFacilities(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}))),this.site&&(t=t.filter((e=>e.siteId===this.site)));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}filterSites(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:s}=e;if(t&&t.length>0&&(t.forEach((e=>{0===e.verticalOrder&&e.facilityId===s&&(i=e)})),!i)){let e=null;t.forEach((t=>{t.facilityId===s&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)})),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find((t=>t.id===e))??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter((t=>t.facilityId===e)).sort(((e,t)=>{const i=e.verticalOrder??0,s=t.verticalOrder??0;return i>s?-1:i===s?0:1}))}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find((t=>t.id===e))??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find((t=>t.id===e))??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:h(1e3),easing:"in-out-quad"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach((e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)})),t.floors=new i(this._computeFloors(e)))}updateWebDocument(e){if(p(e)){const t=new f({enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null});e.widgets?e.widgets.floorFilter=t:e.widgets=new u({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&t.push(e.id)}))}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:l,verticalOrder:r}=e;(s||0!==r||i.includes(t))&&(l===s||0!==r||i.includes(t))||i.push(t)})),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[],s=e?.id.split("--")??[];if(s?.length>1&&"all"===s[0]){this.getFacilityLevels(e?.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const l=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:s}=e;(l||i.includes(t))&&(s===l||i.includes(t))||i.push(t)})),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!p(e.map)&&!v(e.map))throw new s("Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},s=t.floorInfo?.siteLayer?.layerId,l=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!l||!r)return;const a=i.items.filter((e=>"feature"===e.type||"scene"===e.type)),n=i.items.filter((e=>"map-image"===e.type));if(n?.length>0&&o){await Promise.all(n.map((e=>e.load())));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach((t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===s||n===l||n===r)&&d?.length>0&&h.items.forEach((t=>{const l=t.id;n===s&&l===i?e.siteLayer=t:l===o?e.facilityLayer=t:l===a&&(e.levelLayer=t)}))}))}a?.length>0&&a.forEach((t=>{const i=t.id;i===s?e.siteLayer=t:i===l?e.facilityLayer=t:i===r&&(e.levelLayer=t)})),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,s=i?.map,{siteLayer:l}=t;if(!l||!s?.floorInfo?.siteLayer)return e;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=s.floorInfo.siteLayer,n=await l.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=l?.fieldsIndex.get(o)?.name||o,s=l?.fieldsIndex.get(a)?.name||a;null!=i&&null!=s&&t.forEach((t=>{const l=t.attributes,r=t.geometry,o=l[i],a=l[s];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})}))}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:s}=e,l={facilitiesInfo:[]};if(!s||!i?.floorInfo?.facilityLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await s.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach((e=>{const s=e.attributes,o=e.geometry,a=s[t],n=s[i],h=s[r];a&&h&&l.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})}))}return l}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:s}=e,l={levelsInfo:[]};if(!s||!i?.floorInfo?.levelLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,u=await s.queryFeatures(r);if(u?.features?.length>0){const e=u.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n,f=s?.fieldsIndex.get(h)?.name||h,y=s?.fieldsIndex.get(d)?.name||d,p=s?.fieldsIndex.get(c)?.name||c;t&&i&&r&&f&&y&&p&&e.forEach((e=>{const s=e.attributes,o=s[t],a=s[i],n=s[r],h=s[f],d=s[y],c=s[p];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&l.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})}))}return l}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",(e=>{const t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))}))}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!p(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!p(e))return;const t=e?.widgets?.floorFilter;t&&(this._isOverridden("enabled")||(this.enabled=t.enabled),this._isOverridden("longNames")||(this.longNames=t.longNames),this._isOverridden("minimized")||(this.minimized=t.minimized),this._isOverridden("pinnedLevels")||(this.pinnedLevels=t.pinnedLevels),this._isOverridden("site")||(this.site=t.site),this._isOverridden("facility")||(this.facility=t.facility),this._isOverridden("level")||(this.level=t.level))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:s,facility:l}=this,r=[];t.levels.levelsInfo.forEach((e=>{const{id:t,facilityId:i}=e;l&&i===l?s&&t===s&&r.push(t):r.push(t)})),e.floorInfo.viewAllLevelIds=new i(r)}}};e([d({value:!1})],m.prototype,"enabled",null),e([d({value:void 0})],m.prototype,"facility",null),e([d({value:null})],m.prototype,"filterFeatures",null),e([d({value:null})],m.prototype,"filterLayers",null),e([d()],m.prototype,"filterMenuOpen",void 0),e([d()],m.prototype,"filterMenuType",void 0),e([d()],m.prototype,"filterMode",void 0),e([d()],m.prototype,"hasFacilities",null),e([d()],m.prototype,"hasLevels",null),e([d()],m.prototype,"hasMultipleSites",null),e([d({readOnly:!0})],m.prototype,"isNormalMode",null),e([d({value:void 0})],m.prototype,"level",null),e([d({value:!1})],m.prototype,"longNames",null),e([d()],m.prototype,"levelsExpanded",void 0),e([d({value:!1})],m.prototype,"minimized",null),e([d({value:!1})],m.prototype,"pinnedLevels",null),e([d()],m.prototype,"searchTerm",void 0),e([d({value:void 0})],m.prototype,"site",null),e([d({readOnly:!0})],m.prototype,"state",null),e([d()],m.prototype,"view",void 0),e([d()],m.prototype,"_viewHeightBreakpoint",void 0),e([d()],m.prototype,"_viewWidthBreakpoint",void 0),e([d()],m.prototype,"updateWebDocument",null),m=e([c("esri/widgets/FloorFilter/FloorFilterViewModel")],m);const F=m;export{F 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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{debounce as t}from"../../core/promiseUtils.js";import{watch as s,initial as i}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Slider.js";import{loadCalciteComponents as n}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as a}from"../support/jsxFactory.js";import u from"./ValuePickerBaseComponent.js";import p from"./ValuePickerSliderVisibleElements.js";const c="esri-value-picker__slider",d={minorTick:`${c}__tick-minor`,majorTick:`${c}__tick-major`,stepsTick:`${c}__tick-steps`};function h(e){return(t,s)=>{s?.classList.add(e)}}let m=class extends u{constructor(e,s){super(e,s),this._majorTickCreatedFunction=h(d.majorTick),this._minorTickCreatedFunction=h(d.minorTick),this._stepsTickCreatedFunction=h(d.stepsTick),this._thumbNode=null,this._tooltip=null,this._slider=new r({thumbCreatedFunction:(e,t,s)=>{this._thumbNode=s}}),this.labelFormatFunction=null,this.labels=null,this.min=null,this.minorTicks=null,this.majorTicks=null,this.max=null,this.reversed=!1,this.steps=null,this.type="slider",this.visibleElements=new p,this._thumbDragDebounced=t((async e=>{await(this._tooltip?.reposition(!1))}))}initialize(){this.addHandles([s((()=>this.viewModel?.values),(e=>{this._slider.values=e}),i),s((()=>this._slider.values),(e=>{this.viewModel&&this.viewModel.values!==e&&(this.viewModel.values=e)})),this._slider.on("thumb-drag",this._thumbDragDebounced)])}destroy(){this._slider.destroy()}loadDependencies(){return n({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get _ascending(){const{reversed:e,viewModel:t}=this;if(!t)return null;const{layout:s}=t;return"horizontal"===s&&!e||"vertical"===s&&e}get canNext(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[i.length-1]:r!==i[0])}get canPlay(){return null!=this.viewModel&&!!this.steps?.length&&null!=this.min&&null!=this.max}get canPrevious(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[0]:r!==i[i.length-1])}render(){const{labels:e,labelFormatFunction:t,min:s,max:i,steps:o,minorTicks:l,majorTicks:r,reversed:n,viewModel:u}=this;if(!u)return a("div",null);const{disabled:p,layout:d}=u,h=`${d}${n?"-reversed":""}`,m="position",v=[];return null!=s&&null!=i&&(l&&v.push({mode:m,values:l,tickCreatedFunction:this._minorTickCreatedFunction}),r&&v.push({mode:m,values:r,tickCreatedFunction:this._majorTickCreatedFunction}),e&&v.push({mode:m,values:e,labelsVisible:!0}),this.visibleElements.steps&&this.steps&&v.push({mode:m,values:this.steps,tickCreatedFunction:this._stepsTickCreatedFunction})),this._slider.set({disabled:p,labelFormatFunction:t,layout:h,min:s,max:i,steps:o,tickConfigs:v}),a("div",{class:c},this._slider.render(),this._renderToolTip())}animate(e){this._step(1,e)}next(){this._step(this._ascending?1:-1)}previous(){this._step(this._ascending?-1:1)}_onTooltipAfterCreate(e){this._tooltip=e}_renderToolTip(){if(!this.visibleElements.thumbTooltip||!this._thumbNode||!this._slider.values)return null;const e=this._slider.viewModel.getLabelForValue(this._slider.values[0],"value");return e?a("calcite-tooltip",{afterCreate:this._onTooltipAfterCreate,label:e,referenceElement:this._thumbNode},e):null}_step(e,t=!1){if(!this.viewModel||!this.steps?.length)return;if(!this.viewModel.values||!this.steps.includes(this.viewModel.values[0]))return void(this.viewModel.values=[this.steps[0]]);const s=this.steps.indexOf(this.viewModel.values[0])+e;s<0||s>=this.steps.length?this.viewModel.loop||t?this.viewModel.values=[this.steps[1===e?0:this.steps.length-1]]:"playing"===this.viewModel.state&&this.viewModel.pause():this.viewModel.values=[this.steps[s]]}};e([o()],m.prototype,"_ascending",null),e([o()],m.prototype,"canNext",null),e([o()],m.prototype,"canPlay",null),e([o()],m.prototype,"canPrevious",null),e([o()],m.prototype,"labelFormatFunction",void 0),e([o()],m.prototype,"labels",void 0),e([o()],m.prototype,"min",void 0),e([o()],m.prototype,"minorTicks",void 0),e([o()],m.prototype,"majorTicks",void 0),e([o()],m.prototype,"max",void 0),e([o({nonNullable:!0})],m.prototype,"reversed",void 0),e([o()],m.prototype,"steps",void 0),e([o()],m.prototype,"type",void 0),e([o({type:p,nonNullable:!0})],m.prototype,"visibleElements",void 0),m=e([l("esri.widgets.ValuePicker.ValuePickerSlider")],m);const v=m;export{v as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{debounce as t}from"../../core/promiseUtils.js";import{watch as s,initial as i}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Slider.js";import{loadCalciteComponents as n}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as a}from"../support/jsxFactory.js";import u from"./ValuePickerBaseComponent.js";import p from"./ValuePickerSliderVisibleElements.js";const c="esri-value-picker__slider",d={minorTick:`${c}__tick-minor`,majorTick:`${c}__tick-major`,stepsTick:`${c}__tick-steps`,tooltip:`${c}__tooltip`};function h(e){return(t,s)=>{s?.classList.add(e)}}let m=class extends u{constructor(e,s){super(e,s),this._majorTickCreatedFunction=h(d.majorTick),this._minorTickCreatedFunction=h(d.minorTick),this._stepsTickCreatedFunction=h(d.stepsTick),this._thumbNode=null,this._tooltip=null,this._slider=new r({thumbCreatedFunction:(e,t,s)=>{this._thumbNode=s}}),this.labelFormatFunction=null,this.labels=null,this.min=null,this.minorTicks=null,this.majorTicks=null,this.max=null,this.reversed=!1,this.steps=null,this.type="slider",this.visibleElements=new p,this._thumbDragDebounced=t((async e=>{await(this._tooltip?.reposition(!1))}))}initialize(){this.addHandles([s((()=>this.viewModel?.values),(e=>{this._slider.values=e}),i),s((()=>this._slider.values),(e=>{this.viewModel&&this.viewModel.values!==e&&(this.viewModel.values=e)})),this._slider.on("thumb-drag",this._thumbDragDebounced)])}destroy(){this._slider.destroy()}loadDependencies(){return n({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get _ascending(){const{reversed:e,viewModel:t}=this;if(!t)return null;const{layout:s}=t;return"horizontal"===s&&!e||"vertical"===s&&e}get canNext(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[i.length-1]:r!==i[0])}get canPlay(){return null!=this.viewModel&&!!this.steps?.length&&null!=this.min&&null!=this.max}get canPrevious(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[0]:r!==i[i.length-1])}render(){const{labels:e,labelFormatFunction:t,min:s,max:i,steps:o,minorTicks:l,majorTicks:r,reversed:n,viewModel:u}=this;if(!u)return a("div",null);const{disabled:p,layout:d}=u,h=`${d}${n?"-reversed":""}`,m="position",v=[];return null!=s&&null!=i&&(l&&v.push({mode:m,values:l,tickCreatedFunction:this._minorTickCreatedFunction}),r&&v.push({mode:m,values:r,tickCreatedFunction:this._majorTickCreatedFunction}),e&&v.push({mode:m,values:e,labelsVisible:!0}),this.visibleElements.steps&&this.steps&&v.push({mode:m,values:this.steps,tickCreatedFunction:this._stepsTickCreatedFunction})),this._slider.set({disabled:p,labelFormatFunction:t,layout:h,min:s,max:i,steps:o,tickConfigs:v}),a("div",{class:c},this._slider.render(),this._renderToolTip())}animate(e){this._step(1,e)}next(){this._step(this._ascending?1:-1)}previous(){this._step(this._ascending?-1:1)}_onTooltipAfterCreate(e){this._tooltip=e}_renderToolTip(){if(!this.visibleElements.thumbTooltip||!this._thumbNode||!this._slider.values)return null;const e=this._slider.viewModel.getLabelForValue(this._slider.values[0],"value");return e?a("calcite-tooltip",{afterCreate:this._onTooltipAfterCreate,class:d.tooltip,label:e,referenceElement:this._thumbNode},e):null}_step(e,t=!1){if(!this.viewModel||!this.steps?.length)return;if(!this.viewModel.values||!this.steps.includes(this.viewModel.values[0]))return void(this.viewModel.values=[this.steps[0]]);const s=this.steps.indexOf(this.viewModel.values[0])+e;s<0||s>=this.steps.length?this.viewModel.loop||t?this.viewModel.values=[this.steps[1===e?0:this.steps.length-1]]:"playing"===this.viewModel.state&&this.viewModel.pause():this.viewModel.values=[this.steps[s]]}};e([o()],m.prototype,"_ascending",null),e([o()],m.prototype,"canNext",null),e([o()],m.prototype,"canPlay",null),e([o()],m.prototype,"canPrevious",null),e([o()],m.prototype,"labelFormatFunction",void 0),e([o()],m.prototype,"labels",void 0),e([o()],m.prototype,"min",void 0),e([o()],m.prototype,"minorTicks",void 0),e([o()],m.prototype,"majorTicks",void 0),e([o()],m.prototype,"max",void 0),e([o({nonNullable:!0})],m.prototype,"reversed",void 0),e([o()],m.prototype,"steps",void 0),e([o()],m.prototype,"type",void 0),e([o({type:p,nonNullable:!0})],m.prototype,"visibleElements",void 0),m=e([l("esri.widgets.ValuePicker.ValuePickerSlider")],m);const v=m;export{v as default};