@arcgis/core 6.0.0-next.16 → 6.0.0-next.18
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/164c8eeefa8232b2b191.js +2 -0
- package/assets/esri/core/workers/chunks/1967b9c96045a5802d08.js +1 -0
- package/assets/esri/core/workers/chunks/{261fea092ee7d27608a0.js → 20a2124cbe43e5527c40.js} +1 -1
- package/assets/esri/core/workers/chunks/2853606099602f73d379.js +1 -0
- package/assets/esri/core/workers/chunks/2981e904ab62f3ed80d0.js +2 -0
- package/assets/esri/core/workers/chunks/32cc59e126df8c96a0cf.js +2 -0
- package/assets/esri/core/workers/chunks/{36cbd614454581aaf334.js → 34e0a8a3a2beea50f4f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{3baa4a9c52f41bfd6abb.js → 3e30b96a8c75bd5b9ae2.js} +1 -1
- package/assets/esri/core/workers/chunks/{c79934cd6883307203f8.js → 42753cf4965a94bc91ca.js} +1 -1
- package/assets/esri/core/workers/chunks/{b564ec4e03478f5659db.js → 4c240ca50f70bf30813f.js} +1 -1
- package/assets/esri/core/workers/chunks/{70d3055f15d8b0cf4074.js → 532e9cda8ac3601d8892.js} +1 -1
- package/assets/esri/core/workers/chunks/{953ba13299e7aa92c1a0.js → 564565246dae080f5e6c.js} +1 -1
- package/assets/esri/core/workers/chunks/{2145a512d269d64036b0.js → 58c3ae6030def2ed5f31.js} +1 -1
- package/assets/esri/core/workers/chunks/5a19a9c3e01d3d415188.js +1 -0
- package/assets/esri/core/workers/chunks/5a830bc35adbedd33783.js +1 -0
- package/assets/esri/core/workers/chunks/{9f06ec95bdf0d0b52b41.js → 5b91e2dffdc84c006539.js} +1 -1
- package/assets/esri/core/workers/chunks/{5acb422fe3cf693d9d4f.js → 603fdbbe9534c614928f.js} +1 -1
- package/assets/esri/core/workers/chunks/{c5a9e77977e867a75ff2.js → 60f92eb03c6e17ab4747.js} +1 -1
- package/assets/esri/core/workers/chunks/{67ebc5a3d46b254b725c.js → 612345f17f5eeb99ea8f.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b077c92345ffb5916c2.js → 65c98f3449044fa4fd79.js} +1 -1
- package/assets/esri/core/workers/chunks/{2bd4ee083ca4ad221f8b.js → 65cb5e39c467a35621ca.js} +1 -1
- package/assets/esri/core/workers/chunks/67a35155b8b4d36f171e.js +1 -0
- package/assets/esri/core/workers/chunks/{f9c5aa0bbf23e780fecc.js → 6ad309154fe84210d23c.js} +1 -1
- package/assets/esri/core/workers/chunks/784d6c6949284ed6e10b.js +1 -0
- package/assets/esri/core/workers/chunks/{e2190361247f35b02b32.js → 7b5cd150a4d0139850be.js} +1 -1
- package/assets/esri/core/workers/chunks/{9b051745d24d1f43480b.js → 7d2cbc767c336d15e4d5.js} +1 -1
- package/assets/esri/core/workers/chunks/{590e6c70206122e4cc3c.js → 844eedda8f749972f707.js} +2 -2
- package/assets/esri/core/workers/chunks/9503eedfdda55fc5adab.js +1 -0
- package/assets/esri/core/workers/chunks/999c23da883eb11cb29e.js +1 -0
- package/assets/esri/core/workers/chunks/9b6929faf649e81265fb.js +1 -0
- package/assets/esri/core/workers/chunks/a35c69a4751d28c39907.js +1 -0
- package/assets/esri/core/workers/chunks/{ec8b7476eac4718eb0ac.js → a504a5e06cb89a620799.js} +1 -1
- package/assets/esri/core/workers/chunks/a596779eaeec7310671d.js +1 -0
- package/assets/esri/core/workers/chunks/{d5d0fe8e198ff5a902ee.js → a5c8f9f5be4ef5063b42.js} +1 -1
- package/assets/esri/core/workers/chunks/{a7bd5ba4d7d97411fd33.js → ab1660f5f8a5268c2fac.js} +1 -1
- package/assets/esri/core/workers/chunks/{4bbe1f28f5f16a6bef05.js → ae0563d573baf91e01f7.js} +1 -1
- package/assets/esri/core/workers/chunks/b686cd74975da09b9c91.js +2 -0
- package/assets/esri/core/workers/chunks/{aa36c3a9bbaa086e3757.js → b8fd7c3b36981261378b.js} +1 -1
- package/assets/esri/core/workers/chunks/bd046399e05e759e0bc2.js +1 -0
- package/assets/esri/core/workers/chunks/bd46a04a9ee4ea9e6ef1.js +2 -0
- package/assets/esri/core/workers/chunks/bfb39590c548188f5052.js +1 -0
- package/assets/esri/core/workers/chunks/{bf35927979fc5e7e0478.js → dd0310184fe4832755a8.js} +1 -1
- package/assets/esri/core/workers/chunks/dfa5f1311806473e473f.js +1 -0
- package/assets/esri/core/workers/chunks/{634523cc7757da9020e4.js → fb70ab267a08e24b710f.js} +1 -1
- package/assets/esri/core/workers/chunks/fc139f251dc0523074e7.js +1 -0
- package/assets/esri/themes/base/widgets/_Weather.scss +1 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/lerc-wasm.js +1 -1
- package/config.js +1 -1
- package/core/sql/WhereGrammar.js +2 -2
- package/editing/sharedTemplates/executor/builders/equallySpaced.js +1 -1
- package/kernel.js +1 -1
- package/layers/ElevationLayer.js +1 -1
- package/layers/GeoJSONLayer.d.ts +1 -1
- package/layers/effects/parser.js +3 -3
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/layers/raster/formats/ElevationCodec.js +2 -0
- package/layers/raster/formats/Lerc.js +1 -1
- package/layers/support/LercWorker.js +1 -1
- package/layers/support/TileInfo.d.ts +1 -1
- package/layers/support/TileInfo.js +1 -1
- package/layers/support/layerOriginUtils.js +1 -1
- package/package.json +4 -4
- package/popup/FeaturesModel.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerBinningAdapter.js +1 -1
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/OGCFeatureLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/time/TimeExtent.d.ts +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/View.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/interactive/snapping/SnappingManagerPool.js +1 -1
- package/views/interactive/snapping/allLayerSnapping.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.d.ts +2 -1
- package/widgets/BasemapToggle/BasemapToggleViewModel.d.ts +2 -0
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.d.ts +2 -1
- package/widgets/ElevationProfile/components/Statistics.js +1 -1
- package/widgets/Expand/ExpandViewModel.d.ts +2 -0
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/Fullscreen/FullscreenViewModel.d.ts +3 -1
- package/widgets/Home/HomeViewModel.d.ts +2 -0
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Swipe/SwipeViewModel.d.ts +2 -0
- package/widgets/Swipe/types.d.ts +9 -2
- package/widgets/TimeSlider/TimeSliderViewModel.d.ts +9 -5
- package/widgets/TimeSlider/types.d.ts +7 -0
- package/widgets/TimeSlider.d.ts +2 -3
- package/widgets/TimeSlider.js +1 -1
- package/widgets/Track/TrackViewModel.d.ts +4 -0
- package/widgets/Track/types.d.ts +1 -0
- package/widgets/support/Selector3D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0050916e462e3c9e0627.js +0 -1
- package/assets/esri/core/workers/chunks/23c43f09c4a4749516e1.js +0 -1
- package/assets/esri/core/workers/chunks/34cbaf844730ac2d92c2.js +0 -2
- package/assets/esri/core/workers/chunks/3c301a689c7853c9fa67.js +0 -2
- package/assets/esri/core/workers/chunks/3f946c13ad97fbed867b.js +0 -1
- package/assets/esri/core/workers/chunks/604f0f4150fb79ee54c8.js +0 -1
- package/assets/esri/core/workers/chunks/6299be5e7e26bf3c6859.js +0 -1
- package/assets/esri/core/workers/chunks/6a8dd8b18b0b825b0c1b.js +0 -1
- package/assets/esri/core/workers/chunks/745a153d0cd34faa124e.js +0 -1
- package/assets/esri/core/workers/chunks/7572c2bc5062e66f6330.js +0 -1
- package/assets/esri/core/workers/chunks/76ab353d80d786777161.js +0 -2
- package/assets/esri/core/workers/chunks/7b5f3c79e0605c32b267.js +0 -1
- package/assets/esri/core/workers/chunks/8483c50ed8f280fd74bb.js +0 -1
- package/assets/esri/core/workers/chunks/8cb716f110d164030309.js +0 -1
- package/assets/esri/core/workers/chunks/91dd65cf877c8f2e01a7.js +0 -1
- package/assets/esri/core/workers/chunks/b49df4ebd4be1181b0f9.js +0 -2
- package/assets/esri/core/workers/chunks/b557824bc1fa163d72a3.js +0 -2
- package/assets/esri/core/workers/chunks/d311ff96a5a2791d8cfc.js +0 -1
- package/assets/esri/core/workers/chunks/f9ff27cfcf0538ac5e26.js +0 -1
- package/assets/esri/core/workers/chunks/fc44227c1756f65b95df.js +0 -1
- /package/assets/esri/core/workers/chunks/{b557824bc1fa163d72a3.js.LICENSE.txt → 164c8eeefa8232b2b191.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{b49df4ebd4be1181b0f9.js.LICENSE.txt → 2981e904ab62f3ed80d0.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{34cbaf844730ac2d92c2.js.LICENSE.txt → 32cc59e126df8c96a0cf.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{590e6c70206122e4cc3c.js.LICENSE.txt → 844eedda8f749972f707.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{3c301a689c7853c9fa67.js.LICENSE.txt → b686cd74975da09b9c91.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{76ab353d80d786777161.js.LICENSE.txt → bd46a04a9ee4ea9e6ef1.js.LICENSE.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[9696],{74639(e,t,r){r.d(t,{M:()=>s,s:()=>u});var n=r(44729),a=r(1262),i=r(55612),o=r(15032),l=r(34747);function u(e,t){let r=c[e.toLowerCase()];if(null==r)throw new a.L("FunctionNotRecognized");if(t.length<r.minParams||t.length>r.maxParams)throw new a.L("InvalidParameterCount",{name:e.toUpperCase()});return r.evaluate(t)}function s(e,t){let r=c[e.toLowerCase()];return null!=r&&t>=r.minParams&&t<=r.maxParams}const c={min:{minParams:1,maxParams:1,evaluate:e=>p(e[0],"min")},max:{minParams:1,maxParams:1,evaluate:e=>p(e[0],"max")},avg:{minParams:1,maxParams:1,evaluate:e=>f(e[0])},sum:{minParams:1,maxParams:1,evaluate:e=>function(e){if(null===e||0===e.length)return null;let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(null!==n){if(!d(n))throw new a.L("InvalidValueForAggregateFunction");t+=n}}return t}(e[0])},stddev:{minParams:1,maxParams:1,evaluate:e=>function(e){if(null===e)return null;let t=m(e);return null===t?null:Math.sqrt(t)}(e[0])},count:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:e[0].filter(e=>null!==e).length},var:{minParams:1,maxParams:1,evaluate:e=>m(e[0])}};function f(e){if(null===e)return null;let t=0,r=0;for(let n=0;n<e.length;n++){let i=e[n];if(null!==i){if(!d(i))throw new a.L("InvalidValueForAggregateFunction");r++,t+=i}}return 0===r?null:t/r}function d(e){return"number"==typeof e}function p(e,t){if(null===e)return null;let r=null,a=null;for(let u of e){let e=u;e=n.n.isDateOnly(u)||o.k.isTimeOnly(u)?u.toNumber():l.c9.isDateTime(u)?u.toMillis():i.g.isTimestampOffset(u)?u.toMilliseconds():u,(null===r||"max"===t&&null!==a&&null!==e&&a<=e||"min"===t&&null!==a&&null!==e&&a>=e)&&(r=u,a=e)}return r}function m(e){if(null===e||0===(e=e.filter(e=>null!==e)).length)return null;let t=f(e);if(null===t)return null;let r=0;for(let n of e){if(!d(n))throw new a.L("InvalidValueForAggregateFunction");r+=(t-n)**2}return r/(e.length-1)}},55612(e,t,r){r.d(t,{g:()=>o});var n=r(34747);function a(e){return Number.isNaN(e)||0===e?e:Math.trunc(e)}const i="esri.core.sql.SqlTimeStampOffset";class o{constructor(e){this._timeStampOffset=e,this.declaredRootClass=i,this._millis=null,this._date=null}static isTimestampOffset(e){return"object"==typeof e&&!!e&&"declaredRootClass"in e&&e.declaredRootClass===i}toDateTime(){return this._date??=n.c9.fromISO(this._timeStampOffset,{setZone:!0}),this._date}toMilliseconds(){return null==this._millis?(null!=this._date&&(this._millis??=this._date.toMillis()),this._millis??=Date.parse(this._timeStampOffset)):this._millis}get isValid(){return this.toDateTime().isValid}get timezoneOffsetHour(){return a(this.toDateTime().offset/60)}get timezoneOffsetMinutes(){return a(this.toDateTime().offset%60)}get hour(){return this.toDateTime().hour}get minute(){return this.toDateTime().minute}get second(){return this.toDateTime().second}get day(){return this.toDateTime().day}get month(){return this.toDateTime().month}get year(){return this.toDateTime().year}startOfDay(){return o.fromDateTime(this.toDateTime().startOf("day"))}static fromJSDate(e){return new o(n.c9.fromJSDate(e).toISO({includeOffset:!0}))}static fromDateTime(e){return new o(e.toISO({includeOffset:!0}))}static fromParts(e,t,r=0,n=0,a=0,i=0,l=0,u=!1,s=0,c=0){let f=`${e.toString().padStart(4,"0")}-${t.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}`,d="";i<10&&(d="0");let p=`${n.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${d+i.toString()}`;0!==l&&(p+="."+l.toString().padStart(3,"0"));let m=`${u?"-":"+"}${s.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`;return new o(f+"T"+p+m)}toStorageFormat(){return this._timeStampOffset}toString(){return this._timeStampOffset}toSQLValue(){let e=this.toDateTime().toSQL({includeOffset:!0,includeOffsetSpace:!0});return e&&=e.replace(".000",""),e}toSQLWithKeyword(){return`timestamp '${this.toSQLValue()}'`}addMilliseconds(e){let t=this.toDateTime().plus(e);return o.fromDateTime(t)}}},89696(e,t,r){r.d(t,{A:()=>pe});var n=r(44208),a=r(5479),i=r(74639),o=r(44729),l=r(1262);function u(e){if(null!==e.precision||null!==e.secondary)throw new l.L("PrimarySecondaryQualifiers")}function s(e,t){if(t.includes(".")){let r=t.split(".");e.second=parseFloat(r[0]),e.millis=parseInt(r[1],10)}else e.second=parseFloat(t)}const c="esri.core.sql.SqlInterval";class f{constructor(){this.declaredRootClass=c,this.op="+",this.day=0,this.second=0,this.hour=0,this.month=0,this.year=0,this.minute=0,this.millis=0}static isInterval(e){return"object"==typeof e&&!!e&&"declaredRootClass"in e&&e.declaredRootClass===c}static createFromMilliseconds(e){let t=new f;return t.second=e/1e3,t}static createFromValueAndQualifier(e,t,r){let n=null,a=new f;if(a.op="-"===r?"-":"+","interval-period"===t.type){u(t);let r=RegExp("^[0-9]{1,}$");if("year"===t.period||"month"===t.period)throw new l.L("YearMonthIntervals");if("second"===t.period){if(!/^[0-9]{1,}(\.[0-9]{1,}){0,1}$/.test(e))throw new l.L("IllegalInterval");s(a,e)}else{if(!r.test(e))throw new l.L("IllegalInterval");a[t.period]=parseFloat(e)}}else{if(u(t.start),u(t.end),"year"===t.start.period||"month"===t.start.period||"year"===t.end.period||"month"===t.end.period)throw new l.L("YearMonthIntervals");switch(t.start.period){case"day":switch(t.end.period){case"hour":if(n=RegExp("^[0-9]{1,} [0-9]{1,}$"),!n.test(e))throw new l.L("IllegalInterval");a[t.start.period]=parseFloat(e.split(" ")[0]),a[t.end.period]=parseFloat(e.split(" ")[1]);break;case"minute":if(n=RegExp("^[0-9]{1,} [0-9]{1,2}:[0-9]{1,}$"),!n.test(e))throw new l.L("IllegalInterval");{a[t.start.period]=parseFloat(e.split(" ")[0]);let r=e.split(" ")[1].split(":");a.hour=parseFloat(r[0]),a.minute=parseFloat(r[1])}break;case"second":if(n=RegExp("^[0-9]{1,} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,}(\\.[0-9]{1,}){0,1}$"),!n.test(e))throw new l.L("IllegalInterval");{a[t.start.period]=parseFloat(e.split(" ")[0]);let r=e.split(" ")[1].split(":");a.hour=parseFloat(r[0]),a.minute=parseFloat(r[1]),s(a,r[2])}break;default:throw new l.L("IllegalInterval")}break;case"hour":switch(t.end.period){case"minute":if(n=RegExp("^[0-9]{1,}:[0-9]{1,}$"),!n.test(e))throw new l.L("IllegalInterval");a.hour=parseFloat(e.split(":")[0]),a.minute=parseFloat(e.split(":")[1]);break;case"second":if(n=RegExp("^[0-9]{1,}:[0-9]{1,2}:[0-9]{1,}(\\.[0-9]{1,}){0,1}$"),!n.test(e))throw new l.L("IllegalInterval");{let t=e.split(":");a.hour=parseFloat(t[0]),a.minute=parseFloat(t[1]),s(a,t[2])}break;default:throw new l.L("IllegalInterval")}break;case"minute":if("second"!==t.end.period)throw new l.L("IllegalInterval");if(n=RegExp("^[0-9]{1,}:[0-9]{1,}(\\.[0-9]{1,}){0,1}$"),!n.test(e))throw new l.L("IllegalInterval");{let t=e.split(":");a.minute=parseFloat(t[0]),s(a,t[1])}break;default:throw new l.L("IllegalInterval")}}return a}valueInMilliseconds(){return("-"===this.op?-1:1)*(this.millis+1e3*this.second+60*this.minute*1e3+60*this.hour*60*1e3+24*this.day*60*60*1e3+this.month*(365/12)*24*60*60*1e3+365*this.year*24*60*60*1e3)}}var d=r(55612),p=r(15032),m=r(3330),h=r(34747);const v=/^(\d{1,2}):(\d{1,2}):(\d{1,2})$/,w=/^(\d{1,2}):(\d{1,2})$/,g=/^(\d{1,2}):(\d{1,2}):(\d{1,2}).([0-9]+)$/,I=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,y=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?$/,L=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)? {0,1}(\+|-)(\d{1,2}):(\d{1,2})$/,T=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})? {0,1}(\+|-)(\d{1,2}):(\d{1,2})$/,N=/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/;function O(e,t){if(t instanceof h.bo)return t===m.GB.instance?h.c9.fromMillis(e.getTime(),{zone:m.GB.instance}):h.c9.fromJSDate(e,{zone:t});switch(t){case"system":case"local":case null:return h.c9.fromJSDate(e);default:return"unknown"===t?.toLowerCase()?h.c9.fromMillis(e.getTime(),{zone:m.GB.instance}):h.c9.fromJSDate(e,{zone:t})}}function E(e){return f.isInterval(e)}function S(e){return h.c9.isDateTime(e)}function x(e){return o.n.isDateOnly(e)}function C(e){return p.k.isTimeOnly(e)}function _(e){return d.g.isTimestampOffset(e)}function D(e){let t=v.exec(e);if(null!==t){let[,e,r,n]=t,a=p.k.fromParts(parseInt(e,10),parseInt(r,10),parseInt(n,10),0);if(null!==a)return a;throw new l.L("InvalidTime")}if(t=w.exec(e),null!==t){let[,e,r]=t,n=p.k.fromParts(parseInt(e,10),parseInt(r,10),0,0);if(null!==n)return n;throw new l.L("InvalidTime")}if(t=g.exec(e),null!==t){let[,e,r,n,a]=t,i=p.k.fromParts(parseInt(e,10),parseInt(r,10),parseInt(n,10),parseInt(a,10));if(null!==i)return i;throw new l.L("InvalidTime")}throw new l.L("InvalidTime")}function M(e,t){let r=y.exec(e);if(null!==r){let[,e,n,a,i,o,u,s]=r,c=h.c9.fromObject({year:parseInt(e,10),month:parseInt(n,10),day:parseInt(a,10),hour:parseInt(i,10),minute:parseInt(o,10),second:parseInt(u,10),millisecond:s?parseInt(s.replace(".",""),10):0},{zone:(0,m.Qo)(t)});if(!1===c.isValid)throw new l.L("InvalidTimeStamp");return c}if(r=L.exec(e),null!==r){let[,e,t,n,a,i,o,u,s,c,f]=r,p=d.g.fromParts(parseInt(e,10),parseInt(t,10),parseInt(n,10),parseInt(a,10),parseInt(i,10),parseInt(o,10),u?parseInt(u.replace(".",""),10):0,"-"===s,parseInt(c,10),parseInt(f,10));if(!1===p.isValid)throw new l.L("InvalidTimeStamp");return p}if(r=T.exec(e),null!==r){let[,e,t,n,a,i,o,u,s]=r,c=d.g.fromParts(parseInt(e,10),parseInt(t,10),parseInt(n,10),parseInt(a,10),parseInt(i,10),0,0,"-"===o,parseInt(u,10),parseInt(s,10));if(!1===c.isValid)throw new l.L("InvalidTimeStamp");return c}if(r=N.exec(e),null!==r){let[,e,n,a,i,o]=r,u=h.c9.fromObject({year:parseInt(e,10),month:parseInt(n,10),day:parseInt(a,10),hour:parseInt(i,10),minute:parseInt(o,10),second:0},{zone:(0,m.Qo)(t)});if(!1===u.isValid)throw new l.L("InvalidTimeStamp");return u}if(r=I.exec(e),null!==r){let[,e,n,a]=r,i=h.c9.fromObject({year:parseInt(e,10),month:parseInt(n,10),day:parseInt(a,10),hour:0,minute:0,second:0},{zone:(0,m.Qo)(t)});if(!1===i.isValid)throw new l.L("InvalidTimeStamp");return i}throw new l.L("InvalidTimeStamp")}function b(e,t){let r=I.exec(e);if(null===r)try{return M(e,t)}catch{throw new l.L("InvalidDate")}let[,n,a,i]=r,u=o.n.fromParts(parseInt(n,10),parseInt(a,10),parseInt(i,10));if(null===u)throw new l.L("InvalidDate");return u}var P=r(34727),A=r(799),F=r(54218);function $(e){return!(!S(e)&&!_(e))}function R(e){return!!(S(e)||x(e)||_(e)||C(e))}function U(e){if(S(e))return e.toMillis();if(x(e))return e.toNumber();if(_(e))return e.toMilliseconds();throw new l.L("InvalidDataType")}function k(e,t,r){if(null==e||null==t)return null;if((0,F.Et)(e)){if((0,F.Et)(t))return V(e,t,r);if((0,F.Kg)(t))return function(e,t,r){let n=parseFloat(t);if(!isNaN(n))return V(e,n,r);let a=e.toString();switch(r){case"<>":return a!==t;case"=":return a===t;case">":return a>t;case"<":return a<t;case">=":return a>=t;case"<=":return a<=t}}(e,t,r);if(R(t)||x(t))throw new l.L("InvalidOperator")}else if((0,F.Kg)(e)){if((0,F.Et)(t))return function(e,t,r){let n=parseFloat(e);if(!isNaN(n))return V(n,t,r);let a=t.toString();switch(r){case"<>":return e!==a;case"=":return e===a;case">":return e>a;case"<":return e<a;case">=":return e>=a;case"<=":return e<=a}}(e,t,r);if((0,F.Kg)(t))return function(e,t,r){switch(r){case"<>":return e!==t;case"=":return e===t;case">":return e>t;case"<":return e<t;case">=":return e>=t;case"<=":return e<=t}}(e,t,r);if(S(t)||x(t)||C(t)||_(t))throw new l.L("InvalidOperator")}else if(S(e)){if($(t)){if((0,m.Y4)(e.zone)){if(S(t)&&!(0,m.Y4)(t.zone)||_(t))return z(e,t,r)}else if(S(t)&&(0,m.Y4)(t.zone))return z(e,t,r);return V(U(e),U(t),r)}if((0,F.Kg)(t))throw new l.L("InvalidOperator");if(x(t))return function(e,t,r){let n=t.toDateTimeLuxon(e.zone);return V((e=e.startOf("day")).toMillis(),n.toMillis(),r)}(e,t,r);if(C(t)||(0,F.Et)(t))throw new l.L("InvalidOperator")}else if(x(e)){if(_(t))return function(e,t,r){let n=e.toDateTimeLuxon(t.toDateTime().zone);return t=t.startOfDay(),V(n.toMillis(),t.toMilliseconds(),r)}(e,t,r);if(S(t))return function(e,t,r){let n=e.toDateTimeLuxon(t.zone);return t=t.startOf("day"),V(n.toMillis(),t.toMillis(),r)}(e,t,r);if((0,F.Kg)(t))throw new l.L("InvalidOperator");if(x(t))return function(e,t,r){let n=e.compare(t);switch(r){case"<>":return 0!==n;case"=":return 0===n;case">":return n>0;case"<":return n<0;case">=":return n>=0;case"<=":return n<=0}}(e,t,r);if(C(t)||(0,F.Et)(t))throw new l.L("InvalidOperator")}else if(C(e)){if(C(t))return V(e.toNumber(),t.toNumber(),r);if((0,F.Kg)(t)||(0,F.Et)(t)||x(t)||$(t))throw new l.L("InvalidOperator")}else if(_(e)){if($(t))return h.c9.isDateTime(t)&&(0,m.Y4)(t.zone)?z(e,t,r):V(U(e),U(t),r);if((0,F.Kg)(t))throw new l.L("InvalidOperator");if(x(t))return function(e,t,r){let n=t.toDateTimeLuxon(e.toDateTime().zone);return V((e=e.startOfDay()).toMilliseconds(),n.toMillis(),r)}(e,t,r);if(C(t)||(0,F.Et)(t))throw new l.L("InvalidOperator")}switch(r){case"<>":return e!==t;case"=":return e===t;case">":return e>t;case"<":return e<t;case">=":return e>=t;case"<=":return e<=t}}function V(e,t,r){switch(r){case"<>":return e!==t;case"=":return e===t;case">":return e>t;case"<":return e<t;case">=":return e>=t;case"<=":return e<=t}}function z(e,t,r){d.g.isTimestampOffset(e)&&(e=e.toDateTime()),d.g.isTimestampOffset(t)&&(t=t.toDateTime());let n=H(e),a=H(t);switch(r){case"<>":return n!==a;case"=":return n===a;case">":return n>a;case"<":return n<a;case">=":return n>=a;case"<=":return n<=a}}function H(e){return 321408e5*e.year+26784e5*e.month+864e5*e.day+36e5*e.hour+6e4*e.minute+1e3*e.second+e.millisecond}function q(e,t,r){let n=j[e.toLowerCase()];if(null==n)throw new l.L("FunctionNotRecognized");if(t.length<n.minParams||t.length>n.maxParams)throw new l.L("InvalidParameterCount",{name:e.toUpperCase()});return n.evaluate(t,r)}function K(e,t){let r=j[e.toLowerCase()];return null!=r&&t>=r.minParams&&t<=r.maxParams}function Z(e){return!((0,F.$P)(e)||x(e)||S(e)||C(e)||_(e))}function Y(e){return x(e)||C(e)?e.toString():_(e)?e.toSQLValue():S(e)?0===e.millisecond?e.toFormat("yyyy-LL-dd HH:mm:ss"):e.toSQL({includeOffset:!1}):(0,F.$P)(e)?Y(h.c9.fromJSDate(e)):e.toString()}const j={extract:{minParams:2,maxParams:2,evaluate:([e,t])=>{if(null==t)return null;if((0,F.$P)(t))switch(e.toUpperCase()){case"SECOND":return t.getSeconds();case"MINUTE":return t.getMinutes();case"HOUR":return t.getHours();case"DAY":return t.getDate();case"MONTH":return t.getMonth()+1;case"YEAR":return t.getFullYear();case"TIMEZONE_HOUR":case"TIMEZONE_MINUTE":return 0;case"DOW":return h.c9.fromJSDate(t,{zone:"system"}).weekday;case"DOY":return h.c9.fromJSDate(t,{zone:"system"}).ordinal;case"WEEK":return h.c9.fromJSDate(t,{zone:"system"}).weekNumber}else if(S(t))switch(e.toUpperCase()){case"SECOND":return t.second;case"MINUTE":return t.minute;case"HOUR":return t.hour;case"DAY":return t.day;case"MONTH":return t.month;case"YEAR":return t.year;case"TIMEZONE_HOUR":case"TIMEZONE_MINUTE":throw new l.L("InvalidFunctionParameters",{function:"EXTRACT"});case"DOW":return t.weekday;case"DOY":return t.ordinal;case"WEEK":return t.weekNumber}else if(x(t))switch(e.toUpperCase()){case"DAY":return t.day;case"MONTH":return t.month;case"YEAR":return t.year;case"TIMEZONE_HOUR":case"TIMEZONE_MINUTE":throw new l.L("InvalidFunctionParameters",{function:"EXTRACT"});case"DOW":return t.toDateTime("unknown").weekday;case"DOY":return t.toDateTime("unknown").ordinal;case"WEEK":return t.toDateTime("unknown").weekNumber}else if(C(t))switch(e.toUpperCase()){case"SECOND":return t.second;case"MINUTE":return t.minute;case"HOUR":return t.hour}else if(_(t))switch(e.toUpperCase()){case"SECOND":return t.second;case"MINUTE":return t.minute;case"HOUR":return t.hour;case"DAY":return t.day;case"MONTH":return t.month;case"YEAR":return t.year;case"TIMEZONE_HOUR":return t.timezoneOffsetHour;case"TIMEZONE_MINUTE":return t.timezoneOffsetMinutes;case"DOW":return t.toDateTime().weekday;case"DOY":return t.toDateTime().ordinal;case"WEEK":return t.toDateTime().weekNumber}throw new l.L("InvalidFunctionParameters",{function:"EXTRACT"})}},substring:{minParams:2,maxParams:3,evaluate:e=>{if(2===e.length){let[t,r]=e;return null==t||null==r?null:t.toString().substring(r-1)}if(3===e.length){let[t,r,n]=e;return null==t||null==r||null==n?null:n<=0?"":t.toString().substring(r-1,r+n-1)}}},position:{minParams:2,maxParams:2,evaluate:([e,t])=>null==e||null==t?null:t.indexOf(e)+1},trim:{minParams:2,maxParams:3,evaluate:e=>{let t=3===e.length,r=t?e[1]:" ",n=t?e[2]:e[1];if(null==r||null==n)return null;let a=`(${(0,A.Cj)(r)})`;switch(e[0]){case"BOTH":return n.replaceAll(RegExp(`^${a}*|${a}*$`,"g"),"");case"LEADING":return n.replaceAll(RegExp(`^${a}*`,"g"),"");case"TRAILING":return n.replaceAll(RegExp(`${a}*$`,"g"),"")}throw new l.L("InvalidFunctionParameters",{function:"TRIM"})}},abs:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.abs(e[0])},ceiling:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.ceil(e[0])},floor:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.floor(e[0])},log:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.log(e[0])},log10:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.log(e[0])*Math.LOG10E},sin:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.sin(e[0])},cos:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.cos(e[0])},tan:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.tan(e[0])},asin:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.asin(e[0])},acos:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.acos(e[0])},atan:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.atan(e[0])},sign:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:e[0]>0?1:e[0]<0?-1:0},power:{minParams:2,maxParams:2,evaluate:e=>null==e[0]||null==e[1]?null:e[0]**e[1]},mod:{minParams:2,maxParams:2,evaluate:e=>null==e[0]||null==e[1]?null:e[0]%e[1]},round:{minParams:1,maxParams:2,evaluate:e=>{let t=e[0],r=2===e.length?10**e[1]:1;return null==t?null:Math.round(t*r)/r}},truncate:{minParams:1,maxParams:2,evaluate:e=>null==e[0]?null:1===e.length||0===e[1]?Math.trunc(e[0]):(0,P.pF)("trunc",e[0],-Number(e[1]))},char_length:{minParams:1,maxParams:1,evaluate:e=>(0,F.Kg)(e[0])?e[0].length:0},concat:{minParams:1,maxParams:1/0,evaluate:e=>{let t="";for(let r=0;r<e.length;r++){if(null==e[r])return null;t+=e[r].toString()}return t}},lower:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:e[0].toString().toLowerCase()},upper:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:e[0].toString().toUpperCase()},coalesce:{minParams:1,maxParams:1/0,evaluate:e=>{for(let t of e)if(null!==t)return t;return null}},cosh:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.cosh(e[0])},sinh:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.sinh(e[0])},tanh:{minParams:1,maxParams:1,evaluate:e=>null==e[0]?null:Math.tanh(e[0])},nullif:{minParams:2,maxParams:2,evaluate:e=>k(e[0],e[1],"=")?null:e[0]},cast:{minParams:2,maxParams:2,evaluate:(e,t)=>{let r=e[0],n=e[1];if(null===r)return null;switch(n.type){case"integer":{if(!Z(r))throw new l.L("CannotCastValue");let e=parseInt(r,10);if(isNaN(e))throw new l.L("CannotCastValue");return e}case"smallint":{if(!Z(r))throw new l.L("CannotCastValue");let e=parseInt(r,10);if(isNaN(e)||e>32767||e<-32767)throw new l.L("CannotCastValue");return e}case"float":case"real":{if(!Z(r))throw new l.L("CannotCastValue");let e=parseFloat(r);if(isNaN(e))throw new l.L("CannotCastValue");return e}case"time":return function(e){if((0,F.$P)(e))return p.k.fromDateJS(e);if(S(e))return p.k.fromDateTime(e);if(x(e))throw new l.L("CannotCastValue");if(C(e))return e;if(_(e))return p.k.fromSqlTimeStampOffset(e);if((0,F.Kg)(e))return D(e);throw new l.L("CannotCastValue")}(r);case"date":return function(e){if((0,F.$P)(e))return o.n.fromDateJS(e);if(S(e))return o.n.fromParts(e.year,e.month,e.day);if(x(e))return e;if(C(e)||_(e)&&null===o.n.fromParts(e.year,e.month,e.day))throw new l.L("CannotCastValue");if((0,F.Kg)(e)){let t=o.n.fromReader(e);if(null!==t&&t.isValid)return t}throw new l.L("CannotCastValue")}(r);case"timestamp":return function(e,t){if((0,F.$P)(e))return O(e,t);if(S(e))return e;if(x(e))return e.toDateTimeLuxon("unknown");if(C(e))throw new l.L("CannotCastValue");if(_(e))return e;if((0,F.Kg)(e))return M(e,"unknown");throw new l.L("CannotCastValue")}(r,t);case"varchar":{let e=Y(r);if(e.length>n.size)throw new l.L("CannotCastValue");return e}default:throw new l.L("InvalidDataType")}}}};function W(e,t,r,n){if("||"===e)return q("concat",[t,r],n);if(null===t||null===r)return null;if((0,F.Et)(t)){if((0,F.Et)(r))return J(t,r,e);if(E(r))return function(e,t,r){switch(r){case"+":return f.createFromMilliseconds(e+t.valueInMilliseconds());case"-":return f.createFromMilliseconds(e-t.valueInMilliseconds());case"*":return f.createFromMilliseconds(e*t.valueInMilliseconds());case"/":return f.createFromMilliseconds(e/t.valueInMilliseconds())}throw new l.L("InvalidOperator")}(t,r,e);if(C(r))return function(){throw new l.L("InvalidOperator")}();if(x(r))return function(){throw new l.L("InvalidOperator")}();if(_(r))return function(){throw new l.L("InvalidOperator")}();if(S(r))return function(){throw new l.L("InvalidOperator")}();if((0,F.Kg)(r))return function(e,t,r){let n=parseFloat(t);if(isNaN(n))throw new l.L("InvalidOperator");return J(e,n,r)}(t,r,e);throw new l.L("InvalidOperator")}if(x(t)){if((0,F.Et)(r))return function(e,t,r){let n=1e3*t*24*60*60;switch(r){case"+":return e.plus("milliseconds",n);case"-":return e.plus("milliseconds",-1*n)}throw new l.L("InvalidOperator")}(t,r,e);if(E(r))return function(e,t,r){switch(r){case"+":return e.plus("milliseconds",t.valueInMilliseconds());case"-":return e.plus("milliseconds",-1*t.valueInMilliseconds())}throw new l.L("InvalidOperator")}(t,r,e);if(C(r))return function(){throw new l.L("InvalidOperator")}();if(x(r))return function(e,t,r){if("-"===r)return e.toDateTimeLuxon("UTC").diff(t.toDateTimeLuxon("UTC")).as("days");throw new l.L("InvalidOperator")}(t,r,e);if(_(r))return function(e,t,r){if("-"===r)return e.toDateTimeLuxon(t.toDateTime().zone).diff(t.toDateTime()).as("days");throw new l.L("InvalidOperator")}(t,r,e);if(S(r))return function(e,t,r){if("-"===r)return e.toDateTimeLuxon(t.zone).diff(t).as("days");throw new l.L("InvalidOperator")}(t,r,e);if((0,F.Kg)(r))return function(){throw new l.L("InvalidOperator")}();throw new l.L("InvalidOperator")}if(C(t)){if((0,F.Et)(r))return function(e,t,r){let n=1e3*t*24*60*60;switch(r){case"+":return e.plus("milliseconds",n);case"-":return e.plus("milliseconds",-1*n)}throw new l.L("InvalidOperator")}(t,r,e);if(E(r))return function(e,t,r){switch(r){case"+":return e.plus("milliseconds",t.valueInMilliseconds());case"-":return e.plus("milliseconds",-1*t.valueInMilliseconds())}throw new l.L("InvalidOperator")}(t,r,e);if(C(r))return function(){throw new l.L("InvalidOperator")}();if(x(r))return function(){throw new l.L("InvalidOperator")}();if(_(r))return function(){throw new l.L("InvalidOperator")}();if(S(r))return function(){throw new l.L("InvalidOperator")}();if((0,F.Kg)(r))return function(){throw new l.L("InvalidOperator")}();throw new l.L("InvalidOperator")}if(E(t)){if((0,F.Et)(r))return function(e,t,r){switch(r){case"+":return f.createFromMilliseconds(e.valueInMilliseconds()+t);case"-":return f.createFromMilliseconds(e.valueInMilliseconds()-t);case"*":return f.createFromMilliseconds(e.valueInMilliseconds()*t);case"/":return f.createFromMilliseconds(e.valueInMilliseconds()/t)}throw new l.L("InvalidOperator")}(t,r,e);if(E(r))return function(e,t,r){switch(r){case"+":return f.createFromMilliseconds(e.valueInMilliseconds()+t.valueInMilliseconds());case"-":return f.createFromMilliseconds(e.valueInMilliseconds()-t.valueInMilliseconds());case"*":return f.createFromMilliseconds(e.valueInMilliseconds()*t.valueInMilliseconds());case"/":return f.createFromMilliseconds(e.valueInMilliseconds()/t.valueInMilliseconds())}throw new l.L("InvalidOperator")}(t,r,e);if(C(r))return function(e,t,r){if("+"===r)return t.plus("milliseconds",e.valueInMilliseconds());throw new l.L("InvalidOperator")}(t,r,e);if(x(r))return function(e,t,r){if("+"===r)return t.plus("milliseconds",e.valueInMilliseconds());throw new l.L("InvalidOperator")}(t,r,e);if(_(r))return function(e,t,r){if("+"===r)return t.addMilliseconds(e.valueInMilliseconds());throw new l.L("InvalidOperator")}(t,r,e);if(S(r))return function(e,t,r){switch(r){case"+":return t.plus({milliseconds:e.valueInMilliseconds()});case"-":return e.valueInMilliseconds()-t.toMillis()}throw new l.L("InvalidOperator")}(t,r,e);if((0,F.Kg)(r))return function(){throw new l.L("InvalidOperator")}();throw new l.L("InvalidOperator")}if(S(t)){if((0,F.Et)(r))return function(e,t,r){let n=1e3*t*24*60*60;switch(r){case"+":return e.plus({milliseconds:n});case"-":return e.minus({milliseconds:n})}throw new l.L("InvalidOperator")}(t,r,e);if(E(r))return function(e,t,r){switch(r){case"+":return e.plus({milliseconds:t.valueInMilliseconds()});case"-":return e.minus({milliseconds:t.valueInMilliseconds()})}throw new l.L("InvalidOperator")}(t,r,e);if(C(r))return function(){throw new l.L("InvalidOperator")}();if(x(r))return function(e,t,r){if("-"===r)return e.diff(t.toDateTimeLuxon(e.zone)).as("days");throw new l.L("InvalidOperator")}(t,r,e);if(_(r))return function(e,t,r){if("-"===r)return e.diff(t.toDateTime()).as("days");throw new l.L("InvalidOperator")}(t,r,e);if(S(r))return function(e,t,r){if("-"===r)return e.diff(t).as("days");throw new l.L("InvalidOperator")}(t,r,e);if((0,F.Kg)(r))return function(){throw new l.L("InvalidOperator")}();throw new l.L("InvalidOperator")}if(_(t)){if((0,F.Et)(r))return function(e,t,r){let n=1e3*t*24*60*60;switch(r){case"+":return e.addMilliseconds(n);case"-":return e.addMilliseconds(-1*n)}throw new l.L("InvalidOperator")}(t,r,e);if(E(r))return function(e,t,r){switch(r){case"+":return e.addMilliseconds(t.valueInMilliseconds());case"-":return e.addMilliseconds(-1*t.valueInMilliseconds())}throw new l.L("InvalidOperator")}(t,r,e);if(C(r))return function(){throw new l.L("InvalidOperator")}();if(x(r))return function(e,t,r){if("-"===r)return e.toDateTime().diff(t.toDateTimeLuxon(e.toDateTime().zone)).as("days");throw new l.L("InvalidOperator")}(t,r,e);if(_(r))return function(e,t,r){if("-"===r)return e.toDateTime().diff(t.toDateTime()).as("days");throw new l.L("InvalidOperator")}(t,r,e);if(S(r))return function(e,t,r){if("-"===r)return e.toDateTime().diff(t).as("days");throw new l.L("InvalidOperator")}(t,r,e);if((0,F.Kg)(r))return function(){throw new l.L("InvalidOperator")}();throw new l.L("InvalidOperator")}if((0,F.Kg)(t)){if((0,F.Et)(r))return function(e,t,r){let n=parseFloat(e);if(isNaN(n))throw new l.L("InvalidOperator");return J(n,t,r)}(t,r,e);if(E(r))return function(){throw new l.L("InvalidOperator")}();if(C(r))return function(){throw new l.L("InvalidOperator")}();if(x(r))return function(){throw new l.L("InvalidOperator")}();if(_(r))return function(){throw new l.L("InvalidOperator")}();if(S(r))return function(){throw new l.L("InvalidOperator")}();if((0,F.Kg)(r))return function(e,t,r){if("+"===r)return e+t;throw new l.L("InvalidOperator")}(t,r,e);throw new l.L("InvalidOperator")}throw new l.L("InvalidOperator")}function J(e,t,r){switch(r){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return e/t}throw new l.L("InvalidOperator")}function*Q(e){if(null==e)return;let t=[e];for(;t.length;){let e=t.pop();switch(yield e,e.type){case"when-clause":t.push(e.value),t.push(e.operand);break;case"case-expression":{let r=[];for(let t of e.clauses)r.push(t);"simple"===e.format&&r.push(e.operand),null!=e.else&&r.push(e.else);for(let e=r.length-1;e>=0;e--)t.push(r[e]);break}case"expression-list":for(let r=e.value.length-1;r>=0;r--)t.push(e.value[r]);break;case"unary-expression":t.push(e.expr);break;case"binary-expression":t.push(e.right),t.push(e.left);break;case"function":t.push(e.args);break;case"interval":t.push(e.qualifier),t.push(e.value);break;case"interval-qualifier":t.push(e.end),t.push(e.start)}}}class B extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let a=this.location.start,i=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(a):a,o=this.location.source+":"+i.line+":"+i.column;if(r){let e=this.location.end,n="".padEnd(i.line.toString().length," "),l=r[a.line-1],u=(a.line===e.line?e.column:l.length+1)-a.column||1;t+="\n --\x3e "+o+"\n"+n+" |\n"+i.line+" | "+l+"\n"+n+" | "+"".padEnd(a.column-1," ")+"".padEnd(u,"^")}else t+="\n at "+o}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function a(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function i(e){return a(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function o(e){return a(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let l={literal:e=>'"'+i(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function u(e){return l[e.type](e)}return"Expected "+function(e){let t=e.map(u);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+function(e){return e?'"'+i(e)+'"':"end of input"}(t)+" found."}}function G(e,t){let r={},n=(t=void 0===t?{}:t).grammarSource,a={start:st},i=st,o=/^[<-=]/,l=/^[+\-]/,u=/^[*\/]/,s=/^[A-Za-z_\x80-\uFFFF]/,c=/^[A-Za-z0-9_]/,f=/^[A-Za-z0-9_.\x80-\uFFFF]/,d=/^["]/,p=/^[^']/,m=/^[0-9]/,h=/^[eE]/,v=/^[ \t\n\r]/,w=/^[^`]/,g=at("!",!1),I=at("=",!1),y=at(">=",!1),L=at(">",!1),T=at("<=",!1),N=at("<>",!1),O=it([["<","="]],!1,!1,!1),E=at("!=",!1),S=it(["+","-"],!1,!1,!1),x=at("||",!1),C=it(["*","/"],!1,!1,!1),_=it([["A","Z"],["a","z"],"_",["",""]],!1,!1,!1),D=it([["A","Z"],["a","z"],["0","9"],"_"],!1,!1,!1),M=it([["A","Z"],["a","z"],["0","9"],"_",".",["",""]],!1,!1,!1),b=it(['"'],!1,!1,!1),P=at("@",!1),A=at("'",!1),F=at("N'",!1),$=at("''",!1),R=it(["'"],!0,!1,!1),U=at(".",!1),k=it([["0","9"]],!1,!1,!1),V=it(["e","E"],!1,!1,!1),z=at("NULL",!0),H=at("TRUE",!0),q=at("FALSE",!0),K=at("IN",!0),Z=at("IS",!0),Y=at("LIKE",!0),j=at("ESCAPE",!0),W=at("NOT",!0),J=at("AND",!0),Q=at("OR",!0),G=at("BETWEEN",!0),X=at("FROM",!0),ee=at("FOR",!0),te=at("SUBSTRING",!0),re=at("EXTRACT",!0),ne=at("TRIM",!0),ae=at("POSITION",!0),ie=at("TIMESTAMP",!0),oe=at("DATE",!0),le=at("TIME",!0),ue=at("LEADING",!0),se=at("TRAILING",!0),ce=at("BOTH",!0),fe=at("CAST",!0),de=at("AS",!0),pe=at("INTEGER",!0),me=at("INT",!0),he=at("SMALLINT",!0),ve=at("FLOAT",!0),we=at("REAL",!0),ge=at("VARCHAR",!0),Ie=at("TO",!0),ye=at("INTERVAL",!0),Le=at("YEAR",!0),Te=at("TIMEZONE_HOUR",!0),Ne=at("TIMEZONE_MINUTE",!0),Oe=at("MONTH",!0),Ee=at("DAY",!0),Se=at("HOUR",!0),xe=at("MINUTE",!0),Ce=at("SECOND",!0),_e=at("DOW",!0),De=at("DOY",!0),Me=at("WEEK",!0),be=at("CASE",!0),Pe=at("END",!0),Ae=at("WHEN",!0),Fe=at("THEN",!0),$e=at("ELSE",!0),Re=at(",",!1),Ue=at("(",!1),ke=at(")",!1),Ve=it([" ","\t","\n","\r"],!1,!1,!1),ze=at("`",!1),He=it(["`"],!0,!1,!1);function qe(e,t,r){return{op:t,expr:r,location:rt()}}function Ke(e,t,r){return{op:t,expr:r,location:rt()}}function Ze(e,t){return{op:e,expr:t,location:rt()}}function Ye(e,t,r){return{op:t,expr:r,location:rt()}}function je(e,t,r){return{op:t,expr:r,location:rt()}}function We(){return"'"}let Je,Qe=0|t.peg$currPos,Be=Qe,Ge=[{line:1,column:1}],Xe=Qe,et=t.peg$maxFailExpected||[],tt=0|t.peg$silentFails;if(t.startRule){if(!(t.startRule in a))throw Error("Can't start parsing from rule \""+t.startRule+'".');i=a[t.startRule]}function rt(){return lt(Be,Qe)}function nt(e,t){throw function(e,t){return new B(e,null,null,t)}(e,t=void 0===t?lt(Be,Qe):t)}function at(e,t){return{type:"literal",text:e,ignoreCase:t}}function it(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function ot(t){let r,n=Ge[t];if(n)return n;if(t>=Ge.length)r=Ge.length-1;else for(r=t;!Ge[--r];);for(n=Ge[r],n={line:n.line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return Ge[t]=n,n}function lt(e,t,r){let a=ot(e),i=ot(t);return{source:n,start:{offset:e,line:a.line,column:a.column},end:{offset:t,line:i.line,column:i.column}}}function ut(e){Qe<Xe||(Qe>Xe&&(Xe=Qe,et=[]),et.push(e))}function st(){let e,t;return e=Qe,Yr(),t=ft(),t===r?(Qe=e,e=r):(Yr(),Be=e,e=t),e}function ct(){let e,t,n,a,i,o,l,u;if(e=Qe,t=Kr(),t!==r){for(Yr(),n=[],a=ft();a!==r;)n.push(a),a=Qe,i=Qe,o=Yr(),l=qr(),l===r?(Qe=i,i=r):(u=Yr(),o=[o,l,u],i=o),i===r?a=i:(i=ft(),i===r?(Qe=a,a=r):a=i);a=Yr(),i=Zr(),i===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"expression-list",location:rt(),value:e}}(n))}else Qe=e,e=r;return e}function ft(){let e,t,n,a,i,o;if(e=Qe,t=dt(),t!==r){for(n=[],a=Qe,Yr(),i=nr(),i===r?(Qe=a,a=r):(Yr(),o=dt(),o===r?(Qe=a,a=r):(Be=a,a=qe(0,i,o)));a!==r;)n.push(a),a=Qe,Yr(),i=nr(),i===r?(Qe=a,a=r):(Yr(),o=dt(),o===r?(Qe=a,a=r):(Be=a,a=qe(0,i,o)));Be=e,e=function(e,t){return Br(e,t)}(t,n)}else Qe=e,e=r;return e}function dt(){let e,t,n,a,i,o;if(e=Qe,t=pt(),t!==r){for(n=[],a=Qe,Yr(),i=rr(),i===r?(Qe=a,a=r):(Yr(),o=pt(),o===r?(Qe=a,a=r):(Be=a,a=Ke(0,i,o)));a!==r;)n.push(a),a=Qe,Yr(),i=rr(),i===r?(Qe=a,a=r):(Yr(),o=pt(),o===r?(Qe=a,a=r):(Be=a,a=Ke(0,i,o)));Be=e,e=function(e,t){return Br(e,t)}(t,n)}else Qe=e,e=r;return e}function pt(){let t,n,a,i,o;return t=Qe,n=tr(),n===r&&(n=Qe,33===e.charCodeAt(Qe)?(a="!",Qe++):(a=r,0===tt&&ut(g)),a===r?(Qe=n,n=r):(i=Qe,tt++,61===e.charCodeAt(Qe)?(o="=",Qe++):(o=r,0===tt&&ut(I)),tt--,o===r?i=void 0:(Qe=i,i=r),i===r?(Qe=n,n=r):(a=[a,i],n=a))),n===r?(Qe=t,t=r):(a=Yr(),i=pt(),i===r?(Qe=t,t=r):(Be=t,t=function(e){return function(e,t,r){return{type:"unary-expression",location:r,operator:"NOT",expr:t}}(0,e,rt())}(i))),t===r&&(t=function(){let e,t,n,a;return e=Qe,t=wt(),t===r?(Qe=e,e=r):(n=Qe,Yr(),a=function(){let e;return e=function(){let e,t,n,a,i;if(e=Qe,t=[],n=Qe,Yr(),a=mt(),a===r?(Qe=n,n=r):(Yr(),i=wt(),i===r?(Qe=n,n=r):(Be=n,n=Ze(a,i))),n!==r)for(;n!==r;)t.push(n),n=Qe,Yr(),a=mt(),a===r?(Qe=n,n=r):(Yr(),i=wt(),i===r?(Qe=n,n=r):(Be=n,n=Ze(a,i)));else t=r;return t!==r&&(Be=e,t=function(e){return{type:"arithmetic",tail:e}}(t)),e=t,e}(),e===r&&(e=function(){let e,t,n;return e=Qe,t=vt(),t===r?(Qe=e,e=r):(Yr(),n=ct(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:e,right:t}}(t,n))),e===r&&(e=Qe,t=vt(),t===r?(Qe=e,e=r):(Yr(),n=Ct(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:e,right:t}}(t,n)))),e}(),e===r&&(e=function(){let e,t,n,a,i,o,l,u;return e=Qe,t=tr(),t===r?(Qe=e,e=r):(Yr(),n=ar(),n===r?(Qe=e,e=r):(a=Yr(),i=Qe,o=wt(),o===r?(Qe=i,i=r):(Yr(),l=rr(),l===r?(Qe=i,i=r):(Yr(),u=wt(),u===r?(Qe=i,i=r):(Be=i,i=function(e,t,r){return Qr(rt(),t,r)}(0,o,u)))),i===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:"NOT"+e,right:t}}(n,i)))),e===r&&(e=Qe,t=ar(),t===r?(Qe=e,e=r):(Yr(),n=Qe,a=wt(),a===r?(Qe=n,n=r):(i=Yr(),o=rr(),o===r?(Qe=n,n=r):(Yr(),l=wt(),l===r?(Qe=n,n=r):(Be=n,n=function(e,t,r){return Qr(rt(),t,r)}(0,a,l)))),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:e,right:t}}(t,n)))),e}(),e===r&&(e=function(){let e,t,n,a;return e=Qe,t=Gt(),t===r?(Qe=e,e=r):(Yr(),n=tr(),n===r?(Qe=e,e=r):(Yr(),a=wt(),a===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:e+"NOT",right:t}}(t,a)))),e===r&&(e=Qe,t=Gt(),t===r?(Qe=e,e=r):(Yr(),n=wt(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:e,right:t}}(t,n)))),e}(),e===r&&(e=function(){let e,t,n,a,i;return e=Qe,t=ht(),t===r?(Qe=e,e=r):(Yr(),n=wt(),n===r?(Qe=e,e=r):(Yr(),a=er(),a===r?(Qe=e,e=r):(Yr(),i=Ut(),i===r?(Qe=e,e=r):(Be=e,e=function(e,t,r){return{op:e,right:t,escape:r.value}}(t,n,i))))),e===r&&(e=Qe,t=ht(),t===r?(Qe=e,e=r):(Yr(),n=wt(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{op:e,right:t,escape:""}}(t,n)))),e}())))),e}(),a===r?(Qe=n,n=r):n=a,n===r&&(n=null),Be=e,e=function(e,t){return""==t||null==t||null==t?e:"arithmetic"==t.type?Br(e,t.tail):Jr(t.op,e,t.right,t.escape,rt())}(t,n)),e}()),t}function mt(){let t;return">="===e.substr(Qe,2)?(t=">=",Qe+=2):(t=r,0===tt&&ut(y)),t===r&&(62===e.charCodeAt(Qe)?(t=">",Qe++):(t=r,0===tt&&ut(L)),t===r&&("<="===e.substr(Qe,2)?(t="<=",Qe+=2):(t=r,0===tt&&ut(T)),t===r&&("<>"===e.substr(Qe,2)?(t="<>",Qe+=2):(t=r,0===tt&&ut(N)),t===r&&(t=e.charAt(Qe),o.test(t)?Qe++:(t=r,0===tt&&ut(O)),t===r&&("!="===e.substr(Qe,2)?(t="!=",Qe+=2):(t=r,0===tt&&ut(E))))))),t}function ht(){let e,t,n,a,i;return e=Qe,t=Qe,n=tr(),n===r?(Qe=t,t=r):(a=Yr(),i=Xt(),i===r?(Qe=t,t=r):(n=[n,a,i],t=n)),t!==r&&(Be=e,t=function(e){return e[0]+" "+e[2]}(t)),e=t,e===r&&(e=Xt()),e}function vt(){let e,t,n,a,i;return e=Qe,t=Qe,n=tr(),n===r?(Qe=t,t=r):(a=Yr(),i=Bt(),i===r?(Qe=t,t=r):(n=[n,a,i],t=n)),t!==r&&(Be=e,t=function(e){return e[0]+" "+e[2]}(t)),e=t,e===r&&(e=Bt()),e}function wt(){let e,t,n,a,i,o;if(e=Qe,t=It(),t!==r){for(n=[],a=Qe,Yr(),i=gt(),i===r?(Qe=a,a=r):(Yr(),o=It(),o===r?(Qe=a,a=r):(Be=a,a=Ye(0,i,o)));a!==r;)n.push(a),a=Qe,Yr(),i=gt(),i===r?(Qe=a,a=r):(Yr(),o=It(),o===r?(Qe=a,a=r):(Be=a,a=Ye(0,i,o)));Be=e,e=function(e,t){return Br(e,t)}(t,n)}else Qe=e,e=r;return e}function gt(){let t;return t=e.charAt(Qe),l.test(t)?Qe++:(t=r,0===tt&&ut(S)),t===r&&("||"===e.substr(Qe,2)?(t="||",Qe+=2):(t=r,0===tt&&ut(x))),t}function It(){let e,t,n,a,i,o;if(e=Qe,t=Lt(),t!==r){for(n=[],a=Qe,Yr(),i=yt(),i===r?(Qe=a,a=r):(Yr(),o=Lt(),o===r?(Qe=a,a=r):(Be=a,a=je(0,i,o)));a!==r;)n.push(a),a=Qe,Yr(),i=yt(),i===r?(Qe=a,a=r):(Yr(),o=Lt(),o===r?(Qe=a,a=r):(Be=a,a=je(0,i,o)));Be=e,e=function(e,t){return Br(e,t)}(t,n)}else Qe=e,e=r;return e}function yt(){let t;return t=e.charAt(Qe),u.test(t)?Qe++:(t=r,0===tt&&ut(C)),t}function Lt(){let e,t,n,a;return e=function(){let e;return e=Ut(),e===r&&(e=function(){let e,t,n,a;return e=Qe,t=function(){let e,t,n,a;return e=Qe,t=Ht(),t===r?(Qe=e,e=r):(n=qt(),n===r?(Qe=e,e=r):(a=Kt(),a===r?(Qe=e,e=r):(Be=e,e=function(e,t,r){return parseFloat(e+t+r)}(t,n,a)))),e===r&&(e=Qe,t=Ht(),t===r?(Qe=e,e=r):(n=qt(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return parseFloat(e+t)}(t,n))),e===r&&(e=Qe,t=Ht(),t===r?(Qe=e,e=r):(n=Kt(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return parseFloat(e+t)}(t,n))),e===r&&(e=Qe,t=Ht(),t!==r&&(Be=e,t=function(e){return parseFloat(e)}(t)),e=t))),e}(),t===r?(Qe=e,e=r):(n=Qe,tt++,a=Nt(),tt--,a===r?n=void 0:(Qe=n,n=r),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"number",location:rt(),value:e}}(t))),e}(),e===r&&(e=function(){let e,t;return e=Qe,t=Jt(),t!==r&&(Be=e,t={type:"boolean",location:rt(),value:!0}),e=t,e===r&&(e=Qe,t=Qt(),t!==r&&(Be=e,t={type:"boolean",location:rt(),value:!1}),e=t),e}(),e===r&&(e=function(){let e,t;return e=Qe,t=Wt(),t!==r&&(Be=e,t={type:"null",location:rt(),value:null}),e=t,e}(),e===r&&(e=function(){let e,t,n;return e=Qe,t=dr(),t===r?(Qe=e,e=r):(Yr(),n=Rt(),n===r?(Qe=e,e=r):(Be=e,e=function(e){return"string"===e.type&&function(e){!0!==/^(\d{4})-(\d{1,2})-(\d{1,2})$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/.test(e)&&nt("Date literal is invalid")}(e.value),{type:"date",location:rt(),value:e.value}}(n))),e}(),e===r&&(e=function(){let e,t,n;return e=Qe,t=fr(),t===r?(Qe=e,e=r):(Yr(),n=Rt(),n===r?(Qe=e,e=r):(Be=e,e=function(e){return"string"===e.type&&function(e){!0!==/^(\d{4})-(\d{1,2})-(\d{1,2})$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})(\.[0-9]+)?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})?[ ]{0,1}(\+|\-)(\d{1,2}):(\d{1,2})$|^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/.test(e)&&nt("Timestamp literal is invalid")}(e.value),{type:"timestamp",location:rt(),value:e.value}}(n))),e}(),e===r&&(e=bt(),e===r&&(e=function(){let e,t,n;return e=Qe,t=pr(),t===r?(Qe=e,e=r):(Yr(),n=Rt(),n===r?(Qe=e,e=r):(Be=e,e=function(e){return"string"===e.type&&function(e){!0!==/^(\d{1,2}):(\d{1,2}):(\d{1,2})$|^(\d{1,2}):(\d{1,2})$|^(\d{1,2}):(\d{1,2}):(\d{1,2}).([0-9]+)$/.test(e)&&nt("Time literal is invalid")}(e.value),{type:"time",location:rt(),value:e.value}}(n))),e}()))))))),e}(),e===r&&(e=function(){let e,t,n,a,i,o,l,u;return e=Qe,t=ur(),t===r?(Qe=e,e=r):(Yr(),n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=Mt(),i===r?(Qe=n,n=r):(Yr(),o=ir(),o===r?(Qe=n,n=r):(Yr(),l=ft(),l===r?(Qe=n,n=r):(Yr(),u=Zr(),u===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,l)))))),n===r&&(n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=Mt(),i===r?(Qe=n,n=r):(Yr(),o=qr(),o===r?(Qe=n,n=r):(Yr(),l=ft(),l===r?(Qe=n,n=r):(Yr(),u=Zr(),u===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,l))))))),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"function",location:rt(),name:"extract",args:e}}(n))),e}(),e===r&&(e=function(){let e,t,n,a,i,o,l,u,s,c,f;return e=Qe,t=lr(),t===r?(Qe=e,e=r):(Yr(),n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=ft(),i===r?(Qe=n,n=r):(Yr(),o=ir(),o===r?(Qe=n,n=r):(Yr(),l=ft(),l===r?(Qe=n,n=r):(Yr(),u=Qe,s=or(),s===r?(Qe=u,u=r):(c=Yr(),f=ft(),f===r?(Qe=u,u=r):(Yr(),u=f)),u===r&&(u=null),s=Zr(),s===r?(Qe=n,n=r):(Be=n,n=function(e,t,r){return Qr(rt(),e,t,...r?[r]:[])}(i,l,u)))))),n===r&&(n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=ft(),i===r?(Qe=n,n=r):(Yr(),o=qr(),o===r?(Qe=n,n=r):(Yr(),l=ft(),l===r?(Qe=n,n=r):(Yr(),u=qr(),u===r?(Qe=n,n=r):(s=Yr(),c=ft(),c===r?(Qe=n,n=r):(f=Zr(),f===r?(Qe=n,n=r):(Be=n,n=function(e,t,r){return Qr(rt(),e,t,r)}(i,l,c))))))))),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"function",location:rt(),name:"substring",args:e}}(n))),e}(),e===r&&(e=function(){let e,t,n,a,i,o,l,u,s;return e=Qe,t=sr(),t===r?(Qe=e,e=r):(Yr(),n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=Dt(),Yr(),o=ft(),o===r?(Qe=n,n=r):(Yr(),l=ir(),l===r?(Qe=n,n=r):(Yr(),u=ft(),u===r?(Qe=n,n=r):(Yr(),s=Zr(),s===r?(Qe=n,n=r):(Be=n,n=function(e,t,r){return Qr(rt(),e,t,r)}(i,o,u)))))),n===r&&(n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=Dt(),Yr(),o=ft(),o===r?(Qe=n,n=r):(Yr(),l=Zr(),l===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,o))))),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"function",location:rt(),name:"trim",args:e}}(n))),e}(),e===r&&(e=function(){let e,t,n,a,i,o,l,u;return e=Qe,t=cr(),t===r?(Qe=e,e=r):(Yr(),n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=ft(),i===r?(Qe=n,n=r):(Yr(),o=Bt(),o===r?(Qe=n,n=r):(Yr(),l=ft(),l===r?(Qe=n,n=r):(Yr(),u=Zr(),u===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,l)))))),n===r&&(n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=ft(),i===r?(Qe=n,n=r):(Yr(),o=qr(),o===r?(Qe=n,n=r):(Yr(),l=ft(),l===r?(Qe=n,n=r):(Yr(),u=Zr(),u===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,l))))))),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"function",location:rt(),name:"position",args:e}}(n))),e}(),e===r&&(e=function(){let e,t,n,a,i,o,l,u;return e=Qe,t=wr(),t===r?(Qe=e,e=r):(Yr(),n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=ft(),i===r?(Qe=n,n=r):(Yr(),o=gr(),o===r?(Qe=n,n=r):(Yr(),l=_t(),l===r?(Qe=n,n=r):(Yr(),u=Zr(),u===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,l)))))),n===r&&(n=Qe,a=Kr(),a===r?(Qe=n,n=r):(Yr(),i=ft(),i===r?(Qe=n,n=r):(Yr(),o=qr(),o===r?(Qe=n,n=r):(Yr(),l=_t(),l===r?(Qe=n,n=r):(Yr(),u=Zr(),u===r?(Qe=n,n=r):(Be=n,n=function(e,t){return Qr(rt(),e,t)}(i,l))))))),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"function",location:rt(),name:"cast",args:e}}(n))),e}(),e===r&&(e=function(){let e,t,n,a;return e=Qe,t=Qe,tt++,n=ur(),tt--,n===r?t=void 0:(Qe=t,t=r),t===r?(Qe=e,e=r):(n=Wr(),n===r?(Qe=e,e=r):(Yr(),a=ct(),a===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"function",location:rt(),name:e,args:t}}(n,a)))),e}(),e===r&&(e=function(){let e;return e=function(){let e,t,n,a,i,o,l;if(e=Qe,t=Ur(),t!==r)if(Yr(),n=ft(),n!==r){for(Yr(),a=[],i=Qe,o=Vt(),o===r?(Qe=i,i=r):(l=Yr(),i=o);i!==r;)a.push(i),i=Qe,o=Vt(),o===r?(Qe=i,i=r):(l=Yr(),i=o);i=kr(),i===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"case-expression",location:rt(),format:"simple",operand:e,clauses:t,else:null,elseLocation:null}}(n,a))}else Qe=e,e=r;else Qe=e,e=r;if(e===r)if(e=Qe,t=Ur(),t!==r)if(Yr(),n=ft(),n!==r){for(Yr(),a=[],i=Qe,o=Vt(),o===r?(Qe=i,i=r):(l=Yr(),i=o);i!==r;)a.push(i),i=Qe,o=Vt(),o===r?(Qe=i,i=r):(l=Yr(),i=o);i=zt(),i===r?(Qe=e,e=r):(o=Yr(),l=kr(),l===r?(Qe=e,e=r):(Be=e,e=function(e,t,r){return{type:"case-expression",location:rt(),format:"simple",operand:e,clauses:t,else:r.value,elseLocation:r.location}}(n,a,i)))}else Qe=e,e=r;else Qe=e,e=r;return e}(),e===r&&(e=function(){let e,t,n,a,i,o;if(e=Qe,t=Ur(),t!==r){for(Yr(),n=[],a=Qe,i=kt(),i===r?(Qe=a,a=r):(o=Yr(),a=i);a!==r;)n.push(a),a=Qe,i=kt(),i===r?(Qe=a,a=r):(o=Yr(),a=i);a=kr(),a===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"case-expression",location:rt(),format:"searched",clauses:e,else:null,elseLocation:null}}(n))}else Qe=e,e=r;if(e===r)if(e=Qe,t=Ur(),t!==r){for(Yr(),n=[],a=Qe,i=kt(),i===r?(Qe=a,a=r):(o=Yr(),a=i);a!==r;)n.push(a),a=Qe,i=kt(),i===r?(Qe=a,a=r):(o=Yr(),a=i);a=zt(),a===r?(Qe=e,e=r):(i=Yr(),o=kr(),o===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"case-expression",location:rt(),format:"searched",clauses:e,else:t.value,elseLocation:t.location}}(n,a)))}else Qe=e,e=r;return e}()),e}(),e===r&&(e=function(){let e,t;return e=Qe,t=function(){let e,t;return e=Qe,t=function(){let e,t,n,a;if(e=Qe,t=Nt(),t!==r){for(n=[],a=Et();a!==r;)n.push(a),a=Et();Be=e,e=function(e,t){return e+t.join("")}(t,n)}else Qe=e,e=r;return e}(),t!==r&&(Be=e),e=t,e}(),t!==r&&(Be=e,t=function(e){return/^CURRENT_DATE$/i.test(e)?{type:"current-time",location:rt(),mode:"date"}:/^CURRENT_TIMESTAMP$/i.test(e)?{type:"current-time",location:rt(),mode:"timestamp"}:/^CURRENT_TIME$/i.test(e)?{type:"current-time",location:rt(),mode:"time"}:/^CURRENT_USER$/i.test(e)?{type:"current-user",location:rt()}:{type:"column-reference",location:rt(),table:"",column:e}}(t)),e=t,e===r&&(e=Qe,t=function(){let e,t,n,a;return e=Qe,t=xt(),t===r?(Qe=e,e=r):(n=function(){let e,t,n;for(e=Qe,t=[],n=St();n!==r;)t.push(n),n=St();return Be=e,t=function(e){return e.join("")}(t),e=t,e}(),a=xt(),a===r?(Qe=e,e=r):(Be=e,e=n)),e}(),t!==r&&(Be=e,t=function(e){return{type:"column-reference",location:rt(),table:"",column:e,delimited:!0}}(t)),e=t),e}(),e===r&&(e=Ct(),e===r&&(e=Qe,t=Kr(),t===r?(Qe=e,e=r):(Yr(),n=ft(),n===r?(Qe=e,e=r):(Yr(),a=Zr(),a===r?(Qe=e,e=r):(Be=e,e=function(e){return e.paren=!0,e}(n)))))))))))))),e}function Tt(){let e,t,n,a;if(e=Qe,t=Nt(),t!==r){for(n=[],a=Ot();a!==r;)n.push(a),a=Ot();Be=e,e=function(e,t){return e+t.join("")}(t,n)}else Qe=e,e=r;return e}function Nt(){let t;return t=e.charAt(Qe),s.test(t)?Qe++:(t=r,0===tt&&ut(_)),t}function Ot(){let t;return t=e.charAt(Qe),c.test(t)?Qe++:(t=r,0===tt&&ut(D)),t}function Et(){let t;return t=e.charAt(Qe),f.test(t)?Qe++:(t=r,0===tt&&ut(M)),t}function St(){let t;return t=function(){let t;return t=e.charAt(Qe),f.test(t)?Qe++:(t=r,0===tt&&ut(M)),t}(),t===r&&(t=function(){let e,t,n;return e=Qe,t=xt(),t===r?(Qe=e,e=r):(n=xt(),n===r?(Qe=e,e=r):(Be=e,e='"')),e}()),t}function xt(){let t;return t=e.charAt(Qe),d.test(t)?Qe++:(t=r,0===tt&&ut(b)),t}function Ct(){let t,n,a,i;return t=Qe,n=Qe,64===e.charCodeAt(Qe)?(a="@",Qe++):(a=r,0===tt&&ut(P)),a===r?(Qe=n,n=r):(i=Tt(),i===r?(Qe=n,n=r):(a=[a,i],n=a)),n!==r&&(Be=t,n=function(e){return{type:"parameter",location:rt(),value:e[1]}}(n)),t=n,t}function _t(){let e,t,n,a,i;return e=Qe,t=Ir(),t===r&&(t=yr()),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"integer"}}),e=t,e===r&&(e=Qe,t=Lr(),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"smallint"}}),e=t,e===r&&(e=Qe,t=Tr(),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"float"}}),e=t,e===r&&(e=Qe,t=Nr(),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"real"}}),e=t,e===r&&(e=Qe,t=dr(),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"date"}}),e=t,e===r&&(e=Qe,t=fr(),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"timestamp"}}),e=t,e===r&&(e=Qe,t=pr(),t!==r&&(Be=e,t={type:"data-type",location:rt(),value:{type:"time"}}),e=t,e===r&&(e=Qe,t=Or(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=Zt(),a===r?(Qe=e,e=r):(Yr(),i=Zr(),i===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"data-type",location:rt(),value:{type:"varchar",size:parseInt(e)}}}(a)))))))))))),e}function Dt(){let e,t;return e=Qe,t=mr(),t===r&&(t=hr(),t===r&&(t=vr())),t===r&&(t=null),Be=e,t=function(e){return{type:"string",location:rt(),value:e??"BOTH"}}(t),e=t,e}function Mt(){let e,t;return e=Qe,t=xr(),t===r&&(t=Dr(),t===r&&(t=Mr(),t===r&&(t=br(),t===r&&(t=Pr(),t===r&&(t=Ar(),t===r&&(t=Cr(),t===r&&(t=_r(),t===r&&(t=Fr(),t===r&&(t=$r(),t===r&&(t=Rr())))))))))),t!==r&&(Be=e,t=function(e){return{type:"string",location:rt(),value:e}}(t)),e=t,e}function bt(){let t,n,a,i,o;return t=Qe,n=Sr(),n===r?(Qe=t,t=r):(Yr(),a=e.charAt(Qe),l.test(a)?Qe++:(a=r,0===tt&&ut(S)),a===r?(Qe=t,t=r):(Yr(),i=Rt(),i===r?(Qe=t,t=r):(Yr(),o=Pt(),o===r?(Qe=t,t=r):(Be=t,t=function(e,t,r){return{type:"interval",location:rt(),value:t,qualifier:r,op:e}}(a,i,o))))),t===r&&(t=Qe,n=Sr(),n===r?(Qe=t,t=r):(Yr(),a=Rt(),a===r?(Qe=t,t=r):(Yr(),i=Pt(),i===r?(Qe=t,t=r):(Be=t,t=function(e,t){return{type:"interval",location:rt(),value:e,qualifier:t,op:""}}(a,i))))),t}function Pt(){let e,t,n,a;return e=Qe,t=function(){let e,t,n,a,i;return e=Qe,t=At(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=$t(),a===r?(Qe=e,e=r):(Yr(),i=Zr(),i===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"interval-period",location:rt(),period:e.value,precision:t,secondary:null}}(t,a))))),e===r&&(e=Qe,t=At(),t!==r&&(Be=e,t=function(e){return{type:"interval-period",location:rt(),period:e.value,precision:null,secondary:null}}(t)),e=t),e}(),t===r?(Qe=e,e=r):(Yr(),n=Er(),n===r?(Qe=e,e=r):(Yr(),a=function(){let e,t,n,a,i,o,l;return e=Qe,t=At(),t!==r&&(Be=e,t=function(e){return{type:"interval-period",location:rt(),period:e.value,precision:null,secondary:null}}(t)),e=t,e===r&&(e=Qe,t=Ar(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=$t(),a===r?(Qe=e,e=r):(Yr(),i=qr(),i===r?(Qe=e,e=r):(Yr(),o=Ft(),o===r?(Qe=e,e=r):(Yr(),l=Zr(),l===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"interval-period",location:rt(),period:"second",precision:e,secondary:t}}(a,o))))))),e===r&&(e=Qe,t=Ar(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=$t(),a===r?(Qe=e,e=r):(Yr(),i=Zr(),i===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"interval-period",location:rt(),period:"second",precision:e,secondary:null}}(a))))),e===r&&(e=Qe,t=Ar(),t!==r&&(Be=e,t={type:"interval-period",location:rt(),period:"second",precision:null,secondary:null}),e=t))),e}(),a===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"interval-qualifier",location:rt(),start:e,end:t}}(t,a)))),e===r&&(e=function(){let e,t,n,a,i,o,l;return e=Qe,t=At(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=Ft(),a===r?(Qe=e,e=r):(Yr(),i=Zr(),i===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"interval-period",location:rt(),period:e.value,precision:t,secondary:null}}(t,a))))),e===r&&(e=Qe,t=At(),t!==r&&(Be=e,t=function(e){return{type:"interval-period",location:rt(),period:e.value,precision:null,secondary:null}}(t)),e=t,e===r&&(e=Qe,t=Ar(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=$t(),a===r?(Qe=e,e=r):(Yr(),i=qr(),i===r?(Qe=e,e=r):(Yr(),o=Ft(),o===r?(Qe=e,e=r):(Yr(),l=Zr(),l===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"interval-period",location:rt(),period:"second",precision:e,secondary:t}}(a,o))))))),e===r&&(e=Qe,t=Ar(),t===r?(Qe=e,e=r):(Yr(),n=Kr(),n===r?(Qe=e,e=r):(Yr(),a=Ft(),a===r?(Qe=e,e=r):(Yr(),i=Zr(),i===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"interval-period",location:rt(),period:"second",precision:e,secondary:null}}(a))))),e===r&&(e=Qe,t=Ar(),t!==r&&(Be=e,t={type:"interval-period",location:rt(),period:"second",precision:null,secondary:null}),e=t)))),e}()),e}function At(){let e,t;return e=Qe,t=Mr(),t!==r&&(Be=e,t={type:"string",location:rt(),value:"day"}),e=t,e===r&&(e=Qe,t=br(),t!==r&&(Be=e,t={type:"string",location:rt(),value:"hour"}),e=t,e===r&&(e=Qe,t=Pr(),t!==r&&(Be=e,t={type:"string",location:rt(),value:"minute"}),e=t,e===r&&(e=Qe,t=Dr(),t!==r&&(Be=e,t={type:"string",location:rt(),value:"month"}),e=t,e===r&&(e=Qe,t=xr(),t!==r&&(Be=e,t={type:"string",location:rt(),value:"year"}),e=t)))),e}function Ft(){let e,t;return e=Qe,t=Zt(),t!==r&&(Be=e,t=function(e){return parseFloat(e)}(t)),e=t,e}function $t(){let e,t;return e=Qe,t=Zt(),t!==r&&(Be=e,t=function(e){return parseFloat(e)}(t)),e=t,e}function Rt(){let e;return e=Ut(),e===r&&(e=Ct()),e}function Ut(){let t,n,a,i,o;if(t=Qe,39===e.charCodeAt(Qe)?(n="'",Qe++):(n=r,0===tt&&ut(A)),n===r&&("N'"===e.substr(Qe,2)?(n="N'",Qe+=2):(n=r,0===tt&&ut(F))),n!==r){for(a=[],i=Qe,"''"===e.substr(Qe,2)?(o="''",Qe+=2):(o=r,0===tt&&ut($)),o!==r&&(Be=i,o="'"),i=o,i===r&&(i=e.charAt(Qe),p.test(i)?Qe++:(i=r,0===tt&&ut(R)));i!==r;)a.push(i),i=Qe,"''"===e.substr(Qe,2)?(o="''",Qe+=2):(o=r,0===tt&&ut($)),o!==r&&(Be=i,o=We()),i=o,i===r&&(i=e.charAt(Qe),p.test(i)?Qe++:(i=r,0===tt&&ut(R)));39===e.charCodeAt(Qe)?(i="'",Qe++):(i=r,0===tt&&ut(A)),i===r?(Qe=t,t=r):(Be=t,t=function(e){return{type:"string",location:rt(),value:e.join("")}}(a))}else Qe=t,t=r;return t}function kt(){let e,t,n,a,i;return e=Qe,t=Vr(),t===r?(Qe=e,e=r):(Yr(),n=ft(),n===r?(Qe=e,e=r):(Yr(),a=zr(),a===r?(Qe=e,e=r):(Yr(),i=ft(),i===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"when-clause",location:rt(),operand:e,value:t}}(n,i))))),e}function Vt(){let e,t,n,a,i;return e=Qe,t=Vr(),t===r?(Qe=e,e=r):(Yr(),n=ft(),n===r?(Qe=e,e=r):(Yr(),a=zr(),a===r?(Qe=e,e=r):(Yr(),i=ft(),i===r?(Qe=e,e=r):(Be=e,e=function(e,t){return{type:"when-clause",location:rt(),operand:e,value:t}}(n,i))))),e}function zt(){let e,t,n;return e=Qe,t=Hr(),t===r?(Qe=e,e=r):(Yr(),n=ft(),n===r?(Qe=e,e=r):(Be=e,e=function(e){return{type:"else-clause",location:rt(),value:e}}(n))),e}function Ht(){let t,n,a;return t=Zt(),t===r&&(t=Qe,n=e.charAt(Qe),l.test(n)?Qe++:(n=r,0===tt&&ut(S)),n===r?(Qe=t,t=r):(a=Zt(),a===r?(Qe=t,t=r):(Be=t,t=function(e,t){return e[0]+t}(n,a)))),t}function qt(){let t,n,a;return t=Qe,46===e.charCodeAt(Qe)?(n=".",Qe++):(n=r,0===tt&&ut(U)),n===r?(Qe=t,t=r):(a=Zt(),a===r&&(a=null),Be=t,t=function(e){return"."+(e??"")}(a)),t}function Kt(){let e,t,n;return e=Qe,t=jt(),t===r?(Qe=e,e=r):(n=Zt(),n===r?(Qe=e,e=r):(Be=e,e=function(e,t){return e+t}(t,n))),e}function Zt(){let e,t,n;if(e=Qe,t=[],n=Yt(),n!==r)for(;n!==r;)t.push(n),n=Yt();else t=r;return t!==r&&(Be=e,t=function(e){return e.join("")}(t)),e=t,e}function Yt(){let t;return t=e.charAt(Qe),m.test(t)?Qe++:(t=r,0===tt&&ut(k)),t}function jt(){let t,n,a;return t=Qe,n=e.charAt(Qe),h.test(n)?Qe++:(n=r,0===tt&&ut(V)),n===r?(Qe=t,t=r):(a=e.charAt(Qe),l.test(a)?Qe++:(a=r,0===tt&&ut(S)),a===r&&(a=null),Be=t,t=function(e,t){return"e"+(null===t?"":t)}(0,a)),t}function Wt(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"null"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(z)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(n=[n,a],t=n)),t}function Jt(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"true"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(H)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(n=[n,a],t=n)),t}function Qt(){let t,n,a,i;return t=Qe,n=e.substr(Qe,5),"false"===n.toLowerCase()?Qe+=5:(n=r,0===tt&&ut(q)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(n=[n,a],t=n)),t}function Bt(){let t,n,a,i;return t=Qe,n=e.substr(Qe,2),"in"===n.toLowerCase()?Qe+=2:(n=r,0===tt&&ut(K)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="IN")),t}function Gt(){let t,n,a,i;return t=Qe,n=e.substr(Qe,2),"is"===n.toLowerCase()?Qe+=2:(n=r,0===tt&&ut(Z)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="IS")),t}function Xt(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"like"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(Y)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="LIKE")),t}function er(){let t,n,a,i;return t=Qe,n=e.substr(Qe,6),"escape"===n.toLowerCase()?Qe+=6:(n=r,0===tt&&ut(j)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="ESCAPE")),t}function tr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"not"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(W)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="NOT")),t}function rr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"and"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(J)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="AND")),t}function nr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,2),"or"===n.toLowerCase()?Qe+=2:(n=r,0===tt&&ut(Q)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="OR")),t}function ar(){let t,n,a,i;return t=Qe,n=e.substr(Qe,7),"between"===n.toLowerCase()?Qe+=7:(n=r,0===tt&&ut(G)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="BETWEEN")),t}function ir(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"from"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(X)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="FROM")),t}function or(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"for"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(ee)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="FOR")),t}function lr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,9),"substring"===n.toLowerCase()?Qe+=9:(n=r,0===tt&&ut(te)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="SUBSTRING")),t}function ur(){let t,n,a,i;return t=Qe,n=e.substr(Qe,7),"extract"===n.toLowerCase()?Qe+=7:(n=r,0===tt&&ut(re)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="EXTRACT")),t}function sr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"trim"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(ne)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TRIM")),t}function cr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,8),"position"===n.toLowerCase()?Qe+=8:(n=r,0===tt&&ut(ae)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="POSITION")),t}function fr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,9),"timestamp"===n.toLowerCase()?Qe+=9:(n=r,0===tt&&ut(ie)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TIMESTAMP")),t}function dr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"date"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(oe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="DATE")),t}function pr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"time"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(le)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TIME")),t}function mr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,7),"leading"===n.toLowerCase()?Qe+=7:(n=r,0===tt&&ut(ue)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="LEADING")),t}function hr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,8),"trailing"===n.toLowerCase()?Qe+=8:(n=r,0===tt&&ut(se)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TRAILING")),t}function vr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"both"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(ce)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="BOTH")),t}function wr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"cast"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(fe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="CAST")),t}function gr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,2),"as"===n.toLowerCase()?Qe+=2:(n=r,0===tt&&ut(de)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="AS")),t}function Ir(){let t,n,a,i;return t=Qe,n=e.substr(Qe,7),"integer"===n.toLowerCase()?Qe+=7:(n=r,0===tt&&ut(pe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="INTEGER")),t}function yr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"int"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(me)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="INT")),t}function Lr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,8),"smallint"===n.toLowerCase()?Qe+=8:(n=r,0===tt&&ut(he)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="SMALLINT")),t}function Tr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,5),"float"===n.toLowerCase()?Qe+=5:(n=r,0===tt&&ut(ve)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="FLOAT")),t}function Nr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"real"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(we)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="REAL")),t}function Or(){let t,n,a,i;return t=Qe,n=e.substr(Qe,7),"varchar"===n.toLowerCase()?Qe+=7:(n=r,0===tt&&ut(ge)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="VARCHAR")),t}function Er(){let t,n,a,i;return t=Qe,n=e.substr(Qe,2),"to"===n.toLowerCase()?Qe+=2:(n=r,0===tt&&ut(Ie)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TO")),t}function Sr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,8),"interval"===n.toLowerCase()?Qe+=8:(n=r,0===tt&&ut(ye)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="INTERVAL")),t}function xr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"year"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(Le)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="YEAR")),t}function Cr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,13),"timezone_hour"===n.toLowerCase()?Qe+=13:(n=r,0===tt&&ut(Te)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TIMEZONE_HOUR")),t}function _r(){let t,n,a,i;return t=Qe,n=e.substr(Qe,15),"timezone_minute"===n.toLowerCase()?Qe+=15:(n=r,0===tt&&ut(Ne)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="TIMEZONE_MINUTE")),t}function Dr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,5),"month"===n.toLowerCase()?Qe+=5:(n=r,0===tt&&ut(Oe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="MONTH")),t}function Mr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"day"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(Ee)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="DAY")),t}function br(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"hour"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(Se)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="HOUR")),t}function Pr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,6),"minute"===n.toLowerCase()?Qe+=6:(n=r,0===tt&&ut(xe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="MINUTE")),t}function Ar(){let t,n,a,i;return t=Qe,n=e.substr(Qe,6),"second"===n.toLowerCase()?Qe+=6:(n=r,0===tt&&ut(Ce)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="SECOND")),t}function Fr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"dow"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(_e)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="DOW")),t}function $r(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"doy"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(De)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="DOY")),t}function Rr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"week"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(Me)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="WEEK")),t}function Ur(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"case"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(be)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="CASE")),t}function kr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,3),"end"===n.toLowerCase()?Qe+=3:(n=r,0===tt&&ut(Pe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="END")),t}function Vr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"when"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(Ae)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="WHEN")),t}function zr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"then"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut(Fe)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="THEN")),t}function Hr(){let t,n,a,i;return t=Qe,n=e.substr(Qe,4),"else"===n.toLowerCase()?Qe+=4:(n=r,0===tt&&ut($e)),n===r?(Qe=t,t=r):(a=Qe,tt++,i=Ot(),tt--,i===r?a=void 0:(Qe=a,a=r),a===r?(Qe=t,t=r):(Be=t,t="ELSE")),t}function qr(){let t;return 44===e.charCodeAt(Qe)?(t=",",Qe++):(t=r,0===tt&&ut(Re)),t}function Kr(){let t;return 40===e.charCodeAt(Qe)?(t="(",Qe++):(t=r,0===tt&&ut(Ue)),t}function Zr(){let t;return 41===e.charCodeAt(Qe)?(t=")",Qe++):(t=r,0===tt&&ut(ke)),t}function Yr(){let e,t;for(e=[],t=jr();t!==r;)e.push(t),t=jr();return e}function jr(){let t;return t=e.charAt(Qe),v.test(t)?Qe++:(t=r,0===tt&&ut(Ve)),t}function Wr(){let t,n,a,i;if(t=Qe,n=Tt(),n!==r&&(Be=t),t=n,t===r)if(t=Qe,96===e.charCodeAt(Qe)?(n="`",Qe++):(n=r,0===tt&&ut(ze)),n!==r){if(a=[],i=e.charAt(Qe),w.test(i)?Qe++:(i=r,0===tt&&ut(He)),i!==r)for(;i!==r;)a.push(i),i=e.charAt(Qe),w.test(i)?Qe++:(i=r,0===tt&&ut(He));else a=r;a===r?(Qe=t,t=r):(96===e.charCodeAt(Qe)?(i="`",Qe++):(i=r,0===tt&&ut(ze)),i===r?(Qe=t,t=r):(Be=t,t=function(e){return e.join("")}(a)))}else Qe=t,t=r;return t}function Jr(e,t,r,n,a){let i={type:"binary-expression",location:a,operator:e,left:t,right:r};return void 0!==n&&(i.escape=n),i}function Qr(e,...t){return{type:"expression-list",location:e,value:t}}function Br(e,t){let r=e;for(let{op:e,expr:n,location:{end:a}}of t)r=Jr(e,r,n,void 0,{...r.location,end:a});return r}Je=i();let Gr=Je!==r&&Qe===e.length;function Xr(){throw Je!==r&&Qe<e.length&&ut({type:"end"}),function(e,t,r){return new B(B.buildMessage(e,t),e,t,r)}(et,Xe<e.length?function(t=Qe){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(Xe):null,Xe<e.length?lt(Xe,Xe+1):lt(Xe,Xe))}return t.peg$library?{peg$result:Je,peg$currPos:Qe,peg$FAILED:r,peg$maxFailExpected:et,peg$maxFailPos:Xe,peg$success:Gr,peg$throw:Gr?void 0:Xr}:Gr?Je:void Xr()}class X{static parse(e){return G(e)}}var ee=r(56400);const te=new Set(["current_timestamp","current_date","current_time"]);class re{constructor(e){this.staticData=e}makeBool(e){return me(e)}featureValue(e,t,r,n){return Se(e,t,r,n)}equalsNull(e){return null===e}applyLike(e,t,r){return Oe(e,t,r)}ensureArray(e){return he(e)}applyIn(e,t){return Ie(e,t)}currentTimestamp(e){return ye(e)}currentDate(e){return Le(e)}currentTime(e){return Te(e)}makeSqlInterval(e,t,r){return f.createFromValueAndQualifier(e,t,r)}convertInterval(e){return f.isInterval(e)?e.valueInMilliseconds():e}compare(e,t,r){return k(t,r,e)}calculate(e,t,r,n){return W(e,t,r,n)}evaluateTime(e){return D(e)}evaluateTimestamp(e,t){return M(e,t)}evaluateDate(e,t){return b(e,t)}evaluateFunction(e,t,r){return q(e,t,r)}lookup(e,t){let r=t[e];return void 0===r?null:r}between(e,t){return null==e||null==t[0]||null==t[1]?null:k(e,t[0],">=")&&k(e,t[1],"<=")}notbetween(e,t){return null==e||null==t[0]||null==t[1]?null:k(e,t[0],"<")||k(e,t[1],">")}ternaryNot(e){return ve(e)}ternaryAnd(e,t){return we(e,t)}ternaryOr(e,t){return ge(e,t)}}function ne(e,...t){return`this.${e}(${t.join(", ")})`}function ae(e){return void 0===e?"void 0":JSON.stringify(e)}function ie({type:e,period:t,precision:r,secondary:n}){return JSON.stringify({type:e,period:t,precision:r,secondary:n})}const oe="feature",le="lookups",ue="attributeAdapter",se="fieldsIndex",ce="timeZone",fe="currentUser";class de{constructor(e,t){this._parseTree=e,this._fieldsIndex=t,this._staticData=Object.create(null),this._nextStaticDataId=0,this._tempVars=new Set,this._nextTempVarId=0}compile(){let e=this._compileNode(this._parseTree),t=`\n ${this._tempVars.size>0?`var ${Array.from(this._tempVars).join(", ")};`:""}\n return this.convertInterval(${e});\n `;return Function(oe,le,ue,se,ce,fe,t).bind(new re(this._staticData))}_storeStaticData(e){let t="static$"+this._nextStaticDataId++;return this._staticData[t]=e,t}_compileRefStaticData(e){return`this.staticData[${ae(e)}]`}_generateTempVar(){let e="temp$"+this._nextTempVarId++;return this._tempVars.add(e),e}_compileSimpleCase(e){let t=this._compileNode(e.operand),r=this._generateTempVar(),n=[];for(let t of e.clauses){let e=ne("compare",ae("="),r,this._compileNode(t.operand)),a=this._compileNode(t.value);n.push(`${e} ? (${a}) :`)}return null==e.else?n.push(ae(null)):n.push(this._compileNode(e.else)),`(${r} = ${t}, ${n.join(" ")})`}_compileSearchedCase(e){let t=[];for(let r of e.clauses){let e=ne("makeBool",this._compileNode(r.operand)),n=this._compileNode(r.value);t.push(`${e} ? (${n}) :`)}return null==e.else?t.push(ae(null)):t.push(this._compileNode(e.else)),t.join(" ")}_compileInExpr(e,t){let r=new Set,n=[];for(let e of t.value)"number"===e.type||"string"===e.type?r.add(e.value):n.push(e);let a=this._compileNode(e),i=ne("ensureArray",this._compileNode({type:"expression-list",location:t.location,value:n}));if(r.size>0){let e=this._compileRefStaticData(this._storeStaticData(r)),t=this._generateTempVar();return n.length>0?`(${t} = ${a}, ${e}.has(${t}) || ${ne("applyIn",t,i)})`:`(${t} = ${a}, ${t} == null ? null : ${e}.has(${t}))`}return ne("applyIn",a,i)}_compileNode(e){switch(e.type){case"interval":return ne("makeSqlInterval",this._compileNode(e.value),"interval-qualifier"===e.qualifier.type?function({type:e,start:t,end:r}){return`{type: ${ae(e)}, start: ${ie(t)}, end: ${ie(r)}}`}(e.qualifier):ie(e.qualifier),ae(e.op));case"case-expression":return"simple"===e.format?this._compileSimpleCase(e):this._compileSearchedCase(e);case"parameter":return ne("lookup",ae(e.value.toLowerCase()),le);case"expression-list":return`[${e.value.map(e=>this._compileNode(e)).join(", ")}]`;case"unary-expression":return ne("ternaryNot",this._compileNode(e.expr));case"binary-expression":switch(e.operator){case"AND":return ne("ternaryAnd",this._compileNode(e.left),this._compileNode(e.right));case"OR":return ne("ternaryOr",this._compileNode(e.left),this._compileNode(e.right));case"IS":if("null"!==e.right.type)throw new l.L("UnsupportedIsRhs");return ne("equalsNull",this._compileNode(e.left));case"ISNOT":if("null"!==e.right.type)throw new l.L("UnsupportedIsRhs");return`!${ne("equalsNull",this._compileNode(e.left))}`;case"IN":return this._compileInExpr(e.left,e.right);case"NOT IN":return ne("ternaryNot",this._compileInExpr(e.left,e.right));case"BETWEEN":return ne("between",this._compileNode(e.left),this._compileNode(e.right));case"NOTBETWEEN":return ne("notbetween",this._compileNode(e.left),this._compileNode(e.right));case"LIKE":return ne("applyLike",this._compileNode(e.left),this._compileNode(e.right),ae(e.escape));case"NOT LIKE":return ne("ternaryNot",ne("applyLike",this._compileNode(e.left),this._compileNode(e.right),ae(e.escape)));case"<>":case"<":case">":case">=":case"<=":case"=":if(Ee(e,e.operator,this._fieldsIndex)){let t=e.comparisonData;return ne("compare",ae(t.op),ne("featureValue",oe,ae(t.fieldName),ae(null),ue),this._compileRefStaticData(this._storeStaticData(t.comparisonEpochMs)))}return ne("compare",ae(e.operator),this._compileNode(e.left),this._compileNode(e.right));case"*":case"-":case"+":case"/":case"||":return ne("calculate",ae(e.operator),this._compileNode(e.left),this._compileNode(e.right),ce);default:throw new l.L("UnsupportedOperator",{operator:e.operator})}case"null":case"boolean":case"string":case"number":return ae(e.value);case"time":try{return this._compileRefStaticData(this._storeStaticData(D(e.value)))}catch{return ne("evaluateTime",ae(e.value))}case"date":try{return this._compileRefStaticData(this._storeStaticData(b(e.value,"unknown")))}catch{return ne("evaluateDate",ae(e.value),ae("unknown"))}case"timestamp":try{return this._compileRefStaticData(this._storeStaticData(M(e.value,"unknown")))}catch{return ne("evaluateTimestamp",ae(e.value),ae("unknown"))}case"current-time":return"date"===e.mode?ne("currentDate",ce):"time"===e.mode?ne("currentTime",ce):ne("currentTimestamp",ce);case"current-user":return fe;case"column-reference":return ne("featureValue",oe,ae(e.column),se,ue);case"data-type":return function({type:e,size:t,withtimezone:r}){return JSON.stringify({type:e,size:t,withtimezone:r})}(e.value);case"function":return ne("evaluateFunction",ae(e.name),this._compileNode(e.args),ce)}throw new l.L("UnsupportedSyntax",{node:e.type})}}class pe{static create(e,t={}){return new pe(e,t.fieldsIndex,t.timeZone??void 0,t.currentUser)}constructor(e,t,r="UTC",n=null){this.fieldsIndex=t,this.timeZone=r,this.currentUser=n,this.parameters={},this._compiledExecutor=null,this._hasDateFunctions=void 0,this.parseTree=X.parse(e);let{isStandardized:a,isAggregate:i,currentUserRequired:o,referencedFieldNames:l}=this._extractExpressionInfo(t);this._referencedFieldNames=l,this.isStandardized=a,this.isAggregate=i,this.currentUserRequired=o}static convertValueToStorageFormat(e,t=null){if(null===t)return(0,F.$P)(e)?e.getTime():S(e)?e.toMillis():_(e)?e.toStorageFormat():C(e)?e.toStorageString():x(e)?e.toStorageFormat():e;switch(t){case"date":return(0,F.$P)(e)?e.getTime():S(e)?e.toMillis():_(e)?e.toMilliseconds():x(e)?e.toNumber():e;case"date-only":return(0,F.$P)(e)?o.n.fromDateJS(e).toString():_(e)?o.n.fromSqlTimeStampOffset(e).toString():S(e)?o.n.fromDateTime(e).toString():e;case"time-only":return(0,F.$P)(e)?p.k.fromDateJS(e).toStorageString():S(e)?p.k.fromDateTime(e).toStorageString():_(e)?p.k.fromSqlTimeStampOffset(e).toStorageString():C(e)?e.toStorageString():e;case"timestamp-offset":if((0,F.$P)(e))return d.g.fromJSDate(e).toStorageFormat();if(S(e))return d.g.fromDateTime(e).toStorageFormat();if(_(e))return e.toStorageFormat()}return e}get fieldNames(){return this._referencedFieldNames}testSet(e,t=xe,r=this.currentUser){return!!this._evaluateNode(this.parseTree,null,t,e,r)}calculateValue(e,t=xe,r=this.currentUser){let n=this._evaluateNode(this.parseTree,e,t,null,r);return f.isInterval(n)?n.valueInMilliseconds()/864e5:n}tryGetCompiledExecutor(){if(null!=this._compiledExecutor)return this._compiledExecutor;if((0,n.A)("esri-csp-restrictions"))return null;let e=new de(this.parseTree,this.fieldsIndex);return this._compiledExecutor=e.compile(),this._compiledExecutor}calculateValueCompiled(e,t=xe,r=this.currentUser){let n=this.tryGetCompiledExecutor();return null==n?this.calculateValue(e,t):n(e,this.parameters,t,this.fieldsIndex,this.timeZone,r??null)}testFeature(e,t=xe,r=this.currentUser){return!!this._evaluateNode(this.parseTree,e,t,null,r)}testFeatureCompiled(e,t=xe,r=this.currentUser){let n=this.tryGetCompiledExecutor();return null==n?this.testFeature(e,t):!!n(e,this.parameters,t,this.fieldsIndex,this.timeZone,r??null)}get hasDateFunctions(){return this._hasDateFunctions??=(0,a.zN)(Q(this.parseTree),e=>"current-time"===e.type||"function"===e.type&&te.has(e.name.toLowerCase())),this._hasDateFunctions}getFunctions(){let e=new Set;for(let t of Q(this.parseTree))"function"===t.type&&e.add(t.name.toLowerCase());return Array.from(e)}getExpressions(){let e=new Map;for(let t of Q(this.parseTree))if("function"===t.type){let r=t.name.toLowerCase(),n=t.args.value[0];if("column-reference"===n.type){let t=n.column,a=`${r}-${t}`;e.has(a)||e.set(a,{aggregateType:r,field:t})}}return Array.from(e.values())}getVariables(){let e=new Set;for(let t of Q(this.parseTree))"parameter"===t.type&&e.add(t.value.toLowerCase());return Array.from(e)}_extractExpressionInfo(e){let t=[],r=new Set,n=!0,a=!1,o=!1;for(let l of Q(this.parseTree))switch(l.type){case"column-reference":{let n,a,i=e?.get(l.column);i?n=a=i.name??"":(a=l.column,n=a.toLowerCase()),r.has(n)||(r.add(n),t.push(a)),l.column=a;break}case"current-user":o=!0;break;case"function":{let{name:e,args:t}=l,r=t.value.length;n&&=K(e,r),!1===a&&(a=(0,i.M)(e,r));break}}return{referencedFieldNames:Array.from(t),isStandardized:n,isAggregate:a,currentUserRequired:o}}_evaluateNode(e,t,r,n,a){let o;switch(e.type){case"interval":{let i=this._evaluateNode(e.value,t,r,n,a);return f.createFromValueAndQualifier(i,e.qualifier,e.op)}case"case-expression":if("simple"===e.format){let i=this._evaluateNode(e.operand,t,r,n,a);for(let o=0;o<e.clauses.length;o++)if(k(i,this._evaluateNode(e.clauses[o].operand,t,r,n,a),"="))return this._evaluateNode(e.clauses[o].value,t,r,n,a);if(null!==e.else)return this._evaluateNode(e.else,t,r,n,a)}else{for(let i=0;i<e.clauses.length;i++)if(me(this._evaluateNode(e.clauses[i].operand,t,r,n,a)))return this._evaluateNode(e.clauses[i].value,t,r,n,a);if(null!==e.else)return this._evaluateNode(e.else,t,r,n,a)}return null;case"parameter":return o=this.parameters[e.value.toLowerCase()],(0,F.$P)(o)?h.c9.fromJSDate(o):"object"==typeof o&&o&&"toDateTime"in o?o.toDateTime():o;case"expression-list":{let i=[];for(let o of e.value)i.push(this._evaluateNode(o,t,r,n,a));return i}case"unary-expression":return ve(this._evaluateNode(e.expr,t,r,n,a));case"binary-expression":switch(e.operator){case"AND":return we(this._evaluateNode(e.left,t,r,n,a),this._evaluateNode(e.right,t,r,n,a));case"OR":return ge(this._evaluateNode(e.left,t,r,n,a),this._evaluateNode(e.right,t,r,n,a));case"IS":if("null"!==e.right.type)throw new l.L("UnsupportedIsRhs");return null===this._evaluateNode(e.left,t,r,n,a);case"ISNOT":if("null"!==e.right.type)throw new l.L("UnsupportedIsRhs");return null!==this._evaluateNode(e.left,t,r,n,a);case"IN":{let i=he(this._evaluateNode(e.right,t,r,n,a));return Ie(this._evaluateNode(e.left,t,r,n,a),i)}case"NOT IN":{let i=he(this._evaluateNode(e.right,t,r,n,a));return ve(Ie(this._evaluateNode(e.left,t,r,n,a),i))}case"BETWEEN":{let i=this._evaluateNode(e.left,t,r,n,a),o=this._evaluateNode(e.right,t,r,n,a);return null==i||null==o[0]||null==o[1]?null:k(i,o[0],">=")&&k(i,o[1],"<=")}case"NOTBETWEEN":{let i=this._evaluateNode(e.left,t,r,n,a),o=this._evaluateNode(e.right,t,r,n,a);return null==i||null==o[0]||null==o[1]?null:k(i,o[0],"<")||k(i,o[1],">")}case"LIKE":return Oe(this._evaluateNode(e.left,t,r,n,a),this._evaluateNode(e.right,t,r,n,a),e.escape);case"NOT LIKE":return ve(Oe(this._evaluateNode(e.left,t,r,n,a),this._evaluateNode(e.right,t,r,n,a),e.escape));case"<>":case"<":case">":case">=":case"<=":case"=":if(Ee(e,e.operator,this.fieldsIndex)){let n=e.comparisonData;return k(Se(t,n.fieldName,null,r),n.comparisonEpochMs,n.op)}return k(this._evaluateNode(e.left,t,r,n,a),this._evaluateNode(e.right,t,r,n,a),e.operator);case"-":case"+":case"*":case"/":case"||":return W(e.operator,this._evaluateNode(e.left,t,r,n,a),this._evaluateNode(e.right,t,r,n,a),this.timeZone)}case"null":case"boolean":case"string":case"number":return e.value;case"date":return e.parsedValue??=b(e.value,"unknown"),e.parsedValue;case"timestamp":return e.parsedValue??=M(e.value,"unknown"),e.parsedValue;case"time":return e.parsedValue??=D(e.value),e.parsedValue;case"current-time":return"date"===e.mode?Le(this.timeZone):"time"===e.mode?Te(this.timeZone):ye(this.timeZone);case"current-user":return a??null;case"column-reference":return Se(t,e.column,this.fieldsIndex,r);case"data-type":return e.value;case"function":{if(this.isAggregate&&(0,i.M)(e.name,e.args.value.length)){let t=[];for(let i of e.args?.value||[]){let e=[];for(let t of n||[])e.push(this._evaluateNode(i,t,r,null,a));t.push(e)}return(0,i.s)(e.name,t)}let o=this._evaluateNode(e.args,t,r,n,a);return q(e.name,o,this.timeZone)}}throw new l.L("UnsupportedSyntax",{node:e.type})}}function me(e){return!0===e}function he(e){return Array.isArray(e)?e:[e]}function ve(e){return null===e?null:!0!==e}function we(e,t){return null!=e&&null!=t?!0===e&&!0===t:!1!==e&&!1!==t&&null}function ge(e,t){return null!=e&&null!=t?!0===e||!0===t:!0===e||!0===t||null}function Ie(e,t){if(null==e)return null;let r=!1;for(let n of t)if(null==n)r=null;else{if(e===n){r=!0;break}if(R(e)&&R(n)&&(r=k(e,n,"="),r))break}return r}function ye(e){return O(new Date,e)}function Le(e){return o.n.fromNow(e)}function Te(e){let t=O(new Date,e);return p.k.fromDateTime(t)}const Ne="-[]/{}()*+?.\\^$|";function Oe(e,t,r){return null==e?null:function(e,t){let r=t,n="",a=0;for(let t=0;t<e.length;t++){let i=e.charAt(t);switch(a){case 0:i===r?a=1:Ne.includes(i)?n+="\\"+i:n+="%"===i?".*":"_"===i?".":i;break;case 1:Ne.includes(i)?n+="\\"+i:n+=i,a=0}}return RegExp("^"+n+"$","m")}(t,r).test(e)}function Ee(e,t,r){if("comparisonData"in e)return null!=e.comparisonData;try{if(null==r)return!1;let n,a;if("column-reference"===e.left.type&&"timestamp"===e.right.type)n=e.left,a=e.right;else{if("timestamp"!==e.left.type||"column-reference"!==e.right.type)return!1;n=e.right,a=e.left,t=function(e){switch(e){case"<>":case"=":return e;case"<":return">";case">":return"<";case"<=":return">=";case">=":return"<=";default:throw new l.L("UnsupportedOperator",{operator:e})}}(t)}let i=r.get(n.column);if("esriFieldTypeDate"!==i?.type&&"date"!==i?.type)return!1;let o=r.getTimeZone(i.name),u=null==o?h.mQ.utcInstance:(0,ee.S3)(o);return!!u.isUniversal&&(e.comparisonData=function(e,t,r,n){let a,i=M(n,t);if(d.g.isTimestampOffset(i))if((0,m.Y4)(t)){let e=i.toDateTime();a=h.c9.fromObject({year:e.year,month:e.month,day:e.day,hour:e.hour,minute:e.minute,second:e.second,millisecond:e.millisecond},{zone:t}).toMillis()}else a=i.toMilliseconds();else a=i.toMillis();return{fieldName:e,op:r,comparisonEpochMs:a}}(i.name,u,t,a.value),!0)}finally{"comparisonData"in e||(e.comparisonData=null)}}function Se(e,t,r,n){if("getAttributeSQL"in n)return n.getAttributeSQL(e,t);let a=n.getAttribute(e,t);if(null==a)return a;let i=r?.get(t);switch(i?.type){case"esriFieldTypeDate":case"date":{let e=r?.getTimeZone(i.name);return O(new Date(a),null==e?h.mQ.utcInstance:(0,ee.S3)(e))}case"esriFieldTypeDateOnly":case"date-only":return o.n.fromReader(a);case"esriFieldTypeTimeOnly":case"time-only":return p.k.fromReader(a);case"esriFieldTypeTimestampOffset":case"timestamp-offset":return new d.g(a)}return a}const xe={getAttribute:(e,t)=>(function(e){return e&&"object"==typeof e.attributes}(e)?e.attributes:e)[t]}},1262(e,t,r){r.d(t,{L:()=>i});var n=r(799);const a={InvalidValueForAggregateFunction:"Invalid value used in aggregate function",MissingStatisticParameters:"Statistic does not have 1 or 0 Parameters",InvalidFunctionParameters:"Invalid parameters for call to {function}",UnsupportedIsLhs:"Unsupported left hand expression in is statement",UnsupportedIsRhs:"Unsupported right hand expression in is statement",UnsupportedOperator:"Unsupported operator - {operator}",UnsupportedSyntax:"Unsupported syntax - {node}",UnsupportedSqlFunction:"Sql function not found = {function}",InvalidDataType:"Invalid sql data type",InvalidDate:"Invalid date encountered",InvalidOperator:"Invalid operator encountered",InvalidTime:"Invalid time encountered",IllegalInterval:"Illegal interval",FunctionNotRecognized:"Function not recognized",InvalidTimeStamp:"Invalid timestamp encountered",InvalidParameterCount:"Invalid parameter count for call to {name}",PrimarySecondaryQualifiers:"Primary and Secondary SqlInterval qualifiers not supported",YearMonthIntervals:"Year-Month Intervals not supported",CannotCastValue:"Cannot cast value to the required data type"};class i extends Error{constructor(e,t){super((0,n.HC)(a[e],t)),this.declaredRootClass="esri.arcade.featureset.support.sqlerror",Error.captureStackTrace&&Error.captureStackTrace(this,i)}}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7087],{34727(e,t,n){n.d(t,{$8:()=>V,Cc:()=>l,Hx:()=>k,Io:()=>b,KJ:()=>f,OS:()=>D,Sp:()=>h,XM:()=>m,YN:()=>c,ZH:()=>g,b6:()=>B,cU:()=>a,gg:()=>d,hs:()=>o,kU:()=>u,mP:()=>s,or:()=>U,pF:()=>P,qE:()=>r});const i=new Float32Array(1);function a(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}function r(e,t,n){return Math.min(Math.max(e,t),n)}function s(e,t){return 0===t?0:Math.ceil(e/t)*t}function l(e,t,n){return e+(t-e)*n}function o(e,t,n,i,a){return l(i,a,(e-t)/(n-t))}function u(e){return e*Math.PI/180}function f(e){return 180*e/Math.PI}function m(e){return Math.acos(r(e,-1,1))}function c(e){return Math.asin(r(e,-1,1))}function h(e,t,n=1e-6){return e===t||!(!Number.isFinite(e)||!Number.isFinite(t))&&(e>t?e-t:t-e)<=n}function d(e,t,n=1e-6){return!h(e,t,n)&&e>t}function g(e,t,n=1e-6){return!h(e,t,n)&&e<t}function k(e,t,n=1e-6){return h(e,t,n)||e>t}const x=new DataView(new ArrayBuffer(Float64Array.BYTES_PER_ELEMENT));function p(e){return x.setFloat64(0,e),x.getBigInt64(0)}const w=1000000n,M=y(1);function y(e){let t=p(e=Math.abs(e)),n=function(e){return x.setBigInt64(0,e),x.getFloat64(0)}(t<=w?w:t-w);return Math.abs(e-n)}function b(e,t,n=M){if(e===t)return!0;if(!Number.isFinite(e)||!Number.isFinite(t))return!1;if(null!=n&&y(Math.min(Math.abs(e),Math.abs(t)))<n)return Math.abs(e-t)<=n;let i=p(e),a=p(t);return!(i<0!=a<0||(i<a?a-i:i-a)>w)}function B(e,t,n=1e-6){if(e===t)return!0;if(!Number.isFinite(e)||!Number.isFinite(t))return!1;let i=Math.abs(e-t),a=Math.abs(e),r=Math.abs(t);if(0===e||0===t||a<1e-12&&r<1e-12){if(i>.01*n)return!1}else if(i/(a+r)>n)return!1;return!0}function V(e){return v(Math.max(-I,Math.min(e,I)))}function v(e){return i[0]=e,i[0]}function U(e){let t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[3]*e[3]+e[4]*e[4]+e[5]*e[5],i=e[6]*e[6]+e[7]*e[7]+e[8]*e[8];return!(h(t,1)&&h(n,1)&&h(i,1))}function D(e,t){return(e%t+t)%t}const I=v(34028234663852886e22);function P(e,t,n){if(void 0===n||0==+n)return Math[e](t);if(t=+t,n=+n,isNaN(t)||"number"!=typeof n||n%1!=0)return NaN;let i=t.toString().split("e");return i=(t=Math[e](+(i[0]+"e"+(i[1]?+i[1]-n:-n)))).toString().split("e"),+(i[0]+"e"+(i[1]?+i[1]+n:n))}n.d(t,["pq",0,I])},57087(e,t,n){n.r(t),n.d(t,{default:()=>c});var i=n(34727),a={};a.defaultNoDataValue=(0,i.$8)(-1/0),a.decode=function(e,t){t||={};var n=t.encodedMaskData||null===t.encodedMaskData,u=o(e,t.inputOffset||0,n),f=null==t.noDataValue?a.defaultNoDataValue:(0,i.$8)(t.noDataValue),m=r(u,t.pixelType||Float32Array,t.encodedMaskData,f,t.returnMask),c={width:u.width,height:u.height,pixelData:m.resultPixels,minValue:u.pixels.minValue,maxValue:u.pixels.maxValue,noDataValue:f};return m.resultMask&&(c.maskData=m.resultMask),t.returnEncodedMask&&u.mask&&(c.encodedMaskData=u.mask.bitset?u.mask.bitset:null),t.returnFileInfo&&(c.fileInfo=s(u,f),t.computeUsedBitDepths&&(c.fileInfo.bitDepths=l(u))),c};var r=function(e,t,n,i,a){var r=0,s=e.pixels.numBlocksX,l=e.pixels.numBlocksY,o=Math.floor(e.width/s),f=Math.floor(e.height/l),m=2*e.maxZError;n||=e.mask?e.mask.bitset:null;var c,h=new t(e.width*e.height);a&&n&&(c=new Uint8Array(e.width*e.height));for(var d,g,k=new Float32Array(o*f),x=0;x<=l;x++){var p=x===l?e.height%l:f;if(0!==p)for(var w=0;w<=s;w++){var M=w===s?e.width%s:o;if(0!==M){var y,b,B,V,v=x*e.width*f+w*o,U=e.width-M,D=e.pixels.blocks[r];if(D.encoding<2?(0===D.encoding?y=D.rawData:(u(D.stuffedData,D.bitsPerPixel,D.numValidPixels,D.offset,m,k,e.pixels.maxValue),y=k),b=0):B=2===D.encoding?0:D.offset,n)for(g=0;g<p;g++){for(7&v&&(V=n[v>>3],V<<=7&v),d=0;d<M;d++)7&v||(V=n[v>>3]),128&V?(c&&(c[v]=1),h[v++]=D.encoding<2?y[b++]:B):(c&&(c[v]=0),h[v++]=i),V<<=1;v+=U}else if(D.encoding<2)for(g=0;g<p;g++){for(d=0;d<M;d++)h[v++]=y[b++];v+=U}else for(g=0;g<p;g++)if(h.fill)h.fill(B,v,v+M),v+=M+U;else{for(d=0;d<M;d++)h[v++]=B;v+=U}if(1===D.encoding&&b!==D.numValidPixels)throw"Block and Mask do not match";r++}}}return{resultPixels:h,resultMask:c}},s=function(e,t){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,minValue:e.pixels.minValue,noDataValue:t}}},l=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,n={},i=0;i<t;i++){var a=e.pixels.blocks[i];0===a.encoding?n.float32=!0:1===a.encoding?n[a.bitsPerPixel]=!0:n[0]=!0}return Object.keys(n)},o=function(e,t,n){var i={},a=new Uint8Array(e,t,10);if(i.fileIdentifierString=String.fromCharCode.apply(null,a),"CntZImage"!=i.fileIdentifierString.trim())throw"Unexpected file identifier string: "+i.fileIdentifierString;t+=10;var r=new DataView(e,t,24);if(i.fileVersion=r.getInt32(0,!0),i.imageType=r.getInt32(4,!0),i.height=r.getUint32(8,!0),i.width=r.getUint32(12,!0),i.maxZError=r.getFloat64(16,!0),t+=24,!n)if(r=new DataView(e,t,16),i.mask={},i.mask.numBlocksY=r.getUint32(0,!0),i.mask.numBlocksX=r.getUint32(4,!0),i.mask.numBytes=r.getUint32(8,!0),i.mask.maxValue=r.getFloat32(12,!0),t+=16,i.mask.numBytes>0){var s=new Uint8Array(Math.ceil(i.width*i.height/8)),l=(r=new DataView(e,t,i.mask.numBytes)).getInt16(0,!0),o=2,u=0;do{if(l>0)for(;l--;)s[u++]=r.getUint8(o++);else{var f=r.getUint8(o++);for(l=-l;l--;)s[u++]=f}l=r.getInt16(o,!0),o+=2}while(o<i.mask.numBytes);if(-32768!==l||u<s.length)throw"Unexpected end of mask RLE encoding";i.mask.bitset=s,t+=i.mask.numBytes}else 0===(i.mask.numBytes|i.mask.numBlocksY|i.mask.maxValue)&&(s=new Uint8Array(Math.ceil(i.width*i.height/8)),i.mask.bitset=s);r=new DataView(e,t,16),i.pixels={},i.pixels.numBlocksY=r.getUint32(0,!0),i.pixels.numBlocksX=r.getUint32(4,!0),i.pixels.numBytes=r.getUint32(8,!0),i.pixels.maxValue=r.getFloat32(12,!0),t+=16;var m=i.pixels.numBlocksX,c=i.pixels.numBlocksY,h=m+ +(i.width%m>0),d=c+ +(i.height%c>0);i.pixels.blocks=Array(h*d);for(var g=1e9,k=0,x=0;x<d;x++)for(var p=0;p<h;p++){var w=0,M=e.byteLength-t;r=new DataView(e,t,Math.min(10,M));var y={};i.pixels.blocks[k++]=y;var b=r.getUint8(0);if(w++,y.encoding=63&b,y.encoding>3)throw"Invalid block encoding ("+y.encoding+")";if(2===y.encoding)t++,g=Math.min(g,0);else{if(0!==b&&2!==b){if(b>>=6,y.offsetType=b,2===b)y.offset=r.getInt8(1),w++;else if(1===b)y.offset=r.getInt16(1,!0),w+=2;else{if(0!==b)throw"Invalid block offset type";y.offset=r.getFloat32(1,!0),w+=4}if(g=Math.min(y.offset,g),1===y.encoding)if(b=r.getUint8(w),w++,y.bitsPerPixel=63&b,b>>=6,y.numValidPixelsType=b,2===b)y.numValidPixels=r.getUint8(w),w++;else if(1===b)y.numValidPixels=r.getUint16(w,!0),w+=2;else{if(0!==b)throw"Invalid valid pixel count type";y.numValidPixels=r.getUint32(w,!0),w+=4}}var B;if(t+=w,3!=y.encoding)if(0===y.encoding){var V=(i.pixels.numBytes-1)/4;if(V!==Math.floor(V))throw"uncompressed block has invalid length";B=new ArrayBuffer(4*V),new Uint8Array(B).set(new Uint8Array(e,t,4*V));for(var v=new Float32Array(B),U=0;U<v.length;U++)g=Math.min(g,v[U]);y.rawData=v,t+=4*V}else if(1===y.encoding){var D=Math.ceil(y.numValidPixels*y.bitsPerPixel/8),I=Math.ceil(D/4);B=new ArrayBuffer(4*I),new Uint8Array(B).set(new Uint8Array(e,t,D)),y.stuffedData=new Uint32Array(B),t+=D}}}return i.pixels.minValue=g,i.eofOffset=t,i},u=function(e,t,n,i,a,r,s){var l,o,u,f=(1<<t)-1,m=0,c=0,h=Math.ceil((s-i)/a),d=4*e.length-Math.ceil(t*n/8);for(e[e.length-1]<<=8*d,l=0;l<n;l++){if(0===c&&(u=e[m++],c=32),c>=t)o=u>>>c-t&f,c-=t;else{var g=t-c;o=(u&f)<<g&f,o+=(u=e[m++])>>>(c=32-g)}r[l]=o<h?i+o*a:s}return r};const f=a.decode;class m{_decode(e){let t=f(e.buffer,e.options);return Promise.resolve({result:t,transferList:[t.pixelData.buffer]})}}function c(){return new m}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8732,8768],{35982(e,t,i){i.d(t,{B:()=>c});var l=i(4576),r=i(71511),s=i(36563),a=i(53966),o=i(97768),n=i(17676),h=i(83027);class c{constructor(e,t,i,l,r={}){this._mainMethod=t,this._transferLists=i,this._listeners=[],this._onClientConnectedHandle=null,this._destroyed=!1,this._promise=(0,h.h)(e,{...r,schedule:l}).then(e=>{null!=this._thread||this._destroyed?e.close():(this._thread=e,this._promise=null,this._onClientConnectedHandle=this._thread.onClientConnected(e=>{r.hasInitialize&&e.invoke("initialize",{}).catch(()=>{});for(let t of this._listeners)this._connectListenerToClient(t,e);this._onClientConnected(e)}))}),this._promise.catch(t=>a.A.getLogger("esri.core.workers.WorkerHandle").error(`Failed to initialize ${e} worker: ${t}`))}on(e,t){let i=new u(e,t);return this._listeners.push(i),this._connectListener(i),(0,s.hA)(()=>{(0,l.TF)(this._listeners,i),i.destroy()})}[Symbol.dispose](){this.destroy()}destroy(){this._onClientConnectedHandle=(0,o.xt)(this._onClientConnectedHandle),this._thread&&=(this._thread.close(),null),this._promise=null;for(let e of this._listeners)e.destroy();this._listeners.length=0,this._transferLists={},this._destroyed=!0}invoke(e,t,i){return this.invokeMethod(this._mainMethod,e,t,i)}invokeMethod(e,t,i,l){if(this._thread){let r=this._transferLists[e],s=r?r(t):[];return this._thread.invoke(e,t,{transferList:s,signal:i,jobPriority:l})}return this._promise?this._promise.then(()=>((0,n.Te)(i),this.invokeMethod(e,t,i))):Promise.reject((0,n.NK)())}broadcast(e,t){return this._thread?Promise.all(this._thread.broadcast(t,e)).then(p):this._promise?this._promise.then(()=>this.broadcast(e,t)):Promise.reject((0,n.NK)())}get promise(){return this._promise}_onClientConnected(e){}_connectListener(e){this._thread&&e.add(this._thread.on(e.eventName,e.callback))}_connectListenerToClient(e,t){e.add(t.on(e.eventName,e.callback))}}class u{constructor(e,t){this.eventName=e,this.callback=t,this._handles=new r.A}add(e){this._handles.add(e)}destroy(){this._handles.destroy()}}function p(){}},54239(e,t,i){i.d(t,{A:()=>y});var l,r=i(32198),s=i(4576),a=i(66552),o=i(25482),n=i(86211),h=i(67076),c=i(91429),u=i(97348),p=i(43937),d=i(36005);const g=(0,a.O)()({orthometric:"gravity-related-height",gravity_related_height:"gravity-related-height",ellipsoidal:"ellipsoidal"}),f=g.jsonValues.slice();(0,s.Xy)(f,"orthometric");const v=(0,a.O)()({meter:"meters",foot:"feet","us-foot":"us-feet","clarke-foot":"clarke-feet","clarke-yard":"clarke-yards","clarke-link":"clarke-links","sears-yard":"sears-yards","sears-foot":"sears-feet","sears-chain":"sears-chains","benoit-1895-b-chain":"benoit-1895-b-chains","indian-yard":"indian-yards","indian-1937-yard":"indian-1937-yards","gold-coast-foot":"gold-coast-feet","sears-1922-truncated-chain":"sears-1922-truncated-chains","50-kilometers":"50-kilometers","150-kilometers":"150-kilometers"});let y=l=class extends o.o{constructor(e){super(e),this.origin=0,this.associatedSpatialReference=null,this.heightModel="gravity-related-height",this.heightUnit="meters",this.vertCRS=null}read(e,t){super.read(e,t),("service"===t?.origin||"web-scene"===t?.origin)&&(this.origin="service"===t.origin?2:1,this.associatedSpatialReference=null)}writeHeightModel(e,t,i){return g.write(e,t,i)}readHeightModel(e,t,i){return g.read(e)||(i?.messages&&i.messages.push(function(e,t){return new h.A("height-model:unsupported",`Height model of value '${e}' is not supported`,t)}(e,{context:i})),null)}readHeightUnit(e,t,i){return v.read(e)||(i?.messages&&i.messages.push(m(e,{context:i})),null)}readHeightUnitService(e,t,i){return(0,n.LA)(e)||v.read(e)||(i?.messages&&i.messages.push(m(e,{context:i})),null)}readVertCRS(e,t){return t.vertCRS||t.ellipsoid||t.geoid}clone(){return new l({heightModel:this.heightModel,heightUnit:this.heightUnit,vertCRS:this.vertCRS,origin:this.origin,associatedSpatialReference:this.associatedSpatialReference})}equals(e){return!!e&&(this===e||this.heightModel===e.heightModel&&this.heightUnit===e.heightUnit&&this.vertCRS===e.vertCRS)}static fromSpatialReference(e){let{latestVcsWkid:t,vcsWkid:i}=e;if(!i)return null;let r=(null==t?null:u.B.get(t))??u.B.get(i);return r?new l({heightModel:0===r.type?"gravity-related-height":"ellipsoidal",heightUnit:(0,n.LA)(r.unit.name),vertCRS:r.datum,origin:3,associatedSpatialReference:e}):null}write(e,t){return t={origin:"web-scene",...t},super.write(e,t)}static fromJSON(e){if(!e)return null;let t=new l;return t.read(e,{origin:"web-scene"}),t}};function m(e,t){return new h.A("height-unit:unsupported",`Height unit of value '${e}' is not supported`,t)}(0,r.Cg)([(0,c.MZ)()],y.prototype,"origin",void 0),(0,r.Cg)([(0,c.MZ)()],y.prototype,"associatedSpatialReference",void 0),(0,r.Cg)([(0,c.MZ)({type:g.apiValues,constructOnly:!0,json:{origins:{"web-scene":{type:f,default:"ellipsoidal",write:{isRequired:!0,alwaysWriteDefaults:!0}}}}})],y.prototype,"heightModel",void 0),(0,r.Cg)([(0,p.K)("web-scene","heightModel")],y.prototype,"writeHeightModel",null),(0,r.Cg)([(0,d.w)(["web-scene","service"],"heightModel")],y.prototype,"readHeightModel",null),(0,r.Cg)([(0,c.MZ)({type:v.apiValues,constructOnly:!0,json:{origins:{"web-scene":{type:v.jsonValues,write:{writer:v.write,isRequired:!0}}}}})],y.prototype,"heightUnit",void 0),(0,r.Cg)([(0,d.w)("web-scene","heightUnit")],y.prototype,"readHeightUnit",null),(0,r.Cg)([(0,d.w)("service","heightUnit")],y.prototype,"readHeightUnitService",null),(0,r.Cg)([(0,c.MZ)({type:String,constructOnly:!0,json:{origins:{"web-scene":{write:!0}}}})],y.prototype,"vertCRS",void 0),(0,r.Cg)([(0,d.w)("service","vertCRS",["vertCRS","ellipsoid","geoid"])],y.prototype,"readVertCRS",null),y=l=(0,r.Cg)([(0,c.$K)("esri.geometry.HeightModelInfo")],y)},38732(e,t,i){i.r(t),i.d(t,{default:()=>S});var l=i(32198),r=i(56507),s=i(49186),a=i(97768),o=i(25728),n=i(17676),h=i(84952),c=i(91429),u=i(4146),p=i(89186),d=i(18768),g=i(85707),f=i(34287),v=i(8303),y=i(10873),m=i(87378),w=i(35982);class _ extends w.B{constructor(e=null){super("LercWorker","_decode",{_decode:e=>[e.buffer]},e,{strategy:"dedicated"}),this.schedule=e,this.ref=0}decode(e,t,i){return e&&0!==e.byteLength?this.invoke({buffer:e,options:t},i):Promise.resolve(null)}release(){--this.ref<=0&&(C.forEach((e,t)=>{e===this&&C.delete(t)}),this.destroy())}}const C=new Map;var b=i(36005);let M=class extends((0,g.a)((0,p.f)((0,d.b)((0,f.q)((0,v.A)((0,o.M)(u.A))))))){constructor(...e){super(...e),this.capabilities={operations:{supportsTileMap:!1}},this.copyright=null,this.path=null,this.minScale=void 0,this.maxScale=void 0,this.opacity=1,this.operationalLayerType="ArcGISTiledElevationServiceLayer",this.sourceJSON=null,this.type="elevation",this.url=null,this.version=null,this._lercDecoder=function(e=null){let t=C.get(e);return t||(null==e?(t=new _,C.set(null,t)):(t=new _(t=>e.immediate.schedule(t)),C.set(e,t))),++t.ref,t}()}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._lercDecoder=(0,a.Gz)(this._lercDecoder)}readCapabilities(e,t){let i=t.capabilities&&t.capabilities.split(",").map(e=>e.toLowerCase().trim());return i?{operations:{supportsTileMap:i.includes("tilemap")}}:{operations:{supportsTileMap:!1}}}get memoizedElevationQueryDependencies(){return[this.loadStatus,this.tileInfo,this.fullExtent,this.spatialReference]}readVersion(e,t){let i=t.currentVersion;return i||=9.3,i}load(e){let t=null==e?null:e.signal;return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["Image Service"],supportsData:!1,validateItem:e=>{if(e.typeKeywords)for(let t=0;t<e.typeKeywords.length;t++)if("elevation 3d layer"===e.typeKeywords[t].toLowerCase())return!0;throw new s.A("portal:invalid-layer-item-type","Invalid layer item type '${type}', expected '${expectedType}' ",{type:"Image Service",expectedType:"Image Service Elevation 3D Layer"})}},e).catch(n.QP).then(()=>this._fetchImageService(t))),Promise.resolve(this)}async fetchTile(e,t,i,l){let a=l?.signal,o={responseType:"array-buffer",signal:a,useQueue:l?.useQueue,priority:l?.priority},n={noDataValue:l?.noDataValue,returnFileInfo:!0};await this.load(),await this._fetchTileAvailability(e,t,i,l);let h=await(0,r.A)(this.getTileUrl(e,t,i),o),c=await this._lercDecoder.decode(h.data,n,a);if(!c)throw new s.A("elevation-layer:tile-decode-failed","Failed to decode elevation tile data.");return new m.A({values:c.pixelData,width:c.width,height:c.height,noDataValue:c.noDataValue})}getTileUrl(e,t,i){let l=!this.capabilities.operations.supportsTileMap&&this.supportsBlankTile,r=(0,h.x0)({...this.parsedUrl.query,blankTile:!l&&null});return`${this.parsedUrl.path}/tile/${e}/${t}/${i}${r?"?"+r:""}`}async queryElevation(e,t){let{query:l}=await i.e(1359).then(()=>i(1359));return(0,n.Te)(t),l(this,e,t)}async createElevationSampler(e,t){let{createSampler:l}=await i.e(1359).then(()=>i(1359));return(0,n.Te)(t),l(this,e,t)}_fetchTileAvailability(e,t,i,l){return this.tilemapCache?this.tilemapCache.fetchAvailability(e,t,i,l):Promise.resolve("unknown")}async _fetchImageService(e){if(this.sourceJSON)return this.sourceJSON;let t={query:{f:"json",...this.parsedUrl.query},responseType:"json",signal:e},i=await(0,r.A)(this.parsedUrl.path,t);i.ssl&&(this.url=this.url?.replace(/^http:/i,"https:")),this.sourceJSON=i.data,this.read(i.data,{origin:"service",url:this.parsedUrl})}get hasOverriddenFetchTile(){return!this.fetchTile[A]}};(0,l.Cg)([(0,c.MZ)({readOnly:!0})],M.prototype,"capabilities",void 0),(0,l.Cg)([(0,b.w)("service","capabilities",["capabilities"])],M.prototype,"readCapabilities",null),(0,l.Cg)([(0,c.MZ)({json:{read:{source:"copyrightText"}}})],M.prototype,"copyright",void 0),(0,l.Cg)([(0,c.MZ)({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],M.prototype,"path",void 0),(0,l.Cg)([(0,c.MZ)({type:["show","hide"]})],M.prototype,"listMode",void 0),(0,l.Cg)([(0,c.MZ)({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}},readOnly:!0})],M.prototype,"minScale",void 0),(0,l.Cg)([(0,c.MZ)({json:{read:!1,write:!1,origins:{service:{read:!1,write:!1},"portal-item":{read:!1,write:!1},"web-document":{read:!1,write:!1}}},readOnly:!0})],M.prototype,"maxScale",void 0),(0,l.Cg)([(0,c.MZ)({json:{read:!1,write:!1,origins:{"web-document":{read:!1,write:!1}}}})],M.prototype,"opacity",void 0),(0,l.Cg)([(0,c.MZ)({type:["ArcGISTiledElevationServiceLayer"]})],M.prototype,"operationalLayerType",void 0),(0,l.Cg)([(0,c.MZ)()],M.prototype,"sourceJSON",void 0),(0,l.Cg)([(0,c.MZ)({json:{read:!1},value:"elevation",readOnly:!0})],M.prototype,"type",void 0),(0,l.Cg)([(0,c.MZ)()],M.prototype,"memoizedElevationQueryDependencies",null),(0,l.Cg)([(0,c.MZ)(y.OZ)],M.prototype,"url",void 0),(0,l.Cg)([(0,c.MZ)()],M.prototype,"version",void 0),(0,l.Cg)([(0,b.w)("version",["currentVersion"])],M.prototype,"readVersion",null),M=(0,l.Cg)([(0,c.$K)("esri.layers.ElevationLayer")],M);const A=Symbol("default-fetch-tile");M.prototype.fetchTile[A]=!0;const S=M},89186(e,t,i){var l=i(32198),r=i(91429),s=i(16930),a=i(87045),o=i(65509),n=i(25943),h=i(36005);i.d(t,["f",0,e=>{let t=e,i=class extends t{constructor(){super(...arguments),this.copyright=null,this.minScale=0,this.maxScale=0,this.spatialReference=null,this.tileInfo=null,this.tilemapCache=null}destroy(){this.tilemapCache?.destroy?.()}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}get supportsBlankTile(){return this.version>=10.2}readTilemapCache(e,t,i){let l=t.capabilities?.toLowerCase().includes("tilemap"),{minLOD:r,maxLOD:s,minScale:h,maxScale:c}=t;if(null==r&&null==s&&(0!==h||0!==c)){let e=e=>Math.round(1e4*e)/1e4;h=e(h||t.tileInfo.lods[0].scale),c=e(c||t.tileInfo.lods[t.tileInfo.lods.length-1].scale);for(let i of t.tileInfo.lods){let t=e(i.scale);r=t>=h?i.level:r,s=t>=c?i.level:s}}if(l)return new n.d({layer:this,minLOD:r,maxLOD:s});if(t.tileInfo){let e=new a.A;return e.read(t.tileInfo,i),new o.A(e,r,s)}return null}};return(0,l.Cg)([(0,r.MZ)({json:{read:{source:"copyrightText"}}})],i.prototype,"copyright",void 0),(0,l.Cg)([(0,r.MZ)()],i.prototype,"minScale",void 0),(0,l.Cg)([(0,h.w)("service","minScale")],i.prototype,"readMinScale",null),(0,l.Cg)([(0,r.MZ)()],i.prototype,"maxScale",void 0),(0,l.Cg)([(0,h.w)("service","maxScale")],i.prototype,"readMaxScale",null),(0,l.Cg)([(0,r.MZ)({type:s.A})],i.prototype,"spatialReference",void 0),(0,l.Cg)([(0,r.MZ)({readOnly:!0})],i.prototype,"supportsBlankTile",null),(0,l.Cg)([(0,r.MZ)({type:a.A})],i.prototype,"tileInfo",void 0),(0,l.Cg)([(0,r.MZ)()],i.prototype,"tilemapCache",void 0),(0,l.Cg)([(0,h.w)("service","tilemapCache",["capabilities","tileInfo"])],i.prototype,"readTilemapCache",null),(0,l.Cg)([(0,r.MZ)()],i.prototype,"version",void 0),i=(0,l.Cg)([(0,r.$K)("esri.layers.mixins.ArcGISCachedService")],i),i}])},18768(e,t,i){var l=i(32198),r=i(53966),s=i(91429),a=i(60694);i.d(t,["b",0,e=>{let t=e,i=class extends t{get title(){if(this._get("title")&&"defaults"!==this.originOf("title"))return this._get("title");if(this.url){let e=(0,a.qg)(this.url);if(e?.title)return e.title}return this._get("title")||""}set title(e){this._set("title",e)}set url(e){this._set("url",(0,a.Jf)(e,r.A.getLogger(this)))}};return(0,l.Cg)([(0,s.MZ)()],i.prototype,"title",null),(0,l.Cg)([(0,s.MZ)({type:String})],i.prototype,"url",null),i=(0,l.Cg)([(0,s.$K)("esri.layers.mixins.ArcGISService")],i),i}])},85707(e,t,i){var l=i(32198),r=i(91429),s=i(54239);i.d(t,["a",0,e=>{let t=e,i=class extends t{constructor(){super(...arguments),this.heightModelInfo=null}read(e,t){super.read(e,t),"service"===t?.origin&&2===this.heightModelInfo?.origin&&(this.heightModelInfo.associatedSpatialReference=this.getAtOrigin("spatialReference","service"))}};return(0,l.Cg)([(0,r.MZ)({readOnly:!0,type:s.A})],i.prototype,"heightModelInfo",void 0),i=(0,l.Cg)([(0,r.$K)("esri.layers.mixins.HeightModelInfoMixin")],i),i}])},87378(e,t,i){i.d(t,{A:()=>o});var l,r=i(34275),s=i(78888);const a=Symbol("ElevationTileDataClass");class o{static{l=a}constructor({values:e,width:t,height:i,noDataValue:s}){this[l]=!0,this._hasNoDataValues=null,this._minValue=null,this._maxValue=null,this.values=(0,r.vZ)(e)?e:new Float32Array(e),this.width=t,this.height=i,this.noDataValue=s}get hasNoDataValues(){if(null==this._hasNoDataValues){let e=this.noDataValue;this._hasNoDataValues=this.values.includes(e)}return this._hasNoDataValues}get minValue(){return this._ensureBounds(),this._minValue}get maxValue(){return this._ensureBounds(),this._maxValue}get usedMemory(){return this.values.byteLength+256}_ensureBounds(){if(null!=this._minValue)return;let{noDataValue:e,values:t}=this,i=1/0,l=-1/0,r=!0;for(let s of t)s===e?this._hasNoDataValues=!0:(i=s<i?s:i,l=s>l?s:l,r=!1);r?(this._minValue=0,this._maxValue=0):(this._minValue=i,this._maxValue=l>-3e38?l:0)}static{this.from=(0,s.qf)(o)}}},91806(e,t,i){i.d(t,{A:()=>n});var l,r=i(32198),s=i(25482),a=i(91429),o=i(78888);let n=class extends s.o{static{l=this}constructor(e){super(e),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new l({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,r.Cg)([(0,a.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],n.prototype,"cols",void 0),(0,r.Cg)([(0,a.MZ)({type:o.jz,json:{write:!0}})],n.prototype,"level",void 0),(0,r.Cg)([(0,a.MZ)({type:String,json:{write:!0}})],n.prototype,"levelValue",void 0),(0,r.Cg)([(0,a.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],n.prototype,"origin",void 0),(0,r.Cg)([(0,a.MZ)({type:Number,json:{write:!0}})],n.prototype,"resolution",void 0),(0,r.Cg)([(0,a.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],n.prototype,"rows",void 0),(0,r.Cg)([(0,a.MZ)({type:Number,json:{write:!0}})],n.prototype,"scale",void 0),n=l=(0,r.Cg)([(0,a.$K)("esri.layers.support.LOD")],n)},87045(e,t,i){i.d(t,{A:()=>w});var l,r=i(32198),s=i(66552),a=i(25482),o=i(86211),n=i(91429),h=i(78888),c=i(86738),u=i(16930),p=i(21325),d=i(28735),g=i(91806),f=i(72802),v=i(36005),y=i(43937);const m=new s.J({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let w=class extends a.o{static{l=this}static create(e={}){let{resolutionFactor:t=1,scales:i,size:r=256,spatialReference:s=u.A.WebMercator,numLODs:a=24}=e;if(!(0,p.fn)(s)){let e=[];if(i)for(let t=0;t<i.length;t++){let l=i[t];e.push(new g.A({level:t,scale:l,resolution:l}))}else{let t=5e-4;for(let i=a-1;i>=0;i--)e.unshift(new g.A({level:i,scale:t,resolution:t})),t*=2}return new l({dpi:96,lods:e,origin:new c.A(0,0,s),size:[r,r],spatialReference:s})}let n=(0,p.Vp)(s),h=e.origin?new c.A({x:e.origin.x,y:e.origin.y,spatialReference:s}):n?new c.A({x:n.origin[0],y:n.origin[1],spatialReference:s}):new c.A({x:0,y:0,spatialReference:s}),d=1/(39.37*(0,o.GA)(s)*96),f=[];if(i)for(let e=0;e<i.length;e++){let t=i[e],l=t*d;f.push(new g.A({level:e,scale:t,resolution:l}))}else{let e=(0,p.EA)(s)?512/r*591657527.5917094:256/r*591657527.591555,i=Math.ceil(a/t);f.push(new g.A({level:0,scale:e,resolution:e*d}));for(let l=1;l<i;l++){let i=e/2**t,r=i*d;f.push(new g.A({level:l,scale:i,resolution:r})),e=i}}return new l({dpi:96,lods:f,origin:h,size:[r,r],spatialReference:s})}constructor(e){super(e),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){let{spatialReference:e,origin:t}=this;if(e&&t){let i=(0,p.Vp)(e);return e.isWrappable&&!!i&&Math.abs(i.origin[0]-t.x)<=i.dx}return!1}readOrigin(e,t){return c.A.fromJSON({spatialReference:t.spatialReference,...e})}set lods(e){let t=0,i=0,l=[],r=this._levelToLOD={};e&&(t=-1/0,i=1/0,e.forEach(e=>{l.push(e.scale),t=e.scale>t?e.scale:t,i=e.scale<i?e.scale:i,r[e.level]=e})),this._set("scales",l),this._set("lods",e),this._initializeUpsampleLevels()}readSize(e,t){return[t.cols,t.rows]}writeSize(e,t){t.cols=e[0],t.rows=e[1]}zoomToScale(e){let t=this.scales;if(e<=0)return t[0];if(e>=t.length-1)return t[t.length-1];let i=Math.floor(e),l=i+1;return t[i]/(t[i]/t[l])**(e-i)}scaleToZoom(e){let t=this.scales,i=t.length-1,l=0;for(;l<i;l++){let i=t[l],r=t[l+1];if(i<=e)return l;if(r===e)return l+1;if(i>e&&r<e)return l+Math.log(i/e)/Math.log(i/r)}return l}tileAt(e,t,i,l){let r,s,a=this.lodAt(e);if(!a)return null;if("number"==typeof t)r=t,s=i;else if((0,p.aI)(t.spatialReference,this.spatialReference))r=t.x,s=t.y,l=i;else{let e=(0,d.Cv)(t,this.spatialReference);if(null==e)return null;r=e.x,s=e.y,l=i}let o=a.resolution*this.size[0],n=a.resolution*this.size[1];return l??=new f.U(0,0,0),l.level=e,l.row=Math.floor((this.origin.y-s)/n+.001),l.col=Math.floor((r-this.origin.x)/o+.001),this.updateTileInfo(l),l}updateTileInfo(e,t=0){if(!("extent"in e))return!1;let i=this.lodAt(e.level);if(!i&&1===t){let t=this.lods[this.lods.length-1];t.level<e.level&&(i=t)}if(!i)return!1;let l=e.level-i.level,r=i.resolution*this.size[0]/2**l,s=i.resolution*this.size[1]/2**l;return e.extent[0]=this.origin.x+e.col*r,e.extent[1]=this.origin.y-(e.row+1)*s,e.extent[2]=e.extent[0]+r,e.extent[3]=e.extent[1]+s,!0}upsampleTile(e){let t=this._upsampleLevels[e.level];return!(!t||-1===t.parentLevel||(e.level=t.parentLevel,e.row=Math.floor(e.row/t.factor+.001),e.col=Math.floor(e.col/t.factor+.001),this.updateTileInfo(e),0))}getTileBounds(e,t){let i=this.lodAt(t.level);if(null==i)return null;let{resolution:l}=i,r=l*this.size[0],s=l*this.size[1];return e[0]=this.origin.x+t.col*r,e[1]=this.origin.y-(t.row+1)*s,e[2]=e[0]+r,e[3]=e[1]+s,e}lodAt(e){return this._levelToLOD?.[e]??null}clone(){return l.fromJSON(this.write({}))}getCompatibleForVTL(e){if(this.size[0]!==this.size[1]||256===this.size[0]&&512===e)return null;let t=(512===this.size[0]&&256===e?-1:0)+ +!!this.spatialReference.isGeographic;if(this.size[0]===e&&0===t)return this;let i=[],r=this.lods.length-t;for(let e=0;e<r;e++){let l=e+t,{scale:r,resolution:s}=l>=0?this.lods[l]:{scale:2*this.lods[0].scale,resolution:2*this.lods[0].resolution};i.push(new g.A({level:e,scale:r,resolution:s}))}return new l({size:[e,e],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:i})}_initializeUpsampleLevels(){let e=this.lods;this._upsampleLevels=[];let t=null;for(let i=0;i<e.length;i++){let l=e[i];this._upsampleLevels[l.level]={parentLevel:t?t.level:-1,factor:t?t.resolution/l.resolution:0},t=l}}};(0,r.Cg)([(0,n.MZ)({type:Number,json:{write:!0}})],w.prototype,"compressionQuality",void 0),(0,r.Cg)([(0,n.MZ)({type:Number,json:{write:!0}})],w.prototype,"dpi",void 0),(0,r.Cg)([(0,n.MZ)({type:String,json:{read:m.read,write:m.write,origins:{"web-scene":{read:!1,write:!1}}}})],w.prototype,"format",void 0),(0,r.Cg)([(0,n.MZ)({readOnly:!0})],w.prototype,"isWrappable",null),(0,r.Cg)([(0,n.MZ)({type:c.A,json:{write:!0}})],w.prototype,"origin",void 0),(0,r.Cg)([(0,v.w)("origin")],w.prototype,"readOrigin",null),(0,r.Cg)([(0,n.MZ)({type:[g.A],value:null,json:{write:!0}})],w.prototype,"lods",null),(0,r.Cg)([(0,n.MZ)({readOnly:!0})],w.prototype,"scales",void 0),(0,r.Cg)([(0,n.MZ)({cast:e=>Array.isArray(e)?e:"number"==typeof e?[e,e]:[256,256]})],w.prototype,"size",void 0),(0,r.Cg)([(0,v.w)("size",["rows","cols"])],w.prototype,"readSize",null),(0,r.Cg)([(0,y.K)("size",{cols:{type:h.jz},rows:{type:h.jz}})],w.prototype,"writeSize",null),(0,r.Cg)([(0,n.MZ)({type:u.A,json:{write:!0}})],w.prototype,"spatialReference",void 0),w=l=(0,r.Cg)([(0,n.$K)("esri.layers.support.TileInfo")],w)},65509(e,t,i){i.d(t,{A:()=>s});var l=i(49186),r=i(17676);class s{constructor(e,t=0,i=e.lods[e.lods.length-1].level){this.tileInfo=e,this.minLOD=t,this.maxLOD=i,e.lodAt(t)||(this.minLOD=e.lods[0].level),e.lodAt(i)||(this.maxLOD=e.lods[e.lods.length-1].level)}get effectiveMinLOD(){return this.minLOD??this.tileInfo.lods[0].level}get effectiveMaxLOD(){return this.maxLOD??this.tileInfo.lods[this.tileInfo.lods.length-1].level}getAvailability(e,t,i){let l=this.tileInfo?.lodAt(e);return!l||e<this.minLOD||e>this.maxLOD?"unavailable":l.cols&&l.rows?i>=l.cols[0]&&i<=l.cols[1]&&t>=l.rows[0]&&t<=l.rows[1]?"unknown":"unavailable":"unknown"}async fetchAvailability(e,t,i,s){await(0,r.NO)(s);let a=this.getAvailability(e,t,i);if("unavailable"===a)throw new l.A("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i});return a}async fetchAvailabilityUpsample(e,t,i,l,s){await(0,r.NO)(s),l.level=e,l.row=t,l.col=i;let a=this.tileInfo;return a.updateTileInfo(l),this.fetchAvailability(e,t,i,s).catch(e=>{if((0,r.zf)(e))throw e;if(a.upsampleTile(l))return this.fetchAvailabilityUpsample(l.level,l.row,l.col,l,s);throw e})}}},72802(e,t,i){i.d(t,{U:()=>r});var l=i(19419);class r{constructor(e,t,i,r=(0,l.vt)()){this._level=e,this._row=t,this._col=i,this.extent=r}get id(){return this._id??=`${this.level}/${this.row}/${this.col}`,this._id}get level(){return this._level}set level(e){this._level=e,this._id=null}get row(){return this._row}set row(e){this._row=e,this._id=null}get col(){return this._col}set col(e){this._col=e,this._id=null}toJSON(){return{level:this._level,row:this._row,col:this._col,extent:this.extent}}static fromJSON(e){return new r(e.level,e.row,e.col,e.extent)}}},25943(e,t,i){i.d(t,{d:()=>b});var l,r=i(32198),s=i(56507),a=i(69622),o=i(49186),n=i(36563),h=(i(44208),i(66344)),c=i(15142),u=i(17676),p=i(36708),d=i(76030),g=i(84952),f=i(91429),v=i(72802),y=i(4718),m=i(69397);class w{constructor(e){!function(e){if(!e?.location)throw new o.A("tilemap:missing-location","Location missing from tilemap response");if(!1===e.valid)throw new o.A("tilemap:invalid","Tilemap response was marked as invalid");if(!e.data)throw new o.A("tilemap:missing-data","Data missing from tilemap response");if(!Array.isArray(e.data))throw new o.A("tilemap:data-mismatch","Data must be an array of numbers");if(e.data.length!==e.location.width*e.location.height)throw new o.A("tilemap:data-mismatch","Number of data items does not match width/height of tilemap")}(e);let{location:t,data:i}=e;this.location=Object.freeze((0,y.o8)(t));let l=this.location.width,r=this.location.height,s=!0,a=!0,n=function(e,t=!1){return e<=1024?t?Array(e).fill(0):Array(e):new Uint32Array(e)}(Math.ceil(l*r/32)),h=0;for(let e=0;e<i.length;e++){let t=e%32;i[e]?(a=!1,n[h]|=1<<t):s=!1,31===t&&++h}a?(this._availability="unavailable",this.byteSize=40):s?(this._availability="available",this.byteSize=40):(this._availability=n,this.byteSize=40+(0,m.Qf)(n))}getAvailability(e,t){if("unavailable"===this._availability||"available"===this._availability)return this._availability;let i=(e-this.location.top)*this.location.width+(t-this.location.left),l=i%32,r=i>>5,s=this._availability;return r<0||r>s.length?"unknown":s[r]&1<<l?"available":"unavailable"}static fromDefinition(e,t){let i=e.service.request||s.A,{row:l,col:r,width:a,height:n}=e,h={query:{f:"json"}};return t=t?{...h,...t}:h,i(function(e){let t;if(e.service.tileServers?.length){let i=e.service.tileServers;t=`${i&&i.length?i[e.row%i.length]:e.service.url}/tilemap/${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`}else t=`${e.service.url}/tilemap/${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`;let i=e.service.query;return i&&(t=`${t}?${i}`),t}(e),t).then(e=>e.data).catch(e=>{if(422===e?.details?.httpStatus)return{location:{top:l,left:r,width:a,height:n},valid:!0,data:Array(a*n).fill(0)};throw e}).then(e=>{if(e.location&&(e.location.top!==l||e.location.left!==r||e.location.width!==a||e.location.height!==n))throw new o.A("tilemap:location-mismatch","Tilemap response for different location than requested",{response:e,definition:{top:l,left:r,width:a,height:n}});return w.fromJSON(e)})}static fromJSON(e){return Object.freeze(new w(e))}}function _(e){return`${e.level}/${e.row}/${e.col}/${e.width}/${e.height}`}function C(e,t,i){return new o.A("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i})}let b=class extends a.A{static{l=this}constructor(e){super(e),this._pendingTilemapRequests={},this.request=s.A,this.size=32,this._prefetchingEnabled=!0}initialize(){this._tilemapCache=new h.q(2097152),this.addHandles((0,p.wB)(()=>{let{layer:e}=this;return[e?.parsedUrl,e?.tileServers,e?.apiKey,e?.customParameters]},()=>this._initializeTilemapDefinition(),p.Vh))}get effectiveMinLOD(){return this.minLOD??this.layer.tileInfo.lods[0].level}get effectiveMaxLOD(){return this.maxLOD??this.layer.tileInfo.lods[this.layer.tileInfo.lods.length-1].level}getAvailability(e,t,i){if(!this.layer.tileInfo.lodAt(e)||e<this.effectiveMinLOD||e>this.effectiveMaxLOD)return"unavailable";let l=this._tilemapFromCache(e,t,i,this._tmpTilemapDefinition);return l?l.getAvailability(t,i):"unknown"}fetchAvailability(e,t,i,l){return!this.layer.tileInfo.lodAt(e)||e<this.effectiveMinLOD||e>this.effectiveMaxLOD?Promise.reject(C(e,t,i)):this._fetchTilemap(e,t,i,l).catch(e=>e).then(l=>{if(l instanceof w){let r=l.getAvailability(t,i);if("unavailable"===r)throw C(e,t,i);return r}if((0,u.zf)(l))throw l;return"unknown"})}fetchAvailabilityUpsample(e,t,i,l,r){l.level=e,l.row=t,l.col=i;let s=this.layer.tileInfo;s.updateTileInfo(l);let a=this.fetchAvailability(e,t,i,r).catch(e=>{if((0,u.zf)(e))throw e;if(s.upsampleTile(l))return this.fetchAvailabilityUpsample(l.level,l.row,l.col,l,r);throw e});return this._fetchAvailabilityUpsamplePrefetch(e,t,i,r,a),a}async _fetchAvailabilityUpsamplePrefetch(e,t,i,r,s){if(!this._prefetchingEnabled)return;let a=`prefetch-${e}-${t}-${i}`;if(this.hasHandles(a))return;let o=new AbortController;s.then(()=>o.abort(),()=>o.abort());let h=!1,c=(0,n.hA)(()=>{h||(h=!0,o.abort())});if(this.addHandles(c,a),await(0,d.md)(10,o.signal).catch(()=>{}),h||(h=!0,this.removeHandles(a)),(0,u.G4)(o))return;let p=new v.U(e,t,i),g={...r,signal:o.signal},f=this.layer.tileInfo;for(let e=0;l._prefetches.length<l._maxPrefetch&&f.upsampleTile(p);++e){let e=this.fetchAvailability(p.level,p.row,p.col,g);l._prefetches.push(e);let t=()=>{l._prefetches.removeUnordered(e)};e.then(t,t)}}static{this._maxPrefetch=4}static{this._prefetches=new c.A({initialSize:l._maxPrefetch})}static cleanupTilemapCache(){this._prefetches.prune()}_fetchTilemap(e,t,i,l){if(!this.layer.tileInfo.lodAt(e)||e<this.effectiveMinLOD||e>this.effectiveMaxLOD)return Promise.reject(new o.A("tilemap-cache:level-unavailable",`Level ${e} is unavailable in the service`));let r=this._tmpTilemapDefinition,s=this._tilemapFromCache(e,t,i,r);if(s)return Promise.resolve(s);let a=l?.signal;return l={...l,signal:null},new Promise((e,t)=>{(0,u.u7)(a,()=>t((0,u.NK)()));let i=_(r),s=this._pendingTilemapRequests[i];if(!s){s=w.fromDefinition(r,l).then(e=>(this._tilemapCache.put(i,e,e.byteSize),e));let e=()=>{delete this._pendingTilemapRequests[i]};this._pendingTilemapRequests[i]=s,s.then(e,e)}s.then(e,t)})}_initializeTilemapDefinition(){if(!this.layer.parsedUrl)return;let{parsedUrl:e,apiKey:t,customParameters:i}=this.layer;this._tilemapCache.clear(),this._tmpTilemapDefinition={service:{url:e.path,query:(0,g.x0)({...e.query,...i,token:t??e.query?.token}),tileServers:this.layer.tileServers,request:this.request},width:this.size,height:this.size,level:0,row:0,col:0}}_tilemapFromCache(e,t,i,l){l.level=e,l.row=t-t%this.size,l.col=i-i%this.size;let r=_(l);return this._tilemapCache.get(r)}get test(){}};(0,r.Cg)([(0,f.MZ)({constructOnly:!0})],b.prototype,"layer",void 0),(0,r.Cg)([(0,f.MZ)({constructOnly:!0})],b.prototype,"minLOD",void 0),(0,r.Cg)([(0,f.MZ)({constructOnly:!0})],b.prototype,"maxLOD",void 0),(0,r.Cg)([(0,f.MZ)({constructOnly:!0})],b.prototype,"request",void 0),(0,r.Cg)([(0,f.MZ)({constructOnly:!0})],b.prototype,"size",void 0),b=l=(0,r.Cg)([(0,f.$K)("esri.layers.support.TilemapCache")],b)}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[1003],{1003(e,t,i){i.r(t),i.d(t,{default:()=>ye});var a=i(49186),r=i(32198),s=i(91429),n=i(49859),l=i(68197),o=i(5443),f=i(16930),u=i(73444),h=i(94778),c=i(14140);function d(e){return["x","e","east","long","longitude"].includes(e.toLowerCase())}function p(e){return["y","n","west","lat","latitude"].includes(e.toLowerCase())}function m(e){let{axes:t}=e.domain,i=Object.keys(t),a=[],r=[],s=-1,n=-1,l=[];for(let e=0;e<i.length;e++){let o=i[e];d(o)?s=e:p(o)&&(n=e);let f=t[o],u=[];if("values"in f){f.values.forEach(e=>u.push("string"==typeof e?new Date(e).getTime():e));let e=u[1]-u[0];a.push([u[0]-.5*e,u[u.length-1]+.5*e]),r.push(e)}else{let{start:e,stop:t,num:i}=f,s=(t-e)/(i-1);a.push([e-.5*s,t+.5*s]),r.push(s);for(let t=0;t<i;t++)u.push(e+s*t)}l.push({name:o,values:u,extent:[u[0],u[u.length-1]]})}s>-1&&-1===n?n=+(0===s):n>-1&&-1===s?s=+(0===n):-1===n&&-1===s&&(s=0,n=1),l=l.filter((e,t)=>t!==s&&t!==n);let{referencing:u}=e.domain,h=u.find(e=>e.coordinates.includes(i[s])).system.id,c=h?.slice(h.lastIndexOf("/")+1),m=null==c||"CRS84"===c?4326:Number(c),g=new f.A({wkid:m}),[y,x]=a[s],[w,I]=a[n],b=new o.A({xmin:y,xmax:x,ymin:w,ymax:I,spatialReference:g});return{width:Math.round(b.width/r[s]),height:Math.round(b.height/r[n]),extent:b,dimensions:l}}function g(e){let t=(0,u.lR)();return t?e[t]??Object.values(e)[0]:Object.values(e)[0]}function y(){return Math.round(255*Math.random())}function x(e){let t={},{parameters:i}=e;if(!i)return t;for(let[e,a]of Object.entries(i)){let{type:i,description:r,unit:s,categoryEncoding:n,observedProperty:o}=a;if("Parameter"===i&&(t[e]={},r&&(t[e].description=g(r)),s&&(t[e].unit=s.label?g(s.label):null,t[e].symbol=s.symbol?.value),n)){let i=Object.entries(n).map((e,t)=>({OID:t,Value:Number(e[1]),ClassName:e[0].slice(e[0].lastIndexOf("/")+1),Count:1})),a=!1;o?.categories?.length&&(o.categories.forEach(e=>{if(!e.id)return;let t=e.id.slice(e.id.lastIndexOf("/")+1),r=i.find(e=>e.ClassName===t);if(r&&(r.Label=e.label?g(e.label):null,e.preferredColor)){let t=l.A.fromHex(e.preferredColor);t&&(a=!0,r.Red=t.r,r.Green=t.g,r.Blue=t.b)}}),a&&i.forEach(e=>{e.Red??(e.Red=y(),e.Green=y(),e.Blue=y())}));let r={objectIdFieldName:"",fields:[{name:"OID",type:"esriFieldTypeOID",alias:"OID",domain:null},{name:"Value",type:"esriFieldTypeInteger",alias:"Value",domain:null},{name:"Count",type:"esriFieldTypeDouble",alias:"Count",domain:null},{name:"ClassName",type:"esriFieldTypeString",alias:"ClassName",domain:null,length:50},{name:"Label",type:"esriFieldTypeString",alias:"Label",domain:null,length:50}],features:i.map(e=>({attributes:e}))};a&&r.fields.push({name:"Red",type:"esriFieldTypeInteger",alias:"Red",domain:null},{name:"Green",type:"esriFieldTypeInteger",alias:"Green",domain:null},{name:"Blue",type:"esriFieldTypeInteger",alias:"Blue",domain:null}),t[e].attributeTable=r}}return t}function w(e){let t=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let a=0;a<e.length;a++){let r=e[a];null!=r&&(r<t&&(t=r),r>i&&(i=r))}return(0,h.X1)(t,i)}function I(e,t,i){let a=e.map((e,i)=>({name:e,count:t[i]})).sort((e,t)=>e.name>t.name?-1:1),r=(e=>t=>e*=t.count)(1),s=[...a.slice(1),{name:"",count:1}].reverse().map(r).reverse(),n=0;for(let r=e.length-1;r>=0;r--){let l=a.findIndex(({name:t})=>t===e[r]);n+=s[l]*(i%t[r]),i=Math.floor(i/t[r])}return n}var b=i(17676),C=i(4366),v=i(47520),S=i(51927),A=i(45617),T=i(87186);let _=class extends n.A{constructor(){super(...arguments),this._pixelBlockTiles=new Map,this.datasetFormat="MEMORY",this.preGenerateTiles=!0,this.source=null}get url(){return""}async fetchRawTile(e,t,i,a={}){let r=`${e}/${t}/${i}`,s=this._pixelBlockTiles.get(r);if(s)return s;if(!this.source)return null;let{rasterInfo:n}=this,[l,o]=n.storageInfo.tileInfo.size,{sliceId:f}=a,{encodedData:u}=this.source;if(u){let s=await this.decodePixelBlock(u,{tileSize:[l,o],tileIndex:[e,t,i],canvasUsage:"canvas-only",cloneSource:!0,skipStatistics:!0},{signal:a.signal});return s&&this._pixelBlockTiles.set(r,s),s}let{pixelBlocks:h}=this.source,c=null==f?h[0]:h[f];if(null==c)return null;let d={pixelBlock:c,useBilinear:"thematic"!==n.dataType,tileSize:{width:l,height:o},level:e,row:t,col:i};return this.rasterJobHandler?this.rasterJobHandler.clipTile(d,a):(0,v.J$)(d)}async _open(e){if(!this.source)throw new a.A("in-memory-raster:open","source is required to open an in memory raster");let t=this.source;this.datasetName=t.name;let{pixelBlocks:i,attributeTable:r,statistics:s,histograms:n,nativeExtent:l,transform:u,colormap:h}=t,c=i[0],{width:d,height:p,pixelType:m}=c??t.imageInfo,g=t.extent??new o.A({xmin:-.5,ymin:.5,xmax:d-.5,ymax:p-.5,spatialReference:new f.A({wkid:3857})}),y=t.isPseudoSpatialReference??!t.extent,x={x:g.width/d,y:g.height/p},w={...t.keyProperties};t.dataType&&(w.DataType=t.dataType),t.bandInfos&&(w.BandProperties=t.bandInfos.map(e=>e.toJSON())),r&&(w.DataType="Thematic");let I=new T.A({width:d,height:p,pixelType:m,extent:g,nativeExtent:l,attributeTable:r,colormap:h,transform:u,pixelSize:x,spatialReference:g.spatialReference,bandCount:c?.pixels.length??t.imageInfo.bandCount,keyProperties:w,multidimensionalInfo:t.multidimensionalInfo,statistics:s,isPseudoSpatialReference:y,histograms:n});this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(I),this.createRemoteDatasetStorageInfo(I,512,512),this._set("rasterInfo",I),this.updateTileInfo(),I.multidimensionalInfo?await this._buildMDimStats(i,I.multidimensionalInfo):this.preGenerateTiles&&c&&(await this._buildInMemoryRaster(c,{width:512,height:512},e),this.source=null)}async _buildInMemoryRaster(e,t,i){let{rasterInfo:r}=this,s=r.storageInfo.maximumPyramidLevel??0,n="thematic"!==r.dataType,l=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:e,tileSize:t,maximumPyramidLevel:s,useBilinear:n},i):Promise.resolve((0,v.lD)(e,t,s,n)),o=null!=r.statistics,f=null!=r.histograms,u=this.ioConfig.skipStatistics||o?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:e},i):Promise.resolve((0,S.f4)(e)),h=await(0,b.Lx)([l,u]);if(!h[0].value)throw new a.A("in-memory-raster:open","failed to build in memory raster");this._pixelBlockTiles=h[0].value,o||(r.statistics=h[1].value?.statistics),f||(r.histograms=h[1].value?.histograms)}async _buildMDimStats(e,t,i){for(let a=0;a<t.variables.length;a++){let r=t.variables[a];if(r.statistics)continue;let s=r.dimensions.map(e=>new A.A({variableName:r.name,dimensionName:e.name,values:[e.values?.[0]??e.extent?.[0]],isSlice:!0})),n=(0,C.NG)(s,t),l=null==n?null:e[n];if(null==l)continue;let o=this.rasterJobHandler?await this.rasterJobHandler.computeStatisticsHistograms({pixelBlock:l},i):(0,S.eH)(l);r.statistics=o.statistics,r.histograms||=o.histograms}}};(0,r.Cg)([(0,s.MZ)({type:String,json:{write:!0}})],_.prototype,"datasetFormat",void 0),(0,r.Cg)([(0,s.MZ)({constructOnly:!0})],_.prototype,"preGenerateTiles",void 0),(0,r.Cg)([(0,s.MZ)()],_.prototype,"source",void 0),(0,r.Cg)([(0,s.MZ)()],_.prototype,"url",null),_=(0,r.Cg)([(0,s.$K)("esri.layers.raster.datasets.InMemoryRaster")],_);const R=_;var M=i(22671);let k=class extends n.A{constructor(){super(...arguments),this.datasetFormat="CovJSON"}fetchRawTile(e,t,i,a={}){return this._inMemoryRaster.fetchRawTile(e,t,i,a)}async _open(e){let{extent:t,pixelBlocks:i,multidimensionalInfo:a,attributeTable:r,bandNames:s}=await this._fetchData(e),{statistics:n,histograms:l}=(0,S.eH)(i[0]),o=s?.map(e=>({BandName:e})),f={DataType:r?"Thematic":a?"Scientific":"Generic",BandProperties:o},u=new R({source:{extent:t,pixelBlocks:i,attributeTable:r?M.A.fromJSON(r):null,multidimensionalInfo:a,statistics:n,histograms:l,keyProperties:f,isPseudoSpatialReference:!1}});await u.open(),this._inMemoryRaster=u;let h=this.source?"":this.url.slice(this.url.lastIndexOf("/")+1);this._set("datasetName",h.slice(0,h.indexOf("."))),this._set("rasterInfo",u.rasterInfo)}async _fetchData(e){let t=this.source??(await this.request(this.url,{signal:e?.signal})).data,i="imagery-tile-layer:open-coverage-json";if("coverage"!==t.type?.toLowerCase()||"grid"!==t.domain?.domainType?.toLowerCase())throw new a.A(i,"Only coverage with Grid domain type is supported");if(!t.ranges)throw new a.A(i,"Missing ranges in the grid coverage data");if(!t.domain.referencing?.length)throw new a.A(i,"Missing domain referencing in the grid coverage data");let r=Object.values(t.ranges);for(let e=0;e<r.length;e++){let{axisNames:t,shape:s,type:n,values:l}=r[e];if(!("ndarray"===n.toLowerCase()&&l?.length&&t?.length&&s?.length))throw new a.A(i,"Only ranges with valid NdArray, axisNames, shape, and inline values are supported");if(!d(t[t.length-1])||!p(t[t.length-2]))throw new a.A(i,"Only row-major ordered pixel values are supported. X axis must be the last axis.")}return function(e){let{width:t,height:i,extent:a,dimensions:r}=m(e),{ranges:s}=e,n=Object.keys(s).sort((e,t)=>e<t?-1:1),l=[];for(let e=0;e<n.length;e++){let t=n[e];r?.length&&l.push({name:t,dimensions:r})}let o=x(e);l.forEach(e=>o[e.name]&&Object.assign(e,o[e.name]));let f=l.length?{variables:l}:void 0,u=[];for(let e=0;e<n.length;e++){let{values:a,dataType:l,axisNames:o,shape:f}=s[n[e]],h=f.length>2?e*f.slice(0,-2).reduce((e,t)=>e*t):0,d=o.slice(0,-2),p=f.slice(0,-2),m="float"===l?"f32":w(a),g=t*i,y=a.length/g;for(let s=0;s<y;s++){let n=c.A.createEmptyBand(m,g),l=new Uint8Array(g).fill(255),o=!1,f=s*g;for(let e=0;e<g;e++){let t=a[f+e];null==t?(l[e]=0,o=!0):n[e]=t}if(0===e||r?.length){let e=new c.A({width:t,height:i,mask:o?l:null,pixels:[n],pixelType:m});e.updateStatistics(),r?.length?u[I(d,p,s)+h]=e:u.push(e)}else{let e=u[s];e.pixels.push(n),o?e.mask&&=c.A.combineBandMasks([e.mask,l]):e.mask=o?l:null}}}return{extent:a,pixelBlocks:u,multidimensionalInfo:f,attributeTable:Object.values(o).find(e=>e.attributeTable)?.attributeTable,bandNames:f?void 0:n}}(t)}};(0,r.Cg)([(0,s.MZ)({type:String,json:{write:!0}})],k.prototype,"datasetFormat",void 0),(0,r.Cg)([(0,s.MZ)({constructOnly:!0})],k.prototype,"source",void 0),k=(0,r.Cg)([(0,s.$K)("esri.layers.raster.datasets.CovJSONRaster")],k);const O=k;var F=i(4576),P=i(21325),D=i(330),B=i(43163);function L(e,t){if(!e||!t)return null;let i=[];for(let a=0;a<e.length;a++)i.push(e[a]),i.push(t[a]);return i}function N(e){if(!e)return null;let t=Number(e);if(!isNaN(t)&&0!==t)return new f.A({wkid:t});if(e=String(e).trim(),(0,P.jp)(e))return new f.A({wkt2:e});let i=e.toUpperCase();if(i.startsWith("COMPD_CS")){if(!i.includes("VERTCS")||!i.includes("GEOGCS")&&!i.startsWith("PROJCS"))return null;let a=i.indexOf("VERTCS"),r=i.indexOf("PROJCS"),s=r>-1?r:i.indexOf("GEOGCS");if(-1===s)return null;let n=e.slice(s,e.lastIndexOf("]",a)+1).trim(),l=e.slice(a,e.lastIndexOf("]")).trim();t=E(n);let o=t?new f.A({wkid:t}):new f.A({wkt:n}),u=E(l);return u&&(o.vcsWkid=u),o}return i.startsWith("GEOGCS")||i.startsWith("PROJCS")?(t=E(e),0===t?new f.A({wkt:e}):new f.A({wkid:t})):null}function E(e){let t=e.replaceAll("]","[").replaceAll('"',"").split("[").map(e=>e.trim()).filter(e=>""!==e),i=t[t.length-1].split(","),a=i[0]?.toLowerCase();if(("epsg"===a||"esri"===a)&&e.endsWith('"]]')){let e=Number(i[1]);if(!isNaN(e)&&0!==e)return e}return 0}function H(e){if("pamdataset"!==e?.documentElement.tagName?.toLowerCase())return{};let t={spatialReference:null,transform:null,metadata:{},rasterBands:[],statistics:null,histograms:null};e.documentElement.childNodes.forEach(e=>{if(1===e.nodeType)if((0,D.g7)(e,"SRS")){if(!t.spatialReference){let i=(0,D.mX)(e);t.spatialReference=N(i)}}else if((0,D.g7)(e,"Metadata"))if("xml:ESRI"===e.getAttribute("domain")){let{spatialReference:i,transform:a}=function(e){let t=(0,D.V6)(e,"GeodataXform"),i=N((0,D.v7)(t,"SpatialReference/WKID")||(0,D.mX)(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:i,transform:null};let a=(0,D.v7)(t,"PolynomialOrder")??1,r=(0,D.Ui)(t,"CoeffX/Double"),s=(0,D.Ui)(t,"CoeffY/Double"),n=(0,D.Ui)(t,"InverseCoeffX/Double"),l=(0,D.Ui)(t,"InverseCoeffY/Double"),o=L(r,s),f=L(n,l);return{spatialReference:i,transform:o&&f&&o.length&&f.length?new B.A({spatialReference:i,polynomialOrder:a,forwardCoefficients:o,inverseCoefficients:f}):null}}(e);t.transform=a,t.spatialReference||=i}else(0,D.IC)(e,"MDI").forEach(e=>t.metadata[e.getAttribute("key")]=(0,D.mX)(e));else if((0,D.g7)(e,"PAMRasterBand")){let i=function(e){let t,i,a,r,s=(0,D.v7)(e,"NoDataValue"),n=(0,D.V6)(e,"Histograms/HistItem"),l=(0,D.v7)(n,"HistMin"),o=(0,D.v7)(n,"HistMax"),f=(0,D.v7)(n,"BucketCount"),u=(0,D.mX)(n,"HistCounts")?.split("|").map(e=>Number(e));(0,D.IC)(e,"Metadata/MDI").forEach(e=>{let s=Number(e.textContent??e.nodeValue);switch(e.getAttribute("key").toUpperCase()){case"STATISTICS_MINIMUM":t=s;break;case"STATISTICS_MAXIMUM":i=s;break;case"STATISTICS_MEAN":a=s;break;case"STATISTICS_STDDEV":r=s}});let h=(0,D.v7)(e,"Metadata/SourceBandIndex");return{noDataValue:s,histogram:u?.length&&null!=l&&null!=o?{min:l,max:o,size:f||u.length,counts:u}:null,sourceBandIndex:h,statistics:null!=t&&null!=i?{min:t,max:i,avg:a,stddev:r}:null}}(e);null!=i.sourceBandIndex&&null==t.rasterBands[i.sourceBandIndex]?t.rasterBands[i.sourceBandIndex]=i:t.rasterBands.push(i)}});let i=t.rasterBands;return i.length&&(t.statistics=i[0].statistics?i.map(e=>e.statistics).filter(F.Ru):null,t.histograms=i[0].histogram?i.map(e=>e.histogram).filter(F.Ru):null),t}var z=i(85951),J=i(96381);const U="image-aux-raster:open",G="The data is not a supported format.";let j=class extends n.A{set rasterJobHandler(e){this._set("rasterJobHandler",e),this._inMemoryRaster&&(this._inMemoryRaster.rasterJobHandler=e)}async fetchRawTile(e,t,i,a={}){return this._inMemoryRaster?.fetchRawTile(e,t,i,a)}async _open(e){let t,{data:i,format:r}=await this._fetchData(e),{tileGeneration:s}=this.ioConfig,n="immediate"===s||"jpg"!==r;if(n){let s=await this._decodeFullImage(i,r,e);if(!s)throw new a.A(U,"The data cannot be decoded.");t=await this._createRasterSource(s,e)}else{let r=(0,z.R)(i);if(!r)throw new a.A(U,G);t=await this._createRasterSource(r,e),t.encodedData=i}let{rasterJobHandler:l,ioConfig:o}=this,f=new R({preGenerateTiles:n,rasterJobHandler:l,source:t,ioConfig:{...o,sampling:"closest",skipStatistics:!0}});await f.open(e),this._set("rasterInfo",f.rasterInfo),this._inMemoryRaster=f}async _createRasterSource(e,t){let{spatialReference:i,statistics:a,histograms:r,transform:s}=await this._fetchAuxiliaryData(t),n=!i;n&&(i=new f.A({wkid:3857})),r?.length&&null==a&&(a=(0,S.Pg)(r));let{width:l,height:u}=e,h=new o.A({xmin:-.5,ymin:.5-u,xmax:l-.5,ymax:.5,spatialReference:i}),c=s?s.forwardTransform(h):h,d=!0;if(s){let e=s.forwardCoefficients;d=e&&0===e[1]&&0===e[2],d&&(s=null,h=c)}let p=[];return"pixels"in e&&p.push(e),{name:this.datasetName,pixelBlocks:p,imageInfo:{width:l,height:u,pixelType:"u8",bandCount:3},extent:c,nativeExtent:h,transform:s,statistics:a,histograms:r,isPseudoSpatialReference:n,keyProperties:{DataType:"Processed"}}}async _fetchData(e){let{data:t}=await this.request(this.url,{responseType:"array-buffer",signal:e?.signal}),i=(0,J.g)(t);if("jpg"!==i&&"png"!==i&&"gif"!==i&&"bmp"!==i)throw new a.A(U,G);return this._set("datasetFormat",i.toUpperCase()),{data:t,format:i}}async _decodeFullImage(e,t,i){try{return await this.decodePixelBlock(e,{format:t,canvasUsage:"canvas-only",cloneSource:!0,skipStatistics:!0},i)}catch{return(0,b.Te)(i?.signal),this.decodePixelBlock(e,{format:t,canvasUsage:"no-canvas",skipStatistics:!0},i)}}async _fetchAuxiliaryData(e){let t=e?.signal,{skipExtensions:i=[],skipMapInfo:a}=this.ioConfig,r=a||i.includes("aux.xml")?null:this.request(this.url+".aux.xml",{responseType:"xml",signal:t}),s=this.datasetFormat,n="JPG"===s?"jgw":"PNG"===s?"pgw":"BMP"===s?"bpw":null,l=a||null==n||i.includes(n)?null:this.request(this.url.slice(0,this.url.lastIndexOf("."))+"."+n,{responseType:"text",signal:t}),o=await(0,b.Lx)([r,l]);if(t?.aborted)throw(0,b.NK)();let f=H(o[0].value?.data);if(!f.transform){let e=o[1].value?o[1].value.data.split("\n").slice(0,6).map(e=>Number(e)):null;f.transform=6===e?.length?new B.A({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return f}};(0,r.Cg)([(0,s.MZ)({type:String,json:{write:!0}})],j.prototype,"datasetFormat",void 0),(0,r.Cg)([(0,s.MZ)()],j.prototype,"rasterJobHandler",null),j=(0,r.Cg)([(0,s.$K)("esri.layers.raster.datasets.ImageAuxRaster")],j);const q=j;var W=i(97768),V=i(84952),Z=i(86738),$=i(75414),X=i(20223),K=i(87045),Y=i(25943),Q=i(82371);let ee=class extends n.A{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,a={}){let{storageInfo:r,extent:s}=this.rasterInfo,{transposeInfo:n}=r,l=null!=n&&!!a.transposedVariableName;if(this._slices&&!l&&null==a.sliceId)return null;let o,f,u=l?0:r.maximumPyramidLevel-e+this._levelOffset,h=`${this.url}/tile/${u}/${t}/${i}`,c={...this._slices?l?{variable:a.transposedVariableName}:{sliceId:a.sliceId||0}:null,...a.refreshParameters};if(r.isBsqTile){let e=(a.bandIds?.length?a.bandIds:[0,1,2]).map(e=>this.request(h,{query:{...c,bandId:e},responseType:"array-buffer",signal:a.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(i);f=[];let s=0;for(let{data:e}of t)f.push(s),r.set(new Uint8Array(e),s),s+=e.byteLength;o=r.buffer}else o=(await this.request(h,{query:c,responseType:"array-buffer",signal:a.signal})).data;if(!o)return null;let{tileInfo:d}=r,p=l?n.tileSize:d.size,m=/^(mixed|jp)/i.test(d.format),g=await this.decodePixelBlock(o,{width:p[0],height:p[1],planes:f?.length,offsets:f,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:l,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:m},{signal:a.signal});if(null==g)return null;let y=r.blockBoundary[e];if("jpg"!==r.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return g;let{origin:x,blockWidth:w,blockHeight:I}=r,{x:b,y:C}=this.getPyramidPixelSize(e),S=Math.round((s.xmin-x.x)/b)%w,A=Math.round((s.xmax-x.x)/b)%w||w,T=Math.round((x.y-s.ymax)/C)%I,_=Math.round((x.y-s.ymin)/C)%I||I,R=i===y.minCol?S:0,M=t===y.minRow?T:0,k=i===y.maxCol?A:w,O=t===y.maxRow?_:I;return(0,v.z$)(g,{x:R,y:M},{width:k-R,height:O-M}),g}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;let t=e;for(let e=0;e<this._slices.length;e++){let i=this._slices[e].multidimensionalDefinition;if(i.length===t.length&&!i.some(e=>{let i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!i||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),a=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),r=await Promise.all([i,a]);return r[0]&&r[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let a=0,{maximumPyramidLevel:r}=this.rasterInfo.storageInfo,s=r-a+this._levelOffset,n=i.srcLocation;for(;s>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(s,i.row,i.col,t))break}catch{}if(s--,a++,i=this.identifyPixelLocation(n,a,t.datumTransformation),null===i)return null}return-1===s||null==i?null:a}async _open(e){let t=e?.signal,i=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:t});i.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));let r=i.data;if(this.sourceJSON=r,!r)throw new a.A("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!r.tileInfo)throw new a.A("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();this.tileType=r.cacheType,this.tileType??=["jpg","jpeg","png","png8","png24","png32","mixed"].includes(r.tileInfo.format.toLowerCase())?"Map":"lerc"===r.tileInfo.format.toLowerCase()?"Elevation":"Raster",this.datasetName=r.name?.slice(r.name.indexOf("/")+1)??"";let s=this.rasterInfo??await this._fetchRasterInfo({signal:t});if(null==s)throw new a.A("image-server-raster:open","cannot initialize image service");(0,Q.E9)(s,r);let n="Map"===this.tileType?function(e,t){if(!e)return null;let{minScale:i,maxScale:a,minLOD:r,maxLOD:s}=t;if(null!=r&&null!=s)return K.A.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=r&&e<=s)});if(0!==i&&0!==a){let t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,s=a?t(a):-1/0;return K.A.fromJSON({...e,lods:e.lods.filter(e=>{let i=t(e.scale);return i<=r&&i>=s})})}return K.A.fromJSON(e)}(r.tileInfo,r):K.A.fromJSON(r.tileInfo);(0,W.Lw)(n);let[l,o]=this._computeMinMaxLOD(s,n),{extent:f,pixelSize:u}=s,h=.001*Math.min(u.x,u.y);(u.x!==u.y||Math.abs(l.resolution-u.x)>h)&&(u.x=u.y=l.resolution,s.width=Math.ceil((f.xmax-f.xmin)/u.x-.1),s.height=Math.ceil((f.ymax-f.ymin)/u.y-.1));let c=l.level-o.level,[d,p]=n.size,m=[],g=[],{lods:y}=n;y.forEach((e,t)=>{e.level>=o.level&&e.level<=l.level&&m.push({x:e.resolution,y:e.resolution}),t<y.length-1&&g.push(Math.round(10*e.resolution/y[t+1].resolution)/10)}),m.sort((e,t)=>e.x-t.x);let x,w=this.computeBlockBoundary(f,d,p,n.origin,m,c),I=m.length>1?m.slice(1):null;r.transposeInfo&&(x={tileSize:[r.transposeInfo.rows,r.transposeInfo.cols],packetSize:s.keyProperties?._yxs.PacketSize??0});let b=g.length<=1||g.length>=3&&g.slice(0,-1).every(e=>e===g[0])?g[0]??2:Math.round(10/(o.resolution/l.resolution)**(-1/c))/10,C=!!r.bsq&&"Raster"===this.tileType;if(s.storageInfo=new X.A({blockWidth:n.size[0],blockHeight:n.size[1],pyramidBlockWidth:n.size[0],pyramidBlockHeight:n.size[1],pyramidResolutions:I,pyramidScalingFactor:b,compression:n.format,origin:n.origin,firstPyramidLevel:1,maximumPyramidLevel:c,tileInfo:n,isBsqTile:C,transposeInfo:x,blockBoundary:w}),function(e){let{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new $.A,e.extent=e.transform.forwardTransform(t))}(s),this._set("rasterInfo",s),r.capabilities.toLowerCase().includes("tilemap")){let e={tileInfo:s.storageInfo.tileInfo,parsedUrl:(0,V.An)(this.url),url:this.url,tileServers:[]};this._tilemapCache=new Y.d({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if("Map"===this.tileType){let e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),a=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=f.A.fromJSON(t.spatialReference||e.spatialReference),s=new Z.A({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new T.A({width:i,height:a,bandCount:3,extent:o.A.fromJSON(e),spatialReference:r,pixelSize:s,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}let i={...e,query:{...this.ioConfig.customFetchParameters,f:"json"}},a=(0,Q.Tw)(this.url,this.sourceJSON,i),r=t.hasMultidimensions?this.request(`${this.url}/slices`,i).then(e=>e.data?.slices).catch(()=>null):null,s=await Promise.all([a,r]);return this._slices=s[1],s[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:i}=e,a=.5/e.width*i.x,{lods:r}=t,s=t.lodAt(Math.max.apply(null,r.map(e=>e.level))),n=t.lodAt(Math.min.apply(null,r.map(e=>e.level))),{tileType:l}=this;if("Map"===l)return this._levelOffset=r[0].level,[s,n];if("Raster"===l)return[r.find(e=>e.resolution===i.x)??s,n];let{minScale:o,maxScale:f}=this.sourceJSON,u=s;f>0&&(u=r.find(e=>Math.abs(e.scale-f)<a),u||=r.filter(e=>e.scale>f).sort((e,t)=>e.scale>t.scale?1:-1)[0]??s);let h=n;return o>0&&(h=r.find(e=>Math.abs(e.scale-o)<a)??n,this._levelOffset=h.level-n.level),[u,h]}};(0,r.Cg)([(0,s.MZ)({type:String,json:{write:!0}})],ee.prototype,"datasetFormat",void 0),(0,r.Cg)([(0,s.MZ)()],ee.prototype,"tileType",void 0),ee=(0,r.Cg)([(0,s.$K)("esri.layers.raster.datasets.ImageServerRaster")],ee);const te=ee;var ie=i(10713);const ae=new Map([["byte","u8"],["signedbyte","s8"],["int8","s8"],["uint8","u8"],["int16","s16"],["uint16","u16"],["int32","s32"],["uint32","u32"],["float32","f32"],["float64","f64"],["double64","f64"]]),re=new Map;re.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),re.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),re.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),re.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"}),re.set("qb3",{blobExtension:".pq3",isOneSegment:!0,decoderFormat:"qb3"});let se=class extends n.A{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat="MRF"}async fetchRawTile(e,t,i,a={}){let{blockWidth:r,blockHeight:s,blockBoundary:n}=this.rasterInfo.storageInfo,l=n[e];if(!l||l.maxRow<t||l.maxCol<i||l.minRow>t||l.minCol>i)return null;let{bandCount:o,pixelType:f}=this.rasterInfo,{ranges:u,actualTileWidth:h,actualTileHeight:d}=this._getTileLocation(e,t,i);if(!u||0===u.length)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(r*s);return new c.A({width:r,height:s,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,m=this._getBandSegmentCount(),g=[],y=0;for(y=0;y<m;y++)(!p||p.includes(y))&&g.push(this.request(this._files.data,{range:{from:u[y].from,to:u[y].to},responseType:"array-buffer",signal:a.signal}));let x=await Promise.all(g),w=x.map(e=>e.data.byteLength).reduce((e,t)=>e+t),I=new Uint8Array(w),b=[],C=0;for(y=0;y<m;y++)b.push(C),I.set(new Uint8Array(x[y].data),C),C+=x[y].data.byteLength;let v=re.get(this.rasterInfo.storageInfo.compression).decoderFormat,S="jpg"===v&&4===o&&1===b.length,A=await this.decodePixelBlock(I.buffer,{width:r,height:s,format:v,planes:p?.length||o,offsets:b,pixelType:f,canvasUsage:S?"no-canvas":void 0,decodeJpegAsRgb:!1},{signal:a.signal});if(null==A)return null;let{noDataValue:T}=this.rasterInfo;if(null!=T&&"lerc"!==v&&!A.mask&&(T=T[0],null!=T)){let e=A.width*A.height,t=new Uint8Array(e);if(Math.abs(T)>1e24)for(y=0;y<e;y++)Math.abs((A.pixels[0][y]-T)/T)>1e-6&&(t[y]=1);else for(y=0;y<e;y++)A.pixels[0][y]!==T&&(t[y]=1);A.mask=t}let _=0,R=0;if(h!==r||d!==s){let e=A.mask;if(e)for(y=0;y<s;y++)if(R=y*r,y<d)for(_=h;_<r;_++)e[R+_]=0;else for(_=0;_<r;_++)e[R+_]=0;else for(e=new Uint8Array(r*s),A.mask=e,y=0;y<d;y++)for(R=y*r,_=0;_<h;_++)e[R+_]=1}return A}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);let t=e?e.signal:null,i=await this.request(this.url,{responseType:"xml",signal:t}),{rasterInfo:a,files:r}=this._parseHeader(i.data),{skipMapInfo:s,skipExtensions:n=[]}=this.ioConfig;if(!n.includes("aux.xml")&&!s){let t=await this._fetchAuxiliaryData(e);null!=t&&(a.statistics=t.statistics??a.statistics,a.histograms=t.histograms,t.histograms&&null==a.statistics&&(a.statistics=(0,S.Pg)(t.histograms)))}s&&this.updateImageSpaceRasterInfo(a),this._set("rasterInfo",a),this._files=r;let l=await this.request(r.index,{responseType:"array-buffer",signal:t});this._storageIndex=function(e){if(e.byteLength%16>0)throw Error("invalid array buffer must be multiples of 16");let t;if(ie.Z){let i=new Uint8Array(e),a=new ArrayBuffer(e.byteLength),r=new Uint8Array(a);for(let t=0;t<e.byteLength/4;t++)for(let e=0;e<4;e++)r[4*t+e]=i[4*t+3-e];t=new Uint32Array(a)}else t=new Uint32Array(e);return t}(l.data);let{blockWidth:o,blockHeight:f}=this.rasterInfo.storageInfo,u=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:h,height:c}=this.rasterInfo,d=[],p=this._getBandSegmentCount(),m=0,g=-1;for(;m<this._storageIndex.length;){g++;let e=Math.ceil(h/o/u**g)-1,t=Math.ceil(c/f/u**g)-1;m+=(e+1)*(t+1)*p*4,d.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=d,g>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=g),this.updateTileInfo()}_getBandSegmentCount(){return this._isBsq?this.rasterInfo.bandCount:1}_getTileLocation(e,t,i){let a,r,s,{blockWidth:n,blockHeight:l,pyramidScalingFactor:o}=this.rasterInfo.storageInfo,{width:f,height:u}=this.rasterInfo,h=this._getBandSegmentCount(),c=0,d=0;for(s=0;s<e;s++)d=o**s,a=Math.ceil(f/n/d),r=Math.ceil(u/l/d),c+=a*r;d=o**e,a=Math.ceil(f/n/d),r=Math.ceil(u/l/d),c+=t*a+i,c*=4*h;let p=this._storageIndex.subarray(c,c+4*h),m=0,g=0,y=[];for(let e=0;e<h;e++)m=p[4*e]*2**32+p[4*e+1],g=m+p[4*e+2]*2**32+p[4*e+3]-1,y.push({from:m,to:g});return{ranges:y,actualTileWidth:i<a-1?n:Math.ceil(f/d)-n*(a-1),actualTileHeight:t<r-1?l:Math.ceil(u/d)-l*(r-1)}}_parseHeader(e){let t=(0,D.V6)(e,"MRF_META/Raster");if(!t)throw new a.A("mrf:open","not a valid MRF format");let i=(0,D.V6)(t,"Size"),r=parseInt(i.getAttribute("x"),10),s=parseInt(i.getAttribute("y"),10),n=parseInt(i.getAttribute("c"),10),l=((0,D.mX)(t,"Compression")||"none").toLowerCase();if(!re.has(l))throw new a.A("mrf:open","currently does not support compression "+l);let u=(0,D.mX)(t,"DataType")||"UInt8",h=ae.get(u.toLowerCase());if(null==h)throw new a.A("mrf:open","currently does not support pixel type "+u);let c=(0,D.V6)(t,"PageSize"),d=parseInt(c.getAttribute("x"),10),p=parseInt(c.getAttribute("y"),10),m=c.getAttribute("c"),g=m?m===String(n):re.get(l).isOneSegment;this._isBsq=!g;let y,x=(0,D.V6)(t,"DataValues");if(x){let e=x.getAttribute("NoData");null!=e&&(y=e.trim().split(" ").map(e=>parseFloat(e)))}if((0,D.V6)(e,"MRF_META/CachedSource"))throw new a.A("mrf:open","currently does not support MRF referencing other data files");let w,I=(0,D.V6)(e,"MRF_META/GeoTags"),b=(0,D.V6)(I,"BoundingBox"),C=!1;if(null!=b){let e=parseFloat(b.getAttribute("minx")),t=parseFloat(b.getAttribute("miny")),i=parseFloat(b.getAttribute("maxx")),a=parseFloat(b.getAttribute("maxy")),r=(0,D.mX)(I,"Projection")||"",s=f.A.WGS84;if("LOCAL_CS[]"!==r)if(r.toLowerCase().startsWith("epsg:")){let e=Number(r.slice(5));!isNaN(e)&&0!==e&&(s=new f.A({wkid:e}))}else s=N(r)??f.A.WGS84;else C=!0,s=new f.A({wkid:3857});w=new o.A(e,t,i,a),w.spatialReference=s}else C=!0,w=new o.A({xmin:-.5,ymin:.5-s,xmax:r-.5,ymax:.5,spatialReference:new f.A({wkid:3857})});let v=(0,D.V6)(e,"MRF_META/Rsets"),S=parseInt(v?.getAttribute("scale")||"2",10),A=w.spatialReference,_=new X.A({origin:new Z.A({x:w.xmin,y:w.ymax,spatialReference:A}),blockWidth:d,blockHeight:p,pyramidBlockWidth:d,pyramidBlockHeight:p,compression:l,pyramidScalingFactor:S}),R=new Z.A({x:w.width/r,y:w.height/s,spatialReference:A}),M=new T.A({width:r,height:s,extent:w,isPseudoSpatialReference:C,spatialReference:A,bandCount:n,pixelType:h,pixelSize:R,noDataValue:y,storageInfo:_}),k=this._getAuxFullPath((0,D.mX)(t,"DataFile")),O=this._getAuxFullPath((0,D.mX)(t,"IndexFile"));return{rasterInfo:M,files:{mrf:this.url,index:O||this.url.replace(".mrf",".idx"),data:k||this.url.replace(".mrf",re.get(l).blobExtension)}}}_getAuxFullPath(e){return!e||e.includes("\\")?null:e.includes("/")?e.startsWith(new URL(this.url).origin)?e:null:`${this.url.slice(0,this.url.lastIndexOf("/"))}/${e}`}async _fetchAuxiliaryData(e){try{let{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return H(t)}catch{return null}}};(0,r.Cg)([(0,s.MZ)()],se.prototype,"_files",void 0),(0,r.Cg)([(0,s.MZ)()],se.prototype,"_storageIndex",void 0),(0,r.Cg)([(0,s.MZ)()],se.prototype,"_isBsq",void 0),(0,r.Cg)([(0,s.MZ)({type:String,json:{write:!0}})],se.prototype,"datasetFormat",void 0),se=(0,r.Cg)([(0,s.$K)("esri.layers.raster.datasets.MRFRaster")],se);const ne=se;i(44208);var le=i(53966),oe=i(9334);function fe(e){let t=e.fields,i=e.records,a=t.some(e=>"oid"===e.name.toLowerCase())?"OBJECTID":"OID",r=[{name:a,type:"esriFieldTypeOID",alias:"OID"}].concat(t.map(e=>({name:e.name,type:"esriFieldType"+e.typeName,alias:e.name}))),s=r.map(e=>e.name),n=[],l=0,o=0;return i.forEach(e=>{let t={};for(t[a]=l++,o=1;o<s.length;o++)t[s[o]]=e[o-1];n.push({attributes:t})}),{displayFieldName:"",fields:r,features:n}}function ue(e){let t=new DataView(e),i=3&t.getUint8(0);if(3!==i)return{header:{version:i},recordSet:null};let a=t.getUint32(4,!0),r=t.getUint16(8,!0),s=t.getUint16(10,!0),n={version:i,recordCount:a,headerByteCount:r,recordByteCount:s},l=32,o=[],f=[];for(;13!==t.getUint8(l);){let i=String.fromCharCode(t.getUint8(l+11)).trim();o.push({name:(0,oe.w)(new Uint8Array(e,l,11)),type:i,typeName:["String","Date","Double","Boolean","String","Integer"][["C","D","F","L","M","N"].indexOf(i)],length:t.getUint8(l+16)}),l+=32}if(l+=1,o.length>0)for(;f.length<a&&e.byteLength-l>s;){let i=[];32===t.getUint8(l)?(l+=1,o.forEach(t=>{if("C"===t.type)i.push((0,oe.w)(new Uint8Array(e,l,t.length)).trim());else if("N"===t.type)i.push(parseInt(String.fromCharCode.apply(null,new Uint8Array(e,l,t.length)).trim(),10));else if("F"===t.type)i.push(parseFloat(String.fromCharCode.apply(null,new Uint8Array(e,l,t.length)).trim()));else if("D"===t.type){let a=String.fromCharCode.apply(null,new Uint8Array(e,l,t.length)).trim();i.push(new Date(parseInt(a.slice(0,4),10),parseInt(a.slice(4,6),10)-1,parseInt(a.slice(6,8),10)))}l+=t.length}),f.push(i)):l+=s}return{header:n,fields:o,records:f,recordSet:fe({fields:o,records:f})}}var he=i(44094),ce=i(94213);const de="none-tiled tiff is not optimized for access, convert to COG and retry.";let pe=class extends n.A{constructor(){super(...arguments),this._bufferSize=1048576,this._chunkSize=10485760,this._fileSize=-1,this._headerChunks=[],this.datasetFormat="TIFF",this.headerInfo=null}async fetchRawTile(e,t,i,a={}){if(!this.headerInfo?.isSupported||this.isBlockOutside(e,t,i))return null;let r=await this._fetchRawTiffTile(e,t,i,!1,a);if(null!=r&&this.headerInfo.hasMaskBand){let s=await this._fetchRawTiffTile(e,t,i,!0,a);null!=s&&s.pixels[0]instanceof Uint8Array&&(r.mask=s.pixels[0])}return r}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1,this.url.lastIndexOf(".")),await this._readHeader(e?.signal),await this._fetchAllAuxData(),this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(this.rasterInfo),this.updateTileInfo()}async _readHeader(e){try{let t=await this._fetchHeaderData(0,this._bufferSize,e);if(!t)throw new a.A("tiffraster:open","failed to open url "+this.url);let{littleEndian:i,firstIFDPos:r,isBigTiff:s}=(0,he.uT)(t),n=[],l={fileChunk:t,posIFD:r,fileOffset:0};await this._readIFDs(n,l,i,s?8:4,e);let{imageInfo:u,rasterInfo:h}=function(e){let t=(0,he.uc)(e),{width:i,height:a,tileWidth:r,tileHeight:s,planes:n,pixelType:l,compression:u,firstPyramidLevel:h,maximumPyramidLevel:c,pyramidBlockWidth:d,pyramidBlockHeight:p,pyramidResolutions:m,tileBoundary:g,affine:y,metadata:x,colormap:w}=t,I=N(t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid),b=!!t.isPseudoGeographic;I??=(b=!0,new f.A({wkid:3857}));let C=new o.A({...t.extent,spatialReference:I}),v=C?new Z.A({x:C.xmin,y:C.ymax,spatialReference:I}):new Z.A({x:0,y:0}),S=new X.A({blockWidth:r,blockHeight:s,pyramidBlockWidth:d,pyramidBlockHeight:p,compression:u,origin:v,firstPyramidLevel:h,maximumPyramidLevel:c,pyramidResolutions:m,blockBoundary:g}),A=new Z.A({x:(C.xmax-C.xmin)/i,y:(C.ymax-C.ymin)/a,spatialReference:I}),_=x?{BandProperties:x.bandProperties,DataType:x.dataType}:{},R=new T.A({width:i,height:a,bandCount:n,pixelType:l,pixelSize:A,storageInfo:S,spatialReference:I,isPseudoSpatialReference:b,keyProperties:_,extent:C,colormap:w,statistics:x?x.statistics:null});if(y?.length&&(R.nativeExtent=new o.A({xmin:-.5,ymin:.5-a,xmax:i-.5,ymax:.5,spatialReference:I}),R.transform=new B.A({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),R.extent=R.transform.forwardTransform(R.nativeExtent),R.pixelSize=new Z.A({x:(C.xmax-C.xmin)/i,y:(C.ymax-C.ymin)/a,spatialReference:I}),S.origin.x=-.5,S.origin.y=.5),m){let{x:e,y:t}=R.pixelSize;m.forEach(i=>{i.x*=e,i.y*=t})}return{imageInfo:t,rasterInfo:R}}(n),c=(0,he.zS)(n),d=(0,he.r9)(n);this.headerInfo={littleEndian:i,isBigTiff:s,ifds:n,pyramidIFDs:c,maskIFDs:d,...u},this._set("rasterInfo",h),this._validateHeader()}finally{this._headerChunks.length=0}}_validateHeader(){let e=this.headerInfo;if(!e.isSupported)throw new a.A("tiffraster:open","this tiff is not supported: "+e.message);if(!e.tileWidth||!e.tileHeight)throw new a.A("tiffraster:open",de);this.rasterInfo.isPseudoSpatialReference&&le.A.getLogger(this).warn("The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.");let t=e.ifds[0],i=t.get("PREDICTOR")?.values?.[0];if(3===t.get("SAMPLEFORMAT")?.values?.[0]&&2===i)throw new a.A("tiffraster:open","unsupported horizontal difference encoding. Predictor=3 is supported for floating point data")}async _fetchHeaderData(e,t,i){let r=this._getCachedHeaderData(e,t);if(r)return r;let s=Math.floor(e/this._bufferSize)*this._bufferSize,n=s+Math.max(1,Math.ceil((t-s)/this._bufferSize))*this._bufferSize,l=this._getMissingHeaderRanges(s,n).map(async e=>{let{from:t,to:a}=e,r=await this._fetchOffsets(t,a,i),s=this._fileSize;return{chunk:r,fileOffset:t,isEOF:s>0?t+r.byteLength>=s:r.byteLength<a-t+1}}),o=await Promise.all(l);this._headerChunks.push(...o),this._headerChunks.sort((e,t)=>e.fileOffset-t.fileOffset);let f=this._getCachedHeaderData(e,t);if(!f)throw new a.A("tiffraster:open",`failed to fetch byte range ${e}-${t} from ${this.url}`);return f}_getCachedHeaderData(e,t){let i=[],a=e;for(let{chunk:r,fileOffset:s,isEOF:n}of this._headerChunks){if(s+r.byteLength-1<a)continue;if(s>a)return null;let l=a-s,o=Math.min(t-s+1,r.byteLength);if(i.push({chunk:r,start:l,end:o}),a=s+o,a>t||n&&o===r.byteLength){let t=new Uint8Array(a-e),r=0;for(let e of i){let i=new Uint8Array(e.chunk,e.start,e.end-e.start);t.set(i,r),r+=i.byteLength}return t.buffer}}return null}_getMissingHeaderRanges(e,t){let i=[],a=(e,t)=>{let a=Math.floor(e/this._bufferSize)*this._bufferSize,r=Math.ceil(t/this._bufferSize)*this._bufferSize;i.push({from:a,to:r})},r=e;for(let{chunk:e,fileOffset:s,isEOF:n}of this._headerChunks){let l=s+e.byteLength-1;if(!(l<r)&&(s>r&&a(r,Math.min(s-1,t)),r=Math.max(r,l+1),r>t||n))return i}return r<=t&&a(r,t),i}async _validateOrFetchHeaderBuffer(e,t){let{fileChunk:i,fileOffset:r,posIFD:s}=e;if(s+8>=i.byteLength||s<0){if(r=s+r,r<0)throw new a.A("tiffraster:open",`invalid IFD position ${r}. failed to open url ${this.url}`);i=await this._fetchHeaderData(r,r+this._bufferSize/2,t),s=0}return{fileChunk:i,fileOffset:r,posIFD:s}}async _readIFDs(e,t,i,r=4,s){if(!t.posIFD)return null;t=await this._validateOrFetchHeaderBuffer(t,s);let n=await this._readIFD(t,i,ce.NB,r,s);if(!n?.ifd)throw new a.A("tiffraster:open","cannot parse tiff header. failed to open url "+this.url);if(e.push(n.ifd),!n.nextIFD)return null;t.posIFD=n.nextIFD-t.fileOffset,await this._readIFDs(e,t,i,r,s)}async _readIFD(e,t,i=ce.NB,r=4,s){let{fileChunk:n,posIFD:l,fileOffset:o}=e;if(!e.fileChunk)return null;let f=(0,he.JM)(n,t,l,o,i,r);if(f.success){let{ifd:e}=f;if(!e)throw new a.A("tiffraster:open","cannot parse tiff header. failed to open url "+this.url);if(!(this.ioConfig.loadFullMetadata||i!==ce.NB||e.has("TILEWIDTH")&&e.has("TILELENGTH")))throw new a.A("tiffraster:open",de);let r=[];e.forEach(e=>{e.values||r.push(e)}),r.length>0&&await this._fillOffsets(r,t,f.nextIFD,s),(0,he.fM)(e),(0,he.h_)(e);for(let[i,a]of ce.RR){let r=e.get(i),f=null!=r?.data&&Array.from(r.data.values()).some(e=>null==e.values&&null!=e.offlineOffsetSize);if(r&&(!r.data||f)){l=r.valueOffset-o;let e=await this._validateOrFetchHeaderBuffer({fileChunk:n,posIFD:l,fileOffset:o},s);r.data=(await this._readIFD(e,t,a,4,s))?.ifd}}return f}return f.requiredBufferSize?(n=await this._fetchHeaderData(o,o+l+f.requiredBufferSize+8,s),n.byteLength<l+f.requiredBufferSize?null:(e.fileChunk=n,e.fileOffset=o,this._readIFD(e,t,i,r,s))):null}async _fillOffsets(e,t,i,a){let r=e.filter(e=>null!=e.offlineOffsetSize);if(0===r.length)return;let s=r.map(e=>e.offlineOffsetSize),n=Math.min.apply(null,s.map(e=>e[0])),l=Math.max.apply(null,s.map(e=>e[0]+e[1])),o=1===s.length||l-n<=this._bufferSize;if(!o&&s.length>1&&(s.sort((e,t)=>e[0]-t[0]),o=s.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,s[0][0])===l),o){let e=Math.max(l,n+this._bufferSize/4),i=await this._fetchHeaderData(n,e,a);return void r.forEach(e=>(0,he.Cr)(i,t,e,n))}let f=r.map(async e=>{let i=e.offlineOffsetSize,r=await this._fetchHeaderData(i[0],i[1]+i[0],a);(0,he.Cr)(r,t,e,i[0])});await Promise.all(f)}async _fetchOffsets(e,t,i){let a=[],r=this._chunkSize;this._fileSize>0&&(t=Math.min(t,this._fileSize-1));let s=Math.ceil((t-e+1)/r),n=e;for(let e=0;e<s;e++)a.push(this.request(this.url,{range:{from:n,to:e===s-1?t:n+r-1},responseType:"array-buffer",signal:i})),n+=r;let l=await Promise.all(a);if(-1===this._fileSize&&206===l[0].httpStatus){let e=l[0].getHeader?.("Content-Range"),t=Number(e?.split("/")[1]);Number.isFinite(t)&&(this._fileSize=t)}if(1===l.length)return l[0].data;let o=l.reduce((e,t)=>e+t.data.byteLength,0),f=new Uint8Array(o),u=0;for(let e of l)f.set(new Uint8Array(e.data),u),u+=e.data.byteLength;return f.buffer}async _fetchRawTiffTile(e,t,i,a,r={}){let s=this._getTileLocation(e,t,i,a);if(!s)return null;let{ranges:n,actualTileWidth:l,actualTileHeight:o,ifd:f}=s,u=n.map(e=>this.request(this.url,{range:e,responseType:"array-buffer",signal:r.signal})),h=await Promise.all(u),c=h.map(e=>e.data.byteLength).reduce((e,t)=>e+t),d=1===h.length?h[0].data:new ArrayBuffer(c),p=[0],m=[0];if(h.length>1){let e=new Uint8Array(d);for(let t=0,i=0;t<h.length;t++){let a=h[t].data;e.set(new Uint8Array(a),i),p[t]=i,i+=a.byteLength,m[t]=a.byteLength}}let{blockWidth:g,blockHeight:y}=this.getBlockWidthHeight(e),x=await this.decodePixelBlock(d,{format:"tiff",customOptions:{headerInfo:this.headerInfo,ifd:f,offsets:p,sizes:m},width:g,height:y,planes:null,pixelType:null},{signal:r.signal});if(null==x)return null;if(l!==g||o!==y){let e=x.mask;if(e)for(let t=0;t<y;t++){let i=t*g;if(t<o)for(let t=l;t<g;t++)e[i+t]=0;else for(let t=0;t<g;t++)e[i+t]=0}else{e=new Uint8Array(g*y),x.mask=e;for(let t=0;t<o;t++){let i=t*g;for(let t=0;t<l;t++)e[i+t]=1}}}return x}_getTileLocation(e,t,i,a=!1){let{firstPyramidLevel:r,blockBoundary:s}=this.rasterInfo.storageInfo,n=0===e?0:e-(r-1),{headerInfo:l}=this;if(!l)return null;let o=a?l.maskIFDs[n]:0===n?l.ifds[0]:l.pyramidIFDs[n-1];if(!o)return null;let f=(0,he.XO)(o,l),u=(0,he.wc)(o,"TILEOFFSETS"),h=(0,he.wc)(o,"TILEBYTECOUNTS");if(!u?.length||!h?.length)return null;let{minRow:c,minCol:d,maxRow:p,maxCol:m}=s[n];if(t>p||i>m||t<c||i<d)return null;let g=(0,he.LZ)(o,"IMAGEWIDTH"),y=(0,he.LZ)(o,"IMAGELENGTH"),x=(0,he.LZ)(o,"TILEWIDTH"),w=(0,he.LZ)(o,"TILELENGTH"),I=[];if(f){let{bandCount:e}=this.rasterInfo;for(let a=0;a<e;a++){let e=a*(p+1)*(m+1)+t*(m+1)+i;I[a]={from:u[e],to:u[e]+h[e]-1}}}else{let e=t*(m+1)+i;I.push({from:u[e],to:u[e]+h[e]-1})}for(let e=0;e<I.length;e++)if(null==I[e].from||!I[e].to||I[e].to<0)return null;return{ranges:I,ifd:o,actualTileWidth:i===m&&g%x||x,actualTileHeight:t===p&&y%w||w}}async _fetchAllAuxData(e){if(this.ioConfig.skipMapInfo)return;let{rasterInfo:t}=this,{skipExtensions:i=[]}=this.ioConfig,a=i.includes("aux.xml")?Promise.resolve(null):this._fetchAuxiliaryMetaData(e),r=i.includes("vat.dbf")||1!==t.bandCount||"u8"!==t.pixelType?Promise.resolve(null):this._fetchAuxiliaryTable(e),[s,n]=await Promise.all([a,r]);null!=s&&function(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&null==t.statistics&&(t.statistics=(0,S.Pg)(e.histograms)),e.transform&&null==t.transform){t.transform=e.transform,t.nativeExtent=t.extent;let i=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new Z.A({x:(i.xmax-i.xmin)/t.width,y:(i.ymax-i.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=i}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}(s,t),null!=n&&(t.attributeTable=n,t.keyProperties.DataType="thematic")}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return H(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+".vat.dbf",{responseType:"array-buffer",signal:e?.signal}),i=ue(t);return i?.recordSet?M.A.fromJSON(i.recordSet):null}catch{return null}}};(0,r.Cg)([(0,s.MZ)()],pe.prototype,"_bufferSize",void 0),(0,r.Cg)([(0,s.MZ)()],pe.prototype,"_chunkSize",void 0),(0,r.Cg)([(0,s.MZ)()],pe.prototype,"_fileSize",void 0),(0,r.Cg)([(0,s.MZ)()],pe.prototype,"_headerChunks",void 0),(0,r.Cg)([(0,s.MZ)({type:String,json:{write:!0}})],pe.prototype,"datasetFormat",void 0),(0,r.Cg)([(0,s.MZ)()],pe.prototype,"headerInfo",void 0),pe=(0,r.Cg)([(0,s.$K)("esri.layers.raster.datasets.TIFFRaster")],pe);const me=pe,ge=new Map;ge.set("MRF",{desc:"Meta Raster Format",constructor:ne}),ge.set("TIFF",{desc:"GeoTIFF",constructor:me}),ge.set("RasterTileServer",{desc:"Raster Tile Server",constructor:te}),ge.set("JPG",{desc:"JPG Raster Format",constructor:q}),ge.set("PNG",{desc:"PNG Raster Format",constructor:q}),ge.set("GIF",{desc:"GIF Raster Format",constructor:q}),ge.set("BMP",{desc:"BMP Raster Format",constructor:q}),ge.set("CovJSON",{desc:"COVJSON Raster Format",constructor:O}),ge.set("MEMORY",{desc:"In Memory Raster Format",constructor:R});class ye{static get supportedFormats(){let e=new Set;return ge.forEach((t,i)=>e.add(i)),e}static async open(e){let{url:t,ioConfig:i,source:r,sourceJSON:s}=e,n=e.datasetFormat??i?.datasetFormat;n??(t.includes(".")?n=t.slice(t.lastIndexOf(".")+1).toUpperCase():"coverage"===r?.type?.toLowerCase()?n="CovJSON":r?.extent&&r.pixelblocks&&(n="MEMORY")),"OVR"===n||"TIF"===n||"DM"===n?n="TIFF":"JPG"===n||"JPEG"===n||"JFIF"===n?n="JPG":"COVJSON"===n&&(n="CovJSON"),t.toLowerCase().includes("/imageserver")&&!t.toLowerCase().includes("/wcsserver")&&(n="RasterTileServer");let l={url:t,source:r,sourceJSON:s,datasetFormat:n,ioConfig:i??{bandIds:null,sampling:null}};if(Object.keys(l).forEach(e=>{l[e]??delete l[e]}),n){if(!this.supportedFormats.has(n))throw new a.A("rasterfactory:open","not a supported format "+n);if("CRF"===n)throw new a.A("rasterfactory:open",`cannot open raster: ${t}`);let i=new(0,ge.get(n).constructor)(l);return i.rasterJobHandler=e.rasterJobHandler,i.rasterInfo=e.rasterInfo,await i.open({signal:e.signal}),i}let o=Array.from(ge.keys()).filter(e=>"CovJSON"!==e&&"Memory"!==e),f=0,u=()=>{if(n=o[f++],!n||"CRF"===n)return null;let t=new(0,ge.get(n).constructor)(l);return t.rasterJobHandler=e.rasterJobHandler,t.open({signal:e.signal}).then(()=>t).catch(()=>u())};return u()}static register(e,t,i){ge.has(e.toUpperCase())||ge.set(e.toUpperCase(),{desc:t,constructor:i})}}},10333(e,t,i){i.d(t,{A:()=>n});var a=i(32198),r=i(25482),s=i(91429);let n=class extends r.o{get affectsPixelSize(){return!1}forwardTransform(e){return e}inverseTransform(e){return e}};(0,a.Cg)([(0,s.MZ)()],n.prototype,"affectsPixelSize",null),(0,a.Cg)([(0,s.MZ)({json:{write:!0}})],n.prototype,"spatialReference",void 0),n=(0,a.Cg)([(0,s.$K)("esri.layers.raster.transforms.BaseRasterTransform")],n)},75414(e,t,i){i.d(t,{A:()=>o});var a,r=i(32198),s=i(91429),n=i(10333),l=i(93223);let o=a=class extends n.A{constructor(){super(...arguments),this.type="gcs-shift",this.tolerance=1e-8}forwardTransform(e){return"point"===(e=e.clone()).type?(e.x>180+this.tolerance&&(e.x-=360),e):(e.xmin>=180-this.tolerance?(e.xmax-=360,e.xmin-=360):e.xmax>180+this.tolerance&&(e.xmin=-180,e.xmax=180),e)}inverseTransform(e){return"point"===(e=e.clone()).type?(e.x<-this.tolerance&&(e.x+=360),e):(e.xmin<-this.tolerance&&(e.xmin+=360,e.xmax+=360),e)}clone(){return new a({tolerance:this.tolerance})}};(0,r.Cg)([(0,l.e)({GCSShiftXform:"gcs-shift"})],o.prototype,"type",void 0),(0,r.Cg)([(0,s.MZ)()],o.prototype,"tolerance",void 0),o=a=(0,r.Cg)([(0,s.$K)("esri.layers.raster.transforms.GCSShiftTransform")],o)},43163(e,t,i){i.d(t,{A:()=>p});var a,r=i(32198),s=i(91429),n=i(5443),l=i(86738),o=i(10333),f=i(36005),u=i(43937),h=i(93223);function c(e,t,i){let{x:a,y:r}=t;if(i<2)return{x:e[0]+a*e[2]+r*e[4],y:e[1]+a*e[3]+r*e[5]};if(2===i){let t=a*a,i=r*r,s=a*r;return{x:e[0]+a*e[2]+r*e[4]+t*e[6]+s*e[8]+i*e[10],y:e[1]+a*e[3]+r*e[5]+t*e[7]+s*e[9]+i*e[11]}}let s=a*a,n=r*r,l=a*r,o=s*a,f=s*r,u=a*n,h=r*n;return{x:e[0]+a*e[2]+r*e[4]+s*e[6]+l*e[8]+n*e[10]+o*e[12]+f*e[14]+u*e[16]+h*e[18],y:e[1]+a*e[3]+r*e[5]+s*e[7]+l*e[9]+n*e[11]+o*e[13]+f*e[15]+u*e[17]+h*e[19]}}function d(e,t,i){let{xmin:a,ymin:r,xmax:s,ymax:l,spatialReference:o}=t,f=[];if(i<2)f.push({x:a,y:l}),f.push({x:s,y:l}),f.push({x:a,y:r}),f.push({x:s,y:r});else{let e=10;for(let t=0;t<e;t++)f.push({x:a,y:r+(l-r)*t/(e-1)}),f.push({x:s,y:r+(l-r)*t/(e-1)});e=8;for(let t=1;t<=e;t++)f.push({x:a+(s-a)*t/e,y:r}),f.push({x:a+(s-a)*t/e,y:l})}f=f.map(t=>c(e,t,i));let u=f.map(e=>e.x),h=f.map(e=>e.y);return new n.A({xmin:Math.min.apply(null,u),xmax:Math.max.apply(null,u),ymin:Math.min.apply(null,h),ymax:Math.max.apply(null,h),spatialReference:o})}let p=a=class extends o.A{constructor(){super(...arguments),this.polynomialOrder=1,this.type="polynomial"}readForwardCoefficients(e,t){let{coeffX:i,coeffY:a}=t;if(!i?.length||!a?.length||i.length!==a.length)return null;let r=[];for(let e=0;e<i.length;e++)r.push(i[e]),r.push(a[e]);return r}writeForwardCoefficients(e,t,i){let a=[],r=[];for(let t=0;t<e?.length;t++)t%2==0?a.push(e[t]):r.push(e[t]);t.coeffX=a,t.coeffY=r}get inverseCoefficients(){let e=this._get("inverseCoefficients"),t=this._get("forwardCoefficients");return!e&&t&&this.polynomialOrder<2&&(e=function(e){let[t,i,a,r,s,n]=e,l=a*n-s*r,o=s*r-a*n;return[(s*i-t*n)/l,(a*i-t*r)/o,n/l,r/o,-s/l,-a/o]}(t)),e}set inverseCoefficients(e){this._set("inverseCoefficients",e)}readInverseCoefficients(e,t){let{inverseCoeffX:i,inverseCoeffY:a}=t;if(!i?.length||!a?.length||i.length!==a.length)return null;let r=[];for(let e=0;e<i.length;e++)r.push(i[e]),r.push(a[e]);return r}writeInverseCoefficients(e,t,i){let a=[],r=[];for(let t=0;t<e?.length;t++)t%2==0?a.push(e[t]):r.push(e[t]);t.inverseCoeffX=a,t.inverseCoeffY=r}get affectsPixelSize(){return this.polynomialOrder>0}forwardTransform(e){if("point"===e.type){let t=c(this.forwardCoefficients,e,this.polynomialOrder);return new l.A({x:t.x,y:t.y,spatialReference:e.spatialReference})}return d(this.forwardCoefficients,e,this.polynomialOrder)}inverseTransform(e){if("point"===e.type){let t=c(this.inverseCoefficients,e,this.polynomialOrder);return new l.A({x:t.x,y:t.y,spatialReference:e.spatialReference})}return d(this.inverseCoefficients,e,this.polynomialOrder)}clone(){return new a({polynomialOrder:this.polynomialOrder,forwardCoefficients:this.forwardCoefficients?[...this.forwardCoefficients]:null,inverseCoefficients:this.inverseCoefficients?[...this.inverseCoefficients]:null})}};(0,r.Cg)([(0,s.MZ)({json:{write:!0}})],p.prototype,"polynomialOrder",void 0),(0,r.Cg)([(0,s.MZ)()],p.prototype,"forwardCoefficients",void 0),(0,r.Cg)([(0,f.w)("forwardCoefficients",["coeffX","coeffY"])],p.prototype,"readForwardCoefficients",null),(0,r.Cg)([(0,u.K)("forwardCoefficients")],p.prototype,"writeForwardCoefficients",null),(0,r.Cg)([(0,s.MZ)({json:{write:!0}})],p.prototype,"inverseCoefficients",null),(0,r.Cg)([(0,f.w)("inverseCoefficients",["inverseCoeffX","inverseCoeffY"])],p.prototype,"readInverseCoefficients",null),(0,r.Cg)([(0,u.K)("inverseCoefficients")],p.prototype,"writeInverseCoefficients",null),(0,r.Cg)([(0,s.MZ)()],p.prototype,"affectsPixelSize",null),(0,r.Cg)([(0,h.e)({PolynomialXform:"polynomial"})],p.prototype,"type",void 0),p=a=(0,r.Cg)([(0,s.$K)("esri.layers.raster.transforms.PolynomialTransform")],p)}}]);
|