@arcgis/ai-components 5.2.0-next.37 → 5.2.0-next.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/cdn/{KRE4U7V7.js → 2K3FTW7J.js} +1 -1
  2. package/dist/cdn/{TSEQVE2H.js → 32B6ZVYG.js} +1 -1
  3. package/dist/cdn/{L77BTGXY.js → 3RPE2QMJ.js} +1 -1
  4. package/dist/cdn/{4RZPOYZ7.js → 3X7JLPXS.js} +1 -1
  5. package/dist/cdn/53TGCGSX.js +18 -0
  6. package/dist/cdn/{JEIMRNYM.js → 7GE723EX.js} +1 -1
  7. package/dist/cdn/{S27EJSLC.js → B7W5WD4R.js} +1 -1
  8. package/dist/cdn/BLKXZEPZ.js +56 -0
  9. package/dist/cdn/{IGZWQJW7.js → D36UDLAY.js} +1 -1
  10. package/dist/cdn/{7IFCBXV7.js → DFF2LGQI.js} +1 -1
  11. package/dist/cdn/{YRBANNQ5.js → E2JBQWHX.js} +1 -1
  12. package/dist/cdn/{O7TGCM5P.js → EJ2LRQVR.js} +1 -1
  13. package/dist/cdn/{Q73PK7Q7.js → FDPJ5Y3M.js} +1 -1
  14. package/dist/cdn/FK7ENS6I.js +2 -0
  15. package/dist/cdn/{CIW3QMKV.js → FNFJYOHX.js} +1 -1
  16. package/dist/cdn/{2NMR43NW.js → GJHBXGNP.js} +1 -1
  17. package/dist/cdn/HW2FV2RU.js +48 -0
  18. package/dist/cdn/{XVQJBUMY.js → I4A2LAZS.js} +1 -1
  19. package/dist/cdn/{O3F47IO5.js → I5QIEV37.js} +1 -1
  20. package/dist/cdn/{YYY7HKYX.js → IBKTXP76.js} +1 -1
  21. package/dist/cdn/MU52B4SV.js +181 -0
  22. package/dist/cdn/{SMADRJ67.js → NV2KTZTO.js} +1 -1
  23. package/dist/cdn/ON5PWODA.js +208 -0
  24. package/dist/cdn/{IXAKT6L3.js → P22UEKRX.js} +1 -1
  25. package/dist/cdn/PA5W5PWE.js +2 -0
  26. package/dist/cdn/{WAVKMZA6.js → QA7IATZC.js} +1 -1
  27. package/dist/cdn/{IC5P5NYY.js → QJJ6YSAC.js} +1 -1
  28. package/dist/cdn/{HOCTVCHH.js → RHM3WKYV.js} +1 -1
  29. package/dist/cdn/{E7TMP4YV.js → SHFSDORL.js} +1 -1
  30. package/dist/cdn/{AMVOJNWN.js → TIEV263K.js} +1 -1
  31. package/dist/cdn/{HXOSLGWU.js → TKSWXCCJ.js} +1 -1
  32. package/dist/cdn/{AFLQZIKS.js → VAX3IAC3.js} +31 -31
  33. package/dist/cdn/{WDE3HN7K.js → XHJTT7BG.js} +1 -1
  34. package/dist/cdn/XNITXZDU.js +2 -0
  35. package/dist/cdn/{C7E7MJSR.js → XXIKORXX.js} +1 -1
  36. package/dist/cdn/{HBYZSLEZ.js → Y7KEZCVG.js} +1 -1
  37. package/dist/cdn/agent-utils/index.js +1 -1
  38. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +1 -1
  39. package/dist/cdn/agent-utils/middlewares/middleware.js +1 -1
  40. package/dist/cdn/agent-utils/middlewares/trace.js +1 -1
  41. package/dist/cdn/index.js +1 -1
  42. package/dist/docs/api.json +1 -1
  43. package/dist/docs/docs.json +1 -1
  44. package/dist/docs/web-types.json +1 -1
  45. package/package.json +9 -9
  46. package/dist/cdn/6LZ6GOHF.js +0 -56
  47. package/dist/cdn/CJIV4KJZ.js +0 -179
  48. package/dist/cdn/CVHJMR5X.js +0 -2
  49. package/dist/cdn/EBRNMPPO.js +0 -48
  50. package/dist/cdn/IKEF7ZHH.js +0 -181
  51. package/dist/cdn/LODKJRS4.js +0 -2
  52. package/dist/cdn/PKHQW7QU.js +0 -18
  53. package/dist/cdn/VKU4WAQV.js +0 -2
