import{h}from"@stencil/core";import{__}from"@wordpress/i18n";import{addQueryArgs}from"@wordpress/url";import apiFetch from"../../../../functions/fetch";import{onFirstVisible}from"../../../../functions/lazy";export class ScDashboardCustomerDetails{constructor(){this.customerId=void 0,this.heading=void 0,this.customer=void 0,this.loading=void 0,this.error=void 0}componentWillLoad(){onFirstVisible(this.el,(()=>{this.fetch()}))}async fetch(){if(""!==this.customerId)try{this.loading=!0,this.customer=await await apiFetch({path:addQueryArgs(`surecart/v1/customers/${this.customerId}`,{expand:["shipping_address","billing_address","tax_identifier"]})})}catch(t){(null==t?void 0:t.message)?this.error=t.message:this.error=__("Something went wrong","surecart"),console.error(this.error)}finally{this.loading=!1}}render(){return h("sc-customer-details",{key:"daa6010b4f0b5ace8987b50dfdaa0818df7fd0f8",exportparts:"base, heading, heading-text, heading-title, heading-description, error__base, error__icon, error__text, error__title, error__message, test-tag__base, test-tag__content, button__base, button__label, button__prefix",customer:this.customer,loading:this.loading,error:this.error,heading:this.heading,"edit-link":addQueryArgs(window.location.href,{action:"edit",model:"customer",id:this.customerId})})}static get is(){return"sc-dashboard-customer-details"}static get encapsulation(){return"shadow"}static get originalStyleUrls(){return{$:["sc-dashboard-customer-details.css"]}}static get styleUrls(){return{$:["sc-dashboard-customer-details.css"]}}static get properties(){return{customerId:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:""},attribute:"customer-id",reflect:!1},heading:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:""},attribute:"heading",reflect:!1}}}static get states(){return{customer:{},loading:{},error:{}}}static get elementRef(){return"el"}}