D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafdxji
/
shihty.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
/
Filename :
p-0a7d79a6.entry.js
back
Copy
import{r as t,h as s,F as i,a as e}from"./p-e97fde0a.js";import{o as a}from"./p-b719a497.js";import{a as l}from"./p-dd3464cd.js";import{a as n}from"./p-401e165e.js";import"./p-d3366af3.js";const c=":host{display:block}.license__date{font-weight:var(--sc-font-weight-semibold)}.license__heading{display:flex;align-items:center;gap:1rem}.license__key{display:block}.close__button{position:absolute;top:0;right:0;font-size:22px;z-index:1}.license-cancel{display:grid;gap:0.5em}";const o=c;const r=class{constructor(s){t(this,s);this.deleteActivation=async()=>{try{this.busy=true;await l({path:`surecart/v1/activations/${this.selectedActivationId}`,method:"DELETE"});this.onCloseDeleteModal();await this.initialFetch()}catch(t){console.error(t);this.deleteActivationError=(t===null||t===void 0?void 0:t.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.busy=false}};this.onCloseDeleteModal=()=>{this.selectedActivationId="";this.showConfirmDelete=false;this.busy=false;this.deleteActivationError=""};this.licenseId=undefined;this.loading=false;this.error="";this.license=undefined;this.activations=[];this.copied=false;this.showConfirmDelete=false;this.selectedActivationId="";this.deleteActivationError="";this.busy=false;this.pagination={total:0,total_pages:0};this.query={page:1,per_page:10}}nextPage(){this.query.page=this.query.page+1;this.fetchActivations()}prevPage(){this.query.page=this.query.page-1;this.fetchActivations()}componentWillLoad(){a(this.el,(()=>{this.initialFetch()}))}async fetchActivations(){try{this.loading=true;await this.getActivations()}catch(t){console.error(t);this.error=(t===null||t===void 0?void 0:t.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}async initialFetch(){try{this.loading=true;await Promise.all([this.getLicense(),this.getActivations()])}catch(t){console.error(t);this.error=(t===null||t===void 0?void 0:t.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}async getLicense(){this.license=await l({path:n(`surecart/v1/licenses/${this.licenseId}`,{expand:["purchase","purchase.product"]})})}async getActivations(){const t=await l({path:n("surecart/v1/activations",{license_ids:[this.licenseId],...this.query}),parse:false});this.pagination={total:parseInt(t.headers.get("X-WP-Total")),total_pages:parseInt(t.headers.get("X-WP-TotalPages"))};this.activations=await t.json()}async copyKey(t){try{await navigator.clipboard.writeText(t);this.copied=true;setTimeout((()=>{this.copied=false}),2e3)}catch(t){console.error(t);alert(wp.i18n.__("Error copying to clipboard","surecart"))}}renderStatus(){var t,i,e,a;if(((t=this.license)===null||t===void 0?void 0:t.status)==="active"){return s("sc-tag",{type:"success"},wp.i18n.__("Active","surecart"))}if(((i=this.license)===null||i===void 0?void 0:i.status)==="revoked"){return s("sc-tag",{type:"danger"},wp.i18n.__("Revoked","surecart"))}if(((e=this.license)===null||e===void 0?void 0:e.status)==="inactive"){return s("sc-tag",{type:"info"},wp.i18n.__("Inactive","surecart"))}return s("sc-tag",{type:"info"},(a=this.license)===null||a===void 0?void 0:a.status)}renderLoading(){return s("sc-dashboard-module",null,s("span",{slot:"heading"},s("sc-skeleton",{style:{width:"120px"}})),s("sc-card",null,s("sc-stacked-list",null,s("sc-flex",{flexDirection:"column",style:{gap:"1em"}},s("sc-skeleton",{style:{width:"20%",display:"inline-block"}}),s("sc-skeleton",{style:{width:"60%",display:"inline-block"}}),s("sc-skeleton",{style:{width:"40%",display:"inline-block"}})))))}renderEmpty(){return s("sc-empty",{icon:"activity"},wp.i18n.__("License not found.","surecart"))}renderLicenseHeader(){var t;const e=(t=this.license)===null||t===void 0?void 0:t.purchase;const a=e===null||e===void 0?void 0:e.product;return s(i,null,s("span",{slot:"heading"},s("div",{class:"license__heading"},a===null||a===void 0?void 0:a.name,!this.loading&&!e.live_mode&&s("sc-tag",{type:"warning",size:"small"},wp.i18n.__("Test Mode","surecart")))))}renderContent(){var t,e,a,l,n,c,o,r,d;if(this.loading&&!((t=this.license)===null||t===void 0?void 0:t.id)){return this.renderLoading()}if(!((e=this.license)===null||e===void 0?void 0:e.id)){return this.renderEmpty()}return s(i,null,s("sc-dashboard-module",{error:this.error},this.renderLicenseHeader(),s("sc-card",{noPadding:true},s("sc-stacked-list",null,s("sc-stacked-list-row",{style:{"--columns":"2","--sc-stacked-list-row-align-items":"center"}},s("div",null,wp.i18n.__("License Status","surecart")),this.renderStatus()),s("sc-stacked-list-row",{style:{"--columns":"2"}},s("div",null,wp.i18n.__("License Key","surecart")),s("div",{class:"license__key"},s("sc-input",{value:(a=this.license)===null||a===void 0?void 0:a.key,readonly:true},s("sc-button",{class:"license__copy",type:"default",size:"small",slot:"suffix",onClick:()=>{var t;return this.copyKey((t=this.license)===null||t===void 0?void 0:t.key)}},this.copied?wp.i18n.__("Copied!","surecart"):wp.i18n.__("Copy","surecart"))))),s("sc-stacked-list-row",{style:{"--columns":"2"}},s("div",null,wp.i18n.__("Date","surecart")),s("span",null,(l=this.license)===null||l===void 0?void 0:l.created_at_date)),s("sc-stacked-list-row",{style:{"--columns":"2"}},s("div",null,wp.i18n.__("Activations Count","surecart")),s("span",null,(n=this.license)===null||n===void 0?void 0:n.activation_count," / ",((c=this.license)===null||c===void 0?void 0:c.activation_limit)||s("span",null,"∞")))))),s("sc-dashboard-module",null,s("span",{slot:"heading"},s("slot",{name:"heading"},wp.i18n.__("Activations","surecart"))),s("sc-card",{noPadding:true},!!((o=this.activations)===null||o===void 0?void 0:o.length)?s("sc-stacked-list",null,this.activations.map((t=>s("sc-stacked-list-row",{style:{"--columns":"4"}},s("div",{class:"license__date"},t.created_at_date),s("div",null,t.name),s("div",null,t.fingerprint),s("div",null,s("sc-button",{size:"small",onClick:()=>{this.selectedActivationId=t.id;this.showConfirmDelete=true}},wp.i18n.__("Delete","surecart"))))))):s("sc-empty",null,wp.i18n.__("No activations present.","surecart")),this.loading&&s("sc-block-ui",{style:{"--sc-block-ui-opacity":"0.75"},spinner:true})),((r=this.pagination)===null||r===void 0?void 0:r.total_pages)>1&&s("sc-pagination",{page:this.query.page,perPage:this.query.per_page,total:this.pagination.total,totalPages:this.pagination.total_pages,totalShowing:(d=this===null||this===void 0?void 0:this.activations)===null||d===void 0?void 0:d.length,onScNextPage:()=>this.nextPage(),onScPrevPage:()=>this.prevPage()})))}renderConfirmDelete(){return s("sc-dialog",{open:this.showConfirmDelete,style:{"--body-spacing":"var(--sc-spacing-x-large)"},noHeader:true,onScRequestClose:this.onCloseDeleteModal},s("sc-button",{class:"close__button",type:"text",circle:true,onClick:this.onCloseDeleteModal,disabled:this.loading},s("sc-icon",{name:"x"})),s("sc-dashboard-module",{heading:wp.i18n.__("Delete Activation","surecart"),class:"license-cancel",error:this.error,style:{"--sc-dashboard-module-spacing":"1em"}},s("span",{slot:"description"},wp.i18n.__("Are you sure you want to delete activation?","surecart")),s("sc-flex",{justifyContent:"flex-start"},s("sc-button",{type:"primary",disabled:this.loading||this.busy,onClick:this.deleteActivation},wp.i18n.__("Delete Activation","surecart")),s("sc-button",{style:{color:"var(--sc-color-gray-500"},type:"text",onClick:this.onCloseDeleteModal,disabled:this.loading||this.busy},wp.i18n.__("Cancel","surecart"))),this.busy&&s("sc-block-ui",{style:{"--sc-block-ui-opacity":"0.75"},spinner:true})))}render(){return s("sc-spacing",{key:"c4ec74570eb30fc9ad2a29dc2b82392942528028",style:{"--spacing":"var(--sc-spacing-large)"}},this.renderContent(),this.renderConfirmDelete())}get el(){return e(this)}};r.style=o;export{r as sc_license}; //# sourceMappingURL=p-0a7d79a6.entry.js.map