@@ -1,9 +1,9 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./EBRNMPPO.js";import{a as S,b as x}from"./4RZPOYZ7.js";import{_ as b,ea as xe,g as Te,j as B,k as U,pa as D,u as Se}from"./CJIV4KJZ.js";import{L as z,P as oe,_ as j,wc as y}from"./IKEF7ZHH.js";import{a as s}from"./WNS5ZUF5.js";import{Dd as N}from"./ZEYIBYSF.js";export default $arcgis.t(([Me,F,ie,je,,Ae,nt,{addressToLocations:it},st,lt,De,{createRenderer:ct},{getSchemesByTag:ut,getSchemes:dt},{getBackgroundColorTheme:Re},{createAgeRenderer:pt,createContinuousRenderer:mt},{getSchemesByTag:ge},{createContinuousRenderer:ht},{createRenderer:ft},{getSchemesByTag:yt},{createRenderer:gt},{getSchemesByTag:wt},{createRenderer:bt},{getSchemesByTag:vt},{createRenderer:Tt},{getSchemesByTag:St},{createAgeRenderer:xt,createContinuousRenderer:Et},{createRenderer:It},{getSchemesByTag:Nt},kt,Le,Oe,{formatDateOnly:$t,convertDateFormatToIntlOptions:W,formatTimeOnly:Ft,formatDate:qe},Mt,At,Rt,qt,Ct,Pe,,{fetchKnowledgeGraph:Ce,executeQueryStreaming:_t,executeSearchStreaming:zt},jt,{getBindParametersFromCypherQuery:Dt},{b:L,c:Ee,q:Ie}])=>{var Fe=e=>Array.isArray(e)&&e.every(z),tt=e=>typeof e=="object"&&e!=null&&"messages"in e&&Fe(e.messages),rt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,K=class extends xe{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:o,handleToolErrors:a}=t??{};super({name:r,tags:o,func:(n,l)=>this.run(n,l)}),this.tools=e,this.handleToolErrors=a??this.handleToolErrors}async runTool(e,t){let r=this.tools.find(o=>o.name===e.name);try{if(r===void 0)throw new Error(`Tool "${e.name}" not found.`);let o=await r.invoke({...e,type:"tool_call"},t);return z(o)&&o.getType()==="tool"||U(o)?o:new oe({status:"success",name:r.name,content:typeof o=="string"?o:JSON.stringify(o),tool_call_id:e.id})}catch(o){if(!this.handleToolErrors||Se(o))throw o;return new oe({status:"error",content:`Error: ${o.message}
3
- Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,t){let r;if(rt(e))r=[await this.runTool(e.lg_tool_call,t)];else{let n;if(Fe(e))n=e;else if(tt(e))n=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let l=new Set(n.filter(u=>u.getType()==="tool").map(u=>u.tool_call_id)),i;for(let u=n.length-1;u>=0;u-=1){let c=n[u];if(j(c)){i=c;break}}if(i==null||!j(i))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(i.tool_calls?.filter(u=>u.id==null||!l.has(u.id)).map(u=>this.runTool(u,t))??[])}if(!r.some(U))return Array.isArray(e)?r:{messages:r};let o=[],a=null;for(let n of r)U(n)?n.graph===B.PARENT&&Array.isArray(n.goto)&&n.goto.every(l=>Te(l))?a?a.goto.push(...n.goto):a=new B({graph:B.PARENT,goto:n.goto}):o.push(n):o.push(Array.isArray(e)?[n]:{messages:[n]});return a&&o.push(a),o}};var Dn=b.Root({llmInputMessages:b({reducer:(e,t)=>D([],t),default:()=>[]})});var O=(e,t)=>t??e,Wi=b.Root({...Ee(),intent:b({reducer:O}),vectorSearchLayerResults:b({reducer:O,default:()=>[]}),vectorSearchFieldResults:b({reducer:O}),navigationInternalState:b({reducer:O,default:()=>({toolCallMessage:void 0})})});async function Lt(e,t){let r=F.getDefault().helperServices,o=r.geocode.find(d=>d.name==="ArcGIS World Geocoding Service")??r.geocode[0];if(!o)throw new Error("No geocoding service found in helperServices.");let a=o.url,n=`${ie.assetsPath?.endsWith("/")?ie.assetsPath:`${ie.assetsPath}/`}esri/images/search/search-symbol-32.png`,l=(await it(a,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!l?.extent||!l.location)throw new Error(`Could not find location for: ${e}`);let i=new st({url:n,width:24,height:24}),u=new nt({geometry:l.location,symbol:i});t.graphics.removeAll(),t.graphics.add(u),await t.goTo(l.extent);let c={address:l.address??"",location:l.location?l.location.toJSON():null,extent:l.extent?l.extent.toJSON():null};return{text:`Successfully zoomed to ${e}.`,sharedStatePatch:{lastResolvedLocation:{value:c}}}}var Ot=["mapView"];function k(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("NavigationAgent context missing");let r=Ot.filter(o=>!(o in t));if(r.length)throw new Error(`NavigationAgent context missing: ${r.join(", ")}`);return t}async function Pt({address:e},t){let{mapView:r}=k(t);return await Lt(e,r)}var Gt=s.object({address:s.string().describe("The full address or place name to locate.")}),Hi=y(Pt,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:Gt});async function Vt(e,t){let r=t.map.bookmarks;if(!r||r.length===0)throw new Error("No bookmarks found in the map.");let o=r.find(n=>n.name===e);if(!o)throw new Error(`Bookmark with name "${e}" not found.`);let a=o.viewpoint;if(!a)throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);return await t.goTo(a),{text:`Navigated to bookmark: ${e}`}}async function Qt({bookmarkName:e},t){let{mapView:r}=k(t);return await Promise.resolve(Vt(e,r))}var Bt=N.object({bookmarkName:N.string().describe("The name of the bookmark to navigate to.")}),Ji=y(Qt,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:Bt});async function Ut(e,t,r){let o=r.map?.allLayers.find(l=>l.id===e);if(!o)return{text:`Error: Layer with id ${e} not found`};let a=t?.trim()?t:"1=1",n=o.createQuery();n.where=a;try{let{extent:l,count:i}=await o.queryExtent(n);if(i===0)return{text:`No features found in ${o.title} matching: ${a}`,where:a};if(l)await r.goTo(l);else return{text:`Error: Unable to determine extent for ${o.title}`,where:a};let u={layerId:e,layerTitle:o.title??e,where:a,count:i};return{text:`Successfully zoomed to ${i} feature(s) in ${o.title} matching: ${a}`,where:a,sharedStatePatch:{lastNavigatedFeatures:{value:u}}}}catch(l){return console.error("Error in goToFeatures:",l),{text:`Error: ${l instanceof Error?l.message:"Unknown error"}`,where:a}}}async function Kt({layerId:e,where:t},r){let{mapView:o}=k(r);return await Ut(e,t,o)}var Wt=N.object({layerId:N.string().describe("The layerId of the layer to zoom to."),where:N.string().describe("ArcGIS SQL-92 WHERE expression used for `query.where` on the selected layer. Use only fields from that layer and return a boolean filter expression (for example comparisons, LIKE, IN, BETWEEN, IS NULL, AND/OR/NOT). Do NOT include subqueries/nested SELECT, JOIN, GROUP BY, HAVING, ORDER BY, or semicolons.")}),Zi=y(Kt,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:Wt});async function Ht(e){let t=new lt({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(t),{text:"Successfully zoomed to world extent"}}async function Jt(e,t){let{mapView:r}=k(t);return await Ht(r)}var Zt=N.object({}),Yi=y(Jt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Zt});async function Yt(e){let t=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(t)await e.goTo(t);else throw new Error("Initial extent is undefined");return{text:"Successfully zoomed to home extent"}}async function Xt(e,t){let{mapView:r}=k(t);return await Yt(r)}var er=s.object({}),Xi=y(Xt,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:er});async function tr(e,t){await t.when();let r=t.map?.allLayers.find(a=>a.id===e);if(!r)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),{text:`Could not find layer for: ${e}`};let o;return(r.type==="link-chart"||r.type==="knowledge-graph-sublayer")&&t.map?.activeLinkChartLayer?o=t.map.diagramNodesExtent:o=r.fullExtent,o?(await t.goTo(o),r.visible=!0,{text:`Successfully zoomed to: ${r.title??""}`}):{text:"Layer has no defined extent. Cannot zoom to layer."}}async function rr({layerId:e},t){let{mapView:r}=k(t);return await tr(e,r)}var or=N.object({layerId:N.string().describe("The id of the layer to navigate to")}),es=y(rr,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:or});async function ar(e,t){return await t.goTo({scale:e}),{text:`Successfully zoomed to: ${e}`}}async function nr({scale:e},t){let{mapView:r}=k(t);return await ar(e,r)}var ir=s.object({scale:s.number().describe("The map scale of the view to go to.")}),ts=y(nr,{name:"goToScale",description:"Go to the specified view scale.",schema:ir});async function sr(e,t,r){let o={target:new De({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return r?.zoom!==void 0&&(o.zoom=r.zoom),r?.scale!==void 0&&(o.scale=r.scale),await t.goTo(o),{text:`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,r?.zoom!==void 0?`zoom ${r.zoom}`:"",r?.scale!==void 0?`scale 1:${r.scale}`:""].filter(Boolean).join(", ")}`}}async function lr({center:e,zoom:t,scale:r},o){let{mapView:a}=k(o);return await sr(e,a,{zoom:t,scale:r})}var cr=s.object({center:s.object({longitude:s.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:s.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:s.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:s.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),rs=y(lr,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:cr});async function ur(e,t){return await t.goTo({zoom:e}),{text:`Successfully zoomed to: ${e}`}}async function dr({zoom:e},t){let{mapView:r}=k(t);return await ur(e,r)}var pr=s.object({zoom:s.number().min(1).max(20).describe("The zoom level of the view to go to.")}),os=y(dr,{name:"goToZoom",description:'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',schema:pr}),_e=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./LEPJUN3X.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md":()=>import("./W2IHPJ54.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_cypher_query_prompt.md":()=>import("./ZMSJQB65.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md":()=>import("./5ZZGKP7N.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md":()=>import("./3AXQTBIA.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./ZS2TZ6BF.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./LQ6R5YRN.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./TNMXWUXU.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./T537PKP4.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./4I4MCV7V.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./FX7UOGHP.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./KTK4HNL2.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./6YMR4QSD.js").then(e=>e.default)});async function Z(e){let t=Object.entries(_e).find(([r])=>r.endsWith(`/${e}.md`));if(!t)throw new Error(`Prompt not found: ${e}
2
+ import a from"./HW2FV2RU.js";import{a as S,b as x}from"./3X7JLPXS.js";import{Ca as xe,Pa as D,g as Te,ha as b,j as B,k as U,y as Se}from"./ON5PWODA.js";import{Bc as y,Q as z,U as oe,da as j}from"./MU52B4SV.js";import{a as l}from"./WNS5ZUF5.js";import{Dd as N}from"./ZEYIBYSF.js";export default $arcgis.t(([Me,F,ie,je,,Ae,nt,{addressToLocations:it},st,lt,De,{createRenderer:ct},{getSchemesByTag:ut,getSchemes:dt},{getBackgroundColorTheme:Ce},{createAgeRenderer:pt,createContinuousRenderer:mt},{getSchemesByTag:ge},{createContinuousRenderer:ht},{createRenderer:ft},{getSchemesByTag:yt},{createRenderer:gt},{getSchemesByTag:wt},{createRenderer:bt},{getSchemesByTag:vt},{createRenderer:Tt},{getSchemesByTag:St},{createAgeRenderer:xt,createContinuousRenderer:Et},{createRenderer:It},{getSchemesByTag:Nt},kt,Le,Oe,{formatDateOnly:$t,convertDateFormatToIntlOptions:W,formatTimeOnly:Ft,formatDate:Re},Mt,At,Ct,Rt,qt,Pe,,{fetchKnowledgeGraph:qe,executeQueryStreaming:_t,executeSearchStreaming:zt},jt,{getBindParametersFromCypherQuery:Dt},{b:L,c:Ee,q:Ie}])=>{var Fe=e=>Array.isArray(e)&&e.every(z),tt=e=>typeof e=="object"&&e!=null&&"messages"in e&&Fe(e.messages),rt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,K=class extends xe{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:o,handleToolErrors:a}=t??{};super({name:r,tags:o,func:(n,s)=>this.run(n,s)}),this.tools=e,this.handleToolErrors=a??this.handleToolErrors}async runTool(e,t,r){let o=this.tools.find(a=>a.name===e.name);try{if(o===void 0)throw new Error(`Tool "${e.name}" not found.`);let a={...e,type:"tool_call"},n={...t,state:r,toolCallId:e.id??"",config:t,context:t.context,store:t.store??null,writer:t.writer??t.configurable?.writer??null},s=await o.invoke(a,n);return z(s)&&s.getType()==="tool"||U(s)?s:new oe({status:"success",name:o.name,content:typeof s=="string"?s:JSON.stringify(s),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||Se(a))throw a;return new oe({status:"error",content:`Error: ${a.message}
3
+ Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,t){let r;if(rt(e)){let{lg_tool_call:n,...s}=e;r=[await this.runTool(n,t,s)]}else{let n;if(Fe(e))n=e;else if(tt(e))n=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let s=new Set(n.filter(u=>u.getType()==="tool").map(u=>u.tool_call_id)),i;for(let u=n.length-1;u>=0;u-=1){let c=n[u];if(j(c)){i=c;break}}if(i==null||!j(i))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(i.tool_calls?.filter(u=>u.id==null||!s.has(u.id)).map(u=>this.runTool(u,t,e))??[])}if(!r.some(U))return Array.isArray(e)?r:{messages:r};let o=[],a=null;for(let n of r)U(n)?n.graph===B.PARENT&&Array.isArray(n.goto)&&n.goto.every(s=>Te(s))?a?a.goto.push(...n.goto):a=new B({graph:B.PARENT,goto:n.goto}):o.push(n):o.push(Array.isArray(e)?[n]:{messages:[n]});return a&&o.push(a),o}};var Dn=b.Root({llmInputMessages:b({reducer:(e,t)=>D([],t),default:()=>[]})});var O=(e,t)=>t??e,Wi=b.Root({...Ee(),intent:b({reducer:O}),vectorSearchLayerResults:b({reducer:O,default:()=>[]}),vectorSearchFieldResults:b({reducer:O}),navigationInternalState:b({reducer:O,default:()=>({toolCallMessage:void 0})})});async function Lt(e,t){let r=F.getDefault().helperServices,o=r.geocode.find(d=>d.name==="ArcGIS World Geocoding Service")??r.geocode[0];if(!o)throw new Error("No geocoding service found in helperServices.");let a=o.url,n=`${ie.assetsPath?.endsWith("/")?ie.assetsPath:`${ie.assetsPath}/`}esri/images/search/search-symbol-32.png`,s=(await it(a,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!s?.extent||!s.location)throw new Error(`Could not find location for: ${e}`);let i=new st({url:n,width:24,height:24}),u=new nt({geometry:s.location,symbol:i});t.graphics.removeAll(),t.graphics.add(u),await t.goTo(s.extent);let c={address:s.address??"",location:s.location?s.location.toJSON():null,extent:s.extent?s.extent.toJSON():null};return{text:`Successfully zoomed to ${e}.`,sharedStatePatch:{lastResolvedLocation:{value:c}}}}var Ot=["mapView"];function k(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("NavigationAgent context missing");let r=Ot.filter(o=>!(o in t));if(r.length)throw new Error(`NavigationAgent context missing: ${r.join(", ")}`);return t}async function Pt({address:e},t){let{mapView:r}=k(t);return await Lt(e,r)}var Gt=l.object({address:l.string().describe("The full address or place name to locate.")}),Hi=y(Pt,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:Gt});async function Vt(e,t){let r=t.map.bookmarks;if(!r||r.length===0)throw new Error("No bookmarks found in the map.");let o=r.find(n=>n.name===e);if(!o)throw new Error(`Bookmark with name "${e}" not found.`);let a=o.viewpoint;if(!a)throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);return await t.goTo(a),{text:`Navigated to bookmark: ${e}`}}async function Qt({bookmarkName:e},t){let{mapView:r}=k(t);return await Promise.resolve(Vt(e,r))}var Bt=N.object({bookmarkName:N.string().describe("The name of the bookmark to navigate to.")}),Ji=y(Qt,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:Bt});async function Ut(e,t,r){let o=r.map?.allLayers.find(s=>s.id===e);if(!o)return{text:`Error: Layer with id ${e} not found`};let a=t?.trim()?t:"1=1",n=o.createQuery();n.where=a;try{let{extent:s,count:i}=await o.queryExtent(n);if(i===0)return{text:`No features found in ${o.title} matching: ${a}`,where:a};if(s)await r.goTo(s);else return{text:`Error: Unable to determine extent for ${o.title}`,where:a};let u={layerId:e,layerTitle:o.title??e,where:a,count:i};return{text:`Successfully zoomed to ${i} feature(s) in ${o.title} matching: ${a}`,where:a,sharedStatePatch:{lastNavigatedFeatures:{value:u}}}}catch(s){return console.error("Error in goToFeatures:",s),{text:`Error: ${s instanceof Error?s.message:"Unknown error"}`,where:a}}}async function Kt({layerId:e,where:t},r){let{mapView:o}=k(r);return await Ut(e,t,o)}var Wt=N.object({layerId:N.string().describe("The layerId of the layer to zoom to."),where:N.string().describe("ArcGIS SQL-92 WHERE expression used for `query.where` on the selected layer. Use only fields from that layer and return a boolean filter expression (for example comparisons, LIKE, IN, BETWEEN, IS NULL, AND/OR/NOT). Do NOT include subqueries/nested SELECT, JOIN, GROUP BY, HAVING, ORDER BY, or semicolons.")}),Zi=y(Kt,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:Wt});async function Ht(e){let t=new lt({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(t),{text:"Successfully zoomed to world extent"}}async function Jt(e,t){let{mapView:r}=k(t);return await Ht(r)}var Zt=N.object({}),Yi=y(Jt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Zt});async function Yt(e){let t=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(t)await e.goTo(t);else throw new Error("Initial extent is undefined");return{text:"Successfully zoomed to home extent"}}async function Xt(e,t){let{mapView:r}=k(t);return await Yt(r)}var er=l.object({}),Xi=y(Xt,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:er});async function tr(e,t){await t.when();let r=t.map?.allLayers.find(a=>a.id===e);if(!r)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),{text:`Could not find layer for: ${e}`};let o;return(r.type==="link-chart"||r.type==="knowledge-graph-sublayer")&&t.map?.activeLinkChartLayer?o=t.map.diagramNodesExtent:o=r.fullExtent,o?(await t.goTo(o),r.visible=!0,{text:`Successfully zoomed to: ${r.title??""}`}):{text:"Layer has no defined extent. Cannot zoom to layer."}}async function rr({layerId:e},t){let{mapView:r}=k(t);return await tr(e,r)}var or=N.object({layerId:N.string().describe("The id of the layer to navigate to")}),es=y(rr,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:or});async function ar(e,t){return await t.goTo({scale:e}),{text:`Successfully zoomed to: ${e}`}}async function nr({scale:e},t){let{mapView:r}=k(t);return await ar(e,r)}var ir=l.object({scale:l.number().describe("The map scale of the view to go to.")}),ts=y(nr,{name:"goToScale",description:"Go to the specified view scale.",schema:ir});async function sr(e,t,r){let o={target:new De({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return r?.zoom!==void 0&&(o.zoom=r.zoom),r?.scale!==void 0&&(o.scale=r.scale),await t.goTo(o),{text:`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,r?.zoom!==void 0?`zoom ${r.zoom}`:"",r?.scale!==void 0?`scale 1:${r.scale}`:""].filter(Boolean).join(", ")}`}}async function lr({center:e,zoom:t,scale:r},o){let{mapView:a}=k(o);return await sr(e,a,{zoom:t,scale:r})}var cr=l.object({center:l.object({longitude:l.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:l.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:l.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:l.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),rs=y(lr,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:cr});async function ur(e,t){return await t.goTo({zoom:e}),{text:`Successfully zoomed to: ${e}`}}async function dr({zoom:e},t){let{mapView:r}=k(t);return await ur(e,r)}var pr=l.object({zoom:l.number().min(1).max(20).describe("The zoom level of the view to go to.")}),os=y(dr,{name:"goToZoom",description:'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',schema:pr}),_e=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./LEPJUN3X.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md":()=>import("./W2IHPJ54.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_cypher_query_prompt.md":()=>import("./ZMSJQB65.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md":()=>import("./5ZZGKP7N.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md":()=>import("./3AXQTBIA.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./ZS2TZ6BF.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./LQ6R5YRN.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./TNMXWUXU.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./T537PKP4.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./4I4MCV7V.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./FX7UOGHP.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./KTK4HNL2.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./6YMR4QSD.js").then(e=>e.default)});async function Z(e){let t=Object.entries(_e).find(([r])=>r.endsWith(`/${e}.md`));if(!t)throw new Error(`Prompt not found: ${e}
4
4
  Available prompts:
5
5
  ${Object.keys(_e).join(`
6
- `)}`);return await t[1]()}var mr=(e,t=300)=>{let r=e.replace(/\s+/gu," ").replace(/[*_`#>\-]/gu,"").trim();return r.length>t?`${r.slice(0,t)}...`:r},Ge=(e,t)=>{let r=e?.configurable?.services?.[t];if(r==null)throw new Error(`${t} missing in config.configurable.services`);return r},as=(e,t)=>(r,o)=>{let a=o?.configurable?.services;for(let n of e)if(!a?.[n])throw new Error(`${t} requires services.${n} to be available.`);return r};async function hr(e){let{fields:t,layer:r,view:o,styleName:a,colorSchemeTags:n}=e,l;return n?l=ut({basemapTheme:await Re(o),geometryType:r.geometryType,includedTags:n,numColors:Math.min(t.length,8)})[0]:l=dt({basemapTheme:await Re(o),geometryType:r.geometryType,numColors:Math.min(t.length,8)}).primaryScheme,{layer:r,view:o,attributes:t.map(i=>({field:i,label:r.fields.find(u=>u.name===i)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:a.includes("Size"),pieChartScheme:l}}async function fr(e){return await ct(e)}async function yr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,includeSize:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:n?"chart-size":"chart",fields:o,layer:i,view:l,colorSchemeTags:a};try{let c=await hr(u),d=await fr(c);return i.renderer=d.renderer,i.visible=!0,`Chart renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying chart renderer: ${c instanceof Error?c.message:String(c)}`}}var gr=["mapView"];function I(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("LayerStylingAgent context missing");let r=gr.filter(o=>!(o in t));if(r.length)throw new Error(`LayerStylingAgent context missing: ${r.join(", ")}`);return t}async function wr({layerId:e,fields:t,colorSchemes:r,includeSize:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await yr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,includeSize:o})}var br=s.object({layerId:s.string().describe("The id of the layer to apply the chart renderer to"),fields:s.array(s.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),includeSize:s.boolean().optional().describe("Whether to vary the chart size (chart-size)")}),ns=y(wr,{name:"chart",description:`Label: Charts
6
+ `)}`);return await t[1]()}var mr=(e,t=300)=>{let r=e.replace(/\s+/gu," ").replace(/[*_`#>\-]/gu,"").trim();return r.length>t?`${r.slice(0,t)}...`:r},Ge=(e,t)=>{let r=e?.configurable?.services?.[t];if(r==null)throw new Error(`${t} missing in config.configurable.services`);return r},as=(e,t)=>(r,o)=>{let a=o?.configurable?.services;for(let n of e)if(!a?.[n])throw new Error(`${t} requires services.${n} to be available.`);return r};async function hr(e){let{fields:t,layer:r,view:o,styleName:a,colorSchemeTags:n}=e,s;return n?s=ut({basemapTheme:await Ce(o),geometryType:r.geometryType,includedTags:n,numColors:Math.min(t.length,8)})[0]:s=dt({basemapTheme:await Ce(o),geometryType:r.geometryType,numColors:Math.min(t.length,8)}).primaryScheme,{layer:r,view:o,attributes:t.map(i=>({field:i,label:r.fields.find(u=>u.name===i)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:a.includes("Size"),pieChartScheme:s}}async function fr(e){return await ct(e)}async function yr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,includeSize:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:n?"chart-size":"chart",fields:o,layer:i,view:s,colorSchemeTags:a};try{let c=await hr(u),d=await fr(c);return i.renderer=d.renderer,i.visible=!0,`Chart renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying chart renderer: ${c instanceof Error?c.message:String(c)}`}}var gr=["mapView"];function I(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("LayerStylingAgent context missing");let r=gr.filter(o=>!(o in t));if(r.length)throw new Error(`LayerStylingAgent context missing: ${r.join(", ")}`);return t}async function wr({layerId:e,fields:t,colorSchemes:r,includeSize:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await yr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,includeSize:o})}var br=l.object({layerId:l.string().describe("The id of the layer to apply the chart renderer to"),fields:l.array(l.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),includeSize:l.boolean().optional().describe("Whether to vary the chart size (chart-size)")}),ns=y(wr,{name:"chart",description:`Label: Charts
7
7
  Description: Show the values of two or more categories as a proportion of the total using a pie chart.
8
8
  Keywords: pie, chart, all categories, breakdown, proportion
9
9
  Example: Show the total number of homes built in each decade using a pie chart for each feature.
@@ -13,19 +13,19 @@ ${Object.keys(_e).join(`
13
13
  Description: Show the values of two or more categories as a proportion of the total using a pie chart and use size to capture the total amount or magnitude.
14
14
  Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
15
15
  Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
16
- Fields: This style requires 2-8 number fields.`,schema:br});function vr(e){let{fields:t,layer:r,view:o,theme:a,colorSchemeTags:n}=e,l=t[0],i;return n&&(i=ge({geometryType:r.geometryType,includedTags:n,theme:a||"high-to-low"})[0]),{layer:r,view:o,startTime:l,endTime:new Date,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:i}}async function Tr(e){return await pt(e)}async function Sr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"color-age",fields:o,layer:i,view:l,colorSchemeTags:a,theme:n};try{let c=vr(u),d=await Tr(c);return i.renderer=d.renderer,i.visible=!0,`Color-age renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying color-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function xr({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await Sr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var Er=s.object({layerId:s.string().describe("The id of the layer to apply the color-age renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),is=y(xr,{name:"color-age",description:`Label: Age (color)
16
+ Fields: This style requires 2-8 number fields.`,schema:br});function vr(e){let{fields:t,layer:r,view:o,theme:a,colorSchemeTags:n}=e,s=t[0],i;return n&&(i=ge({geometryType:r.geometryType,includedTags:n,theme:a||"high-to-low"})[0]),{layer:r,view:o,startTime:s,endTime:new Date,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:i}}async function Tr(e){return await pt(e)}async function Sr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"color-age",fields:o,layer:i,view:s,colorSchemeTags:a,theme:n};try{let c=vr(u),d=await Tr(c);return i.renderer=d.renderer,i.visible=!0,`Color-age renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying color-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function xr({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await Sr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var Er=l.object({layerId:l.string().describe("The id of the layer to apply the color-age renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),theme:l.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),is=y(xr,{name:"color-age",description:`Label: Age (color)
17
17
  Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
18
18
  Keywords: since, age, how old, how long
19
19
  Example: Show the age of each feature based on its reported date.
20
- Fields: This style requires at least one field with a date type.`,schema:Er});function Ir(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,{theme:n}=e,l=t[1],i=t[0],u;return a&&(u=ge({geometryType:r.geometryType,includedTags:a,theme:n||"high-to-low"})[0]),{layer:r,view:o,field:i,normalizationField:l,theme:n,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:u}}async function Nr(e){return await mt(e)}async function kr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"color",fields:o,layer:i,view:l,colorSchemeTags:a,theme:n};try{let c=Ir(u),d=await Nr(c);return i.renderer=d.renderer,i.visible=!0,`Color renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying color renderer: ${c instanceof Error?c.message:String(c)}`}}async function $r({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await kr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var Fr=s.object({layerId:s.string().describe("The id of the layer to apply the color renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the color renderer"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),ss=y($r,{name:"color",description:`Label: Counts and Amounts (color)
20
+ Fields: This style requires at least one field with a date type.`,schema:Er});function Ir(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,{theme:n}=e,s=t[1],i=t[0],u;return a&&(u=ge({geometryType:r.geometryType,includedTags:a,theme:n||"high-to-low"})[0]),{layer:r,view:o,field:i,normalizationField:s,theme:n,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:u}}async function Nr(e){return await mt(e)}async function kr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"color",fields:o,layer:i,view:s,colorSchemeTags:a,theme:n};try{let c=Ir(u),d=await Nr(c);return i.renderer=d.renderer,i.visible=!0,`Color renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying color renderer: ${c instanceof Error?c.message:String(c)}`}}async function $r({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await kr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var Fr=l.object({layerId:l.string().describe("The id of the layer to apply the color renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the color renderer"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),theme:l.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),ss=y($r,{name:"color",description:`Label: Counts and Amounts (color)
21
21
  Description: Vary color along a continuous color ramp to represent numeric or ranked data.
22
22
  Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
23
23
  Example: Color each feature based on the population density.
24
- Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,schema:Fr});function Mr(e){let{fields:t,layer:r,view:o,colorSchemeTags:a,theme:n}=e,l,i,u=t[0];return a&&(i=ge({geometryType:r.geometryType,includedTags:a,theme:n||"high-to-low"})[0]),{layer:r,view:o,field:u,normalizationField:l,theme:n,colorOptions:{colorScheme:i}}}async function Ar(e){return await ht(e)}async function Rr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"color-size-univariate",fields:o,layer:i,view:l,colorSchemeTags:a,theme:n};try{let c=Mr(u),d=await Ar(c);return i.renderer=d.renderer,i.visible=!0,`Color-size-univariate renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying color-size-univariate renderer: ${c instanceof Error?c.message:String(c)}`}}async function qr({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await Rr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var Cr=s.object({layerId:s.string().describe("The id of the layer to apply the color-size univariate renderer to"),fields:s.array(s.string()).describe("The fields to use for the color-size univariate renderer"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color and size ramps")}),ls=y(qr,{name:"color-size-univariate",description:`Label: Color and Size (univariate)
24
+ Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,schema:Fr});function Mr(e){let{fields:t,layer:r,view:o,colorSchemeTags:a,theme:n}=e,s,i,u=t[0];return a&&(i=ge({geometryType:r.geometryType,includedTags:a,theme:n||"high-to-low"})[0]),{layer:r,view:o,field:u,normalizationField:s,theme:n,colorOptions:{colorScheme:i}}}async function Ar(e){return await ht(e)}async function Cr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"color-size-univariate",fields:o,layer:i,view:s,colorSchemeTags:a,theme:n};try{let c=Mr(u),d=await Ar(c);return i.renderer=d.renderer,i.visible=!0,`Color-size-univariate renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying color-size-univariate renderer: ${c instanceof Error?c.message:String(c)}`}}async function Rr({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await Cr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var qr=l.object({layerId:l.string().describe("The id of the layer to apply the color-size univariate renderer to"),fields:l.array(l.string()).describe("The fields to use for the color-size univariate renderer"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),theme:l.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color and size ramps")}),ls=y(Rr,{name:"color-size-univariate",description:`Label: Color and Size (univariate)
25
25
  Description: Vary symbol size and color based on the values of two numeric attributes.
26
26
  Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
27
27
  Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
28
- Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,schema:Cr});function _r(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n;return a&&(n=yt({includedTags:a,numColors:Math.min(t.length,8)})[0]),{layer:r,view:o,legendOptions:{unit:"units"},attributes:t.map(l=>({field:l,label:r.fields.find(i=>i.name===l)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,dotDensityScheme:n}}async function zr(e){return await ft(e)}async function jr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let n=t,l=e?.allLayers.find(u=>u.id===r);if(!l)return`Could not find layer for id: ${r}`;let i={styleName:"dot-density",fields:o,layer:l,view:n,colorSchemeTags:a};try{let u=_r(i),c=await zr(u);return l.renderer=c.renderer,l.visible=!0,`Dot Density renderer applied to layer: ${l.title??l.id} using fields ${o.join(", ")}`}catch(u){return`Error applying dot density renderer: ${u instanceof Error?u.message:String(u)}`}}async function Dr({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=I(o);return await x({type:"show-legend",data:{layerIds:[e]}},o),await jr({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var Lr=s.object({layerId:s.string().describe("The id of the layer to apply the dot density renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),cs=y(Dr,{name:"dot-density",description:`Dot Density
28
+ Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,schema:qr});function _r(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n;return a&&(n=yt({includedTags:a,numColors:Math.min(t.length,8)})[0]),{layer:r,view:o,legendOptions:{unit:"units"},attributes:t.map(s=>({field:s,label:r.fields.find(i=>i.name===s)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,dotDensityScheme:n}}async function zr(e){return await ft(e)}async function jr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let n=t,s=e?.allLayers.find(u=>u.id===r);if(!s)return`Could not find layer for id: ${r}`;let i={styleName:"dot-density",fields:o,layer:s,view:n,colorSchemeTags:a};try{let u=_r(i),c=await zr(u);return s.renderer=c.renderer,s.visible=!0,`Dot Density renderer applied to layer: ${s.title??s.id} using fields ${o.join(", ")}`}catch(u){return`Error applying dot density renderer: ${u instanceof Error?u.message:String(u)}`}}async function Dr({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=I(o);return await x({type:"show-legend",data:{layerIds:[e]}},o),await jr({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var Lr=l.object({layerId:l.string().describe("The id of the layer to apply the dot density renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use")}),cs=y(Dr,{name:"dot-density",description:`Dot Density
29
29
  Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
30
30
  **Use cases:**
31
31
  - Population distribution visualization
@@ -36,11 +36,11 @@ ${Object.keys(_e).join(`
36
36
  - Visualize distribution of different crops across regions
37
37
  - Display demographic patterns within census tracts
38
38
  **Fields:** Requires 2-8 number fields.
39
- **Keywords:** density, how much, how many, total, number, amount`,schema:Lr});function Or(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n,l=t[0];return a&&(n=wt({includedTags:a,basemap:o.map?.basemap||"topo"})[0]),{layer:r,view:o,field:l,heatmapScheme:n}}async function Pr(e){return await gt(e)}async function Gr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let n=t,l=e?.allLayers.find(u=>u.id===r);if(!l)return`Could not find layer for id: ${r}`;let i={styleName:"heatmap",fields:o,layer:l,view:n,colorSchemeTags:a};try{let u=Or(i),c=await Pr(u);return l.renderer=c.renderer,l.visible=!0,`Heatmap renderer applied to layer: ${l.title??l.id} using fields ${o.join(", ")}`}catch(u){return`Error applying heatmap renderer: ${u instanceof Error?u.message:String(u)}`}}async function Vr({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=I(o);return await x({type:"show-legend",data:{layerIds:[e]}},o),await Gr({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var Qr=s.object({layerId:s.string().describe("The id of the layer to apply the heatmap renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),us=y(Vr,{name:"heatmap",description:`Label: Heat Map
39
+ **Keywords:** density, how much, how many, total, number, amount`,schema:Lr});function Or(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n,s=t[0];return a&&(n=wt({includedTags:a,basemap:o.map?.basemap||"topo"})[0]),{layer:r,view:o,field:s,heatmapScheme:n}}async function Pr(e){return await gt(e)}async function Gr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let n=t,s=e?.allLayers.find(u=>u.id===r);if(!s)return`Could not find layer for id: ${r}`;let i={styleName:"heatmap",fields:o,layer:s,view:n,colorSchemeTags:a};try{let u=Or(i),c=await Pr(u);return s.renderer=c.renderer,s.visible=!0,`Heatmap renderer applied to layer: ${s.title??s.id} using fields ${o.join(", ")}`}catch(u){return`Error applying heatmap renderer: ${u instanceof Error?u.message:String(u)}`}}async function Vr({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=I(o);return await x({type:"show-legend",data:{layerIds:[e]}},o),await Gr({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var Qr=l.object({layerId:l.string().describe("The id of the layer to apply the heatmap renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use")}),us=y(Vr,{name:"heatmap",description:`Label: Heat Map
40
40
  Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
41
41
  Keywords: density, heatmap, hot spots, pattern, cluster
42
42
  Example: Create a heatmap
43
- Fields: This typically requires zero or one field of type number.`,schema:Qr});function Br(e){let{fields:t,layer:r,view:o,styleName:a,colorSchemeTags:n}=e,l;return n&&(l=vt({geometryType:r.geometryType,includedTags:n,numColors:Math.min(t.length,10)})[0]),{layer:r,view:o,fields:t.map(i=>({name:i})).slice(0,9),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:a.includes("Size"),predominanceScheme:l}}async function Ur(e){return await bt(e)}async function Kr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,includeSize:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:n?"predominance-size":"predominance",fields:o,layer:i,view:l,colorSchemeTags:a};try{let c=Br(u),d=await Ur(c);return i.renderer=d.renderer,i.visible=!0,`Predominance renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying predominance renderer: ${c instanceof Error?c.message:String(c)}`}}async function Wr({layerId:e,fields:t,colorSchemes:r,includeSize:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await Kr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,includeSize:o})}var Hr=s.object({layerId:s.string().describe("The id of the layer to apply the predominance renderer to"),fields:s.array(s.string()).describe("The fields to use for the predominance renderer (competing categories)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),includeSize:s.boolean().optional().describe("Whether to include size visualization (predominance-size)")}),ds=y(Wr,{name:"predominance",description:`Label: Predominant category
43
+ Fields: This typically requires zero or one field of type number.`,schema:Qr});function Br(e){let{fields:t,layer:r,view:o,styleName:a,colorSchemeTags:n}=e,s;return n&&(s=vt({geometryType:r.geometryType,includedTags:n,numColors:Math.min(t.length,10)})[0]),{layer:r,view:o,fields:t.map(i=>({name:i})).slice(0,9),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:a.includes("Size"),predominanceScheme:s}}async function Ur(e){return await bt(e)}async function Kr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,includeSize:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:n?"predominance-size":"predominance",fields:o,layer:i,view:s,colorSchemeTags:a};try{let c=Br(u),d=await Ur(c);return i.renderer=d.renderer,i.visible=!0,`Predominance renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying predominance renderer: ${c instanceof Error?c.message:String(c)}`}}async function Wr({layerId:e,fields:t,colorSchemes:r,includeSize:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await Kr({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,includeSize:o})}var Hr=l.object({layerId:l.string().describe("The id of the layer to apply the predominance renderer to"),fields:l.array(l.string()).describe("The fields to use for the predominance renderer (competing categories)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),includeSize:l.boolean().optional().describe("Whether to include size visualization (predominance-size)")}),ds=y(Wr,{name:"predominance",description:`Label: Predominant category
44
44
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
45
45
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top
46
46
  Example: Using fields for Corn Acres, Wheat Acres, and Cotton Acres, show the predominant crop harvested in each area.
@@ -50,15 +50,15 @@ Fields: This typically requires zero or one field of type number.`,schema:Qr});f
50
50
  Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value. Also varies the size of each symbol based on the total of all categories.
51
51
  Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
52
52
  Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
53
- Fields: This style relies on 2-10 number fields.`,schema:Hr});function Jr(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n,l={field:t[0]},i={field:t[1]};return a&&(n=St({geometryType:r.geometryType,includedTags:a})[0]),{layer:r,view:o,field1:l,field2:i,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,relationshipScheme:n}}async function Zr(e){return await Tt(e)}async function Yr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let n=t,l=e?.allLayers.find(u=>u.id===r);if(!l)return`Could not find layer for id: ${r}`;let i={styleName:"relationship",fields:o,layer:l,view:n,colorSchemeTags:a};try{let u=Jr(i),c=await Zr(u);return l.renderer=c.renderer,l.visible=!0,`Relationship renderer applied to layer: ${l.title??l.id} using fields ${o.join(", ")}`}catch(u){return`Error applying relationship renderer: ${u instanceof Error?u.message:String(u)}`}}async function Xr({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=I(o);return await x({type:"show-legend",data:{layerIds:[e]}},o),await Yr({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var eo=s.object({layerId:s.string().describe("The id of the layer to apply the relationship renderer to"),fields:s.array(s.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use")}),ps=y(Xr,{name:"relationship",description:`Label: Relationship
53
+ Fields: This style relies on 2-10 number fields.`,schema:Hr});function Jr(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n,s={field:t[0]},i={field:t[1]};return a&&(n=St({geometryType:r.geometryType,includedTags:a})[0]),{layer:r,view:o,field1:s,field2:i,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,relationshipScheme:n}}async function Zr(e){return await Tt(e)}async function Yr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let n=t,s=e?.allLayers.find(u=>u.id===r);if(!s)return`Could not find layer for id: ${r}`;let i={styleName:"relationship",fields:o,layer:s,view:n,colorSchemeTags:a};try{let u=Jr(i),c=await Zr(u);return s.renderer=c.renderer,s.visible=!0,`Relationship renderer applied to layer: ${s.title??s.id} using fields ${o.join(", ")}`}catch(u){return`Error applying relationship renderer: ${u instanceof Error?u.message:String(u)}`}}async function Xr({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=I(o);return await x({type:"show-legend",data:{layerIds:[e]}},o),await Yr({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var eo=l.object({layerId:l.string().describe("The id of the layer to apply the relationship renderer to"),fields:l.array(l.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use")}),ps=y(Xr,{name:"relationship",description:`Label: Relationship
54
54
  Description: Overlays two color ramps to represent the relationship between two numeric attributes.
55
55
  Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
56
56
  Example: Show the relationship between tree height and carbon storage
57
- Fields: This style requires two number fields.`,schema:eo});function to(e){let{fields:t,layer:r,view:o,theme:a}=e,n=t[0];return{layer:r,view:o,startTime:n,endTime:new Date,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function ro(e){return await xt(e)}async function oo({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"size-age",fields:o,layer:i,view:l,colorSchemeTags:a,theme:n};try{let c=to(u),d=await ro(c);return i.renderer=d.renderer,i.visible=!0,`Size-age renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying size-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function ao({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await oo({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var no=s.object({layerId:s.string().describe("The id of the layer to apply the size-age renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),ms=y(ao,{name:"size-age",description:`Label: Age (size)
57
+ Fields: This style requires two number fields.`,schema:eo});function to(e){let{fields:t,layer:r,view:o,theme:a}=e,n=t[0];return{layer:r,view:o,startTime:n,endTime:new Date,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function ro(e){return await xt(e)}async function oo({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"size-age",fields:o,layer:i,view:s,colorSchemeTags:a,theme:n};try{let c=to(u),d=await ro(c);return i.renderer=d.renderer,i.visible=!0,`Size-age renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying size-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function ao({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await oo({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var no=l.object({layerId:l.string().describe("The id of the layer to apply the size-age renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),theme:l.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),ms=y(ao,{name:"size-age",description:`Label: Age (size)
58
58
  Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
59
59
  Keywords: since, age, how old, how long
60
60
  Example: Change the size of features so older features are larger than new features.
61
- Fields: This style requires at least one field with a date type.`,schema:no});function io(e){let{fields:t,layer:r,view:o}=e,{theme:a}=e,n=t[1],l=t[0];return{layer:r,view:o,field:l,normalizationField:n,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function so(e){return await Et(e)}async function lo({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"size",fields:o,layer:i,view:l,colorSchemeTags:a,theme:n};try{let c=io(u),d=await so(c);return i.renderer=d.renderer,i.visible=!0,`Size renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying size renderer: ${c instanceof Error?c.message:String(c)}`}}async function co({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await lo({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var uo=s.object({layerId:s.string().describe("The id of the layer to apply the size renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the size renderer (numeric data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),hs=y(co,{name:"size",description:`Label: Counts and Amounts (size)
61
+ Fields: This style requires at least one field with a date type.`,schema:no});function io(e){let{fields:t,layer:r,view:o}=e,{theme:a}=e,n=t[1],s=t[0];return{layer:r,view:o,field:s,normalizationField:n,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function so(e){return await Et(e)}async function lo({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"size",fields:o,layer:i,view:s,colorSchemeTags:a,theme:n};try{let c=io(u),d=await so(c);return i.renderer=d.renderer,i.visible=!0,`Size renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying size renderer: ${c instanceof Error?c.message:String(c)}`}}async function co({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await lo({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var uo=l.object({layerId:l.string().describe("The id of the layer to apply the size renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the size renderer (numeric data)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),theme:l.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),hs=y(co,{name:"size",description:`Label: Counts and Amounts (size)
62
62
  Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
63
63
  Keywords: graduated size, proportional size, how much, total, number, amount, size
64
64
  Example: Vary the size of each point based on the total population.
@@ -68,11 +68,11 @@ Fields: This typically requires zero or one field of type number.`,schema:Qr});f
68
68
  Description: Vary symbol sizes along a continuous ramp to represent dates.
69
69
  Keywords: graduated size, proportional size, classed size, how much, total, number, when
70
70
  Example: Vary the size of each feature based on the date a ticket was completed.
71
- Fields: This style requires a single field with a date type.`,schema:uo});function po(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n=t[0],l=t[1],i=t[2],u;return a&&(u=Nt({geometryType:r.geometryType,includedTags:a})[0]),{layer:r,view:o,field:n,field2:l,field3:i,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,typeScheme:u}}async function mo(e){return await It(e)}async function ho({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let l=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"type",fields:o,layer:i,view:l,colorSchemeTags:a,theme:n};try{let c=po(u),d=await mo(c);return i.renderer=d.renderer,i.visible=!0,`Type renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying type renderer: ${c instanceof Error?c.message:String(c)}`}}async function fo({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await ho({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var yo=s.object({layerId:s.string().describe("The id of the layer to apply the type renderer to"),fields:s.array(s.string()).describe("The field(s) to use for the type renderer (categorical data)"),colorSchemes:s.array(s.string()).optional().describe("Optional color scheme tags to use"),theme:s.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color scheme")}),fs=y(fo,{name:"type",description:`Label: Types (unique symbols)
71
+ Fields: This style requires a single field with a date type.`,schema:uo});function po(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,n=t[0],s=t[1],i=t[2],u;return a&&(u=Nt({geometryType:r.geometryType,includedTags:a})[0]),{layer:r,view:o,field:n,field2:s,field3:i,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,typeScheme:u}}async function mo(e){return await It(e)}async function ho({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:n}){let s=t,i=e?.allLayers.find(c=>c.id===r);if(!i)return`Could not find layer for id: ${r}`;let u={styleName:"type",fields:o,layer:i,view:s,colorSchemeTags:a,theme:n};try{let c=po(u),d=await mo(c);return i.renderer=d.renderer,i.visible=!0,`Type renderer applied to layer: ${i.title??i.id} using fields ${o.join(", ")}`}catch(c){return`Error applying type renderer: ${c instanceof Error?c.message:String(c)}`}}async function fo({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:n}=I(a);return await x({type:"show-legend",data:{layerIds:[e]}},a),await ho({arcgisMap:n.map,arcgisMapView:n,layerId:e,fields:t,colorSchemes:r,theme:o})}var yo=l.object({layerId:l.string().describe("The id of the layer to apply the type renderer to"),fields:l.array(l.string()).describe("The field(s) to use for the type renderer (categorical data)"),colorSchemes:l.array(l.string()).optional().describe("Optional color scheme tags to use"),theme:l.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color scheme")}),fs=y(fo,{name:"type",description:`Label: Types (unique symbols)
72
72
  Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
73
73
  Keywords: categorical, category, type, unique, discrete, point of interest, region, group
74
74
  Example: Color each feature based on the region it belongs to
75
- Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,schema:yo}),ys=b.Root({...L(),vectorSearchLayerIds:b(),vectorSearchFieldResults:b(),layerFieldInfo:b(),selectedLayerId:b()}),gs=b.Root({...L(),vectorSearchLayerIds:b(),vectorSearchFieldResults:b(),layerFieldInfo:b(),queryResponse:b(),dataExplorationMessages:b({reducer:D,default:()=>[]})}),go=["mapView"];function M(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("DataExplorationAgent context missing");let r=go.filter(o=>!(o in t));if(r.length)throw new Error(`DataExplorationAgent context missing: ${r.join(", ")}`);return t}var wo=e=>{let t=e.map?.allLayers.filter(o=>o.type==="feature"),r=0;return t?.forEach(o=>{let a=o;a.featureEffect&&(a.featureEffect=null,r++)}),r>0?`Cleared filters from ${r} layer(s). View unchanged.`:"No active filters to clear. View unchanged."},bo=async(e,t)=>{let{mapView:r}=M(t);return wo(r)},vo=y(bo,{name:"clearFilters",description:"Clears all feature effects/filters from the map but does NOT change the current view. Use when user says 'clear filters', 'reset filters', 'remove filters', 'show all features', or wants to remove emphasis without navigating anywhere.",schema:s.object({})}),To=async e=>{e.map?.allLayers.filter(r=>r.type==="feature")?.forEach(r=>{let o=r;o.featureEffect&&(o.featureEffect=null)});let t=e.map.initialViewProperties?.viewpoint?.targetGeometry;return t?(await e.goTo(t),"Cleared all filters and returned to home extent."):"Cleared all filters. Could not determine home extent."},So=async(e,t)=>{let{mapView:r}=M(t);return await To(r)},xo=y(So,{name:"resetMap",description:"Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",schema:s.object({})}),ze=750;function Y(e){return"point"in e&&e.point!==void 0}function P(e){return"layerId"in e&&e.layerId!==void 0}var ee=async(e,t)=>{if(Y(e)){let{point:r}=e;return{geometry:new De({x:r.x,y:r.y,spatialReference:r.spatialReference?{wkid:r.spatialReference.wkid}:t.spatialReference})}}if(P(e)){let r=t.map?.allLayers.find(n=>n.id===e.layerId);if(!r)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let o=r.title??r.id,a=e.where?.trim()||"1=1";try{let n=await r.queryFeatures({where:a,returnGeometry:!0,outSpatialReference:t.spatialReference,num:ze+1});if(!n.features.length)return{error:`No features found in geometry layer "${o}" with the specified where clause: ${a}`};if(n.features.length>ze)return{error:`Geometry filter for layer "${o}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`};let l=n.features.map(u=>u.geometry).filter(u=>!!u);if(!l.length)return{error:"No valid geometries found for the matched geometry layer features."};let i=l.length===1?l[0]:Oe.executeMany(l);return i?(i.spatialReference||(i.spatialReference=t.spatialReference),{geometry:i}):{error:"Failed to combine geometries from geometry layer."}}catch(n){return{error:`Failed to query geometry: ${String(n)}`}}}return{error:"Invalid geometry configuration provided"}},Eo=async(e,t,r,o,a,n)=>{let l=e.map?.allLayers.find(u=>u.id===t);if(!l)return{success:!1,error:`Layer '${t}' not found.`};let i=l.createQuery();i.where=r??"1=1",o&&(i.geometry=o,i.spatialRelationship="intersects",a&&(i.distance=a),n&&(i.units=n));try{let{extent:u,count:c}=await l.queryExtent(i);return!u||c===0?{success:!1,error:`No features found for filter (where: ${i.where}${o?", spatial filter used":""})`}:(await e.goTo(u),{success:!0})}catch(u){return{success:!1,error:u instanceof Error?u.message:String(u)}}},Io=async(e,t,r,o,a,n)=>{let l=t.map?.allLayers.find(m=>m.id===e.layerId);if(!l)return`Could not find target layer with ID: ${e.layerId}`;let i;if(a){let m=await ee(a,t);if("error"in m)return m.error;i=m.geometry}if(l.featureEffect=null,l.featureEffect=new kt({filter:new Le({...e.objectIds?.length?{objectIds:e.objectIds}:{where:e.where},geometry:i,spatialRelationship:"intersects",distance:a?.distance,units:a?.units}),includedEffect:r,excludedEffect:o}),l.visible=!0,n)return`Applied feature effects to "${l.title??e.layerId}" within current map extent.`;let u=e.objectIds?.length?`${l.objectIdField} IN (${e.objectIds.join(",")})`:e.where,c=await Eo(t,e.layerId,u,i,a?.distance,a?.units),d=l.title??e.layerId;return c.success?`Applied feature effects to target layer "${l.title??e.layerId}"${a&&"layerId"in a?` using geometry from layer "${a.layerId}"`:""}.`:`Applied filter to "${d}" but no features matched. ${c.error}`},No=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],$=s.enum(No),ko=async({targetLayer:e,geometryFilter:t,useCurrentExtent:r,includedEffect:o="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},n)=>{let{mapView:l}=M(n);return await Io(e,l,o,a,t,r)},$o=s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:s.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),Fo=s.object({point:s.object({x:s.number().describe("X coordinate (longitude) from navigation result"),y:s.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:s.object({wkid:s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:s.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),Mo=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer on which to set a feature effect."),where:s.string().describe("The SQL-92 where clause representing the features to emphasize."),objectIds:s.array(s.number()).optional().describe("Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause.")}),geometryFilter:s.union([$o,Fo]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),useCurrentExtent:s.boolean().optional().describe("Set to true when the previous query used the current map extent as a spatial filter. This ensures the feature effect applies only to features visible in the current view. Default is false."),includedEffect:s.string().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:s.string().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),Ao=y(ko,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Mo}),Ro=new Set(["date","esrifieldtypedate","date-only","dateonly","esrifieldtypedateonly","time-only","timeonly","esrifieldtypetimeonly","timestamp-offset","timestampoffset","esrifieldtypetimestampoffset"]),Ve=e=>{if(!e)return!1;let t=e.toLowerCase();return Ro.has(t)},le=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="number"&&Number.isFinite(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}return null},qo=e=>!e||e==="system"?Intl.DateTimeFormat().resolvedOptions().timeZone:e==="unknown"?"UTC":e,Co=e=>{if(typeof e=="string"&&e)return e;let t=le(e);return t?t.toISOString().slice(0,10):null},ws=()=>{let e=new Date().getTimezoneOffset(),t=e<=0?"+":"-",r=Math.floor(Math.abs(e)/60).toString().padStart(2,"0"),o=(Math.abs(e)%60).toString().padStart(2,"0"),a=`${t}${r}:${o}`;return{userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,userTimezoneOffset:a}},_o=(e,t,r)=>{let o=t?.toLowerCase();if(o&&!Ve(o))return e;if(o==="date-only"){let n=Co(e);return n?$t(n,W("short-date")):e}if(o==="time-only"){if(typeof e=="string"&&e)return Ft(e,W("long-time"));let n=le(e);return n?qe(n,{...W("long-time"),timeZone:"UTC"}):e}let a=le(e);return a?qe(a,{...W("short-date-short-time"),timeZone:qo(r)}):e},Qe=(e,t,r)=>{if(e&&typeof e!="function"){let o="getField"in r&&r.getField?.(e),a=o&&"getFieldDomain"in r&&r.getFieldDomain?r.getFieldDomain(o.name):null;if(a?.type==="coded-value"){let n=a.codedValues.find(l=>l.code===t);return n?n.name:null}}return null},zo=e=>!e||e==="system"?Intl.DateTimeFormat().resolvedOptions().timeZone:e==="unknown"?"UTC":e,jo=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="number"&&Number.isFinite(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}if(typeof e=="string"&&e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}return null},Do=(e,t)=>{if(typeof e!="number")return e;let r={};t.minimumFractionDigits!==void 0&&(r.minimumFractionDigits=t.minimumFractionDigits),t.maximumFractionDigits!==void 0&&(r.maximumFractionDigits=t.maximumFractionDigits),t.useGrouping==="always"?r.useGrouping=!0:t.useGrouping==="never"&&(r.useGrouping=!1);try{return new Intl.NumberFormat(void 0,r).format(e)}catch{return e}},Lo=(e,t,r)=>{let o=jo(e);if(!o)return e;let a={};t.dateStyle?a.dateStyle=t.dateStyle:(t.year&&(a.year=t.year),t.month&&(a.month=t.month)),t.timeStyle&&(a.timeStyle=t.timeStyle),t.timeStyle&&t.hour12==="always"?a.hour12=!0:t.timeStyle&&t.hour12==="never"&&(a.hour12=!1),a.timeZone=zo(r);try{return new Intl.DateTimeFormat(void 0,a).format(o)}catch{return e}},Be=(e,t)=>e.getFieldAlias?.(t)??e.fieldsIndex?.get(t)?.alias??e.fieldsIndex?.get(t)?.name??t,Ue=(e,t,r,o,a)=>{if(r==null)return r;let n=e.getFieldConfiguration?.(t)?.fieldFormat;return n?.type==="number"?Do(r,n):n?.type==="date-time"?!o||Ve(o)?Lo(r,n,a):r:_o(r,o,a)},Oo=(e,t,r,o)=>{let a=e.fieldsIndex?.get(t),n=Qe(t,r,e)??r;return Ue(e,t,n,a?.type,o)},Po=(e,t)=>Be(e,t),Ke=(e,t,r)=>{let o=e.objectIdField,a=t.features.map(l=>l.attributes[o]),n=t.features.map(l=>{let i=l.attributes,u={};return e.fields.forEach(c=>{if(!Object.hasOwn(i,c.name))return;let d=i[c.name];if(c.name===o){u[c.name]=d;return}let m=Qe(c.name,d,e)??d,p=Be(e,c.name);u[p]=Ue(e,c.name,m,c.type,r)}),u});return{objectIds:a,attributes:n}},Go=(e,t,r)=>{let o=e.createQuery();return o.outFields=[t],o.where=r||"1=1",o.num=1,o},Vo=async(e,t,r,o)=>{let a=o.map?.allLayers.find(d=>d.id===e),n=Go(a,t,r.where),l=(await a.queryFeatures(n)).features[0],i=l?l.attributes[t]:null,u=Oo(a,t,i,o.timeZone),c=Po(a,t);return{tool:"getAttribute",layerName:a.title??e,summary:`${c} = ${u}`,details:{fieldName:t,fieldAlias:c!==t?c:void 0,value:u,where:r.where}}};async function Qo({layerId:e,fieldName:t,query:r},o){let{mapView:a}=M(o),n=await Vo(e,t,r,a);return JSON.stringify(n,null,2)}var Bo=s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:s.string().describe("The name of the field/attribute from which to get a field value."),query:s.object({where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),Uo=y(Qo,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Bo}),we=(e,t,r)=>{if(!(r?e.hasAllFeaturesInView:e.hasAllFeatures))return!1;let o=new Set((e.availableFields??[]).map(a=>a.toLowerCase()));return o.has("*")?!0:t.every(a=>o.has(a.toLowerCase()))};function X(e,t){let r=e??"";return t!=null&&t&&(r=r?`(${r}) AND (${t})`:t),r||null}var Ko=async e=>{let{targetLayer:t,fieldName:r,statisticType:o,mapView:a,layersAndFieldsRegistry:n,geometryFilter:l}=e,i=a.map?.allLayers.find(g=>g.id===t.layerId);if(!i)throw new Error(`Layer '${t.layerId}' not found.`);let u=await a.whenLayerView(i),c=n.get(t.layerId)?.fieldRegistry.get(r),d=c?.alias;if(!c)throw new Error(`Field '${r}' not found.`);let m,p;if(l){let g=await ee(l,a);if("error"in g)throw new Error(g.error);if(!g.geometry)throw P(l)?new Error(`No features found matching: ${l.where}`):new Error("Failed to create geometry");if(P(l)){let T=a.map?.allLayers.find(E=>E.id===l.layerId);m={geometryLayerName:T?.title??T?.id,geometryLayerId:l.layerId,geometryWhere:l.where,distance:l.distance,units:l.units,applied:!0}}else Y(l)&&(m={point:l.point,distance:l.distance,units:l.units,applied:!0});p=new Le({geometry:g.geometry,distance:l.distance,units:l.units,spatialRelationship:"intersects"})}let w=we(u,[r],!1),f=null,h=null,v=10;if(c.type!=="geometry"&&c.type!=="oid"&&c.type!=="global-id")try{let g={layer:i,useFeaturesInView:w,view:w?a:void 0,field:r,sqlWhere:X(i.definitionExpression,t.where),...p&&{filter:p},outStatisticTypes:{include:[o]}};f=await Mt(g);let T=["string","small-integer","integer"],E=c.domain?.type==="coded-value"?c.domain:null;(T.includes(c.type)||E)&&(h=(await At({layer:i,useFeaturesInView:w,view:w?a:void 0,field:r,sqlWhere:X(i.definitionExpression,t.where),...p&&{filter:p}})).uniqueValueInfos.sort((R,Xe)=>Xe.count-R.count).slice(0,v)),h&&c.domain?.type==="coded-value"&&(h=h.map(R=>({...R,value:E?E.getName(R.value)??R.value:R.value})))}catch(g){console.error("Statistics error:",g)}return{tool:"getStatistics",layerName:i.title??t.layerId,summary:`${o} = ${typeof f?.[o]=="number"?f[o]:"N/A"}`,details:{fieldName:r,fieldAlias:d,statisticType:o,statistic:f?.[o]??null,summaryStatistics:f,uniqueValues:h,where:t.where,spatialFilterInfo:m}}};async function Wo({targetLayer:e,fieldName:t,statisticType:r,geometryFilter:o},a){let n=Ge(a,"layersAndFieldsRegistry"),{mapView:l}=M(a),i=await Ko({targetLayer:e,fieldName:t,statisticType:r,mapView:l,layersAndFieldsRegistry:n,geometryFilter:o});return JSON.stringify(i,null,2)}var Ho=s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:s.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),Jo=s.object({point:s.object({x:s.number().describe("X coordinate (longitude) from navigation result"),y:s.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:s.object({wkid:s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:s.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),Zo=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryFilter:s.union([Ho,Jo]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),fieldName:s.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),statisticType:s.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),Yo=y(Wo,{name:"getStatistics",description:`Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
75
+ Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,schema:yo}),ys=b.Root({...L(),vectorSearchLayerIds:b(),vectorSearchFieldResults:b(),layerFieldInfo:b(),selectedLayerId:b()}),gs=b.Root({...L(),vectorSearchLayerIds:b(),vectorSearchFieldResults:b(),layerFieldInfo:b(),queryResponse:b(),dataExplorationMessages:b({reducer:D,default:()=>[]})}),go=["mapView"];function M(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("DataExplorationAgent context missing");let r=go.filter(o=>!(o in t));if(r.length)throw new Error(`DataExplorationAgent context missing: ${r.join(", ")}`);return t}var wo=e=>{let t=e.map?.allLayers.filter(o=>o.type==="feature"),r=0;return t?.forEach(o=>{let a=o;a.featureEffect&&(a.featureEffect=null,r++)}),r>0?`Cleared filters from ${r} layer(s). View unchanged.`:"No active filters to clear. View unchanged."},bo=async(e,t)=>{let{mapView:r}=M(t);return wo(r)},vo=y(bo,{name:"clearFilters",description:"Clears all feature effects/filters from the map but does NOT change the current view. Use when user says 'clear filters', 'reset filters', 'remove filters', 'show all features', or wants to remove emphasis without navigating anywhere.",schema:l.object({})}),To=async e=>{e.map?.allLayers.filter(r=>r.type==="feature")?.forEach(r=>{let o=r;o.featureEffect&&(o.featureEffect=null)});let t=e.map.initialViewProperties?.viewpoint?.targetGeometry;return t?(await e.goTo(t),"Cleared all filters and returned to home extent."):"Cleared all filters. Could not determine home extent."},So=async(e,t)=>{let{mapView:r}=M(t);return await To(r)},xo=y(So,{name:"resetMap",description:"Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",schema:l.object({})}),ze=750;function Y(e){return"point"in e&&e.point!==void 0}function P(e){return"layerId"in e&&e.layerId!==void 0}var ee=async(e,t)=>{if(Y(e)){let{point:r}=e;return{geometry:new De({x:r.x,y:r.y,spatialReference:r.spatialReference?{wkid:r.spatialReference.wkid}:t.spatialReference})}}if(P(e)){let r=t.map?.allLayers.find(n=>n.id===e.layerId);if(!r)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let o=r.title??r.id,a=e.where?.trim()||"1=1";try{let n=await r.queryFeatures({where:a,returnGeometry:!0,outSpatialReference:t.spatialReference,num:ze+1});if(!n.features.length)return{error:`No features found in geometry layer "${o}" with the specified where clause: ${a}`};if(n.features.length>ze)return{error:`Geometry filter for layer "${o}" matched too many features (${n.features.length}+). Please narrow the geometry layer filter.`};let s=n.features.map(u=>u.geometry).filter(u=>!!u);if(!s.length)return{error:"No valid geometries found for the matched geometry layer features."};let i=s.length===1?s[0]:Oe.executeMany(s);return i?(i.spatialReference||(i.spatialReference=t.spatialReference),{geometry:i}):{error:"Failed to combine geometries from geometry layer."}}catch(n){return{error:`Failed to query geometry: ${String(n)}`}}}return{error:"Invalid geometry configuration provided"}},Eo=async(e,t,r,o,a,n)=>{let s=e.map?.allLayers.find(u=>u.id===t);if(!s)return{success:!1,error:`Layer '${t}' not found.`};let i=s.createQuery();i.where=r??"1=1",o&&(i.geometry=o,i.spatialRelationship="intersects",a&&(i.distance=a),n&&(i.units=n));try{let{extent:u,count:c}=await s.queryExtent(i);return!u||c===0?{success:!1,error:`No features found for filter (where: ${i.where}${o?", spatial filter used":""})`}:(await e.goTo(u),{success:!0})}catch(u){return{success:!1,error:u instanceof Error?u.message:String(u)}}},Io=async(e,t,r,o,a,n)=>{let s=t.map?.allLayers.find(m=>m.id===e.layerId);if(!s)return`Could not find target layer with ID: ${e.layerId}`;let i;if(a){let m=await ee(a,t);if("error"in m)return m.error;i=m.geometry}if(s.featureEffect=null,s.featureEffect=new kt({filter:new Le({...e.objectIds?.length?{objectIds:e.objectIds}:{where:e.where},geometry:i,spatialRelationship:"intersects",distance:a?.distance,units:a?.units}),includedEffect:r,excludedEffect:o}),s.visible=!0,n)return`Applied feature effects to "${s.title??e.layerId}" within current map extent.`;let u=e.objectIds?.length?`${s.objectIdField} IN (${e.objectIds.join(",")})`:e.where,c=await Eo(t,e.layerId,u,i,a?.distance,a?.units),d=s.title??e.layerId;return c.success?`Applied feature effects to target layer "${s.title??e.layerId}"${a&&"layerId"in a?` using geometry from layer "${a.layerId}"`:""}.`:`Applied filter to "${d}" but no features matched. ${c.error}`},No=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],$=l.enum(No),ko=async({targetLayer:e,geometryFilter:t,useCurrentExtent:r,includedEffect:o="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},n)=>{let{mapView:s}=M(n);return await Io(e,s,o,a,t,r)},$o=l.object({layerId:l.string().describe("The layerId of the layer containing the geometry by which to filter."),where:l.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:l.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),Fo=l.object({point:l.object({x:l.number().describe("X coordinate (longitude) from navigation result"),y:l.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:l.object({wkid:l.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:l.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),Mo=l.object({targetLayer:l.object({layerId:l.string().describe("The layerId of the layer on which to set a feature effect."),where:l.string().describe("The SQL-92 where clause representing the features to emphasize."),objectIds:l.array(l.number()).optional().describe("Array of objectIds from a previous query result. Use this instead of a where clause when the query returned objectIds (e.g. top N results). If provided, takes precedence over where clause.")}),geometryFilter:l.union([$o,Fo]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),useCurrentExtent:l.boolean().optional().describe("Set to true when the previous query used the current map extent as a spatial filter. This ensures the feature effect applies only to features visible in the current view. Default is false."),includedEffect:l.string().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:l.string().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),Ao=y(ko,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Mo}),Co=new Set(["date","esrifieldtypedate","date-only","dateonly","esrifieldtypedateonly","time-only","timeonly","esrifieldtypetimeonly","timestamp-offset","timestampoffset","esrifieldtypetimestampoffset"]),Ve=e=>{if(!e)return!1;let t=e.toLowerCase();return Co.has(t)},le=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="number"&&Number.isFinite(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}return null},Ro=e=>!e||e==="system"?Intl.DateTimeFormat().resolvedOptions().timeZone:e==="unknown"?"UTC":e,qo=e=>{if(typeof e=="string"&&e)return e;let t=le(e);return t?t.toISOString().slice(0,10):null},ws=()=>{let e=new Date().getTimezoneOffset(),t=e<=0?"+":"-",r=Math.floor(Math.abs(e)/60).toString().padStart(2,"0"),o=(Math.abs(e)%60).toString().padStart(2,"0"),a=`${t}${r}:${o}`;return{userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,userTimezoneOffset:a}},_o=(e,t,r)=>{let o=t?.toLowerCase();if(o&&!Ve(o))return e;if(o==="date-only"){let n=qo(e);return n?$t(n,W("short-date")):e}if(o==="time-only"){if(typeof e=="string"&&e)return Ft(e,W("long-time"));let n=le(e);return n?Re(n,{...W("long-time"),timeZone:"UTC"}):e}let a=le(e);return a?Re(a,{...W("short-date-short-time"),timeZone:Ro(r)}):e},Qe=(e,t,r)=>{if(e&&typeof e!="function"){let o="getField"in r&&r.getField?.(e),a=o&&"getFieldDomain"in r&&r.getFieldDomain?r.getFieldDomain(o.name):null;if(a?.type==="coded-value"){let n=a.codedValues.find(s=>s.code===t);return n?n.name:null}}return null},zo=e=>!e||e==="system"?Intl.DateTimeFormat().resolvedOptions().timeZone:e==="unknown"?"UTC":e,jo=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="number"&&Number.isFinite(e)){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}if(typeof e=="string"&&e){let t=new Date(e);return Number.isNaN(t.getTime())?null:t}return null},Do=(e,t)=>{if(typeof e!="number")return e;let r={};t.minimumFractionDigits!==void 0&&(r.minimumFractionDigits=t.minimumFractionDigits),t.maximumFractionDigits!==void 0&&(r.maximumFractionDigits=t.maximumFractionDigits),t.useGrouping==="always"?r.useGrouping=!0:t.useGrouping==="never"&&(r.useGrouping=!1);try{return new Intl.NumberFormat(void 0,r).format(e)}catch{return e}},Lo=(e,t,r)=>{let o=jo(e);if(!o)return e;let a={};t.dateStyle?a.dateStyle=t.dateStyle:(t.year&&(a.year=t.year),t.month&&(a.month=t.month)),t.timeStyle&&(a.timeStyle=t.timeStyle),t.timeStyle&&t.hour12==="always"?a.hour12=!0:t.timeStyle&&t.hour12==="never"&&(a.hour12=!1),a.timeZone=zo(r);try{return new Intl.DateTimeFormat(void 0,a).format(o)}catch{return e}},Be=(e,t)=>e.getFieldAlias?.(t)??e.fieldsIndex?.get(t)?.alias??e.fieldsIndex?.get(t)?.name??t,Ue=(e,t,r,o,a)=>{if(r==null)return r;let n=e.getFieldConfiguration?.(t)?.fieldFormat;return n?.type==="number"?Do(r,n):n?.type==="date-time"?!o||Ve(o)?Lo(r,n,a):r:_o(r,o,a)},Oo=(e,t,r,o)=>{let a=e.fieldsIndex?.get(t),n=Qe(t,r,e)??r;return Ue(e,t,n,a?.type,o)},Po=(e,t)=>Be(e,t),Ke=(e,t,r)=>{let o=e.objectIdField,a=t.features.map(s=>s.attributes[o]),n=t.features.map(s=>{let i=s.attributes,u={};return e.fields.forEach(c=>{if(!Object.hasOwn(i,c.name))return;let d=i[c.name];if(c.name===o){u[c.name]=d;return}let m=Qe(c.name,d,e)??d,p=Be(e,c.name);u[p]=Ue(e,c.name,m,c.type,r)}),u});return{objectIds:a,attributes:n}},Go=(e,t,r)=>{let o=e.createQuery();return o.outFields=[t],o.where=r||"1=1",o.num=1,o},Vo=async(e,t,r,o)=>{let a=o.map?.allLayers.find(d=>d.id===e),n=Go(a,t,r.where),s=(await a.queryFeatures(n)).features[0],i=s?s.attributes[t]:null,u=Oo(a,t,i,o.timeZone),c=Po(a,t);return{tool:"getAttribute",layerName:a.title??e,summary:`${c} = ${u}`,details:{fieldName:t,fieldAlias:c!==t?c:void 0,value:u,where:r.where}}};async function Qo({layerId:e,fieldName:t,query:r},o){let{mapView:a}=M(o),n=await Vo(e,t,r,a);return JSON.stringify(n,null,2)}var Bo=l.object({layerId:l.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:l.string().describe("The name of the field/attribute from which to get a field value."),query:l.object({where:l.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),Uo=y(Qo,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Bo}),we=(e,t,r)=>{if(!(r?e.hasAllFeaturesInView:e.hasAllFeatures))return!1;let o=new Set((e.availableFields??[]).map(a=>a.toLowerCase()));return o.has("*")?!0:t.every(a=>o.has(a.toLowerCase()))};function X(e,t){let r=e??"";return t!=null&&t&&(r=r?`(${r}) AND (${t})`:t),r||null}var Ko=async e=>{let{targetLayer:t,fieldName:r,statisticType:o,mapView:a,layersAndFieldsRegistry:n,geometryFilter:s}=e,i=a.map?.allLayers.find(g=>g.id===t.layerId);if(!i)throw new Error(`Layer '${t.layerId}' not found.`);let u=await a.whenLayerView(i),c=n.get(t.layerId)?.fieldRegistry.get(r),d=c?.alias;if(!c)throw new Error(`Field '${r}' not found.`);let m,p;if(s){let g=await ee(s,a);if("error"in g)throw new Error(g.error);if(!g.geometry)throw P(s)?new Error(`No features found matching: ${s.where}`):new Error("Failed to create geometry");if(P(s)){let T=a.map?.allLayers.find(E=>E.id===s.layerId);m={geometryLayerName:T?.title??T?.id,geometryLayerId:s.layerId,geometryWhere:s.where,distance:s.distance,units:s.units,applied:!0}}else Y(s)&&(m={point:s.point,distance:s.distance,units:s.units,applied:!0});p=new Le({geometry:g.geometry,distance:s.distance,units:s.units,spatialRelationship:"intersects"})}let w=we(u,[r],!1),f=null,h=null,v=10;if(c.type!=="geometry"&&c.type!=="oid"&&c.type!=="global-id")try{let g={layer:i,useFeaturesInView:w,view:w?a:void 0,field:r,sqlWhere:X(i.definitionExpression,t.where),...p&&{filter:p},outStatisticTypes:{include:[o]}};f=await Mt(g);let T=["string","small-integer","integer"],E=c.domain?.type==="coded-value"?c.domain:null;(T.includes(c.type)||E)&&(h=(await At({layer:i,useFeaturesInView:w,view:w?a:void 0,field:r,sqlWhere:X(i.definitionExpression,t.where),...p&&{filter:p}})).uniqueValueInfos.sort((C,Xe)=>Xe.count-C.count).slice(0,v)),h&&c.domain?.type==="coded-value"&&(h=h.map(C=>({...C,value:E?E.getName(C.value)??C.value:C.value})))}catch(g){console.error("Statistics error:",g)}return{tool:"getStatistics",layerName:i.title??t.layerId,summary:`${o} = ${typeof f?.[o]=="number"?f[o]:"N/A"}`,details:{fieldName:r,fieldAlias:d,statisticType:o,statistic:f?.[o]??null,summaryStatistics:f,uniqueValues:h,where:t.where,spatialFilterInfo:m}}};async function Wo({targetLayer:e,fieldName:t,statisticType:r,geometryFilter:o},a){let n=Ge(a,"layersAndFieldsRegistry"),{mapView:s}=M(a),i=await Ko({targetLayer:e,fieldName:t,statisticType:r,mapView:s,layersAndFieldsRegistry:n,geometryFilter:o});return JSON.stringify(i,null,2)}var Ho=l.object({layerId:l.string().describe("The layerId of the layer containing the geometry by which to filter."),where:l.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:l.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),Jo=l.object({point:l.object({x:l.number().describe("X coordinate (longitude) from navigation result"),y:l.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:l.object({wkid:l.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:l.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),Zo=l.object({targetLayer:l.object({layerId:l.string().describe("The layerId of the layer containing the field from which to get a value."),where:l.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryFilter:l.union([Ho,Jo]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),fieldName:l.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),statisticType:l.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),Yo=y(Wo,{name:"getStatistics",description:`Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
76
76
 
77
77
  USE THIS TOOL FOR:
78
78
  - "What is the average/maximum/minimum/total [field]?" \u2014 aggregate computations
@@ -84,7 +84,7 @@ DO NOT USE FOR:
84
84
  - "Show / list / find features" \u2014 use queryFeatures instead
85
85
  - Simple counts of features matching a condition \u2014 use queryFeatures instead
86
86
 
87
- Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,schema:Zo}),Xo=e=>e.flatMap(t=>t.split(",")).map(t=>t.trim()).map(t=>t.split(/\s+/u)[0]?.replace(/^"|"$/gu,"")).filter(t=>!!t),ea=async(e,t,r,o,a)=>{let n=r.map?.allLayers.find(p=>p.id===e.layerId),l=await r.whenLayerView(n),i=n.title??e.layerId,u;if(o){let p=await ee(o,r);if("error"in p)return{tool:"getTopFeatures",layerName:i,summary:"Geometry lookup failed",details:{error:p.error}};if(!p.geometry)return{tool:"getTopFeatures",layerName:i,summary:"No features found for geometry filter",details:{error:`No features found matching: ${"where"in o?o.where:"unknown criteria"}`}};u=p.geometry}else a&&(u=r.extent.clone());let c=t.groupByFields&&t.groupByFields.length>0,d=n.objectIdField,m=e.outFields.includes("*")?["*"]:[...new Set([...e.outFields,d])];try{let p;if(c){let h=new Rt({where:e.where||"1=1",outFields:m,orderByFields:e.orderByFields,geometry:u,spatialRelationship:u?"intersects":void 0,distance:o?.distance,units:o?.units,topFilter:new qt({topCount:t.topCount,groupByFields:t.groupByFields,orderByFields:t.orderByFields})});p=await n.queryTopFeatures(h)}else{let h=n.createQuery();h.where=X(n.definitionExpression,e.where||"1=1"),h.outFields=m.length?m:["*"],h.orderByFields=t.orderByFields,h.returnGeometry=!1,h.num=t.topCount,u&&(h.geometry=u,h.spatialRelationship="intersects"),o?.distance&&(h.distance=o.distance),o?.units&&(h.units=o.units),h.outSpatialReference=r.spatialReference;let v=[...new Set([...e.outFields,...Xo(t.orderByFields)])],g=we(l,v,a??!1);try{p=g?await l.queryFeatures(h):await n.queryFeatures(h)}catch(T){console.warn("Client-side query failed, falling back to server:",T),p=await n.queryFeatures(h)}}let w=p.features.map(h=>h.attributes[d]),{attributes:f}=Ke(n,p,r.timeZone);return{tool:"getTopFeatures",layerName:i,summary:`Top ${t.topCount} features extracted`,details:{topCount:t.topCount,attributes:f,objectIds:w,objectIdField:d,where:e.where,orderByFields:t.orderByFields,...c&&{groupByFields:t.groupByFields}}}}catch(p){return{tool:"getTopFeatures",layerName:i,summary:"Query failed",details:{error:p instanceof Error?p.message:String(p)}}}},ta=async({targetLayer:e,topFilter:t,geometryFilter:r,useCurrentExtent:o},a)=>{let{mapView:n}=M(a),l=await ea(e,t,n,r,o);return JSON.stringify(l,null,2)},ra=s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:s.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),oa=s.object({point:s.object({x:s.number().describe("X coordinate (longitude) from navigation result"),y:s.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:s.object({wkid:s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:s.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),aa=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:s.union([ra,oa]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),topFilter:s.object({topCount:s.number().describe("Number of top features to return per group."),orderByFields:s.array(s.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")),groupByFields:s.array(s.string().describe("Field(s) to group results by. Returns top N per group."))}).required(),useCurrentExtent:s.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer).")}),na=y(ta,{name:"getTopFeatures",description:'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',schema:aa}),se=25,ia=e=>e.flatMap(t=>t.split(",")).map(t=>t.trim()).map(t=>t.split(/\s+/u)[0]?.replace(/^"|"$/gu,"")).filter(t=>!!t),sa=async(e,t,r,o)=>{let a=t.map?.allLayers.find(v=>v.id===e.layerId),n=await t.whenLayerView(a),l=a.title??e.layerId,i;if(r){let v=await ee(r,t);if("error"in v){let g={error:v.error};if(P(r)){let T=t.map?.allLayers.find(E=>E.id===r.layerId);g.geometryLayerName=T?.title??T?.id,g.geometryLayerId=r.layerId,g.geometryWhere=r.where}else Y(r)&&(g.point=r.point);return{tool:"queryFeatures",layerName:l,summary:"Geometry lookup failed",details:g}}if(!v.geometry){let g={};if(P(r)){let T=t.map?.allLayers.find(E=>E.id===r.layerId);g.error=`No features found matching: ${r.where}`,g.geometryLayerName=T?.title??T?.id,g.geometryLayerId=r.layerId,g.geometryWhere=r.where}else Y(r)&&(g.error="Failed to create point geometry",g.point=r.point);return{tool:"queryFeatures",layerName:l,summary:"No features found for geometry filter",details:g}}i=v.geometry}else o&&(i=t.extent.clone());let u=[...new Set([...e.outFields,...ia(e.orderByFields)])],c=we(n,u,o??!1),d=a.objectIdField,m=a.createQuery();m.where=X(a.definitionExpression,e.where||"1=1"),m.outFields=e.outFields.includes("*")?["*"]:[...new Set([...e.outFields,d])],m.orderByFields=e.orderByFields,i&&(m.geometry=i,m.spatialRelationship="intersects"),r?.distance&&(m.distance=r.distance),r?.units&&(m.units=r.units),m.outSpatialReference=t.spatialReference;let p,w;try{p=c?await n.queryFeatureCount(m):await a.queryFeatureCount(m),p>0&&p<=se&&(w=c?await n.queryFeatures(m):await a.queryFeatures(m))}catch(v){console.warn("Client-side query failed, falling back to server:",v),p=await a.queryFeatureCount(m),p>0&&p<=se&&(w=await a.queryFeatures(m))}let{objectIds:f,attributes:h}=w?Ke(a,w,t.timeZone):{objectIds:void 0,attributes:void 0};return{tool:"queryFeatures",layerName:l,summary:`${p} features found`,details:{totalCount:p,where:e.where,orderByFields:e.orderByFields,outFields:e.outFields,...f&&{objectIds:f,objectIdField:d},...h&&{attributes:h},...p>se&&{note:`${p} features found.`}}}};async function la({targetLayer:e,geometryFilter:t,useCurrentExtent:r},o){let{mapView:a}=M(o),n=await sa(e,a,t,r);return JSON.stringify(n,null,2)}var ca=s.object({layerId:s.string().describe("The layerId of the layer containing the geometry by which to filter."),where:s.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:s.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),ua=s.object({point:s.object({x:s.number().describe("X coordinate (longitude) from navigation result"),y:s.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:s.object({wkid:s.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:s.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),da=s.object({targetLayer:s.object({layerId:s.string().describe("The layerId of the layer containing the field from which to get a value."),where:s.string().describe("SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."),orderByFields:s.array(s.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:s.array(s.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:s.union([ca,ua]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),useCurrentExtent:s.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer).")}),pa=y(la,{name:"queryFeatures",description:`Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if \u226425 features match.
87
+ Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,schema:Zo}),Xo=e=>e.flatMap(t=>t.split(",")).map(t=>t.trim()).map(t=>t.split(/\s+/u)[0]?.replace(/^"|"$/gu,"")).filter(t=>!!t),ea=async(e,t,r,o,a)=>{let n=r.map?.allLayers.find(p=>p.id===e.layerId),s=await r.whenLayerView(n),i=n.title??e.layerId,u;if(o){let p=await ee(o,r);if("error"in p)return{tool:"getTopFeatures",layerName:i,summary:"Geometry lookup failed",details:{error:p.error}};if(!p.geometry)return{tool:"getTopFeatures",layerName:i,summary:"No features found for geometry filter",details:{error:`No features found matching: ${"where"in o?o.where:"unknown criteria"}`}};u=p.geometry}else a&&(u=r.extent.clone());let c=t.groupByFields&&t.groupByFields.length>0,d=n.objectIdField,m=e.outFields.includes("*")?["*"]:[...new Set([...e.outFields,d])];try{let p;if(c){let h=new Ct({where:e.where||"1=1",outFields:m,orderByFields:e.orderByFields,geometry:u,spatialRelationship:u?"intersects":void 0,distance:o?.distance,units:o?.units,topFilter:new Rt({topCount:t.topCount,groupByFields:t.groupByFields,orderByFields:t.orderByFields})});p=await n.queryTopFeatures(h)}else{let h=n.createQuery();h.where=X(n.definitionExpression,e.where||"1=1"),h.outFields=m.length?m:["*"],h.orderByFields=t.orderByFields,h.returnGeometry=!1,h.num=t.topCount,u&&(h.geometry=u,h.spatialRelationship="intersects"),o?.distance&&(h.distance=o.distance),o?.units&&(h.units=o.units),h.outSpatialReference=r.spatialReference;let v=[...new Set([...e.outFields,...Xo(t.orderByFields)])],g=we(s,v,a??!1);try{p=g?await s.queryFeatures(h):await n.queryFeatures(h)}catch(T){console.warn("Client-side query failed, falling back to server:",T),p=await n.queryFeatures(h)}}let w=p.features.map(h=>h.attributes[d]),{attributes:f}=Ke(n,p,r.timeZone);return{tool:"getTopFeatures",layerName:i,summary:`Top ${t.topCount} features extracted`,details:{topCount:t.topCount,attributes:f,objectIds:w,objectIdField:d,where:e.where,orderByFields:t.orderByFields,...c&&{groupByFields:t.groupByFields}}}}catch(p){return{tool:"getTopFeatures",layerName:i,summary:"Query failed",details:{error:p instanceof Error?p.message:String(p)}}}},ta=async({targetLayer:e,topFilter:t,geometryFilter:r,useCurrentExtent:o},a)=>{let{mapView:n}=M(a),s=await ea(e,t,n,r,o);return JSON.stringify(s,null,2)},ra=l.object({layerId:l.string().describe("The layerId of the layer containing the geometry by which to filter."),where:l.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:l.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),oa=l.object({point:l.object({x:l.number().describe("X coordinate (longitude) from navigation result"),y:l.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:l.object({wkid:l.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:l.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),aa=l.object({targetLayer:l.object({layerId:l.string().describe("The layerId of the layer containing the field from which to get a value."),where:l.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:l.array(l.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:l.array(l.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:l.union([ra,oa]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),topFilter:l.object({topCount:l.number().describe("Number of top features to return per group."),orderByFields:l.array(l.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")),groupByFields:l.array(l.string().describe("Field(s) to group results by. Returns top N per group."))}).required(),useCurrentExtent:l.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer).")}),na=y(ta,{name:"getTopFeatures",description:'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',schema:aa}),se=25,ia=e=>e.flatMap(t=>t.split(",")).map(t=>t.trim()).map(t=>t.split(/\s+/u)[0]?.replace(/^"|"$/gu,"")).filter(t=>!!t),sa=async(e,t,r,o)=>{let a=t.map?.allLayers.find(v=>v.id===e.layerId),n=await t.whenLayerView(a),s=a.title??e.layerId,i;if(r){let v=await ee(r,t);if("error"in v){let g={error:v.error};if(P(r)){let T=t.map?.allLayers.find(E=>E.id===r.layerId);g.geometryLayerName=T?.title??T?.id,g.geometryLayerId=r.layerId,g.geometryWhere=r.where}else Y(r)&&(g.point=r.point);return{tool:"queryFeatures",layerName:s,summary:"Geometry lookup failed",details:g}}if(!v.geometry){let g={};if(P(r)){let T=t.map?.allLayers.find(E=>E.id===r.layerId);g.error=`No features found matching: ${r.where}`,g.geometryLayerName=T?.title??T?.id,g.geometryLayerId=r.layerId,g.geometryWhere=r.where}else Y(r)&&(g.error="Failed to create point geometry",g.point=r.point);return{tool:"queryFeatures",layerName:s,summary:"No features found for geometry filter",details:g}}i=v.geometry}else o&&(i=t.extent.clone());let u=[...new Set([...e.outFields,...ia(e.orderByFields)])],c=we(n,u,o??!1),d=a.objectIdField,m=a.createQuery();m.where=X(a.definitionExpression,e.where||"1=1"),m.outFields=e.outFields.includes("*")?["*"]:[...new Set([...e.outFields,d])],m.orderByFields=e.orderByFields,i&&(m.geometry=i,m.spatialRelationship="intersects"),r?.distance&&(m.distance=r.distance),r?.units&&(m.units=r.units),m.outSpatialReference=t.spatialReference;let p,w;try{p=c?await n.queryFeatureCount(m):await a.queryFeatureCount(m),p>0&&p<=se&&(w=c?await n.queryFeatures(m):await a.queryFeatures(m))}catch(v){console.warn("Client-side query failed, falling back to server:",v),p=await a.queryFeatureCount(m),p>0&&p<=se&&(w=await a.queryFeatures(m))}let{objectIds:f,attributes:h}=w?Ke(a,w,t.timeZone):{objectIds:void 0,attributes:void 0};return{tool:"queryFeatures",layerName:s,summary:`${p} features found`,details:{totalCount:p,where:e.where,orderByFields:e.orderByFields,outFields:e.outFields,...f&&{objectIds:f,objectIdField:d},...h&&{attributes:h},...p>se&&{note:`${p} features found.`}}}};async function la({targetLayer:e,geometryFilter:t,useCurrentExtent:r},o){let{mapView:a}=M(o),n=await sa(e,a,t,r);return JSON.stringify(n,null,2)}var ca=l.object({layerId:l.string().describe("The layerId of the layer containing the geometry by which to filter."),where:l.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:l.number().optional().describe("The buffer distance around the geometry."),units:$.optional().describe("The units for the distance buffer.")}),ua=l.object({point:l.object({x:l.number().describe("X coordinate (longitude) from navigation result"),y:l.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:l.object({wkid:l.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:l.number().optional().describe("Optional buffer distance around the point."),units:$.optional().describe("The units for the distance buffer.")}),da=l.object({targetLayer:l.object({layerId:l.string().describe("The layerId of the layer containing the field from which to get a value."),where:l.string().describe("SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."),orderByFields:l.array(l.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:l.array(l.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:l.union([ca,ua]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),useCurrentExtent:l.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer).")}),pa=y(la,{name:"queryFeatures",description:`Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if \u226425 features match.
88
88
 
89
89
  USE THIS TOOL FOR:
90
90
  - "Show / display / list features where..." \u2014 finding and listing features
@@ -93,11 +93,11 @@ USE THIS TOOL FOR:
93
93
  - Spatial queries \u2014 finding features near/within/intersecting other features
94
94
  - Any question where the user wants to SEE or COUNT matching features
95
95
 
96
- This is the DEFAULT tool for most queries. When in doubt, use this tool.`,schema:da}),ma=[Uo,Yo,na,pa],bs=[Ao,xo,vo],ha=new K(ma,{handleToolErrors:!1});async function vs(e,t){let{messages:r}=await ha.invoke({messages:e.dataExplorationMessages},t),o=[],a=[];for(let n of r){let l=n.content,i;typeof l!="string"&&(i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:l}});try{typeof l=="string"?i=JSON.parse(l):i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Invalid tool output type",raw:l}}}catch{i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:l}}}o.push(i),i.details&&typeof i.details=="object"&&"error"in i.details?a.push(`- ${i.tool}: Error - ${String(i.details.error)}`):a.push(`- ${i.layerName}: ${i.summary}`)}return await S({text:`Finished executing layer query tool: ${a.join(", ")}`},t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,...r],queryResponse:o,status:"success",summary:a.length>0?mr(a.join(`
97
- `)):"Query executed."}}var Ts=b.Root({...L(),helpInternalState:b({reducer:O,default:()=>({toolCallMessage:void 0})})}),fa=(e,t)=>{let r=Array.from(e.values()).find(({layerItem:n})=>n.title?.toLowerCase().includes(t.toLowerCase()));if(!r){let n=Array.from(e.values()).map(l=>l.layerItem.title).join(", ");return`Could not find a layer matching "${t}". Available layers: ${n}`}let o=Array.from(r.fieldRegistry.values()),a=o.map(n=>`- **${n.alias||n.name}** (\`${n.name}\`, ${n.type})${n.description?`: ${n.description}`:""}`).join(`
96
+ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,schema:da}),ma=[Uo,Yo,na,pa],bs=[Ao,xo,vo],ha=new K(ma,{handleToolErrors:!1});async function vs(e,t){let{messages:r}=await ha.invoke({messages:e.dataExplorationMessages},t),o=[],a=[];for(let n of r){let s=n.content,i;typeof s!="string"&&(i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:s}});try{typeof s=="string"?i=JSON.parse(s):i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Invalid tool output type",raw:s}}}catch{i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:s}}}o.push(i),i.details&&typeof i.details=="object"&&"error"in i.details?a.push(`- ${i.tool}: Error - ${String(i.details.error)}`):a.push(`- ${i.layerName}: ${i.summary}`)}return await S({text:`Finished executing layer query tool: ${a.join(", ")}`},t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,...r],queryResponse:o,status:"success",summary:a.length>0?mr(a.join(`
97
+ `)):"Query executed."}}var Ts=b.Root({...L(),helpInternalState:b({reducer:O,default:()=>({toolCallMessage:void 0})})}),fa=(e,t)=>{let r=Array.from(e.values()).find(({layerItem:n})=>n.title?.toLowerCase().includes(t.toLowerCase()));if(!r){let n=Array.from(e.values()).map(s=>s.layerItem.title).join(", ");return`Could not find a layer matching "${t}". Available layers: ${n}`}let o=Array.from(r.fieldRegistry.values()),a=o.map(n=>`- **${n.alias||n.name}** (\`${n.name}\`, ${n.type})${n.description?`: ${n.description}`:""}`).join(`
98
98
  `);return`**${r.layerItem.title}** has ${o.length} field(s):
99
99
 
100
- ${a}`},ya=async({layerTitle:e},t)=>{let r=Ge(t,"layersAndFieldsRegistry");return fa(r,e)},Ss=y(ya,{name:"listLayerFields",description:"Lists all fields for a given layer by title. Use ONLY when the user explicitly asks to see fields, columns, or attributes of a specific named layer. Do NOT call this tool for general help questions, capability overviews, or layer listing.",schema:s.object({layerTitle:s.string().describe("The title or partial title of the layer to list fields for.")})}),xs=b.Root({...L(),intent:b({reducer:(e,t)=>t}),arcgisKnowledgeMessages:b({reducer:D,default:()=>[]}),arcgisKnowledgeToolResult:b({reducer:(e,t)=>t,default:()=>null})});function be(e){let t=e.map?.allLayers.filter(r=>r.type==="knowledge-graph");if(!t||t?.length!==1)throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.")}function A(e){return!!e?.map&&!("activeLinkChartLayer"in e.map)}async function te(e){!e||A(e)||!e.map?.diagramNodesExtent||await e.goTo(e.map.diagramNodesExtent)}function V(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("ArcgisKnowledgeAgent context missing");if(!("view"in t))throw new Error("View context missing");let r=t.view;return r.map&&!("activeLinkChartLayer"in r.map)&&be(r),{view:r}}function Es(e){let t=e?.configurable?.context;if(We(e)==="knowledgeGraph")return"knowledgeGraph";let r=t.view;return A(r)?(be(r),"map"):"linkChart"}async function Q(e){let t=e?.configurable?.context;if(We(e)==="knowledgeGraph")return t;{let r=t.view.map;if(r&&"activeLinkChartLayer"in r){let o=r.knowledgeGraph?.url;if(!o)throw new Error("Knowledge graph url missing from link chart.");return{knowledgeGraph:await Ce(o)}}else{be(t.view);let o=(t.view.map?.allLayers.find(a=>a.type==="knowledge-graph")).url;if(!o)throw new Error("Knowledge graph url missing from map.");return{knowledgeGraph:await Ce(o)}}}}function We(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("ArcgisKnowledgeAgent context missing");if("knowledgeGraph"in t&&"view"in t)throw new Error("Knowledge Graph context should only have a view or knowledgeGraph, but never both.");if("knowledgeGraph"in t)return"knowledgeGraph";if("view"in t)return"view";throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.")}var ce=class{constructor(t){this.dataModel=t,this.kind="GraphQueryGenerationRequest",this.explainQuery=!0,this.schemaInformation=ue.fromDataModel(t)}},ue=class e{constructor(){this.schemaType="ArcgisGraphSchema",this.entityTypes=[],this.relationshipTypes=[],this.identifierInfo={mappingInfo:{identifierMapsTo:"UniformPropertyIdentifier",identifierPropertyName:"globalid"}}}static fromDataModel(t){let r=new e;for(let o of t.entityTypes)r.entityTypes.push(G.fromEntityType(o));for(let o of t.relationshipTypes)r.relationshipTypes.push(de.fromRelationshipType(o));return r.identifierInfo={mappingInfo:{identifierMapsTo:ga(t.identifierInfo.identifierMappingInfo.identifierInfoType),identifierPropertyName:t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName}},r.spatialReference=JSON.parse(JSON.stringify(t.spatialReference)),r}static getDataModelTypesSummary(t){let r=t.entityTypes.map(a=>a.name).join(", "),o=t.relationshipTypes.map(a=>a.name).join(", ");return`Entity Types: ${r}.
100
+ ${a}`},ya=async({layerTitle:e},t)=>{let r=Ge(t,"layersAndFieldsRegistry");return fa(r,e)},Ss=y(ya,{name:"listLayerFields",description:"Lists all fields for a given layer by title. Use ONLY when the user explicitly asks to see fields, columns, or attributes of a specific named layer. Do NOT call this tool for general help questions, capability overviews, or layer listing.",schema:l.object({layerTitle:l.string().describe("The title or partial title of the layer to list fields for.")})}),xs=b.Root({...L(),intent:b({reducer:(e,t)=>t}),arcgisKnowledgeMessages:b({reducer:D,default:()=>[]}),arcgisKnowledgeToolResult:b({reducer:(e,t)=>t,default:()=>null})});function be(e){let t=e.map?.allLayers.filter(r=>r.type==="knowledge-graph");if(!t||t?.length!==1)throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.")}function A(e){return!!e?.map&&!("activeLinkChartLayer"in e.map)}async function te(e){!e||A(e)||!e.map?.diagramNodesExtent||await e.goTo(e.map.diagramNodesExtent)}function V(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("ArcgisKnowledgeAgent context missing");if(!("view"in t))throw new Error("View context missing");let r=t.view;return r.map&&!("activeLinkChartLayer"in r.map)&&be(r),{view:r}}function Es(e){let t=e?.configurable?.context;if(We(e)==="knowledgeGraph")return"knowledgeGraph";let r=t.view;return A(r)?(be(r),"map"):"linkChart"}async function Q(e){let t=e?.configurable?.context;if(We(e)==="knowledgeGraph")return t;{let r=t.view.map;if(r&&"activeLinkChartLayer"in r){let o=r.knowledgeGraph?.url;if(!o)throw new Error("Knowledge graph url missing from link chart.");return{knowledgeGraph:await qe(o)}}else{be(t.view);let o=(t.view.map?.allLayers.find(a=>a.type==="knowledge-graph")).url;if(!o)throw new Error("Knowledge graph url missing from map.");return{knowledgeGraph:await qe(o)}}}}function We(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("ArcgisKnowledgeAgent context missing");if("knowledgeGraph"in t&&"view"in t)throw new Error("Knowledge Graph context should only have a view or knowledgeGraph, but never both.");if("knowledgeGraph"in t)return"knowledgeGraph";if("view"in t)return"view";throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.")}var ce=class{constructor(t){this.dataModel=t,this.kind="GraphQueryGenerationRequest",this.explainQuery=!0,this.schemaInformation=ue.fromDataModel(t)}},ue=class e{constructor(){this.schemaType="ArcgisGraphSchema",this.entityTypes=[],this.relationshipTypes=[],this.identifierInfo={mappingInfo:{identifierMapsTo:"UniformPropertyIdentifier",identifierPropertyName:"globalid"}}}static fromDataModel(t){let r=new e;for(let o of t.entityTypes)r.entityTypes.push(G.fromEntityType(o));for(let o of t.relationshipTypes)r.relationshipTypes.push(de.fromRelationshipType(o));return r.identifierInfo={mappingInfo:{identifierMapsTo:ga(t.identifierInfo.identifierMappingInfo.identifierInfoType),identifierPropertyName:t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName}},r.spatialReference=JSON.parse(JSON.stringify(t.spatialReference)),r}static getDataModelTypesSummary(t){let r=t.entityTypes.map(a=>a.name).join(", "),o=t.relationshipTypes.map(a=>a.name).join(", ");return`Entity Types: ${r}.
101
101
  Relationship Types: ${o}.`}},G=class e{constructor(){this.name="",this.properties=[]}static fromEntityType(t){let r=new e;r.name=t.name,r.alias=t.alias?t.alias:void 0,r.role=wa(t.role);for(let o of t.properties){let a={name:o.name,alias:o.alias?o.alias:void 0,fieldType:o.fieldType,role:ba(o.role),geometryDef:o.fieldType==="esriFieldTypeGeometry"?{geometryType:o.geometryType??"esriGeometryAny",hasM:o.hasM?o.hasM:void 0,hasZ:o.hasZ?o.hasZ:void 0}:void 0};r.properties.push(a)}return r}},de=class extends G{constructor(){super(...arguments),this.observedEndPoints=[]}static fromRelationshipType(t){let r=G.fromEntityType(t);r.observedEndPoints=[];for(let o of t.endPoints)r.observedEndPoints.push({originEntityType:o.originEntityType,destinationEntityType:o.destinationEntityType});return r}},ga=e=>{switch(e){case"esriIdentifierInfoTypeUNSPECIFIED":return"UNSPECIFIED";case"esriIdentifierInfoTypeDatabaseNative":return"DatabaseNative";case"esriIdentifierInfoTypeUniformProperty":return"UniformPropertyIdentifier";default:return e}},wa=e=>{switch(e){case"Regular":return"esriGraphNamedObjectRegular";case"Provenance":return"esriGraphNamedObjectProvenance";case"Document":return"esriGraphNamedObjectDocument";default:return e}};function ba(e){switch(e){case"esriGraphPropertyRegular":return"Regular";case"esriGraphPropertyDocumentName":return"Document_Name";case"esriGraphPropertyDocumentTitle":return"Document_Title";case"esriGraphPropertyDocumentUrl":return"Document_Url";case"esriGraphPropertyDocumentText":return"Document_Text";case"esriGraphPropertyDocumentKeywords":return"Document_Keywords";case"esriGraphPropertyDocumentContentType":return"Document_ContentType";case"esriGraphPropertyDocumentMetadata":return"Document_Metadata";case"esriGraphPropertyDocumentFileExtension":return"Document_FileExtension";case"esriGraphPropertyProvenanceInstanceId":return"Provenance_InstanceId";case"esriGraphPropertyProvenanceSourceType":return"Provenance_SourceType";case"esriGraphPropertyProvenanceSourceName":return"Provenance_SourceName";case"esriGraphPropertyProvenanceSource":return"Provenance_Source";case"esriGraphPropertyProvenanceComment":return"Provenance_Comment";case"esriGraphPropertyProvenanceTypeName":return"Provenance_TypeName";case"esriGraphPropertyProvenancePropertyName":return"Provenance_PropertyName";default:return"Regular"}}function re(e){return e?.signal}async function va(e,t){let r=await Z("arcgis_knowledge_cypher_query_prompt");return t?`${e} ${r}
102
102
 
103
103
  Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
@@ -105,15 +105,15 @@ Your previous attempt to generate a cypher query failed. See the details below a
105
105
  Attempt Number: ${t.attemptCount}
106
106
  Execution Error: ${t.executionError}
107
107
  Failed Query:
108
- ${t.failedGraphQuery}`:`${e} ${r}`}async function Ta(e,t,r,o){let{graphQuery:a,explanation:n}=await ve(e,t,r,o);return{graphQuery:a,explanation:n}}async function ve(e,t,r,o,a){let n={message:await va(e,a),context:new ce(t)},l=re(o);await S({text:"Attempting to generate a cypher query from your prompt..."},o);let i=await Ae(`${r}/chat`,{method:"post",body:JSON.stringify(n),headers:{"Content-Type":"application/json",token:Me.findCredential(F.getDefault().url)?.token??""},signal:l});if(i.httpStatus!==200)throw new Error(`Graph query service returned an error: ${i.httpStatus}`,{cause:i.data});let u=!1,c=Date.now(),d=i.data.sequenceNumber,m="",p="",w=1;for(;!u;){await new Promise(h=>setTimeout(h,1e3)),await S({text:`Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,w)}`},o),w=w%3+1;let f=await Ae(`${r}/chat`,{method:"post",body:JSON.stringify({conversationId:i.data.conversationId,inquiryId:i.data.inquiryId,ackSequenceNumber:d}),headers:{"Content-Type":"application/json",token:Me.findCredential(F.getDefault().url)?.token??""},signal:l});if(f.httpStatus!==200)throw new Error(`Graph query service polling returned an error: ${f.httpStatus}`,{cause:f.data});if(f.data.context?.kind){if(f.data.context.kind!=="GraphQueryGenerationResponse")throw new Error(`Unexpected response from graph query service polling. Message: ${f.data.message}`,{cause:f.data});m=f.data.context.graphQuery,p=f.data.message||"",u=!0}else if(!f.data.hasMore)u=!0;else if(Date.now()-c>6e4)throw new Error("Graph query service polling timed out after 1 minute.");d=f.data.sequenceNumber}return{graphQuery:m,explanation:p}}function Sa(e,t){q(e,r=>{t.set(`${r.typeName}__${r.id}`,{id:r.id,typeName:r.typeName})})}function q(e,t){if(!(!e||typeof e!="object")){if(Ea(e))for(let r of e.path)q(r,t);else if(xa(e))t(e);else if(Array.isArray(e))for(let r of e)q(r,t);else if(Ia(e))for(let r of Object.values(e.properties??{}))q(r,t)}}function xa(e){return!e||typeof e!="object"||Array.isArray(e)?!1:"id"in e&&"typeName"in e}function Ea(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e&&"path"in e&&Array.isArray(e.path)}function Ia(e){return!e||typeof e!="object"||Array.isArray(e)||"id"in e?!1:"properties"in e&&typeof e.properties=="object"}function Na(e,t){let r=[],o=[],a=[[t.dataModel.entityTypes,r],[t.dataModel.relationshipTypes,o]];for(let[n,l]of a)for(let i of n){let u=e.getMemberIdsByType(i.name);l.push(...u)}return{entityIds:r,relationshipIds:o}}function ka(e,t){let r={entityIds:new Array,relationshipIds:new Array},o=[],a=e?.allLayers.find(i=>i.type==="knowledge-graph")?.inclusionModeDefinition;if(!a)return{allNamedTypesFullyDynamic:!0,bindParameters:r,nonDynamicTypes:o};let n=[[t.dataModel.entityTypes,r.entityIds],[t.dataModel.relationshipTypes,r.relationshipIds]],l=!0;for(let[i,u]of n)for(let c of i){let d=a.namedTypeDefinitions.get(c.name);if(!d){l=!1,o.push(c.name);continue}if(!d.useAllData){l=!1,o.push(c.name);for(let[m]of d.members||[])u.push(m)}}return{allNamedTypesFullyDynamic:l,bindParameters:r,nonDynamicTypes:o}}var C=3;function He(e,t=100){let r={};for(let o of Object.entries(e.properties??{})){let[a,n]=o;typeof n=="string"&&n.length>t?r[a]=`${n.slice(0,t)}... (truncated, original length: ${n.length})`:r[a]=n}return e.properties=r,e}function _(e){return typeof e!="object"||e===null?String(e):"details"in e&&typeof e.details=="object"&&e.details!==null&&"errorMessage"in e.details&&typeof e.details.errorMessage=="string"?e.details.errorMessage:"message"in e&&typeof e.message=="string"?e.message:String(e)}var $a=async({kg:e,queryParams:t,targetStructure:r,targetStructureReducer:o,requestOptions:a,queryRowLimit:n,queryTimeoutMs:l})=>{let i=null,u=r,c=new AbortController,d=a?.signal,m=()=>{c.abort(d?.reason)};d&&(d.aborted?c.abort(d.reason):d.addEventListener("abort",m,{once:!0}));try{let p=await _t(e,t,a);i=p.resultHeader;let w=p.resultRowsStream.getReader(),f=0,h=Date.now(),v=!1;for(;;){let{done:g,value:T}=await w.read();if(g)break;if(!v&&l&&Date.now()-h>l)return c.abort(),{type:"timeout"};for(let E of T){if(f++,n&&f>n)return c.abort(),{type:"success",rowLimitReached:!0,resultHeader:i,processedResult:u};u=o(u,E)}}}catch(p){return c.signal.aborted?{type:"aborted"}:{type:"error",errorMessage:_(p),error:p}}finally{d?.removeEventListener("abort",m)}return{type:"success",rowLimitReached:!1,resultHeader:i,processedResult:u}};async function Je({prompt:e,bindParameters:t,kg:r,graphQueryServiceUrl:o,targetStructure:a,targetStructureReducer:n,requestOptions:l,queryRowLimit:i,queryTimeoutMs:u,config:c}){let d;for(let m=1;m<=C;m++){let p;try{p=await ve(e,r.dataModel,o,c,d)}catch(v){return{type:"generation-error",errorMessage:_(v),error:v}}await S({text:`Attempting to execute query: ${p.graphQuery.substring(0,500)}${p.graphQuery.length>500?"...":""}`},c);let w=await Fa(p.graphQuery,t),f=await $a({kg:r,queryParams:new Pe({openCypherQuery:p.graphQuery,bindParameters:w}),targetStructure:a,targetStructureReducer:n,requestOptions:l,queryRowLimit:i,queryTimeoutMs:u}),h=f.type==="aborted"?"Query execution was aborted.":f.type==="timeout"?"Query execution timed out.":f.type==="error"?`Query failed with error: ${f.errorMessage}`:"";if(f.type==="success")return{type:"success",graphQuery:p.graphQuery,explanation:p.explanation,rowLimitReached:f.rowLimitReached,resultHeader:f.resultHeader,processedResult:f.processedResult};if(f.type==="aborted")return{type:"aborted",errorMessage:h,graphQuery:p.graphQuery,explanation:p.explanation};if(m>=C)return f.type==="timeout"?{type:"timeout",errorMessage:h,graphQuery:p.graphQuery,explanation:p.explanation}:{type:"execution-error",errorMessage:h,error:f.error,graphQuery:p.graphQuery,explanation:p.explanation};d={failedGraphQuery:p.graphQuery,executionError:h,attemptCount:m},await S({text:`Attempt ${m} failed with error: ${h}. Retrying...`},c)}throw new Error(`Failed to execute generated cypher due to an unexpected error after ${C} attempts.`)}var Fa=async(e,t)=>{if(!t)return{};let{bindParameters:r,parseErrors:o}=await Dt(e);if(o)return t;let a={};for(let n of r)n in t&&(a[n]=t[n]);return a},Ma=async({kg:e,searchQuery:t,typeCategoryFilter:r,namedTypesFilter:o,searchResultLimit:a,requestOptions:n})=>{let l=[],i=[r];r==="both"&&!e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth")&&(i=["entity","relationship"]);let u=a??1/0;try{for(let c of i){let d=u-l.length;if(d<=0)break;let m=(await zt(e,new jt({searchQuery:t,typeCategoryFilter:c,namedTypesFilter:o??void 0,num:d}),n)).resultRowsStream.getReader(),p=!1;for(;!p;){let{done:w,value:f}=await m.read();if(w){p=!0;break}for(let h of f)for(let v of h)l.push(v)}}}catch(c){let d=_(c);return n?.signal?.aborted?{type:"aborted",errorMessage:d,error:c}:{type:"error",errorMessage:d,error:c}}return{type:"success",results:l}},Ze="IMPORTANT: The generated cypher query must return entire entities and relationships ONLY.";async function Ye({prompt:e,view:t,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:o=!1}){let a=[e];if(o&&a.push(Ze),!A(t)&&t.map){let d=await Z("arcgis_knowledge_current_lc_context"),m=Na(t.map,r);return a.push(d),{enhancedPrompt:a.join(`
108
+ ${t.failedGraphQuery}`:`${e} ${r}`}async function Ta(e,t,r,o){let{graphQuery:a,explanation:n}=await ve(e,t,r,o);return{graphQuery:a,explanation:n}}async function ve(e,t,r,o,a){let n={message:await va(e,a),context:new ce(t)},s=re(o);await S({text:"Attempting to generate a cypher query from your prompt..."},o);let i=await Ae(`${r}/chat`,{method:"post",body:JSON.stringify(n),headers:{"Content-Type":"application/json",token:Me.findCredential(F.getDefault().url)?.token??""},signal:s});if(i.httpStatus!==200)throw new Error(`Graph query service returned an error: ${i.httpStatus}`,{cause:i.data});let u=!1,c=Date.now(),d=i.data.sequenceNumber,m="",p="",w=1;for(;!u;){await new Promise(h=>setTimeout(h,1e3)),await S({text:`Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,w)}`},o),w=w%3+1;let f=await Ae(`${r}/chat`,{method:"post",body:JSON.stringify({conversationId:i.data.conversationId,inquiryId:i.data.inquiryId,ackSequenceNumber:d}),headers:{"Content-Type":"application/json",token:Me.findCredential(F.getDefault().url)?.token??""},signal:s});if(f.httpStatus!==200)throw new Error(`Graph query service polling returned an error: ${f.httpStatus}`,{cause:f.data});if(f.data.context?.kind){if(f.data.context.kind!=="GraphQueryGenerationResponse")throw new Error(`Unexpected response from graph query service polling. Message: ${f.data.message}`,{cause:f.data});m=f.data.context.graphQuery,p=f.data.message||"",u=!0}else if(!f.data.hasMore)u=!0;else if(Date.now()-c>6e4)throw new Error("Graph query service polling timed out after 1 minute.");d=f.data.sequenceNumber}return{graphQuery:m,explanation:p}}function Sa(e,t){R(e,r=>{t.set(`${r.typeName}__${r.id}`,{id:r.id,typeName:r.typeName})})}function R(e,t){if(!(!e||typeof e!="object")){if(Ea(e))for(let r of e.path)R(r,t);else if(xa(e))t(e);else if(Array.isArray(e))for(let r of e)R(r,t);else if(Ia(e))for(let r of Object.values(e.properties??{}))R(r,t)}}function xa(e){return!e||typeof e!="object"||Array.isArray(e)?!1:"id"in e&&"typeName"in e}function Ea(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e&&"path"in e&&Array.isArray(e.path)}function Ia(e){return!e||typeof e!="object"||Array.isArray(e)||"id"in e?!1:"properties"in e&&typeof e.properties=="object"}function Na(e,t){let r=[],o=[],a=[[t.dataModel.entityTypes,r],[t.dataModel.relationshipTypes,o]];for(let[n,s]of a)for(let i of n){let u=e.getMemberIdsByType(i.name);s.push(...u)}return{entityIds:r,relationshipIds:o}}function ka(e,t){let r={entityIds:new Array,relationshipIds:new Array},o=[],a=e?.allLayers.find(i=>i.type==="knowledge-graph")?.inclusionModeDefinition;if(!a)return{allNamedTypesFullyDynamic:!0,bindParameters:r,nonDynamicTypes:o};let n=[[t.dataModel.entityTypes,r.entityIds],[t.dataModel.relationshipTypes,r.relationshipIds]],s=!0;for(let[i,u]of n)for(let c of i){let d=a.namedTypeDefinitions.get(c.name);if(!d){s=!1,o.push(c.name);continue}if(!d.useAllData){s=!1,o.push(c.name);for(let[m]of d.members||[])u.push(m)}}return{allNamedTypesFullyDynamic:s,bindParameters:r,nonDynamicTypes:o}}var q=3;function He(e,t=100){let r={};for(let o of Object.entries(e.properties??{})){let[a,n]=o;typeof n=="string"&&n.length>t?r[a]=`${n.slice(0,t)}... (truncated, original length: ${n.length})`:r[a]=n}return e.properties=r,e}function _(e){return typeof e!="object"||e===null?String(e):"details"in e&&typeof e.details=="object"&&e.details!==null&&"errorMessage"in e.details&&typeof e.details.errorMessage=="string"?e.details.errorMessage:"message"in e&&typeof e.message=="string"?e.message:String(e)}var $a=async({kg:e,queryParams:t,targetStructure:r,targetStructureReducer:o,requestOptions:a,queryRowLimit:n,queryTimeoutMs:s})=>{let i=null,u=r,c=new AbortController,d=a?.signal,m=()=>{c.abort(d?.reason)};d&&(d.aborted?c.abort(d.reason):d.addEventListener("abort",m,{once:!0}));try{let p=await _t(e,t,a);i=p.resultHeader;let w=p.resultRowsStream.getReader(),f=0,h=Date.now(),v=!1;for(;;){let{done:g,value:T}=await w.read();if(g)break;if(!v&&s&&Date.now()-h>s)return c.abort(),{type:"timeout"};for(let E of T){if(f++,n&&f>n)return c.abort(),{type:"success",rowLimitReached:!0,resultHeader:i,processedResult:u};u=o(u,E)}}}catch(p){return c.signal.aborted?{type:"aborted"}:{type:"error",errorMessage:_(p),error:p}}finally{d?.removeEventListener("abort",m)}return{type:"success",rowLimitReached:!1,resultHeader:i,processedResult:u}};async function Je({prompt:e,bindParameters:t,kg:r,graphQueryServiceUrl:o,targetStructure:a,targetStructureReducer:n,requestOptions:s,queryRowLimit:i,queryTimeoutMs:u,config:c}){let d;for(let m=1;m<=q;m++){let p;try{p=await ve(e,r.dataModel,o,c,d)}catch(v){return{type:"generation-error",errorMessage:_(v),error:v}}await S({text:`Attempting to execute query: ${p.graphQuery.substring(0,500)}${p.graphQuery.length>500?"...":""}`},c);let w=await Fa(p.graphQuery,t),f=await $a({kg:r,queryParams:new Pe({openCypherQuery:p.graphQuery,bindParameters:w}),targetStructure:a,targetStructureReducer:n,requestOptions:s,queryRowLimit:i,queryTimeoutMs:u}),h=f.type==="aborted"?"Query execution was aborted.":f.type==="timeout"?"Query execution timed out.":f.type==="error"?`Query failed with error: ${f.errorMessage}`:"";if(f.type==="success")return{type:"success",graphQuery:p.graphQuery,explanation:p.explanation,rowLimitReached:f.rowLimitReached,resultHeader:f.resultHeader,processedResult:f.processedResult};if(f.type==="aborted")return{type:"aborted",errorMessage:h,graphQuery:p.graphQuery,explanation:p.explanation};if(m>=q)return f.type==="timeout"?{type:"timeout",errorMessage:h,graphQuery:p.graphQuery,explanation:p.explanation}:{type:"execution-error",errorMessage:h,error:f.error,graphQuery:p.graphQuery,explanation:p.explanation};d={failedGraphQuery:p.graphQuery,executionError:h,attemptCount:m},await S({text:`Attempt ${m} failed with error: ${h}. Retrying...`},c)}throw new Error(`Failed to execute generated cypher due to an unexpected error after ${q} attempts.`)}var Fa=async(e,t)=>{if(!t)return{};let{bindParameters:r,parseErrors:o}=await Dt(e);if(o)return t;let a={};for(let n of r)n in t&&(a[n]=t[n]);return a},Ma=async({kg:e,searchQuery:t,typeCategoryFilter:r,namedTypesFilter:o,searchResultLimit:a,requestOptions:n})=>{let s=[],i=[r];r==="both"&&!e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth")&&(i=["entity","relationship"]);let u=a??1/0;try{for(let c of i){let d=u-s.length;if(d<=0)break;let m=(await zt(e,new jt({searchQuery:t,typeCategoryFilter:c,namedTypesFilter:o??void 0,num:d}),n)).resultRowsStream.getReader(),p=!1;for(;!p;){let{done:w,value:f}=await m.read();if(w){p=!0;break}for(let h of f)for(let v of h)s.push(v)}}}catch(c){let d=_(c);return n?.signal?.aborted?{type:"aborted",errorMessage:d,error:c}:{type:"error",errorMessage:d,error:c}}return{type:"success",results:s}},Ze="IMPORTANT: The generated cypher query must return entire entities and relationships ONLY.";async function Ye({prompt:e,view:t,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:o=!1}){let a=[e];if(o&&a.push(Ze),!A(t)&&t.map){let d=await Z("arcgis_knowledge_current_lc_context"),m=Na(t.map,r);return a.push(d),{enhancedPrompt:a.join(`
109
109
 
110
- `),bindParameters:m,allNamedTypesFullyDynamic:!1}}let n=t.map,{allNamedTypesFullyDynamic:l,bindParameters:i,nonDynamicTypes:u}=ka(n,r);if(l)return{enhancedPrompt:a.join(`
110
+ `),bindParameters:m,allNamedTypesFullyDynamic:!1}}let n=t.map,{allNamedTypesFullyDynamic:s,bindParameters:i,nonDynamicTypes:u}=ka(n,r);if(s)return{enhancedPrompt:a.join(`
111
111
 
112
112
  `),bindParameters:i,allNamedTypesFullyDynamic:!0};let c=(await Z("arcgis_knowledge_current_map_context")).replaceAll("{nonDynamicTypes}",JSON.stringify(u));return a.push(c),{enhancedPrompt:a.join(`
113
113
 
114
- `),bindParameters:i,allNamedTypesFullyDynamic:l}}async function Aa(e,t,r,o,a,n){let{view:l}=a,i=await Je({prompt:e,bindParameters:t,kg:r,graphQueryServiceUrl:o,targetStructure:new Map,targetStructureReducer:(p,w)=>{for(let f of w)Sa(f,p);return p},requestOptions:{signal:re(n),timeout:n?.timeout},config:n});if(i.type!=="success"){let p=i.type==="generation-error"?i.errorMessage:`${i.errorMessage} Cypher query: ${i.graphQuery}`;throw new Error(`Failed to add records to the link chart. ${p}`)}let{graphQuery:u,explanation:c,processedResult:d}=i,m=Array.from(d.values());return await S({text:`Query Results parsed into ${m.length} unique relationships and entities. Atempting to add to link chart...`},n),!A(l)&&l?.map?(await l.map.addRecords(m),await te(l),{generatedQuery:u,explanation:c,addedIdTypePairs:m}):(await l?.map?.allLayers.find(p=>p.type==="knowledge-graph")?.addRecords(m),{generatedQuery:u,explanation:c,addedIdTypePairs:m})}var H="addRecords",Ra=s.object({prompt:s.string().describe("The user's inquiry and context required in order to generate a cypher query that will be used to add records to the link chart.")}),qa=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),o=V(t),{view:a}=o,n=F.getDefault().helperServices,{enhancedPrompt:l,bindParameters:i,allNamedTypesFullyDynamic:u}=await Ye({prompt:e,view:a,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:!0});if(u)return{toolName:H,status:"success",summary:"No records have been added to the map because all data in the knowledge graph is contained in the map.",details:{generatedQuery:"N/A",explanation:"All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",addedIdTypePairs:[]}};try{let{generatedQuery:c,explanation:d,addedIdTypePairs:m}=await Aa(l,i,r,`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,o,t);return{toolName:H,status:"success",summary:`Records added successfully. Cypher Query used: ${c}
114
+ `),bindParameters:i,allNamedTypesFullyDynamic:s}}async function Aa(e,t,r,o,a,n){let{view:s}=a,i=await Je({prompt:e,bindParameters:t,kg:r,graphQueryServiceUrl:o,targetStructure:new Map,targetStructureReducer:(p,w)=>{for(let f of w)Sa(f,p);return p},requestOptions:{signal:re(n),timeout:n?.timeout},config:n});if(i.type!=="success"){let p=i.type==="generation-error"?i.errorMessage:`${i.errorMessage} Cypher query: ${i.graphQuery}`;throw new Error(`Failed to add records to the link chart. ${p}`)}let{graphQuery:u,explanation:c,processedResult:d}=i,m=Array.from(d.values());return await S({text:`Query Results parsed into ${m.length} unique relationships and entities. Atempting to add to link chart...`},n),!A(s)&&s?.map?(await s.map.addRecords(m),await te(s),{generatedQuery:u,explanation:c,addedIdTypePairs:m}):(await s?.map?.allLayers.find(p=>p.type==="knowledge-graph")?.addRecords(m),{generatedQuery:u,explanation:c,addedIdTypePairs:m})}var H="addRecords",Ca=l.object({prompt:l.string().describe("The user's inquiry and context required in order to generate a cypher query that will be used to add records to the link chart.")}),Ra=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),o=V(t),{view:a}=o,n=F.getDefault().helperServices,{enhancedPrompt:s,bindParameters:i,allNamedTypesFullyDynamic:u}=await Ye({prompt:e,view:a,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:!0});if(u)return{toolName:H,status:"success",summary:"No records have been added to the map because all data in the knowledge graph is contained in the map.",details:{generatedQuery:"N/A",explanation:"All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",addedIdTypePairs:[]}};try{let{generatedQuery:c,explanation:d,addedIdTypePairs:m}=await Aa(s,i,r,`${n.aiAssistantServices.url}${n.aiAssistantServices.graphQueryAssistant}`,o,t);return{toolName:H,status:"success",summary:`Records added successfully. Cypher Query used: ${c}
115
115
 
116
- Number of records added: ${m.length}`,details:{generatedQuery:c,explanation:d,addedIdTypePairs:m}}}catch(c){let d=_(c);return{toolName:H,status:"error",errorMessage:`Failed to add records to the link chart. ${d}`,error:c}}},Is=y(qa,{name:H,description:`Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt. "add to new link chart" is not a valid prompt for this tool.
116
+ Number of records added: ${m.length}`,details:{generatedQuery:c,explanation:d,addedIdTypePairs:m}}}catch(c){let d=_(c);return{toolName:H,status:"error",errorMessage:`Failed to add records to the link chart. ${d}`,error:c}}},Is=y(Ra,{name:H,description:`Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt. "add to new link chart" is not a valid prompt for this tool.
117
117
 
118
118
  example prompts:
119
119
  - "add all suppliers and the parts they produce to the link chart"
@@ -123,15 +123,15 @@ Number of records added: ${m.length}`,details:{generatedQuery:c,explanation:d,ad
123
123
  - "expand company x through all the buildings it owns"
124
124
  - "connect company x and company y"
125
125
  - "connect all buildings on the link chart"
126
- `,schema:Ra});async function Ca(e,t){return await t.map?.applyLayout(e),await te(t),{appliedLayout:e}}var pe="applyLayout",_a=s.object({layout:s.enum(["organic-standard","organic-community","basic-grid","hierarchical-bottom-to-top","radial-root-centric","tree-left-to-right","geographic-organic-standard","chronological-mono-timeline","chronological-multi-timeline"]).describe("The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline")}),za=async({layout:e},t)=>{let{view:r}=V(t);if(A(r))return{toolName:pe,status:"error",errorMessage:"The applyLayout tool can only be used with a LinkChartView.",error:new Error};{let{appliedLayout:o}=await Ca(e,r);return{toolName:pe,status:"success",summary:`Successfully applied layout: ${o}.`,details:{appliedLayout:o}}}},Ns=y(za,{name:pe,description:"Apply a diagram layout to the link chart",schema:_a});async function ja(e,t){return t.map?.changeNonspatialDataDisplay(e),await te(t),{appliedNonspatialDataDisplayMode:e}}var me="changeNonspatialVisibility",Da=s.object({setting:s.enum(["hidden","visible"]).describe("The setting of nonspatial visibility")}),La=async({setting:e},t)=>{let{view:r}=V(t);if(A(r))return{toolName:me,status:"error",errorMessage:"The changeNonspatialVisibility tool can only be used with a LinkChartView.",error:new Error};{let{appliedNonspatialDataDisplayMode:o}=await ja(e,r);return{toolName:me,status:"success",summary:`Successfully applied nonspatial visibility setting: ${o}.`,details:{appliedNonspatialDataDisplayMode:o}}}},ks=y(La,{name:me,description:"Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",schema:Da});async function Oa(e,t,r,o,a){let n,l="";for(let i=1;i<=C;i++){let{graphQuery:u,explanation:c}=await ve(e,t.dataModel,r,a,n);try{await S({text:`Attempting to create link chart from derived query: ${u}`},a);let d=await Ct.fromCypherQuery(t,new Pe({openCypherQuery:u}));await S({text:"Link chart created successfully, loading..."},a),await d.load();let m=o.map;return o.map=d,await o.when(),await je.whenOnce(()=>!o.updating),d.entityCount===0&&d.relationshipCount===0?(o.map===d&&(o.map=m),d.destroy(),{type:"error",errorMessage:`Query returned no results. Cypher Query used to create the link chart:
126
+ `,schema:Ca});async function qa(e,t){return await t.map?.applyLayout(e),await te(t),{appliedLayout:e}}var pe="applyLayout",_a=l.object({layout:l.enum(["organic-standard","organic-community","basic-grid","hierarchical-bottom-to-top","radial-root-centric","tree-left-to-right","geographic-organic-standard","chronological-mono-timeline","chronological-multi-timeline"]).describe("The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline")}),za=async({layout:e},t)=>{let{view:r}=V(t);if(A(r))return{toolName:pe,status:"error",errorMessage:"The applyLayout tool can only be used with a LinkChartView.",error:new Error};{let{appliedLayout:o}=await qa(e,r);return{toolName:pe,status:"success",summary:`Successfully applied layout: ${o}.`,details:{appliedLayout:o}}}},Ns=y(za,{name:pe,description:"Apply a diagram layout to the link chart",schema:_a});async function ja(e,t){return t.map?.changeNonspatialDataDisplay(e),await te(t),{appliedNonspatialDataDisplayMode:e}}var me="changeNonspatialVisibility",Da=l.object({setting:l.enum(["hidden","visible"]).describe("The setting of nonspatial visibility")}),La=async({setting:e},t)=>{let{view:r}=V(t);if(A(r))return{toolName:me,status:"error",errorMessage:"The changeNonspatialVisibility tool can only be used with a LinkChartView.",error:new Error};{let{appliedNonspatialDataDisplayMode:o}=await ja(e,r);return{toolName:me,status:"success",summary:`Successfully applied nonspatial visibility setting: ${o}.`,details:{appliedNonspatialDataDisplayMode:o}}}},ks=y(La,{name:me,description:"Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",schema:Da});async function Oa(e,t,r,o,a){let n,s="";for(let i=1;i<=q;i++){let{graphQuery:u,explanation:c}=await ve(e,t.dataModel,r,a,n);try{await S({text:`Attempting to create link chart from derived query: ${u}`},a);let d=await qt.fromCypherQuery(t,new Pe({openCypherQuery:u}));await S({text:"Link chart created successfully, loading..."},a),await d.load();let m=o.map;return o.map=d,await o.when(),await je.whenOnce(()=>!o.updating),d.entityCount===0&&d.relationshipCount===0?(o.map===d&&(o.map=m),d.destroy(),{type:"error",errorMessage:`Query returned no results. Cypher Query used to create the link chart:
127
127
  ${u}
128
128
 
129
- Explanation: ${c}`}):(await te(o),{type:"success",graphQuery:u,explanation:c})}catch(d){let m=_(d);if(i>=C){l=m;break}n={failedGraphQuery:u,executionError:m,attemptCount:i},await S({text:`Attempt ${i} to create link chart failed with error: ${m}. Retrying ...`},a)}}return{type:"error",errorMessage:`Failed to create link chart after ${C} attempts. Last error: ${l}`}}var J="createLinkChart",Pa=s.object({prompt:s.string().describe("The user's inquiry and context required in order to generate a cypher query that will be used to create a link chart visualization. Only include information relevant to generating a cypher query. Do not suggest entity types, relationship types or properties. Do not include limits or formatting instructions for the query results unless specifically requested by the user. The prompt should be focused on the data the user wants to see in the link chart, not how to generate it.")}),Ga=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),{view:o}=V(t);if(A(o))return{toolName:J,status:"error",errorMessage:"The createLinkChart tool can only be used with a LinkChartView.",error:new Error};{let a=F.getDefault().helperServices,n=await Oa(`${e}
129
+ Explanation: ${c}`}):(await te(o),{type:"success",graphQuery:u,explanation:c})}catch(d){let m=_(d);if(i>=q){s=m;break}n={failedGraphQuery:u,executionError:m,attemptCount:i},await S({text:`Attempt ${i} to create link chart failed with error: ${m}. Retrying ...`},a)}}return{type:"error",errorMessage:`Failed to create link chart after ${q} attempts. Last error: ${s}`}}var J="createLinkChart",Pa=l.object({prompt:l.string().describe("The user's inquiry and context required in order to generate a cypher query that will be used to create a link chart visualization. Only include information relevant to generating a cypher query. Do not suggest entity types, relationship types or properties. Do not include limits or formatting instructions for the query results unless specifically requested by the user. The prompt should be focused on the data the user wants to see in the link chart, not how to generate it.")}),Ga=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),{view:o}=V(t);if(A(o))return{toolName:J,status:"error",errorMessage:"The createLinkChart tool can only be used with a LinkChartView.",error:new Error};{let a=F.getDefault().helperServices,n=await Oa(`${e}
130
130
 
131
- ${Ze}`,r,`${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,o,t);if(n.type==="error")return{toolName:J,status:"error",errorMessage:n.errorMessage,error:new Error};let{graphQuery:l,explanation:i}=n;return{toolName:J,status:"success",summary:`Link chart created successfully. Cypher Query used to create the link chart:
132
- ${l}
131
+ ${Ze}`,r,`${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,o,t);if(n.type==="error")return{toolName:J,status:"error",errorMessage:n.errorMessage,error:new Error};let{graphQuery:s,explanation:i}=n;return{toolName:J,status:"success",summary:`Link chart created successfully. Cypher Query used to create the link chart:
132
+ ${s}
133
133
 
134
- Explanation: ${i}`,details:{generatedQuery:l,explanation:i}}}},$s=y(Ga,{name:J,description:"Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt using language like 'create new link chart' or 'add to new link chart'.",schema:Pa}),he="queryGraphData",Va=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. Only include entity types, relationship types or properties if they are provided in the user prompt or prior steps. Do not suggest entity types, relationship types or properties. Do not include limits, information on what to return, instructions on how to write the query, or formatting instructions for the query results unless specifically requested by the user.")}),Qa=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),o=F.getDefault().helperServices,a=e,n=null,l=null;try{({view:l}=V(t))}catch{}l&&({enhancedPrompt:a,bindParameters:n}=await Ye({prompt:e,view:l,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:!1}));let i=await Je({prompt:a,bindParameters:n,kg:r,graphQueryServiceUrl:`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,targetStructure:new Array,targetStructureReducer:(h,v)=>(h.push(v),h),requestOptions:{signal:re(t),timeout:t?.timeout},config:t});if(i.type!=="success"){let h=i.type==="generation-error"?i.errorMessage:`${i.errorMessage} Cypher query: ${i.graphQuery}`;return{toolName:he,status:"error",errorMessage:`Failed to query the knowledge graph. ${h}`,error:"error"in i?i.error:null}}let{graphQuery:u,explanation:c,processedResult:d,resultHeader:m}=i,p=m.headerKeys;for(let h of d)for(let v of h)q(v,g=>He(g));let w=50,f=d.slice(0,w).map(h=>JSON.stringify(h));return{toolName:he,status:"success",summary:`To answer the inquiry, the following cypher query was executed against the knowledge graph:
134
+ Explanation: ${i}`,details:{generatedQuery:s,explanation:i}}}},$s=y(Ga,{name:J,description:"Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt using language like 'create new link chart' or 'add to new link chart'.",schema:Pa}),he="queryGraphData",Va=l.object({prompt:l.string().describe("The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. Only include entity types, relationship types or properties if they are provided in the user prompt or prior steps. Do not suggest entity types, relationship types or properties. Do not include limits, information on what to return, instructions on how to write the query, or formatting instructions for the query results unless specifically requested by the user.")}),Qa=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),o=F.getDefault().helperServices,a=e,n=null,s=null;try{({view:s}=V(t))}catch{}s&&({enhancedPrompt:a,bindParameters:n}=await Ye({prompt:e,view:s,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:!1}));let i=await Je({prompt:a,bindParameters:n,kg:r,graphQueryServiceUrl:`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,targetStructure:new Array,targetStructureReducer:(h,v)=>(h.push(v),h),requestOptions:{signal:re(t),timeout:t?.timeout},config:t});if(i.type!=="success"){let h=i.type==="generation-error"?i.errorMessage:`${i.errorMessage} Cypher query: ${i.graphQuery}`;return{toolName:he,status:"error",errorMessage:`Failed to query the knowledge graph. ${h}`,error:"error"in i?i.error:null}}let{graphQuery:u,explanation:c,processedResult:d,resultHeader:m}=i,p=m.headerKeys;for(let h of d)for(let v of h)R(v,g=>He(g));let w=50,f=d.slice(0,w).map(h=>JSON.stringify(h));return{toolName:he,status:"success",summary:`To answer the inquiry, the following cypher query was executed against the knowledge graph:
135
135
 
136
136
  \`\`\`cypher
137
137
  ${u}
@@ -148,16 +148,16 @@ ${f.length>w?`Showing top ${w} results:
148
148
 
149
149
  `}${f.join(`
150
150
  `)}
151
- `,details:{generatedQuery:u,explanation:c,resultHeader:m,queryResults:d}}},Fs=y(Qa,{name:he,description:"Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",schema:Va}),fe="generateCypher",Ba=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")}),Ua=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),o=F.getDefault().helperServices;try{let{graphQuery:a,explanation:n}=await Ta(e,r.dataModel,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,t);return{toolName:fe,status:"success",summary:`Generated Graph Query:
151
+ `,details:{generatedQuery:u,explanation:c,resultHeader:m,queryResults:d}}},Fs=y(Qa,{name:he,description:"Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",schema:Va}),fe="generateCypher",Ba=l.object({prompt:l.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")}),Ua=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t),o=F.getDefault().helperServices;try{let{graphQuery:a,explanation:n}=await Ta(e,r.dataModel,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,t);return{toolName:fe,status:"success",summary:`Generated Graph Query:
152
152
  ${a}
153
153
 
154
154
  Explanation: ${n}`,details:{generatedQuery:a,explanation:n}}}catch(a){let n=_(a);return{toolName:fe,status:"error",errorMessage:`Failed to generate Cypher query. ${n}`,error:a}}},Ms=y(Ua,{name:fe,description:"Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",schema:Ba}),Ka=e=>{let t=e.dataModel,r=new Map;for(let i of t.searchIndexes)if(i.supportedCategory!=="esriTypeMetaEntityProvenance")for(let[u,c]of i.searchProperties.entries()){let d=r.get(u)??new Set;c.propertyNames.forEach(m=>d.add(m)),r.set(u,d)}let o=t.entityTypes.filter(i=>r.has(i.name)),a=t.relationshipTypes.filter(i=>r.has(i.name)),n=`Entity Types:
155
155
  ${o.map(({name:i})=>`${i}: [${Array.from(r.get(i)??[]).join(", ")}]`).join(`
156
- `)}`,l=`Relationship Types:
156
+ `)}`,s=`Relationship Types:
157
157
  ${a.map(({name:i})=>`${i}: [${Array.from(r.get(i)??[]).join(", ")}]`).join(`
158
158
  `)}`;return`${n}
159
159
 
160
- ${l}`};async function Wa(e,t,r){let o=await Z("arcgis_knowledge_lucene_generation_prompt"),a={inquiry:e,dataModelForSearch:Ka(t)},n=s.enum(["entity","relationship","both"]).describe("The graph element category to search against - entity, relationship, or both"),l=s.number().int().positive().nullable().describe("The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."),i=s.array(s.enum(t.dataModel.entityTypes.map(c=>c.name).concat(t.dataModel.relationshipTypes.map(c=>c.name)))).min(1),u=s.object({query:s.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),typeFilters:i.nullable().describe("Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"),typeCategoryFilter:n,resultLimit:l});return await Ie({promptText:o,inputVariables:a,schema:u,config:r})}var ye="searchGraphData",Ha=s.object({prompt:s.string().describe("The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results.")}),Ja=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t);await S({text:"Generating search query for the user inquiry"},t);let o=await Wa(e,r,t);await S({text:"Executing graph search with generated search query"},t);let a=await Ma({kg:r,searchQuery:o.query,typeCategoryFilter:o.typeCategoryFilter,namedTypesFilter:o.typeFilters,searchResultLimit:o.resultLimit,requestOptions:{signal:re(t),timeout:t?.timeout}});if(a.type!=="success")return{toolName:ye,status:"error",errorMessage:a.errorMessage,error:"error"in a?a.error:null};for(let i of a.results)q(i,u=>He(u));let n=10,l=a.results.slice(0,n);return{toolName:ye,status:"success",summary:`To answer the query, the following lucene query was generated and executed:
160
+ ${s}`};async function Wa(e,t,r){let o=await Z("arcgis_knowledge_lucene_generation_prompt"),a={inquiry:e,dataModelForSearch:Ka(t)},n=l.enum(["entity","relationship","both"]).describe("The graph element category to search against - entity, relationship, or both"),s=l.number().int().positive().nullable().describe("The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."),i=l.array(l.enum(t.dataModel.entityTypes.map(c=>c.name).concat(t.dataModel.relationshipTypes.map(c=>c.name)))).min(1),u=l.object({query:l.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),typeFilters:i.nullable().describe("Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"),typeCategoryFilter:n,resultLimit:s});return await Ie({promptText:o,inputVariables:a,schema:u,config:r})}var ye="searchGraphData",Ha=l.object({prompt:l.string().describe("The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results.")}),Ja=async({prompt:e},t)=>{let{knowledgeGraph:r}=await Q(t);await S({text:"Generating search query for the user inquiry"},t);let o=await Wa(e,r,t);await S({text:"Executing graph search with generated search query"},t);let a=await Ma({kg:r,searchQuery:o.query,typeCategoryFilter:o.typeCategoryFilter,namedTypesFilter:o.typeFilters,searchResultLimit:o.resultLimit,requestOptions:{signal:re(t),timeout:t?.timeout}});if(a.type!=="success")return{toolName:ye,status:"error",errorMessage:a.errorMessage,error:"error"in a?a.error:null};for(let i of a.results)R(i,u=>He(u));let n=10,s=a.results.slice(0,n);return{toolName:ye,status:"success",summary:`To answer the query, the following lucene query was generated and executed:
161
161
  Query: ${o.query}
162
162
  Type Category Filter: ${o.typeCategoryFilter}
163
163
  Named Type Filters: ${o.typeFilters?o.typeFilters.join(", "):"None"}
@@ -167,7 +167,7 @@ ${l}`};async function Wa(e,t,r){let o=await Z("arcgis_knowledge_lucene_generatio
167
167
 
168
168
  ${a.results.length>n?`Showing top ${n} results:
169
169
 
170
- `:""}${l.map(i=>JSON.stringify(i)).join(`
170
+ `:""}${s.map(i=>JSON.stringify(i)).join(`
171
171
  `)}`,details:{generatedSearchQuery:o,searchResults:a.results}}},As=y(Ja,{name:ye,description:`
172
172
  Search the knowledge graph using one or more search texts, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.
173
173
  Example prompts: