// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("require ../chunks/tslib.es6 ../intl ../core/Collection ../core/jsonMap ../core/lang ../core/reactiveUtils ../core/unitFormatUtils ../core/urlUtils ../core/accessorSupport/decorators/property ../core/has ../core/Logger ../core/accessorSupport/decorators/subclass ../portal/support/urlUtils ../rest/utils ../rest/support/fileFormat ./Widget ./Print/FileLink ./Print/PrintViewModel ../chunks/componentsUtils ./support/globalCss ./support/Heading ./support/legacyIcon ./support/widgetUtils ./support/decorators/messageBundle ./support/jsxFactory ../intl/number".split(" "), function(x,p,m,T,U,M,G,V,N,q,ka,la,W,X,Y,Z,aa,O,P,ba,F,ca,da,Q,K,c,R){function E(a,b){return b?a.some(e=>e.layoutItem?.id===b||e.layout===b):!1}const S=T.ofType(O);var h;(function(a){a.layout="layoutTab";a.mapOnly="mapOnlyTab";a["export"]="exportTab"})(h||={});const ea=new U.JSONMap({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});m=class extends aa{constructor(a, b){super(a,b);this._awaitingServerResponse=this._activeTabFocusRequested=!1;this._exportedFileNameMap={};this._selectedTab=h.layout;this._pendingExportScroll=!1;this._abortController=this._selectedLayout=this._rootNode=null;this._showTemplates=!1;this.browseTemplateButtonOnClick=null;this.exportedLinks=new S;this.headingLevel=3;this.messagesUnits=this.messagesCommon=null;this.viewModel=new P;this._onInput=e=>{this._selectedTab===h.layout?this.templateOptions.title=e.target.value:this._selectedTab=== h.mapOnly&&(this.templateOptions.fileName=e.target.value)};this._removeLink=e=>{(e=e.currentTarget["data-item"])&&this.exportedLinks.remove(e)};this._handleLinkClick=e=>{const d=e.currentTarget["data-item"];if(d&&"ready"===d.state&&d.url){var g=Y.getToken(this.viewModel.effectivePrintServiceUrl),r=d.url,l=document.createElement("a");l.target="_blank";l.href=r;l.rel="noreferrer";l.download=d.formattedName??"";g?(e.preventDefault(),e=new URL(r),e.searchParams.set("token",g),l.href=e.href,l.click(), l.href=r):(l.click(),e.stopPropagation())}};this._focusOnTabChange=this._focusOnTabChange.bind(this)}initialize(){this.addHandles([G.watch(()=>[this.templateOptions.format,this.viewModel.templatesInfo?.format.defaultValue],([d,g])=>{if(g&&!d)this.templateOptions.format=g;else if(d&&g&&this.viewModel.templatesInfo&&!this.viewModel.templatesInfo.format.choiceList.includes(d)){var r=this.viewModel.templatesInfo.format.choiceList.find(l=>l.toUpperCase().includes(`(${d.toUpperCase()})`));this.templateOptions.format= r??g}}),G.watch(()=>[this.templateOptions.layout,this.viewModel.templatesInfo?.layout.defaultValue],async([d,g])=>{this._selectedTab="MAP_ONLY"===d?.toUpperCase()?h.mapOnly:h.layout;if(this._selectedTab===h.layout){var {includeDefaultTemplates:r,viewModel:l,_selectedLayout:n}=this,{portalTemplateIds:u,browseTemplates:z,templatesInfo:y}=l,A=l.defaultTemplates.filter(({layoutItem:k})=>u.includes(k?.id)),C=l.defaultTemplates.filter(({layoutItem:k})=>!u.includes(k?.id)),f=r&&C.length;d?(f?E(C,d):y?.layout.choiceList.includes(d))|| E(A,d)||E(z,d)||(this.templateOptions.layout=null,this.templateOptions.layoutItem=null):(n&&((f?E(C,n):y?.layout.choiceList.includes(n))||E(A,n)||E(z,n))?await this._applyTemplate(n):(this.templateOptions.layout=null,this.templateOptions.layoutItem=null),this.templateOptions.layout||f||!g||await this._applyTemplate(g));this._selectedLayout=this.templateOptions.layout;d=!!this.templateOptions.layout&&this.viewModel.effectiveTemplateCustomTextElements[this.templateOptions.layout];this.templateOptions.customTextElements= d?M.clone(d):null}}),G.watch(()=>this.templateOptions.dpi,d=>{0>=d&&(this.templateOptions.dpi=1)}),G.watch(()=>this.viewModel.view?.scale,d=>{!d||this.templateOptions.scaleEnabled&&this.templateOptions.scale||(this.templateOptions.scale=d)})]);const {height:a,width:b}=this.templateOptions;this.templateOptions.width=b||800;this.templateOptions.height=a||1100;const e=setTimeout(()=>{this._awaitingServerResponse=!0;this.scheduleRender()},500);this.viewModel.load().then(()=>{clearTimeout(e);this._awaitingServerResponse= !1})}loadDependencies(){return ba.loadCalciteComponents({action:()=>new Promise((a,b)=>x(["../chunks/calcite-action"],a,b)),block:()=>new Promise((a,b)=>x(["../chunks/calcite-block"],a,b)),button:()=>new Promise((a,b)=>x(["../chunks/calcite-button"],a,b)),checkbox:()=>new Promise((a,b)=>x(["../chunks/calcite-checkbox"],a,b)),combobox:()=>new Promise((a,b)=>x(["../chunks/calcite-combobox"],a,b)),"combobox-item":()=>new Promise((a,b)=>x(["../chunks/calcite-combobox-item"],a,b)),flow:()=>new Promise((a, b)=>x(["../chunks/calcite-flow"],a,b)),"flow-item":()=>new Promise((a,b)=>x(["../chunks/calcite-flow-item"],a,b)),icon:()=>new Promise((a,b)=>x(["../chunks/calcite-icon"],a,b)),input:()=>new Promise((a,b)=>x(["../chunks/calcite-input"],a,b)),label:()=>new Promise((a,b)=>x(["../chunks/calcite-label"],a,b)),list:()=>new Promise((a,b)=>x(["../chunks/calcite-list"],a,b)),"list-item":()=>new Promise((a,b)=>x(["../chunks/calcite-list-item"],a,b)),loader:()=>new Promise((a,b)=>x(["../chunks/calcite-loader"], a,b)),switch:()=>new Promise((a,b)=>x(["../chunks/calcite-switch"],a,b)),chip:()=>new Promise((a,b)=>x(["../chunks/calcite-chip"],a,b))})}destroy(){this.viewModel.destroy()}get allowedFormats(){return this.viewModel.allowedFormats}set allowedFormats(a){this.viewModel.allowedFormats=a}get allowedLayouts(){return this.viewModel.allowedLayouts}set allowedLayouts(a){this.viewModel.allowedLayouts=a}get error(){return this.viewModel.error}get extraParameters(){return this.viewModel.extraParameters}set extraParameters(a){this.viewModel.extraParameters= a}get icon(){return"print"}set icon(a){this._overrideIfSome("icon",a)}get includeDefaultTemplates(){return this.viewModel.includeDefaultTemplates}set includeDefaultTemplates(a){this.viewModel.includeDefaultTemplates=a}get label(){return this.messages?.widgetLabel??""}set label(a){this._overrideIfSome("label",a)}get portal(){return this.viewModel.portal}set portal(a){this.viewModel.portal=a}get showPrintAreaEnabled(){return this.viewModel.showPrintAreaEnabled}set showPrintAreaEnabled(a){this.viewModel.showPrintAreaEnabled= a}get printServiceUrl(){return this.viewModel.printServiceUrl}set printServiceUrl(a){this.viewModel.printServiceUrl=a}get templateCustomTextElements(){return this.viewModel.templateCustomTextElements}set templateCustomTextElements(a){this.viewModel.templateCustomTextElements=a}get templateOptions(){return this.viewModel.templateOptions}set templateOptions(a){this.viewModel.templateOptions=a}get view(){return this.viewModel.view}set view(a){this.viewModel.view=a}render(){const {messages:a,templateOptions:b, viewModel:e,view:d}=this,{attributionEnabled:g,author:r,copyright:l,dpi:n,format:u,height:z,layout:y,legendEnabled:A,northArrowEnabled:C,scaleEnabled:f,scale:k,width:t}=b;var v="ready"!==e.state||this._awaitingServerResponse||!y,w=this._renderTitleOrFileNameSection(),H=c.tsx("div",{class:"esri-print__form-section-container"},c.tsx("calcite-label",null,a.fileFormatTitle,c.tsx("calcite-combobox",{clearDisabled:!0,label:a.formatDefaultOption,maxItems:6,placeholder:a.formatDefaultOption,selectionMode:"single-persist", onCalciteComboboxChange:({target:D})=>{this.templateOptions.format=D.selectedItems[0].value}},e.templatesInfo?.format?.choiceList.sort().map((D,fa)=>c.tsx("calcite-combobox-item",{key:`file-format-${fa}`,selected:D===this.templateOptions.format,textLabel:Z.toJSON(D),value:D}))))),I=c.tsx("calcite-label",{layout:"inline"},c.tsx("calcite-switch",{checked:this.showPrintAreaEnabled,onCalciteSwitchChange:D=>{this.showPrintAreaEnabled=!!D.target.checked}}),a.printPreview),L=c.tsx("div",null,c.tsx("div", {class:"esri-print__form-section-container"},c.tsx("calcite-label",null,a.template,c.tsx("div",{class:"esri-print__template-select-container",onclick:()=>{this._showTemplates=!0}},c.tsx("calcite-block",{class:"esri-print__template-select-block",description:this._getPageSizeLabel(y),heading:this._getTemplateLabel()}),c.tsx("calcite-icon",{class:"esri-print__template-select-icon",icon:Q.isRTL()?"chevron-left":"chevron-right",scale:"s"})))),I),B=c.tsx("div",{class:"esri-print__form-section-container"}, c.tsx("calcite-label",null,a.dpi,c.tsx("calcite-input",{bind:this,"data-input-name":"dpi",min:1,tabIndex:0,type:"number",value:`${n}`,onCalciteInputInput:this._handleDPIChange}))),J=c.tsx("div",{class:this.classes("esri-print__scale-info-container","esri-print__form-section-container")},c.tsx("calcite-label",{layout:"inline"},c.tsx("calcite-checkbox",{bind:this,checked:f,"data-option-name":"scaleEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),a.scale),c.tsx("div",{class:"esri-print__scale-input-container"}, c.tsx("calcite-input",{"aria-label":a.scaleLabel,"aria-valuenow":`${k}`,bind:this,class:"esri-print__scale-input","data-input-name":"scale",disabled:!f,tabIndex:0,type:"number",value:`${k}`,onCalciteInputInput:this._updateInputValue}),c.tsx("calcite-button",{appearance:"outline","aria-label":a.reset,bind:this,disabled:!f,iconStart:"refresh",kind:"neutral",onclick:this._resetToCurrentScale,tabIndex:0})));const ha=c.tsx("div",{"aria-labelledby":`${this.id}__advancedOptionsForLayout`,class:"esri-print__advanced-options-container", key:"advanced-section-for-layout"},J,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasAuthorText??!0?c.tsx("div",{class:"esri-print__form-section-container",key:"author-info"},c.tsx("calcite-label",null,a.author,c.tsx("calcite-input",{bind:this,"data-input-name":"author",tabIndex:0,value:r??"",onCalciteInputInput:this._updateInputValue}))):null,this.viewModel.layoutTemplateInfo?.layoutOptions?.hasCopyrightText??!0?c.tsx("div",{class:"esri-print__form-section-container",key:"copyright-text"},c.tsx("calcite-label", null,a.copyright,c.tsx("calcite-input",{bind:this,"data-input-name":"copyright",tabIndex:0,value:l??"",onCalciteInputInput:this._updateInputValue}))):null,B,this._renderCustomTextElementSection(),this.viewModel.layoutTemplateInfo?.layoutOptions?.hasLegend??!0?c.tsx("div",{class:"esri-print__form-section-container",key:"legend-info"},c.tsx("calcite-label",{layout:"inline"},c.tsx("calcite-checkbox",{bind:this,checked:A,"data-option-name":"legendEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}), a.legend)):null,this.viewModel.layoutTemplateNorthArrowInfo??!0?c.tsx("div",{class:"esri-print__form-section-container",key:"north-arrow"},c.tsx("calcite-label",{layout:"inline"},c.tsx("calcite-checkbox",{bind:this,checked:C,"data-option-name":"northArrowEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),a.northArrow)):null);J=c.tsx("div",{"aria-labelledby":`${this.id}__advancedOptionsForMapOnly`,class:"esri-print__advanced-options-container"},J,B,c.tsx("div",{class:"esri-print__form-section-container"}, c.tsx("calcite-label",{layout:"inline"},c.tsx("calcite-checkbox",{bind:this,checked:g,"data-option-name":"attributionEnabled",tabIndex:0,onCalciteCheckboxChange:this._toggleInputValue}),a.attribution)),this._renderCustomTextElementSection());B=this.exportedLinks.toArray();const ia=this._renderExportedLink(B),ja={["esri-print__export-section--centered"]:!B.length};I=this._selectedTab===h.layout?c.tsx("section",{"aria-labelledby":`${this.id}__layoutTab`,class:"esri-print__layout-section",id:`${this.id}__layoutContent`, key:"esri-print__layoutContent",role:"tabpanel"},c.tsx("div",{class:"esri-print__panel-container"},this.viewModel.layoutTemplateInfo?.layoutOptions?.hasTitleText??!0?w:null,L,this._selectedTab===h.layout?H:null,c.tsx("calcite-block",{"aria-label":a.advancedOptions,class:this.classes("esri-print__panel-container","esri-print__advanced-options-section"),collapsible:!0,disabled:!y,heading:a.advancedOptions,id:"advancedOptionsForLayout",key:"advanced-options-for-layout"},ha))):this._selectedTab===h.mapOnly? c.tsx("section",{"aria-labelledby":`${this.id}__mapOnlyTab`,class:"esri-print__map-only-section",id:`${this.id}__mapOnlyContent`,key:"esri-print__mapOnlyContent",role:"tabpanel"},c.tsx("div",{class:"esri-print__panel-container"},w,H,c.tsx("div",null,c.tsx("div",{class:this.classes("esri-print__size-container","esri-print__form-section-container")},c.tsx("calcite-label",null,a.width,c.tsx("calcite-input",{bind:this,"data-input-name":"width",tabIndex:0,type:"number",value:`${t}`,onCalciteInputInput:this._updateInputValue})), c.tsx("calcite-label",null,a.height,c.tsx("calcite-input",{bind:this,"data-input-name":"height",tabIndex:0,type:"number",value:`${z}`,onCalciteInputInput:this._updateInputValue})),c.tsx("button",{"aria-label":a.swap,bind:this,class:this.classes(F.globalCss.widgetButton,"esri-print__swap-button",da.legacyIcon.swap),onclick:this._switchInput,tabIndex:0,type:"button"})),I),c.tsx("calcite-block",{"aria-label":a.advancedOptions,class:this.classes("esri-print__panel-container","esri-print__advanced-options-section"), collapsible:!0,heading:a.advancedOptions,id:"advancedOptionsForMapOnly",key:"advanced-options-for-map-only"},J))):c.tsx("section",{"aria-labelledby":`${this.id}__exportTab`,class:this.classes("esri-print__export-section",ja),id:`${this.id}__exportContent`,key:"esri-print__exportContent",role:"tabpanel"},c.tsx("div",{class:"esri-print__panel-container"},c.tsx("div",{afterUpdate:this._scrollExportIntoView,bind:this,class:"esri-print__export-panel-container"},0===B.length?c.tsx("div",{class:"esri-print__exported-files-empty"}, c.tsx("calcite-icon",{icon:"file",scale:"l"}),c.tsx("div",null,c.tsx(ca.Heading,{class:"esri-print__export-title",level:this.headingLevel},a.noExportedFiles),c.tsx("div",null,a.exportHint))):ia)));L={[F.globalCss.buttonDisabled]:v||!y&&!u};w=!d||"2d"!==d.type;H=c.tsx("div",{class:"esri-print__panel--error"},w?a.sceneViewError:a.serviceError);B=B.some(({state:D})=>"pending"===D);v=c.tsx("div",{class:"esri-print__content",key:"panel"},c.tsx("div",null,c.tsx("ul",{bind:this,class:"esri-print__layout-tab-list", onclick:this._toggleLayoutPanel,onkeydown:this._handleLayoutPanelKeyDown,role:"tablist"},c.tsx("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===h.layout}`,class:"esri-print__layout-tab","data-tab-id":h.layout,id:`${this.id}__layoutTab`,role:"tab",tabIndex:0},a.layoutTab),c.tsx("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===h.mapOnly}`,class:"esri-print__layout-tab", "data-tab-id":h.mapOnly,id:`${this.id}__mapOnlyTab`,role:"tab",tabIndex:0},a.mapOnlyTab),c.tsx("li",{afterCreate:this._focusOnTabChange,afterUpdate:this._focusOnTabChange,"aria-selected":`${this._selectedTab===h.export}`,class:"esri-print__layout-tab","data-tab-id":h.export,id:`${this.id}__exportedFilesTab`,role:"tab",tabIndex:0},B?c.tsx("calcite-loader",{inline:!0,label:"loading",scale:"s"}):null,a.exportsTab)),I),this._selectedTab!==h.export?c.tsx("button",{"aria-label":a.exportDescription,bind:this, class:this.classes("esri-print__export-button",F.globalCss.button,L),disabled:v,onclick:this._handlePrintMap,tabIndex:0,type:"button"},a.export):null);B=c.tsx("calcite-flow",{key:"root-flow"},c.tsx("calcite-flow-item",{bind:this,key:"root-flow-item"},c.tsx("div",{class:"esri-print__container"},c.tsx("header",{class:"esri-print__header-title"},a.export),this.error||w||!d?H:v)),this._renderChooseTemplateFlowItem());B=(v="initializing"===e.state)?this._renderLoader():B;return c.tsx("div",{bind:this, class:this.classes("esri-print",F.globalCss.widget,F.globalCss.panel,{["esri-print__panel-items--centered"]:v})},B)}_getPageSizeLabel(a){if(a&&(a=this.viewModel.getLayoutTemplateInfo(a))){var b=ea.fromJSON(a.pageUnits.toLowerCase());return`${R.formatNumber(a.pageSize[0])} x ${R.formatNumber(a.pageSize[1])} ${V.unitName(this.messagesUnits,b,"abbr")}`}}_getTemplateLabel(){const {messages:a,includeDefaultTemplates:b,templateOptions:e,viewModel:d}=this,{layout:g}=e;return(g?(b?d.defaultTemplates.find(({layoutItem:r, layout:l})=>g===r?.id||g===l):null)??d.browseTemplates.find(({layoutItem:r})=>g===r?.id):null)?.label?.replaceAll("_"," ")??a[g]??g?.replaceAll("_"," ")??a.selectTemplate}_renderChooseTemplateFlowItem(){if(!this._showTemplates)return null;const {includeDefaultTemplates:a,messages:b,viewModel:e}=this,{defaultTemplates:d,templatesInfo:g,browseTemplates:r,portalTemplateIds:l}=e,n=X.reArcGISOnlineDomain.test(this.portal?.url),u=r.length?r.toArray().sort((f,k)=>(f.label??"")>(k.label??"")?1:-1).map((f, k)=>{const t=f.layoutItem?.id??f.layout,v=this._getPageSizeLabel(t),w=t===this.templateOptions.layout;return c.tsx("calcite-list-item",{description:v,key:`browse-template-${k}`,label:f?.label?.replaceAll("_"," ")??b.untitled,selected:w,title:f.description??"",value:t},!v&&w&&f.layoutItem?.id?c.tsx("calcite-loader",{inline:!0,key:`browse-template-loader-${k}`,label:"loading",scale:"s",slot:"content-end"}):null,c.tsx("calcite-action",{icon:"trash",onclick:()=>e.removePortalTemplate(f),slot:"actions-end", text:"delete"}))}):null,z=d.length&&a?d.toArray().filter(({label:f,layoutItem:k})=>"MAP_ONLY"!==f?.toUpperCase()&&l.includes(k?.id)).map((f,k)=>{const t=f.layoutItem?.id??f.layout,v=this._getPageSizeLabel(t),w=t===this.templateOptions.layout;return c.tsx("calcite-list-item",{description:v,key:`portal-template-${t}-${w}`,label:f?.label?.replaceAll("_"," ")??b.untitled,selected:w,title:f.description??"",value:t},!v&&w&&f.layoutItem?.id?c.tsx("calcite-loader",{inline:!0,key:`portal-template-loader-${k}`, label:"loading",scale:"s",slot:"content-end"}):null)}):null,y=d.length&&a?d.toArray().filter(({label:f,layoutItem:k})=>"MAP_ONLY"!==f?.toUpperCase()&&!l.includes(k?.id)).sort((f,k)=>(f.label??"")>(k.label??"")?1:-1).map((f,k)=>{const t=f.layoutItem?.id??f.layout,v=this._getPageSizeLabel(t),w=t===this.templateOptions.layout;return c.tsx("calcite-list-item",{description:v,key:`default-template-${k}`,label:f?.label?.replaceAll("_"," ")??b.untitled,selected:w,title:f.description??"",value:t},!v&&w&&f.layoutItem?.id? c.tsx("calcite-loader",{inline:!0,key:`default-template-loader-${k}`,label:"loading",scale:"s",slot:"content-end"}):null)}):null,A=!g?.layout?.choiceList.length||a&&y?.length?null:g.layout.choiceList.map(f=>({label:b[f]??f.replaceAll("_"," "),value:f})).sort((f,k)=>f.label>k.label?1:0).map(({label:f,value:k},t)=>c.tsx("calcite-list-item",{description:this._getPageSizeLabel(k),key:`service-template-${t}`,label:f,selected:k===this.templateOptions.layout,value:k})),C=15<(u?.length??0)+(z?.length??0)+ (y?.length??0)+(A?.length??0);return c.tsx("calcite-flow-item",{bind:this,closable:!1,heading:b.chooseTemplate,key:"template-flow-item",onCalciteFlowItemBack:f=>{f.preventDefault();this._showTemplates=!1}},c.tsx("div",{class:"esri-print__template-select-flow-item-container"},c.tsx("div",{class:"esri-print__template-select-flow-item-content"},this.browseTemplateButtonOnClick?c.tsx("calcite-button",{appearance:"outline",class:"esri-print__browse-template-button-container",key:"browse-template-button", onclick:this.browseTemplateButtonOnClick},"Browse Templates"):null,c.tsx("calcite-list",{filterEnabled:C,key:"template-list",selectionMode:"single-persist",onCalciteListChange:({target:f})=>this._applyTemplate(f.selectedItems[0].value)},u?.length?c.tsx("div",{key:"my-templates"},c.tsx("div",{class:"esri-print__template-select-flow-item-list-heading"},b.myTemplates,c.tsx("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:b.beta},b.beta)),u):null,z?.length?c.tsx("div",{key:"org-templates"}, c.tsx("div",{class:"esri-print__template-select-flow-item-list-heading"},b.organizationTemplates,n?c.tsx("calcite-chip",{appearance:"outline",kind:"neutral",scale:"s",value:b.beta},b.beta):null),z):null,u?.length||z?.length?y?.length?c.tsx("div",{key:"default-templates"},c.tsx("div",{class:"esri-print__template-select-flow-item-list-heading"},b.defaultTemplates),y):null:y,u?.length||z?.length?A?.length?c.tsx("div",{key:"service-templates"},c.tsx("div",{class:"esri-print__template-select-flow-item-list-heading"}, b.defaultTemplates),A):null:A)),c.tsx("div",{class:"esri-print__template-button-container"},c.tsx("calcite-button",{class:"esri-print__template-done-button",onclick:()=>this._showTemplates=!1},this.messagesCommon.done))))}_renderCustomTextElementSection(){const {customTextElements:a}=this.templateOptions;return a?c.tsx("div",{class:"esri-print__form-section-container",key:"custom-text-elements"},a.map((b,e)=>{const [d,g]=Object.entries(b)[0];return"date"===d?null:c.tsx("calcite-label",{key:`custom-text-elements-${d}-${e}`}, d,c.tsx("calcite-input",{bind:this,"data-input-custom":!0,"data-input-name":d,value:g??"",onCalciteInputInput:this._updateInputValue}))})):null}async _applyTemplate(a){this._abortController&&(this._abortController.abort(),this._abortController=null);if(a){var b=this.viewModel.defaultTemplates.find(({layoutItem:n})=>a===n?.id)??this.viewModel.browseTemplates.find(({layoutItem:n})=>a===n?.id);if(b){var {layoutItem:e}=b,d=b.format??this.templateOptions.format,g=e?.id??b.layout??this.templateOptions.layout; this.templateOptions.layout=g;if(!b.layoutOptions)try{this._abortController=new AbortController,await this.viewModel.fetchLayoutTemplateInfo(b,{signal:this._abortController.signal})}catch(n){return}finally{this._abortController=null}var r=b.layoutOptions?.legend??this.templateOptions.legendEnabled;b=b.layoutOptions?.northArrow??this.templateOptions.northArrowEnabled;var l=g?this.viewModel.effectiveTemplateCustomTextElements[g]:null;l=l?M.clone(l):null;this.templateOptions.set({customTextElements:l, format:d,layout:g,layoutItem:e,legendEnabled:r,northArrowEnabled:b})}else this.templateOptions.layout=a,this.templateOptions.layoutItem=null}}_renderTitleOrFileNameSection(){const {title:a,fileName:b,titlePlaceHolder:e,fileNamePlaceHolder:d}=this.messages,g=this._selectedTab===h.layout?a:b;return c.tsx("div",{class:"esri-print__form-section-container",key:g},c.tsx("calcite-label",null,g,c.tsx("calcite-input",{placeholder:this._selectedTab===h.layout?e:d,value:(this._selectedTab===h.layout?this.templateOptions.title: this.templateOptions.fileName)??"",onCalciteInputInput:this._onInput})))}_focusOnTabChange(a){if(this._activeTabFocusRequested){var b=a.getAttribute("data-tab-id");if("layoutTab"===b&&this._selectedTab===h.layout||"mapOnlyTab"===b&&this._selectedTab===h.mapOnly||"exportTab"===b&&this._selectedTab===h.export)a.focus(),this._activeTabFocusRequested=!1}}_renderLoader(){return c.tsx("div",{class:this.classes({["esri-print__loader"]:this._awaitingServerResponse}),key:"loader"})}_createFileLink(a,b){b= b||this.messages.untitled;a=a.format.toLowerCase();a=a.includes("png")?"png":a;const e=b+a;void 0!==this._exportedFileNameMap[e]?this._exportedFileNameMap[e]++:this._exportedFileNameMap[e]=0;return new O({name:b,extension:a,count:this._exportedFileNameMap[e]})}_resetToCurrentScale(){this.templateOptions.scale=this.viewModel.view?.scale}_updateCustomTextElementValue(a,b,e){a.find(d=>{[d]=Object.entries(d)[0];return d===b})[b]=e}_updateInputValue(a){var b=a.target;a=b.getAttribute("data-input-name"); var e=!!b["data-input-custom"];const {templateOptions:d}=this;if(e)this._updateCustomTextElementValue(d.customTextElements,a,b.value);else{if("number"===b.type){const g=Number(b.value);e=g;if(isNaN(e)||!(0{e.set({url:d&&d.url,state:"ready"})}).catch(d=>{e.set({error:d,state:"error"})}).then(()=>{this.emit("complete",{link:e});this.scheduleRender()})}_switchInput(){[this.templateOptions.width,this.templateOptions.height]=[this.templateOptions.height, this.templateOptions.width]}_scrollExportIntoView(){if(this._pendingExportScroll){this._pendingExportScroll=!1;var a=this._rootNode;if(a){var {clientHeight:b,scrollHeight:e}=a,d=e-b;0{const {error:g,url:r,state:l}=d,n=d.formattedName??"";var u="error"===l;const z="pending"=== l,y="ready"===l;var A=r||null;A&&=N.addProxy(A);A=N.hasSameOrigin(r,location.href);u=u?"print-task:cim-symbol-unsupported"===g?.name?b.exportWebMapCIMError:b.exportWebMapError:"";var C=c.tsx,f={"aria-label":z?b.pending:y?b.ready:b.errorMessage,class:"esri-print__exported-file","data-item":d,description:z?b.generatingExport:u||(A?b.ready:b.linkReady),key:n,label:n,title:u,onCalciteListItemSelect:this._handleLinkClick};if(z)var k=c.tsx("calcite-loader",{class:"esri-print__exported-file--loader",inline:!0, key:`${n}-loader`,label:b.generatingExport,scale:"m",slot:"content-start"});else{k=c.tsx;a:{const {state:v,extension:w}=d;switch(v){case "pending":var t="spinner";break a;case "error":t="exclamation-mark-circle";break a;default:t=w?.toLowerCase()?.includes("pdf")?"file-pdf":"file"}}k=k.call(c,"calcite-icon",{icon:t,key:`${n}-start-icon`,scale:"s",slot:"content-start"})}return C.call(c,"calcite-list-item",f,k,y?c.tsx("calcite-icon",{"aria-label":`${n}. ${b.linkReady}`,icon:A?"download-to":"launch", key:`${n}-end-icon`,scale:"s",slot:"content-end"}):null,z?null:c.tsx("calcite-action",{"aria-label":`${u}`,"data-item":d,icon:"x",key:`${n}-action`,onclick:this._removeLink,slot:"actions-end",text:`${u}`}))});return c.tsx("calcite-list",{filterEnabled:10