import{h}from"@stencil/core";import{__,sprintf}from"@wordpress/i18n";export class ScPaymentMethodDetails{constructor(){this.paymentMethod=void 0,this.editHandler=void 0}render(){var t,e,o,i,n,d,a,l,r,s;return h("sc-card",null,h("sc-flex",{alignItems:"center",justifyContent:"flex-start",style:{gap:"0.5em"}},h("sc-payment-method",{paymentMethod:this.paymentMethod}),h("div",null,!!(null===(e=null===(t=this.paymentMethod)||void 0===t?void 0:t.card)||void 0===e?void 0:e.exp_month)&&h("span",null,
// Translators: %d/%d is month and year of expiration.
sprintf(__("Exp. %d/%d","surecart"),null===(i=null===(o=this.paymentMethod)||void 0===o?void 0:o.card)||void 0===i?void 0:i.exp_month,null===(d=null===(n=this.paymentMethod)||void 0===n?void 0:n.card)||void 0===d?void 0:d.exp_year)),!!(null===(l=null===(a=this.paymentMethod)||void 0===a?void 0:a.paypal_account)||void 0===l?void 0:l.email)&&(null===(s=null===(r=this.paymentMethod)||void 0===r?void 0:r.paypal_account)||void 0===s?void 0:s.email)),h("sc-button",{type:"text",circle:!0,onClick:this.editHandler},h("sc-icon",{name:"edit-2"}))))}static get is(){return"sc-payment-method-details"}static get encapsulation(){return"shadow"}static get properties(){return{paymentMethod:{type:"unknown",mutable:!1,complexType:{original:"PaymentMethod",resolved:"PaymentMethod",references:{PaymentMethod:{location:"import",path:"../../../types"}}},required:!1,optional:!1,docs:{tags:[],text:""}},editHandler:{type:"unknown",mutable:!1,complexType:{original:"() => void",resolved:"() => void",references:{}},required:!1,optional:!1,docs:{tags:[],text:""}}}}}/**
* AJAX Request Queue
*
* - add()
* - remove()
* - run()
* - stop()
*
* @since 1.0.0
*/
var AstraSitesAjaxQueue = ( function () {
var requests = [];
return {
/**
* Add AJAX request
*
* @since 1.0.0
*/
add: function ( opt ) {
requests.push( opt );
},
/**
* Remove AJAX request
*
* @since 1.0.0
*/
remove: function ( opt ) {
if ( jQuery.inArray( opt, requests ) > -1 )
requests.splice( $.inArray( opt, requests ), 1 );
},
/**
* Run / Process AJAX request
*
* @since 1.0.0
*/
run: function () {
var self = this,
oriSuc;
if ( requests.length ) {
oriSuc = requests[ 0 ].complete;
requests[ 0 ].complete = function () {
if ( typeof oriSuc === 'function' ) oriSuc();
requests.shift();
self.run.apply( self, [] );
};
jQuery.ajax( requests[ 0 ] );
} else {
self.tid = setTimeout( function () {
self.run.apply( self, [] );
}, 1000 );
}
},
/**
* Stop AJAX request
*
* @since 1.0.0
*/
stop: function () {
requests = [];
clearTimeout( this.tid );
},
};
} )();
( function ( $ ) {
$elscope = {};
$.fn.isInViewport = function () {
// If not have the element then return false!
if ( ! $( this ).length ) {
return false;
}
var elementTop = $( this ).offset().top;
var elementBottom = elementTop + $( this ).outerHeight();
var viewportTop = $( window ).scrollTop();
var viewportBottom = viewportTop + $( window ).height();
return elementBottom > viewportTop && elementTop < viewportBottom;
};
AstraElementorSitesAdmin = {
visited_pages: [],
reset_remaining_posts: 0,
site_imported_data: null,
backup_taken: false,
templateData: {},
insertData: {},
log_file: '',
pages_list: '',
insertActionFlag: false,
page_id: '',
site_id: '',
block_id: '',
requiredPlugins: [],
canImport: false,
canInsert: false,
type: 'pages',
action: '',
masonryObj: [],
index: 0,
blockCategory: '',
blockColor: '',
processing: false,
siteType: '',
page: 1,
per_page: 20,
init: function () {
this._bind();
},
/**
* Binds events for the Astra Sites.
*
* @since 1.0.0
* @access private
* @method _bind
*/
_bind: function () {
if ( elementorCommon ) {
let add_section_tmpl = $( '#tmpl-elementor-add-section' );
if ( add_section_tmpl.length > 0 ) {
let action_for_add_section = add_section_tmpl.text();
let white_label_class = '';
let stylesheet = '';
if ( astraElementorSites.isWhiteLabeled ) {
white_label_class = ' ast-elementor-white-label';
stylesheet =
'";
}
action_for_add_section = action_for_add_section.replace(
'
=
$elscope
.find( '.astra-sites-library-template:last' )
.offset().top
) {
AstraElementorSitesAdmin.page =
AstraElementorSitesAdmin.page + 1;
// Set listing HTML.
AstraElementorSitesAdmin._appendPaginationBlocks(
astraElementorSites.astra_blocks
);
}
}
}
},
_changeType: function () {
AstraElementorSitesAdmin.siteType = $( this ).val();
$elscope.find( '#wp-filter-search-input' ).trigger( 'keyup' );
},
_categoryChange: function ( event ) {
AstraElementorSitesAdmin.blockCategory = $( this ).val();
$elscope.find( '#wp-filter-search-input' ).trigger( 'keyup' );
},
_blockColorChange: function ( event ) {
AstraElementorSitesAdmin.blockColor = $( this ).val();
$elscope.find( '#wp-filter-search-input' ).trigger( 'keyup' );
},
_dismiss: function () {
$( this )
.closest( '.ast-sites-floating-notice-wrap' )
.removeClass( 'slide-in' );
$( this )
.closest( '.ast-sites-floating-notice-wrap' )
.addClass( 'slide-out' );
setTimeout( function () {
$( this )
.closest( '.ast-sites-floating-notice-wrap' )
.removeClass( 'slide-out' );
}, 200 );
if (
$( this )
.closest( '.ast-sites-floating-notice-wrap' )
.hasClass( 'refreshed-notice' )
) {
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-update-library-complete',
_ajax_nonce: astraElementorSites._ajax_nonce,
},
} ).done( function ( response ) {
$( '#ast-sites-floating-notice-wrap-id' ).toggle();
} );
}
},
_done: function ( data ) {
console.groupEnd( 'Process Done.' );
var str =
AstraElementorSitesAdmin.type == 'pages'
? astraElementorSites.template
: astraElementorSites.block;
$elscope
.find( '.ast-import-elementor-template' )
.removeClass( 'installing' );
$elscope
.find( '.ast-import-elementor-template' )
.attr( 'data-demo-link', data.data.link );
setTimeout( function () {
$elscope
.find( '.ast-import-elementor-template' )
.text( 'View Saved ' + str );
$elscope
.find( '.ast-import-elementor-template' )
.addClass( 'action-done' );
}, 200 );
},
_beforeClose: function () {
if ( AstraElementorSitesAdmin.action == 'insert' ) {
$elscope
.find( '.ast-library-template-insert' )
.removeClass( 'installing' );
$elscope
.find( '.ast-library-template-insert' )
.text( 'Imported' );
$elscope
.find( '.ast-library-template-insert' )
.addClass( 'action-done' );
if (
$elscope
.find( '.ast-sites-floating-notice-wrap' )
.hasClass( 'slide-in' )
) {
$elscope
.find( '.ast-sites-floating-notice-wrap' )
.removeClass( 'slide-in' );
$elscope
.find( '.ast-sites-floating-notice-wrap' )
.addClass( 'slide-out' );
setTimeout( function () {
$elscope
.find( '.ast-sites-floating-notice-wrap' )
.removeClass( 'slide-out' );
}, 200 );
}
}
},
_closeTooltip: function ( event ) {
if (
event.target.className !== 'ast-tooltip-wrap' &&
event.target.className !== 'dashicons dashicons-editor-help'
) {
var wrap = $elscope.find( '.ast-tooltip-wrap' );
if ( wrap.hasClass( 'ast-show-tooltip' ) ) {
$elscope
.find( '.ast-tooltip-wrap' )
.removeClass( 'ast-show-tooltip' );
}
}
},
_sync: function ( event ) {
event.preventDefault();
var button = $( this ).find( '.astra-sites-sync-library-button' );
if ( button.hasClass( 'updating-message' ) ) {
return;
}
button.addClass( 'updating-message' );
$elscope
.find( '#ast-sites-floating-notice-wrap-id' )
.show()
.removeClass( 'error' );
$elscope
.find(
'#ast-sites-floating-notice-wrap-id .ast-sites-floating-notice'
)
.html(
'Syncing template library in the background. The process can take anywhere between 2 to 3 minutes. We will notify you once done.'
);
$elscope
.find( '#ast-sites-floating-notice-wrap-id' )
.addClass( 'slide-in' )
.removeClass( 'refreshed-notice' );
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-update-library',
_ajax_nonce: astraElementorSites._ajax_nonce,
},
} )
.fail( function ( jqXHR ) {
console.log( jqXHR );
} )
.done( function ( response ) {
if ( response.success ) {
if ( 'updated' === response.data ) {
$elscope
.find( '#ast-sites-floating-notice-wrap-id' )
.addClass( 'refreshed-notice' )
.find( '.ast-sites-floating-notice' )
.html(
'' +
astraElementorSites.syncCompleteMessage +
''
);
button.removeClass( 'updating-message' );
console.log( 'Already sync all the sites.' );
} else {
// Import categories.
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-import-all-categories-and-tags',
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
} ).fail( function ( jqXHR ) {
console.log( jqXHR );
} );
// Import categories.
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-import-all-categories',
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
} ).fail( function ( jqXHR ) {
console.log( jqXHR );
} );
// Import Blocks.
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-get-blocks-request-count',
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
beforeSend: function () {
console.groupCollapsed( 'Updating Blocks' );
console.log( 'Updating Blocks' );
},
} )
.fail( function ( jqXHR ) {
console.log( jqXHR, 'error' );
console.error(
jqXHR.status + jqXHR.statusText,
'Blocks Count Request Failed!',
jqXHR
);
console.groupEnd( 'Updating Blocks' );
} )
.done( function ( response ) {
console.log( response );
if ( response.success ) {
var total = response.data;
for ( let i = 1; i <= total; i++ ) {
AstraSitesAjaxQueue.add( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-import-blocks',
page_no: i,
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
beforeSend: function () {
console.groupCollapsed(
'Importing Blocks - Page ' +
i
);
console.log(
'Importing Blocks - Page ' +
i
);
},
success: function ( response ) {
console.log( response );
console.groupEnd(
'Importing Blocks - Page ' +
i
);
},
} );
}
// Run the AJAX queue.
AstraSitesAjaxQueue.run();
} else {
console.error(
response.data,
'Blocks Count Request Failed!'
);
}
} );
// Import Block Categories.
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-import-block-categories',
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
} ).fail( function ( jqXHR ) {
console.log( jqXHR );
} );
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-get-sites-request-count',
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
} )
.fail( function ( jqXHR ) {
console.log( jqXHR );
} )
.done( function ( response ) {
if ( response.success ) {
var total = response.data;
for ( let i = 1; i <= total; i++ ) {
AstraSitesAjaxQueue.add( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-import-sites',
page_no: i,
_ajax_nonce:
astraElementorSites._ajax_nonce,
},
success: function ( result ) {
if (
i === total &&
astraElementorSites.syncCompleteMessage
) {
button.removeClass(
'updating-message'
);
$elscope
.find(
'#ast-sites-floating-notice-wrap-id'
)
.addClass(
'refreshed-notice'
)
.find(
'.ast-sites-floating-notice'
)
.html(
'' +
astraElementorSites.syncCompleteMessage +
''
);
}
},
} );
}
// Run the AJAX queue.
AstraSitesAjaxQueue.run();
}
} );
}
}
} );
},
_toggleTooltip: function ( e ) {
var wrap = $elscope.find( '.ast-tooltip-wrap' );
if ( wrap.hasClass( 'ast-show-tooltip' ) ) {
$elscope
.find( '.ast-tooltip-wrap' )
.removeClass( 'ast-show-tooltip' );
} else {
$elscope
.find( '.ast-tooltip-wrap' )
.addClass( 'ast-show-tooltip' );
}
},
_toggle: function ( e ) {
$elscope
.find( '.elementor-template-library-menu-item' )
.removeClass( 'elementor-active' );
$elscope.find( '.dialog-lightbox-content' ).hide();
$elscope.find( '.theme-preview' ).hide();
$elscope.find( '.theme-preview' ).html( '' );
$elscope.find( '.theme-preview-block' ).hide();
$elscope.find( '.theme-preview-block' ).html( '' );
$elscope.find( '.ast-template-library-toolbar' ).show();
$elscope.find( '.dialog-lightbox-content' ).hide();
$elscope.find( '.dialog-lightbox-content-block' ).hide();
$( this ).addClass( 'elementor-active' );
let data_type = $( this ).data( 'template-type' );
AstraElementorSitesAdmin.type = data_type;
AstraElementorSitesAdmin._switchTo( data_type );
},
_home: function () {
if ( AstraElementorSitesAdmin.processing ) {
return;
}
$elscope.find( '#wp-filter-search-input' ).val( '' );
// Hide Back button.
$elscope.find( '.back-to-layout' ).css( 'visibility', 'hidden' );
$elscope.find( '.back-to-layout' ).css( 'opacity', '0' );
$elscope
.find( '.elementor-template-library-menu-item:first-child' )
.trigger( 'click' );
},
_switchTo: function ( type ) {
if ( 'pages' == type ) {
AstraElementorSitesAdmin._initSites();
$elscope.find( '.dialog-lightbox-content' ).show();
$elscope.find( '.astra-blocks-category-inner-wrap' ).hide();
$elscope.find( '.astra-blocks-filter-inner-wrap' ).hide();
$elscope.find( '.elementor-template-library-order' ).show();
} else {
AstraElementorSitesAdmin._initBlocks();
$elscope.find( '.dialog-lightbox-content-block' ).show();
$elscope.find( '.astra-blocks-category-inner-wrap' ).show();
$elscope.find( '.astra-blocks-filter-inner-wrap' ).show();
$elscope.find( '.elementor-template-library-order' ).hide();
}
$elscope.find( '.astra-sites-content-wrap' ).trigger( 'scroll' );
},
_importWPForm: function ( wpforms_url, callback ) {
if ( ! wpforms_url ) {
if ( callback && typeof callback == 'function' ) {
callback( '' );
}
return;
}
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
dataType: 'json',
data: {
action: 'astra-sites-import-wpforms',
screen: 'elementor',
id: AstraElementorSitesAdmin.templateData.id,
_ajax_nonce: astraElementorSites._ajax_nonce,
},
beforeSend: function () {
console.groupCollapsed( 'Importing WP Forms' );
},
} )
.fail( function ( jqXHR ) {
console.log(
jqXHR.status + ' ' + jqXHR.responseText,
true
);
console.groupEnd();
} )
.done( function ( data ) {
// 1. Fail - Import WPForms Options.
if ( false === data.success ) {
console.log( data.data );
console.groupEnd();
} else {
if ( callback && typeof callback == 'function' ) {
callback( data );
}
}
} );
},
_createTemplate: function () {
console.groupEnd();
// Work with JSON page here
$.ajax( {
url: astraElementorSites.ajaxurl,
type: 'POST',
dataType: 'json',
data: {
action: 'astra-sites-create-template',
id:
AstraElementorSitesAdmin.type == 'pages'
? AstraElementorSitesAdmin.page_id?.replace(
'id-',
''
)
: AstraElementorSitesAdmin.block_id?.replace(
'id-',
''
),
title:
AstraElementorSitesAdmin.templateData?.title
?.rendered || '',
type:
'blocks' == AstraElementorSitesAdmin.type
? 'astra-blocks'
: 'site-pages',
_ajax_nonce: astraElementorSites._ajax_nonce,
},
beforeSend: function () {
console.groupCollapsed( 'Creating Template' );
},
} )
.fail( function ( jqXHR ) {
console.log( jqXHR );
} )
.done( function ( data ) {
AstraElementorSitesAdmin._done( data );
} );
},
/**
* Install All Plugins.
*/
_installAllPlugins: function ( not_installed ) {
$.each( not_installed, function ( index, single_plugin ) {
console.log( 'Installing Plugin - ' + single_plugin.name );
// Add each plugin activate request in Ajax queue.
// @see wp-admin/js/updates.js
wp.updates.queue.push( {
action: 'install-plugin', // Required action.
data: {
slug: single_plugin.slug,
},
} );
} );
// Required to set queue.
wp.updates.queueChecker();
},
/**
* Activate All Plugins.
*/
_activateAllPlugins: function ( activate_plugins ) {
$.each( activate_plugins, function ( index, single_plugin ) {
console.log( 'Activating Plugin - ' + single_plugin.name );
AstraSitesAjaxQueue.add( {
url: astraElementorSites.ajaxurl,
type: 'POST',
data: {
action: 'astra-sites-required_plugin_activate',
init: single_plugin.init,
_ajax_nonce: astraElementorSites._ajax_nonce,
},
success: function ( result ) {
if ( result.success ) {
var pluginsList =
AstraElementorSitesAdmin.requiredPlugins
.inactive;
// Reset not installed plugins list.
AstraElementorSitesAdmin.requiredPlugins.inactive =
AstraElementorSitesAdmin._removePluginFromQueue(
single_plugin.slug,
pluginsList
);
// Enable Demo Import Button
AstraElementorSitesAdmin._enableImport();
}
},
} );
} );
AstraSitesAjaxQueue.run();
},
/**
* Remove plugin from the queue.
*/
_removePluginFromQueue: function ( removeItem, pluginsList ) {
return jQuery.grep( pluginsList, function ( value ) {
return value.slug != removeItem;
} );
},
/**
* Get plugin from the queue.
*/
_getPluginFromQueue: function ( item, pluginsList ) {
var match = '';
for ( ind in pluginsList ) {
if ( item == pluginsList[ ind ].slug ) {
match = pluginsList[ ind ];
}
}
return match;
},
_bulkPluginInstallActivate: function () {
console.groupCollapsed( 'Bulk Plugin Install Process Started' );
// If has class the skip-plugins then,
// Avoid installing 3rd party plugins.
var not_installed =
AstraElementorSitesAdmin.requiredPlugins.notinstalled || '';
var activate_plugins =
AstraElementorSitesAdmin.requiredPlugins.inactive || '';
console.log( AstraElementorSitesAdmin.requiredPlugins );
// First Install Bulk.
if ( not_installed.length > 0 ) {
AstraElementorSitesAdmin._installAllPlugins( not_installed );
}
// Second Activate Bulk.
if ( activate_plugins.length > 0 ) {
AstraElementorSitesAdmin._activateAllPlugins(
activate_plugins
);
}
if ( activate_plugins.length <= 0 && not_installed.length <= 0 ) {
AstraElementorSitesAdmin._enableImport();
}
},
_importTemplate: function ( e ) {
if ( ! AstraElementorSitesAdmin.canImport ) {
if ( $( this ).attr( 'data-demo-link' ) != undefined ) {
window.open( $( this ).attr( 'data-demo-link' ), '_blank' );
}
return;
}
AstraElementorSitesAdmin.canImport = false;
var str =
AstraElementorSitesAdmin.type == 'pages'
? astraElementorSites.template
: astraElementorSites.block;
$( this ).addClass( 'installing' );
$( this ).text( 'Saving ' + str + '...' );
AstraElementorSitesAdmin.action = 'import';
AstraElementorSitesAdmin._bulkPluginInstallActivate();
},
_unescape: function ( input_string ) {
var title = _.unescape( input_string );
// @todo check why below character not escape with function _.unescape();
title = title.replace( '–', '-' );
return title;
},
_unescape_lower: function ( input_string ) {
input_string = $( '