Pipeline-FIWUDD7H.js 127 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027
  1. import {
  2. R as R2,
  3. d as d5,
  4. r as r3
  5. } from "./chunk-B2HJOMLZ.js";
  6. import "./chunk-II7RCTF3.js";
  7. import "./chunk-VS4BIQ2O.js";
  8. import {
  9. n as n3,
  10. s as s6
  11. } from "./chunk-HWIURR7X.js";
  12. import "./chunk-Q4LKAPDF.js";
  13. import "./chunk-TODU7HVH.js";
  14. import "./chunk-23ONSYIH.js";
  15. import {
  16. c as c4,
  17. l as l3,
  18. r as r2
  19. } from "./chunk-U2FIWR5R.js";
  20. import {
  21. A
  22. } from "./chunk-P2L4QEOI.js";
  23. import {
  24. s as s7
  25. } from "./chunk-D6FGJON6.js";
  26. import "./chunk-YLVXZ2PS.js";
  27. import {
  28. v as v2
  29. } from "./chunk-T6STWTVU.js";
  30. import "./chunk-546QCRS4.js";
  31. import "./chunk-QXZVBSBH.js";
  32. import "./chunk-YVTH4OGO.js";
  33. import {
  34. o as o5
  35. } from "./chunk-WFSV2B2I.js";
  36. import "./chunk-4D6PVVFX.js";
  37. import {
  38. Y
  39. } from "./chunk-NP2BYFXT.js";
  40. import "./chunk-6H5PP7QI.js";
  41. import "./chunk-HSPVIAVJ.js";
  42. import "./chunk-XIEPNAEI.js";
  43. import {
  44. f as f4,
  45. g as g3
  46. } from "./chunk-M5BTTMP6.js";
  47. import "./chunk-WQJRLXWG.js";
  48. import "./chunk-ETWBEEKL.js";
  49. import "./chunk-XZA4MVET.js";
  50. import "./chunk-J525NRN3.js";
  51. import "./chunk-MI7HWWFL.js";
  52. import "./chunk-D5GG5NVO.js";
  53. import "./chunk-USORKAIZ.js";
  54. import {
  55. s as s5
  56. } from "./chunk-Q34L5KZA.js";
  57. import {
  58. l as l4
  59. } from "./chunk-TYZ4SNOQ.js";
  60. import {
  61. l as l2
  62. } from "./chunk-LMCIAW5S.js";
  63. import {
  64. h
  65. } from "./chunk-OTS3UE5B.js";
  66. import "./chunk-6RAL4JPQ.js";
  67. import {
  68. i
  69. } from "./chunk-VAY3LZG7.js";
  70. import "./chunk-LGW7TID4.js";
  71. import {
  72. c as c5
  73. } from "./chunk-6SASJ6IM.js";
  74. import "./chunk-3OHML7FO.js";
  75. import {
  76. c as c3,
  77. f as f5
  78. } from "./chunk-GS2NUWMB.js";
  79. import "./chunk-FUEX356Y.js";
  80. import {
  81. c as c2,
  82. q
  83. } from "./chunk-54AOZV5X.js";
  84. import {
  85. a as a2
  86. } from "./chunk-PK35UGFJ.js";
  87. import "./chunk-H6ETEALK.js";
  88. import "./chunk-FIYKFRB2.js";
  89. import "./chunk-ROWZMUVJ.js";
  90. import "./chunk-7IKYLNB5.js";
  91. import "./chunk-P4UZNLD5.js";
  92. import {
  93. D as D2,
  94. M as M2,
  95. Q,
  96. b as b2,
  97. ce,
  98. ie,
  99. me,
  100. ne,
  101. ue
  102. } from "./chunk-FYNVVMWY.js";
  103. import "./chunk-Q52DVFYK.js";
  104. import {
  105. o as o2,
  106. s as s4,
  107. t as t3
  108. } from "./chunk-HBMVUVZX.js";
  109. import "./chunk-QOV6ITMI.js";
  110. import "./chunk-DH2OBAUC.js";
  111. import {
  112. o as o4
  113. } from "./chunk-TNLRDNTC.js";
  114. import {
  115. b as b3
  116. } from "./chunk-UD63WBG3.js";
  117. import {
  118. g as g4
  119. } from "./chunk-X7DBH4KK.js";
  120. import {
  121. a as a3,
  122. m as m2,
  123. y as y2
  124. } from "./chunk-LY74KTXV.js";
  125. import "./chunk-EWE6EXPY.js";
  126. import "./chunk-KUXNUNAI.js";
  127. import {
  128. d as d3
  129. } from "./chunk-KMAHKQ2G.js";
  130. import "./chunk-522WBHUO.js";
  131. import "./chunk-WNCU6BFU.js";
  132. import "./chunk-BJHM4JNS.js";
  133. import "./chunk-F6A2QQ26.js";
  134. import "./chunk-EOSZHC5H.js";
  135. import "./chunk-C43UE3Z5.js";
  136. import {
  137. d as d4
  138. } from "./chunk-RMX2AZ4P.js";
  139. import "./chunk-NE3ESGA6.js";
  140. import {
  141. f as f3,
  142. j as j2,
  143. l
  144. } from "./chunk-YIS6BAC3.js";
  145. import "./chunk-7XXXCK2A.js";
  146. import "./chunk-7ZIDBK7B.js";
  147. import {
  148. y
  149. } from "./chunk-EG5OI4V4.js";
  150. import "./chunk-65BYCSII.js";
  151. import "./chunk-WZQZRKNH.js";
  152. import "./chunk-LRDX4TO7.js";
  153. import {
  154. S
  155. } from "./chunk-RBZL6SRZ.js";
  156. import "./chunk-WDLTDV2L.js";
  157. import "./chunk-TERAW6FT.js";
  158. import "./chunk-N2663GRX.js";
  159. import "./chunk-O4FY3ITT.js";
  160. import "./chunk-WEMIK25H.js";
  161. import "./chunk-JXW4QTJA.js";
  162. import "./chunk-UXF37FQ4.js";
  163. import "./chunk-ZOEK6QHJ.js";
  164. import {
  165. o2 as o3
  166. } from "./chunk-XNLG7T2T.js";
  167. import "./chunk-IR4PV7VK.js";
  168. import {
  169. d as d2
  170. } from "./chunk-2Z6LERTI.js";
  171. import {
  172. v2 as v
  173. } from "./chunk-OWVBLVP3.js";
  174. import "./chunk-MXB2XLKV.js";
  175. import "./chunk-ALDCDSPV.js";
  176. import {
  177. n as n2
  178. } from "./chunk-DT6EAZQ5.js";
  179. import "./chunk-HNOZUNJ4.js";
  180. import {
  181. U
  182. } from "./chunk-VNFRAYHO.js";
  183. import "./chunk-R5IG2D6H.js";
  184. import {
  185. Bt
  186. } from "./chunk-VBRY5KJM.js";
  187. import "./chunk-PDKDCAAD.js";
  188. import {
  189. M2 as M,
  190. s as s3
  191. } from "./chunk-ECW2QABR.js";
  192. import "./chunk-GCDJLKH4.js";
  193. import {
  194. E as E3,
  195. R,
  196. k2 as k
  197. } from "./chunk-MRJEICT6.js";
  198. import {
  199. d,
  200. e,
  201. n2 as n
  202. } from "./chunk-Y3WMVFTW.js";
  203. import "./chunk-SAS7RONY.js";
  204. import "./chunk-WSRBH7BF.js";
  205. import "./chunk-IHXECKQQ.js";
  206. import {
  207. C,
  208. D,
  209. E as E2,
  210. L,
  211. b,
  212. f as f2,
  213. g as g2,
  214. j
  215. } from "./chunk-ULGDPLM2.js";
  216. import {
  217. s,
  218. s3 as s2
  219. } from "./chunk-EMJ4ZSM2.js";
  220. import "./chunk-IKP3YN53.js";
  221. import {
  222. E,
  223. a,
  224. c,
  225. e as e2,
  226. f,
  227. g,
  228. m,
  229. o,
  230. r,
  231. t,
  232. t2
  233. } from "./chunk-GZT4BVFP.js";
  234. import "./chunk-A5ICIBVI.js";
  235. // node_modules/@arcgis/core/views/2d/layers/features/processors.js
  236. function o6(o11) {
  237. return o11 === "heatmap" ? import("./HeatmapProcessor-ZTNOMUTP.js") : import("./SymbolProcessor-QOW6BODF.js");
  238. }
  239. // node_modules/@arcgis/core/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js
  240. var r4 = 268435455;
  241. var n4 = class {
  242. constructor() {
  243. this.fieldMap = new Map(), this.fields = [], this.hasFeatures = false, this.fieldCount = 0, this.featureCount = 0, this.objectIdFieldIndex = 0, this.vertexCount = 0, this.offsets = { attributes: new Array(), geometry: new Array() }, this.centroid = new Array();
  244. }
  245. hasField(e3) {
  246. return this.fieldMap.has(e3);
  247. }
  248. isDateField(e3) {
  249. return this.fieldMap.get(e3)?.isDate;
  250. }
  251. getFieldIndex(e3) {
  252. return this.fieldMap.get(e3)?.index;
  253. }
  254. };
  255. function a4(e3) {
  256. const t7 = 1, r5 = 2, n6 = e3.getLength(), a8 = e3.pos() + n6, i4 = { name: "", isDate: false };
  257. for (; e3.pos() < a8 && e3.next(); )
  258. switch (e3.tag()) {
  259. case t7:
  260. i4.name = e3.getString();
  261. break;
  262. case r5:
  263. c2(e3.getEnum()) === "esriFieldTypeDate" && (i4.isDate = true);
  264. break;
  265. default:
  266. e3.skip();
  267. }
  268. return i4;
  269. }
  270. function i2(e3) {
  271. return e3.toLowerCase().trim();
  272. }
  273. function o7(s8, o11, c12 = false) {
  274. const f10 = 1, d11 = 3, u5 = 9, l9 = 12, g9 = 13, p5 = 15, h6 = s8.pos(), m7 = new n4();
  275. let b5 = 0, w5 = 0;
  276. const k3 = 1, x5 = 2, y8 = 4, I2 = 3;
  277. let F4 = null, L4 = null, A4 = null, C2 = false;
  278. for (; s8.next(); )
  279. switch (s8.tag()) {
  280. case f10:
  281. F4 = s8.getString();
  282. break;
  283. case d11:
  284. L4 = s8.getString();
  285. break;
  286. case l9:
  287. A4 = s8.processMessage(q);
  288. break;
  289. case u5:
  290. if (m7.exceededTransferLimit = s8.getBool(), m7.exceededTransferLimit) {
  291. m7.offsets.geometry = c12 ? new Float64Array(8e3) : new Int32Array(8e3), m7.centroid = c12 ? new Float64Array(16e3) : new Int32Array(16e3);
  292. for (let e3 = 0; e3 < m7.centroid.length; e3++)
  293. m7.centroid[e3] = r4;
  294. }
  295. break;
  296. case g9: {
  297. const e3 = a4(s8), t7 = e3.name, r5 = i2(e3.name), n6 = { fieldName: t7, index: b5++, isDate: e3.isDate };
  298. m7.fields.push(n6), m7.fieldMap.set(e3.name, n6), m7.fieldMap.set(r5, n6);
  299. break;
  300. }
  301. case p5: {
  302. const e3 = s8.getLength(), t7 = s8.pos() + e3;
  303. if (!m7.exceededTransferLimit) {
  304. const e4 = m7.offsets.geometry, t8 = m7.centroid;
  305. e4.push(0), t8.push(r4), t8.push(r4);
  306. }
  307. !C2 && m7.exceededTransferLimit && (C2 = true, m7.offsets.attributes = c12 ? new Float64Array(8e3 * b5) : new Uint32Array(8e3 * b5));
  308. let n6 = w5 * b5;
  309. for (; s8.pos() < t7 && s8.next(); )
  310. switch (s8.tag()) {
  311. case k3: {
  312. if (C2)
  313. m7.offsets.attributes[n6++] = s8.pos();
  314. else {
  315. m7.offsets.attributes.push(s8.pos());
  316. }
  317. const e4 = s8.getLength();
  318. s8.skipLen(e4);
  319. break;
  320. }
  321. case x5:
  322. if (o11) {
  323. const e4 = s8.getLength(), t8 = s8.pos() + e4;
  324. for (; s8.pos() < t8 && s8.next(); )
  325. switch (s8.tag()) {
  326. case I2: {
  327. s8.getUInt32();
  328. const e5 = s8.getSInt64(), t9 = s8.getSInt64();
  329. m7.centroid[2 * w5] = e5, m7.centroid[2 * w5 + 1] = t9;
  330. break;
  331. }
  332. default:
  333. s8.skip();
  334. }
  335. } else {
  336. m7.offsets.geometry[w5] = s8.pos();
  337. const e4 = s8.getLength();
  338. m7.vertexCount += e4, s8.skipLen(e4);
  339. }
  340. break;
  341. case y8: {
  342. const e4 = s8.getLength(), t8 = s8.pos() + e4;
  343. for (; s8.pos() < t8 && s8.next(); )
  344. switch (s8.tag()) {
  345. case I2: {
  346. s8.getUInt32();
  347. const e5 = s8.getSInt64(), t9 = s8.getSInt64();
  348. m7.centroid[2 * w5] = e5, m7.centroid[2 * w5 + 1] = t9;
  349. break;
  350. }
  351. default:
  352. s8.skip();
  353. }
  354. break;
  355. }
  356. default:
  357. s8.skip();
  358. }
  359. w5++, m7.hasFeatures = true;
  360. break;
  361. }
  362. default:
  363. s8.skip();
  364. }
  365. const S4 = F4 || L4;
  366. if (!S4)
  367. throw new s2("FeatureSet has no objectId or globalId field name");
  368. return m7.featureCount = w5, m7.fieldCount = b5, m7.objectIdFieldIndex = m7.getFieldIndex(S4), m7.transform = A4, m7.displayIds = new Uint32Array(m7.featureCount), m7.groupIds = new Uint16Array(m7.featureCount), s8.move(h6), m7;
  369. }
  370. // node_modules/@arcgis/core/views/2d/layers/features/support/FeatureSetReaderPBF.js
  371. var c6 = s.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF");
  372. var g5 = true;
  373. var l5 = 268435455;
  374. var _ = 128;
  375. var f6 = 128e3;
  376. var y3 = { small: { delta: new Int32Array(_), decoded: new Int32Array(_) }, large: { delta: new Int32Array(f6), decoded: new Int32Array(f6) } };
  377. function I(e3) {
  378. return e3 <= y3.small.delta.length ? y3.small : (e3 <= y3.large.delta.length || (y3.large.delta = new Int32Array(Math.round(1.25 * e3)), y3.large.decoded = new Int32Array(Math.round(1.25 * e3))), y3.large);
  379. }
  380. function p(e3) {
  381. return e3.toLowerCase().trim();
  382. }
  383. function m3(t7) {
  384. try {
  385. const e3 = 2, r5 = new a2(new Uint8Array(t7), new DataView(t7));
  386. for (; r5.next(); ) {
  387. if (r5.tag() === e3)
  388. return x(r5.getMessage());
  389. r5.skip();
  390. }
  391. } catch (r5) {
  392. const t8 = new s2("query:parsing-pbf", "Error while parsing FeatureSet PBF payload", { error: r5 });
  393. c6.error(t8);
  394. }
  395. return null;
  396. }
  397. function x(e3) {
  398. const t7 = 1;
  399. for (; e3.next(); ) {
  400. if (e3.tag() === t7)
  401. return e3.getMessage();
  402. e3.skip();
  403. }
  404. return null;
  405. }
  406. function S2(e3) {
  407. const t7 = 1, r5 = 2, s8 = 3, i4 = 4, n6 = 5, a8 = 6, h6 = 7, o11 = 8, d11 = 9, u5 = e3.getLength(), c12 = e3.pos() + u5;
  408. for (; e3.pos() < c12 && e3.next(); )
  409. switch (e3.tag()) {
  410. case t7:
  411. return e3.getString();
  412. case r5:
  413. return e3.getFloat();
  414. case s8:
  415. return e3.getDouble();
  416. case i4:
  417. return e3.getSInt32();
  418. case n6:
  419. return e3.getUInt32();
  420. case a8:
  421. return e3.getInt64();
  422. case h6:
  423. return e3.getUInt64();
  424. case o11:
  425. return e3.getSInt64();
  426. case d11:
  427. return e3.getBool();
  428. default:
  429. return e3.skip(), null;
  430. }
  431. return null;
  432. }
  433. function F(e3, t7, r5, s8, i4, n6) {
  434. return 0.5 * Math.abs(e3 * s8 + r5 * n6 + i4 * t7 - e3 * n6 - r5 * t7 - i4 * s8);
  435. }
  436. function G(e3, t7, r5, s8) {
  437. return e3 * s8 - r5 * t7 === 0 && e3 * r5 + t7 * s8 > 0;
  438. }
  439. var w = class extends A {
  440. constructor(e3, t7, r5, s8) {
  441. super(e3, s8), this._hasNext = false, this._isPoints = false, this._featureIndex = -1, this._featureOffset = 0, this._cache = { area: 0, unquantGeometry: void 0, geometry: void 0, centroid: void 0, legacyFeature: void 0, optFeature: void 0 }, this._geometryType = s8.geometryType, this._reader = t7, this._header = r5, this._hasNext = r5.hasFeatures, this._isPoints = s8.geometryType === "esriGeometryPoint";
  442. }
  443. static fromBuffer(e3, t7, r5 = false) {
  444. const s8 = t7.geometryType, i4 = m3(e3), n6 = o7(i4, s8 === "esriGeometryPoint", r5), a8 = A.createInstance();
  445. return new w(a8, i4, n6, t7);
  446. }
  447. get geometryType() {
  448. return this._geometryType;
  449. }
  450. get size() {
  451. return this._header.featureCount;
  452. }
  453. get hasZ() {
  454. return false;
  455. }
  456. get hasM() {
  457. return false;
  458. }
  459. get stride() {
  460. return 2 + (this.hasZ ? 1 : 0) + (this.hasM ? 1 : 0);
  461. }
  462. get hasFeatures() {
  463. return this._header.hasFeatures;
  464. }
  465. get hasNext() {
  466. return this._hasNext;
  467. }
  468. get exceededTransferLimit() {
  469. return this._header.exceededTransferLimit;
  470. }
  471. hasField(e3) {
  472. return this._header.hasField(e3) || this._header.hasField(p(e3));
  473. }
  474. getFieldNames() {
  475. return this._header.fields.map((e3) => e3.fieldName);
  476. }
  477. getSize() {
  478. return this.size;
  479. }
  480. getQuantizationTransform() {
  481. return this._header.transform;
  482. }
  483. getCursor() {
  484. return this.copy();
  485. }
  486. getIndex() {
  487. return this._featureIndex;
  488. }
  489. setIndex(e3) {
  490. this._cache.area = 0, this._cache.unquantGeometry = void 0, this._cache.geometry = void 0, this._cache.centroid = void 0, this._cache.legacyFeature = void 0, this._cache.optFeature = void 0, this._featureIndex = e3;
  491. }
  492. getAttributeHash() {
  493. let e3 = "";
  494. return this._header.fields.forEach(({ index: t7 }) => {
  495. e3 += this._readAttributeAtIndex(t7) + ".";
  496. }), e3;
  497. }
  498. getObjectId() {
  499. return this._readAttributeAtIndex(this._header.objectIdFieldIndex);
  500. }
  501. getDisplayId() {
  502. return this._header.displayIds[this._featureIndex];
  503. }
  504. setDisplayId(e3) {
  505. this._header.displayIds[this._featureIndex] = e3;
  506. }
  507. getGroupId() {
  508. return this._header.groupIds[this._featureIndex];
  509. }
  510. setGroupId(e3) {
  511. this._header.groupIds[this._featureIndex] = e3;
  512. }
  513. readLegacyFeature() {
  514. if (this._cache.legacyFeature === void 0) {
  515. const e3 = this.readCentroid(), t7 = { attributes: this.readAttributes(), geometry: this._isPoints ? this.readLegacyPointGeometry() : this.readLegacyGeometry(), centroid: (e3 && { x: e3.coords[0], y: e3.coords[1] }) ?? null };
  516. return this._cache.legacyFeature = t7, t7;
  517. }
  518. return this._cache.legacyFeature;
  519. }
  520. readOptimizedFeature() {
  521. if (this._cache.optFeature === void 0) {
  522. const e3 = new s4(this.readGeometry(), this.readAttributes(), this.readCentroid());
  523. return e3.objectId = this.getObjectId(), e3.displayId = this.getDisplayId(), this._cache.optFeature = e3, e3;
  524. }
  525. return this._cache.optFeature;
  526. }
  527. getXHydrated() {
  528. const e3 = this._header.centroid[2 * this._featureIndex], t7 = this.getQuantizationTransform();
  529. return t(t7) ? e3 : e3 * t7.scale[0] + t7.translate[0];
  530. }
  531. getYHydrated() {
  532. const e3 = this._header.centroid[2 * this._featureIndex + 1], t7 = this.getQuantizationTransform();
  533. return t(t7) ? e3 : t7.translate[1] - e3 * t7.scale[1];
  534. }
  535. getX() {
  536. return this._header.centroid[2 * this._featureIndex] * this._sx + this._tx;
  537. }
  538. getY() {
  539. return this._header.centroid[2 * this._featureIndex + 1] * this._sy + this._ty;
  540. }
  541. readLegacyPointGeometry() {
  542. return { x: this.getX(), y: this.getY() };
  543. }
  544. readLegacyGeometry(e3) {
  545. const t7 = this.readGeometry(e3);
  546. return ne(t7, this.geometryType, false, false);
  547. }
  548. readLegacyCentroid() {
  549. const e3 = this.readCentroid();
  550. if (!e3)
  551. return null;
  552. const [t7, r5] = e3.coords;
  553. return { x: t7, y: r5 };
  554. }
  555. readGeometryArea() {
  556. return this._cache.area || this.readGeometry(true), this._cache.area;
  557. }
  558. readUnquantizedGeometry(e3 = false) {
  559. if (this._cache.unquantGeometry === void 0) {
  560. const t7 = this.readGeometry(e3);
  561. if (!t7)
  562. return this._cache.unquantGeometry = null, null;
  563. const r5 = I(t7.coords.length).decoded, s8 = t7.clone(r5), i4 = s8.coords;
  564. let n6 = 0;
  565. for (const e4 of s8.lengths) {
  566. for (let t8 = 1; t8 < e4; t8++) {
  567. const e5 = 2 * (n6 + t8), r6 = 2 * (n6 + t8 - 1);
  568. i4[e5] += i4[r6], i4[e5 + 1] += i4[r6 + 1];
  569. }
  570. n6 += e4;
  571. }
  572. return this._cache.unquantGeometry = s8, s8;
  573. }
  574. return this._cache.unquantGeometry;
  575. }
  576. readHydratedGeometry() {
  577. if (this._isPoints) {
  578. if (this._header.centroid[2 * this._featureIndex] === l5)
  579. return null;
  580. const e4 = this.getXHydrated(), t8 = this.getYHydrated();
  581. return new t3([], [e4, t8]);
  582. }
  583. const e3 = this.readGeometry();
  584. if (!e3)
  585. return null;
  586. const t7 = e3.clone(), r5 = this.getQuantizationTransform();
  587. return r(r5) && me(t7, t7, this.hasZ, this.hasM, r5), t7;
  588. }
  589. readGeometry(e3 = false) {
  590. if (this._cache.geometry === void 0) {
  591. let r5 = null;
  592. if (this._isPoints) {
  593. if (this._header.centroid[2 * this._featureIndex] === l5)
  594. return null;
  595. const e4 = this.getX(), t7 = this.getY();
  596. r5 = new t3([], [e4, t7]);
  597. } else {
  598. const s8 = this._header.offsets.geometry[this._featureIndex], i4 = this._reader;
  599. if (s8 === 0)
  600. return null;
  601. i4.move(s8);
  602. try {
  603. r5 = e3 ? this._parseGeometryForDisplay(i4) : this._parseGeometry(i4);
  604. } catch (t7) {
  605. return console.error("Failed to parse geometry!", t7), null;
  606. }
  607. }
  608. return this._cache.geometry = r5, r5;
  609. }
  610. return this._cache.geometry;
  611. }
  612. readCentroid() {
  613. if (this._cache.centroid === void 0) {
  614. let e3 = null;
  615. const t7 = this._header.centroid[2 * this._featureIndex] + this._tx, r5 = this._header.centroid[2 * this._featureIndex + 1] + this._ty;
  616. return t7 === l5 ? (e3 = this._computeCentroid(), e3 && (this._header.centroid[2 * this._featureIndex] = e3.coords[0] - this._tx, this._header.centroid[2 * this._featureIndex + 1] = e3.coords[1] - this._ty)) : e3 = new t3([], [t7, r5]), this._cache.centroid = e3, e3;
  617. }
  618. return this._cache.centroid;
  619. }
  620. copy() {
  621. const e3 = this._reader.clone(), t7 = new w(this.instance, e3, this._header, this.fullSchema());
  622. return this.copyInto(t7), t7;
  623. }
  624. next() {
  625. for (this._cache.area = 0, this._cache.unquantGeometry = void 0, this._cache.geometry = void 0, this._cache.centroid = void 0, this._cache.legacyFeature = void 0, this._cache.optFeature = void 0; ++this._featureIndex < this.size && !this._getExists(); )
  626. ;
  627. return this._featureIndex < this.size;
  628. }
  629. _readAttribute(e3, t7) {
  630. const r5 = this._header.hasField(e3) ? e3 : p(e3), s8 = this._header.getFieldIndex(r5);
  631. if (s8 == null)
  632. return;
  633. const i4 = this._readAttributeAtIndex(s8);
  634. if (!t7)
  635. return i4;
  636. if (i4 == null)
  637. return i4;
  638. return this._header.isDateField(r5) ? new Date(i4) : i4;
  639. }
  640. _readAttributes() {
  641. const e3 = {};
  642. return this._header.fields.forEach(({ fieldName: t7, index: r5 }) => {
  643. e3[t7] = this._readAttributeAtIndex(r5);
  644. }), e3;
  645. }
  646. copyInto(e3) {
  647. super.copyInto(e3), e3._featureIndex = this._featureIndex, e3._featureOffset = this._featureOffset, e3._hasNext = this._hasNext;
  648. }
  649. _readAttributeAtIndex(e3) {
  650. const t7 = this._header.offsets.attributes[this._featureIndex * this._header.fieldCount + e3], r5 = this._reader;
  651. return r5.move(t7), S2(r5);
  652. }
  653. _parseGeometry(e3) {
  654. const t7 = 2, r5 = 3, s8 = e3.getLength(), i4 = e3.pos() + s8, n6 = [], a8 = [];
  655. for (; e3.pos() < i4 && e3.next(); )
  656. switch (e3.tag()) {
  657. case t7: {
  658. const t8 = e3.getUInt32(), r6 = e3.pos() + t8;
  659. for (; e3.pos() < r6; )
  660. a8.push(e3.getUInt32());
  661. break;
  662. }
  663. case r5: {
  664. const t8 = e3.getUInt32(), r6 = e3.pos() + t8;
  665. for (n6.push(e3.getSInt32() + this._tx), n6.push(e3.getSInt32() + this._ty), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); e3.pos() < r6; )
  666. n6.push(e3.getSInt32()), n6.push(e3.getSInt32()), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32();
  667. break;
  668. }
  669. default:
  670. e3.skip();
  671. }
  672. return new t3(a8, n6);
  673. }
  674. _parseGeometryForDisplay(e3) {
  675. const t7 = 2, r5 = 3, s8 = e3.getLength(), i4 = e3.pos() + s8, n6 = [], a8 = [];
  676. let h6 = 0, d11 = 0, u5 = null, c12 = 0;
  677. const l9 = this.geometryType === "esriGeometryPolygon";
  678. for (; e3.pos() < i4 && e3.next(); )
  679. switch (e3.tag()) {
  680. case t7: {
  681. const t8 = e3.getUInt32(), r6 = e3.pos() + t8;
  682. for (; e3.pos() < r6; ) {
  683. const t9 = e3.getUInt32();
  684. n6.push(t9), h6 += t9;
  685. }
  686. u5 = I(2 * h6).delta;
  687. break;
  688. }
  689. case r5: {
  690. e3.getUInt32();
  691. const t8 = 2 + (this.hasZ ? 1 : 0) + (this.hasM ? 1 : 0);
  692. for (const r6 of n6)
  693. if (d11 + t8 * r6 > u5.length)
  694. for (let t9 = 0; t9 < r6; t9++)
  695. e3.getSInt32(), e3.getSInt32(), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32();
  696. else if (l9 && g5) {
  697. const t9 = this.getAreaSimplificationThreshold(r6, this._header.vertexCount);
  698. let s9 = 2, i5 = 1;
  699. const n7 = false;
  700. let h7 = e3.getSInt32(), o11 = e3.getSInt32();
  701. u5[d11++] = h7, u5[d11++] = o11, this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32();
  702. let g9 = e3.getSInt32(), l10 = e3.getSInt32();
  703. for (this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); s9 < r6; ) {
  704. let r7 = e3.getSInt32(), n8 = e3.getSInt32();
  705. this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32();
  706. const a9 = h7 + g9, _4 = o11 + l10;
  707. F(h7, o11, a9, _4, a9 + r7, _4 + n8) >= t9 ? (c12 += -0.5 * (a9 - h7) * (_4 + o11), i5 > 1 && G(u5[d11 - 2], u5[d11 - 1], g9, l10) ? (u5[d11 - 2] += g9, u5[d11 - 1] += l10) : (u5[d11++] = g9, u5[d11++] = l10, i5++), h7 = a9, o11 = _4) : (r7 += g9, n8 += l10), g9 = r7, l10 = n8, s9++;
  708. }
  709. i5 < 3 || n7 ? d11 -= 2 * i5 : (c12 += -0.5 * (h7 + g9 - h7) * (o11 + l10 + o11), G(u5[d11 - 2], u5[d11 - 1], g9, l10) ? (u5[d11 - 2] += g9, u5[d11 - 1] += l10, a8.push(i5)) : (u5[d11++] = g9, u5[d11++] = l10, a8.push(++i5)));
  710. } else {
  711. let t9 = 0, s9 = e3.getSInt32(), i5 = e3.getSInt32();
  712. this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(), u5[d11++] = s9, u5[d11++] = i5, t9 += 1;
  713. for (let n7 = 1; n7 < r6; n7++) {
  714. const r7 = e3.getSInt32(), a9 = e3.getSInt32(), h7 = s9 + r7, o11 = i5 + a9;
  715. c12 += -0.5 * (h7 - s9) * (o11 + i5), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(), n7 > 2 && G(u5[d11 - 2], u5[d11 - 1], r7, a9) ? (u5[d11 - 2] += r7, u5[d11 - 1] += a9) : (u5[d11++] = r7, u5[d11++] = a9, t9 += 1), s9 = h7, i5 = o11;
  716. }
  717. a8.push(t9);
  718. }
  719. break;
  720. }
  721. default:
  722. e3.skip();
  723. }
  724. if (this._cache.area = c12, !a8.length)
  725. return null;
  726. if (this._tx || this._ty) {
  727. let e4 = 0;
  728. for (const t8 of a8)
  729. u5[2 * e4] += this._tx, u5[2 * e4 + 1] += this._ty, e4 += t8;
  730. }
  731. return new t3(a8, u5);
  732. }
  733. };
  734. // node_modules/@arcgis/core/views/2d/layers/features/controllers/support/sourceAdapters.js
  735. var l6 = class {
  736. constructor(e3) {
  737. this.service = e3;
  738. }
  739. destroy() {
  740. }
  741. };
  742. function f7(e3) {
  743. return Array.isArray(e3.source);
  744. }
  745. function y4(e3) {
  746. return e3 && e3.capabilities && e3.collection && e3.layerDefinition;
  747. }
  748. function h2(t7) {
  749. const { capabilities: r5 } = t7;
  750. return y4(t7.source) ? new w2(t7) : f7(t7) ? new v3(t7) : r5.query.supportsFormatPBF && a("featurelayer-pbf") ? new F2(t7) : new q2(t7);
  751. }
  752. async function d6(e3) {
  753. const t7 = new c5();
  754. return await t7.open(e3, {}), t7;
  755. }
  756. var v3 = class extends l6 {
  757. constructor(e3) {
  758. super(e3), this._portsOpen = d6(e3.source).then((e4) => this.client = e4);
  759. }
  760. destroy() {
  761. this.client.close(), this.client = null;
  762. }
  763. async executeQuery(e3, t7) {
  764. await this._portsOpen;
  765. const r5 = await this.client.invoke("queryFeatures", e3.toJSON(), t7);
  766. return d5.fromFeatureSet(r5, this.service);
  767. }
  768. };
  769. var F2 = class extends l6 {
  770. async executeQuery(e3, t7) {
  771. const { data: r5 } = await f5(this.service.source, e3, t7), s8 = !e3.quantizationParameters;
  772. return w.fromBuffer(r5, this.service, s8);
  773. }
  774. };
  775. var q2 = class extends l6 {
  776. async executeQuery(e3, s8) {
  777. const { source: n6, capabilities: c12, spatialReference: p5, objectIdField: l9, geometryType: f10 } = this.service;
  778. if (r(e3.quantizationParameters) && !c12.query.supportsQuantization) {
  779. const t7 = e3.clone(), c13 = s5(e2(t7.quantizationParameters));
  780. t7.quantizationParameters = null;
  781. const { data: f11 } = await c3(n6, t7, p5, s8), y9 = ce(f11, l9);
  782. return ue(c13, y9), d5.fromOptimizedFeatureSet(y9, this.service);
  783. }
  784. const { data: y8 } = await c3(n6, e3, this.service.spatialReference, s8);
  785. return f10 === "esriGeometryPoint" && (y8.features = y8.features?.filter((e4) => {
  786. if (r(e4.geometry)) {
  787. const t7 = e4.geometry;
  788. return Number.isFinite(t7.x) && Number.isFinite(t7.y);
  789. }
  790. return true;
  791. })), d5.fromFeatureSet(y8, this.service);
  792. }
  793. };
  794. var w2 = class extends l6 {
  795. async executeQuery(e3, t7) {
  796. const { capabilities: s8 } = this.service;
  797. if (e3.quantizationParameters && !s8.query.supportsQuantization) {
  798. const s9 = e3.clone(), a9 = s5(e2(s9.quantizationParameters));
  799. s9.quantizationParameters = null;
  800. const c12 = await v2(this.service.source, e3, t7);
  801. return ue(a9, c12), d5.fromOptimizedFeatureSet(c12, this.service);
  802. }
  803. const a8 = await v2(this.service.source, e3, t7);
  804. return d5.fromOptimizedFeatureSet(a8, this.service);
  805. }
  806. };
  807. // node_modules/@arcgis/core/views/2d/layers/features/support/UpdateToken.js
  808. var t4 = class {
  809. constructor() {
  810. this.version = 0, this.source = false, this.targets = { feature: false, aggregate: false }, this.storage = { filters: false, data: false }, this.mesh = false, this.queryFilter = false, this.why = { mesh: [], source: [] };
  811. }
  812. static create(e3) {
  813. const s8 = new t4();
  814. for (const t7 in e3) {
  815. const r5 = e3[t7];
  816. if (typeof r5 == "object")
  817. for (const e4 in r5) {
  818. const a8 = r5[e4];
  819. s8[t7][e4] = a8;
  820. }
  821. s8[t7] = r5;
  822. }
  823. return s8;
  824. }
  825. static empty() {
  826. return t4.create({});
  827. }
  828. static all() {
  829. return t4.create({ source: true, targets: { feature: true, aggregate: true }, storage: { filters: true, data: true }, mesh: true });
  830. }
  831. unset(t7) {
  832. this.version = t7.version, t7.source && (this.source = false), t7.targets.feature && (this.targets.feature = false), t7.targets.aggregate && (this.targets.aggregate = false), t7.storage.filters && (this.storage.filters = false), t7.storage.data && (this.storage.data = false), t7.mesh && (this.mesh = false), t7.queryFilter && (this.queryFilter = false);
  833. }
  834. any() {
  835. return this.source || this.mesh || this.storage.filters || this.storage.data || this.targets.feature || this.targets.aggregate || this.queryFilter;
  836. }
  837. describe() {
  838. let t7 = 0, e3 = "";
  839. if (this.mesh) {
  840. t7 += 20, e3 += "-> (20) Mesh needs update\n";
  841. for (const t8 of this.why.mesh)
  842. e3 += ` + ${t8}
  843. `;
  844. }
  845. if (this.source) {
  846. t7 += 10, e3 += "-> (10) The source needs update\n";
  847. for (const t8 of this.why.source)
  848. e3 += ` + ${t8}
  849. `;
  850. }
  851. this.targets.feature && (t7 += 5, e3 += "-> (5) Feature target parameters changed\n"), this.storage.filters && (t7 += 5, e3 += "-> (5) Feature filter parameters changed\n"), this.targets.aggregate && (t7 += 4, e3 += "-> (4) Aggregate target parameters changed\n"), this.storage.data && (t7 += 1, e3 += "-> (1) Texture storage parameters changed");
  852. const s8 = t7 < 5 ? "Fastest" : t7 < 10 ? "Fast" : t7 < 15 ? "Moderate" : t7 < 20 ? "Slow" : "Very Slow";
  853. console.debug(`Applying ${s8} update of cost ${t7}/45 `), console.debug(e3);
  854. }
  855. toJSON() {
  856. return { queryFilter: this.queryFilter, source: this.source, targets: this.targets, storage: this.storage, mesh: this.mesh };
  857. }
  858. };
  859. // node_modules/@arcgis/core/views/2d/layers/features/sources/DataTileSubscription.js
  860. var o8 = class {
  861. constructor(s8, t7) {
  862. this.requests = { done: new Array(), stream: new s7(10) }, this._edits = null, this._abortController = new AbortController(), this._version = 0, this._done = false, this.didSend = false, this.tile = s8, this._version = t7;
  863. }
  864. get signal() {
  865. return this._abortController.signal;
  866. }
  867. get options() {
  868. return { signal: this._abortController.signal };
  869. }
  870. get empty() {
  871. return !this.requests.done.length;
  872. }
  873. get edits() {
  874. return this._edits;
  875. }
  876. get done() {
  877. return this._done;
  878. }
  879. end() {
  880. this._done = true;
  881. }
  882. clear() {
  883. this.requests.done = [];
  884. }
  885. applyUpdate(e3) {
  886. this.requests.done.forEach((s8) => s8.message.status.unset(e3)), this._version = e3.version, r(this._edits) && this._edits.status.unset(e3);
  887. }
  888. add(e3) {
  889. e3.message.status = e3.message.status ?? t4.empty(), e3.message.status.version = this._version, a("esri-2d-update-debug") && console.debug(this.tile.id, "DataTileSubscription:add", this._version), e3.message.end && this.requests.done.forEach((e4) => {
  890. r(e4.message) && e4.message.end && (e4.message.end = false);
  891. }), this.requests.done.push(e3);
  892. }
  893. edit(e3, s8) {
  894. const t7 = e3.getQuantizationTransform(), o11 = e3.fullSchema(), n6 = Array.from(e3.features()), h6 = [...s8, ...n6.map((e4) => e4.objectId)];
  895. if (this.removeIds(h6), this._invalidate(), t(this._edits))
  896. return void (this._edits = { type: "append", addOrUpdate: d5.fromOptimizedFeatures(n6, o11, e2(t7)), id: this.tile.id, status: t4.empty(), end: true });
  897. this.requests.done.forEach((e4) => e4.message.end = false);
  898. e2(this._edits.addOrUpdate).append(e3.features());
  899. }
  900. *readers() {
  901. for (const { message: e3 } of this.requests.done)
  902. r(e3.addOrUpdate) && (yield e3.addOrUpdate);
  903. r(this._edits) && r(this._edits.addOrUpdate) && (yield this._edits.addOrUpdate);
  904. }
  905. _invalidate() {
  906. for (const e3 of this.requests.done)
  907. e3.message.status = t4.empty();
  908. r(this._edits) && (this._edits.status = t4.empty());
  909. }
  910. removeIds(e3) {
  911. this._invalidate();
  912. for (const { message: s8 } of this.requests.done) {
  913. const r5 = s8.addOrUpdate;
  914. r(r5) && (r5.removeIds(e3), r5.isEmpty && (s8.addOrUpdate = null));
  915. }
  916. r(this._edits) && r(this._edits.addOrUpdate) && this._edits.addOrUpdate.removeIds(e3), this.requests.done = this.requests.done.filter((e4) => e4.message.addOrUpdate || e4.message.end);
  917. }
  918. abort() {
  919. this._abortController.abort();
  920. }
  921. };
  922. // node_modules/@arcgis/core/views/2d/layers/features/sources/DataTileSource.js
  923. function m4(e3, s8) {
  924. const t7 = new Set();
  925. return e3 && e3.forEach((e4) => t7.add(e4)), s8 && s8.forEach((e4) => t7.add(e4)), t7.has("*") ? ["*"] : Array.from(t7);
  926. }
  927. var f8 = class {
  928. constructor(e3) {
  929. this.events = new n2(), this._resolver = D(), this._didEdit = false, this._subscriptions = new Map(), this._outSR = e3.outSR, this._serviceInfo = e3.serviceInfo, this._onTileUpdateMessage = e3.onMessage;
  930. }
  931. destroy() {
  932. }
  933. async _onMessage(e3) {
  934. const s8 = this._subscriptions.get(e3.id);
  935. if (!s8)
  936. return;
  937. const t7 = { ...e3, remove: e3.remove ?? [], status: e3.status ?? t4.empty() };
  938. return j(this._onTileUpdateMessage(t7, s8.options));
  939. }
  940. update(s8, r5) {
  941. const i4 = r5.fields.length;
  942. r5.outFields = m4(this._schema?.outFields, r5.outFields), r5.outFields = r5.outFields.length >= 0.75 * i4 ? ["*"] : r5.outFields, r5.outFields.sort();
  943. const o11 = m2(this._schema, r5);
  944. if (!o11)
  945. return;
  946. a("esri-2d-update-debug") && console.debug("Applying Update - Source:", o11);
  947. const n6 = "orderByFields" in this._serviceInfo && this._serviceInfo.orderByFields ? this._serviceInfo.orderByFields : this._serviceInfo.objectIdField + " ASC", c12 = { returnCentroid: a("esri-2d-query-centroid-enabled") && this._serviceInfo.geometryType === "esriGeometryPolygon", returnGeometry: true, timeReferenceUnknownClient: this._serviceInfo.type !== "stream" && this._serviceInfo.timeReferenceUnknownClient, outFields: r5.outFields, outSpatialReference: this._outSR, orderByFields: [n6], where: r5.definitionExpression || "1=1", gdbVersion: r5.gdbVersion, historicMoment: r5.historicMoment, timeExtent: y.fromJSON(r5.timeExtent) }, d11 = this._schema && a3(o11, "outFields");
  948. this._schema && y2(o11, ["timeExtent", "definitionExpression", "gdbVersion", "historicMoment", "customParameters"]) && (s8.why.mesh.push("Layer filter and/or custom parameters changed"), s8.why.source.push("Layer filter and/or custom parameters changed"), s8.mesh = true, s8.source = true, s8.queryFilter = true), d11 && (s8.why.source.push("Layer required fields changed"), s8.source = true), m2(c12, this._queryInfo) && (this._queryInfo = c12), this._schema = r5, this._resolver.resolve();
  949. }
  950. whenInitialized() {
  951. return this._resolver.promise;
  952. }
  953. async applyUpdate(e3) {
  954. if (e3.queryFilter || e3.source && this._didEdit)
  955. return this.refresh(e3.version), void (this._didEdit = false);
  956. this._subscriptions.forEach((s8) => s8.applyUpdate(e3)), await this.resend();
  957. }
  958. refresh(e3) {
  959. for (const s8 of this._tiles())
  960. this.unsubscribe(s8), this.subscribe(s8, e3);
  961. }
  962. subscribe(e3, s8) {
  963. const t7 = new o8(e3, s8);
  964. this._subscriptions.set(e3.id, t7);
  965. }
  966. unsubscribe(e3) {
  967. const s8 = this.get(e3.id);
  968. r(s8) && s8.abort(), this._subscriptions.delete(e3.id);
  969. }
  970. createQuery(e3 = {}) {
  971. const s8 = this._queryInfo.historicMoment ? new Date(this._queryInfo.historicMoment) : null;
  972. return new b3({ ...this._queryInfo, historicMoment: s8, ...e3 });
  973. }
  974. get(e3) {
  975. return this._subscriptions.has(e3) ? this._subscriptions.get(e3) : null;
  976. }
  977. async queryLastEditDate() {
  978. throw new Error("Service does not support query type");
  979. }
  980. async query(e3) {
  981. throw new Error("Service does not support query");
  982. }
  983. *_tiles() {
  984. const e3 = Array.from(this._subscriptions.values());
  985. for (const s8 of e3)
  986. yield s8.tile;
  987. }
  988. async edit(e3, s8) {
  989. const t7 = Array.from(this._subscriptions.values()), r5 = t7.map(({ tile: e4 }) => e4);
  990. for (const i4 of t7)
  991. i4.removeIds(s8);
  992. if (e3.length) {
  993. const t8 = r5.map((s9) => {
  994. const t9 = this.createTileQuery(s9);
  995. return t9.objectIds = e3, { tile: s9, query: t9 };
  996. }).map(async ({ tile: e4, query: s9 }) => ({ tile: e4, result: await this.query(s9), query: s9 })), i4 = (await C(t8)).map(async ({ tile: t9, result: r6 }) => {
  997. if (!r6.hasFeatures && !s8.length && !e3.length)
  998. return;
  999. const i5 = this._subscriptions.get(t9.key.id);
  1000. i5 && i5.edit(r6, e3);
  1001. });
  1002. await E2(i4);
  1003. }
  1004. this._didEdit = true;
  1005. }
  1006. };
  1007. // node_modules/@arcgis/core/views/2d/layers/features/sources/BaseFeatureSource.js
  1008. var d7 = s.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource");
  1009. var y5 = 4;
  1010. var h3 = class extends f8 {
  1011. constructor(e3) {
  1012. super(e3), this.type = "feature", this.mode = "on-demand", this._adapter = h2(e3.serviceInfo), this._queue = new l2({ concurrency: 8, process: async (e4) => {
  1013. if (f2(e4), r(e4.tile)) {
  1014. const t7 = e4.tile.key.id, { signal: s8 } = e4, i4 = a("esri-tiles-debug") ? { tile: t7.replace(/\//g, "."), depth: e4.depth } : void 0, a8 = await this._adapter.executeQuery(e4.query, { signal: s8, query: { ...i4, ...this._schema.customParameters } });
  1015. return a8.level = e4.tile.key.level, a8;
  1016. }
  1017. return this._adapter.executeQuery(e4.query, { ...e4, query: this._schema.customParameters });
  1018. } }), this._patchQueue = new l2({ concurrency: 8, process: async (e4) => {
  1019. if (f2(e4), r(e4.tile)) {
  1020. const t7 = e4.tile.key.id, { signal: s8 } = e4, i4 = a("esri-tiles-debug") ? { tile: t7.replace(/\//g, "."), depth: e4.depth } : void 0, a8 = await this._adapter.executeQuery(e4.query, { signal: s8, query: { ...i4, ...this._schema.customParameters } });
  1021. return a8.level = e4.tile.key.level, a8;
  1022. }
  1023. return this._adapter.executeQuery(e4.query, { ...e4, query: this._schema.customParameters });
  1024. } });
  1025. }
  1026. destroy() {
  1027. super.destroy(), this._adapter.destroy(), this._queue.destroy(), this._patchQueue.destroy();
  1028. }
  1029. get updating() {
  1030. return !!this._queue.length || Array.from(this._subscriptions.values()).some((e3) => !e3.done);
  1031. }
  1032. get maxRecordCountFactor() {
  1033. const { query: e3 } = this._serviceInfo.capabilities;
  1034. return e3.supportsMaxRecordCountFactor ? y5 : null;
  1035. }
  1036. get maxPageSize() {
  1037. const { query: e3 } = this._serviceInfo.capabilities;
  1038. return (e3.maxRecordCount ?? 8e3) * c(this.maxRecordCountFactor, 1);
  1039. }
  1040. get pageSize() {
  1041. return Math.min(8e3, this.maxPageSize);
  1042. }
  1043. enableEvent(e3, t7) {
  1044. }
  1045. subscribe(e3, r5) {
  1046. super.subscribe(e3, r5);
  1047. const s8 = this._subscriptions.get(e3.id);
  1048. this._fetchDataTile(e3).catch((r6) => {
  1049. g2(r6) || d7.error(new s2("mapview-query-error", "Encountered error when fetching tile", { tile: e3, error: r6 }));
  1050. }).then(() => s8.end());
  1051. }
  1052. unsubscribe(e3) {
  1053. super.unsubscribe(e3);
  1054. }
  1055. readers(e3) {
  1056. return this._subscriptions.get(e3).readers();
  1057. }
  1058. async query(e3) {
  1059. return this._adapter.executeQuery(e3, { query: this._schema.customParameters });
  1060. }
  1061. async queryLastEditDate() {
  1062. const t7 = this._serviceInfo.source, r5 = { ...t7.query, f: "json" };
  1063. return (await U(t7.path, { query: r5, responseType: "json" })).data.editingInfo.lastEditDate;
  1064. }
  1065. createTileQuery(e3, t7 = {}) {
  1066. const s8 = this._serviceInfo.geometryType, i4 = this.createQuery(t7);
  1067. i4.quantizationParameters = t7.quantizationParameters ?? e3.getQuantizationParameters(), i4.resultType = "tile", i4.geometry = e3.extent, this._serviceInfo.capabilities.query.supportsQuantization ? s8 === "esriGeometryPolyline" && (i4.maxAllowableOffset = e3.resolution * a("feature-polyline-generalization-factor")) : s8 !== "esriGeometryPolyline" && s8 !== "esriGeometryPolygon" || (i4.maxAllowableOffset = e3.resolution, s8 === "esriGeometryPolyline" && (i4.maxAllowableOffset *= a("feature-polyline-generalization-factor")));
  1068. const a8 = this._serviceInfo.capabilities.query;
  1069. return i4.defaultSpatialReferenceEnabled = a8.supportsDefaultSpatialReference, i4.compactGeometryEnabled = a8.supportsCompactGeometry, i4;
  1070. }
  1071. async _executePatchQuery(e3, t7, r5, s8) {
  1072. const a8 = t7.clone();
  1073. a8.outFields = [this._serviceInfo.objectIdField, ...r5], a8.returnCentroid = false, a8.returnGeometry = false;
  1074. const o11 = r(a8.start) ? a8.start / 8e3 : 0, n6 = s8.signal;
  1075. return this._patchQueue.push({ tile: e3, query: a8, signal: n6, depth: o11 });
  1076. }
  1077. async _resend(e3, t7) {
  1078. const { query: r5, message: s8 } = e3, a8 = r(r5.outFields) ? r5.outFields : [], u5 = this._queryInfo.outFields, c12 = u5.filter((e4) => !a8.includes(e4));
  1079. if (t(s8.addOrUpdate))
  1080. this._onMessage({ ...s8, type: "append" });
  1081. else if (c12.length)
  1082. try {
  1083. const e4 = this._subscriptions.get(s8.id).tile, i4 = await this._executePatchQuery(e4, r5, c12, t7);
  1084. f2(t7), r5.outFields = u5, s8.addOrUpdate.joinAttributes(i4), this._onMessage({ ...s8, end: s8.end, type: "append" });
  1085. } catch (l9) {
  1086. }
  1087. else
  1088. this._onMessage({ ...s8, type: "append" });
  1089. }
  1090. async _resendSubscription(e3) {
  1091. if (a("esri-2d-update-debug") && console.debug(e3.tile.id, "Resend Subscription"), e3.empty)
  1092. return this._onMessage({ id: e3.tile.id, addOrUpdate: null, end: false, type: "append" });
  1093. const t7 = e3.signal;
  1094. for (const r5 of e3.requests.done)
  1095. await this._resend(r5, { signal: t7 });
  1096. return r(e3.edits) ? this._onMessage(e3.edits) : void 0;
  1097. }
  1098. async resend() {
  1099. const e3 = Array.from(this._subscriptions.values());
  1100. await Promise.all(e3.map((e4) => this._resendSubscription(e4)));
  1101. }
  1102. };
  1103. // node_modules/@arcgis/core/views/2d/layers/features/sources/DrillDownFeatureSource.js
  1104. var i3 = a("esri-mobile");
  1105. var a5 = { maxDrillLevel: i3 ? 1 : 4, maxRecordCountFactor: i3 ? 1 : 3 };
  1106. var o9 = class extends h3 {
  1107. constructor(e3) {
  1108. super(e3);
  1109. }
  1110. async _fetchDataTile(e3) {
  1111. const s8 = this._serviceInfo.capabilities.query.supportsMaxRecordCountFactor, i4 = this._subscriptions.get(e3.key.id), o11 = i4.signal, n6 = e3.getQuantizationParameters();
  1112. let c12 = 0;
  1113. const d11 = async (u5, l9) => {
  1114. const p5 = this._queryInfo, m7 = this.createTileQuery(u5, { maxRecordCountFactor: s8 ? a5.maxRecordCountFactor : void 0, returnExceededLimitFeatures: false, quantizationParameters: n6 });
  1115. c12++;
  1116. try {
  1117. const r5 = await this._queue.push({ tile: e3, query: m7, signal: o11, depth: l9 });
  1118. if (c12--, f2(o11), !r5)
  1119. return;
  1120. if (p5 !== this._queryInfo)
  1121. return void d11(u5, l9);
  1122. if (r5.exceededTransferLimit && l9 < a5.maxDrillLevel) {
  1123. for (const e4 of u5.createChildTiles())
  1124. d11(e4, l9 + 1);
  1125. return;
  1126. }
  1127. const s9 = { id: e3.id, addOrUpdate: r5, end: c12 === 0, type: "append" };
  1128. i4.add({ query: m7, message: s9 }), this._onMessage(s9);
  1129. } catch (h6) {
  1130. g2(h6) || this._onMessage({ id: e3.id, addOrUpdate: null, end: true, type: "append" });
  1131. }
  1132. };
  1133. d11(e3, 0);
  1134. }
  1135. };
  1136. // node_modules/@arcgis/core/layers/graphics/data/StreamFeatureManager.js
  1137. var o10 = "__esri_stream_id__";
  1138. var d8 = "__esri_timestamp__";
  1139. var a6 = 1e3;
  1140. var h4 = class {
  1141. constructor(t7, e3, s8, i4, r5 = 128) {
  1142. this._trackIdToObservations = new Map(), this._idCounter = 0, this._lastPurge = performance.now(), this._addOrUpdated = new Map(), this._removed = [], this._maxAge = 0, this._timeInfo = s8, this._purgeOptions = i4, this.store = t7, this.objectIdField = e3, this.purgeInterval = r5, this._useGeneratedIds = this.objectIdField === o10;
  1143. }
  1144. add(r5) {
  1145. if (this._useGeneratedIds) {
  1146. const t7 = this._nextId();
  1147. r5.attributes[this.objectIdField] = t7, r5.objectId = t7;
  1148. } else
  1149. r5.objectId = r5.attributes[this.objectIdField];
  1150. if (this._addOrUpdated.set(r5.objectId, r5), this._maxAge = Math.max(this._maxAge, r5.attributes[this._timeInfo.startTimeField]), !this._timeInfo.trackIdField)
  1151. return t(this._trackIdLessObservations) && (this._trackIdLessObservations = new s7(1e5)), void this._trackIdLessObservations.enqueue(r5.objectId);
  1152. const o11 = r5.attributes[this._timeInfo.trackIdField];
  1153. if (!this._trackIdToObservations.has(o11)) {
  1154. const s8 = r(this._purgeOptions) && this._purgeOptions.maxObservations != null ? this._purgeOptions.maxObservations : a6, r6 = o3(s8, 0, a6);
  1155. this._trackIdToObservations.set(o11, new s7(r6));
  1156. }
  1157. const d11 = this._trackIdToObservations.get(o11).enqueue(r5.objectId);
  1158. r(d11) && (this._addOrUpdated.has(d11) ? this._addOrUpdated.delete(d11) : this._removed.push(d11));
  1159. }
  1160. checkForUpdates() {
  1161. const t7 = this._getToAdd(), e3 = this._getToRemove(), s8 = performance.now();
  1162. s8 - this._lastPurge >= this.purgeInterval && (this._purge(s8), this._lastPurge = s8);
  1163. const r5 = [];
  1164. if (r(e3))
  1165. for (const o11 of e3) {
  1166. const t8 = this.store.removeById(o11);
  1167. r(t8) && r5.push(t8);
  1168. }
  1169. if (r(t7))
  1170. for (const i4 of t7)
  1171. i4.attributes[d8] = s8, this.store.add(i4);
  1172. (t7 || r5) && this.store.update(t7, r5);
  1173. }
  1174. _getToAdd() {
  1175. if (!this._addOrUpdated.size)
  1176. return null;
  1177. const t7 = new Array(this._addOrUpdated.size);
  1178. let e3 = 0;
  1179. return this._addOrUpdated.forEach((s8) => t7[e3++] = s8), this._addOrUpdated.clear(), t7;
  1180. }
  1181. _getToRemove() {
  1182. const t7 = this._removed;
  1183. return this._removed.length ? (this._removed = [], t7) : null;
  1184. }
  1185. _nextId() {
  1186. const t7 = this._idCounter;
  1187. return this._idCounter = (this._idCounter + 1) % 4294967294 + 1, t7;
  1188. }
  1189. _purge(t7) {
  1190. const e3 = this._purgeOptions;
  1191. r(e3) && (this._purgeSomeByDisplayCount(e3), this._purgeByAge(e3), this._purgeByAgeReceived(t7, e3), this._purgeTracks());
  1192. }
  1193. _purgeSomeByDisplayCount(t7) {
  1194. if (!t7.displayCount)
  1195. return;
  1196. let e3 = this.store.size;
  1197. if (e3 > t7.displayCount) {
  1198. if (this._timeInfo.trackIdField) {
  1199. for (const s8 of this._trackIdToObservations.values())
  1200. if (e3 > t7.displayCount && s8.size) {
  1201. const t8 = e2(s8.dequeue());
  1202. this._removed.push(t8), e3--;
  1203. }
  1204. }
  1205. if (r(this._trackIdLessObservations)) {
  1206. let s8 = e3 - t7.displayCount;
  1207. for (; s8-- > 0; ) {
  1208. const t8 = this._trackIdLessObservations.dequeue();
  1209. r(t8) && this._removed.push(t8);
  1210. }
  1211. }
  1212. }
  1213. }
  1214. _purgeByAge(t7) {
  1215. if (!t7.age || !this._timeInfo?.startTimeField)
  1216. return;
  1217. const e3 = 60 * t7.age * 1e3, s8 = this._maxAge - e3;
  1218. this.store.forEach((t8) => {
  1219. t8.attributes[this._timeInfo.startTimeField] < s8 && this._removed.push(t8.objectId);
  1220. });
  1221. }
  1222. _purgeByAgeReceived(t7, e3) {
  1223. if (!e3.ageReceived)
  1224. return;
  1225. const s8 = t7 - 60 * e3.ageReceived * 1e3;
  1226. this.store.forEach((t8) => {
  1227. t8.attributes[d8] < s8 && this._removed.push(t8.objectId);
  1228. });
  1229. }
  1230. _purgeTracks() {
  1231. this._trackIdToObservations.forEach((t7, e3) => {
  1232. t7.size === 0 && this._trackIdToObservations.delete(e3);
  1233. });
  1234. }
  1235. };
  1236. // node_modules/@arcgis/core/layers/graphics/sources/connections/StreamConnection.js
  1237. var t5 = class extends n2.EventedMixin(d4) {
  1238. onFeature(r5) {
  1239. this.emit("feature", r5);
  1240. }
  1241. };
  1242. t5 = e([n("esri.layers.graphics.sources.connections.StreamConnection")], t5);
  1243. var c7 = t5;
  1244. // node_modules/@arcgis/core/layers/graphics/sources/connections/WebSocketConnection.js
  1245. var p2 = s.getLogger("esri.layers.graphics.sources.connections.WebSocketConnection");
  1246. var u;
  1247. !function(e3) {
  1248. e3[e3.CONNECTING = 0] = "CONNECTING", e3[e3.OPEN = 1] = "OPEN", e3[e3.CLOSING = 2] = "CLOSING", e3[e3.CLOSED = 3] = "CLOSED";
  1249. }(u || (u = {}));
  1250. var m5 = class extends c7 {
  1251. constructor(e3) {
  1252. super(), this.errorString = null;
  1253. const { geometryType: t7, spatialReference: o11, sourceSpatialReference: r5 } = e3;
  1254. this._config = e3, this._featureZScaler = o4(t7, r5, o11), this._open();
  1255. }
  1256. async _open() {
  1257. await this._tryCreateWebSocket(), this.destroyed || await this._handshake();
  1258. }
  1259. destroy() {
  1260. r(this._websocket) && (this._websocket.onopen = null, this._websocket.onclose = null, this._websocket.onerror = null, this._websocket.onmessage = null, this._websocket.close()), this._websocket = null;
  1261. }
  1262. get connectionStatus() {
  1263. if (t(this._websocket))
  1264. return "disconnected";
  1265. switch (this._websocket.readyState) {
  1266. case u.CONNECTING:
  1267. case u.OPEN:
  1268. return "connected";
  1269. case u.CLOSING:
  1270. case u.CLOSED:
  1271. return "disconnected";
  1272. }
  1273. }
  1274. async _tryCreateWebSocket(e3 = this._config.source.path, o11 = 1e3, r5 = 0) {
  1275. try {
  1276. if (this.destroyed)
  1277. return;
  1278. const t7 = Bt(e3, this._config.customParameters);
  1279. this._websocket = await this._createWebSocket(t7), this.notifyChange("connectionStatus");
  1280. } catch (s8) {
  1281. const c12 = o11 / 1e3;
  1282. return this._config.maxReconnectionAttempts && r5 >= this._config.maxReconnectionAttempts ? (p2.error(new s2("websocket-connection", "Exceeded maxReconnectionAttempts attempts. No further attempts will be made")), void this.destroy()) : (p2.error(new s2("websocket-connection", `Failed to connect. Attempting to reconnect in ${c12}s`, s8)), await L(o11), this._tryCreateWebSocket(e3, Math.min(1.5 * o11, 1e3 * this._config.maxReconnectionInterval), r5 + 1));
  1283. }
  1284. }
  1285. _createWebSocket(e3) {
  1286. return new Promise((t7, o11) => {
  1287. const r5 = new WebSocket(e3);
  1288. r5.onopen = () => {
  1289. if (r5.onopen = null, this.destroyed)
  1290. return r5.onclose = null, void r5.close();
  1291. r5.onclose = (e4) => this._onClose(e4), r5.onerror = (e4) => this._onError(e4), r5.onmessage = (e4) => this._onMessage(e4), t7(r5);
  1292. }, r5.onclose = (e4) => {
  1293. r5.onopen = r5.onclose = null, o11(e4);
  1294. };
  1295. });
  1296. }
  1297. async _handshake(e3 = 1e4) {
  1298. const o11 = this._websocket;
  1299. if (t(o11))
  1300. return;
  1301. const r5 = D(), n6 = o11.onmessage, { filter: i4, outFields: a8, spatialReference: l9 } = this._config;
  1302. return r5.timeout(e3), o11.onmessage = (e4) => {
  1303. let s8 = null;
  1304. try {
  1305. s8 = JSON.parse(e4.data);
  1306. } catch (c12) {
  1307. }
  1308. s8 && typeof s8 == "object" || (p2.error(new s2("websocket-connection", "Protocol violation. Handshake failed - malformed message", e4.data)), r5.reject(), this.destroy()), s8.spatialReference?.wkid !== l9?.wkid && (p2.error(new s2("websocket-connection", `Protocol violation. Handshake failed - expected wkid of ${l9.wkid}`, e4.data)), r5.reject(), this.destroy()), s8.format !== "json" && (p2.error(new s2("websocket-connection", "Protocol violation. Handshake failed - format is not set", e4.data)), r5.reject(), this.destroy()), i4 && s8.filter !== i4 && p2.error(new s2("websocket-connection", "Tried to set filter, but server doesn't support it")), a8 && s8.outFields !== a8 && p2.error(new s2("websocket-connection", "Tried to set outFields, but server doesn't support it")), o11.onmessage = n6, r5.resolve();
  1309. }, o11.send(JSON.stringify({ filter: i4, outFields: a8, format: "json", spatialReference: { wkid: l9.wkid } })), r5.promise;
  1310. }
  1311. _onMessage(e3) {
  1312. try {
  1313. const o11 = JSON.parse(e3.data);
  1314. if (o11.type !== "featureResult")
  1315. throw new s2("websocket-connection", "Protocol violation - Expected to find message of type 'featureResult'", o11);
  1316. for (const e4 of o11.features)
  1317. r(this._featureZScaler) && this._featureZScaler(e4.geometry), this.onFeature(e4);
  1318. } catch (o11) {
  1319. return p2.error(new s2("websocket-connection", "Failed to parse message", o11)), void this.destroy();
  1320. }
  1321. }
  1322. _onError(e3) {
  1323. const t7 = "Encountered an error over WebSocket connection";
  1324. this._set("errorString", t7), p2.error("websocket-connection", t7);
  1325. }
  1326. _onClose(e3) {
  1327. this._websocket = null, this.notifyChange("connectionStatus"), e3.code !== 1e3 && p2.error("websocket-connection", `WebSocket closed unexpectedly with error code ${e3.code}`), this.destroyed || this._open();
  1328. }
  1329. };
  1330. e([d()], m5.prototype, "connectionStatus", null), e([d()], m5.prototype, "errorString", void 0), m5 = e([n("esri.layers.graphics.sources.connections.WebSocketConnection")], m5);
  1331. // node_modules/@arcgis/core/layers/graphics/sources/connections/GeoEventConnection.js
  1332. var p3 = s.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection");
  1333. var g6 = 1e4;
  1334. var _2 = { maxQueryDepth: 5, maxRecordCountFactor: 3 };
  1335. var w3 = class extends m5 {
  1336. constructor(e3) {
  1337. super({ ..._2, ...e3 });
  1338. }
  1339. async _open() {
  1340. const e3 = await this._fetchServiceDefinition(this._config.source);
  1341. e3.timeInfo.trackIdField || p3.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");
  1342. const t7 = this._fetchWebSocketUrl(e3.streamUrls, this._config.spatialReference);
  1343. this._buddyServicesQuery || (this._buddyServicesQuery = this._queryBuddyServices()), await this._buddyServicesQuery, await this._tryCreateWebSocket(t7);
  1344. const { filter: r5, outFields: o11 } = this._config;
  1345. this.destroyed || this._setFilter(r5, o11);
  1346. }
  1347. _onMessage(e3) {
  1348. let t7;
  1349. try {
  1350. t7 = this._enrich(JSON.parse(e3.data)), r(this._featureZScaler) && this._featureZScaler(t7.geometry);
  1351. } catch (o11) {
  1352. return void p3.error(new s2("geoevent-connection", "Failed to parse message", o11));
  1353. }
  1354. this.onFeature(t7);
  1355. }
  1356. async _fetchServiceDefinition(e3) {
  1357. const r5 = { f: "json", ...this._config.customParameters }, o11 = U(e3.path, { query: r5, responseType: "json" }), s8 = (await o11).data;
  1358. return this._serviceDefinition = s8, s8;
  1359. }
  1360. _fetchWebSocketUrl(e3, t7) {
  1361. const r5 = e3[0], { urls: o11, token: s8 } = r5, i4 = this._inferWebSocketBaseUrl(o11);
  1362. return Bt(`${i4}/subscribe`, { outSR: "" + t7.wkid, token: s8 });
  1363. }
  1364. _inferWebSocketBaseUrl(e3) {
  1365. if (e3.length === 1)
  1366. return e3[0];
  1367. for (const t7 of e3)
  1368. if (t7.includes("wss"))
  1369. return t7;
  1370. return p3.error(new s2("geoevent-connection", "Unable to infer WebSocket url", e3)), null;
  1371. }
  1372. async _setFilter(e3, t7) {
  1373. const o11 = this._websocket;
  1374. if (t(o11) || t(e3) && t(t7))
  1375. return;
  1376. const s8 = JSON.stringify({ filter: this._serializeFilter(e3, t7) });
  1377. let n6 = false;
  1378. const a8 = D(), u5 = () => {
  1379. n6 || (this.destroyed || this._websocket !== o11 || p3.error(new s2("geoevent-connection", "Server timed out when setting filter")), a8.reject());
  1380. }, f10 = (e4) => {
  1381. const t8 = JSON.parse(e4.data);
  1382. t8.filter && (t8.error && (p3.error(new s2("geoevent-connection", "Failed to set service filter", t8.error)), this._set("errorString", `Could not set service filter - ${t8.error}`), a8.reject(t8.error)), o11.onmessage = this._onMessage.bind(this), n6 = true, a8.resolve());
  1383. };
  1384. return o11.onmessage = f10, o11.send(s8), setTimeout(u5, g6), a8.promise;
  1385. }
  1386. _serializeFilter(e3, t7) {
  1387. const o11 = {};
  1388. if (t(e3) && t(t7))
  1389. return o11;
  1390. if (r(e3) && e3.geometry)
  1391. try {
  1392. const t8 = d2(e3.geometry);
  1393. if (t8.type !== "extent")
  1394. throw new s2(`Expected extent but found type ${t8.type}`);
  1395. o11.geometry = JSON.stringify(t8.shiftCentralMeridian());
  1396. } catch (n6) {
  1397. p3.error(new s2("geoevent-connection", "Encountered an error when setting connection geometryDefinition", n6));
  1398. }
  1399. return r(e3) && e3.where && e3.where !== "1 = 1" && (o11.where = e3.where), r(t7) && (o11.outFields = t7.join(",")), o11;
  1400. }
  1401. _enrich(e3) {
  1402. if (!this._relatedFeatures)
  1403. return e3;
  1404. const t7 = this._serviceDefinition.relatedFeatures.joinField, o11 = e3.attributes[t7];
  1405. if (!this._relatedFeatures.has(o11))
  1406. return p3.warn("geoevent-connection", "Feature join failed. Is the join field configured correctly?", e3), e3;
  1407. const { attributes: s8, geometry: i4 } = this._relatedFeatures.get(o11);
  1408. for (const r5 in s8)
  1409. e3.attributes[r5] = s8[r5];
  1410. return i4 && (e3.geometry = i4), e3.geometry || e3.centroid || p3.error(new s2("geoevent-connection", "Found malformed feature - no geometry found", e3)), e3;
  1411. }
  1412. async _queryBuddyServices() {
  1413. try {
  1414. const { relatedFeatures: e3, keepLatestArchive: t7 } = this._serviceDefinition, r5 = this._queryRelatedFeatures(e3), o11 = this._queryArchive(t7);
  1415. await r5;
  1416. const s8 = await o11;
  1417. if (!s8)
  1418. return;
  1419. for (const i4 of s8.features)
  1420. this.onFeature(this._enrich(i4));
  1421. } catch (e3) {
  1422. p3.error(new s2("geoevent-connection", "Encountered an error when querying buddy services", { error: e3 }));
  1423. }
  1424. }
  1425. async _queryRelatedFeatures(e3) {
  1426. if (!e3)
  1427. return;
  1428. const t7 = await this._queryBuddy(e3.featuresUrl);
  1429. this._addRelatedFeatures(t7);
  1430. }
  1431. async _queryArchive(e3) {
  1432. if (e3)
  1433. return this._queryBuddy(e3.featuresUrl);
  1434. }
  1435. async _queryBuddy(e3) {
  1436. const t7 = new (await import("./FeatureLayer-TEDDRCNO.js")).default({ url: e3 }), { capabilities: r5 } = await t7.load(), o11 = r5.query.supportsMaxRecordCountFactor, s8 = r5.query.supportsPagination, i4 = r5.query.supportsCentroid, c12 = this._config.maxRecordCountFactor, u5 = t7.capabilities.query.maxRecordCount, f10 = o11 ? u5 * c12 : u5, d11 = new b3();
  1437. if (d11.outFields = c(this._config.outFields, ["*"]), d11.where = c(m(this._config.filter, "where"), "1=1"), d11.returnGeometry = true, d11.returnExceededLimitFeatures = true, d11.outSpatialReference = k.fromJSON(this._config.spatialReference), i4 && (d11.returnCentroid = true), o11 && (d11.maxRecordCountFactor = c12), s8)
  1438. return d11.num = f10, t7.destroy(), this._queryPages(e3, d11);
  1439. const y8 = await c3(e3, d11, this._config.sourceSpatialReference);
  1440. return t7.destroy(), y8.data;
  1441. }
  1442. async _queryPages(e3, t7, r5 = [], o11 = 0) {
  1443. t7.start = r(t7.num) ? o11 * t7.num : null;
  1444. const { data: i4 } = await c3(e3, t7, this._config.sourceSpatialReference);
  1445. return i4.exceededTransferLimit && o11 < this._config.maxQueryDepth ? (i4.features.forEach((e4) => r5.push(e4)), this._queryPages(e3, t7, r5, o11 + 1)) : (r5.forEach((e4) => i4.features.push(e4)), i4);
  1446. }
  1447. _addRelatedFeatures(e3) {
  1448. const t7 = new Map(), r5 = e3.features, o11 = this._serviceDefinition.relatedFeatures.joinField;
  1449. for (const s8 of r5) {
  1450. const e4 = s8.attributes[o11];
  1451. t7.set(e4, s8);
  1452. }
  1453. this._relatedFeatures = t7;
  1454. }
  1455. };
  1456. w3 = e([n("esri.layers.graphics.sources.connections.GeoEventConnection")], w3);
  1457. var F3 = w3;
  1458. // node_modules/@arcgis/core/layers/graphics/sources/connections/createConnection.js
  1459. function t6(t7, o11, r5, c12, i4, s8, a8, m7) {
  1460. const p5 = t7.path.indexOf("wss://") === 0 || t7.path.indexOf("ws://") === 0, f10 = { source: t7, sourceSpatialReference: o11, spatialReference: r5, geometryType: c12, filter: i4, maxReconnectionAttempts: s8, maxReconnectionInterval: a8, customParameters: m7 };
  1461. return p5 ? new m5(f10) : new F3(f10);
  1462. }
  1463. // node_modules/@arcgis/core/views/2d/layers/features/sources/GeoEventSource.js
  1464. var m6 = 2500;
  1465. function l7(t7, s8) {
  1466. const r5 = t7.weakClone();
  1467. if (r(t7.geometry)) {
  1468. const e3 = b2(s8, t7.geometry.coords[0]), i4 = M2(s8, t7.geometry.coords[1]);
  1469. r5.geometry = new t3([], [e3, i4]);
  1470. }
  1471. return r5;
  1472. }
  1473. function _3(e3) {
  1474. return e3 === "esriGeometryPoint" ? l7 : (t7, s8) => {
  1475. const r5 = t7.weakClone(), n6 = new t3(), o11 = false, c12 = false, d11 = ie(n6, t7.geometry, o11, c12, e3, s8, false, false);
  1476. return r5.geometry = d11, r5;
  1477. };
  1478. }
  1479. function f9(t7) {
  1480. return t7 === "esriGeometryPoint" ? (t8) => r(t8.geometry) ? { minX: t8.geometry.coords[0], minY: t8.geometry.coords[1], maxX: t8.geometry.coords[0], maxY: t8.geometry.coords[1] } : { minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 } : (t8) => {
  1481. let s8 = 1 / 0, r5 = 1 / 0, i4 = -1 / 0, n6 = -1 / 0;
  1482. return r(t8.geometry) && t8.geometry.forEachVertex((e3, t9) => {
  1483. s8 = Math.min(s8, e3), r5 = Math.min(r5, t9), i4 = Math.max(i4, e3), n6 = Math.max(n6, t9);
  1484. }), { minX: s8, minY: r5, maxX: i4, maxY: n6 };
  1485. };
  1486. }
  1487. function g7(e3, t7) {
  1488. const r5 = i(9, f9(t7));
  1489. return r5.load(e3), r5;
  1490. }
  1491. function v4(e3, t7) {
  1492. return e3.search({ minX: t7.bounds[0], minY: t7.bounds[1], maxX: t7.bounds[2], maxY: t7.bounds[3] });
  1493. }
  1494. var y6 = class {
  1495. constructor(e3, t7) {
  1496. this.onUpdate = e3, this._geometryType = t7, this._objectIdToFeature = new Map();
  1497. }
  1498. get _features() {
  1499. const e3 = [];
  1500. return this._objectIdToFeature.forEach((t7) => e3.push(t7)), e3;
  1501. }
  1502. add(e3) {
  1503. this._objectIdToFeature.set(e3.objectId, e3), this._index = null;
  1504. }
  1505. get(e3) {
  1506. return this._objectIdToFeature.has(e3) ? this._objectIdToFeature.get(e3) : null;
  1507. }
  1508. forEach(e3) {
  1509. this._objectIdToFeature.forEach(e3);
  1510. }
  1511. search(e3) {
  1512. return this._index || (this._index = g7(this._features, this._geometryType)), v4(this._index, e3);
  1513. }
  1514. removeById(e3) {
  1515. const t7 = this._objectIdToFeature.get(e3);
  1516. return t7 ? (this._objectIdToFeature.delete(e3), this._index = null, t7) : null;
  1517. }
  1518. update(e3, t7) {
  1519. this.onUpdate(e3, t7);
  1520. }
  1521. get size() {
  1522. return this._objectIdToFeature.size;
  1523. }
  1524. };
  1525. var b4 = class extends f8 {
  1526. constructor(e3) {
  1527. super(e3), this.type = "geoevent", this._dataReceiveEventEnabled = false, this._level = 0, this._updateInfo = { websocket: 0, client: 0 };
  1528. const { outSR: s8 } = e3, { geometryType: r5, objectIdField: i4, timeInfo: n6, purgeOptions: o11, source: a8, spatialReference: u5, serviceFilter: h6, maxReconnectionAttempts: p5, maxReconnectionInterval: l9, updateInterval: f10, enableDataReceived: g9, customParameters: v5 } = e3.serviceInfo, b5 = new y6(this._onUpdate.bind(this), r5), I2 = new h4(b5, i4, n6, o11), j4 = t6(a8, u5, s8, r5, h6, p5, l9, v5);
  1529. this._store = b5, this._manager = I2, this._connection = j4, this._quantize = _3(r5), this._dataReceiveEventEnabled = g9, this._handles = [this._connection.on("feature", (e4) => this._onFeature(e4)), l(() => j4.connectionStatus, (e4) => this.events.emit("connectionStatus", e4)), l(() => j4.errorString, (e4) => this.events.emit("errorString", e4))], this._initUpdateInterval = () => {
  1530. let t7 = performance.now();
  1531. this._updateIntervalId = setInterval(() => {
  1532. const s9 = performance.now(), r6 = s9 - t7;
  1533. if (r6 > m6) {
  1534. t7 = s9;
  1535. const e4 = Math.round(this._updateInfo.client / (r6 / 1e3)), i5 = Math.round(this._updateInfo.websocket / (r6 / 1e3));
  1536. this._updateInfo.client = 0, this._updateInfo.websocket = 0, this.events.emit("updateRate", { client: e4, websocket: i5 });
  1537. }
  1538. e3.canAcceptRequest() && this._manager.checkForUpdates();
  1539. }, f10);
  1540. }, this._initUpdateInterval();
  1541. }
  1542. destroy() {
  1543. super.destroy(), this._clearUpdateInterval(), this._handles.forEach((e3) => e3.remove()), this._connection.destroy();
  1544. }
  1545. _fetchDataTile() {
  1546. }
  1547. pauseStream() {
  1548. this._clearUpdateInterval();
  1549. }
  1550. resumeStream() {
  1551. this._initUpdateInterval();
  1552. }
  1553. enableEvent(e3, t7) {
  1554. e3 === "data-received" && (this._dataReceiveEventEnabled = t7);
  1555. }
  1556. get updating() {
  1557. return false;
  1558. }
  1559. subscribe(e3, t7) {
  1560. super.subscribe(e3, t7);
  1561. const s8 = this._subscriptions.get(e3.id);
  1562. this._level = e3.level;
  1563. const r5 = this._getTileFeatures(e3);
  1564. this._onMessage({ type: "append", id: e3.key.id, addOrUpdate: r5, end: true }), s8.didSend = true;
  1565. }
  1566. unsubscribe(e3) {
  1567. super.unsubscribe(e3);
  1568. }
  1569. *readers(t7) {
  1570. const s8 = this._subscriptions.get(t7), { tile: r5 } = s8;
  1571. yield this._getTileFeatures(r5);
  1572. for (const i4 of s8.requests.stream.entries)
  1573. r(i4) && r(i4.addOrUpdate) && (yield i4.addOrUpdate);
  1574. }
  1575. createTileQuery(e3) {
  1576. throw new Error("Service does not support tile queries");
  1577. }
  1578. async resend() {
  1579. this._subscriptions.forEach((e3) => {
  1580. const { tile: t7 } = e3, s8 = { type: "append", id: t7.id, addOrUpdate: this._getTileFeatures(t7), end: true };
  1581. this._onMessage(s8);
  1582. });
  1583. }
  1584. _getTileFeatures(e3) {
  1585. const t7 = this._store.search(e3).map((t8) => this._quantize(t8, e3.transform));
  1586. return d5.fromOptimizedFeatures(t7, this._serviceInfo, e3.transform);
  1587. }
  1588. _onFeature(e3) {
  1589. this._updateInfo.websocket++;
  1590. try {
  1591. this._dataReceiveEventEnabled && this.events.emit("feature", e3);
  1592. const t7 = Q(e3, this._serviceInfo.geometryType, false, false, this._serviceInfo.objectIdField);
  1593. this._manager.add(t7);
  1594. } catch (t7) {
  1595. }
  1596. }
  1597. _clearUpdateInterval() {
  1598. clearInterval(this._updateIntervalId), this._updateIntervalId = 0;
  1599. }
  1600. _onUpdate(t7, s8) {
  1601. r(t7) && (this._updateInfo.client += t7.length), this._subscriptions.forEach((e3, t8) => {
  1602. e3.didSend && e3.tile.level === this._level && this._onMessage({ type: "append", id: t8, addOrUpdate: null, clear: true, end: false });
  1603. }), this._subscriptions.forEach((e3, t8) => {
  1604. if (!e3.didSend || e3.tile.level !== this._level)
  1605. return;
  1606. const s9 = e3.tile, r5 = { type: "append", id: t8, addOrUpdate: this._getTileFeatures(s9), remove: [], end: true, status: t4.empty() };
  1607. e3.requests.stream.enqueue(r5), this._onMessage(r5);
  1608. });
  1609. }
  1610. };
  1611. // node_modules/@arcgis/core/views/2d/layers/features/sources/PagedFeatureSource.js
  1612. var n5 = s.getLogger("esri.views.2d.layers.features.sources.FeatureSource");
  1613. var d9 = class extends h3 {
  1614. constructor(e3) {
  1615. super(e3);
  1616. }
  1617. async _fetchDataTile(t7) {
  1618. const r5 = 6, i4 = 20, o11 = this._subscriptions.get(t7.key.id);
  1619. let d11 = false, c12 = 0, u5 = 0;
  1620. const p5 = (e3, r6) => {
  1621. u5--, f2(o11);
  1622. const a8 = t7.id, i5 = e3.reader, n6 = e3.query;
  1623. if (!i5.exceededTransferLimit) {
  1624. if (d11 = true, r6 !== 0 && !i5.hasFeatures) {
  1625. const e5 = { id: a8, addOrUpdate: i5, end: u5 === 0, type: "append" };
  1626. return o11.add({ message: e5, query: n6 }), void this._onMessage(e5);
  1627. }
  1628. const e4 = { id: a8, addOrUpdate: i5, end: u5 === 0, type: "append" };
  1629. return o11.add({ message: e4, query: n6 }), void this._onMessage(e4);
  1630. }
  1631. const c13 = { id: a8, addOrUpdate: i5, end: d11 && u5 === 0, type: "append" };
  1632. o11.add({ message: c13, query: n6 }), this._onMessage(c13);
  1633. };
  1634. let h6 = 0, m7 = 0;
  1635. for (; !d11 && m7++ < i4; ) {
  1636. let i5;
  1637. for (let r6 = 0; r6 < h6 + 1; r6++) {
  1638. const r7 = c12++;
  1639. u5++, i5 = this._fetchDataTilePage(t7, r7, o11).then((e3) => e3 && p5(e3, r7)).catch((r8) => {
  1640. d11 = true, g2(r8) || (n5.error(new s2("mapview-query-error", "Encountered error when fetching tile", { tile: t7, error: r8 })), this._onMessage({ id: t7.id, addOrUpdate: null, end: d11, type: "append" }));
  1641. });
  1642. }
  1643. await i5, f2(o11), h6 = Math.min(h6 + 2, r5);
  1644. }
  1645. }
  1646. async _fetchDataTilePage(e3, t7, a8) {
  1647. f2(a8);
  1648. const o11 = this._queryInfo, n6 = { start: this.pageSize * t7, num: this.pageSize, returnExceededLimitFeatures: true, quantizationParameters: e3.getQuantizationParameters() };
  1649. r(this.maxRecordCountFactor) && (n6.maxRecordCountFactor = this.maxRecordCountFactor);
  1650. const d11 = this.createTileQuery(e3, n6);
  1651. try {
  1652. const r5 = a8.signal, i4 = await this._queue.push({ tile: e3, query: d11, signal: r5, depth: t7 });
  1653. return f2(a8), i4 ? o11 !== this._queryInfo ? this._fetchDataTilePage(e3, t7, a8) : { reader: i4, query: d11 } : null;
  1654. } catch (c12) {
  1655. return b(c12), null;
  1656. }
  1657. }
  1658. };
  1659. // node_modules/@arcgis/core/views/2d/layers/features/sources/SnapshotFeatureSource.js
  1660. var u2 = s.getLogger("esri.views.2d.layers.features.sources.SnapshotFeatureSource");
  1661. function l8(t7, e3, s8) {
  1662. const r5 = t7.getXHydrated(), o11 = t7.getYHydrated(), a8 = e3.getColumnForX(r5), i4 = Math.floor(e3.normalizeCol(a8));
  1663. return `${s8}/${Math.floor(e3.getRowForY(o11))}/${i4}`;
  1664. }
  1665. function c8(t7, e3) {
  1666. if (t(t7))
  1667. return null;
  1668. const s8 = e3.transform, o11 = t7.getQuantizationTransform();
  1669. if (t(o11)) {
  1670. const [e4, r5] = s8.scale, [o12, a9] = s8.translate, i5 = -o12 / e4, n7 = 1 / e4, d12 = a9 / r5, h7 = 1 / -r5;
  1671. return t7.transform(i5, d12, n7, h7);
  1672. }
  1673. const [a8, i4] = o11.scale, [n6, d11] = o11.translate, [h6, u5] = s8.scale, [l9, c12] = s8.translate, g9 = a8 / h6, p5 = (n6 - l9) / h6, _4 = i4 / u5, m7 = (-d11 + c12) / u5;
  1674. return t7.transform(p5, m7, g9, _4);
  1675. }
  1676. var g8 = class extends h3 {
  1677. constructor(t7) {
  1678. super(t7), this.mode = "snapshot", this._loading = true, this._controller = new AbortController(), this._downloadPromise = null, this._didSendEnd = false, this._queries = new Array(), this._invalidated = false, this._hasAggregates = false, this._random = new t2(1e3), this._store = t7.store, this._markedIdsBufId = this._store.storage.createBitset();
  1679. }
  1680. destroy() {
  1681. super.destroy(), this._controller.abort();
  1682. }
  1683. get loading() {
  1684. return this._loading;
  1685. }
  1686. get _signal() {
  1687. return this._controller.signal;
  1688. }
  1689. update(t7, e3) {
  1690. super.update(t7, e3), this._hasAggregates = t7.targets.aggregate;
  1691. }
  1692. async resend(t7 = false) {
  1693. if (await this._downloadPromise, this._invalidated || t7) {
  1694. const t8 = f(this._schema.featureCount, "Expected featureCount to be defined");
  1695. return this._invalidated = false, this._subscriptions.forEach((t9) => t9.clear()), this._downloadPromise = this._download(t8), void await this._downloadPromise;
  1696. }
  1697. const s8 = this._queries.map(({ query: t8, reader: e3 }) => this._sendPatchQuery(t8, e3));
  1698. await Promise.all(s8), this._subscriptions.forEach((t8) => {
  1699. t8.requests.done.forEach((t9) => this._onMessage(t9.message));
  1700. });
  1701. }
  1702. async refresh() {
  1703. await this.resend(true);
  1704. }
  1705. async _sendPatchQuery(t7, e3) {
  1706. const r5 = r(t7.outFields) ? t7.outFields : [], a8 = this._queryInfo.outFields, i4 = a8.filter((t8) => !r5.includes(t8));
  1707. if (!i4.length)
  1708. return;
  1709. const n6 = t7.clone(), d11 = this._signal;
  1710. n6.returnGeometry = false, n6.returnCentroid = false, n6.outFields = i4, t7.outFields = a8;
  1711. const h6 = await this._queue.push({ query: n6, depth: 0, signal: d11 });
  1712. f2({ signal: d11 }), e3.joinAttributes(h6);
  1713. }
  1714. async _fetchDataTile(t7) {
  1715. if (!this._downloadPromise) {
  1716. const t8 = f(this._schema.featureCount, "Expected featureCount to be defined");
  1717. this._downloadPromise = this._download(t8);
  1718. }
  1719. const s8 = this._store.search(t7), r5 = this._subscriptions.get(t7.key.id), o11 = s8.length - 1;
  1720. for (let e3 = 0; e3 < o11; e3++) {
  1721. const o12 = c8(s8[e3], t7), i5 = { type: "append", id: t7.id, addOrUpdate: o12, end: false, status: t4.empty() };
  1722. r5.add({ query: null, message: i5 }), this._hasAggregates || await L(1), this._onMessage(i5);
  1723. }
  1724. const i4 = c8(o11 >= 0 ? s8[o11] : null, t7), n6 = this._didSendEnd, d11 = { type: "append", id: t7.id, addOrUpdate: i4, end: n6, status: t4.empty() };
  1725. r5.add({ query: null, message: d11 }), this._onMessage(d11);
  1726. }
  1727. async _download(t7) {
  1728. try {
  1729. await this.whenInitialized();
  1730. const e3 = this._store.storage.getBitset(this._markedIdsBufId), s8 = new Set();
  1731. e3.clear();
  1732. const r5 = Math.ceil(t7 / this.pageSize), o11 = Array.from({ length: r5 }, (t8, e4) => e4).sort((t8, e4) => this._random.getInt() - this._random.getInt()).map((t8) => this._downloadPage(t8, e3, s8));
  1733. await Promise.all(o11), this._store.sweepFeatures(e3, this._store.storage), this._store.sweepFeatureSets(s8);
  1734. } catch (e3) {
  1735. u2.error("mapview-snapshot-source", "Encountered and error when downloading feature snapshot", e3);
  1736. }
  1737. this._sendEnd(), this._loading = false;
  1738. }
  1739. async _downloadPage(t7, e3, r5) {
  1740. const a8 = this.pageSize, i4 = { start: t7 * a8, num: a8, cacheHint: true };
  1741. r(this.maxRecordCountFactor) && (i4.maxRecordCountFactor = this.maxRecordCountFactor);
  1742. const n6 = this.createQuery(i4), d11 = this._signal, h6 = await this._queue.push({ query: n6, depth: t7, signal: d11 });
  1743. f2({ signal: d11 }), this._queries.push({ query: n6, reader: h6 }), this._store.insert(h6), r5.add(h6.instance);
  1744. const u5 = h6.getCursor();
  1745. for (; u5.next(); )
  1746. e3.set(u5.getDisplayId());
  1747. this._send(h6);
  1748. }
  1749. _send(t7) {
  1750. if (!this._subscriptions.size)
  1751. return;
  1752. let e3 = null;
  1753. const o11 = new Map(), a8 = new Set(), i4 = new Map();
  1754. this._subscriptions.forEach((t8) => {
  1755. const s8 = t8.tile;
  1756. o11.set(s8.key.id, null), e3 = s8.tileInfoView, a8.add(s8.level);
  1757. const { row: r5, col: n6 } = s8.key, d11 = `${s8.level}/${r5}/${n6}`, h6 = i4.get(d11) ?? [];
  1758. h6.push(t8), i4.set(d11, h6);
  1759. });
  1760. for (const s8 of a8) {
  1761. const a9 = e3.getLODInfoAt(s8), n6 = t7.getCursor();
  1762. for (; n6.next(); ) {
  1763. const t8 = l8(n6, a9, s8), e4 = n6.getIndex();
  1764. if (i4.has(t8))
  1765. for (const s9 of i4.get(t8)) {
  1766. const t9 = s9.tile.id;
  1767. let a10 = o11.get(t9);
  1768. t(a10) && (a10 = [], o11.set(t9, a10)), a10.push(e4);
  1769. }
  1770. }
  1771. }
  1772. o11.forEach((e4, r5) => {
  1773. if (r(e4)) {
  1774. const s8 = this._subscriptions.get(r5), o12 = { type: "append", id: r5, addOrUpdate: c8(r2.from(t7, e4), s8.tile), end: false, status: t4.empty() };
  1775. s8.add({ query: null, message: o12 }), this._onMessage(o12);
  1776. }
  1777. });
  1778. }
  1779. _sendEnd() {
  1780. this._subscriptions.forEach((t7) => {
  1781. const e3 = { type: "append", id: t7.tile.id, addOrUpdate: null, end: true, status: t4.empty() };
  1782. t7.add({ query: null, message: e3 }), this._onMessage(e3);
  1783. }), this._didSendEnd = true;
  1784. }
  1785. };
  1786. // node_modules/@arcgis/core/views/2d/layers/features/sources/createSource.js
  1787. function a7(e3, r5, a8, u5, i4, p5) {
  1788. const f10 = c9(e3, r5, a8, u5, i4, p5);
  1789. switch (f10.type) {
  1790. case "feature":
  1791. switch (f10.origin) {
  1792. case "hosted":
  1793. case "local":
  1794. return new d9(f10);
  1795. case "snapshot":
  1796. return new g8(f10);
  1797. case "unknown":
  1798. return new o9(f10);
  1799. }
  1800. case "geoevent":
  1801. return new b4(f10);
  1802. }
  1803. }
  1804. function c9(t7, o11, n6, s8, a8, c12) {
  1805. switch (t7.type) {
  1806. case "snapshot":
  1807. return { type: "feature", origin: "snapshot", featureCount: c(t7.featureCount, 0), serviceInfo: t7, onMessage: s8, outSR: o11, tileInfoView: n6, canAcceptRequest: a8, store: c12 };
  1808. case "stream":
  1809. return { type: "geoevent", serviceInfo: t7, onMessage: s8, outSR: o11, canAcceptRequest: a8 };
  1810. case "memory":
  1811. case "on-demand":
  1812. return { type: "feature", serviceInfo: t7, onMessage: s8, outSR: o11, origin: u5(t7.source), tileInfoView: n6, canAcceptRequest: a8 };
  1813. }
  1814. function u5(e3) {
  1815. return Array.isArray(e3) ? "local" : "path" in e3 && g4(e3.path) ? "hosted" : "unknown";
  1816. }
  1817. }
  1818. // node_modules/@arcgis/core/geohash/geohashUtils.js
  1819. var c10 = new Float64Array(2);
  1820. var h5 = new Float64Array(2);
  1821. function x2(t7, n6) {
  1822. let o11 = -90, e3 = 90, r5 = -180, c12 = 180;
  1823. for (let h6 = 0; h6 < n6; h6++) {
  1824. const n7 = Math.ceil((h6 + 1) / 2), f10 = Math.floor((h6 + 1) / 2), l9 = 1 - h6 % 2, a8 = 30 - (3 * n7 + 2 * f10), u5 = 30 - (2 * n7 + 3 * f10), s8 = 3 * l9 + 2 * (1 - l9), i4 = 2 * l9 + 3 * (1 - l9), M4 = 3 * l9 + 7 * (1 - l9) << u5, g9 = (7 * l9 + 3 * (1 - l9) << a8 & t7.geohashX) >> a8, b5 = (M4 & t7.geohashY) >> u5;
  1825. for (let t8 = s8 - 1; t8 >= 0; t8--) {
  1826. const n8 = (r5 + c12) / 2, o12 = g9 & 1 << t8 ? 1 : 0;
  1827. r5 = (1 - o12) * r5 + o12 * n8, c12 = (1 - o12) * n8 + o12 * c12;
  1828. }
  1829. for (let t8 = i4 - 1; t8 >= 0; t8--) {
  1830. const n8 = (o11 + e3) / 2, r6 = b5 & 1 << t8 ? 1 : 0;
  1831. o11 = (1 - r6) * o11 + r6 * n8, e3 = (1 - r6) * n8 + r6 * e3;
  1832. }
  1833. }
  1834. return [r5, o11, c12, e3];
  1835. }
  1836. function y7(t7, n6, o11, e3) {
  1837. e3 % 2 && (e3 += 1);
  1838. let r5 = 0, c12 = 0, h6 = -90, f10 = 90, l9 = -180, a8 = 180;
  1839. for (let u5 = 0; u5 < e3 / 2; u5++) {
  1840. for (let t8 = 0; t8 < 5; t8++) {
  1841. const n7 = (l9 + a8) / 2, e4 = o11 > n7 ? 1 : 0;
  1842. r5 |= e4 << 29 - (t8 + 5 * u5), l9 = (1 - e4) * l9 + e4 * n7, a8 = (1 - e4) * n7 + e4 * a8;
  1843. }
  1844. for (let t8 = 0; t8 < 5; t8++) {
  1845. const o12 = (h6 + f10) / 2, e4 = n6 > o12 ? 1 : 0;
  1846. c12 |= e4 << 29 - (t8 + 5 * u5), h6 = (1 - e4) * h6 + e4 * o12, f10 = (1 - e4) * o12 + e4 * f10;
  1847. }
  1848. }
  1849. t7.geohashX = r5, t7.geohashY = c12;
  1850. }
  1851. function p4(t7, n6, o11, e3, r5) {
  1852. r5 % 2 && (r5 += 1);
  1853. let c12 = 0, h6 = 0, f10 = -90, l9 = 90, a8 = -180, u5 = 180;
  1854. for (let s8 = 0; s8 < r5 / 2; s8++) {
  1855. for (let t8 = 0; t8 < 5; t8++) {
  1856. const n7 = (a8 + u5) / 2, o12 = e3 > n7 ? 1 : 0;
  1857. c12 |= o12 << 29 - (t8 + 5 * s8), a8 = (1 - o12) * a8 + o12 * n7, u5 = (1 - o12) * n7 + o12 * u5;
  1858. }
  1859. for (let t8 = 0; t8 < 5; t8++) {
  1860. const n7 = (f10 + l9) / 2, e4 = o11 > n7 ? 1 : 0;
  1861. h6 |= e4 << 29 - (t8 + 5 * s8), f10 = (1 - e4) * f10 + e4 * n7, l9 = (1 - e4) * n7 + e4 * l9;
  1862. }
  1863. }
  1864. t7[2 * n6] = c12, t7[2 * n6 + 1] = h6;
  1865. }
  1866. // node_modules/@arcgis/core/geohash/GeohashTree.js
  1867. var c11 = class {
  1868. constructor(e3 = [], s8, i4 = 8096) {
  1869. this.onRelease = (t7) => {
  1870. }, this._nodes = 0, this._root = new u3(this, 0, 0, 0), this._statisticFields = e3, this._pool = i4 ? new s7(8096) : null, this._serviceInfo = s8;
  1871. }
  1872. destroy() {
  1873. this.clear();
  1874. }
  1875. _acquire(t7, s8, i4) {
  1876. this._nodes++;
  1877. let o11 = null;
  1878. return r(this._pool) && (o11 = this._pool.dequeue()), r(o11) ? o11.realloc(t7, s8, i4) : o11 = new u3(this, t7, s8, i4), o11;
  1879. }
  1880. _release(t7) {
  1881. this.onRelease(t7), this._nodes--, r(this._pool) && this._pool.enqueue(t7);
  1882. }
  1883. get count() {
  1884. return this._root.count;
  1885. }
  1886. get size() {
  1887. return this._nodes;
  1888. }
  1889. get poolSize() {
  1890. return E(this._pool, 0, (t7) => t7.size);
  1891. }
  1892. get depth() {
  1893. let t7 = 0;
  1894. return this.forEach((e3) => t7 = Math.max(t7, e3.depth)), t7;
  1895. }
  1896. dropLevels(t7) {
  1897. this.forEach((e3) => {
  1898. if (e3.depth >= t7)
  1899. for (let t8 = 0; t8 < e3.children.length; t8++) {
  1900. const s8 = e3.children[t8];
  1901. s8 && this._release(s8);
  1902. }
  1903. }), this.forEach((e3) => {
  1904. if (e3.depth >= t7)
  1905. for (let t8 = 0; t8 < e3.children.length; t8++)
  1906. e3.children[t8] = null;
  1907. });
  1908. }
  1909. clear() {
  1910. this.forEach((t7) => this._release(t7)), this._root = new u3(this, 0, 0, 0);
  1911. }
  1912. insert(t7, e3, s8 = 0) {
  1913. const i4 = d5.fromOptimizedFeatures([t7], this._serviceInfo).getCursor();
  1914. i4.next();
  1915. const o11 = i4.readGeometry();
  1916. if (!o11)
  1917. return;
  1918. const [n6, a8] = o11.coords, r5 = t7.geohashX, l9 = t7.geohashY;
  1919. this.insertCursor(i4, t7.displayId, n6, a8, r5, l9, e3, s8);
  1920. }
  1921. insertCursor(t7, e3, s8, i4, o11, n6, a8, r5 = 0) {
  1922. let l9 = this._root, h6 = 0, c12 = 0, u5 = 0;
  1923. for (; l9 !== null; ) {
  1924. if (l9.depth >= r5 && (l9.count += 1, l9.xTotal += s8, l9.yTotal += i4, l9.xGeohashTotal += o11, l9.yGeohashTotal += n6, l9.referenceId = e3, this._updateStatisticsCursor(t7, l9, 1)), h6 >= a8)
  1925. return void l9.add(e3);
  1926. const d11 = Math.ceil((h6 + 1) / 2), f10 = Math.floor((h6 + 1) / 2), x5 = 1 - h6 % 2, m7 = 30 - (3 * d11 + 2 * f10), p5 = 30 - (2 * d11 + 3 * f10), g9 = (o11 & 7 * x5 + 3 * (1 - x5) << m7) >> m7, y8 = (n6 & 3 * x5 + 7 * (1 - x5) << p5) >> p5, _4 = g9 + y8 * (8 * x5 + 4 * (1 - x5));
  1927. c12 = c12 << 3 * x5 + 2 * (1 - x5) | g9, u5 = u5 << 2 * x5 + 3 * (1 - x5) | y8, l9.children[_4] == null && (l9.children[_4] = this._acquire(c12, u5, h6 + 1)), h6 += 1, l9 = l9.children[_4];
  1928. }
  1929. }
  1930. remove(t7, e3) {
  1931. const s8 = d5.fromOptimizedFeatures([t7], this._serviceInfo).getCursor();
  1932. s8.next();
  1933. const i4 = s8.readGeometry();
  1934. if (!i4)
  1935. return;
  1936. const [o11, n6] = i4.coords, a8 = t7.geohashX, r5 = t7.geohashY;
  1937. this.removeCursor(s8, o11, n6, a8, r5, e3);
  1938. }
  1939. removeCursor(t7, e3, s8, i4, o11, n6) {
  1940. let a8 = this._root, r5 = 0;
  1941. for (; a8 !== null; ) {
  1942. if (a8.count -= 1, a8.xTotal -= e3, a8.yTotal -= s8, a8.xGeohashTotal -= i4, a8.yGeohashTotal -= o11, this._updateStatisticsCursor(t7, a8, -1), r5 >= n6)
  1943. return void a8.remove(t7.getDisplayId());
  1944. const l9 = Math.ceil((r5 + 1) / 2), h6 = Math.floor((r5 + 1) / 2), c12 = 1 - r5 % 2, u5 = 30 - (3 * l9 + 2 * h6), d11 = 30 - (2 * l9 + 3 * h6), f10 = ((i4 & 7 * c12 + 3 * (1 - c12) << u5) >> u5) + ((o11 & 3 * c12 + 7 * (1 - c12) << d11) >> d11) * (8 * c12 + 4 * (1 - c12)), x5 = a8.children[f10];
  1945. x5.count === 1 && (this._release(x5), a8.children[f10] = null), r5 += 1, a8 = x5;
  1946. }
  1947. }
  1948. forEach(t7) {
  1949. let e3 = this._root;
  1950. for (; e3 !== null; ) {
  1951. const s8 = this._linkChildren(e3) || e3.next;
  1952. t7(e3), e3 = s8;
  1953. }
  1954. }
  1955. find(t7, e3, s8) {
  1956. return this._root.find(t7, e3, s8, 0, 0, 0);
  1957. }
  1958. findIf(t7) {
  1959. let e3 = null;
  1960. return this.forEach((s8) => {
  1961. t7(s8) && (e3 = s8);
  1962. }), e3;
  1963. }
  1964. findAllIf(t7) {
  1965. const e3 = [];
  1966. return this.forEach((s8) => {
  1967. t7(s8) && e3.push(s8);
  1968. }), e3;
  1969. }
  1970. findSingleOccupancyNode(t7, e3, s8, i4, o11) {
  1971. let n6 = this._root;
  1972. for (; n6 !== null; ) {
  1973. const a8 = n6.depth, r5 = n6.xNode, l9 = n6.yNode, h6 = 1 - a8 % 2, c12 = n6.xGeohashTotal / n6.count, u5 = n6.yGeohashTotal / n6.count;
  1974. if (n6.count === 1 && t7 < c12 && c12 <= s8 && e3 < u5 && u5 <= i4)
  1975. return n6;
  1976. if (a8 >= o11) {
  1977. n6 = n6.next;
  1978. continue;
  1979. }
  1980. const d11 = Math.ceil((a8 + 1) / 2), f10 = Math.floor((a8 + 1) / 2), x5 = 30 - (3 * d11 + 2 * f10), m7 = 30 - (2 * d11 + 3 * f10), p5 = ~((1 << x5) - 1), g9 = ~((1 << m7) - 1), y8 = (t7 & p5) >> x5, _4 = (e3 & g9) >> m7, M4 = (s8 & p5) >> x5, N = (i4 & g9) >> m7, T2 = r5 << 3 * h6 + 2 * (1 - h6), I2 = l9 << 2 * h6 + 3 * (1 - h6), S4 = T2 + 8 * h6 + 4 * (1 - h6), v5 = I2 + 4 * h6 + 8 * (1 - h6), C2 = Math.max(T2, y8), b5 = Math.max(I2, _4), G3 = Math.min(S4, M4), k3 = Math.min(v5, N);
  1981. let F4 = null, z = null;
  1982. for (let t8 = b5; t8 <= k3; t8++)
  1983. for (let e4 = C2; e4 <= G3; e4++) {
  1984. const s9 = e4 - T2 + (t8 - I2) * (8 * h6 + 4 * (1 - h6)), i5 = n6.children[s9];
  1985. i5 && (F4 || (F4 = i5, F4.next = n6.next), z && (z.next = i5), z = i5, i5.next = n6.next);
  1986. }
  1987. n6 = F4 || n6.next;
  1988. }
  1989. return null;
  1990. }
  1991. getRegionDisplayIds(t7, e3, s8, i4, o11) {
  1992. let n6 = this._root;
  1993. const a8 = [];
  1994. for (; n6 !== null; ) {
  1995. const r5 = n6.depth, l9 = n6.xNode, h6 = n6.yNode;
  1996. if (r5 >= o11) {
  1997. const o12 = n6.xGeohashTotal / n6.count, r6 = n6.yGeohashTotal / n6.count;
  1998. t7 <= o12 && o12 <= s8 && e3 <= r6 && r6 <= i4 && n6.displayIds.forEach((t8) => a8.push(t8)), n6 = n6.next;
  1999. continue;
  2000. }
  2001. const c12 = Math.ceil((r5 + 1) / 2), u5 = Math.floor((r5 + 1) / 2), d11 = 1 - r5 % 2, f10 = 30 - (3 * c12 + 2 * u5), x5 = 30 - (2 * c12 + 3 * u5), m7 = ~((1 << f10) - 1), p5 = ~((1 << x5) - 1), g9 = (t7 & m7) >> f10, y8 = (e3 & p5) >> x5, _4 = (s8 & m7) >> f10, M4 = (i4 & p5) >> x5, N = l9 << 3 * d11 + 2 * (1 - d11), T2 = h6 << 2 * d11 + 3 * (1 - d11), I2 = N + 8 * d11 + 4 * (1 - d11), S4 = T2 + 4 * d11 + 8 * (1 - d11), v5 = Math.max(N, g9), C2 = Math.max(T2, y8), b5 = Math.min(I2, _4), G3 = Math.min(S4, M4);
  2002. let k3 = null, F4 = null;
  2003. for (let t8 = C2; t8 <= G3; t8++)
  2004. for (let e4 = v5; e4 <= b5; e4++) {
  2005. const s9 = e4 - N + (t8 - T2) * (8 * d11 + 4 * (1 - d11)), i5 = n6.children[s9];
  2006. i5 && (k3 || (k3 = i5, k3.next = n6.next), F4 && (F4.next = i5), F4 = i5, i5.next = n6.next);
  2007. }
  2008. n6 = k3 || n6.next;
  2009. }
  2010. return a8;
  2011. }
  2012. getRegionStatistics(t7, e3, s8, i4, o11) {
  2013. let n6 = this._root, a8 = 0, r5 = 0, l9 = 0;
  2014. const h6 = {};
  2015. let c12 = 0;
  2016. for (; n6 !== null; ) {
  2017. const u5 = n6.depth, d11 = n6.xNode, f10 = n6.yNode;
  2018. if (u5 >= o11) {
  2019. const o12 = n6.xGeohashTotal / n6.count, u6 = n6.yGeohashTotal / n6.count;
  2020. t7 < o12 && o12 <= s8 && e3 < u6 && u6 <= i4 && (a8 += n6.count, r5 += n6.xTotal, l9 += n6.yTotal, n6.count === 1 && (c12 = n6.referenceId), this._aggregateStatistics(h6, n6.statistics)), n6 = n6.next;
  2021. continue;
  2022. }
  2023. const x5 = Math.ceil((u5 + 1) / 2), m7 = Math.floor((u5 + 1) / 2), p5 = 1 - u5 % 2, g9 = 30 - (3 * x5 + 2 * m7), y8 = 30 - (2 * x5 + 3 * m7), _4 = ~((1 << g9) - 1), M4 = ~((1 << y8) - 1), N = (t7 & _4) >> g9, T2 = (e3 & M4) >> y8, I2 = (s8 & _4) >> g9, S4 = (i4 & M4) >> y8, v5 = d11 << 3 * p5 + 2 * (1 - p5), C2 = f10 << 2 * p5 + 3 * (1 - p5), b5 = v5 + 8 * p5 + 4 * (1 - p5), G3 = C2 + 4 * p5 + 8 * (1 - p5), k3 = Math.max(v5, N), F4 = Math.max(C2, T2), z = Math.min(b5, I2), w5 = Math.min(G3, S4);
  2024. let j4 = null, E4 = null;
  2025. for (let o12 = F4; o12 <= w5; o12++)
  2026. for (let u6 = k3; u6 <= z; u6++) {
  2027. const d12 = u6 - v5 + (o12 - C2) * (8 * p5 + 4 * (1 - p5)), f11 = n6.children[d12];
  2028. if (f11) {
  2029. if (o12 !== F4 && o12 !== w5 && u6 !== k3 && u6 !== z) {
  2030. const o13 = f11.xGeohashTotal / f11.count, u7 = f11.yGeohashTotal / f11.count;
  2031. t7 < o13 && o13 <= s8 && e3 < u7 && u7 <= i4 && (a8 += f11.count, r5 += f11.xTotal, l9 += f11.yTotal, n6.count === 1 && (c12 = n6.referenceId), this._aggregateStatistics(h6, f11.statistics));
  2032. continue;
  2033. }
  2034. j4 || (j4 = f11, j4.next = n6.next), E4 && (E4.next = f11), E4 = f11, f11.next = n6.next;
  2035. }
  2036. }
  2037. n6 = j4 || n6.next;
  2038. }
  2039. return { count: a8, attributes: this.normalizeStatistics(h6, a8), xTotal: r5, yTotal: l9, referenceId: c12 };
  2040. }
  2041. getBins(t7, e3, s8, i4, o11) {
  2042. const n6 = [];
  2043. let a8 = this._root;
  2044. for (; a8 !== null; ) {
  2045. const r5 = a8.depth, l9 = a8.xNode, h6 = a8.yNode;
  2046. if (r5 >= o11) {
  2047. n6.push(a8), a8 = a8.next;
  2048. continue;
  2049. }
  2050. const c12 = Math.ceil((r5 + 1) / 2), u5 = Math.floor((r5 + 1) / 2), d11 = 1 - r5 % 2, f10 = 30 - (3 * c12 + 2 * u5), x5 = 30 - (2 * c12 + 3 * u5), m7 = ~((1 << f10) - 1), p5 = ~((1 << x5) - 1), g9 = (t7 & m7) >> f10, y8 = (e3 & p5) >> x5, _4 = (s8 & m7) >> f10, M4 = (i4 & p5) >> x5, N = l9 << 3 * d11 + 2 * (1 - d11), T2 = h6 << 2 * d11 + 3 * (1 - d11), I2 = N + 8 * d11 + 4 * (1 - d11), S4 = T2 + 4 * d11 + 8 * (1 - d11), v5 = Math.max(N, g9), C2 = Math.max(T2, y8), b5 = Math.min(I2, _4), G3 = Math.min(S4, M4);
  2051. let k3 = null, F4 = null;
  2052. for (let t8 = C2; t8 <= G3; t8++)
  2053. for (let e4 = v5; e4 <= b5; e4++) {
  2054. const s9 = e4 - N + (t8 - T2) * (8 * d11 + 4 * (1 - d11)), i5 = a8.children[s9];
  2055. i5 && (k3 || (k3 = i5, k3.next = a8.next), F4 && (F4.next = i5), F4 = i5, i5.next = a8.next);
  2056. }
  2057. a8 = k3 || a8.next;
  2058. }
  2059. return n6;
  2060. }
  2061. _linkChildren(t7) {
  2062. let e3 = null, s8 = null;
  2063. for (let i4 = 0; i4 <= t7.children.length; i4++) {
  2064. const o11 = t7.children[i4];
  2065. o11 && (e3 || (e3 = o11, e3.next = t7.next), s8 && (s8.next = o11), s8 = o11, o11.next = t7.next);
  2066. }
  2067. return e3;
  2068. }
  2069. _updateStatisticsCursor(t7, e3, s8) {
  2070. for (const i4 of this._statisticFields) {
  2071. const o11 = i4.name, n6 = i4.inField ? t7.readAttribute(i4.inField) : t7.getComputedNumericAtIndex(i4.inFieldIndex);
  2072. switch (i4.statisticType) {
  2073. case "norm": {
  2074. e3.statistics[o11] || (e3.statistics[o11] = {});
  2075. const a8 = i4.inNormalizationField, r5 = t7.readAttribute(a8), l9 = e3.statistics[o11].onStatisticField || 0, h6 = e3.statistics[o11].onStatisticNormalizationField || 0;
  2076. n6 == null || isNaN(n6) || r5 == null || r5 === 0 || isNaN(r5) || (e3.statistics[o11].onStatisticField = l9 + s8 * n6, e3.statistics[o11].onStatisticNormalizationField = h6 + s8 * r5);
  2077. break;
  2078. }
  2079. case "sum":
  2080. case "avg": {
  2081. e3.statistics[o11] || (e3.statistics[o11] = { value: 0, nanCount: 0 });
  2082. const t8 = e3.statistics[o11].value, i5 = e3.statistics[o11].nanCount;
  2083. n6 == null || isNaN(n6) ? e3.statistics[o11].nanCount = i5 + s8 : e3.statistics[o11].value = t8 + s8 * n6;
  2084. break;
  2085. }
  2086. case "avg_angle": {
  2087. e3.statistics[o11] || (e3.statistics[o11] = { x: 0, y: 0, nanCount: 0 });
  2088. const t8 = e3.statistics[o11].x, i5 = e3.statistics[o11].y, a8 = e3.statistics[o11].nanCount, r5 = Math.PI / 180;
  2089. n6 == null || isNaN(n6) ? e3.statistics[o11].nanCount = a8 + s8 : (e3.statistics[o11].x = t8 + s8 * Math.cos(n6 * r5), e3.statistics[o11].y = i5 + s8 * Math.sin(n6 * r5));
  2090. break;
  2091. }
  2092. case "mode": {
  2093. e3.statistics[o11] || (e3.statistics[o11] = {});
  2094. const t8 = e3.statistics[o11][n6] || 0;
  2095. e3.statistics[o11][n6] = t8 + s8;
  2096. break;
  2097. }
  2098. }
  2099. }
  2100. }
  2101. _aggregateStatistics(t7, e3) {
  2102. for (const s8 of this._statisticFields) {
  2103. const i4 = s8.name;
  2104. switch (s8.statisticType) {
  2105. case "sum":
  2106. case "avg":
  2107. case "avg_angle":
  2108. case "mode":
  2109. case "norm":
  2110. t7[i4] || (t7[i4] = {});
  2111. for (const s9 in e3[i4]) {
  2112. const o11 = t7[i4][s9] || 0;
  2113. t7[i4][s9] = o11 + e3[i4][s9];
  2114. }
  2115. }
  2116. }
  2117. }
  2118. normalizeStatistics(t7, e3) {
  2119. const s8 = {};
  2120. for (const i4 of this._statisticFields) {
  2121. const o11 = i4.name;
  2122. switch (i4.statisticType) {
  2123. case "norm": {
  2124. const i5 = t7[o11];
  2125. if (e3 && i5.onStatisticNormalizationField == null)
  2126. break;
  2127. if (e3 && i5.onStatisticNormalizationField) {
  2128. s8[o11] = i5.onStatisticField / i5.onStatisticNormalizationField;
  2129. break;
  2130. }
  2131. s8[o11] = 0;
  2132. break;
  2133. }
  2134. case "sum": {
  2135. if (!e3)
  2136. break;
  2137. const { value: i5, nanCount: n6 } = t7[o11];
  2138. if (!(e3 - n6))
  2139. break;
  2140. s8[o11] = i5;
  2141. break;
  2142. }
  2143. case "avg": {
  2144. if (!e3)
  2145. break;
  2146. const { value: i5, nanCount: n6 } = t7[o11];
  2147. if (!(e3 - n6))
  2148. break;
  2149. s8[o11] = i5 / (e3 - n6);
  2150. break;
  2151. }
  2152. case "avg_angle": {
  2153. if (!e3)
  2154. break;
  2155. const { x: i5, y: n6, nanCount: a8 } = t7[o11];
  2156. if (!(e3 - a8))
  2157. break;
  2158. const r5 = i5 / (e3 - a8), l9 = n6 / (e3 - a8), h6 = 180 / Math.PI, c12 = Math.atan2(l9, r5) * h6;
  2159. s8[o11] = c12;
  2160. break;
  2161. }
  2162. case "mode": {
  2163. const e4 = t7[o11];
  2164. let i5 = 0, n6 = null;
  2165. for (const t8 in e4) {
  2166. const s9 = e4[t8];
  2167. s9 > i5 && (i5 = s9, n6 = t8);
  2168. }
  2169. s8[o11] = n6 === "null" ? null : n6;
  2170. break;
  2171. }
  2172. }
  2173. }
  2174. return s8;
  2175. }
  2176. };
  2177. var u3 = class {
  2178. constructor(t7, e3, s8, i4) {
  2179. this.count = 0, this.xTotal = 0, this.yTotal = 0, this.statistics = {}, this.displayId = 0, this.referenceId = 0, this.displayIds = new Set(), this.next = null, this.depth = 0, this.xNode = 0, this.yNode = 0, this.xGeohashTotal = 0, this.yGeohashTotal = 0, this._tree = t7, this.children = new Array(32);
  2180. for (let o11 = 0; o11 < this.children.length; o11++)
  2181. this.children[o11] = null;
  2182. this.xNode = e3, this.yNode = s8, this.depth = i4;
  2183. }
  2184. realloc(t7, e3, s8) {
  2185. for (let i4 = 0; i4 < this.children.length; i4++)
  2186. this.children[i4] = null;
  2187. return this.xNode = t7, this.yNode = e3, this.depth = s8, this.next = null, this.xGeohashTotal = 0, this.yGeohashTotal = 0, this.displayId = 0, this.referenceId = 0, this.xTotal = 0, this.yTotal = 0, this.count = 0, this.statistics = {}, this.displayIds.clear(), this;
  2188. }
  2189. get id() {
  2190. return `${this.xNode}.${this.yNode}`;
  2191. }
  2192. add(t7) {
  2193. this.displayIds.add(t7);
  2194. }
  2195. remove(t7) {
  2196. this.displayIds.delete(t7);
  2197. }
  2198. getAttributes() {
  2199. const t7 = this._tree.normalizeStatistics(this.statistics, this.count);
  2200. return t7.aggregateId = this.id, t7.aggregateCount = this.count, t7;
  2201. }
  2202. getGeometry(t7, s8) {
  2203. const i4 = this.getLngLatBounds(), [h6, c12, u5, d11] = i4, f10 = g3({ rings: [[[h6, c12], [h6, d11], [u5, d11], [u5, c12], [h6, c12]]] }, k.WGS84, t7), x5 = D2(new t3(), f10, false, false);
  2204. return r(s8) ? ie(new t3(), x5, false, false, "esriGeometryPolygon", s8, false, false) : x5;
  2205. }
  2206. getLngLatBounds() {
  2207. const t7 = this.depth, e3 = Math.ceil(t7 / 2), s8 = Math.floor(t7 / 2), o11 = 30 - (3 * e3 + 2 * s8), n6 = 30 - (2 * e3 + 3 * s8), a8 = this.xNode << o11, r5 = this.yNode << n6;
  2208. return x2({ geohashX: a8, geohashY: r5 }, this.depth);
  2209. }
  2210. find(t7, e3, s8, i4, o11, n6) {
  2211. if (i4 >= s8)
  2212. return this;
  2213. const a8 = 1 - i4 % 2, r5 = 3 * a8 + 2 * (1 - a8), l9 = 2 * a8 + 3 * (1 - a8), h6 = 30 - o11 - r5, c12 = 30 - n6 - l9, u5 = ((t7 & 7 * a8 + 3 * (1 - a8) << h6) >> h6) + ((e3 & 3 * a8 + 7 * (1 - a8) << c12) >> c12) * (8 * a8 + 4 * (1 - a8)), d11 = this.children[u5];
  2214. return d11 == null ? null : d11.find(t7, e3, s8, i4 + 1, o11 + r5, n6 + l9);
  2215. }
  2216. };
  2217. // node_modules/@arcgis/core/views/2d/layers/features/support/BinStore.js
  2218. var G2 = s.getLogger("esri.view.2d.layers.features.support.BinStore");
  2219. var B = 12;
  2220. var L2 = 64;
  2221. var R3 = 5;
  2222. function S3(e3) {
  2223. return 57.29577951308232 * e3;
  2224. }
  2225. var A2 = class extends c4 {
  2226. constructor(e3, t7, s8, r5) {
  2227. super(e3, s8), this._geohashLevel = R3, this._geohashBuf = [], this._serviceInfo = r5, this.geometryInfo = e3.geometryInfo, this._spatialReference = t7, this._projectionSupportCheck = f4(t7, k.WGS84), this._bitsets.geohash = s8.getBitset(s8.createBitset()), this._bitsets.inserted = s8.getBitset(s8.createBitset());
  2228. }
  2229. destroy() {
  2230. this._tree && this._tree.destroy();
  2231. }
  2232. async updateSchema(t7, r5) {
  2233. const i4 = this._schema;
  2234. try {
  2235. await super.updateSchema(t7, r5), await this._projectionSupportCheck;
  2236. } catch (d11) {
  2237. }
  2238. const n6 = m2(i4, r5);
  2239. r5 && (!t(n6) || t7.source || t7.storage.filters) ? ((a3(n6, "params.fields") || a3(n6, "params") || !this._tree || t7.source) && (this._tree && this._tree.destroy(), this._tree = new c11(this._statisticFields, this._serviceInfo), this._tree.onRelease = (e3) => e3.displayId && this._storage.releaseDisplayId(e3.displayId), this._geohashLevel = this._schema.params.fixedBinLevel, this._rebuildTree(), a("esri-2d-update-debug") && G2.info("Aggregate mesh needs update due to tree changing")), a("esri-2d-update-debug") && G2.info("Aggregate mesh needs update due to tree changing"), t7.targets[r5.name] = true, t7.mesh = false) : i4 && (t7.mesh = true);
  2240. }
  2241. clear() {
  2242. this._rebuildTree();
  2243. }
  2244. sweepFeatures(e3, t7) {
  2245. this._bitsets.inserted.forEachSet((s8) => {
  2246. if (!e3.has(s8)) {
  2247. const e4 = t7.lookupByDisplayIdUnsafe(s8);
  2248. this._remove(e4);
  2249. }
  2250. });
  2251. }
  2252. sweepAggregates(e3, t7, s8) {
  2253. }
  2254. onTileData(e3, t7, r5, i4, o11 = true) {
  2255. if (!this._schema || t(t7.addOrUpdate))
  2256. return t7;
  2257. const a8 = this._getTransforms(e3, this._spatialReference);
  2258. {
  2259. const e4 = t7.addOrUpdate.getCursor();
  2260. for (; e4.next(); )
  2261. this._update(e4, i4);
  2262. }
  2263. if (t7.status.mesh || !o11)
  2264. return t7;
  2265. const h6 = new Array();
  2266. this._getBinsForTile(h6, e3, a8, r5), t7.addOrUpdate = d5.fromOptimizedFeatures(h6, { ...this._serviceInfo, geometryType: "esriGeometryPolygon" }), t7.addOrUpdate.attachStorage(r5), t7.clear = true, t7.end = true;
  2267. {
  2268. const s8 = t7.addOrUpdate.getCursor();
  2269. for (; s8.next(); ) {
  2270. const t8 = s8.getDisplayId();
  2271. this._bitsets.computed.unset(t8), this.setComputedAttributes(r5, s8, t8, e3.scale);
  2272. }
  2273. }
  2274. return t7;
  2275. }
  2276. forEach(e3) {
  2277. this._tree.forEach(e3);
  2278. }
  2279. onTileUpdate(e3) {
  2280. }
  2281. getAggregate(e3) {
  2282. const t7 = s6(e3, true), s8 = this._tree.findIf((e4) => e4.displayId === t7);
  2283. return o(s8, (e4) => this._toAggregateGraphic(e4));
  2284. }
  2285. getAggregates() {
  2286. return this._tree.findAllIf((e3) => e3.depth === this._geohashLevel).map(this._toAggregateGraphic.bind(this));
  2287. }
  2288. getDisplayId(e3) {
  2289. const t7 = this._tree.findIf((t8) => t8.id === e3);
  2290. return o(t7, (e4) => e4.displayId);
  2291. }
  2292. getFeatureDisplayIdsForAggregate(e3) {
  2293. const t7 = this._tree.findIf((t8) => t8.id === e3);
  2294. return E(t7, [], (e4) => Array.from(e4.displayIds));
  2295. }
  2296. getDisplayIdForReferenceId(e3) {
  2297. const t7 = this._tree.findIf((t8) => t8.displayIds.size === 1 && t8.displayIds.has(e3));
  2298. return o(t7, (e4) => e4.displayId);
  2299. }
  2300. _toAggregateGraphic(e3) {
  2301. const t7 = this._spatialReference;
  2302. return { referenceId: null, objectId: e3.id, displayId: e3.displayId, attributes: e3.getAttributes(), geometry: ne(e3.getGeometry(t7), "esriGeometryPolygon", false, false), centroid: null };
  2303. }
  2304. _rebuildTree() {
  2305. this._bitsets.computed.clear(), this._bitsets.inserted.clear(), this._tree && this._tree.clear();
  2306. }
  2307. _remove(e3) {
  2308. const t7 = e3.getDisplayId(), s8 = e3.getXHydrated(), r5 = e3.getYHydrated(), i4 = this._geohashBuf[2 * t7], o11 = this._geohashBuf[2 * t7 + 1];
  2309. this._bitsets.inserted.has(t7) && (this._bitsets.inserted.unset(t7), this._tree.removeCursor(e3, s8, r5, i4, o11, this._geohashLevel));
  2310. }
  2311. _update(e3, t7) {
  2312. const s8 = e3.getDisplayId(), r5 = this._bitsets.inserted, i4 = t7.isVisible(s8);
  2313. if (i4 === r5.has(s8))
  2314. return;
  2315. if (!i4)
  2316. return void this._remove(e3);
  2317. const o11 = e3.getXHydrated(), a8 = e3.getYHydrated();
  2318. if (!this._setGeohash(s8, o11, a8))
  2319. return;
  2320. const h6 = this._geohashBuf[2 * s8], n6 = this._geohashBuf[2 * s8 + 1];
  2321. this._tree.insertCursor(e3, s8, o11, a8, h6, n6, this._geohashLevel), r5.set(s8);
  2322. }
  2323. _setGeohash(e3, t7, s8) {
  2324. if (this._bitsets.geohash.has(e3))
  2325. return true;
  2326. const r5 = this._geohashBuf;
  2327. if (this._spatialReference.isWebMercator) {
  2328. const i4 = S3(t7 / s3.radius), o11 = i4 - 360 * Math.floor((i4 + 180) / 360), a8 = S3(Math.PI / 2 - 2 * Math.atan(Math.exp(-s8 / s3.radius)));
  2329. p4(r5, e3, a8, o11, B);
  2330. } else {
  2331. const i4 = g3({ x: t7, y: s8 }, this._spatialReference, k.WGS84);
  2332. if (!i4)
  2333. return false;
  2334. p4(r5, e3, i4.y, i4.x, B);
  2335. }
  2336. return this._bitsets.geohash.set(e3), true;
  2337. }
  2338. _getBinsForTile(e3, t7, s8, r5) {
  2339. try {
  2340. const { xLL: i4, yLL: o11, xTR: a8, yTR: h6, level: n6 } = this._getGeohashBounds(t7), d11 = this._tree.getBins(i4, o11, a8, h6, n6);
  2341. for (const t8 of d11) {
  2342. t8.displayId || (t8.displayId = r5.createDisplayId(true));
  2343. const i5 = t8.getGeometry(this._spatialReference, s8.tile), o12 = new s4(i5, t8.getAttributes());
  2344. o12.objectId = t8.id, o12.displayId = t8.displayId, e3.push(o12);
  2345. }
  2346. } catch (i4) {
  2347. return void G2.error("Unable to get bins for tile", t7.key.id);
  2348. }
  2349. }
  2350. _getGeohash(e3, t7, s8) {
  2351. const r5 = { geohashX: 0, geohashY: 0 };
  2352. return y7(r5, t7, e3, s8), r5;
  2353. }
  2354. _getGeohashBounds(e3) {
  2355. const t7 = this._getGeohashLevel(e3.key.level), s8 = [e3.extent.xmin, e3.extent.ymin, e3.extent.xmax, e3.extent.ymax], r5 = v.fromExtent(M.fromBounds(s8, this._spatialReference)), i4 = g3(r5, this._spatialReference, k.WGS84, { densificationStep: e3.resolution * L2 }), o11 = D2(new t3(), i4, false, false), a8 = o11.coords.filter((e4, t8) => !(t8 % 2)), h6 = o11.coords.filter((e4, t8) => t8 % 2), n6 = Math.min(...a8), d11 = Math.min(...h6), g9 = Math.max(...a8), p5 = Math.max(...h6), l9 = this._getGeohash(n6, d11, t7), u5 = this._getGeohash(g9, p5, t7);
  2356. return { xLL: l9.geohashX, yLL: l9.geohashY, xTR: u5.geohashX, yTR: u5.geohashY, level: t7 };
  2357. }
  2358. _getGeohashLevel(e3) {
  2359. return this._schema.params.fixedBinLevel;
  2360. }
  2361. _getTransforms(e3, t7) {
  2362. const s8 = { originPosition: "upperLeft", scale: [e3.resolution, e3.resolution], translate: [e3.bounds[0], e3.bounds[3]] }, r5 = R(t7);
  2363. if (!r5)
  2364. return { tile: s8, left: null, right: null };
  2365. const [i4, o11] = r5.valid;
  2366. return { tile: s8, left: { ...s8, translate: [o11, e3.bounds[3]] }, right: { ...s8, translate: [i4 - o11 + e3.bounds[0], e3.bounds[3]] } };
  2367. }
  2368. };
  2369. // node_modules/@arcgis/core/views/2d/layers/features/support/ClusterStore.js
  2370. var M3 = 12;
  2371. var x3 = 1;
  2372. var L3 = class extends o2 {
  2373. constructor(e3, t7, s8, r5, i4) {
  2374. super(new t3([], [t7, s8]), r5, null, e3), this.geohashBoundsInfo = i4;
  2375. }
  2376. get count() {
  2377. return this.attributes.cluster_count;
  2378. }
  2379. static create(e3, t7, s8, r5, i4, a8, o11, h6) {
  2380. const l9 = new L3(t7, s8, r5, a8, o11);
  2381. return l9.displayId = e3.createDisplayId(true), l9.referenceId = h6, l9.tileLevel = i4, l9;
  2382. }
  2383. update(e3, t7, s8, r5, i4, a8) {
  2384. return this.geometry.coords[0] = e3, this.geometry.coords[1] = t7, this.tileLevel = s8, this.attributes = r5, this.geohashBoundsInfo = i4, this.referenceId = null, this.referenceId = a8, this;
  2385. }
  2386. toJSON() {
  2387. return { objectId: this.objectId, referenceId: this.attributes.cluster_count === 1 ? this.referenceId : null, attributes: { ...this.attributes, clusterId: this.objectId }, geometry: { x: this.geometry.coords[0], y: this.geometry.coords[1] } };
  2388. }
  2389. };
  2390. function j3(e3) {
  2391. return 57.29577951308232 * e3;
  2392. }
  2393. var w4 = class extends c4 {
  2394. constructor(t7, s8, r5, i4) {
  2395. super(t7, r5), this.events = new n2(), this._geohashLevel = 0, this._tileLevel = 0, this._aggregateValueRanges = {}, this._aggregateValueRangesChanged = false, this._geohashBuf = [], this._clusters = new Map(), this._tiles = new Map(), this._serviceInfo = i4, this.geometryInfo = t7.geometryInfo, this._spatialReference = s8, this._projectionSupportCheck = f4(s8, k.WGS84), this._bitsets.geohash = r5.getBitset(r5.createBitset()), this._bitsets.inserted = r5.getBitset(r5.createBitset());
  2396. }
  2397. destroy() {
  2398. this._tree.destroy();
  2399. }
  2400. async updateSchema(e3, r5) {
  2401. const i4 = this._schema;
  2402. try {
  2403. await super.updateSchema(e3, r5), await this._projectionSupportCheck;
  2404. } catch (n6) {
  2405. }
  2406. const l9 = m2(i4, r5);
  2407. r5 && (!t(l9) || e3.source || e3.storage.filters) ? ((a3(l9, "params.fields") || !this._tree || e3.source) && (this._tree && this._tree.destroy(), this._tree = new c11(this._statisticFields, this._serviceInfo), this._rebuildTree(), a("esri-2d-update-debug") && console.debug("Aggregate mesh needs update due to tree changing")), a("esri-2d-update-debug") && console.debug("Applying Update - ClusterStore:", l9), e3.targets[r5.name] = true, e3.mesh = false, this._aggregateValueRanges = {}) : i4 && (e3.mesh = true);
  2408. }
  2409. clear() {
  2410. this._rebuildTree();
  2411. }
  2412. sweepFeatures(e3, t7) {
  2413. this._bitsets.inserted.forEachSet((s8) => {
  2414. if (!e3.has(s8)) {
  2415. const e4 = t7.lookupByDisplayIdUnsafe(s8);
  2416. this._remove(e4);
  2417. }
  2418. });
  2419. }
  2420. sweepAggregates(e3, t7, s8) {
  2421. this._clusters.forEach((r5, i4) => {
  2422. r5 && r5.tileLevel !== s8 && (e3.releaseDisplayId(r5.displayId), t7.unsetAttributeData(r5.displayId), this._clusters.delete(i4));
  2423. });
  2424. }
  2425. onTileData(e3, t7, r5, i4, a8 = true) {
  2426. if (!this._schema || t(t7.addOrUpdate))
  2427. return t7;
  2428. const o11 = this._getTransforms(e3, this._spatialReference);
  2429. {
  2430. const e4 = t7.addOrUpdate.getCursor();
  2431. for (; e4.next(); )
  2432. this._update(e4, i4);
  2433. }
  2434. if (t7.status.mesh || !a8)
  2435. return t7;
  2436. const h6 = new Array(), l9 = this._schema.params.clusterRadius;
  2437. this._getClustersForTile(h6, e3, l9, r5, o11), t7.addOrUpdate = d5.fromOptimizedFeatures(h6, this._serviceInfo), t7.addOrUpdate.attachStorage(r5), t7.clear = true, t7.end = true;
  2438. {
  2439. const s8 = t7.addOrUpdate.getCursor();
  2440. for (; s8.next(); ) {
  2441. const t8 = s8.getDisplayId();
  2442. this._bitsets.computed.unset(t8), this.setComputedAttributes(r5, s8, t8, e3.scale);
  2443. }
  2444. }
  2445. return this._aggregateValueRangesChanged && t7.end && (this.events.emit("valueRangesChanged", { valueRanges: this._aggregateValueRanges }), this._aggregateValueRangesChanged = false), t7;
  2446. }
  2447. onTileUpdate({ added: e3, removed: t7 }) {
  2448. if (e3.length) {
  2449. const t8 = e3[0].level;
  2450. this._tileLevel = t8, this._setGeohashLevel(t8);
  2451. }
  2452. if (!this._schema)
  2453. return;
  2454. const s8 = this._schema.params.clusterRadius;
  2455. t7.forEach((e4) => {
  2456. this._tiles.delete(e4.key.id), this._markTileClustersForDeletion(e4, s8);
  2457. });
  2458. }
  2459. getAggregate(e3) {
  2460. for (const t7 of this._clusters.values())
  2461. if ((t7?.displayId & n3) == (e3 & n3))
  2462. return t7.toJSON();
  2463. return null;
  2464. }
  2465. getAggregates() {
  2466. const e3 = [];
  2467. for (const t7 of this._clusters.values())
  2468. t7?.tileLevel === this._tileLevel && e3.push(t7.toJSON());
  2469. return e3;
  2470. }
  2471. getDisplayId(e3) {
  2472. const t7 = this._clusters.get(e3);
  2473. return t7 ? t7.displayId : null;
  2474. }
  2475. getFeatureDisplayIdsForAggregate(e3) {
  2476. const t7 = this._clusters.get(e3);
  2477. if (!t7)
  2478. return [];
  2479. const s8 = t7.geohashBoundsInfo;
  2480. return this._tree.getRegionDisplayIds(s8.xLL, s8.yLL, s8.xTR, s8.yTR, s8.level);
  2481. }
  2482. getDisplayIdForReferenceId(e3) {
  2483. for (const t7 of this._clusters.values())
  2484. if (t7?.referenceId === e3)
  2485. return t7.displayId;
  2486. return null;
  2487. }
  2488. getAggregateValueRanges() {
  2489. return this._aggregateValueRanges;
  2490. }
  2491. forEach(e3) {
  2492. for (const [t7, s8] of this._clusters)
  2493. s8 && e3(s8, t7);
  2494. }
  2495. size() {
  2496. let e3 = 0;
  2497. return this.forEach((t7) => e3++), e3;
  2498. }
  2499. _rebuildTree() {
  2500. this._bitsets.computed.clear(), this._bitsets.inserted.clear(), this._tree && this._tree.clear();
  2501. }
  2502. _remove(e3) {
  2503. const t7 = e3.getDisplayId(), s8 = e3.getXHydrated(), r5 = e3.getYHydrated(), i4 = this._geohashBuf[2 * t7], a8 = this._geohashBuf[2 * t7 + 1];
  2504. this._bitsets.inserted.has(t7) && (this._bitsets.inserted.unset(t7), this._tree.removeCursor(e3, s8, r5, i4, a8, this._geohashLevel));
  2505. }
  2506. _update(e3, t7) {
  2507. const s8 = e3.getDisplayId(), r5 = this._bitsets.inserted, i4 = t7.isVisible(s8);
  2508. if (i4 === r5.has(s8))
  2509. return;
  2510. if (!i4)
  2511. return void this._remove(e3);
  2512. const a8 = e3.getXHydrated(), o11 = e3.getYHydrated();
  2513. if (!this._setGeohash(s8, a8, o11))
  2514. return;
  2515. const h6 = this._geohashBuf[2 * s8], l9 = this._geohashBuf[2 * s8 + 1];
  2516. this._tree.insertCursor(e3, s8, a8, o11, h6, l9, this._geohashLevel), r5.set(s8);
  2517. }
  2518. _setGeohash(e3, t7, s8) {
  2519. if (this._bitsets.geohash.has(e3))
  2520. return true;
  2521. const r5 = this._geohashBuf;
  2522. if (this._spatialReference.isWebMercator) {
  2523. const i4 = j3(t7 / s3.radius), a8 = i4 - 360 * Math.floor((i4 + 180) / 360), o11 = j3(Math.PI / 2 - 2 * Math.atan(Math.exp(-s8 / s3.radius)));
  2524. p4(r5, e3, o11, a8, M3);
  2525. } else {
  2526. const i4 = g3({ x: t7, y: s8 }, this._spatialReference, k.WGS84);
  2527. if (!i4)
  2528. return false;
  2529. p4(r5, e3, i4.y, i4.x, M3);
  2530. }
  2531. return this._bitsets.geohash.set(e3), true;
  2532. }
  2533. _getClustersForTile(e3, t7, a8, o11, h6, l9 = true) {
  2534. const n6 = this._schema.params.clusterPixelBuffer, u5 = 2 * a8, c12 = this._getGeohashLevel(t7.key.level), f10 = Math.ceil(2 ** t7.key.level * o5 / u5), _4 = Math.ceil(n6 / u5) + 0, m7 = Math.ceil(o5 / u5), { row: y8, col: v5 } = t7.key, b5 = v5 * o5, R5 = y8 * o5, C2 = Math.floor(b5 / u5) - _4, M4 = Math.floor(R5 / u5) - _4, x5 = C2 + m7 + 2 * _4, L4 = M4 + m7 + 2 * _4, j4 = t7.tileInfoView.getLODInfoAt(t7.key.level);
  2535. for (let I2 = C2; I2 <= x5; I2++)
  2536. for (let a9 = M4; a9 <= L4; a9++) {
  2537. let n7 = I2;
  2538. j4.wrap && (n7 = I2 < 0 ? I2 + f10 : I2 % f10);
  2539. const u6 = j4.wrap && I2 < 0, _5 = j4.wrap && I2 % f10 !== I2, m8 = this._lookupCluster(o11, j4, t7.key.level, n7, a9, c12);
  2540. if (r(m8)) {
  2541. const t8 = o(h6, (e4) => u6 ? e4.left : _5 ? e4.right : e4.tile);
  2542. if (l9 && t(t8))
  2543. continue;
  2544. if (!m8.count)
  2545. continue;
  2546. if (r(t8) && l9) {
  2547. const s8 = m8.geometry.clone();
  2548. let i4 = m8.attributes;
  2549. s8.coords[0] = b2(t8, s8.coords[0]), s8.coords[1] = M2(t8, s8.coords[1]), m8.count === 1 && r(m8.referenceId) && (i4 = { ...m8.attributes, referenceId: m8.referenceId });
  2550. const a10 = new s4(s8, i4);
  2551. a10.displayId = m8.displayId, e3.push(a10);
  2552. }
  2553. }
  2554. }
  2555. }
  2556. _getGeohashLevel(e3) {
  2557. return Math.min(Math.ceil(e3 / 2 + 2), M3);
  2558. }
  2559. _setGeohashLevel(e3) {
  2560. const t7 = this._getGeohashLevel(e3), s8 = (Math.floor(t7 / x3) + 1) * x3 - 1;
  2561. if (this._geohashLevel !== s8)
  2562. return this._geohashLevel = s8, this._rebuildTree(), void this._bitsets.geohash.clear();
  2563. }
  2564. _getTransforms(e3, t7) {
  2565. const s8 = { originPosition: "upperLeft", scale: [e3.resolution, e3.resolution], translate: [e3.bounds[0], e3.bounds[3]] }, r5 = R(t7);
  2566. if (!r5)
  2567. return { tile: s8, left: null, right: null };
  2568. const [i4, a8] = r5.valid;
  2569. return { tile: s8, left: { ...s8, translate: [a8, e3.bounds[3]] }, right: { ...s8, translate: [i4 - a8 + e3.bounds[0], e3.bounds[3]] } };
  2570. }
  2571. _getClusterId(e3, t7, s8) {
  2572. return (15 & e3) << 28 | (16383 & t7) << 14 | 16383 & s8;
  2573. }
  2574. _markForDeletion(e3, t7, s8) {
  2575. const r5 = this._getClusterId(e3, t7, s8);
  2576. this._clusters.delete(r5);
  2577. }
  2578. _getClusterBounds(e3, t7, s8) {
  2579. const r5 = this._schema.params.clusterRadius, i4 = 2 * r5;
  2580. let a8 = s8 % 2 ? t7 * i4 : t7 * i4 - r5;
  2581. const o11 = s8 * i4;
  2582. let h6 = a8 + i4;
  2583. const l9 = o11 - i4, n6 = 2 ** e3.level * o5;
  2584. e3.wrap && a8 < 0 && (a8 = 0), e3.wrap && h6 > n6 && (h6 = n6);
  2585. const u5 = a8 / o5, c12 = o11 / o5, g9 = h6 / o5, d11 = l9 / o5;
  2586. return [e3.getXForColumn(u5), e3.getYForRow(c12), e3.getXForColumn(g9), e3.getYForRow(d11)];
  2587. }
  2588. _lookupCluster(e3, t7, s8, i4, a8, o11) {
  2589. const h6 = this._getClusterId(s8, i4, a8), l9 = this._clusters.get(h6), [c12, g9, d11, f10] = this._getClusterBounds(t7, i4, a8), p5 = { x: c12, y: g9 }, _4 = { x: d11, y: f10 };
  2590. let m7 = 0, I2 = 0, v5 = 0, b5 = 0;
  2591. if (this._spatialReference.isWebMercator) {
  2592. {
  2593. const e4 = j3(p5.x / s3.radius);
  2594. m7 = e4 - 360 * Math.floor((e4 + 180) / 360), I2 = j3(Math.PI / 2 - 2 * Math.atan(Math.exp(-p5.y / s3.radius)));
  2595. }
  2596. {
  2597. const e4 = j3(_4.x / s3.radius);
  2598. v5 = e4 - 360 * Math.floor((e4 + 180) / 360), b5 = j3(Math.PI / 2 - 2 * Math.atan(Math.exp(-_4.y / s3.radius)));
  2599. }
  2600. } else {
  2601. const e4 = g3(p5, this._spatialReference, k.WGS84), t8 = g3(_4, this._spatialReference, k.WGS84);
  2602. if (!e4 || !t8)
  2603. return null;
  2604. m7 = e4.x, I2 = e4.y, v5 = t8.x, b5 = t8.y;
  2605. }
  2606. const R5 = { geohashX: 0, geohashY: 0 }, M4 = { geohashX: 0, geohashY: 0 };
  2607. y7(R5, I2, m7, o11), y7(M4, b5, v5, o11);
  2608. const x5 = R5.geohashX, w5 = R5.geohashY, V = M4.geohashX, S4 = M4.geohashY, F4 = { xLL: x5, yLL: w5, xTR: V, yTR: S4, level: o11 }, D3 = this._tree.getRegionStatistics(x5, w5, V, S4, o11), { count: T2, xTotal: k3, yTotal: B2, referenceId: A4 } = D3, G3 = T2 ? k3 / T2 : 0, O2 = T2 ? B2 / T2 : 0;
  2609. if (T2 === 0)
  2610. return this._clusters.set(h6, null), null;
  2611. const U3 = { cluster_count: T2, ...D3.attributes }, X = r(l9) ? l9.update(G3, O2, s8, U3, F4, A4) : L3.create(e3, h6, G3, O2, s8, U3, F4, A4);
  2612. return T2 === 0 && (X.geometry.coords[0] = (c12 + d11) / 2, X.geometry.coords[1] = (g9 + f10) / 2), this._clusters.set(h6, X), this._updateAggregateValueRangeForCluster(X, X.tileLevel), X;
  2613. }
  2614. _updateAggregateValueRangeForCluster(e3, t7) {
  2615. const s8 = this._aggregateValueRanges[t7] || { minValue: 1 / 0, maxValue: 0 }, r5 = s8.minValue, i4 = s8.maxValue;
  2616. s8.minValue = Math.min(r5, e3.count), s8.maxValue = Math.max(i4, e3.count), this._aggregateValueRanges[t7] = s8, r5 === s8.minValue && i4 === s8.maxValue || (this._aggregateValueRangesChanged = true);
  2617. }
  2618. _markTileClustersForDeletion(e3, t7) {
  2619. const s8 = 2 * t7, r5 = Math.ceil(o5 / s8), { row: i4, col: a8 } = e3.key, o11 = a8 * o5, h6 = i4 * o5, l9 = Math.floor(o11 / s8), n6 = Math.floor(h6 / s8);
  2620. for (let u5 = l9; u5 < l9 + r5; u5++)
  2621. for (let t8 = n6; t8 < n6 + r5; t8++)
  2622. this._markForDeletion(e3.key.level, u5, t8);
  2623. }
  2624. };
  2625. // node_modules/@arcgis/core/views/2d/layers/features/controllers/FeatureController2D.js
  2626. var T = 5e3;
  2627. var k2 = "tileRenderer.featuresView.attributeView.initialize";
  2628. var q3 = "tileRenderer.featuresView.attributeView.requestUpdate";
  2629. var R4 = "tileRenderer.featuresView.requestRender";
  2630. function U2(e3) {
  2631. return e3.name === "worker:port-closed";
  2632. }
  2633. function x4(e3) {
  2634. if (!g2(e3) && !U2(e3))
  2635. throw e3;
  2636. }
  2637. function Q2(e3) {
  2638. return e3.type === "feature" && e3.mode === "snapshot";
  2639. }
  2640. var O = class extends d4 {
  2641. constructor() {
  2642. super(...arguments), this._storage = new r3(), this._markedIdsBufId = this._storage.createBitset(), this._lastCleanup = performance.now(), this._cleanupNeeded = false, this._invalidated = false, this._tileToResolver = new Map(), this._didEdit = false, this._updateVersion = 1, this.tileStore = null, this.config = null, this.processor = null, this.remoteClient = null, this.service = null;
  2643. }
  2644. initialize() {
  2645. this._initStores(), this._initSource(), this._updateQueue = new l2({ concurrency: this._source.type === "geoevent" ? 1 : 4, process: (e3, t7) => this._onTileMessage(e3, { signal: t7 }) }), this.handles.add([this.tileStore.on("update", this.onTileUpdate.bind(this)), f3(() => !this.updating, () => this.onIdle())]), this._checkUpdating = setInterval(() => this.notifyChange("updating"), 300);
  2646. }
  2647. _initSource() {
  2648. const e3 = this.tileStore.tileScheme, t7 = () => this._updateQueue.length < 50, r5 = (e4, t8) => (this._invalidated = true, this._patchTile(e4, t8));
  2649. this._source = a7(this.service, this.spatialReference, e3, r5, t7, this.featureStore), this._proxyEvents();
  2650. }
  2651. _proxyEvents() {
  2652. if (this._source.type === "geoevent") {
  2653. const e3 = this._source.events;
  2654. this.handles.add([e3.on("connectionStatus", (e4) => this.remoteClient.invoke("setProperty", { propertyName: "connectionStatus", value: e4 }).catch(x4)), e3.on("errorString", (e4) => this.remoteClient.invoke("setProperty", { propertyName: "errorString", value: e4 }).catch(x4)), e3.on("feature", (e4) => this.remoteClient.invoke("emitEvent", { name: "data-received", event: { attributes: e4.attributes, centroid: e4.centroid, geometry: e4.geometry } }).catch(x4)), e3.on("updateRate", (e4) => this.remoteClient.invoke("emitEvent", { name: "update-rate", event: { ...e4 } }).catch(x4))]);
  2655. }
  2656. }
  2657. _initAttributeStore(e3) {
  2658. this.attributeStore ? this.attributeStore.invalidateResources() : this.attributeStore = new R2({ type: "remote", initialize: (e4, t7) => j(this.remoteClient.invoke(k2, e4, { signal: t7 }).catch(x4)), update: (e4, t7) => j(this.remoteClient.invoke(q3, e4, { signal: t7 }).catch(x4)), render: (e4) => j(this.remoteClient.invoke(R4, void 0, { signal: e4 }).catch(x4)) }, e3, () => this.notifyChange("updating"));
  2659. }
  2660. _initStores() {
  2661. const e3 = this.service.type === "snapshot" ? "snapshot" : "on-demand", t7 = { geometryInfo: { geometryType: this.service.geometryType, hasM: false, hasZ: false }, spatialReference: this.spatialReference, fieldsIndex: this.fieldsIndex, fields: this.service.fields };
  2662. this.featureStore = new l3(t7, this._storage, e3);
  2663. }
  2664. _initQueryEngine(e3) {
  2665. const t7 = this;
  2666. this.queryEngine?.destroy(), this.queryEngine = new Y({ definitionExpression: e3.schema.source.definitionExpression, fields: this.service.fields, geometryType: this.service.geometryType, objectIdField: this.service.objectIdField, hasM: false, hasZ: false, spatialReference: this.spatialReference.toJSON(), cacheSpatialQueries: true, featureStore: this.featureStore, aggregateAdapter: { getFeatureObjectIds(e4) {
  2667. if (t(t7.aggregateStore))
  2668. return [];
  2669. return t7.aggregateStore.getFeatureDisplayIdsForAggregate(e4).map((e5) => t7.getObjectId(e5));
  2670. } }, timeInfo: this.service.timeInfo });
  2671. }
  2672. destroy() {
  2673. this._updateQueue.destroy(), this._source.destroy(), this.queryEngine.destroy(), this.attributeStore && this.attributeStore.destroy();
  2674. for (const e3 of this.tileStore.tiles)
  2675. this._source.unsubscribe(e3);
  2676. clearInterval(this._checkUpdating);
  2677. }
  2678. get fieldsIndex() {
  2679. return new d3(this.service.fields);
  2680. }
  2681. get spatialReference() {
  2682. return this.tileStore.tileScheme.spatialReference;
  2683. }
  2684. get updating() {
  2685. return this.isUpdating();
  2686. }
  2687. isUpdating() {
  2688. const e3 = this._source.updating, t7 = !!this._updateQueue.length, s8 = !this.attributeStore || this.attributeStore.isUpdating(), i4 = e3 || t7 || s8;
  2689. return a("esri-2d-log-updating") && console.log(`Updating FeatureController2D: ${i4}
  2690. -> updatingSource ${e3}
  2691. -> updateQueue ${t7}
  2692. -> updatingAttributeStore ${s8}
  2693. `), i4;
  2694. }
  2695. enableEvent(e3) {
  2696. this._source.enableEvent(e3.name, e3.value);
  2697. }
  2698. pause() {
  2699. this._updateQueue.pause(), this._updateQueue.clear();
  2700. }
  2701. resume() {
  2702. this._updateQueue.resume();
  2703. }
  2704. pauseStream() {
  2705. this._source.type === "geoevent" && this._source.pauseStream();
  2706. }
  2707. resumeStream() {
  2708. this._source.type === "geoevent" && this._source.resumeStream();
  2709. }
  2710. _initAggregateStore(e3) {
  2711. const t7 = { geometryInfo: { geometryType: this.service.geometryType, hasM: false, hasZ: false }, spatialReference: this.spatialReference, fieldsIndex: this.fieldsIndex, fields: this.service.fields }, r5 = e3.schema.targets?.aggregate?.type, s8 = o(this.config, (e4) => e4.schema.targets?.aggregate?.type);
  2712. if (s8 !== r5 && (r(this.aggregateStore) && (this.handles.remove("valueRangesChanged"), this.aggregateStore.destroy(), this.aggregateStore = null), r5)) {
  2713. switch (r5) {
  2714. case "cluster":
  2715. this.aggregateStore = new w4(t7, this.spatialReference, this._storage, this.service), this.handles.add(this.aggregateStore.events.on("valueRangesChanged", (e4) => {
  2716. this.remoteClient.invoke("emitEvent", { name: "valueRangesChanged", event: { valueRanges: e4.valueRanges } }).catch(x4);
  2717. }), "valueRangesChanged");
  2718. break;
  2719. case "bin":
  2720. this.aggregateStore = new A2(t7, this.spatialReference, this._storage, this.service);
  2721. }
  2722. this.aggregateStore.onTileUpdate({ added: this.tileStore.tiles, removed: [] });
  2723. }
  2724. }
  2725. async update(e3, t7) {
  2726. this._updateVersion++, this._initQueryEngine(t7), this._initAttributeStore(t7), this.pause(), await Promise.all([this._source.update(e3, t7.schema.source), this.featureStore.updateSchema(e3, t7.schema.targets.feature), this.attributeStore.update(e3, t7), this.attributeStore.updateFilters(e3, t7, this)]), this._initAggregateStore(t7), r(this.aggregateStore) && await this.aggregateStore.updateSchema(e3, t7.schema.targets.aggregate), a("esri-2d-update-debug") && e3.describe(), this._set("config", t7);
  2727. }
  2728. async applyUpdate(e3) {
  2729. e3.version = this._updateVersion, a("esri-2d-update-debug") && console.debug(`Applying update ${e3.version}`), e3.mesh && this.clearTiles(), this._updateQueue.resume(), await this._source.applyUpdate(e3), this.notifyChange("updating"), await j2(() => !this.updating), r(this.aggregateStore) && (await L(10), await j2(() => !this.updating));
  2730. }
  2731. async onEdits({ edits: e3 }) {
  2732. a("esri-2d-update-debug") && console.debug("Applying Edit:", e3), this._didEdit = true;
  2733. try {
  2734. const t7 = e3.removed.map((e4) => e4.objectId && e4.objectId !== -1 ? e4.objectId : this._lookupObjectIdByGlobalId(e4.globalId)), r5 = e3.addOrModified.map(({ objectId: e4 }) => e4);
  2735. this.featureStore.invalidate(), await this._source.edit(r5, t7), this.clearTiles(), this.notifyChange("updating"), r(this.aggregateStore) && this.aggregateStore.clear(), await this._source.resend(), await j2(() => !this.updating);
  2736. } catch (t7) {
  2737. }
  2738. }
  2739. async refresh(e3) {
  2740. if (!e3) {
  2741. const e4 = t4.empty();
  2742. return e4.storage.filters = true, this.applyUpdate(e4);
  2743. }
  2744. this.featureStore.invalidate(), this.clearTiles(), this._source.refresh(this._updateVersion), this._cleanupNeeded = true, this.notifyChange("updating"), await j2(() => !this.updating);
  2745. }
  2746. clearTiles() {
  2747. for (const e3 of this.tileStore.tiles)
  2748. this.processor.onTileClear(e3);
  2749. }
  2750. onTileUpdate(e3) {
  2751. r(this.aggregateStore) && this.aggregateStore.onTileUpdate(e3);
  2752. for (const t7 of e3.added)
  2753. this._source.subscribe(t7, this._updateVersion), this._level = t7.level;
  2754. for (const t7 of e3.removed)
  2755. this._source.unsubscribe(t7), this._cleanupNeeded = true, this._tileToResolver.has(t7.id) && (this._tileToResolver.get(t7.id).resolve(), this._tileToResolver.delete(t7.id));
  2756. this.notifyChange("updating");
  2757. }
  2758. async onIdle() {
  2759. this._invalidated && (this._invalidated = false, (r(this.aggregateStore) || this.processor.type === "heatmap") && await this._repushCurrentLevelTiles()), this._markAndSweep();
  2760. }
  2761. async querySummaryStatistics({ query: e3, params: t7 }) {
  2762. return this.queryEngine.executeQueryForSummaryStatistics(e3, t7);
  2763. }
  2764. async queryUniqueValues({ query: e3, params: t7 }) {
  2765. return this.queryEngine.executeQueryForUniqueValues(e3, t7);
  2766. }
  2767. async queryClassBreaks({ query: e3, params: t7 }) {
  2768. return this.queryEngine.executeQueryForClassBreaks(e3, t7);
  2769. }
  2770. async queryHistogram({ query: e3, params: t7 }) {
  2771. return this.queryEngine.executeQueryForHistogram(e3, t7);
  2772. }
  2773. queryExtent(e3) {
  2774. return this.queryEngine.executeQueryForExtent(e3);
  2775. }
  2776. queryFeatures(e3) {
  2777. return this.queryEngine.executeQuery(e3);
  2778. }
  2779. async queryVisibleFeatures(e3) {
  2780. const t7 = await this.queryEngine.executeQuery(e3), r5 = t7.objectIdFieldName;
  2781. return t7.features = t7.features.filter((e4) => {
  2782. const t8 = e4.attributes[r5], s8 = this.getDisplayId(t8);
  2783. return o(s8, (e5) => this.attributeStore.isVisible(e5));
  2784. }), t7;
  2785. }
  2786. queryFeatureCount(e3) {
  2787. return this.queryEngine.executeQueryForCount(e3);
  2788. }
  2789. queryLatestObservations(e3) {
  2790. return this.queryEngine.executeQueryForLatestObservations(e3);
  2791. }
  2792. queryObjectIds(e3) {
  2793. return this.queryEngine.executeQueryForIds(e3);
  2794. }
  2795. async queryStatistics() {
  2796. return this.featureStore.storeStatistics;
  2797. }
  2798. getObjectId(e3) {
  2799. return this.featureStore.lookupObjectId(e3, this._storage);
  2800. }
  2801. getDisplayId(e3) {
  2802. if (r(this.aggregateStore)) {
  2803. const t7 = this.aggregateStore.getDisplayId(e3);
  2804. if (t(t7)) {
  2805. const t8 = this.featureStore.lookupDisplayId(e3);
  2806. return this.aggregateStore.getDisplayIdForReferenceId(t8);
  2807. }
  2808. return t7;
  2809. }
  2810. return this.featureStore.lookupDisplayId(e3);
  2811. }
  2812. getFeatures(e3) {
  2813. const t7 = [], r5 = [];
  2814. for (const s8 of e3) {
  2815. const e4 = r(this.aggregateStore) ? this.getAggregate(s8) : null;
  2816. if (r(e4))
  2817. if (r(e4.referenceId)) {
  2818. const r6 = this.getFeature(e4.referenceId);
  2819. r(r6) && t7.push(r6);
  2820. } else
  2821. r5.push(e4);
  2822. else {
  2823. const e5 = this.getFeature(s8);
  2824. r(e5) && t7.push(e5);
  2825. }
  2826. }
  2827. return { features: t7, aggregates: r5 };
  2828. }
  2829. getFeature(e3) {
  2830. const t7 = this.featureStore.lookupFeatureByDisplayId(e3, this._storage);
  2831. if (t(t7))
  2832. return null;
  2833. const r5 = t7.readHydratedGeometry(), i4 = ne(r5, t7.geometryType, t7.hasZ, t7.hasM);
  2834. return { attributes: t7.readAttributes(), geometry: i4 };
  2835. }
  2836. getAggregate(e3) {
  2837. return t(this.aggregateStore) ? null : this.aggregateStore.getAggregate(e3);
  2838. }
  2839. getAggregates() {
  2840. return t(this.aggregateStore) ? [] : this.aggregateStore.getAggregates();
  2841. }
  2842. async setHighlight(e3) {
  2843. const t7 = g(e3.map((e4) => this.getDisplayId(e4)));
  2844. return this.attributeStore.setHighlight(e3, t7);
  2845. }
  2846. _lookupObjectIdByGlobalId(e3) {
  2847. const t7 = this.service.globalIdField;
  2848. if (t(t7))
  2849. throw new Error("Expected globalIdField to be defined");
  2850. let r5 = null;
  2851. if (this.featureStore.forEach((s8) => {
  2852. e3 === s8.readAttribute(t7) && (r5 = s8.getObjectId());
  2853. }), t(r5))
  2854. throw new Error(`Expected to find a feature with globalId ${e3}`);
  2855. return r5;
  2856. }
  2857. async _repushCurrentLevelTiles() {
  2858. const e3 = this.tileStore.tiles.filter((e4) => e4.level === this._level).map(async (e4) => this._patchTile({ type: "append", id: e4.key.id, addOrUpdate: d5.fromOptimizedFeatures([], this.service), remove: [], end: true, status: t4.empty() }));
  2859. await Promise.all(e3);
  2860. }
  2861. _maybeForceCleanup() {
  2862. performance.now() - this._lastCleanup > T && this._markAndSweep();
  2863. }
  2864. _patchTile(e3, t7) {
  2865. const r5 = this._updateQueue.push(e3, t7).then(() => {
  2866. this.notifyChange("updating");
  2867. }).catch((e4) => {
  2868. this.notifyChange("updating");
  2869. });
  2870. return this.notifyChange("updating"), r5;
  2871. }
  2872. async _onTileMessage(e3, t7) {
  2873. f2(t7);
  2874. const r5 = this.tileStore.get(e3.id);
  2875. if (!r5)
  2876. return;
  2877. if (e3.clear)
  2878. return this.processor.onTileClear(r5);
  2879. const i4 = e3.status;
  2880. this._cleanupNeeded = true;
  2881. const o11 = [];
  2882. for (const s8 of e3.remove) {
  2883. const e4 = this.featureStore.lookupDisplayId(s8);
  2884. e4 && o11.push(e4);
  2885. }
  2886. e3.remove = o11;
  2887. try {
  2888. if (t(e3.addOrUpdate))
  2889. return void this.processor.onTileMessage(r5, { ...e3, addOrUpdate: null }, r(this.aggregateStore), t7).catch(b);
  2890. if (e3.addOrUpdate.setArcadeSpatialReference(this.spatialReference), this.featureStore.hasInstance(e3.addOrUpdate.instance) && i4.targets.feature || (i4.targets.feature = true, this.featureStore.onTileData(r5, e3)), !i4.storage.data || !i4.storage.filters) {
  2891. i4.storage.data = true, i4.storage.filters = true, this.attributeStore.onTileData(r5, e3);
  2892. this._source.type === "geoevent" || this._didEdit ? (await this.attributeStore.sendUpdates(), f2(t7)) : this.attributeStore.sendUpdates();
  2893. }
  2894. if (r(this.aggregateStore) && !i4.targets.aggregate) {
  2895. i4.targets.aggregate = true;
  2896. const t8 = Q2(this._source) && this._source.loading, s8 = !Q2(this._source) || t8 || e3.end;
  2897. if (this.aggregateStore.onTileData(r5, e3, this._storage, this.attributeStore, s8), !s8)
  2898. return;
  2899. i4.mesh || (this.attributeStore.onTileData(r5, e3), await this.attributeStore.sendUpdates());
  2900. }
  2901. i4.mesh || (i4.mesh = true, await this.processor.onTileMessage(r5, e3, r(this.aggregateStore), t7), f2(t7)), this._maybeForceCleanup();
  2902. } catch (n6) {
  2903. b(n6);
  2904. }
  2905. }
  2906. _mark(e3, t7, r5) {
  2907. const s8 = (4294901760 & this._storage.getInstanceId(e3)) >>> 16;
  2908. e3 && (t7.add(s8), r5.set(e3));
  2909. }
  2910. _markAndSweep() {
  2911. this._lastCleanup = performance.now();
  2912. if (!(!(this._source.type === "feature" && this._source.mode === "snapshot") && (this._source.type === "geoevent" || this._cleanupNeeded)))
  2913. return;
  2914. this._cleanupNeeded = false;
  2915. const e3 = this._storage.getBitset(this._markedIdsBufId), t7 = new Set();
  2916. e3.clear();
  2917. for (const r5 of this.tileStore.tiles)
  2918. for (const s8 of this._source.readers(r5.id)) {
  2919. const r6 = s8.getCursor();
  2920. for (; r6.next(); ) {
  2921. let s9 = r6.getDisplayId();
  2922. if (!s9) {
  2923. const e4 = r6.getObjectId();
  2924. s9 = this.featureStore.lookupDisplayId(e4);
  2925. }
  2926. this._mark(s9, t7, e3);
  2927. }
  2928. }
  2929. this.processor.type === "symbol" && this.processor.forEachBufferId((r5) => {
  2930. this._mark(r5, t7, e3);
  2931. }), this._updateQueue.forEach((r5) => {
  2932. for (const s8 of r5.remove) {
  2933. const r6 = this.featureStore.lookupDisplayId(s8);
  2934. this._mark(r6, t7, e3);
  2935. }
  2936. }), r(this.aggregateStore) && (this.aggregateStore.sweepFeatures(e3, this.featureStore), "sweepAggregates" in this.aggregateStore && this.aggregateStore.sweepAggregates(this._storage, this.attributeStore, this._level)), this.featureStore.sweepFeatures(e3, this._storage, this.attributeStore), this.featureStore.sweepFeatureSets(t7);
  2937. }
  2938. };
  2939. e([d({ constructOnly: true })], O.prototype, "tileStore", void 0), e([d()], O.prototype, "config", void 0), e([d({ readOnly: true })], O.prototype, "fieldsIndex", null), e([d()], O.prototype, "processor", void 0), e([d({ constructOnly: true })], O.prototype, "remoteClient", void 0), e([d({ constructOnly: true })], O.prototype, "service", void 0), e([d()], O.prototype, "spatialReference", null), e([d()], O.prototype, "updating", null), O = e([n("esri.views.2d.layers.features.controllers.FeatureController2D")], O);
  2940. var A3 = O;
  2941. // node_modules/@arcgis/core/views/2d/layers/features/Pipeline.js
  2942. var d10 = class extends d4 {
  2943. constructor() {
  2944. super(...arguments), this.controller = null, this.processor = null, this.remoteClient = null, this.tileStore = null, this.service = null, this.viewState = null, this._paused = false, this._pendingTileUpdates = [];
  2945. }
  2946. initialize() {
  2947. this.handles.add(l(() => this.updating, (e3) => {
  2948. this.remoteClient.invoke("setUpdating", e3).catch((e4) => {
  2949. });
  2950. }));
  2951. }
  2952. destroy() {
  2953. this.stop(), this.controller?.destroy(), this.processor?.destroy(), this.controller = this.processor = this.tileStore = this.remoteClient = null;
  2954. }
  2955. get updating() {
  2956. return !this.controller || this.controller.updating;
  2957. }
  2958. stop() {
  2959. this._paused = true, Array.isArray(this.service?.source) && (this.service.source.forEach((e3) => e3.close()), this.service.source.length = 0), this.tileStore?.updateTiles({ added: [], removed: this.tileStore.tiles.map((e3) => e3.id) }), this.tileStore?.destroy(), this.tileStore = null, this._pendingTileUpdates.length = 0;
  2960. }
  2961. async startup({ service: e3, config: t7, tileInfo: r5, tiles: s8 }) {
  2962. if (this._paused = true, Array.isArray(this.service?.source) && (this.service.source.forEach((e4) => e4.close()), this.service.source.length = 0), this.service = e3, !this.tileStore || !E3(this.tileStore.tileScheme.spatialReference, r5.spatialReference)) {
  2963. const e4 = new h(S.fromJSON(r5));
  2964. s8.added.length = s8.removed.length = 0, this.tileStore?.updateTiles({ added: [], removed: this.tileStore.tiles.map((e5) => e5.id) }), this.tileStore?.destroy(), this.tileStore = new l4(e4), this._pendingTileUpdates.length = 0;
  2965. }
  2966. for (await this._createProcessorAndController(t7), await this.update({ config: t7 }), this.controller.resume(), this.tileStore.clear(), this.tileStore.updateTiles(s8), this._paused = false; this._pendingTileUpdates.length; )
  2967. this.tileStore.updateTiles(this._pendingTileUpdates.pop());
  2968. }
  2969. async updateTiles(e3) {
  2970. this._paused ? this._pendingTileUpdates.push(e3) : this.tileStore.updateTiles(e3);
  2971. }
  2972. async update({ config: e3 }) {
  2973. const t7 = t4.empty();
  2974. return await Promise.all([this.processor.update(t7, e3), this.controller.update(t7, e3)]), t7.toJSON();
  2975. }
  2976. async applyUpdate(e3) {
  2977. return this.controller.applyUpdate(t4.create(e3));
  2978. }
  2979. async _createProcessorAndController(e3) {
  2980. await Promise.all([this._handleControllerConfig(e3), this._handleProcessorConfig(e3)]), this.controller.processor = this.processor;
  2981. }
  2982. async _handleControllerConfig(e3) {
  2983. return this._createController(this.service, e3);
  2984. }
  2985. async _handleProcessorConfig(e3) {
  2986. return this._createProcessor(this.service, e3);
  2987. }
  2988. async _createController(e3, t7) {
  2989. this.controller && this.controller.destroy();
  2990. const { tileStore: r5, remoteClient: s8 } = this, o11 = new A3({ service: e3, tileStore: r5, remoteClient: s8 });
  2991. return this.controller = o11, o11;
  2992. }
  2993. async _createProcessor(e3, t7) {
  2994. const r5 = t7.schema.processors[0].type, s8 = (await o6(r5)).default, { remoteClient: o11, tileStore: i4 } = this, l9 = new s8({ service: e3, config: t7, tileStore: i4, remoteClient: o11 });
  2995. return this.processor && this.processor.destroy(), this.processor = l9, l9;
  2996. }
  2997. };
  2998. e([d()], d10.prototype, "controller", void 0), e([d()], d10.prototype, "processor", void 0), e([d()], d10.prototype, "updating", null), e([d()], d10.prototype, "viewState", void 0), d10 = e([n("esri.views.2d.layers.features.Pipeline")], d10);
  2999. var u4 = d10;
  3000. export {
  3001. u4 as default
  3002. };
  3003. //# sourceMappingURL=Pipeline-FIWUDD7H.js.map