@arcgis/core 4.27.0 → 4.27.2

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 (62) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/07f52b140db07fa962bb.js +1 -0
  3. package/assets/esri/core/workers/chunks/2d19500b2c042b6b79ac.js +1 -0
  4. package/assets/esri/core/workers/chunks/{979d9f37c555df0e8fa6.js → 7adbd577bb58c3bbaf28.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{588cd91d08cec5207be1.js → 873b608720cce890e572.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{9d4bd73dd50400e9d328.js → 9c8ab6bd8c170cbc5fa5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/da2110b4caff9cc9b116.js +1 -0
  8. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +1 -1
  9. package/assets/esri/themes/base/widgets/_Feature.scss +1 -1
  10. package/assets/esri/themes/base/widgets/_ValuePicker.scss +5 -2
  11. package/assets/esri/themes/dark/main.css +1 -1
  12. package/assets/esri/themes/light/main.css +1 -1
  13. package/assets/esri/themes/light/view.css +1 -1
  14. package/chunks/Pattern.glsl.js +33 -32
  15. package/interfaces.d.ts +42 -12
  16. package/kernel.js +1 -1
  17. package/layers/SceneLayer.js +1 -1
  18. package/layers/VideoLayer.js +1 -1
  19. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  20. package/layers/support/ElevationQuery.js +1 -1
  21. package/layers/support/TelemetryData.js +1 -1
  22. package/layers/support/TelemetryDisplay.js +1 -1
  23. package/layers/support/imageryRendererUtils.js +1 -1
  24. package/layers/video/videoUtils.js +1 -1
  25. package/package.json +1 -1
  26. package/renderers/support/colorRampUtils.js +1 -1
  27. package/support/revision.js +1 -1
  28. package/views/2d/layers/MediaLayerView2D.js +1 -1
  29. package/views/2d/layers/TileLayerView2D.js +1 -1
  30. package/views/3d/layers/graphics/Labeler.js +1 -1
  31. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  32. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  33. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  34. package/views/3d/layers/i3s/featureEditing.js +1 -1
  35. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  36. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  37. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  38. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  39. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  40. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  41. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  42. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  43. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  44. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  45. package/views/webgl/AppleAmdDriverHelper.js +5 -0
  46. package/views/webgl/testAppleAmdDrawArrays.js +1 -1
  47. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  48. package/widgets/Attachments.js +1 -1
  49. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  50. package/widgets/Editor/UpdateWorkflow.js +1 -1
  51. package/widgets/Editor.js +1 -1
  52. package/widgets/Feature/FeatureAttachments.js +1 -1
  53. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  54. package/widgets/Feature/support/relatedFeatureUtils.js +1 -1
  55. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  56. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  57. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  58. package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
  59. package/assets/esri/core/workers/chunks/17ab08f60764244b2cf8.js +0 -1
  60. package/assets/esri/core/workers/chunks/38c6452dc9cf18e8bca8.js +0 -1
  61. package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +0 -1
  62. package/views/3d/webgl-engine/lib/AppleAmdDriverHelper.js +0 -5
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as a,on as i,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as w}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as k}from"./Editor/modelUploadUtils.js";import{renderItem as y,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:a,viewModel:i,visibleElements:r}=this,l=i.sketchViewModel,c=i.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:a.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},a.undo),L("calcite-button",{key:"redo-button",label:a.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},a.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&k(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([a((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),a((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),i((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return w(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return w(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return w(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:a,_onBack:i,viewModel:r}=this;if(!t)return null;const l=t.type,c="activeWorkflow"in t?t.activeWorkflow?.type:null,d=r.featureFormViewModel,p="update"===l&&!t.hasPendingEdits||r.syncing||d.updating,m="update"===l?o.editFeature:o.createFeatures,h="update"===l&&"create-features"!==c?n.update:n.create,u="create-features"===l&&"create-new"===t.createFeatureState,g="create-features"===l?t.numPendingFeatures:0,_=g>1?S(o.createFeaturesTemplate,{numFeatures:g}):h,f=t.shouldShowAttachments,w=d.inputs.every((e=>!e.visible))&&!f?this._renderMessage(S(o.clickToFinishTemplate,{button:h})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),f&&L("div",{key:"attachments"},L(F,{level:M(a)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:m,headingLevel:a,handleBack:i},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:u})},w,u&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:p,label:_,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesCommon:i}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:a.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?i.cancel:i.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:a,messages:i,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:i.editAttachment,headingLevel:a,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...a},i)=>L("calcite-button",{key:`action-${i}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...a},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,a=n.secondary;let i;switch(o){case"danger":i="danger";break;case"info":i="brand";break;default:i="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:i,onclick:n.primary.action,scale:"m",width:a?"half":"full"},n.primary.label),l=a&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:i,onclick:a.action,scale:"m",width:"half"},a.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:a}=n,i=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!a&&0===i;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},a&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),i>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},y({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesTemplates:i,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(a.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,a=l.find((e=>e.layer===s.layer));if(!a)return null;const{attachmentsOnUpdateEnabled:i,supports:r}=a;return(r.includes("update")||r.includes("delete")||i)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,a=m(t);return a&&n[a]&&`${n[a]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const a=n(),{view:i}=this,r=i?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}},a.promise.finally((()=>{this._clearPrompt(),r&&i?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as a,on as i,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as w}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as k}from"./Editor/modelUploadUtils.js";import{renderItem as y,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as L}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...$},this._renderSelectIcon=()=>I("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:a,viewModel:i,visibleElements:r}=this,l=i.sketchViewModel,c=i.syncing||this._attachments.submitting;return I("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},I("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[I("calcite-button",{key:"undo-button",label:a.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},a.undo),I("calcite-button",{key:"redo-button",label:a.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},a.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&k(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([a((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),a((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),i((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return w(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return w(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return w(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return I("div",{key:"empty",class:D.base});const{state:t}=e;return I("div",{key:"base",class:D.base},I("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return I("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return I(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},I("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:a,_onBack:i,viewModel:r}=this;if(!t)return null;const l=t.type,c="activeWorkflow"in t&&t.activeWorkflow,d=c?c.type:null,p=r.featureFormViewModel,m=c&&!c.hasPendingEdits||"update"===l&&!t.hasPendingEdits||r.syncing||p.updating,h="update"===l?o.editFeature:o.createFeatures,u="update"===l&&"create-features"!==d?n.update:n.create,g="create-features"===l&&"create-new"===t.createFeatureState,_="create-features"===l?t.numPendingFeatures:0,f=_>1?S(o.createFeaturesTemplate,{numFeatures:_}):u,w=t.shouldShowAttachments&&!r.featureFormViewModel.activeRelationshipInput,v=p.inputs.every((e=>!e.visible))&&!w?this._renderMessage(S(o.clickToFinishTemplate,{button:u})):I("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),I("div",{class:D.panelContentSectionGroup},this._featureForm.render(),w&&I("div",{key:"attachments"},I(F,{level:M(a)},o.attachments),this._attachments.render())));return I(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:a,handleBack:i},I("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:g})},v,g&&I("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:m,label:f,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return I("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},I("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesCommon:i}=this;return I(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:a.addAttachment,headingLevel:n,handleBack:o},I("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?i.cancel:i.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:a,messages:i,messagesCommon:r}=this;return n?I(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:i.editAttachment,headingLevel:a,handleBack:o},I("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return I("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return I("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...a},i)=>I("calcite-button",{key:`action-${i}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...a},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,a=n.secondary;let i;switch(o){case"danger":i="danger";break;case"info":i="brand";break;default:i="neutral"}const r=I("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:i,onclick:n.primary.action,scale:"m",width:a?"half":"full"},n.primary.label),l=a&&I("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:i,onclick:a.action,scale:"m",width:"half"},a.label);return I("calcite-scrim",{key:"prompt"},I("div",{class:`${D.promptContainer}--${o}`},I("div",{class:D.promptHeader},I("calcite-icon",{icon:O}),I(F,{class:D.promptHeading,level:this.headingLevel},t)),I("div",{class:D.promptMessage},s),I("div",{class:D.promptDivider}),I("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:a}=n,i=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!a&&0===i;return I(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},I("div",{key:"landing-content",class:D.panelContent},a&&I("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),i>0&&I("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&I("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?I("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return I("div",{key:"update-actions"},I(F,{level:M(this.headingLevel)},t.editFeatures),I("calcite-list",{selectionMode:"single",selectionAppearance:"border"},y({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return I("div",{key:"create-actions"},I(F,{level:M(t)},s.createFeatures),I("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=I("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return I("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return I("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return I("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesTemplates:i,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(a.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,a=l.find((e=>e.layer===s.layer));if(!a)return null;const{attachmentsOnUpdateEnabled:i,supports:r}=a;return(r.includes("update")||r.includes("delete")||i)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return I(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},I("div",{key:"feature-list",class:D.panelContent},I("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?I("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},I("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&I(L,{tooltipOptions:this.tooltipOptions}),t&&I(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,a=m(t);return a&&n[a]&&`${n[a]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const a=n(),{view:i}=this,r=i?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}},a.promise.finally((()=>{this._clearPrompt(),r&&i?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as i}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Attachments.js";import a from"../Widget.js";import p from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import n from"./support/FeatureElementInfo.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";const d={base:"esri-feature-attachments"};let c=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attachmentsWidget=new o,this.headingLevel=2,this.viewModel=new p}initialize(){this._featureElementInfo=new n,this.addHandles([t((()=>[this.viewModel?.description,this.viewModel?.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),i),t((()=>this.viewModel),(e=>this.attachmentsWidget.viewModel=e),i)])}destroy(){this.attachmentsWidget.destroy(),this._featureElementInfo?.destroy()}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get displayType(){return this.attachmentsWidget.displayType}set displayType(e){this.attachmentsWidget.displayType=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){const{attachmentsWidget:e}=this;return l("div",{class:d.base},this._featureElementInfo?.render(),e?.render())}_setupFeatureElementInfo(){const{description:e,title:t,headingLevel:i}=this;this._featureElementInfo?.set({description:e,title:t,headingLevel:i})}};e([s({readOnly:!0})],c.prototype,"attachmentsWidget",void 0),e([s()],c.prototype,"description",null),e([s()],c.prototype,"displayType",null),e([s()],c.prototype,"graphic",null),e([s()],c.prototype,"headingLevel",void 0),e([s()],c.prototype,"title",null),e([s({type:p})],c.prototype,"viewModel",void 0),c=e([r("esri.widgets.Feature.FeatureAttachments")],c);const h=c;export{h as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as i}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as r}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Attachments.js";import a from"../Widget.js";import n from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import p from"./support/FeatureElementInfo.js";import"../support/widgetUtils.js";import{tsx as l}from"../support/jsxFactory.js";const d={base:"esri-feature-attachments"};let c=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.attachmentsWidget=new o,this.headingLevel=2,this.viewModel=new n}initialize(){this._featureElementInfo=new p,this.addHandles([t((()=>[this.viewModel?.description,this.viewModel?.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),i),t((()=>this.viewModel),(e=>this.attachmentsWidget.viewModel=e),i)])}destroy(){this.attachmentsWidget.viewModel=null,this.attachmentsWidget.destroy(),this._featureElementInfo?.destroy()}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get displayType(){return this.attachmentsWidget.displayType}set displayType(e){this.attachmentsWidget.displayType=e}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){const{attachmentsWidget:e}=this;return l("div",{class:d.base},this._featureElementInfo?.render(),e?.render())}_setupFeatureElementInfo(){const{description:e,title:t,headingLevel:i}=this;this._featureElementInfo?.set({description:e,title:t,headingLevel:i})}};e([s({readOnly:!0})],c.prototype,"attachmentsWidget",void 0),e([s()],c.prototype,"description",null),e([s()],c.prototype,"displayType",null),e([s()],c.prototype,"graphic",null),e([s()],c.prototype,"headingLevel",void 0),e([s()],c.prototype,"title",null),e([s({type:n})],c.prototype,"viewModel",void 0),c=e([r("esri.widgets.Feature.FeatureAttachments")],c);const h=c;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as y}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as b}from"../support/featureUtils.js";import{parseFormTemplateString as g,getFieldsInTitleAndDesc as F}from"../../FeatureForm/featureFormUtils.js";const _=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=u(this._queryController,_),this._queryFeatureCountDebounced=u(this._queryFeatureCountController,_),this._queryPageDebounced=u(this._queryPageController,_),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.handles.add([d((()=>[this.displayCount,this.graphic,this.layer,this.map,this.orderByFieldsFixedCasing,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),y),d((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),d((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>({feature:t,description:e?t.getAttribute(e):void 0,title:l?g(l,t.attributes,r.fieldsIndex):void 0}))).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?b(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,b=r?l:a,g=d.objectIdField,_=[...t.map((e=>e.field)),...F(d),g].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),q=new c({orderByFields:m,start:C,num:b,outFields:_,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:f.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_loaded",void 0),e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canLoad",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const f=m;export{f as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as y}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as b}from"../support/featureUtils.js";import{getComputedAttributes as g,parseFormTemplateString as _,getFieldsInTitleAndDesc as F}from"../../FeatureForm/featureFormUtils.js";const f=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=u(this._queryController,f),this._queryFeatureCountDebounced=u(this._queryFeatureCountController,f),this._queryPageDebounced=u(this._queryPageController,f),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.handles.add([d((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),y),d((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),d((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>{let o;if(e){const l=t.getAttribute(e),a=r.fieldsIndex.get(e);if(a){const t=g([l],[a])[e];null!=t&&(o=t.toString())}}return{feature:t,description:o,title:l?_(l,t.attributes,r.fieldsIndex):void 0}})).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?b(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,b=r?l:a,g=d.objectIdField,_=[...t.map((e=>e.field)),...F(d),g].filter(o),f=t.map((e=>`${e.field} ${e.order}`)),m=d.createQuery(),q=new c({orderByFields:f,start:C,num:b,outFields:_,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:m.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_loaded",void 0),e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canLoad",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const q=m;export{q as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../request.js";import t from"../../../core/Error.js";import r from"../../../core/Logger.js";import{whenOrAbort as s,eachAlways as o}from"../../../core/promiseUtils.js";import{isNumericField as i}from"../../../layers/support/fieldUtils.js";import"../../../core/has.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as n}from"../../../rest/query/executeQueryJSON.js";import"../../../config.js";import"../../../kernel.js";import"../../../core/arrayUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../layers/graphics/featureConversionUtils.js";import"../../../geometry/Extent.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Point.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../geometry/support/normalizeUtils.js";import"../../../core/pbf.js";import"../../../rest/support/FeatureSet.js";import a from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import"../../../geometry.js";import l from"../../../rest/support/RelationshipQuery.js";import"../../../rest/support/TopFeaturesQuery.js";import u from"../../../rest/support/StatisticDefinition.js";import{isRelatedField as p}from"./featureUtils.js";const c="esri.widgets.Feature.support.relatedFeatureUtils",f=r.getLogger(c),d=new Map;function m(e){if(!p(e))return null;const[t,r]=e.split("/").slice(1);return{layerId:t,fieldName:r}}function y(e,t){if(!t.relationships)return null;let r=null;const{relationships:s}=t;return s.some((t=>t.id===parseInt(e,10)&&(r=t,!0))),r}function j({originRelationship:e,relationships:t,layerId:r}){let s=null;return t&&t.some((t=>(`${t.relatedTableId}`===r&&t.id===e?.id&&(s=t),!!s))),s}function h(e,t){const r=t.toLowerCase();for(const s in e)if(s.toLowerCase()===r)return e[s];return null}function g(e,t){const r=y(e,t);if(!r)return;return{url:`${t.url}/${r.relatedTableId}`,sourceSpatialReference:t.spatialReference,relation:r,relatedFields:[],outStatistics:[]}}function F(e,t){if(!t)return;if(!e)return;const{features:r,statsFeatures:s}=e,o=r&&r.value;t.relatedFeatures=o?o.features:[];const i=s&&s.value;t.relatedStatsFeatures=i?i.features:[]}function I(e,t,r,s){const o=new l;return o.outFields=["*"],o.relationshipId="number"==typeof t.id?t.id:parseInt(t.id,10),o.objectIds=[e.attributes[r.objectIdField]],r.queryRelatedFeatures?.(o,s)??Promise.resolve({})}function S(e,t,r){let s=0;const o=[];for(;s<t.length;)o.push(`${e} IN (${t.slice(s,r+s)})`),s+=r;return o.join(" OR ")}async function w(e,t,r,s){const l=r.layerId.toString(),{layerInfo:u,relation:p,relatedFields:c,outStatistics:f,url:d,sourceSpatialReference:m}=t;if(!u||!p)return null;const y=j({originRelationship:p,relationships:u.relationships,layerId:l});if(y?.relationshipTableId&&y.keyFieldInRelationshipTable){const t=(await I(e,y,r,s))[e.attributes[r.objectIdField]];if(!t)return null;const i=t.features.map((e=>e.attributes[u.objectIdField]));if(f?.length&&u.supportsStatistics){const e=new a;e.where=S(u.objectIdField,i,1e3),e.outFields=c,e.outStatistics=f,e.sourceSpatialReference=m;const r={features:Promise.resolve(t),statsFeatures:n(d,e)};return o(r)}}const g=y?.keyField;if(g){const r=i(T(u.fields,g)),l=h(e.attributes,p.keyField),c=r?`${g}=${l}`:`${g}='${l}'`,f=n(d,new a({where:c,outFields:t.relatedFields,sourceSpatialReference:m}),s),y=t.outStatistics&&t.outStatistics.length>0&&u.supportsStatistics?n(d,new a({where:c,outFields:t.relatedFields,outStatistics:t.outStatistics,sourceSpatialReference:m}),s):null,j={features:f};return y&&(j.statsFeatures=y),o(j)}return null}function b(t,r){return e(t,{query:{f:"json"},signal:r&&r.signal})}function R({relatedInfos:e,layer:r},i){const n={};return e.forEach(((e,s)=>{const{relation:o}=e;if(!o){const e=new t("relation-required","A relation is required on a layer to retrieve related records.");throw f.error(e),e}const{relatedTableId:a}=o;if("number"!=typeof a){const e=new t("A related table ID is required on a layer to retrieve related records.");throw f.error(e),e}const l=`${r.url}/${a}`,u=d.get(l),p=u??b(l,i);u||d.set(l,p),n[s]=p})),s(o(n),i)}function $({graphic:e,relatedInfos:t,layer:r},s){const i={};return t.forEach(((t,o)=>{t.layerInfo&&(i[o]=w(e,t,r,s))})),o(i)}function U({relatedInfo:e,fieldName:t,fieldInfo:r}){if(e.relatedFields?.push(t),r.statisticType){const s=new u({statisticType:r.statisticType,onStatisticField:t,outStatisticFieldName:t});e.outStatistics?.push(s)}}function T(e,t){if(null!=e){t=t.toLowerCase();for(const r of e)if(r&&r.name.toLowerCase()===t)return r}return null}export{g as createRelatedInfo,j as getDestinationRelation,m as getRelatedFieldInfo,R as queryLayerInfos,$ as queryRelatedFeatures,F as setRelatedFeatures,U as updateRelatedInfo};
5
+ import e from"../../../request.js";import t from"../../../core/Error.js";import r from"../../../core/Logger.js";import{whenOrAbort as s,eachAlways as o}from"../../../core/promiseUtils.js";import{isNumericField as i}from"../../../layers/support/fieldUtils.js";import"../../../core/has.js";import"../../../layers/support/source/DataLayerSource.js";import{executeQueryJSON as n}from"../../../rest/query/executeQueryJSON.js";import"../../../config.js";import"../../../kernel.js";import"../../../core/arrayUtils.js";import"../../../core/urlUtils.js";import"../../../core/unitUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../layers/graphics/featureConversionUtils.js";import"../../../geometry/Extent.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Point.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../geometry/support/normalizeUtils.js";import"../../../core/pbf.js";import"../../../rest/support/FeatureSet.js";import a from"../../../rest/support/Query.js";import"../../../rest/query/support/AttachmentInfo.js";import"../../../rest/support/AttachmentQuery.js";import"../../../geometry.js";import l from"../../../rest/support/RelationshipQuery.js";import"../../../rest/support/TopFeaturesQuery.js";import u from"../../../rest/support/StatisticDefinition.js";import{isRelatedField as p}from"./featureUtils.js";const c="esri.widgets.Feature.support.relatedFeatureUtils",f=r.getLogger(c),d=new Map;function m(e){if(!p(e))return null;const[t,r]=e.split("/").slice(1);return{layerId:t,fieldName:r}}function y(e,t){if(!t.relationships)return null;let r=null;const{relationships:s}=t;return s.some((t=>t.id===parseInt(e,10)&&(r=t,!0))),r}function j({originRelationship:e,relationships:t,layerId:r}){let s=null;return t&&t.some((t=>(`${t.relatedTableId}`===r&&t.id===e?.id&&(s=t),!!s))),s}function h(e,t){const r=t.toLowerCase();for(const s in e)if(s.toLowerCase()===r)return e[s];return null}function g(e,t){const r=y(e,t);if(!r)return;return{url:`${t.url}/${r.relatedTableId}`,sourceSpatialReference:t.spatialReference,relation:r,relatedFields:[],outStatistics:[]}}function F(e,t){if(!t)return;if(!e)return;const{features:r,statsFeatures:s}=e,o=r&&r.value;t.relatedFeatures=o?o.features:[];const i=s&&s.value;t.relatedStatsFeatures=i?i.features:[]}function I(e,t,r,s){const o=new l;return o.outFields=["*"],o.relationshipId="number"==typeof t.id?t.id:parseInt(t.id,10),o.objectIds=[e.attributes[r.objectIdField]],r.queryRelatedFeatures?.(o,s)??Promise.resolve({})}function S(e,t,r){let s=0;const o=[];for(;s<t.length;)o.push(`${e} IN (${t.slice(s,r+s)})`),s+=r;return o.join(" OR ")}async function w(e,t,r,s){const l=r.layerId.toString(),{layerInfo:u,relation:p,relatedFields:c,outStatistics:f,url:d,sourceSpatialReference:m}=t;if(!u||!p)return null;const y=j({originRelationship:p,relationships:u.relationships,layerId:l});if(y?.relationshipTableId&&y.keyFieldInRelationshipTable){const t=(await I(e,y,r,s))[e.attributes[r.objectIdField]];if(!t)return null;const i=t.features.map((e=>e.attributes[u.objectIdField]));if(f?.length&&u.supportsStatistics){const e=new a;e.where=S(u.objectIdField,i,1e3),e.outFields=c,e.outStatistics=f,e.sourceSpatialReference=m;const r={features:Promise.resolve(t),statsFeatures:n(d,e)};return o(r)}}const g=y?.keyField;if(g){const r=i(T(u.fields,g)),l=h(e.attributes,p.keyField),c=r?`${g}=${l}`:`${g}='${l}'`,f=n(d,new a({where:c,outFields:t.relatedFields,sourceSpatialReference:m}),s),y=t.outStatistics&&t.outStatistics.length>0&&u.supportsStatistics?n(d,new a({where:c,outFields:t.relatedFields,outStatistics:t.outStatistics,sourceSpatialReference:m}),s):null,j={features:f};return y&&(j.statsFeatures=y),o(j)}return null}function b(t,r){return e(t,{query:{f:"json"},signal:r&&r.signal})}function R({relatedInfos:e,layer:r},i){const n={};return e.forEach(((e,s)=>{const{relation:o}=e;if(!o){const e=new t("relation-required","A relation is required on a layer to retrieve related records.");throw f.error(e),e}const{relatedTableId:i}=o;if("number"!=typeof i){const e=new t("A related table ID is required on a layer to retrieve related records.");throw f.error(e),e}const a=`${r.url}/${i}`,l=d.get(a),u=l??b(a);l||d.set(a,u),n[s]=u})),s(o(n),i)}function $({graphic:e,relatedInfos:t,layer:r},s){const i={};return t.forEach(((t,o)=>{t.layerInfo&&(i[o]=w(e,t,r,s))})),o(i)}function U({relatedInfo:e,fieldName:t,fieldInfo:r}){if(e.relatedFields?.push(t),r.statisticType){const s=new u({statisticType:r.statisticType,onStatisticField:t,outStatisticFieldName:t});e.outStatistics?.push(s)}}function T(e,t){if(null!=e){t=t.toLowerCase();for(const r of e)if(r&&r.name.toLowerCase()===t)return r}return null}export{g as createRelatedInfo,j as getDestinationRelation,m as getRelatedFieldInfo,R as queryLayerInfos,$ as queryRelatedFeatures,F as setRelatedFeatures,U as updateRelatedInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n,s,i],[o,r,a,l,u])=>e===o&&t===r&&n===a&&s===l&&i===u,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o}=this;if(!o)return;const r={arcadeEditType:n,feature:e,initialFeature:t,layer:o},a=i.slice(),l=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(a,s.elements,r):this._updateInputsUsingLayerFields(a,o?.fields,r);this.inputs=l}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../layers/support/layerUtils.js";import l from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as a}from"../Feature/support/featureUtils.js";import n from"./EditableInput.js";const p=3;let u=class extends n{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship||!this.loaded)return!1;const{cardinality:s,role:i}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===i&&t>0)&&e))}get displayCount(){return this.element.displayCount??p}get displayType(){return this.element.displayType}get editable(){if(!this.layerAllowsEdits)return!1;const{_relationshipVM:e,relatedLayer:t}=this;if(!e?.relationship)return!1;const{cardinality:r}=e.relationship;return"many-to-many"!==r&&(!(t&&!o(t))&&(this.evaluatedEditableExpression??!0))}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}get loaded(){return"ready"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:i,map:o,orderByFields:n,relationshipId:p,showAllEnabled:u}=this;a(s)&&(this._relationshipVM=new l({graphic:t,displayCount:i,layer:s,map:o,orderByFields:n,relationshipId:p,showAllEnabled:u}))}};e([s()],u.prototype,"canAddRelatedFeature",null),e([s()],u.prototype,"displayCount",null),e([s()],u.prototype,"displayType",null),e([s()],u.prototype,"editable",null),e([s()],u.prototype,"group",void 0),e([s()],u.prototype,"map",null),e([s()],u.prototype,"orderByFields",null),e([s()],u.prototype,"relationshipId",null),e([s()],u.prototype,"relatedFeatureInfos",null),e([s()],u.prototype,"relatedLayer",null),e([s()],u.prototype,"showAllEnabled",null),e([s()],u.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],u.prototype,"type",void 0),e([s()],u.prototype,"updating",null),e([s()],u.prototype,"incrementPage",null),e([s()],u.prototype,"getRelatedFeatureByObjectId",null),u=e([i("esri.widgets.FeatureForm.RelationshipInput")],u);const h=u;export{h as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as i,isTable as o}from"../../layers/support/layerUtils.js";import a from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as n}from"../Feature/support/featureUtils.js";import p from"./EditableInput.js";const d=3;let u=class extends p{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship||!this.loaded||!this.relatedLayerAllowsAdds)return!1;const{cardinality:s,role:l}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===l&&t>0)&&e))}get displayCount(){return this.element.displayCount??d}get displayType(){return this.element.displayType}get editable(){return!!this.relatedLayerAllowsEdits&&(this.evaluatedEditableExpression??!1)}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get relatedLayerAllowsAdds(){const{relatedLayer:e}=this;if(!e||!this.relatedLayerAllowsEdits)return!1;const t=i(e);return!!t?.operations?.supportsAdd}get relatedLayerAllowsEdits(){const{relatedLayer:e}=this;if(!e)return!1;const t=i(e);return!!t?.operations?.supportsEditing}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get visible(){const{_relationshipVM:e,relatedLayer:t}=this;if(!e?.relationship)return!1;const{cardinality:r}=e.relationship;return"many-to-many"!==r&&(!(t&&!o(t))&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element))}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}get loaded(){return"ready"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:l,map:i,orderByFields:o,relationshipId:p,showAllEnabled:d}=this;n(s)&&(this._relationshipVM=new a({graphic:t,displayCount:l,layer:s,map:i,orderByFields:o,relationshipId:p,showAllEnabled:d}))}};e([s()],u.prototype,"canAddRelatedFeature",null),e([s()],u.prototype,"displayCount",null),e([s()],u.prototype,"displayType",null),e([s()],u.prototype,"editable",null),e([s()],u.prototype,"group",void 0),e([s()],u.prototype,"map",null),e([s()],u.prototype,"orderByFields",null),e([s()],u.prototype,"relationshipId",null),e([s()],u.prototype,"relatedFeatureInfos",null),e([s()],u.prototype,"relatedLayer",null),e([s()],u.prototype,"relatedLayerAllowsAdds",null),e([s()],u.prototype,"relatedLayerAllowsEdits",null),e([s()],u.prototype,"showAllEnabled",null),e([s()],u.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],u.prototype,"type",void 0),e([s()],u.prototype,"visible",null),e([s()],u.prototype,"updating",null),e([s()],u.prototype,"incrementPage",null),e([s()],u.prototype,"getRelatedFeatureByObjectId",null),u=e([l("esri.widgets.FeatureForm.RelationshipInput")],u);const h=u;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{HandleOwner as l}from"../../core/HandleOwner.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{when as o,watch as a,initial as n,syncAndInitial as h}from"../../core/reactiveUtils.js";import{Milliseconds as d}from"../../core/time.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../webdoc/Widgets.js";import y from"../../webdoc/widgets/FloorFilter.js";import{GoToMixin as p}from"../support/GoTo.js";function v(e){return"esri.WebMap"===e.declaredClass}function m(e){return"esri.WebScene"===e.declaredClass}let F=class extends(p(l)){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType="site",this.filterMode="base-floors",this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([o((()=>this.view?.map),(e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=t((async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)}))}),n),a((()=>this.view),((e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)}),h),a((()=>this.view?.widthBreakpoint??null),(e=>{this._viewWidthBreakpoint=e})),a((()=>this.view?.heightBreakpoint??null),(e=>{this._viewHeightBreakpoint=e}))])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride("facility",e)}set filterFeatures(e){this._callOverride("filterFeatures",e)}set filterLayers(e){this._callOverride("filterLayers",e)}get hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const s=e?.split("--");if(s?.length>1&&"all"===s[0]?(i=s[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.siteId||null),this.setFloors(t)):this._isOverridden("level")&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType="site"),this.setFloors(null)),this._callOverride("level",e);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}set site(e){this._callOverride("site",e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?"ready":this.view&&!this.filterFeatures?"loading":"disabled"}filterFacilities(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}))),this.site&&(t=t.filter((e=>e.siteId===this.site)));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}filterSites(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:s}=e;if(t&&t.length>0&&(t.forEach((e=>{0===e.verticalOrder&&e.facilityId===s&&(i=e)})),!i)){let e=null;t.forEach((t=>{t.facilityId===s&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)})),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find((t=>t.id===e))??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter((t=>t.facilityId===e)).sort(((e,t)=>{const i=e.verticalOrder??0,s=t.verticalOrder??0;return i>s?-1:i===s?0:1}))}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find((t=>t.id===e))??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find((t=>t.id===e))??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:d(1e3),easing:"in-out-quad"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach((e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)})),t.floors=new i(this._computeFloors(e)))}updateWebDocument(e){if(v(e)){const t=new y({enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null});e.widgets?e.widgets.floorFilter=t:e.widgets=new f({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&t.push(e.id)}))}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:l,verticalOrder:r}=e;(s||0!==r||i.includes(t))&&(l===s||0!==r||i.includes(t))||i.push(t)})),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[],s=e?.id.split("--")??[];if(s?.length>1&&"all"===s[0]){this.getFacilityLevels(e?.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const l=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:s}=e;(l||i.includes(t))&&(s===l||i.includes(t))||i.push(t)})),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!v(e.map)&&!m(e.map))throw new s("Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},s=t.floorInfo?.siteLayer?.layerId,l=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!l||!r)return;const a=i.items.filter((e=>"feature"===e.type||"scene"===e.type)),n=i.items.filter((e=>"map-image"===e.type));if(n?.length>0&&o){await Promise.all(n.map((e=>e.load())));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach((t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===s||n===l||n===r)&&d?.length>0&&h.items.forEach((t=>{const l=t.id;n===s&&l===i?e.siteLayer=t:l===o?e.facilityLayer=t:l===a&&(e.levelLayer=t)}))}))}a?.length>0&&a.forEach((t=>{const i=t.id;i===s?e.siteLayer=t:i===l?e.facilityLayer=t:i===r&&(e.levelLayer=t)})),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,s=i?.map,{siteLayer:l}=t;if(!l||!s?.floorInfo?.siteLayer)return e;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=s.floorInfo.siteLayer,n=await l.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=l?.fieldsIndex.get(o)?.name||o,s=l?.fieldsIndex.get(a)?.name||a;null!=i&&null!=s&&t.forEach((t=>{const l=t.attributes,r=t.geometry,o=l[i],a=l[s];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})}))}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:s}=e,l={facilitiesInfo:[]};if(!s||!i?.floorInfo?.facilityLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await s.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach((e=>{const s=e.attributes,o=e.geometry,a=s[t],n=s[i],h=s[r];a&&n&&h&&l.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})}))}return l}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:s}=e,l={levelsInfo:[]};if(!s||!i?.floorInfo?.levelLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,u=await s.queryFeatures(r);if(u?.features?.length>0){const e=u.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n,f=s?.fieldsIndex.get(h)?.name||h,y=s?.fieldsIndex.get(d)?.name||d,p=s?.fieldsIndex.get(c)?.name||c;t&&i&&r&&f&&y&&p&&e.forEach((e=>{const s=e.attributes,o=s[t],a=s[i],n=s[r],h=s[f],d=s[y],c=s[p];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&l.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})}))}return l}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",(e=>{const t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))}))}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!v(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!v(e))return;const t=e?.widgets?.floorFilter;t&&(this._isOverridden("enabled")||(this.enabled=t.enabled),this._isOverridden("longNames")||(this.longNames=t.longNames),this._isOverridden("minimized")||(this.minimized=t.minimized),this._isOverridden("pinnedLevels")||(this.pinnedLevels=t.pinnedLevels),this._isOverridden("site")||(this.site=t.site),this._isOverridden("facility")||(this.facility=t.facility),this._isOverridden("level")||(this.level=t.level))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:s,facility:l}=this,r=[];t.levels.levelsInfo.forEach((e=>{const{id:t,facilityId:i}=e;l&&i===l?s&&t===s&&r.push(t):r.push(t)})),e.floorInfo.viewAllLevelIds=new i(r)}}};e([c({value:!1})],F.prototype,"enabled",null),e([c({value:void 0})],F.prototype,"facility",null),e([c({value:null})],F.prototype,"filterFeatures",null),e([c({value:null})],F.prototype,"filterLayers",null),e([c()],F.prototype,"filterMenuOpen",void 0),e([c()],F.prototype,"filterMenuType",void 0),e([c()],F.prototype,"filterMode",void 0),e([c()],F.prototype,"hasFacilities",null),e([c()],F.prototype,"hasLevels",null),e([c()],F.prototype,"hasMultipleSites",null),e([c({readOnly:!0})],F.prototype,"isNormalMode",null),e([c({value:void 0})],F.prototype,"level",null),e([c({value:!1})],F.prototype,"longNames",null),e([c()],F.prototype,"levelsExpanded",void 0),e([c({value:!1})],F.prototype,"minimized",null),e([c({value:!1})],F.prototype,"pinnedLevels",null),e([c()],F.prototype,"searchTerm",void 0),e([c({value:void 0})],F.prototype,"site",null),e([c({readOnly:!0})],F.prototype,"state",null),e([c()],F.prototype,"view",void 0),e([c()],F.prototype,"_viewHeightBreakpoint",void 0),e([c()],F.prototype,"_viewWidthBreakpoint",void 0),e([c()],F.prototype,"updateWebDocument",null),F=e([u("esri/widgets/FloorFilter/FloorFilterViewModel")],F);const g=F;export{g as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{HandleOwner as l}from"../../core/HandleOwner.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{watch as o,initial as a,syncAndInitial as n}from"../../core/reactiveUtils.js";import{Milliseconds as h}from"../../core/time.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../webdoc/Widgets.js";import f from"../../webdoc/widgets/FloorFilter.js";import{GoToMixin as y}from"../support/GoTo.js";function p(e){return"esri.WebMap"===e.declaredClass}function v(e){return"esri.WebScene"===e.declaredClass}let m=class extends(y(l)){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType="site",this.filterMode="base-floors",this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([o((()=>this.view?.map),(e=>{null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=t((async t=>{await this._updateFloorFilterFromMap(e),r(t),this._setInitialViewState(e)}))}),a),o((()=>this.view),((e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)}),n),o((()=>this.view?.widthBreakpoint??null),(e=>{this._viewWidthBreakpoint=e})),o((()=>this.view?.heightBreakpoint??null),(e=>{this._viewHeightBreakpoint=e}))])}destroy(){this._unregisterWidget(this.view),this.view=null,null!=this._updateFloorFilterTask&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride("enabled",e)}set facility(e){if(e&&this._isOverridden("facility")){const t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride("facility",e)}set filterFeatures(e){this._callOverride("filterFeatures",e)}set filterLayers(e){this._callOverride("filterLayers",e)}get hasFacilities(){return null!=this.filterLayers?.facilityLayer&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return null!=this.filterLayers?.levelLayer&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return null!=this.filterLayers?.siteLayer&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0;const t=this._viewWidthBreakpoint;return"xsmall"!==this._viewHeightBreakpoint&&"xsmall"!==t||(e=!1),e}set level(e){if(!e)return this._callOverride("level",e),this.facility=null,this.site=null,void this.setFloors(null);let t=null,i=null;const s=e?.split("--");if(s?.length>1&&"all"===s[0]?(i=s[1],t={id:e,facilityId:i,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),i=t?.facilityId??null),this.level!==e||this.isNormalMode||this.levelsExpanded)t&&this.hasFacilities&&this.hasLevels?(this.facility=i,this.hasMultipleSites&&(this.site=this.getFacility(i)?.siteId||null),this.setFloors(t)):this._isOverridden("level")&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType="site"),this.setFloors(null)),this._callOverride("level",e);else{const e=this.getFacilityLevels(i);e?.length>1&&(this.levelsExpanded=!0)}}set longNames(e){this._callOverride("longNames",e)}set minimized(e){this._callOverride("minimized",e)}set pinnedLevels(e){this._callOverride("pinnedLevels",e)}set site(e){this._callOverride("site",e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?"ready":this.view&&!this.filterFeatures?"loading":"disabled"}filterFacilities(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())}))),this.site&&(t=t.filter((e=>e.siteId===this.site)));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}filterSites(e){let t=e;this.searchTerm&&(t=e.filter((e=>{const{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})));return t.sort(((e,t)=>{const i=e.name,s=t.name;return i>s?1:i===s?0:-1}))}getBaseLevel(e){const t=this.filterFeatures?.levels?.levelsInfo;let i=null;if(e){const{id:s}=e;if(t&&t.length>0&&(t.forEach((e=>{0===e.verticalOrder&&e.facilityId===s&&(i=e)})),!i)){let e=null;t.forEach((t=>{t.facilityId===s&&(e?(t.verticalOrder??0)>=0?null!=e.verticalOrder&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):null!=e.verticalOrder&&null!=t.verticalOrder&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)})),e&&(i=e)}}return i}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find((t=>t.id===e))??null}getFacilityLevels(e){if(!e||!this.filterFeatures?.levels?.levelsInfo)return[];return this.filterFeatures.levels.levelsInfo.filter((t=>t.facilityId===e)).sort(((e,t)=>{const i=e.verticalOrder??0,s=t.verticalOrder??0;return i>s?-1:i===s?0:1}))}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find((t=>t.id===e))??null}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find((t=>t.id===e))??null}goTo(e){const{view:t}=this;if(!t||!e)return;const{geometry:i}=e;i&&i.extent&&this.callGoTo({target:i.extent,options:{duration:h(1e3),easing:"in-out-quad"}})}setFloors(e){const{view:t}=this;t&&(t?.map?.allLayers?.forEach((e=>{"feature"===e.type&&this._computeViewAllModeFloors(e)})),t.floors=new i(this._computeFloors(e)))}updateWebDocument(e){if(p(e)){const t=new f({enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null});e.widgets?e.widgets.floorFilter=t:e.widgets=new u({floorFilter:t})}}_computeFloors(e){if("single-floor"===this.filterMode)this._computeSingleFloor(e);else if("base-floors"===this.filterMode)return"3d"===this.view?.type?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();const t=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&t.push(e.id)}))}else e&&t.push(e.id);return t}_computeBaseFloors(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[];if("all"===e?.id){this.getFacilityLevels(e.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const s=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:l,verticalOrder:r}=e;(s||0!==r||i.includes(t))&&(l===s||0!==r||i.includes(t))||i.push(t)})),i}_computeBaseFloors3D(e){const t=this.filterFeatures?.levels?.levelsInfo;if(!t||!t.length)return this._computeEmptyFloors();const i=[],s=e?.id.split("--")??[];if(s?.length>1&&"all"===s[0]){this.getFacilityLevels(e?.facilityId).forEach((e=>{e.id&&i.push(e.id)}))}else e&&i.push(e.id);const l=e?.facilityId;return t.forEach((e=>{const{id:t,facilityId:s}=e;(l||i.includes(t))&&(s===l||i.includes(t))||i.push(t)})),i}_computeEmptyFloors(){return[]}async _setFilterLayers(){const{view:e}=this;if(e&&!this._isOverridden("filterLayers")){if(!p(e.map)&&!v(e.map))throw new s("Map must be a webmap or webscene");{const t=e.map,i=t?.allLayers;if(i?.items?.length>0){const e={siteLayer:null,facilityLayer:null,levelLayer:null},s=t.floorInfo?.siteLayer?.layerId,l=t.floorInfo?.facilityLayer?.layerId,r=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!l||!r)return;const a=i.items.filter((e=>"feature"===e.type||"scene"===e.type)),n=i.items.filter((e=>"map-image"===e.type));if(n?.length>0&&o){await Promise.all(n.map((e=>e.load())));const i=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,a=t.floorInfo?.levelLayer?.sublayerId;n.forEach((t=>{const n=t.id,h=t?.allSublayers,d=h?.items;(n===s||n===l||n===r)&&d?.length>0&&h.items.forEach((t=>{const l=t.id;n===s&&l===i?e.siteLayer=t:l===o?e.facilityLayer=t:l===a&&(e.levelLayer=t)}))}))}a?.length>0&&a.forEach((t=>{const i=t.id;i===s?e.siteLayer=t:i===l?e.facilityLayer=t:i===r&&(e.levelLayer=t)})),this.filterLayers=e}}}}async _getFilterFeatures(){if(this._isOverridden("filterFeatures"))return this.filterFeatures;const[e,t,i]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:i}}async _getSites(){const e={sitesInfo:[]},{filterLayers:t,view:i}=this,s=i?.map,{siteLayer:l}=t;if(!l||!s?.floorInfo?.siteLayer)return e;const r=l.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in l&&"scene"===l.type&&(r.multipatchOption="xyFootprint");const{siteIdField:o,nameField:a}=s.floorInfo.siteLayer,n=await l.queryFeatures(r);if(n?.features?.length>0){const t=n.features,i=l?.fieldsIndex.get(o)?.name||o,s=l?.fieldsIndex.get(a)?.name||a;null!=i&&null!=s&&t.forEach((t=>{const l=t.attributes,r=t.geometry,o=l[i],a=l[s];o&&a&&e.sitesInfo.push({id:o,name:a,geometry:r})}))}return e}async _getFacilities(){const{filterLayers:e,view:t}=this,i=t?.map,{facilityLayer:s}=e,l={facilitiesInfo:[]};if(!s||!i?.floorInfo?.facilityLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0,"type"in s&&"scene"===s.type&&(r.multipatchOption="xyFootprint");const{facilityIdField:o,siteIdField:a,nameField:n}=i.floorInfo.facilityLayer,h=await s.queryFeatures(r);if(h?.features?.length>0){const e=h.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n;t&&i&&r&&e.forEach((e=>{const s=e.attributes,o=e.geometry,a=s[t],n=s[i],h=s[r];a&&h&&l.facilitiesInfo.push({id:a,siteId:n,name:h,geometry:o})}))}return l}async _getLevels(){const{filterLayers:e,view:t}=this,i=t?.map,{levelLayer:s}=e,l={levelsInfo:[]};if(!s||!i?.floorInfo?.levelLayer)return l;const r=s.createQuery();r.returnGeometry=!0,r.outFields=["*"],r.returnZ=!0;const{levelIdField:o,facilityIdField:a,longNameField:n,shortNameField:h,levelNumberField:d,verticalOrderField:c}=i.floorInfo.levelLayer,u=await s.queryFeatures(r);if(u?.features?.length>0){const e=u.features,t=s?.fieldsIndex.get(o)?.name||o,i=s?.fieldsIndex.get(a)?.name||a,r=s?.fieldsIndex.get(n)?.name||n,f=s?.fieldsIndex.get(h)?.name||h,y=s?.fieldsIndex.get(d)?.name||d,p=s?.fieldsIndex.get(c)?.name||c;t&&i&&r&&f&&y&&p&&e.forEach((e=>{const s=e.attributes,o=s[t],a=s[i],n=s[r],h=s[f],d=s[y],c=s[p];o&&a&&n&&h&&"number"==typeof d&&"number"==typeof c&&l.levelsInfo.push({id:o,facilityId:a,longName:n,shortName:h,levelNumber:d,verticalOrder:c})}))}return l}_registerWidget(e){const t=e?.persistableViewModels.includes(this);t||e?.persistableViewModels.add(this)}_unregisterWidget(e){e?.persistableViewModels.remove(this)}_watchSearchResults(e){e?.on("select-result-floor",(e=>{const t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))}))}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();const t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels)return void console.error("Facilities and Levels are required for the Floor Filter widget");if(this.hasMultipleSites||(this.filterMenuType="facility"),this.facility&&this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||(this.site=e?.siteId||void 0),this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType="facility";const e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||(this.site=e?.siteId||void 0),this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType="facility";const e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||(this.site=t?.siteId||void 0),this.setFloors(e)}else if(!this.site||this.facility||this.level){if(!e||!p(e))return void this.setFloors(null);const t=e?.widgets?.floorFilter;if(!t)return void this.setFloors(null);t.site&&!this.site&&(this.site=t.site,this.filterMenuType="facility"),this.setFloors(null)}else this.filterMenuType="site",this.setFloors(null)}catch(t){console.error("Couldn't retrieve sites, facilities, and levels",t)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!p(e))return;const t=e?.widgets?.floorFilter;t&&(this._isOverridden("enabled")||(this.enabled=t.enabled),this._isOverridden("longNames")||(this.longNames=t.longNames),this._isOverridden("minimized")||(this.minimized=t.minimized),this._isOverridden("pinnedLevels")||(this.pinnedLevels=t.pinnedLevels),this._isOverridden("site")||(this.site=t.site),this._isOverridden("facility")||(this.facility=t.facility),this._isOverridden("level")||(this.level=t.level))}_computeViewAllModeFloors(e){const{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&"base-floors"===this.filterMode){const{level:s,facility:l}=this,r=[];t.levels.levelsInfo.forEach((e=>{const{id:t,facilityId:i}=e;l&&i===l?s&&t===s&&r.push(t):r.push(t)})),e.floorInfo.viewAllLevelIds=new i(r)}}};e([d({value:!1})],m.prototype,"enabled",null),e([d({value:void 0})],m.prototype,"facility",null),e([d({value:null})],m.prototype,"filterFeatures",null),e([d({value:null})],m.prototype,"filterLayers",null),e([d()],m.prototype,"filterMenuOpen",void 0),e([d()],m.prototype,"filterMenuType",void 0),e([d()],m.prototype,"filterMode",void 0),e([d()],m.prototype,"hasFacilities",null),e([d()],m.prototype,"hasLevels",null),e([d()],m.prototype,"hasMultipleSites",null),e([d({readOnly:!0})],m.prototype,"isNormalMode",null),e([d({value:void 0})],m.prototype,"level",null),e([d({value:!1})],m.prototype,"longNames",null),e([d()],m.prototype,"levelsExpanded",void 0),e([d({value:!1})],m.prototype,"minimized",null),e([d({value:!1})],m.prototype,"pinnedLevels",null),e([d()],m.prototype,"searchTerm",void 0),e([d({value:void 0})],m.prototype,"site",null),e([d({readOnly:!0})],m.prototype,"state",null),e([d()],m.prototype,"view",void 0),e([d()],m.prototype,"_viewHeightBreakpoint",void 0),e([d()],m.prototype,"_viewWidthBreakpoint",void 0),e([d()],m.prototype,"updateWebDocument",null),m=e([c("esri/widgets/FloorFilter/FloorFilterViewModel")],m);const F=m;export{F as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{debounce as t}from"../../core/promiseUtils.js";import{watch as s,initial as i}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Slider.js";import{loadCalciteComponents as n}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as a}from"../support/jsxFactory.js";import u from"./ValuePickerBaseComponent.js";import p from"./ValuePickerSliderVisibleElements.js";const c="esri-value-picker__slider",d={minorTick:`${c}__tick-minor`,majorTick:`${c}__tick-major`,stepsTick:`${c}__tick-steps`};function h(e){return(t,s)=>{s?.classList.add(e)}}let m=class extends u{constructor(e,s){super(e,s),this._majorTickCreatedFunction=h(d.majorTick),this._minorTickCreatedFunction=h(d.minorTick),this._stepsTickCreatedFunction=h(d.stepsTick),this._thumbNode=null,this._tooltip=null,this._slider=new r({thumbCreatedFunction:(e,t,s)=>{this._thumbNode=s}}),this.labelFormatFunction=null,this.labels=null,this.min=null,this.minorTicks=null,this.majorTicks=null,this.max=null,this.reversed=!1,this.steps=null,this.type="slider",this.visibleElements=new p,this._thumbDragDebounced=t((async e=>{await(this._tooltip?.reposition(!1))}))}initialize(){this.addHandles([s((()=>this.viewModel?.values),(e=>{this._slider.values=e}),i),s((()=>this._slider.values),(e=>{this.viewModel&&this.viewModel.values!==e&&(this.viewModel.values=e)})),this._slider.on("thumb-drag",this._thumbDragDebounced)])}destroy(){this._slider.destroy()}loadDependencies(){return n({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get _ascending(){const{reversed:e,viewModel:t}=this;if(!t)return null;const{layout:s}=t;return"horizontal"===s&&!e||"vertical"===s&&e}get canNext(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[i.length-1]:r!==i[0])}get canPlay(){return null!=this.viewModel&&!!this.steps?.length&&null!=this.min&&null!=this.max}get canPrevious(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[0]:r!==i[i.length-1])}render(){const{labels:e,labelFormatFunction:t,min:s,max:i,steps:o,minorTicks:l,majorTicks:r,reversed:n,viewModel:u}=this;if(!u)return a("div",null);const{disabled:p,layout:d}=u,h=`${d}${n?"-reversed":""}`,m="position",v=[];return null!=s&&null!=i&&(l&&v.push({mode:m,values:l,tickCreatedFunction:this._minorTickCreatedFunction}),r&&v.push({mode:m,values:r,tickCreatedFunction:this._majorTickCreatedFunction}),e&&v.push({mode:m,values:e,labelsVisible:!0}),this.visibleElements.steps&&this.steps&&v.push({mode:m,values:this.steps,tickCreatedFunction:this._stepsTickCreatedFunction})),this._slider.set({disabled:p,labelFormatFunction:t,layout:h,min:s,max:i,steps:o,tickConfigs:v}),a("div",{class:c},this._slider.render(),this._renderToolTip())}animate(e){this._step(1,e)}next(){this._step(this._ascending?1:-1)}previous(){this._step(this._ascending?-1:1)}_onTooltipAfterCreate(e){this._tooltip=e}_renderToolTip(){if(!this.visibleElements.thumbTooltip||!this._thumbNode||!this._slider.values)return null;const e=this._slider.viewModel.getLabelForValue(this._slider.values[0],"value");return e?a("calcite-tooltip",{afterCreate:this._onTooltipAfterCreate,label:e,referenceElement:this._thumbNode},e):null}_step(e,t=!1){if(!this.viewModel||!this.steps?.length)return;if(!this.viewModel.values||!this.steps.includes(this.viewModel.values[0]))return void(this.viewModel.values=[this.steps[0]]);const s=this.steps.indexOf(this.viewModel.values[0])+e;s<0||s>=this.steps.length?this.viewModel.loop||t?this.viewModel.values=[this.steps[1===e?0:this.steps.length-1]]:"playing"===this.viewModel.state&&this.viewModel.pause():this.viewModel.values=[this.steps[s]]}};e([o()],m.prototype,"_ascending",null),e([o()],m.prototype,"canNext",null),e([o()],m.prototype,"canPlay",null),e([o()],m.prototype,"canPrevious",null),e([o()],m.prototype,"labelFormatFunction",void 0),e([o()],m.prototype,"labels",void 0),e([o()],m.prototype,"min",void 0),e([o()],m.prototype,"minorTicks",void 0),e([o()],m.prototype,"majorTicks",void 0),e([o()],m.prototype,"max",void 0),e([o({nonNullable:!0})],m.prototype,"reversed",void 0),e([o()],m.prototype,"steps",void 0),e([o()],m.prototype,"type",void 0),e([o({type:p,nonNullable:!0})],m.prototype,"visibleElements",void 0),m=e([l("esri.widgets.ValuePicker.ValuePickerSlider")],m);const v=m;export{v as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{debounce as t}from"../../core/promiseUtils.js";import{watch as s,initial as i}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import r from"../Slider.js";import{loadCalciteComponents as n}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{tsx as a}from"../support/jsxFactory.js";import u from"./ValuePickerBaseComponent.js";import p from"./ValuePickerSliderVisibleElements.js";const c="esri-value-picker__slider",d={minorTick:`${c}__tick-minor`,majorTick:`${c}__tick-major`,stepsTick:`${c}__tick-steps`,tooltip:`${c}__tooltip`};function h(e){return(t,s)=>{s?.classList.add(e)}}let m=class extends u{constructor(e,s){super(e,s),this._majorTickCreatedFunction=h(d.majorTick),this._minorTickCreatedFunction=h(d.minorTick),this._stepsTickCreatedFunction=h(d.stepsTick),this._thumbNode=null,this._tooltip=null,this._slider=new r({thumbCreatedFunction:(e,t,s)=>{this._thumbNode=s}}),this.labelFormatFunction=null,this.labels=null,this.min=null,this.minorTicks=null,this.majorTicks=null,this.max=null,this.reversed=!1,this.steps=null,this.type="slider",this.visibleElements=new p,this._thumbDragDebounced=t((async e=>{await(this._tooltip?.reposition(!1))}))}initialize(){this.addHandles([s((()=>this.viewModel?.values),(e=>{this._slider.values=e}),i),s((()=>this._slider.values),(e=>{this.viewModel&&this.viewModel.values!==e&&(this.viewModel.values=e)})),this._slider.on("thumb-drag",this._thumbDragDebounced)])}destroy(){this._slider.destroy()}loadDependencies(){return n({tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get _ascending(){const{reversed:e,viewModel:t}=this;if(!t)return null;const{layout:s}=t;return"horizontal"===s&&!e||"vertical"===s&&e}get canNext(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[i.length-1]:r!==i[0])}get canPlay(){return null!=this.viewModel&&!!this.steps?.length&&null!=this.min&&null!=this.max}get canPrevious(){const{_ascending:e,min:t,max:s,steps:i,viewModel:o}=this;if(null==e||null==t||null==s||!i?.length||!o)return!1;const{values:l}=o,r=l?.[0];return null==r||(e?r!==i[0]:r!==i[i.length-1])}render(){const{labels:e,labelFormatFunction:t,min:s,max:i,steps:o,minorTicks:l,majorTicks:r,reversed:n,viewModel:u}=this;if(!u)return a("div",null);const{disabled:p,layout:d}=u,h=`${d}${n?"-reversed":""}`,m="position",v=[];return null!=s&&null!=i&&(l&&v.push({mode:m,values:l,tickCreatedFunction:this._minorTickCreatedFunction}),r&&v.push({mode:m,values:r,tickCreatedFunction:this._majorTickCreatedFunction}),e&&v.push({mode:m,values:e,labelsVisible:!0}),this.visibleElements.steps&&this.steps&&v.push({mode:m,values:this.steps,tickCreatedFunction:this._stepsTickCreatedFunction})),this._slider.set({disabled:p,labelFormatFunction:t,layout:h,min:s,max:i,steps:o,tickConfigs:v}),a("div",{class:c},this._slider.render(),this._renderToolTip())}animate(e){this._step(1,e)}next(){this._step(this._ascending?1:-1)}previous(){this._step(this._ascending?-1:1)}_onTooltipAfterCreate(e){this._tooltip=e}_renderToolTip(){if(!this.visibleElements.thumbTooltip||!this._thumbNode||!this._slider.values)return null;const e=this._slider.viewModel.getLabelForValue(this._slider.values[0],"value");return e?a("calcite-tooltip",{afterCreate:this._onTooltipAfterCreate,class:d.tooltip,label:e,referenceElement:this._thumbNode},e):null}_step(e,t=!1){if(!this.viewModel||!this.steps?.length)return;if(!this.viewModel.values||!this.steps.includes(this.viewModel.values[0]))return void(this.viewModel.values=[this.steps[0]]);const s=this.steps.indexOf(this.viewModel.values[0])+e;s<0||s>=this.steps.length?this.viewModel.loop||t?this.viewModel.values=[this.steps[1===e?0:this.steps.length-1]]:"playing"===this.viewModel.state&&this.viewModel.pause():this.viewModel.values=[this.steps[s]]}};e([o()],m.prototype,"_ascending",null),e([o()],m.prototype,"canNext",null),e([o()],m.prototype,"canPlay",null),e([o()],m.prototype,"canPrevious",null),e([o()],m.prototype,"labelFormatFunction",void 0),e([o()],m.prototype,"labels",void 0),e([o()],m.prototype,"min",void 0),e([o()],m.prototype,"minorTicks",void 0),e([o()],m.prototype,"majorTicks",void 0),e([o()],m.prototype,"max",void 0),e([o({nonNullable:!0})],m.prototype,"reversed",void 0),e([o()],m.prototype,"steps",void 0),e([o()],m.prototype,"type",void 0),e([o({type:p,nonNullable:!0})],m.prototype,"visibleElements",void 0),m=e([l("esri.widgets.ValuePicker.ValuePickerSlider")],m);const v=m;export{v as default};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[7476],{28576:(e,t,r)=>{r.d(t,{B:()=>u});var i=r(81153),s=r(81271),o=r(41123),n=r(7628),a=r(31263),l=r(5600),p=r(66094),d=r(25929);function u(e){const t=e?.origins??[void 0];return(r,o)=>{const u=function(e,t,r){if("resource"===e?.type)return function(e,t,r){const o=(0,n.Oe)(t,r);return{type:String,read:(e,t,r)=>{const i=(0,d.r)(e,t,r);return o.type===String?i:"function"==typeof o.type?new o.type({url:i}):void 0},write:{writer(t,n,l,u){if(!u||!u.resources)return"string"==typeof t?void(n[l]=(0,d.t)(t,u)):void(n[l]=t.write({},u));const f=function(e){return null==e?null:"string"==typeof e?e:e.url}(t),g=(0,d.t)(f,{...u,verifyItemRelativeUrls:u&&u.verifyItemRelativeUrls?{writtenUrls:u.verifyItemRelativeUrls.writtenUrls,rootPath:void 0}:void 0},d.M.NO),m=o.type!==String&&(!(0,i.l)(this)||u&&u.origin&&this.originIdOf(r)>(0,a.M9)(u.origin)),b={object:this,propertyName:r,value:t,targetUrl:g,dest:n,targetPropertyName:l,context:u,params:e};u&&u.portalItem&&g&&!(0,s.YP)(g)?m?function(e){const{context:t,targetUrl:r,params:i,value:o,dest:n,targetPropertyName:a}=e;if(!t.portalItem)return;const l=t.portalItem.resourceFromPath(r),d=h(o,r,t),u=(0,p.B)(d),f=(0,s.Ml)(l.path),g=i?.compress??!1;u===f?(t.resources&&y({...e,resource:l,content:d,compress:g,updates:t.resources.toUpdate}),n[a]=r):c(e)}(b):function({context:e,targetUrl:t,dest:r,targetPropertyName:i}){e.portalItem&&e.resources&&(e.resources.toKeep.push({resource:e.portalItem.resourceFromPath(t),compress:!1}),r[i]=t)}(b):u&&u.portalItem&&(null==g||null!=(0,d.i)(g)||(0,s.jc)(g)||m)?c(b):n[l]=g}}}}(e,t,r);switch(e?.type??"other"){case"other":return{read:!0,write:!0};case"url":{const{read:e,write:t}=d.a;return{read:e,write:t}}}}(e,r,o);for(const e of t){const t=(0,l.CJ)(r,e,o);for(const e in u)t[e]=u[e]}}}function c(e){const{targetUrl:t,params:i,value:n,context:a,dest:l,targetPropertyName:u}=e;if(!a.portalItem)return;const c=(0,d.p)(t),f=c?.filename??(0,o.D)(),g=i?.prefix??c?.prefix,m=h(n,t,a),b=(0,s.v_)(g,f),v=`${b}.${(0,p.B)(m)}`,w=a.portalItem.resourceFromPath(v);(0,s.jc)(t)&&a.resources&&a.resources.pendingOperations.push(async function(e){const t=(await Promise.resolve().then(r.bind(r,3172))).default,{data:i}=await t(e,{responseType:"blob"});return i}(t).then((e=>{w.path=`${b}.${(0,p.B)(e)}`,l[u]=w.itemRelativeUrl})).catch((()=>{})));const _=i?.compress??!1;a.resources&&y({...e,resource:w,content:m,compress:_,updates:a.resources.toAdd}),l[u]=w.itemRelativeUrl}function y({object:e,propertyName:t,updates:r,resource:i,content:s,compress:o}){r.push({resource:i,content:s,compress:o,finish:r=>{!function(e,t,r){"string"==typeof e[t]?e[t]=r.url:e[t].url=r.url}(e,t,r)}})}function h(e,t,r){return"string"==typeof e?{url:t}:new Blob([JSON.stringify(e.toJSON(r))],{type:"application/json"})}},57476:(e,t,r)=>{r.r(t),r.d(t,{default:()=>he});var i=r(43697),s=r(38171),o=r(51773),n=(r(16050),r(12501),r(28756),r(92271),r(72529),r(5499),r(84382),r(81571),r(91423),r(32400)),a=r(3172),l=r(2368),p=r(46791),d=r(20102),u=r(92604),c=r(16453),y=r(95330),h=r(17445),f=r(81271),g=r(5600),m=(r(75215),r(67676),r(80442),r(1153)),b=r(71715),v=r(52011),w=r(31263),_=r(87085),I=r(54295),S=r(17287),L=r(66361),C=r(38009),F=r(16859),j=r(72965),x=r(20559),O=r(15506),P=r(21506),R=r(61960),A=r(85857),E=r(14147),T=r(53518),N=r(99514),Z=r(35671),D=r(51161),U=r(54306),q=r(30707),Q=r(56765),G=r(96674);let k=class extends G.wq{constructor(){super(...arguments),this.name=null,this.field=null,this.currentRangeExtent=null,this.fullRangeExtent=null,this.type="rangeInfo"}};(0,i._)([(0,g.Cb)({type:String,json:{read:!0,write:!0}})],k.prototype,"name",void 0),(0,i._)([(0,g.Cb)({type:String,json:{read:!0,write:!0}})],k.prototype,"field",void 0),(0,i._)([(0,g.Cb)({type:[Number],json:{read:!0,write:!0}})],k.prototype,"currentRangeExtent",void 0),(0,i._)([(0,g.Cb)({type:[Number],json:{read:!0,write:!0}})],k.prototype,"fullRangeExtent",void 0),(0,i._)([(0,g.Cb)({type:["rangeInfo"],readOnly:!0,json:{read:!1,write:!0}})],k.prototype,"type",void 0),k=(0,i._)([(0,v.j)("esri.layers.support.RangeInfo")],k);var V,J=r(61247),M=r(22974),B=r(28576),$=r(20941),z=r(38913),K=r(44547);let W=V=class extends((0,G.eC)(p.Z.ofType(z.Z))){constructor(e){super(e)}clone(){return new V(this.items.map((e=>e.clone())))}write(e,t){return this.toJSON(t)}toJSON(e){const t=e?.layer?.spatialReference;return t?this.toArray().map((r=>{if(!t.equals(r.spatialReference)){if(!(0,K.Up)(r.spatialReference,t))return e&&e.messages&&e.messages.push(new $.Z("scenefilter:unsupported","Scene filters with incompatible spatial references are not supported",{modification:this,spatialReference:e.layer.spatialReference,context:e})),null;const i=new z.Z;(0,K.Wt)(r,i,t),r=i}const i=r.toJSON(e);return delete i.spatialReference,i})).filter((e=>null!=e)):(e?.messages&&e.messages.push(new $.Z("scenefilter:unsupported","Writing Scene filters without context layer is not supported",{modification:this,spatialReference:e.layer.spatialReference,context:e})),this.toArray().map((t=>t.toJSON(e))))}static fromJSON(e,t){const r=new V;return e.forEach((e=>r.add(z.Z.fromJSON(e,t)))),r}};W=V=(0,i._)([(0,v.j)("esri.layers.support.PolygonCollection")],W);const Y=W;var H,X=r(25929);let ee=H=class extends G.wq{constructor(e){super(e),this.spatialRelationship="disjoint",this.geometries=new Y,this._geometriesSource=null,this._handles=new J.Z}initialize(){this._handles.add((0,h.on)((()=>this.geometries),"after-changes",(()=>this.geometries=this.geometries),h.Z_))}destroy(){this._handles.destroy()}readGeometries(e,t,r){Array.isArray(e)?this.geometries=Y.fromJSON(e,r):this._geometriesSource={url:(0,X.f)(e,r),context:r}}async loadGeometries(e,t){if(null==this._geometriesSource)return;const{url:r,context:i}=this._geometriesSource,s=await(0,a.default)(r,{responseType:"json",signal:t?.signal}),o=e.toJSON(),n=s.data.map((e=>({...e,spatialReference:o})));this.geometries=Y.fromJSON(n,i),this._geometriesSource=null}clone(){const e=new H({geometries:(0,M.d9)(this.geometries),spatialRelationship:this.spatialRelationship});return e._geometriesSource=this._geometriesSource,e}};(0,i._)([(0,g.Cb)({type:["disjoint","contains"],nonNullable:!0,json:{write:!0}})],ee.prototype,"spatialRelationship",void 0),(0,i._)([(0,g.Cb)({type:Y,nonNullable:!0,json:{write:!0}}),(0,B.B)({origins:["web-scene","portal-item"],type:"resource",prefix:"geometries"})],ee.prototype,"geometries",void 0),(0,i._)([(0,b.r)(["web-scene","portal-item"],"geometries")],ee.prototype,"readGeometries",null),ee=H=(0,i._)([(0,v.j)("esri.layers.support.SceneFilter")],ee);const te=ee;var re=r(40555),ie=r(14165),se=r(72245),oe=r(32163),ne=r(77397),ae=r(19833),le=r(65242);const pe=["3DObject","Point"],de=(0,T.v)();let ue=class extends((0,L.o1)((0,x.Vt)((0,S.Y)((0,C.q)((0,F.I)((0,j.M)((0,c.R)((0,I.V)((0,l.J)(_.Z)))))))))){constructor(...e){super(...e),this.featureReduction=null,this.rangeInfos=null,this.operationalLayerType="ArcGISSceneServiceLayer",this.type="scene",this.fields=null,this.floorInfo=null,this.outFields=null,this.nodePages=null,this.materialDefinitions=null,this.textureSetDefinitions=null,this.geometryDefinitions=null,this.serviceUpdateTimeStamp=null,this.excludeObjectIds=new p.Z,this.definitionExpression=null,this.filter=null,this.path=null,this.labelsVisible=!0,this.labelingInfo=null,this.legendEnabled=!0,this.priority=null,this.semantic=null,this.cachedDrawingInfo={color:!1},this.popupEnabled=!0,this.popupTemplate=null,this.objectIdField=null,this.globalIdField=null,this._fieldUsageInfo={},this.screenSizePerspectiveEnabled=!0}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}destroy(){this._set("renderer",null)}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e,t){const r=this.getFeatureType(t?.feature)?.domains?.[e];return r&&"inherited"!==r.type?r:this.getField(e)?.domain??null}getFeatureType(e){return e&&this.associatedLayer?this.associatedLayer.getFeatureType(e):null}get types(){return this.associatedLayer?.types??[]}get typeIdField(){return this.associatedLayer?.typeIdField??null}get templates(){return this.associatedLayer?.templates??null}get formTemplate(){return this.associatedLayer?.formTemplate??null}get fieldsIndex(){return new N.Z(this.fields)}readNodePages(e,t,r){return"Point"===t.layerType&&(e=t.pointNodePages),null==e||"object"!=typeof e?null:D.U4.fromJSON(e,r)}set elevationInfo(e){this._set("elevationInfo",e),this.loaded&&this._validateElevationInfo()}get geometryType(){return ye[this.profile]||"mesh"}set renderer(e){(0,Z.YN)(e,this.fieldsIndex),this._set("renderer",e)}readCachedDrawingInfo(e){return null!=e&&"object"==typeof e||(e={}),null==e.color&&(e.color=!1),e}get capabilities(){const e=this.associatedLayer?.capabilities??O.C,{query:t,editing:{supportsGlobalId:r,supportsRollbackOnFailure:i,supportsUploadWithItemId:s,supportsGeometryUpdate:o,supportsReturnServiceEditsInSourceSpatialReference:n},data:{supportsZ:a,supportsM:l,isVersioned:p,supportsAttachment:d},operations:{supportsEditing:u,supportsAdd:c,supportsUpdate:y,supportsDelete:h,supportsQuery:f,supportsQueryAttachments:g,supportsAsyncConvert3D:m}}=e,b=e.operations.supportsChangeTracking,v=!!this.associatedLayer?.infoFor3D&&(0,se.Rx)();return{query:t,editing:{supportsGlobalId:r,supportsReturnServiceEditsInSourceSpatialReference:n,supportsRollbackOnFailure:i,supportsGeometryUpdate:v&&o,supportsUploadWithItemId:s},data:{supportsAttachment:d,supportsZ:a,supportsM:l,isVersioned:p},operations:{supportsQuery:f,supportsQueryAttachments:g,supportsEditing:u&&b,supportsAdd:v&&c&&b,supportsDelete:v&&h&&b,supportsUpdate:y&&b,supportsAsyncConvert3D:m}}}get editingEnabled(){return this._isOverridden("editingEnabled")?this._get("editingEnabled"):this.userHasEditingPrivileges}set editingEnabled(e){this._overrideIfSome("editingEnabled",e)}get infoFor3D(){return this.associatedLayer?.infoFor3D??null}get defaultPopupTemplate(){return this.associatedLayer||this.attributeStorageInfo?this.createPopupTemplate():null}readObjectIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeOID"===t.type&&(e=t.name),!!e))),e||void 0}readGlobalIdField(e,t){return!e&&t.fields&&t.fields.some((t=>("esriFieldTypeGlobalID"===t.type&&(e=t.name),!!e))),e||void 0}get displayField(){return this.associatedLayer?.displayField??null}readProfile(e,t){const r=t.store.profile;return null!=r&&ce[r]?ce[r]:(u.Z.getLogger(this).error("Unknown or missing profile",{profile:r,layer:this}),"mesh-pyramids")}load(e){const t=null!=e?e.signal:null,r=this.loadFromPortal({supportedTypes:["Scene Service"]},e).catch(y.r9).then((()=>this._fetchService(t))).then((()=>Promise.all([this._fetchIndexAndUpdateExtent(this.nodePages,t),this._setAssociatedFeatureLayer(t),this._loadFilterGeometries()]))).then((()=>this._validateElevationInfo())).then((()=>this._applyAssociatedLayerOverrides())).then((()=>this._populateFieldUsageInfo())).then((()=>(0,re.y)(this,{origin:"service"},t))).then((()=>(0,Z.YN)(this.renderer,this.fieldsIndex))).then((()=>this.finishLoadEditablePortalLayer(e)));return this.addResolvingPromise(r),Promise.resolve(this)}async beforeSave(){null!=this.filter&&(this.filter=this.filter.clone(),await this.load())}async _loadFilterGeometries(){if(this.filter)try{await this.filter.loadGeometries(this.spatialReference)}catch(e){u.Z.getLogger(this).error("#_loadFilterGeometries()",this,"Failed to load filter geometries. Geometry filter will not be applied for this layer.",{error:e}),this.filter=null}}createQuery(){const e=new ie.Z;return"mesh"!==this.geometryType&&(e.returnGeometry=!0,e.returnZ=!0),e.where=this.definitionExpression||"1=1",e.sqlFormat="standard",e.outFields=["*"],e}queryExtent(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryExtent(e||this.createQuery(),t)))}queryFeatureCount(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatureCount(e||this.createQuery(),t)))}queryFeatures(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryFeatures(e||this.createQuery(),t))).then((e=>{if(e?.features)for(const t of e.features)t.layer=this,t.sourceLayer=this;return e}))}async queryCachedAttributes(e,t){const r=(0,Z.Lk)(this.fieldsIndex,await(0,ae.e7)(this,(0,ae.V5)(this)));return(0,ne.xe)(this.parsedUrl.path,this.attributeStorageInfo??[],e,t,r)}async queryCachedFeature(e,t){const r=await this.queryCachedAttributes(e,[t]);if(!r||0===r.length)throw new d.Z("scenelayer:feature-not-in-cached-data","Feature not found in cached data");const i=new s.Z;return i.attributes=r[0],i.layer=this,i.sourceLayer=this,i}queryObjectIds(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryObjectIds(e||this.createQuery(),t)))}queryAttachments(e,t){return this._getAssociatedLayerForQuery().then((r=>r.queryAttachments(e,t)))}getFieldUsageInfo(e){const t={supportsLabelingInfo:!1,supportsRenderer:!1,supportsPopupTemplate:!1,supportsLayerQuery:!1};return this.loaded?this._fieldUsageInfo[e]||t:(u.Z.getLogger(this).error("#getFieldUsageInfo()","Unavailable until layer is loaded"),t)}createPopupTemplate(e){return(0,oe.eZ)(this,e)}_getAssociatedLayerForQuery(){const e=this.associatedLayer;return e?.loaded?Promise.resolve(e):this._loadAssociatedLayerForQuery()}async _loadAssociatedLayerForQuery(){if(await this.load(),!this.associatedLayer)throw new d.Z("scenelayer:query-not-available","SceneLayer queries are not available without an associated feature layer",{layer:this});try{await this.associatedLayer.load()}catch(e){throw new d.Z("scenelayer:query-not-available","SceneLayer associated feature layer could not be loaded",{layer:this,error:e})}return this.associatedLayer}hasCachedStatistics(e){return null!=this.statisticsInfo&&this.statisticsInfo.some((t=>t.name===e))}async queryCachedStatistics(e,t){if(await this.load(t),!this.statisticsInfo)throw new d.Z("scenelayer:no-cached-statistics","Cached statistics are not available for this layer");const r=this.fieldsIndex.get(e);if(!r)throw new d.Z("scenelayer:field-unexisting",`Field '${e}' does not exist on the layer`);for(const e of this.statisticsInfo)if(e.name===r.name){const r=(0,f.v_)(this.parsedUrl.path,e.href);return(0,a.default)(r,{query:{f:"json",token:this.apiKey},responseType:"json",signal:t?t.signal:null}).then((e=>e.data))}throw new d.Z("scenelayer:no-cached-statistics","Cached statistics for this attribute are not available")}async saveAs(e,t){return this._debouncedSaveOperations(x.xp.SAVE_AS,{...t,getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"},e)}async save(){const e={getTypeKeywords:()=>this._getTypeKeywords(),portalItemLayerType:"scene"};return this._debouncedSaveOperations(x.xp.SAVE,e)}async applyEdits(e,t){const{applyEdits:i}=await r.e(1444).then(r.bind(r,14720));if(await this.load(),!this.associatedLayer)throw new d.Z(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),i(this,this.associatedLayer.source,e,t)}async uploadAssets(e,t){if(await this.load(),null==this.associatedLayer)throw new d.Z(`${this.type}-layer:not-editable`,"Service is not editable");return await this.associatedLayer.load(),this.associatedLayer.uploadAssets(e,t)}on(e,t){return super.on(e,t)}validateLayer(e){if(e.layerType&&!pe.includes(e.layerType))throw new d.Z("scenelayer:layer-type-not-supported","SceneLayer does not support this layer type",{layerType:e.layerType});if(isNaN(this.version.major)||isNaN(this.version.minor))throw new d.Z("layer:service-version-not-supported","Service version is not supported.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});if(this.version.major>2)throw new d.Z("layer:service-version-too-new","Service version is too new.",{serviceVersion:this.version.versionString,supportedVersions:"1.x, 2.x"});!function(e,t){let r=!1,i=!1;if(null==e)r=!0,i=!0;else{const s=t&&t.isGeographic;switch(e){case"east-north-up":case"earth-centered":r=!0,i=s;break;case"vertex-reference-frame":r=!0,i=!s;break;default:r=!1}}if(!r)throw new d.Z("scenelayer:unsupported-normal-reference-frame","Normal reference frame is invalid.");if(!i)throw new d.Z("scenelayer:incompatible-normal-reference-frame","Normal reference frame is incompatible with layer spatial reference.")}(this.normalReferenceFrame,this.spatialReference)}_getTypeKeywords(){const e=[];if("points"===this.profile)e.push("Point");else{if("mesh-pyramids"!==this.profile)throw new d.Z("scenelayer:unknown-profile","SceneLayer:save() encountered an unknown SceneLayer profile: "+this.profile);e.push("3DObject")}return e}_populateFieldUsageInfo(){if(this._fieldUsageInfo={},this.fields)for(const e of this.fields){const t=!(!this.attributeStorageInfo||!this.attributeStorageInfo.some((t=>t.name===e.name))),r=!!this.associatedLayer?.fields?.some((t=>t&&e.name===t.name)),i={supportsLabelingInfo:t,supportsRenderer:t,supportsPopupTemplate:t||r,supportsLayerQuery:r};this._fieldUsageInfo[e.name]=i}}_applyAssociatedLayerOverrides(){this._applyAssociatedLayerFieldsOverrides(),this._applyAssociatedLayerPopupOverrides()}_applyAssociatedLayerFieldsOverrides(){if(!this.associatedLayer?.fields)return;let e=null;for(const t of this.associatedLayer.fields){const r=this.getField(t.name);r?(!r.domain&&t.domain&&(r.domain=t.domain.clone()),r.editable=t.editable,r.nullable=t.nullable,r.length=t.length):(e||(e=this.fields?this.fields.slice():[]),e.push(t.clone()))}e&&this._set("fields",e)}_applyAssociatedLayerPopupOverrides(){if(!this.associatedLayer)return;const e=["popupTemplate","popupEnabled"],t=(0,m.vw)(this);for(let r=0;r<e.length;r++){const i=e[r],s=this.originIdOf(i),o=this.associatedLayer.originIdOf(i);s<o&&(o===w.s3.SERVICE||o===w.s3.PORTAL_ITEM)&&t.setAtOrigin(i,this.associatedLayer[i],o)}}async _setAssociatedFeatureLayer(e){if(!["mesh-pyramids","points"].includes(this.profile))return;const t=new E.W(this.parsedUrl,this.portalItem,this.apiKey,e);try{this.associatedLayer=await t.fetch()}catch(e){(0,y.D_)(e)||this._logWarningOnPopupEnabled()}}async _logWarningOnPopupEnabled(){await(0,h.N1)((()=>this.popupEnabled&&null!=this.popupTemplate));const e=`this SceneLayer: ${this.title}`;null==this.attributeStorageInfo?u.Z.getLogger(this).warn(`Associated FeatureLayer could not be loaded and no binary attributes found. Popups will not work on ${e}`):u.Z.getLogger(this).info(`Associated FeatureLayer could not be loaded. Falling back to binary attributes for Popups on ${e}`)}_validateElevationInfo(){const e=this.elevationInfo;e&&("mesh-pyramids"===this.profile&&"relative-to-scene"===e.mode&&u.Z.getLogger(this).warn(".elevationInfo=","Mesh scene layers don't support relative-to-scene elevation mode"),e.featureExpressionInfo&&"0"!==e.featureExpressionInfo.expression&&u.Z.getLogger(this).warn(".elevationInfo=","Scene layers do not support featureExpressionInfo"))}};(0,i._)([(0,g.Cb)({types:{key:"type",base:R.B,typeMap:{selection:A.Z}},json:{origins:{"web-scene":{name:"layerDefinition.featureReduction",write:!0},"portal-item":{name:"layerDefinition.featureReduction",write:!0}}}})],ue.prototype,"featureReduction",void 0),(0,i._)([(0,g.Cb)({type:[k],json:{read:!1,origins:{"web-scene":{name:"layerDefinition.rangeInfos",write:!0},"portal-item":{name:"layerDefinition.rangeInfos",write:!0}}}})],ue.prototype,"rangeInfos",void 0),(0,i._)([(0,g.Cb)({json:{read:!1}})],ue.prototype,"associatedLayer",void 0),(0,i._)([(0,g.Cb)({type:["show","hide"]})],ue.prototype,"listMode",void 0),(0,i._)([(0,g.Cb)({type:["ArcGISSceneServiceLayer"]})],ue.prototype,"operationalLayerType",void 0),(0,i._)([(0,g.Cb)({json:{read:!1},readOnly:!0})],ue.prototype,"type",void 0),(0,i._)([(0,g.Cb)({...de.fields,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"fields",void 0),(0,i._)([(0,g.Cb)()],ue.prototype,"types",null),(0,i._)([(0,g.Cb)()],ue.prototype,"typeIdField",null),(0,i._)([(0,g.Cb)()],ue.prototype,"templates",null),(0,i._)([(0,g.Cb)()],ue.prototype,"formTemplate",null),(0,i._)([(0,g.Cb)({readOnly:!0})],ue.prototype,"fieldsIndex",null),(0,i._)([(0,g.Cb)({type:Q.Z,json:{read:{source:"layerDefinition.floorInfo"},write:{target:"layerDefinition.floorInfo"}}})],ue.prototype,"floorInfo",void 0),(0,i._)([(0,g.Cb)(de.outFields)],ue.prototype,"outFields",void 0),(0,i._)([(0,g.Cb)({type:D.U4,readOnly:!0,json:{read:!1}})],ue.prototype,"nodePages",void 0),(0,i._)([(0,b.r)("service","nodePages",["nodePages","pointNodePages"])],ue.prototype,"readNodePages",null),(0,i._)([(0,g.Cb)({type:[D.QI],readOnly:!0})],ue.prototype,"materialDefinitions",void 0),(0,i._)([(0,g.Cb)({type:[D.Yh],readOnly:!0})],ue.prototype,"textureSetDefinitions",void 0),(0,i._)([(0,g.Cb)({type:[D.H3],readOnly:!0})],ue.prototype,"geometryDefinitions",void 0),(0,i._)([(0,g.Cb)({readOnly:!0})],ue.prototype,"serviceUpdateTimeStamp",void 0),(0,i._)([(0,g.Cb)({readOnly:!0})],ue.prototype,"attributeStorageInfo",void 0),(0,i._)([(0,g.Cb)({readOnly:!0})],ue.prototype,"statisticsInfo",void 0),(0,i._)([(0,g.Cb)({type:p.Z.ofType(Number),nonNullable:!0,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.excludeObjectIds",write:{enabled:!0}}})],ue.prototype,"excludeObjectIds",void 0),(0,i._)([(0,g.Cb)({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],ue.prototype,"definitionExpression",void 0),(0,i._)([(0,g.Cb)({type:te,json:{name:"layerDefinition.polygonFilter",write:{enabled:!0,allowNull:!0},origins:{service:{read:!1,write:!1}}}})],ue.prototype,"filter",void 0),(0,i._)([(0,g.Cb)({type:String,json:{origins:{"web-scene":{read:!0,write:!0}},read:!1}})],ue.prototype,"path",void 0),(0,i._)([(0,g.Cb)(P.PV)],ue.prototype,"elevationInfo",null),(0,i._)([(0,g.Cb)({type:String})],ue.prototype,"geometryType",null),(0,i._)([(0,g.Cb)(P.iR)],ue.prototype,"labelsVisible",void 0),(0,i._)([(0,g.Cb)({type:[U.Z],json:{origins:{service:{name:"drawingInfo.labelingInfo",read:{reader:q.r},write:!1}},name:"layerDefinition.drawingInfo.labelingInfo",read:{reader:q.r},write:!0}})],ue.prototype,"labelingInfo",void 0),(0,i._)([(0,g.Cb)(P.rn)],ue.prototype,"legendEnabled",void 0),(0,i._)([(0,g.Cb)({type:Number,json:{origins:{"web-document":{default:1,write:{enabled:!0,target:{opacity:{type:Number},"layerDefinition.drawingInfo.transparency":{type:Number}}},read:{source:["opacity","layerDefinition.drawingInfo.transparency"],reader(e,t){if("number"==typeof e&&e>=0&&e<=1)return e;const r=t.layerDefinition?.drawingInfo?.transparency;return void 0!==r?(0,le.b)(r):void 0}}},"portal-item":{write:!0},service:{read:!1}}}})],ue.prototype,"opacity",void 0),(0,i._)([(0,g.Cb)({type:["Low","High"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"priority",void 0),(0,i._)([(0,g.Cb)({type:["Labels"],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],ue.prototype,"semantic",void 0),(0,i._)([(0,g.Cb)({types:n.o,json:{origins:{service:{read:{source:"drawingInfo.renderer"}}},name:"layerDefinition.drawingInfo.renderer",write:!0},value:null})],ue.prototype,"renderer",null),(0,i._)([(0,g.Cb)({json:{read:!1}})],ue.prototype,"cachedDrawingInfo",void 0),(0,i._)([(0,b.r)("service","cachedDrawingInfo")],ue.prototype,"readCachedDrawingInfo",null),(0,i._)([(0,g.Cb)({readOnly:!0,json:{read:!1}})],ue.prototype,"capabilities",null),(0,i._)([(0,g.Cb)({type:Boolean,json:{read:!1}})],ue.prototype,"editingEnabled",null),(0,i._)([(0,g.Cb)({readOnly:!0,json:{write:!1,read:!1}})],ue.prototype,"infoFor3D",null),(0,i._)([(0,g.Cb)(P.C_)],ue.prototype,"popupEnabled",void 0),(0,i._)([(0,g.Cb)({type:o.Z,json:{name:"popupInfo",write:!0}})],ue.prototype,"popupTemplate",void 0),(0,i._)([(0,g.Cb)({readOnly:!0,json:{read:!1}})],ue.prototype,"defaultPopupTemplate",null),(0,i._)([(0,g.Cb)({type:String,json:{read:!1}})],ue.prototype,"objectIdField",void 0),(0,i._)([(0,b.r)("service","objectIdField",["objectIdField","fields"])],ue.prototype,"readObjectIdField",null),(0,i._)([(0,g.Cb)({type:String,json:{read:!1}})],ue.prototype,"globalIdField",void 0),(0,i._)([(0,b.r)("service","globalIdField",["globalIdField","fields"])],ue.prototype,"readGlobalIdField",null),(0,i._)([(0,g.Cb)({readOnly:!0,type:String,json:{read:!1}})],ue.prototype,"displayField",null),(0,i._)([(0,g.Cb)({type:String,json:{read:!1}})],ue.prototype,"profile",void 0),(0,i._)([(0,b.r)("service","profile",["store.profile"])],ue.prototype,"readProfile",null),(0,i._)([(0,g.Cb)({readOnly:!0,type:String,json:{origins:{service:{read:{source:"store.normalReferenceFrame"}}},read:!1}})],ue.prototype,"normalReferenceFrame",void 0),(0,i._)([(0,g.Cb)(P.YI)],ue.prototype,"screenSizePerspectiveEnabled",void 0),ue=(0,i._)([(0,v.j)("esri.layers.SceneLayer")],ue);const ce={"mesh-pyramids":"mesh-pyramids",meshpyramids:"mesh-pyramids","features-meshes":"mesh-pyramids",points:"points","features-points":"points",lines:"lines","features-lines":"lines",polygons:"polygons","features-polygons":"polygons"},ye={"mesh-pyramids":"mesh",points:"point",lines:"polyline",polygons:"polygon"},he=ue},66094:(e,t,r)=>{r.d(t,{B:()=>s});var i=r(81271);function s(e){return o[function(e){return e instanceof Blob?e.type:function(e){const t=(0,i.Ml)(e);return l[t]||n}(e.url)}(e)]||a}const o={},n="text/plain",a=o[n],l={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpg",bmp:"image/bmp",gif:"image/gif",json:"application/json",txt:"text/plain",xml:"application/xml",svg:"image/svg+xml",zip:"application/zip",pbf:"application/vnd.mapbox-vector-tile",gz:"application/gzip","bin.gz":"application/octet-stream"};for(const e in l)o[l[e]]=e}}]);