/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.24/esri/copyright.txt for details. */ import{validateLanguage as n,findScriptDependencies as e,checkScript as r,findFieldLiterals as t,validateScript as o,findExpectedFieldLiterals as i,referencesMember as c,referencesFunction as l}from"./treeAnalysis.js";import{parse as u}from"./lib/arcade-parser.js";function a(r,t=[]){const o=u("function _() { "+r+"\n}");if(null===o.body||void 0===o.body)throw new Error("No formula provided.");if(0===o.body.length)throw new Error("No formula provided.");if(0===o.body.length)throw new Error("No formula provided.");if("BlockStatement"!==o.body[0].body.type)throw new Error("Invalid formula content.");const i=n(o);if(""!==i)throw new Error(i);return e(o,t),o}function s(n,e,t,o,i){const c=[],l="function _() { \n".length-1,a="function _() { \n"+n+"\n}";try{const n=u(a,{tolerant:!0,loc:!0,range:!0}),s=n.errors;if(s.length>0)for(let e=0;e