/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import{b as v}from"./POZ7OKIJ.js";import c from"./SJIHZIXG.js";import b from"./MZWO5JYA.js";import a from"./OKHEBRQW.js";import{a as d}from"./VJVKFKSG.js";import{O as x,U as k,a as T,b as o}from"./IXZEUVT2.js";import"./H6RQVSYM.js";export default $arcgis.t(([{watch:w,when:I},L,A,E,{compileExpression:J},{b:m,e:f},,{p:y}])=>{var b=T`.loading-container{display:flex;justify-content:center;padding:var(--calcite-spacing-md) 0;width:100%}`,$=1,g=class extends x{constructor(){super(...arguments),this._compileThrottled=v(this._startCompile,$),this._evaluateThrottled=v(this._startEvaluate,$),this.headingLevel=2}static{this.properties={_compileTask:16,_evaluateTask:16,values:0,fieldInfoMap:0,expressionInfo:0,graphic:0,headingLevel:9,interceptor:0,location:0,messages:0,spatialReference:0,map:0,view:0}}static{this.styles=b}loaded(){this.manager.onLifecycle(()=>[w(()=>[this.expressionInfo,this.graphic],()=>this._compileThrottled(),{initial:!0}),I(()=>{if(!this._compileTask?.finished)return null;let t=this._compileTask.value,s=t?.dependencies,{view:e}=this;return[t,this.spatialReference,this.map,e,s?.has("view-scale")&&e&&"scale"in e?e.scale:null,s?.has("view-time-extent")?e?.timeExtent?.start:null,s?.has("view-time-extent")?e?.timeExtent?.end:null]},([t])=>this._evaluateThrottled(t)),{remove:()=>this._cancelThrottles()}])}_cancelThrottles(){this._compileThrottled.cancel(),this._evaluateThrottled.cancel()}_startCompile(){this._evaluateTask=d(this._evaluateTask),this._compileTask=d(this._compileTask),this._compileTask=f(async t=>{let{expressionInfo:s,graphic:e}=this,i=s?.expression;if(!i||!e)return null;let a=await J({expression:i,graphic:e});return m(t),a})}_startEvaluate(t){this._evaluateTask=d(this._evaluateTask),this._evaluateTask=f(async s=>{let{graphic:e}=this;if(!t||!e)return null;let{interceptor:i,spatialReference:a,map:r,location:c,view:l}=this,h=await t.evaluate({graphic:e,interceptor:i,location:c,map:r,options:{signal:s},spatialReference:a,view:l});m(s);let _=h&&"castAsJsonAsync"in h&&typeof h.castAsJsonAsync=="function"?h:null;if(!_)return null;let p=await _.castAsJsonAsync(s);m(s);let u=p?.type,n=u==="media"?L.fromJSON(p):u==="text"?E.fromJSON(p):u==="fields"?A.fromJSON(p):null;return!n||n.type==="media"&&!n.mediaInfos||n.type==="fields"&&!n.fieldInfos||n.type==="text"&&!n.text?null:n})}render(){let t=!this._compileTask?.finished||!this._evaluateTask?.finished;return o`<div class="root">${t?this._renderLoading():this._evaluateTask?.value?this._renderContent():null}</div>`}_renderContent(){let{values:t,fieldInfoMap:s}=this,e=this._evaluateTask?.value,i=e?.type,a={...t,...e?.attributes};if(!i)return null;if(i==="text"){let r=y({values:a,fieldInfoMap:s??new Map,globalValues:a,layer:void 0,text:e.text});return o`<arcgis-feature-content .creator=${r} .graphic=${this.graphic}></arcgis-feature-content>`}else if(i==="media"){let{title:r,description:c,mediaInfos:l}=e;return l?.length?o`<arcgis-feature-media .heading=${r??""} .values=${a} .formattedValues=${a} .description=${c??""} .mediaInfos=${l} .messages=${this.messages} .headingLevel=${this.headingLevel}></arcgis-feature-media>`:null}else if(i==="fields"){let{title:r,description:c,fieldInfos:l}=e;return l?.length?o`<arcgis-feature-fields .fieldInfos=${l} .heading=${r??""} .values=${a} .description=${c??""} .headingLevel=${this.headingLevel} .messages=${this.messages}></arcgis-feature-fields>`:null}return null}_renderLoading(){return o`<div class="loading-container"><calcite-loader inline label></calcite-loader></div>`}};k("arcgis-feature-expression",g);return g},"core/reactiveUtils","popup/content/MediaContent","popup/content/FieldsContent","popup/content/TextContent","applications/Components/arcadeFeatureUtils",a,b,c)