@foxy.io/elements 1.31.1-beta.1 → 1.32.0-beta.1
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.
- package/dist/cdn/foxy-access-recovery-form.js +1 -1
- package/dist/cdn/foxy-address-card.js +1 -1
- package/dist/cdn/foxy-address-form.js +1 -1
- package/dist/cdn/foxy-admin-subscription-card.js +1 -1
- package/dist/cdn/foxy-admin-subscription-form.js +1 -1
- package/dist/cdn/foxy-api-browser.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-applied-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-applied-tax-card.js +1 -1
- package/dist/cdn/foxy-attribute-card.js +1 -1
- package/dist/cdn/foxy-attribute-form.js +1 -1
- package/dist/cdn/foxy-billing-address-card.js +1 -1
- package/dist/cdn/foxy-cancellation-form.js +1 -1
- package/dist/cdn/foxy-cart-card.js +1 -1
- package/dist/cdn/foxy-cart-form.js +1 -1
- package/dist/cdn/foxy-client-card.js +1 -1
- package/dist/cdn/foxy-client-form.js +1 -1
- package/dist/cdn/foxy-collection-page.js +1 -1
- package/dist/cdn/foxy-collection-pages.js +1 -1
- package/dist/cdn/foxy-copy-to-clipboard.js +1 -1
- package/dist/cdn/foxy-coupon-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-card.js +1 -1
- package/dist/cdn/foxy-coupon-code-form.js +1 -1
- package/dist/cdn/foxy-coupon-codes-form.js +1 -1
- package/dist/cdn/foxy-coupon-detail-card.js +1 -1
- package/dist/cdn/foxy-coupon-form.js +1 -1
- package/dist/cdn/foxy-custom-field-card.js +1 -1
- package/dist/cdn/foxy-custom-field-form.js +1 -1
- package/dist/cdn/foxy-customer-api.js +1 -1
- package/dist/cdn/foxy-customer-card.js +1 -1
- package/dist/cdn/foxy-customer-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
- package/dist/cdn/foxy-customer-portal-settings.js +1 -1
- package/dist/cdn/foxy-customer-portal.js +1 -1
- package/dist/cdn/foxy-customer.js +1 -1
- package/dist/cdn/foxy-customers-table.js +1 -1
- package/dist/cdn/foxy-discount-builder.js +1 -1
- package/dist/cdn/foxy-discount-card.js +1 -1
- package/dist/cdn/foxy-discount-detail-card.js +1 -1
- package/dist/cdn/foxy-donation.js +1 -1
- package/dist/cdn/foxy-downloadable-card.js +1 -1
- package/dist/cdn/foxy-downloadable-form.js +1 -1
- package/dist/cdn/foxy-email-template-card.js +1 -1
- package/dist/cdn/foxy-email-template-form.js +1 -1
- package/dist/cdn/foxy-error-entry-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-card.js +1 -1
- package/dist/cdn/foxy-filter-attribute-form.js +1 -1
- package/dist/cdn/foxy-form-dialog.js +1 -1
- package/dist/cdn/foxy-generate-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-card.js +1 -1
- package/dist/cdn/foxy-gift-card-code-form.js +1 -1
- package/dist/cdn/foxy-gift-card-code-log-card.js +1 -1
- package/dist/cdn/foxy-gift-card-codes-form.js +1 -1
- package/dist/cdn/foxy-gift-card-form.js +1 -1
- package/dist/cdn/foxy-i18n-editor.js +1 -1
- package/dist/cdn/foxy-i18n.js +1 -1
- package/dist/cdn/foxy-integration-card.js +1 -1
- package/dist/cdn/foxy-integration-form.js +1 -1
- package/dist/cdn/foxy-item-card.js +1 -1
- package/dist/cdn/foxy-item-category-card.js +1 -1
- package/dist/cdn/foxy-item-category-form.js +1 -1
- package/dist/cdn/foxy-item-form.js +1 -1
- package/dist/cdn/foxy-item-option-card.js +1 -1
- package/dist/cdn/foxy-item-option-form.js +1 -1
- package/dist/cdn/foxy-items-form.js +1 -1
- package/dist/cdn/foxy-native-integration-card.js +1 -1
- package/dist/cdn/foxy-native-integration-form.js +1 -1
- package/dist/cdn/foxy-nucleon-element.js +1 -1
- package/dist/cdn/foxy-pagination.js +1 -1
- package/dist/cdn/foxy-passkey-card.js +1 -1
- package/dist/cdn/foxy-passkey-form.js +1 -1
- package/dist/cdn/foxy-payment-card-embed.js +1 -1
- package/dist/cdn/foxy-payment-card.js +1 -1
- package/dist/cdn/foxy-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-card.js +1 -1
- package/dist/cdn/foxy-payments-api-fraud-protection-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-card.js +1 -1
- package/dist/cdn/foxy-payments-api-payment-preset-form.js +1 -1
- package/dist/cdn/foxy-payments-api.js +1 -1
- package/dist/cdn/foxy-query-builder.js +2 -2
- package/dist/cdn/foxy-report-form.js +2 -2
- package/dist/cdn/foxy-reports-table.js +1 -1
- package/dist/cdn/foxy-shipment-card.js +1 -1
- package/dist/cdn/foxy-shipping-container-card.js +1 -1
- package/dist/cdn/foxy-shipping-drop-type-card.js +1 -1
- package/dist/cdn/foxy-shipping-method-card.js +1 -1
- package/dist/cdn/foxy-shipping-service-card.js +1 -1
- package/dist/cdn/foxy-sign-in-form.js +1 -1
- package/dist/cdn/foxy-spinner.js +2 -2
- package/dist/cdn/foxy-store-card.js +1 -1
- package/dist/cdn/foxy-store-form.js +1 -1
- package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
- package/dist/cdn/foxy-subscription-card.js +1 -1
- package/dist/cdn/foxy-subscription-form.js +1 -1
- package/dist/cdn/foxy-subscription-settings-form.js +1 -1
- package/dist/cdn/foxy-subscriptions-table.js +1 -1
- package/dist/cdn/foxy-table.js +1 -1
- package/dist/cdn/foxy-tax-card.js +1 -1
- package/dist/cdn/foxy-tax-form.js +1 -1
- package/dist/cdn/foxy-template-config-form.js +1 -1
- package/dist/cdn/foxy-template-form.js +1 -1
- package/dist/cdn/foxy-template-set-card.js +1 -1
- package/dist/cdn/foxy-template-set-form.js +1 -1
- package/dist/cdn/foxy-transaction-card.js +1 -1
- package/dist/cdn/foxy-transaction.js +1 -1
- package/dist/cdn/foxy-transactions-table.js +7 -7
- package/dist/cdn/foxy-update-payment-method-form.js +1 -1
- package/dist/cdn/foxy-user-card.js +1 -1
- package/dist/cdn/foxy-user-form.js +1 -1
- package/dist/cdn/foxy-user-invitation-card.js +1 -0
- package/dist/cdn/foxy-user-invitation-form.js +1 -0
- package/dist/cdn/foxy-users-table.js +1 -1
- package/dist/cdn/foxy-webhook-card.js +1 -1
- package/dist/cdn/foxy-webhook-form.js +1 -1
- package/dist/cdn/foxy-webhook-log-card.js +1 -1
- package/dist/cdn/foxy-webhook-status-card.js +1 -1
- package/dist/cdn/{shared-12a7a15d.js → shared-019348d7.js} +1 -1
- package/dist/cdn/{shared-01b2cad8.js → shared-0e156ee7.js} +1 -1
- package/dist/cdn/{shared-9b2d6d62.js → shared-11694c05.js} +1 -1
- package/dist/cdn/{shared-21bc5d5e.js → shared-15100be0.js} +1 -1
- package/dist/cdn/{shared-f7a1193f.js → shared-17a61265.js} +1 -1
- package/dist/cdn/{shared-55e95bd2.js → shared-185dffc3.js} +1 -1
- package/dist/cdn/{shared-7c411b0a.js → shared-193bb806.js} +1 -1
- package/dist/cdn/{shared-f3773d62.js → shared-19df2a73.js} +1 -1
- package/dist/cdn/{shared-0700fd80.js → shared-1a30f25e.js} +1 -1
- package/dist/cdn/shared-1aff7995.js +1 -0
- package/dist/cdn/{shared-6e859df6.js → shared-239062b0.js} +1 -1
- package/dist/cdn/{shared-6918312e.js → shared-28ebee50.js} +1 -1
- package/dist/cdn/{shared-24d71d01.js → shared-2ad18636.js} +1 -1
- package/dist/cdn/{shared-3c3497d6.js → shared-2bc0d0cd.js} +1 -1
- package/dist/cdn/{shared-ac0368ec.js → shared-2e090291.js} +1 -1
- package/dist/cdn/{shared-8cd578ee.js → shared-374e6faa.js} +1 -1
- package/dist/cdn/{shared-280f868d.js → shared-40af05b3.js} +1 -1
- package/dist/cdn/{shared-c8a6496c.js → shared-482ba043.js} +5 -5
- package/dist/cdn/{shared-56bf05ef.js → shared-4903b2e3.js} +1 -1
- package/dist/cdn/shared-492da078.js +1 -0
- package/dist/cdn/{shared-90a47948.js → shared-5513e830.js} +1 -1
- package/dist/cdn/{shared-8f3398dc.js → shared-562d466d.js} +1 -1
- package/dist/cdn/shared-56ba2d28.js +1 -0
- package/dist/cdn/{shared-08e0a194.js → shared-5c35d93a.js} +1 -1
- package/dist/cdn/{shared-56a559fd.js → shared-5c846a3b.js} +1 -1
- package/dist/cdn/shared-5e09e162.js +1 -0
- package/dist/cdn/{shared-453d8f75.js → shared-60209b2d.js} +1 -1
- package/dist/cdn/{shared-6ac0d05e.js → shared-641786b2.js} +1 -1
- package/dist/cdn/{shared-09b4185a.js → shared-65479601.js} +1 -1
- package/dist/cdn/{shared-0f67d020.js → shared-6b8c2a83.js} +1 -1
- package/dist/cdn/{shared-a49a2300.js → shared-6e1b5baf.js} +1 -1
- package/dist/cdn/{shared-61b6ef6e.js → shared-6f0504e2.js} +1 -1
- package/dist/cdn/{shared-e778071b.js → shared-7275324b.js} +1 -1
- package/dist/cdn/{shared-937b497c.js → shared-745f340a.js} +1 -1
- package/dist/cdn/{shared-1f0b8b7e.js → shared-74eedbe6.js} +1 -1
- package/dist/cdn/{shared-d1c10d58.js → shared-7c15c149.js} +1 -1
- package/dist/cdn/{shared-a207423c.js → shared-7ceceb4c.js} +1 -1
- package/dist/cdn/{shared-ce75e928.js → shared-86a9b27a.js} +1 -1
- package/dist/cdn/{shared-91f5e0b3.js → shared-87b5a6aa.js} +1 -1
- package/dist/cdn/{shared-5be5874d.js → shared-8a3fd383.js} +1 -1
- package/dist/cdn/{shared-c388e926.js → shared-8a73d1aa.js} +1 -1
- package/dist/cdn/{shared-b8198665.js → shared-8b5e05df.js} +1 -1
- package/dist/cdn/{shared-e24da82e.js → shared-8da3186f.js} +2 -2
- package/dist/cdn/{shared-4b346553.js → shared-8fc527b7.js} +1 -1
- package/dist/cdn/{shared-ef78d7d9.js → shared-9092b5db.js} +1 -1
- package/dist/cdn/{shared-0a6a28ce.js → shared-913e1955.js} +1 -1
- package/dist/cdn/{shared-c2776a33.js → shared-91d8985f.js} +1 -1
- package/dist/cdn/{shared-5a2f398c.js → shared-92192fe1.js} +1 -1
- package/dist/cdn/{shared-d8c3067b.js → shared-97cfdcdb.js} +1 -1
- package/dist/cdn/{shared-19884cf4.js → shared-9a59aab2.js} +1 -1
- package/dist/cdn/{shared-522a172d.js → shared-9cf15285.js} +1 -1
- package/dist/cdn/{shared-28f74114.js → shared-9d309e97.js} +1 -1
- package/dist/cdn/{shared-2a5c89a4.js → shared-9e360643.js} +1 -1
- package/dist/cdn/{shared-388e9240.js → shared-aaf72aad.js} +1 -1
- package/dist/cdn/{shared-37efab30.js → shared-acd33590.js} +1 -1
- package/dist/cdn/{shared-44ce656d.js → shared-adcfd50a.js} +1 -1
- package/dist/cdn/{shared-f11b2116.js → shared-addddf0e.js} +1 -1
- package/dist/cdn/{shared-fb34e84c.js → shared-b726120d.js} +2 -2
- package/dist/cdn/{shared-0e055562.js → shared-bc023a29.js} +1 -1
- package/dist/cdn/{shared-6d645dc5.js → shared-c2efc54e.js} +1 -1
- package/dist/cdn/{shared-029d623b.js → shared-c4f15ea3.js} +1 -1
- package/dist/cdn/{shared-ce172224.js → shared-c508d5dc.js} +1 -1
- package/dist/cdn/{shared-c286c5ad.js → shared-c518ece2.js} +1 -1
- package/dist/cdn/{shared-16c17e32.js → shared-c538157f.js} +1 -1
- package/dist/cdn/{shared-f407c2cb.js → shared-c5647b62.js} +1 -1
- package/dist/cdn/{shared-60d586ba.js → shared-c9346893.js} +1 -1
- package/dist/cdn/{shared-d132bd37.js → shared-c98881c7.js} +1 -1
- package/dist/cdn/{shared-da9e048f.js → shared-ca0847b0.js} +1 -1
- package/dist/cdn/shared-d1195c27.js +15 -0
- package/dist/cdn/{shared-0b01f721.js → shared-d1cb97c6.js} +1 -1
- package/dist/cdn/{shared-fb0ca5e2.js → shared-d3044c4c.js} +1 -1
- package/dist/cdn/{shared-245f8836.js → shared-d4a1658e.js} +1 -1
- package/dist/cdn/shared-d8bffb38.js +14 -0
- package/dist/cdn/{shared-fc1dfa64.js → shared-df51ee50.js} +1 -1
- package/dist/cdn/{shared-edbf7378.js → shared-dfe41029.js} +1 -1
- package/dist/cdn/{shared-536a2d53.js → shared-e709057b.js} +1 -1
- package/dist/cdn/{shared-199e3870.js → shared-f5547471.js} +1 -1
- package/dist/cdn/{shared-0cc5420d.js → shared-f67f6fc5.js} +1 -1
- package/dist/cdn/{shared-7d38cb8a.js → shared-f8368b97.js} +1 -1
- package/dist/cdn/{shared-f2968508.js → shared-f893763a.js} +2 -2
- package/dist/cdn/{shared-b08ca8d0.js → shared-f998f9c8.js} +1 -1
- package/dist/cdn/{shared-ee36b83f.js → shared-fcdb896f.js} +1 -1
- package/dist/cdn/translations/user-invitation-card/en.json +17 -0
- package/dist/cdn/translations/user-invitation-form/en.json +94 -0
- package/dist/elements/public/UserCard/UserCard.d.ts +7 -0
- package/dist/elements/public/UserCard/UserCard.js +81 -2
- package/dist/elements/public/UserCard/UserCard.js.map +1 -1
- package/dist/elements/public/UserCard/index.d.ts +1 -0
- package/dist/elements/public/UserCard/index.js +1 -0
- package/dist/elements/public/UserCard/index.js.map +1 -1
- package/dist/elements/public/UserInvitationCard/UserInvitationCard.d.ts +16 -0
- package/dist/elements/public/UserInvitationCard/UserInvitationCard.js +110 -0
- package/dist/elements/public/UserInvitationCard/UserInvitationCard.js.map +1 -0
- package/dist/elements/public/UserInvitationCard/index.d.ts +4 -0
- package/dist/elements/public/UserInvitationCard/index.js +6 -0
- package/dist/elements/public/UserInvitationCard/index.js.map +1 -0
- package/dist/elements/public/UserInvitationCard/types.d.ts +1 -0
- package/dist/elements/public/UserInvitationCard/types.js +2 -0
- package/dist/elements/public/UserInvitationCard/types.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/UserInvitationForm.d.ts +29 -0
- package/dist/elements/public/UserInvitationForm/UserInvitationForm.js +313 -0
- package/dist/elements/public/UserInvitationForm/UserInvitationForm.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/index.d.ts +7 -0
- package/dist/elements/public/UserInvitationForm/index.js +9 -0
- package/dist/elements/public/UserInvitationForm/index.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/InternalUserInvitationFormAsyncAction.d.ts +10 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/InternalUserInvitationFormAsyncAction.js +51 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/InternalUserInvitationFormAsyncAction.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/index.d.ts +5 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/index.js +7 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormAsyncAction/index.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormSyncAction/InternalUserInvitationFormSyncAction.d.ts +9 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormSyncAction/InternalUserInvitationFormSyncAction.js +32 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormSyncAction/InternalUserInvitationFormSyncAction.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormSyncAction/index.d.ts +5 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormSyncAction/index.js +7 -0
- package/dist/elements/public/UserInvitationForm/internal/InternalUserInvitationFormSyncAction/index.js.map +1 -0
- package/dist/elements/public/UserInvitationForm/types.d.ts +33 -0
- package/dist/elements/public/UserInvitationForm/types.js +2 -0
- package/dist/elements/public/UserInvitationForm/types.js.map +1 -0
- package/dist/elements/public/index.d.ts +2 -0
- package/dist/elements/public/index.defined.d.ts +2 -0
- package/dist/elements/public/index.defined.js +2 -0
- package/dist/elements/public/index.defined.js.map +1 -1
- package/dist/elements/public/index.js +2 -0
- package/dist/elements/public/index.js.map +1 -1
- package/dist/mixins/themeable.js +4 -0
- package/dist/mixins/themeable.js.map +1 -1
- package/dist/utils/get-gravatar-url.d.ts +1 -0
- package/dist/utils/get-gravatar-url.js +8 -0
- package/dist/utils/get-gravatar-url.js.map +1 -0
- package/package.json +1 -1
- package/dist/cdn/shared-0f6e4584.js +0 -15
- package/dist/cdn/shared-3ee151ce.js +0 -1
- package/dist/cdn/shared-6474675f.js +0 -1
- package/dist/cdn/shared-9db46672.js +0 -1
- package/dist/cdn/shared-f34aeb6c.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-51c4a6dd.js";import"./foxy-spinner.js";import"./shared-
|
|
1
|
+
import"./shared-51c4a6dd.js";import"./foxy-spinner.js";import"./shared-acd33590.js";import{_ as r}from"./shared-d1195c27.js";import{a as s}from"./shared-b726120d.js";import{T as e}from"./shared-d3044c4c.js";import{h as t}from"./shared-dc73b9a5.js";import"./shared-5513e830.js";import"./shared-adcfd50a.js";import"./shared-4903b2e3.js";import"./shared-17a61265.js";import"./shared-343d1fd7.js";import"./shared-d1cb97c6.js";import"./shared-9803aa7c.js";import"./shared-19df2a73.js";import"./shared-2ad18636.js";import"./shared-c518ece2.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-1aff7995.js";import"./shared-fcdb896f.js";import"./shared-4e709717.js";let a,i,d,o=r=>r;const m=s(e,"payments-api-fraud-protection-card");class c extends m{constructor(){super(...arguments),this.getImageSrc=null}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='M0 20.73v-9.9L10.83 0h9.9L0 20.73ZM0 0h9.41L0 9.41V0Zm0 22.14L22.14 0h9.9l-9.43 9.44-.61-.27-10.5 4.66v7-.29L0 32.04v-9.9Zm11.54-.23L0 33.46v9.9l14.14-14.14a15 15 0 0 1-2.6-7.3Zm3.2 8.12L.77 44h9.9l9.7-9.7a13.75 13.75 0 0 1-5.63-4.27Zm6.67 4.64L12.08 44h9.9L44 21.98v-9.9L32.16 23.92C31.01 29.15 27.05 33.6 22 34.83l-.59-.16Zm11.02-12.43L44 10.67V.77L31.42 13.35l1.08.48v7a13 13 0 0 1-.07 1.4Zm-1.99-9.32L43.35 0h-9.9l-9.87 9.87 6.86 3.05ZM23.4 44 44 23.4v9.9L33.3 44h-9.9Zm11.31 0L44 34.71V44h-9.29Z'/%3E%3Cpath fill='%23fff' d='M30.17 21.99H22V11.72l-8.17 3.63V22H22v10.42c4.34-1.34 7.55-5.63 8.17-10.43Z'/%3E%3C/svg%3E"}static get properties(){return r(r({},super.properties),{},{getImageSrc:{attribute:!1}})}renderBody(){var r,s;const e=super.renderBody({title:r=>t(a||(a=o`${0}`),r.helper.name),subtitle:r=>t(i||(i=o`${0}`),r.description)});if(!this.in({idle:"snapshot"}))return e;const m=c.defaultImageSrc,p=this.data;return t(d||(d=o` <figure class="flex items-center" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> <img class="relative h-s w-s object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs" src="${0}" alt="${0}" @error="${0}"> <figcaption class="min-w-0 flex-1">${0}</figcaption> </figure> `),null!==(s=p?null===(r=this.getImageSrc)||void 0===r?void 0:r.call(this,p.type):null)&&void 0!==s?s:m,this.t("image_alt"),(r=>r.currentTarget.src=m),e)}}customElements.define("foxy-payments-api-fraud-protection-card",c);export{c as PaymentsApiFraudProtectionCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-239062b0.js";import"./shared-374e6faa.js";import"./shared-745f340a.js";import"./shared-8a73d1aa.js";import"./shared-9092b5db.js";import"./shared-5c35d93a.js";import{I as e}from"./shared-bc023a29.js";import"./foxy-nucleon-element.js";import"./shared-acd33590.js";import{_ as t,B as r,aM as o,l as a}from"./shared-d1195c27.js";import{a as i}from"./shared-b726120d.js";import{i as s}from"./shared-9803aa7c.js";import{c as n}from"./shared-4e709717.js";import{h as l}from"./shared-dc73b9a5.js";import{s as d}from"./shared-1aff7995.js";import{h as c}from"./shared-56ba2d28.js";import"./shared-f998f9c8.js";import"./shared-adcfd50a.js";import"./shared-65479601.js";import"./shared-61ade33e.js";import"./shared-f8368b97.js";import"./shared-51c4a6dd.js";import"./shared-d1cb97c6.js";import"./shared-17a61265.js";import"./shared-2ad18636.js";import"./shared-c518ece2.js";import"./shared-343d1fd7.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-fcdb896f.js";import"./shared-11694c05.js";import"./shared-5513e830.js";import"./shared-c4f15ea3.js";import"./shared-c98881c7.js";import"./shared-8fc527b7.js";import"./shared-562d466d.js";import"./shared-8b5e05df.js";import"./shared-7ceceb4c.js";import"./shared-913e1955.js";import"./shared-40af05b3.js";import"./shared-91d8985f.js";import"./shared-8da3186f.js";import"./shared-9a59aab2.js";import"./shared-651c44fa.js";import"./shared-f893763a.js";import"./shared-97cfdcdb.js";import"./shared-22ba9566.js";import"./shared-28ebee50.js";import"./shared-df51ee50.js";import"./foxy-copy-to-clipboard.js";import"./shared-4903b2e3.js";import"./foxy-spinner.js";import"./shared-bab2ea2c.js";let p,h,f,u,m,v,j,y,_,b,g,$,x,L,w,F,P=e=>e;const S=i(e,"payments-api-fraud-protection-form");class I extends S{constructor(){super(...arguments),this.getImageSrc=null,this.__availableFraudProtectionsLoaderId="availableFraudProtections"}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='M0 20.73v-9.9L10.83 0h9.9L0 20.73ZM0 0h9.41L0 9.41V0Zm0 22.14L22.14 0h9.9l-9.43 9.44-.61-.27-10.5 4.66v7-.29L0 32.04v-9.9Zm11.54-.23L0 33.46v9.9l14.14-14.14a15 15 0 0 1-2.6-7.3Zm3.2 8.12L.77 44h9.9l9.7-9.7a13.75 13.75 0 0 1-5.63-4.27Zm6.67 4.64L12.08 44h9.9L44 21.98v-9.9L32.16 23.92C31.01 29.15 27.05 33.6 22 34.83l-.59-.16Zm11.02-12.43L44 10.67V.77L31.42 13.35l1.08.48v7a13 13 0 0 1-.07 1.4Zm-1.99-9.32L43.35 0h-9.9l-9.87 9.87 6.86 3.05ZM23.4 44 44 23.4v9.9L33.3 44h-9.9Zm11.31 0L44 34.71V44h-9.29Z'/%3E%3Cpath fill='%23fff' d='M30.17 21.99H22V11.72l-8.17 3.63V22H22v10.42c4.34-1.34 7.55-5.63 8.17-10.43Z'/%3E%3C/svg%3E"}static get properties(){return t(t({},super.properties),{},{getImageSrc:{attribute:!1}})}static get v8n(){return[({description:e})=>!e||e.length<=100||"description:v8n_too_long",({type:e})=>!!e||"type:v8n_required",({score_threshold_reject:e})=>"number"!=typeof e||(e<=100&&e>=0||"score-threshold-reject:v8n_out_of_range"),e=>{var t,r,o,a;const i=null!==(o=null===(r=null===(t=e.helper)||void 0===t?void 0:t.json)||void 0===r?void 0:r.blocks)&&void 0!==o?o:[];let s;try{s=JSON.parse(null!==(a=e.json)&&void 0!==a?a:"{}")}catch(e){s={}}for(const e of i)for(const t of e.fields)if("optional"in t&&!t.optional){const r=[e.parent_id,e.id,t.id].filter((e=>!!e));if(!c(s,r)&&"checkbox"!==t.type)return"json:v8n_invalid"}return!0}]}get hiddenSelector(){return new r(`header:copy-json ${super.hiddenSelector}`.trimEnd())}get headerTitleOptions(){var e;return t(t({},this.data),{},{context:null!==(e=this.form.type)&&void 0!==e?e:"new"})}get headerSubtitleOptions(){return{id:this.headerCopyIdValue}}renderHeader(...e){var t;return l(p||(p=P` <div> ${0} ${0} </div> `),super.renderHeader(...e),(null===(t=this.data)||void 0===t?void 0:t.type)||!this.form.type?l(h||(h=P``)):l(f||(f=P` <vaadin-button data-testid="select-another-button" theme="tertiary-inline" @click="${0}"> <foxy-i18n infer="" key="select_another_button_label"></foxy-i18n> </vaadin-button> `),(()=>this.undo())))}renderBody(){const e=l(u||(u=P` <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),s(this.__availableFraudProtectionsHref),this.__availableFraudProtectionsLoaderId,(()=>this.requestUpdate()));return l(m||(m=P`${0}${0}${0}`),this.renderHeader(),this.form.type?this.__renderFraudProtectionConfig():this.__renderFraudProtectionSelector(),e)}get __availableFraudProtectionsLoader(){return this.renderRoot.querySelector(`#${this.__availableFraudProtectionsLoaderId}`)}get __availableFraudProtectionsHref(){try{const e=o(/\/payment_presets\/(.+)\//,{presetId:1}),t=new URL(this.href||this.parent).pathname,r=e.exec(t).groups.presetId;return new URL(`/payment_presets/${r}/available_fraud_protections`,this.href||this.parent).toString()}catch(e){}}get __availableFraudProtections(){var e,t;return null===(t=null===(e=this.__availableFraudProtectionsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values}__renderFraudProtectionSelector(){var e;const t=this.__availableFraudProtectionsLoader;return l(v||(v=P` ${0} `),(null==t?void 0:t.data)?l(j||(j=P` <div class="grid grid-cols-2 gap-m" data-testid="select-protection-list"> ${0} </div> `),Object.entries(null!==(e=this.__availableFraudProtections)&&void 0!==e?e:{}).map((([e,t])=>this.__renderFraudProtectionButton({type:e,helper:t})))):l(y||(y=P` <foxy-spinner infer="list-spinner" state="${0}"> </foxy-spinner> `),(null==t?void 0:t.in("fail"))?"error":"busy"))}__renderFraudProtectionButton({type:e,helper:t}){var r,o;const a=I.defaultImageSrc,i=null!==(o=null===(r=this.getImageSrc)||void 0===r?void 0:r.call(this,e))&&void 0!==o?o:a,d=e=>e.currentTarget.src=a;return l(_||(_=P` <button class="${0}" ?disabled="${0}" title="${0}" @click="${0}"> <img class="absolute top-0 left-0 w-1-2 h-full object-cover bg-center filter saturate-200 blur-3xl" style="transform:translate3d(0,0,0)" src="${0}" alt="" ?hidden="${0}" @error="${0}"> <figure class="relative flex flex-col gap-m"> <img class="${0}" src="${0}" alt="" @error="${0}"> <figcaption class="${0}"> <div class="font-medium">${0}​</div> <div class="text-xs ${0}">${0}</div> </figcaption> </figure> </button> `),n({"relative w-full block text-left p-s rounded bg-contrast-5 overflow-hidden":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"transition-colors hover-bg-contrast-10":!t.conflict,"cursor-default":!!t.conflict}),!!t.conflict,s(t.conflict?this.t("conflict_message"):void 0),(()=>this.edit({type:e,helper:t})),i,!!t.conflict,d,n({"h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs":!0,"filter grayscale":!!t.conflict}),i,d,n({"min-w-0 flex-1 truncate leading-s":!0,"text-disabled":!!t.conflict}),t.name,t.conflict?"":"text-secondary",e)}__renderFraudProtectionConfig(){var e,t,r;return l(b||(b=P` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> </foxy-internal-summary-control> <foxy-internal-summary-control infer="setup"> ${0} ${0} </foxy-internal-summary-control> ${0} `),(null===(e=this.form.helper)||void 0===e?void 0:e.uses_rejection_threshold)?l(g||(g=P` <foxy-internal-number-control layout="summary-item" infer="score-threshold-reject"> </foxy-internal-number-control> `)):"",null===(r=null===(t=this.form.helper)||void 0===t?void 0:t.json)||void 0===r?void 0:r.blocks.map((e=>this.__renderBlock(e))),super.renderBody())}__renderBlock(e){return l($||($=P`${0}`),e.fields.map((t=>{var r,o,i;const s=()=>{var r,o;let i;try{i=JSON.parse(null!==(r=this.form.json)&&void 0!==r?r:"")}catch(e){i={}}const s=[e.parent_id,e.id,t.id].filter((e=>!!e));return null!==(o=a(i,s))&&void 0!==o?o:i.default_value},n=r=>{var o;let a;try{a=JSON.parse(null!==(o=this.form.json)&&void 0!==o?o:"")}catch(e){a={}}const i=[e.parent_id,e.id,t.id].filter((e=>!!e));this.edit({json:JSON.stringify(d(a,i,r))})},c=t.options,p=["json",...[e.parent_id,e.id,t.id].filter((e=>!!e))].join("-").replace(/_/g,"-");return l(x||(x=P` ${0} `),"checkbox"===t.type?l(L||(L=P` <foxy-internal-switch-control helper-text="${0}" label="${0}" infer="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),null!==(r=t.description)&&void 0!==r?r:"",t.name,p,s,n):"select"===t.type?l(w||(w=P` <foxy-internal-select-control helper-text="${0}" placeholder="${0}" layout="summary-item" label="${0}" infer="${0}" .options="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-select-control> `),null!==(o=t.description)&&void 0!==o?o:"",this.t("default_additional_field_placeholder"),t.name,p,c.map((({name:e,value:t})=>({label:e,value:t}))),s,n):l(F||(F=P` <foxy-internal-text-control helper-text="${0}" placeholder="${0}" layout="summary-item" label="${0}" infer="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-text-control> `),null!==(i=t.description)&&void 0!==i?i:"",t.default_value||this.t("default_additional_field_placeholder"),t.name,p,s,n))})))}}customElements.define("foxy-payments-api-fraud-protection-form",I);export{I as PaymentsApiFraudProtectionForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-51c4a6dd.js";import"./foxy-spinner.js";import"./shared-
|
|
1
|
+
import"./shared-51c4a6dd.js";import"./foxy-spinner.js";import"./shared-acd33590.js";import{_ as r}from"./shared-d1195c27.js";import{a as e}from"./shared-b726120d.js";import{T as s}from"./shared-d3044c4c.js";import{h as t}from"./shared-dc73b9a5.js";import"./shared-5513e830.js";import"./shared-adcfd50a.js";import"./shared-4903b2e3.js";import"./shared-17a61265.js";import"./shared-343d1fd7.js";import"./shared-d1cb97c6.js";import"./shared-9803aa7c.js";import"./shared-19df2a73.js";import"./shared-2ad18636.js";import"./shared-c518ece2.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-1aff7995.js";import"./shared-fcdb896f.js";import"./shared-4e709717.js";let a,i,d,o=r=>r;const m=e(s,"payments-api-payment-method-card");class l extends m{constructor(){super(...arguments),this.getImageSrc=null}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E"}static get properties(){return r(r({},super.properties),{},{getImageSrc:{attribute:!1}})}renderBody(){var r,e;const s=super.renderBody({title:r=>t(a||(a=o`${0}`),r.helper.name),subtitle:r=>t(i||(i=o`${0}`),r.description)});if(!this.in({idle:"snapshot"}))return s;const m=l.defaultImageSrc,p=this.data;return t(d||(d=o` <figure class="flex items-center" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> <img class="relative h-s w-s object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs" src="${0}" alt="${0}" @error="${0}"> <figcaption class="min-w-0 flex-1">${0}</figcaption> </figure> `),null!==(e=p?null===(r=this.getImageSrc)||void 0===r?void 0:r.call(this,p.type):null)&&void 0!==e?e:m,this.t("image_alt"),(r=>r.currentTarget.src=m),s)}}customElements.define("foxy-payments-api-payment-method-card",l);export{l as PaymentsApiPaymentMethodCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-6e859df6.js";import"./shared-8cd578ee.js";import"./shared-937b497c.js";import"./shared-ef78d7d9.js";import"./shared-08e0a194.js";import{I as e}from"./shared-0e055562.js";import"./foxy-nucleon-element.js";import"./foxy-spinner.js";import"./shared-37efab30.js";import{_ as t,B as r,l as i}from"./shared-0f6e4584.js";import{g as o}from"./shared-bab2ea2c.js";import{a}from"./shared-fb34e84c.js";import{i as s}from"./shared-9803aa7c.js";import{h as l,s as n}from"./shared-dc73b9a5.js";import{c as d}from"./shared-4e709717.js";import{h as c}from"./shared-9db46672.js";import{s as h}from"./shared-6474675f.js";import"./shared-b08ca8d0.js";import"./shared-44ce656d.js";import"./shared-09b4185a.js";import"./shared-61ade33e.js";import"./shared-7d38cb8a.js";import"./shared-51c4a6dd.js";import"./shared-0b01f721.js";import"./shared-f7a1193f.js";import"./shared-24d71d01.js";import"./shared-c286c5ad.js";import"./shared-343d1fd7.js";import"./shared-cd96ff03.js";import"./shared-522a172d.js";import"./shared-12a7a15d.js";import"./shared-ee36b83f.js";import"./shared-9b2d6d62.js";import"./shared-90a47948.js";import"./shared-029d623b.js";import"./shared-0a6a28ce.js";import"./shared-280f868d.js";import"./shared-c2776a33.js";import"./shared-e24da82e.js";import"./shared-19884cf4.js";import"./shared-4b346553.js";import"./shared-651c44fa.js";import"./shared-8f3398dc.js";import"./shared-b8198665.js";import"./shared-a207423c.js";import"./shared-f2968508.js";import"./shared-d8c3067b.js";import"./shared-22ba9566.js";import"./shared-6918312e.js";import"./shared-fc1dfa64.js";import"./foxy-copy-to-clipboard.js";import"./shared-56bf05ef.js";let u,m,p,f,_,v,y,g,x,$,b,j,L,S,k,w,P,V,M,I,B,C,q,Z,H,D,O,R=e=>e;const T=a(e,"payments-api-payment-method-form");class W extends T{constructor(){super(...arguments),this.paymentPreset=null,this.getImageSrc=null,this.store=null,this.__availablePaymentMethodsLoaderId="availablePaymentMethodsLoader",this.__paymentPresetLoaderId="paymentPresetLoader",this.__storeLoaderId="storeLoader",this.__threeDSecureResponseGetValue=()=>{var e;return null===(e=this.form.config_3d_secure)||void 0===e?void 0:e.endsWith("require_valid_response")},this.__threeDSecureResponseSetValue=e=>{const t=e?"_require_valid_response":"",r=this.form.config_3d_secure,i=(null==r?void 0:r.startsWith("all_cards"))?"all_cards":"maestro_only";this.edit({config_3d_secure:`${i}${t}`})},this.__threeDSecureToggleGetValue=()=>{const e=this.form.config_3d_secure;return(null==e?void 0:e.startsWith("all_cards"))?"all_cards":(null==e?void 0:e.startsWith("maestro_only"))?"maestro_only":"off"},this.__threeDSecureToggleSetValue=e=>{var t;let r="";"all_cards"!==e&&"maestro_only"!==e||(r=(null===(t=this.form.config_3d_secure)||void 0===t?void 0:t.endsWith("require_valid_response"))?`${e}_require_valid_response`:e),this.edit({config_3d_secure:r})},this.__threeDSecureToggleOptions=[{value:"off",label:"option_off"},{value:"all_cards",label:"option_all_cards"},{value:"maestro_only",label:"option_maestro_only"}]}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E"}static get properties(){return t(t({},super.properties),{},{paymentPreset:{attribute:"payment-preset"},getImageSrc:{attribute:!1},store:{}})}static get v8n(){return[({description:e})=>!e||e.length<=100||"description:v8n_too_long",({type:e})=>!!e||"type:v8n_required",e=>{var t,r,i,o;const a=null!==(i=null===(r=null===(t=e.helper)||void 0===t?void 0:t.additional_fields)||void 0===r?void 0:r.blocks)&&void 0!==i?i:[];let s;try{s=JSON.parse(null!==(o=e.additional_fields)&&void 0!==o?o:"{}")}catch(e){s={}}for(const e of a)for(const t of e.fields)if("optional"in t&&!t.optional&&!c(s,t.id)&&"checkbox"!==t.type)return"additional-fields:v8n_invalid";return!0}]}get hiddenSelector(){return new r(`header:copy-json ${super.hiddenSelector}`.trimEnd())}renderHeader(...e){var t;return l(u||(u=R` <div> ${0} ${0} </div> `),super.renderHeader(...e),(null===(t=this.data)||void 0===t?void 0:t.type)||!this.form.type?l(m||(m=R``)):l(p||(p=R` <vaadin-button data-testid="select-another-button" theme="tertiary-inline" @click="${0}"> <foxy-i18n infer="" key="select_another_button_label"></foxy-i18n> </vaadin-button> `),(()=>this.undo())))}get headerTitleOptions(){var e;return{context:this.form.type?"selected":"new",name:null===(e=this.form.helper)||void 0===e?void 0:e.name}}get headerSubtitleOptions(){if(this.href){const e=o(this.href),t=this.headerCopyIdValue;return e.startsWith("R")?{context:"regular",id:t}:{context:"hosted",id:t}}return{}}get headerCopyIdValue(){if(this.href){const e=o(this.href);return e.startsWith("R")?e.slice(1):e.slice(1).split("C")[0]}return""}renderBody(){var e;const t=null===(e=this.__paymentPresetLoader)||void 0===e?void 0:e.data,r=l(f||(f=R` <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),s(null==t?void 0:t._links["fx:available_payment_methods"].href),this.__availablePaymentMethodsLoaderId,(()=>this.requestUpdate()),s(this.store),this.__storeLoaderId,(()=>this.requestUpdate()),s(this.paymentPreset),this.__paymentPresetLoaderId,(()=>this.requestUpdate()));return l(_||(_=R`${0}${0}${0}`),this.renderHeader(),this.form.type?this.__renderPaymentMethodConfig():this.__renderPaymentMethodSelector(),r)}get __groupedAvailablePaymentMethods(){var e;return Object.entries(null!==(e=this.__availablePaymentMethods)&&void 0!==e?e:{}).sort(((e,t)=>e[0].localeCompare(t[0],"en"))).reduce(((e,[t,r])=>{if(r.is_deprecated)return e;const i=t.charAt(0).toUpperCase(),o=!/\w/.test(i)?"#":i,a=e.find((e=>e.name===o));return a?a.items.push({type:t,helper:r}):e.push({name:o,items:[{type:t,helper:r}]}),e}),[])}get __availablePaymentMethodsLoader(){return this.renderRoot.querySelector(`#${this.__availablePaymentMethodsLoaderId}`)}get __availablePaymentMethods(){var e,t;return null===(t=null===(e=this.__availablePaymentMethodsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values}get __paymentPresetLoader(){return this.renderRoot.querySelector(`#${this.__paymentPresetLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __liveBlocks(){var e,t,r;return null!==(r=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>e.is_live)))&&void 0!==r?r:[]}get __testBlocks(){var e,t,r;return null!==(r=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>!e.is_live)))&&void 0!==r?r:[]}__renderPaymentMethodSelector(){const e=this.__availablePaymentMethodsLoader;return(null==e?void 0:e.data)?l(y||(y=R` <div> <section data-testid="select-method-list" class="-mt-m"> ${0} </section> </div> `),this.__groupedAvailablePaymentMethods.map((({name:e,items:t})=>l(g||(g=R` <p class="font-medium text-tertiary py-m">${0}</p> <ul class="grid grid-cols-2 gap-m"> ${0} </ul> `),e,t.map((e=>l(x||(x=R`<li>${0}</li>`),this.__renderPaymentMethodButton(e)))))))):l(v||(v=R` <foxy-spinner infer="list-spinner" state="${0}"> </foxy-spinner> `),(null==e?void 0:e.in("fail"))?"error":"busy")}__renderPaymentMethodConfig(){var e;return this.form.type&&["stripe_connect","square_up","quickbook_payments","amazon_mws","paypal_platform"].includes(this.form.type)?l($||($=R` <div class="flex items-start rounded border border-primary" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px);padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p> <foxy-i18n infer="" key="no_oauth_support_message"></foxy-i18n> <br> <a target="_blank" class="mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50" href="https://admin.foxycart.com"> admin.foxycart.com </a> </p> </div> `),n(b||(b=R`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`))):l(j||(j=R` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> ${0} </foxy-internal-summary-control> ${0} ${0} `),(null===(e=this.form.helper)||void 0===e?void 0:e.supports_3d_secure)?l(L||(L=R` <foxy-internal-select-control layout="summary-item" infer="three-d-secure-toggle" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-select-control> ${0} `),this.__threeDSecureToggleGetValue,this.__threeDSecureToggleSetValue,this.__threeDSecureToggleOptions,this.form.config_3d_secure?l(S||(S=R` <foxy-internal-switch-control layout="summary-item" infer="three-d-secure-response" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),this.__threeDSecureResponseGetValue,this.__threeDSecureResponseSetValue):""):"",["live","test"].map(((e,t)=>{var r,i,o,a,d,c,h,u,m,p,f,_;const v=0===t?"":`${e}-`,y=0===t?this.__liveBlocks:this.__testBlocks,g=`${e}-group`;if("live"===e&&!(null===(r=this.__storeLoader)||void 0===r?void 0:r.data))return l(k||(k=R``));if("live"===e&&!(null===(o=null===(i=this.__storeLoader)||void 0===i?void 0:i.data)||void 0===o?void 0:o.is_active))return l(w||(w=R` <foxy-internal-summary-control infer="${0}-group"> <div class="flex items-start" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p><foxy-i18n infer="" key="inactive_message"></foxy-i18n></p> </div> </foxy-internal-summary-control> `),e,n(P||(P=R`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`)));const x=!0===(null===(d=null===(a=this.__storeLoader)||void 0===a?void 0:a.data)||void 0===d?void 0:d.is_active)&&("test"===e&&!0===(null===(h=null===(c=this.__paymentPresetLoader)||void 0===c?void 0:c.data)||void 0===h?void 0:h.is_live)||"live"===e&&!1===(null===(m=null===(u=this.__paymentPresetLoader)||void 0===u?void 0:u.data)||void 0===m?void 0:m.is_live));return l(V||(V=R` <foxy-internal-summary-control helper-text="${0}" label="${0}" infer="${0}"> ${0} ${0} ${0} ${0} </foxy-internal-summary-control> `),s(x?this.t(`${g}.helper_text_inactive`):void 0),s(x?this.t(`${g}.label_inactive`):void 0),g,(null===(p=this.form.helper)||void 0===p?void 0:p.id_description)?l(M||(M=R` <foxy-internal-text-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}account-id"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.id_description,v):"",(null===(f=this.form.helper)||void 0===f?void 0:f.third_party_key_description)?l(I||(I=R` <foxy-internal-text-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}third-party-key"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.third_party_key_description,v):"",(null===(_=this.form.helper)||void 0===_?void 0:_.key_description)?l(B||(B=R` <foxy-internal-text-control placeholder="${0}" layout="summary-item" helper-text="" label="${0}" infer="${0}account-key"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.key_description,v):"",y.map((e=>this.__renderBlock(e))))})),super.renderBody())}__renderPaymentMethodButton({type:e,helper:t}){var r,i;const o=W.defaultImageSrc,a=null!==(i=null===(r=this.getImageSrc)||void 0===r?void 0:r.call(this,e))&&void 0!==i?i:o,s=e=>e.currentTarget.src=o;return l(C||(C=R` <button class="${0}" ?disabled="${0}" title="${0}" @click="${0}"> <img class="absolute top-0 left-0 w-1-2 h-full object-cover bg-center filter saturate-200 blur-3xl" style="transform:translate3d(0,0,0)" src="${0}" alt="" ?hidden="${0}" @error="${0}"> <figure class="relative flex flex-col gap-m"> <img class="${0}" src="${0}" alt="" @error="${0}"> <figcaption class="${0}"> <div class="font-medium">${0}​</div> <div class="text-xs ${0}">${0}</div> </figcaption> </figure> </button> `),d({"relative w-full block text-left p-s rounded bg-contrast-5 overflow-hidden":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"transition-colors hover-bg-contrast-10":!t.conflict,"cursor-default":!!t.conflict}),!!t.conflict,t.conflict?this.t("conflict_message",t.conflict):"",(()=>this.edit({type:e,helper:t})),a,!!t.conflict,s,d({"h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs":!0,"filter grayscale":!!t.conflict}),a,s,d({"min-w-0 flex-1 truncate leading-s":!0,"text-disabled":!!t.conflict}),t.name,t.conflict?"":"text-secondary",e)}__renderBlock(e){return l(q||(q=R`${0}`),e.fields.map((e=>{var t,r,o;if("hidden"===e.type)return;const a=["additional-fields",e.id].join("-").replace(/_/g,"-"),s=()=>{var t,r;try{const o=JSON.parse(null!==(t=this.form.additional_fields)&&void 0!==t?t:"{}");return null!==(r=i(o,e.id))&&void 0!==r?r:o.default_value}catch(t){return e.default_value}},n=t=>{var r;let i={};try{i=JSON.parse(null!==(r=this.form.additional_fields)&&void 0!==r?r:"")}catch(e){}this.edit({additional_fields:JSON.stringify(h(i,e.id,t))})},d=e.options;return l(Z||(Z=R` ${0} `),"checkbox"===e.type?l(H||(H=R` <foxy-internal-switch-control helper-text="${0}" label="${0}" infer="${0}" helper-text-as-tooltip .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),null!==(t=e.description)&&void 0!==t?t:"",e.name,a,s,n):"select"===e.type?l(D||(D=R` <foxy-internal-select-control placeholder="${0}" helper-text="${0}" layout="summary-item" label="${0}" infer="${0}" .options="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-select-control> `),this.t("default_additional_field_select_placeholder"),null!==(r=e.description)&&void 0!==r?r:"",e.name,a,d.map((({name:e,value:t})=>({label:e,value:t}))),s,n):l(O||(O=R` <foxy-internal-text-control helper-text="${0}" placeholder="${0}" layout="summary-item" label="${0}" infer="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-text-control> `),null!==(o=e.description)&&void 0!==o?o:"",e.default_value||this.t("default_additional_field_placeholder"),e.name,a,s,n))})))}}customElements.define("foxy-payments-api-payment-method-form",W);export{W as PaymentsApiPaymentMethodForm};
|
|
1
|
+
import"./shared-239062b0.js";import"./shared-374e6faa.js";import"./shared-745f340a.js";import"./shared-9092b5db.js";import"./shared-5c35d93a.js";import{I as e}from"./shared-bc023a29.js";import"./foxy-nucleon-element.js";import"./foxy-spinner.js";import"./shared-acd33590.js";import{_ as t,B as r,l as i}from"./shared-d1195c27.js";import{g as o}from"./shared-bab2ea2c.js";import{a}from"./shared-b726120d.js";import{i as s}from"./shared-9803aa7c.js";import{h as l,s as n}from"./shared-dc73b9a5.js";import{c as d}from"./shared-4e709717.js";import{h as c}from"./shared-56ba2d28.js";import{s as h}from"./shared-1aff7995.js";import"./shared-f998f9c8.js";import"./shared-adcfd50a.js";import"./shared-65479601.js";import"./shared-61ade33e.js";import"./shared-f8368b97.js";import"./shared-51c4a6dd.js";import"./shared-d1cb97c6.js";import"./shared-17a61265.js";import"./shared-2ad18636.js";import"./shared-c518ece2.js";import"./shared-343d1fd7.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-fcdb896f.js";import"./shared-11694c05.js";import"./shared-5513e830.js";import"./shared-c4f15ea3.js";import"./shared-913e1955.js";import"./shared-40af05b3.js";import"./shared-91d8985f.js";import"./shared-8da3186f.js";import"./shared-9a59aab2.js";import"./shared-8fc527b7.js";import"./shared-651c44fa.js";import"./shared-562d466d.js";import"./shared-8b5e05df.js";import"./shared-7ceceb4c.js";import"./shared-f893763a.js";import"./shared-97cfdcdb.js";import"./shared-22ba9566.js";import"./shared-28ebee50.js";import"./shared-df51ee50.js";import"./foxy-copy-to-clipboard.js";import"./shared-4903b2e3.js";let u,m,p,f,_,v,y,g,x,$,b,j,L,S,k,w,P,V,M,I,B,C,q,Z,H,D,O,R=e=>e;const T=a(e,"payments-api-payment-method-form");class W extends T{constructor(){super(...arguments),this.paymentPreset=null,this.getImageSrc=null,this.store=null,this.__availablePaymentMethodsLoaderId="availablePaymentMethodsLoader",this.__paymentPresetLoaderId="paymentPresetLoader",this.__storeLoaderId="storeLoader",this.__threeDSecureResponseGetValue=()=>{var e;return null===(e=this.form.config_3d_secure)||void 0===e?void 0:e.endsWith("require_valid_response")},this.__threeDSecureResponseSetValue=e=>{const t=e?"_require_valid_response":"",r=this.form.config_3d_secure,i=(null==r?void 0:r.startsWith("all_cards"))?"all_cards":"maestro_only";this.edit({config_3d_secure:`${i}${t}`})},this.__threeDSecureToggleGetValue=()=>{const e=this.form.config_3d_secure;return(null==e?void 0:e.startsWith("all_cards"))?"all_cards":(null==e?void 0:e.startsWith("maestro_only"))?"maestro_only":"off"},this.__threeDSecureToggleSetValue=e=>{var t;let r="";"all_cards"!==e&&"maestro_only"!==e||(r=(null===(t=this.form.config_3d_secure)||void 0===t?void 0:t.endsWith("require_valid_response"))?`${e}_require_valid_response`:e),this.edit({config_3d_secure:r})},this.__threeDSecureToggleOptions=[{value:"off",label:"option_off"},{value:"all_cards",label:"option_all_cards"},{value:"maestro_only",label:"option_maestro_only"}]}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E"}static get properties(){return t(t({},super.properties),{},{paymentPreset:{attribute:"payment-preset"},getImageSrc:{attribute:!1},store:{}})}static get v8n(){return[({description:e})=>!e||e.length<=100||"description:v8n_too_long",({type:e})=>!!e||"type:v8n_required",e=>{var t,r,i,o;const a=null!==(i=null===(r=null===(t=e.helper)||void 0===t?void 0:t.additional_fields)||void 0===r?void 0:r.blocks)&&void 0!==i?i:[];let s;try{s=JSON.parse(null!==(o=e.additional_fields)&&void 0!==o?o:"{}")}catch(e){s={}}for(const e of a)for(const t of e.fields)if("optional"in t&&!t.optional&&!c(s,t.id)&&"checkbox"!==t.type)return"additional-fields:v8n_invalid";return!0}]}get hiddenSelector(){return new r(`header:copy-json ${super.hiddenSelector}`.trimEnd())}renderHeader(...e){var t;return l(u||(u=R` <div> ${0} ${0} </div> `),super.renderHeader(...e),(null===(t=this.data)||void 0===t?void 0:t.type)||!this.form.type?l(m||(m=R``)):l(p||(p=R` <vaadin-button data-testid="select-another-button" theme="tertiary-inline" @click="${0}"> <foxy-i18n infer="" key="select_another_button_label"></foxy-i18n> </vaadin-button> `),(()=>this.undo())))}get headerTitleOptions(){var e;return{context:this.form.type?"selected":"new",name:null===(e=this.form.helper)||void 0===e?void 0:e.name}}get headerSubtitleOptions(){if(this.href){const e=o(this.href),t=this.headerCopyIdValue;return e.startsWith("R")?{context:"regular",id:t}:{context:"hosted",id:t}}return{}}get headerCopyIdValue(){if(this.href){const e=o(this.href);return e.startsWith("R")?e.slice(1):e.slice(1).split("C")[0]}return""}renderBody(){var e;const t=null===(e=this.__paymentPresetLoader)||void 0===e?void 0:e.data,r=l(f||(f=R` <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),s(null==t?void 0:t._links["fx:available_payment_methods"].href),this.__availablePaymentMethodsLoaderId,(()=>this.requestUpdate()),s(this.store),this.__storeLoaderId,(()=>this.requestUpdate()),s(this.paymentPreset),this.__paymentPresetLoaderId,(()=>this.requestUpdate()));return l(_||(_=R`${0}${0}${0}`),this.renderHeader(),this.form.type?this.__renderPaymentMethodConfig():this.__renderPaymentMethodSelector(),r)}get __groupedAvailablePaymentMethods(){var e;return Object.entries(null!==(e=this.__availablePaymentMethods)&&void 0!==e?e:{}).sort(((e,t)=>e[0].localeCompare(t[0],"en"))).reduce(((e,[t,r])=>{if(r.is_deprecated)return e;const i=t.charAt(0).toUpperCase(),o=!/\w/.test(i)?"#":i,a=e.find((e=>e.name===o));return a?a.items.push({type:t,helper:r}):e.push({name:o,items:[{type:t,helper:r}]}),e}),[])}get __availablePaymentMethodsLoader(){return this.renderRoot.querySelector(`#${this.__availablePaymentMethodsLoaderId}`)}get __availablePaymentMethods(){var e,t;return null===(t=null===(e=this.__availablePaymentMethodsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values}get __paymentPresetLoader(){return this.renderRoot.querySelector(`#${this.__paymentPresetLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __liveBlocks(){var e,t,r;return null!==(r=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>e.is_live)))&&void 0!==r?r:[]}get __testBlocks(){var e,t,r;return null!==(r=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>!e.is_live)))&&void 0!==r?r:[]}__renderPaymentMethodSelector(){const e=this.__availablePaymentMethodsLoader;return(null==e?void 0:e.data)?l(y||(y=R` <div> <section data-testid="select-method-list" class="-mt-m"> ${0} </section> </div> `),this.__groupedAvailablePaymentMethods.map((({name:e,items:t})=>l(g||(g=R` <p class="font-medium text-tertiary py-m">${0}</p> <ul class="grid grid-cols-2 gap-m"> ${0} </ul> `),e,t.map((e=>l(x||(x=R`<li>${0}</li>`),this.__renderPaymentMethodButton(e)))))))):l(v||(v=R` <foxy-spinner infer="list-spinner" state="${0}"> </foxy-spinner> `),(null==e?void 0:e.in("fail"))?"error":"busy")}__renderPaymentMethodConfig(){var e;return this.form.type&&["stripe_connect","square_up","quickbook_payments","amazon_mws","paypal_platform"].includes(this.form.type)?l($||($=R` <div class="flex items-start rounded border border-primary" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px);padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p> <foxy-i18n infer="" key="no_oauth_support_message"></foxy-i18n> <br> <a target="_blank" class="mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50" href="https://admin.foxycart.com"> admin.foxycart.com </a> </p> </div> `),n(b||(b=R`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`))):l(j||(j=R` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> ${0} </foxy-internal-summary-control> ${0} ${0} `),(null===(e=this.form.helper)||void 0===e?void 0:e.supports_3d_secure)?l(L||(L=R` <foxy-internal-select-control layout="summary-item" infer="three-d-secure-toggle" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-select-control> ${0} `),this.__threeDSecureToggleGetValue,this.__threeDSecureToggleSetValue,this.__threeDSecureToggleOptions,this.form.config_3d_secure?l(S||(S=R` <foxy-internal-switch-control layout="summary-item" infer="three-d-secure-response" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),this.__threeDSecureResponseGetValue,this.__threeDSecureResponseSetValue):""):"",["live","test"].map(((e,t)=>{var r,i,o,a,d,c,h,u,m,p,f,_;const v=0===t?"":`${e}-`,y=0===t?this.__liveBlocks:this.__testBlocks,g=`${e}-group`;if("live"===e&&!(null===(r=this.__storeLoader)||void 0===r?void 0:r.data))return l(k||(k=R``));if("live"===e&&!(null===(o=null===(i=this.__storeLoader)||void 0===i?void 0:i.data)||void 0===o?void 0:o.is_active))return l(w||(w=R` <foxy-internal-summary-control infer="${0}-group"> <div class="flex items-start" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p><foxy-i18n infer="" key="inactive_message"></foxy-i18n></p> </div> </foxy-internal-summary-control> `),e,n(P||(P=R`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`)));const x=!0===(null===(d=null===(a=this.__storeLoader)||void 0===a?void 0:a.data)||void 0===d?void 0:d.is_active)&&("test"===e&&!0===(null===(h=null===(c=this.__paymentPresetLoader)||void 0===c?void 0:c.data)||void 0===h?void 0:h.is_live)||"live"===e&&!1===(null===(m=null===(u=this.__paymentPresetLoader)||void 0===u?void 0:u.data)||void 0===m?void 0:m.is_live));return l(V||(V=R` <foxy-internal-summary-control helper-text="${0}" label="${0}" infer="${0}"> ${0} ${0} ${0} ${0} </foxy-internal-summary-control> `),s(x?this.t(`${g}.helper_text_inactive`):void 0),s(x?this.t(`${g}.label_inactive`):void 0),g,(null===(p=this.form.helper)||void 0===p?void 0:p.id_description)?l(M||(M=R` <foxy-internal-text-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}account-id"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.id_description,v):"",(null===(f=this.form.helper)||void 0===f?void 0:f.third_party_key_description)?l(I||(I=R` <foxy-internal-text-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}third-party-key"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.third_party_key_description,v):"",(null===(_=this.form.helper)||void 0===_?void 0:_.key_description)?l(B||(B=R` <foxy-internal-text-control placeholder="${0}" layout="summary-item" helper-text="" label="${0}" infer="${0}account-key"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.key_description,v):"",y.map((e=>this.__renderBlock(e))))})),super.renderBody())}__renderPaymentMethodButton({type:e,helper:t}){var r,i;const o=W.defaultImageSrc,a=null!==(i=null===(r=this.getImageSrc)||void 0===r?void 0:r.call(this,e))&&void 0!==i?i:o,s=e=>e.currentTarget.src=o;return l(C||(C=R` <button class="${0}" ?disabled="${0}" title="${0}" @click="${0}"> <img class="absolute top-0 left-0 w-1-2 h-full object-cover bg-center filter saturate-200 blur-3xl" style="transform:translate3d(0,0,0)" src="${0}" alt="" ?hidden="${0}" @error="${0}"> <figure class="relative flex flex-col gap-m"> <img class="${0}" src="${0}" alt="" @error="${0}"> <figcaption class="${0}"> <div class="font-medium">${0}​</div> <div class="text-xs ${0}">${0}</div> </figcaption> </figure> </button> `),d({"relative w-full block text-left p-s rounded bg-contrast-5 overflow-hidden":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"transition-colors hover-bg-contrast-10":!t.conflict,"cursor-default":!!t.conflict}),!!t.conflict,t.conflict?this.t("conflict_message",t.conflict):"",(()=>this.edit({type:e,helper:t})),a,!!t.conflict,s,d({"h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs":!0,"filter grayscale":!!t.conflict}),a,s,d({"min-w-0 flex-1 truncate leading-s":!0,"text-disabled":!!t.conflict}),t.name,t.conflict?"":"text-secondary",e)}__renderBlock(e){return l(q||(q=R`${0}`),e.fields.map((e=>{var t,r,o;if("hidden"===e.type)return;const a=["additional-fields",e.id].join("-").replace(/_/g,"-"),s=()=>{var t,r;try{const o=JSON.parse(null!==(t=this.form.additional_fields)&&void 0!==t?t:"{}");return null!==(r=i(o,e.id))&&void 0!==r?r:o.default_value}catch(t){return e.default_value}},n=t=>{var r;let i={};try{i=JSON.parse(null!==(r=this.form.additional_fields)&&void 0!==r?r:"")}catch(e){}this.edit({additional_fields:JSON.stringify(h(i,e.id,t))})},d=e.options;return l(Z||(Z=R` ${0} `),"checkbox"===e.type?l(H||(H=R` <foxy-internal-switch-control helper-text="${0}" label="${0}" infer="${0}" helper-text-as-tooltip .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),null!==(t=e.description)&&void 0!==t?t:"",e.name,a,s,n):"select"===e.type?l(D||(D=R` <foxy-internal-select-control placeholder="${0}" helper-text="${0}" layout="summary-item" label="${0}" infer="${0}" .options="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-select-control> `),this.t("default_additional_field_select_placeholder"),null!==(r=e.description)&&void 0!==r?r:"",e.name,a,d.map((({name:e,value:t})=>({label:e,value:t}))),s,n):l(O||(O=R` <foxy-internal-text-control helper-text="${0}" placeholder="${0}" layout="summary-item" label="${0}" infer="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-text-control> `),null!==(o=e.description)&&void 0!==o?o:"",e.default_value||this.t("default_additional_field_placeholder"),e.name,a,s,n))})))}}customElements.define("foxy-payments-api-payment-method-form",W);export{W as PaymentsApiPaymentMethodForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-51c4a6dd.js";import"./foxy-spinner.js";import"./shared-
|
|
1
|
+
import"./shared-51c4a6dd.js";import"./foxy-spinner.js";import"./shared-acd33590.js";import{a as s}from"./shared-b726120d.js";import{T as r}from"./shared-d3044c4c.js";import{c as e}from"./shared-4e709717.js";import{h as a}from"./shared-dc73b9a5.js";import"./shared-5513e830.js";import"./shared-adcfd50a.js";import"./shared-4903b2e3.js";import"./shared-d1195c27.js";import"./shared-17a61265.js";import"./shared-343d1fd7.js";import"./shared-d1cb97c6.js";import"./shared-9803aa7c.js";import"./shared-19df2a73.js";import"./shared-2ad18636.js";import"./shared-c518ece2.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-1aff7995.js";import"./shared-fcdb896f.js";let d,t,i=s=>s;const o=s(r,"payments-api-payment-preset-card");class p extends o{renderBody(){return super.renderBody({title:s=>a(d||(d=i`${0}`),s.description),subtitle:({is_live:s})=>a(t||(t=i` <foxy-i18n class="${0}" infer="" key="status_${0}"> </foxy-i18n> `),e({"text-success":s}),s?"live":"test")})}}customElements.define("foxy-payments-api-payment-preset-card",p);export{p as PaymentsApiPaymentPresetCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-aaf72aad.js";import"./shared-374e6faa.js";import"./shared-745f340a.js";import"./shared-5c35d93a.js";import{I as e}from"./shared-bc023a29.js";import"./foxy-payments-api-fraud-protection-card.js";import"./foxy-payments-api-fraud-protection-form.js";import"./foxy-payments-api-payment-method-card.js";import"./foxy-payments-api-payment-method-form.js";import{_ as r,B as t}from"./shared-d1195c27.js";import{a as o}from"./shared-b726120d.js";import{i as s}from"./shared-9803aa7c.js";import{h as a}from"./shared-dc73b9a5.js";import"./shared-f998f9c8.js";import"./shared-adcfd50a.js";import"./shared-5513e830.js";import"./shared-65479601.js";import"./shared-6f0504e2.js";import"./shared-61ade33e.js";import"./shared-40af05b3.js";import"./shared-91d8985f.js";import"./shared-8da3186f.js";import"./shared-239062b0.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-4903b2e3.js";import"./shared-acd33590.js";import"./shared-343d1fd7.js";import"./shared-17a61265.js";import"./shared-d1cb97c6.js";import"./shared-2ad18636.js";import"./shared-c518ece2.js";import"./shared-cd96ff03.js";import"./shared-9cf15285.js";import"./shared-019348d7.js";import"./shared-1aff7995.js";import"./shared-fcdb896f.js";import"./shared-a0c6a159.js";import"./shared-99940888.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-28ebee50.js";import"./shared-df51ee50.js";import"./shared-4e709717.js";import"./foxy-pagination.js";import"./shared-f8368b97.js";import"./shared-51c4a6dd.js";import"./shared-11694c05.js";import"./shared-c4f15ea3.js";import"./shared-8b5e05df.js";import"./shared-7ceceb4c.js";import"./shared-8fc527b7.js";import"./shared-562d466d.js";import"./shared-22ba9566.js";import"./foxy-copy-to-clipboard.js";import"./shared-bab2ea2c.js";import"./shared-d3044c4c.js";import"./shared-19df2a73.js";import"./shared-8a73d1aa.js";import"./shared-c98881c7.js";import"./shared-9092b5db.js";import"./shared-913e1955.js";import"./shared-9a59aab2.js";import"./shared-651c44fa.js";import"./shared-f893763a.js";import"./shared-97cfdcdb.js";import"./foxy-nucleon-element.js";import"./shared-56ba2d28.js";let i,d=e=>e;const n=o(e,"payments-api-payment-preset-form");class p extends n{constructor(){super(...arguments),this.getFraudProtectionImageSrc=null,this.getPaymentMethodImageSrc=null,this.__isPurchaseOrderEnabledGetValue=()=>{var e,r;return!!(null===(r=null===(e=this.__storeLoader)||void 0===e?void 0:e.data)||void 0===r?void 0:r.is_active)&&this.form.is_purchase_order_enabled},this.__isLiveGetValue=()=>{var e,r;return!!(null===(r=null===(e=this.__storeLoader)||void 0===e?void 0:e.data)||void 0===r?void 0:r.is_active)&&this.form.is_live},this.__storeLoaderId="storeLoader"}static get properties(){return r(r({},super.properties),{},{getFraudProtectionImageSrc:{attribute:!1},getPaymentMethodImageSrc:{attribute:!1}})}static get v8n(){return[({description:e})=>!!e||"description:v8n_required",({description:e})=>e&&e.length<=100||"description:v8n_too_long"]}get readonlySelector(){var e,r;const o=[super.hiddenSelector.toString()];return(null===(r=null===(e=this.__storeLoader)||void 0===e?void 0:e.data)||void 0===r?void 0:r.is_active)||o.unshift("general:is-live","general:is-purchase-order-enabled"),new t(o.join(" ").trim())}get hiddenSelector(){var e;const r=["header:copy-json",super.hiddenSelector.toString()],o=null===(e=this.__storeLoader)||void 0===e?void 0:e.data;return this.data||r.unshift("payment-methods","fraud-protections"),o||r.unshift("general:is-live","general:is-purchase-order-enabled"),new t(r.join(" ").trim())}renderBody(){var e,r,t,o,n,p;const m=!!(null===(r=null===(e=this.__storeLoader)||void 0===e?void 0:e.data)||void 0===r?void 0:r.is_active)?"":"_inactive_store";return a(i||(i=d` ${0} <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> <foxy-internal-switch-control helper-text="${0}" infer="is-live" helper-text-as-tooltip .getValue="${0}"> </foxy-internal-switch-control> <foxy-internal-switch-control helper-text="${0}" infer="is-purchase-order-enabled" helper-text-as-tooltip .getValue="${0}"> </foxy-internal-switch-control> </foxy-internal-summary-control> <foxy-internal-async-list-control infer="payment-methods" first="${0}" limit="5" item="foxy-payments-api-payment-method-card" form="foxy-payments-api-payment-method-form" alert .itemProps="${0}" .formProps="${0}"> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="fraud-protections" first="${0}" limit="5" item="foxy-payments-api-fraud-protection-card" form="foxy-payments-api-fraud-protection-form" alert .itemProps="${0}" .formProps="${0}"> </foxy-internal-async-list-control> ${0} <foxy-nucleon class="hidden" infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),this.t(`general.is-live.helper_text${m}`),this.__isLiveGetValue,this.t(`general.is-purchase-order-enabled.helper_text${m}`),this.__isPurchaseOrderEnabledGetValue,s(null===(t=this.data)||void 0===t?void 0:t._links["fx:payment_methods"].href),{".getImageSrc":this.getPaymentMethodImageSrc},{".getImageSrc":this.getPaymentMethodImageSrc,"payment-preset":this.href,store:null===(o=this.data)||void 0===o?void 0:o._links["fx:store"].href},s(null===(n=this.data)||void 0===n?void 0:n._links["fx:fraud_protections"].href),{".getImageSrc":this.getFraudProtectionImageSrc},{".getImageSrc":this.getFraudProtectionImageSrc},super.renderBody(),s(null===(p=this.data)||void 0===p?void 0:p._links["fx:store"].href),this.__storeLoaderId,(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}}customElements.define("foxy-payments-api-payment-preset-form",p);export{p as PaymentsApiPaymentPresetForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e}from"./shared-dc73b9a5.js";import{F as t}from"./shared-343d1fd7.js";import{aM as a,aH as s,_ as n}from"./shared-0f6e4584.js";import{A as r}from"./shared-c286c5ad.js";async function o(e){const t=await e;if(!t.ok)throw new Error(await t.text());return t.json()}async function i(e){var t;let s,n;try{const{hostedPaymentGatewaysHelperUrl:r,paymentGatewaysHelperUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if("GET"!==d.method)throw s=405,new Error("Method not allowed. Allowed methods: GET.");const p=a(/\/payment_presets\/(.+)\/available_payment_methods/,{presetId:1}).exec(new URL(d.url).pathname).groups.presetId,h=o(m(r)),y=o(m(i)),f=await o(m(l(p))),c=(async()=>{const e=[];for(;;){const t=new URL(d.url).origin,a=new URL(`${t}/payment_presets/${p}/payment_methods`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(m(a.toString()));if(e.push(...s._embedded["fx:payment_methods"]),s._embedded["fx:payment_methods"].length<200)break}return e})(),u=null===(t=f._links["fx:payment_gateway"])||void 0===t?void 0:t.href,w=u?await o(m(u)):void 0,_=function(e){const{hostedPaymentGatewaysHelper:t,paymentGatewaysHelper:a,paymentPresetId:s,paymentMethods:n,paymentGateway:r,base:o}=e,i=new URL(`./payment_presets/${s}/available_payment_methods`,o),l={};return Object.entries(t.values).forEach((([e,t])=>{l[e]=t;const a=n.find((t=>t.type===e));a&&(l[e].conflict={type:a.type,name:a.description})})),Object.entries(a.values).forEach((([e,t])=>{l[e]=t,r&&(l[e].conflict={type:r.type,name:r.description})})),{_links:{self:{href:i.toString()}},values:l}}({hostedPaymentGatewaysHelper:await h,paymentGatewaysHelper:await y,paymentPresetId:p,paymentGateway:w,paymentMethods:await c,base:new URL(d.url).origin});n=JSON.stringify(_),s=200}catch(e){n=e instanceof Error?e.message:String(e),s=null!=s?s:500}return new Response(n,{status:s})}function l(e){const{paymentPresetId:t,fraudProtections:a,base:s}=e,n=new URL(`./payment_presets/${t}/available_fraud_protections`,s),r={minfraud:{name:"MaxMind minFraud",uses_rejection_threshold:!0,json:null},google_recaptcha:{name:"Google reCAPTCHA",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"config",name:"Configuration",type:"select",description:"Determines how reCAPTCHA is configured to operate.",default_value:"disabled",options:[{name:"Disabled",value:"disabled"},{name:"Always enabled",value:"enabled_always"},{name:"Enabled by errors",value:"enabled_by_errors"}]},{id:"private_key",name:"Private Key",type:"text",optional:!0,description:"If using a custom subdomain, enter your Private Key here.",default_value:""},{id:"site_key",name:"Site Key",type:"text",optional:!0,description:"If using a custom subdomain, enter your Site Key here.",default_value:""}]}]}},custom_precheckout_hook:{name:"Pre-Checkout Webhook",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"enabled",name:"Enabled",type:"checkbox",default_value:!1},{id:"url",name:"URL",type:"text",description:"Url of your Pre-Checkout Hook",default_value:""},{id:"failure_handling",name:"Failure handling",type:"select",description:"Determines what happens to the checkout submission if your webhook fails to respond correctly.",default_value:"",options:[{name:"Reject",value:"reject"},{name:"Approve",value:"approve"}]}]}]}}};for(const e in r){const t=null==a?void 0:a.find((t=>t.type===e));t&&(r[e].conflict={type:t.type,name:t.description})}return{_links:{self:{href:n.toString()}},values:r}}async function d(e){let t,s;try{const{request:n,fetch:r}=e;if("GET"!==n.method)throw t=405,new Error("Method not allowed. Allowed methods: GET.");const i=a(/\/payment_presets\/(.+)\/available_fraud_protections/,{presetId:1}).exec(new URL(n.url).pathname).groups.presetId,d=(async()=>{const e=[];for(;;){const t=new URL(n.url).origin,a=new URL(`${t}/payment_presets/${i}/fraud_protections`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(r(a.toString()));if(e.push(...s._embedded["fx:fraud_protections"]),s._embedded["fx:fraud_protections"].length<200)break}return e})(),m=l({fraudProtections:await d,paymentPresetId:i,base:new URL(n.url).origin});s=JSON.stringify(m),t=200}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const m=["_links"];function p(e){const{paymentMethodSetFraudProtectionId:t,paymentPresetId:a,fraudProtection:r,base:o}=e,{_links:i}=r,d=s(r,m),p=l({paymentPresetId:a,base:o}),h=`${new URL(i.self.href).pathname.split("/").pop()}C${t}`,y=new URL(`./payment_presets/${a}`,o),f=new URL(`./payment_presets/${a}/fraud_protections/${h}`,o);return n(n({_links:{self:{href:f.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:y.toString()}}},d),{},{helper:p.values[r.type]})}async function h(e){var t,s;let n,r;try{const{fraudProtectionsUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if(!["GET","POST"].includes(d.method))throw n=405,new Error("Method not allowed. Allowed methods: GET, POST.");const h=new URL(d.url),y=a(/\/payment_presets\/(.+)\/fraud_protections/,{presetId:1}).exec(h.pathname).groups.presetId,f=await o(m(l(y)));if("GET"===d.method){const e=parseInt(null!==(t=h.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=h.searchParams.get("limit"))&&void 0!==s?s:"20"),i=new URL(f._links["fx:payment_method_set_fraud_protections"].href);i.searchParams.set("offset",String(Math.max(0,e-1))),i.searchParams.set("limit",String(a));const l=await o(m(i.toString())),c=await Promise.all(l._embedded["fx:payment_method_set_fraud_protections"].map((async e=>o(m(e._links["fx:fraud_protection"].href))))),u=function(e){const{paymentMethodSetFraudProtections:t,fraudProtections:a,paymentPresetId:s,base:n}=e,r=new URL(`/payment_presets/${s}/fraud_protections`,n);r.search=new URL(t._links.self.href).search;const o=new URL(r.toString());o.search=new URL(t._links.first.href).search;const i=new URL(r.toString());i.search=new URL(t._links.last.href).search;const l=new URL(r.toString());l.search=new URL(t._links.prev.href).search;const d=new URL(r.toString());d.search=new URL(t._links.next.href).search;const m=a.map((e=>{const a=t._embedded["fx:payment_method_set_fraud_protections"].find((t=>t.fraud_protection_uri===e._links.self.href));return p({paymentMethodSetFraudProtectionId:new URL(a._links.self.href).pathname.split("/").pop(),fraudProtection:e,paymentPresetId:s,base:n})}));return{_links:{first:{href:o.toString()},last:{href:i.toString()},prev:{href:l.toString()},next:{href:d.toString()},self:{href:r.toString()}},_embedded:{"fx:fraud_protections":m},returned_items:t.returned_items,total_items:t.total_items,offset:t.offset,limit:t.limit}}({paymentMethodSetFraudProtections:l,fraudProtections:c,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(u)}else{const e=await d.json();delete e.helper;const t=m(i,{method:"POST",body:JSON.stringify(e)}),a=await o(t),s=await o(m(f._links["fx:payment_method_set_fraud_protections"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:f._links.self.href,fraud_protection_uri:a._links.self.href})})),l=p({paymentMethodSetFraudProtectionId:new URL(s._links.self.href).pathname.split("/").pop(),fraudProtection:a,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(l)}}catch(e){r=e instanceof Error?e.message:String(e),n=null!=n?n:500}return new Response(r,{status:n})}async function y(e){let t,s;try{const{getPaymentMethodSetUrl:n,getFraudProtectionUrl:r,request:i,fetch:l}=e;if(!["GET","PATCH","DELETE"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const d=a(/\/payment_presets\/(.+)\/fraud_protections\/(.+)/,{presetId:1,protectionId:2}),{presetId:m,protectionId:h}=d.exec(i.url).groups,y=n(m),f=h.substring(0,h.indexOf("C"));if("DELETE"===i.method){const e=(await o(l(y)))._links["fx:payment_method_set_fraud_protections"].href,t=new URL(e);t.searchParams.set("fraud_protection_id",f);const a=await o(l(t.toString())),s=a._embedded["fx:payment_method_set_fraud_protections"].map((e=>o(l(e._links.self.href,{method:"DELETE"}))));await Promise.all(s)}let c=await i.text();try{const e=JSON.parse(c);delete e.helper,c=JSON.stringify(e)}catch(e){}const u=l(r(f),{method:i.method,body:"PATCH"===i.method?c:null}),w=await o(u);s="DELETE"===i.method?JSON.stringify({message:"Fraud protection was successfully deleted."}):JSON.stringify(p({paymentMethodSetFraudProtectionId:h.substring(h.indexOf("C")+1),fraudProtection:w,paymentPresetId:m,base:new URL(i.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const f=["_links"];function c(e){const{paymentPresetId:t,helper:a,base:r}=e,o="paymentGateway"in e?e.paymentGateway:e.hostedPaymentGateway,{_links:i}=o,l=s(o,f),d=new URL(i.self.href).pathname.split("/").pop();let m;m="paymentMethodSetHostedPaymentGatewayId"in e?`H${d}C${e.paymentMethodSetHostedPaymentGatewayId}`:`R${d}`;const p=new URL(`./payment_presets/${t}`,r),h=new URL(`./payment_presets/${t}/payment_methods/${m}`,r);return n(n({_links:{self:{href:h.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:p.toString()}}},l),{},{helper:a})}async function u(e){var t,s,n,r;let i,l;try{const{hostedPaymentGatewaysHelperUrl:d,paymentGatewaysHelperUrl:m,hostedPaymentGatewaysUrl:p,getPaymentMethodSetUrl:h,paymentGatewaysUrl:y,request:f,fetch:u}=e;if(!["GET","POST"].includes(f.method))throw i=405,new Error("Method not allowed. Allowed methods: GET, POST.");const w=new URL(f.url),_=a(/\/payment_presets\/(.+)\/payment_methods/,{presetId:1}).exec(w.pathname).groups.presetId,[g,P,S]=await Promise.all([o(u(d)),o(u(m)),o(u(h(_)))]);if("GET"===f.method){const e=parseInt(null!==(t=w.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=w.searchParams.get("limit"))&&void 0!==s?s:"20"),r=new URL(S._links["fx:payment_method_set_hosted_payment_gateways"].href);r.searchParams.set("offset",String(Math.max(0,e-1))),r.searchParams.set("limit",String(a));const d=null===(n=S._links["fx:payment_gateway"])||void 0===n?void 0:n.href,[m,p]=await Promise.all([d&&0===e?o(u(d)):null,o(u(r.toString()))]),h=await Promise.all(p._embedded["fx:payment_method_set_hosted_payment_gateways"].map((async e=>o(u(e._links["fx:hosted_payment_gateway"].href))))),y=function(e){var t,a;const{paymentMethodSetHostedPaymentGateways:s,hostedPaymentGatewaysHelper:n,hostedPaymentGateways:r,paymentGatewaysHelper:o,paymentPresetId:i,paymentGateway:l,query:d,base:m}=e,p=new URLSearchParams(d),h=parseInt(null!==(t=p.get("offset"))&&void 0!==t?t:"0"),y=parseInt(null!==(a=p.get("limit"))&&void 0!==a?a:"20"),f=s.total_items+(l?1:0),u=s.returned_items+(l&&"not-on-page"!==l?1:0),w=new URL(`/payment_presets/${i}/payment_methods`,m);w.search=d;const _=new URL(w.toString()),g=new URL(w.toString()),P=new URL(w.toString()),S=new URL(w.toString());_.searchParams.set("limit",String(y)),_.searchParams.set("offset",String(h)),g.searchParams.set("limit",String(y)),g.searchParams.set("offset",String(Math.max(0,f-y))),P.searchParams.set("limit",String(y)),P.searchParams.set("offset",String(Math.max(0,h-y))),S.searchParams.set("limit",String(y)),S.searchParams.set("offset",String(Math.min(h+y,Math.max(0,f-y))));const U=[...l&&"not-on-page"!==l?[l]:[],...r].map((e=>{const t=s._embedded["fx:payment_method_set_hosted_payment_gateways"].find((t=>t.hosted_payment_gateway_uri===e._links.self.href));return c(t?{paymentMethodSetHostedPaymentGatewayId:new URL(t._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:e,paymentPresetId:i,helper:n.values[e.type],base:m}:{paymentPresetId:i,paymentGateway:e,helper:o.values[e.type],base:m})}));return{_links:{first:{href:_.toString()},last:{href:g.toString()},prev:{href:P.toString()},next:{href:S.toString()},self:{href:w.toString()}},_embedded:{"fx:payment_methods":U},returned_items:u,total_items:f,offset:h,limit:y}}({paymentMethodSetHostedPaymentGateways:p,hostedPaymentGatewaysHelper:g,paymentGatewaysHelper:P,hostedPaymentGateways:h,paymentPresetId:_,paymentGateway:m||(d?"not-on-page":void 0),query:new URL(f.url).search,base:new URL(f.url).origin});i=200,l=JSON.stringify(y)}else{const e=await f.clone().json(),t=!!g.values[null!==(r=e.type)&&void 0!==r?r:""];if(delete e.helper,t){const t=await o(u(p,{method:"POST",body:JSON.stringify(e)})),a=await o(u(S._links["fx:payment_method_set_hosted_payment_gateways"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:S._links.self.href,hosted_payment_gateway_uri:t._links.self.href})})),s=c({paymentMethodSetHostedPaymentGatewayId:new URL(a._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:t,paymentPresetId:_,helper:g.values[t.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(s)}else{const t=u(y,{method:f.method,body:JSON.stringify(e)}),a=await o(t),s={gateway_uri:a._links.self.href};await Promise.all([o(u(S._links.self.href,{method:"PATCH",body:JSON.stringify(s)})),S.gateway_uri?o(u(S.gateway_uri,{method:"DELETE"})):null]);const n=c({paymentPresetId:_,paymentGateway:a,helper:P.values[a.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(n)}}}catch(e){l=e instanceof Error?e.message:String(e),i=null!=i?i:500}return new Response(l,{status:i})}const w=["_links"];function _(e){const{paymentMethodSet:t,base:a}=e,{_links:r}=t,o=s(t,w),i=new URL(t._links.self.href).pathname.split("/").pop(),l=new URL(`./payment_presets/${i}`,a),d=new URL(`./payment_presets/${i}/payment_methods`,a),m=new URL(`./payment_presets/${i}/fraud_protections`,a),p=new URL(`./payment_presets/${i}/available_payment_methods`,a),h=new URL(`./payment_presets/${i}/available_fraud_protections`,a);return n({_links:{self:{href:l.toString()},"fx:store":r["fx:store"],"fx:payment_methods":{href:d.toString()},"fx:fraud_protections":{href:m.toString()},"fx:available_payment_methods":{href:p.toString()},"fx:available_fraud_protections":{href:h.toString()}}},o)}const g=["_embedded","_links"];async function P(e){let t,a;try{const{paymentMethodSetsUrl:r,request:i,fetch:l}=e;if(!["GET","POST"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, POST.");const d=new URL(i.url),m=new URL(r);let p;if(m.search=d.search,"POST"===i.method){const e=l(m.toString(),{method:"POST",body:await i.text()});p=_({paymentMethodSet:await o(e),base:d.origin})}else p=function(e){const{paymentMethodSets:t,base:a}=e,{_embedded:r,_links:o}=t,i=s(t,g),l=new URL("./payment_presets",a),d=new URL(o.first.href);l.search=d.search;const m=new URL("./payment_presets",a),p=new URL(o.last.href);m.search=p.search;const h=new URL("./payment_presets",a),y=new URL(o.prev.href);h.search=y.search;const f=new URL("./payment_presets",a),c=new URL(o.next.href);f.search=c.search;const u=new URL("./payment_presets",a),w=new URL(o.self.href);return u.search=w.search,n(n({},i),{},{_links:{first:{href:l.toString()},last:{href:m.toString()},prev:{href:h.toString()},next:{href:f.toString()},self:{href:u.toString()}},_embedded:{"fx:payment_presets":r["fx:payment_method_sets"].map((e=>_({paymentMethodSet:e,base:a})))}})}({paymentMethodSets:await o(l(m.toString())),base:d.origin});a=JSON.stringify(p),t=200}catch(e){a=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(a,{status:t})}async function S(e){let t,s;try{const{getPaymentMethodSetUrl:n,request:r,fetch:i}=e;if(!["GET","PATCH","DELETE"].includes(r.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const l=a(/payment_presets\/(.+)/,{presetId:1}).exec(r.url).groups.presetId,d=new URL(r.url),m=new URL(n(l));m.search=d.search;const p=await o(i(m.toString(),{method:r.method,body:"PATCH"===r.method?await r.text():null}));s="DELETE"===r.method?JSON.stringify({message:"Payment preset was successfully deleted."}):JSON.stringify(_({paymentMethodSet:p,base:new URL(r.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}async function U(e){let t,s;try{const{hostedPaymentGatewaysHelperUrl:n,paymentGatewaysHelperUrl:r,getPaymentMethodSetHostedPaymentGatewayUrl:i,getHostedPaymentGatewayUrl:l,getPaymentMethodSetUrl:d,getPaymentGatewayUrl:m,request:p,fetch:h}=e;if(!["GET","PATCH","DELETE"].includes(p.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const y=a(/\/payment_presets\/(.+)\/payment_methods\/(.+)/,{presetId:1,methodId:2}),{presetId:f,methodId:u}=y.exec(p.url).groups,w=u.startsWith("H"),_=d(f),g=u.substring(1,w?u.indexOf("C"):void 0),P=o(h(n)),S=o(h(r));if("DELETE"===p.method)if(w){const e=i(u.substring(u.indexOf("C")+1));await o(h(e,{method:"DELETE"}))}else{const e={gateway_uri:""},t=JSON.stringify(e);await o(h(_,{method:"PATCH",body:t}))}let U=await p.text();try{const e=JSON.parse(U);delete e.helper,U=JSON.stringify(e)}catch(e){}if(w){const e=h(l(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await P,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentMethodSetHostedPaymentGatewayId:u.substring(u.indexOf("C")+1),hostedPaymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}else{const e=h(m(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await S,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}class b extends e{constructor(){super(...arguments),this.paymentMethodSetHostedPaymentGatewayBaseUrl=null,this.paymentMethodSetHostedPaymentGatewaysUrl=null,this.hostedPaymentGatewaysHelperUrl=null,this.hostedPaymentGatewayBaseUrl=null,this.hostedPaymentGatewaysUrl=null,this.paymentGatewaysHelperUrl=null,this.paymentMethodSetBaseUrl=null,this.paymentMethodSetsUrl=null,this.fraudProtectionBaseUrl=null,this.fraudProtectionsUrl=null,this.paymentGatewayBaseUrl=null,this.paymentGatewaysUrl=null,this.__api=new r(this),this.__fetch=this.__api.fetch.bind(this.__api),this.__handleFetch=e=>{var s,n,r,o,l;if(!(e instanceof t))return;if(!e.request.url.startsWith("https://foxy-payments-api.element/"))return;if(e.defaultPrevented)return;const{paymentMethodSetHostedPaymentGatewaysUrl:m,hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g}=this,b=null!==(s=this.paymentMethodSetHostedPaymentGatewayBaseUrl)&&void 0!==s?s:this.paymentMethodSetHostedPaymentGatewaysUrl,G=null!==(n=this.hostedPaymentGatewayBaseUrl)&&void 0!==n?n:this.hostedPaymentGatewaysUrl,L=null!==(r=this.paymentMethodSetBaseUrl)&&void 0!==r?r:this.paymentMethodSetsUrl,E=null!==(o=this.fraudProtectionBaseUrl)&&void 0!==o?o:this.fraudProtectionsUrl,R=null!==(l=this.paymentGatewayBaseUrl)&&void 0!==l?l:this.paymentGatewaysUrl;if(null===m)return;if(null===b)return;if(null===p)return;if(null===f)return;if(null===c)return;if(null===G)return;if(null===w)return;if(null===L)return;if(null===_)return;if(null===E)return;if(null===g)return;if(null===R)return;const v=e=>t=>{const a=new URL(e);return a.pathname.endsWith("/")||(a.pathname+="/"),a.pathname+=t,a.toString()},x=function(e){const t=[[a(/\/payment_presets\/(.+?)\/payment_methods\/(.+?)/,{presetId:1,methodId:2}),U],[a(/\/payment_presets\/(.+?)\/available_fraud_protections/,{presetId:1}),d],[a(/\/payment_presets\/(.+?)\/available_payment_methods/,{presetId:1}),i],[a(/\/payment_presets\/(.+?)\/fraud_protections\/(.+?)/,{presetId:1,protectionId:2}),y],[a(/\/payment_presets\/(.+?)\/fraud_protections/,{presetId:1}),h],[a(/\/payment_presets\/(.+?)\/payment_methods/,{presetId:1}),u],[a(/\/payment_presets\/(.+?)/,{presetId:1}),S],[/\/payment_presets/,P]];for(const[a,s]of t)if(a.test(new URL(e.request.url).pathname))return s(e);return null}({hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g,getPaymentMethodSetHostedPaymentGatewayUrl:v(m),getHostedPaymentGatewayUrl:v(G),getPaymentMethodSetUrl:v(L),getFraudProtectionUrl:v(E),getPaymentGatewayUrl:v(R),request:e.request,fetch:this.__fetch});x&&(e.preventDefault(),e.respondWith(x))}}static get properties(){return{paymentMethodSetHostedPaymentGatewayBaseUrl:{attribute:"payment-method-set-hosted-payment-gateway-base-url"},paymentMethodSetHostedPaymentGatewaysUrl:{attribute:"payment-method-set-hosted-payment-gateways-url"},hostedPaymentGatewaysHelperUrl:{attribute:"hosted-payment-gateways-helper-url"},hostedPaymentGatewayBaseUrl:{attribute:"hosted-payment-gateway-base-url"},hostedPaymentGatewaysUrl:{attribute:"hosted-payment-gateways-url"},paymentGatewaysHelperUrl:{attribute:"payment-gateways-helper-url"},paymentMethodSetBaseUrl:{attribute:"payment-method-set-base-url"},paymentMethodSetsUrl:{attribute:"payment-method-sets-url"},fraudProtectionBaseUrl:{attribute:"fraud-protection-base-url"},fraudProtectionsUrl:{attribute:"fraud-protections-url"},paymentGatewayBaseUrl:{attribute:"payment-gateway-base-url"},paymentGatewaysUrl:{attribute:"payment-gateways-url"}}}connectedCallback(){super.connectedCallback(),this.addEventListener("fetch",this.__handleFetch)}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("fetch",this.__handleFetch)}}customElements.define("foxy-payments-api",b);export{b as PaymentsApi};
|
|
1
|
+
import{L as e}from"./shared-dc73b9a5.js";import{F as t}from"./shared-343d1fd7.js";import{aM as a,aH as s,_ as n}from"./shared-d1195c27.js";import{A as r}from"./shared-c518ece2.js";async function o(e){const t=await e;if(!t.ok)throw new Error(await t.text());return t.json()}async function i(e){var t;let s,n;try{const{hostedPaymentGatewaysHelperUrl:r,paymentGatewaysHelperUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if("GET"!==d.method)throw s=405,new Error("Method not allowed. Allowed methods: GET.");const p=a(/\/payment_presets\/(.+)\/available_payment_methods/,{presetId:1}).exec(new URL(d.url).pathname).groups.presetId,h=o(m(r)),y=o(m(i)),f=await o(m(l(p))),c=(async()=>{const e=[];for(;;){const t=new URL(d.url).origin,a=new URL(`${t}/payment_presets/${p}/payment_methods`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(m(a.toString()));if(e.push(...s._embedded["fx:payment_methods"]),s._embedded["fx:payment_methods"].length<200)break}return e})(),u=null===(t=f._links["fx:payment_gateway"])||void 0===t?void 0:t.href,w=u?await o(m(u)):void 0,_=function(e){const{hostedPaymentGatewaysHelper:t,paymentGatewaysHelper:a,paymentPresetId:s,paymentMethods:n,paymentGateway:r,base:o}=e,i=new URL(`./payment_presets/${s}/available_payment_methods`,o),l={};return Object.entries(t.values).forEach((([e,t])=>{l[e]=t;const a=n.find((t=>t.type===e));a&&(l[e].conflict={type:a.type,name:a.description})})),Object.entries(a.values).forEach((([e,t])=>{l[e]=t,r&&(l[e].conflict={type:r.type,name:r.description})})),{_links:{self:{href:i.toString()}},values:l}}({hostedPaymentGatewaysHelper:await h,paymentGatewaysHelper:await y,paymentPresetId:p,paymentGateway:w,paymentMethods:await c,base:new URL(d.url).origin});n=JSON.stringify(_),s=200}catch(e){n=e instanceof Error?e.message:String(e),s=null!=s?s:500}return new Response(n,{status:s})}function l(e){const{paymentPresetId:t,fraudProtections:a,base:s}=e,n=new URL(`./payment_presets/${t}/available_fraud_protections`,s),r={minfraud:{name:"MaxMind minFraud",uses_rejection_threshold:!0,json:null},google_recaptcha:{name:"Google reCAPTCHA",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"config",name:"Configuration",type:"select",description:"Determines how reCAPTCHA is configured to operate.",default_value:"disabled",options:[{name:"Disabled",value:"disabled"},{name:"Always enabled",value:"enabled_always"},{name:"Enabled by errors",value:"enabled_by_errors"}]},{id:"private_key",name:"Private Key",type:"text",optional:!0,description:"If using a custom subdomain, enter your Private Key here.",default_value:""},{id:"site_key",name:"Site Key",type:"text",optional:!0,description:"If using a custom subdomain, enter your Site Key here.",default_value:""}]}]}},custom_precheckout_hook:{name:"Pre-Checkout Webhook",uses_rejection_threshold:!1,json:{blocks:[{id:"",parent_id:"",fields:[{id:"enabled",name:"Enabled",type:"checkbox",default_value:!1},{id:"url",name:"URL",type:"text",description:"Url of your Pre-Checkout Hook",default_value:""},{id:"failure_handling",name:"Failure handling",type:"select",description:"Determines what happens to the checkout submission if your webhook fails to respond correctly.",default_value:"",options:[{name:"Reject",value:"reject"},{name:"Approve",value:"approve"}]}]}]}}};for(const e in r){const t=null==a?void 0:a.find((t=>t.type===e));t&&(r[e].conflict={type:t.type,name:t.description})}return{_links:{self:{href:n.toString()}},values:r}}async function d(e){let t,s;try{const{request:n,fetch:r}=e;if("GET"!==n.method)throw t=405,new Error("Method not allowed. Allowed methods: GET.");const i=a(/\/payment_presets\/(.+)\/available_fraud_protections/,{presetId:1}).exec(new URL(n.url).pathname).groups.presetId,d=(async()=>{const e=[];for(;;){const t=new URL(n.url).origin,a=new URL(`${t}/payment_presets/${i}/fraud_protections`);a.searchParams.set("offset",e.length.toString()),a.searchParams.set("limit","200");const s=await o(r(a.toString()));if(e.push(...s._embedded["fx:fraud_protections"]),s._embedded["fx:fraud_protections"].length<200)break}return e})(),m=l({fraudProtections:await d,paymentPresetId:i,base:new URL(n.url).origin});s=JSON.stringify(m),t=200}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const m=["_links"];function p(e){const{paymentMethodSetFraudProtectionId:t,paymentPresetId:a,fraudProtection:r,base:o}=e,{_links:i}=r,d=s(r,m),p=l({paymentPresetId:a,base:o}),h=`${new URL(i.self.href).pathname.split("/").pop()}C${t}`,y=new URL(`./payment_presets/${a}`,o),f=new URL(`./payment_presets/${a}/fraud_protections/${h}`,o);return n(n({_links:{self:{href:f.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:y.toString()}}},d),{},{helper:p.values[r.type]})}async function h(e){var t,s;let n,r;try{const{fraudProtectionsUrl:i,getPaymentMethodSetUrl:l,request:d,fetch:m}=e;if(!["GET","POST"].includes(d.method))throw n=405,new Error("Method not allowed. Allowed methods: GET, POST.");const h=new URL(d.url),y=a(/\/payment_presets\/(.+)\/fraud_protections/,{presetId:1}).exec(h.pathname).groups.presetId,f=await o(m(l(y)));if("GET"===d.method){const e=parseInt(null!==(t=h.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=h.searchParams.get("limit"))&&void 0!==s?s:"20"),i=new URL(f._links["fx:payment_method_set_fraud_protections"].href);i.searchParams.set("offset",String(Math.max(0,e-1))),i.searchParams.set("limit",String(a));const l=await o(m(i.toString())),c=await Promise.all(l._embedded["fx:payment_method_set_fraud_protections"].map((async e=>o(m(e._links["fx:fraud_protection"].href))))),u=function(e){const{paymentMethodSetFraudProtections:t,fraudProtections:a,paymentPresetId:s,base:n}=e,r=new URL(`/payment_presets/${s}/fraud_protections`,n);r.search=new URL(t._links.self.href).search;const o=new URL(r.toString());o.search=new URL(t._links.first.href).search;const i=new URL(r.toString());i.search=new URL(t._links.last.href).search;const l=new URL(r.toString());l.search=new URL(t._links.prev.href).search;const d=new URL(r.toString());d.search=new URL(t._links.next.href).search;const m=a.map((e=>{const a=t._embedded["fx:payment_method_set_fraud_protections"].find((t=>t.fraud_protection_uri===e._links.self.href));return p({paymentMethodSetFraudProtectionId:new URL(a._links.self.href).pathname.split("/").pop(),fraudProtection:e,paymentPresetId:s,base:n})}));return{_links:{first:{href:o.toString()},last:{href:i.toString()},prev:{href:l.toString()},next:{href:d.toString()},self:{href:r.toString()}},_embedded:{"fx:fraud_protections":m},returned_items:t.returned_items,total_items:t.total_items,offset:t.offset,limit:t.limit}}({paymentMethodSetFraudProtections:l,fraudProtections:c,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(u)}else{const e=await d.json();delete e.helper;const t=m(i,{method:"POST",body:JSON.stringify(e)}),a=await o(t),s=await o(m(f._links["fx:payment_method_set_fraud_protections"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:f._links.self.href,fraud_protection_uri:a._links.self.href})})),l=p({paymentMethodSetFraudProtectionId:new URL(s._links.self.href).pathname.split("/").pop(),fraudProtection:a,paymentPresetId:y,base:new URL(d.url).origin});n=200,r=JSON.stringify(l)}}catch(e){r=e instanceof Error?e.message:String(e),n=null!=n?n:500}return new Response(r,{status:n})}async function y(e){let t,s;try{const{getPaymentMethodSetUrl:n,getFraudProtectionUrl:r,request:i,fetch:l}=e;if(!["GET","PATCH","DELETE"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const d=a(/\/payment_presets\/(.+)\/fraud_protections\/(.+)/,{presetId:1,protectionId:2}),{presetId:m,protectionId:h}=d.exec(i.url).groups,y=n(m),f=h.substring(0,h.indexOf("C"));if("DELETE"===i.method){const e=(await o(l(y)))._links["fx:payment_method_set_fraud_protections"].href,t=new URL(e);t.searchParams.set("fraud_protection_id",f);const a=await o(l(t.toString())),s=a._embedded["fx:payment_method_set_fraud_protections"].map((e=>o(l(e._links.self.href,{method:"DELETE"}))));await Promise.all(s)}let c=await i.text();try{const e=JSON.parse(c);delete e.helper,c=JSON.stringify(e)}catch(e){}const u=l(r(f),{method:i.method,body:"PATCH"===i.method?c:null}),w=await o(u);s="DELETE"===i.method?JSON.stringify({message:"Fraud protection was successfully deleted."}):JSON.stringify(p({paymentMethodSetFraudProtectionId:h.substring(h.indexOf("C")+1),fraudProtection:w,paymentPresetId:m,base:new URL(i.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}const f=["_links"];function c(e){const{paymentPresetId:t,helper:a,base:r}=e,o="paymentGateway"in e?e.paymentGateway:e.hostedPaymentGateway,{_links:i}=o,l=s(o,f),d=new URL(i.self.href).pathname.split("/").pop();let m;m="paymentMethodSetHostedPaymentGatewayId"in e?`H${d}C${e.paymentMethodSetHostedPaymentGatewayId}`:`R${d}`;const p=new URL(`./payment_presets/${t}`,r),h=new URL(`./payment_presets/${t}/payment_methods/${m}`,r);return n(n({_links:{self:{href:h.toString()},"fx:store":i["fx:store"],"fx:payment_preset":{href:p.toString()}}},l),{},{helper:a})}async function u(e){var t,s,n,r;let i,l;try{const{hostedPaymentGatewaysHelperUrl:d,paymentGatewaysHelperUrl:m,hostedPaymentGatewaysUrl:p,getPaymentMethodSetUrl:h,paymentGatewaysUrl:y,request:f,fetch:u}=e;if(!["GET","POST"].includes(f.method))throw i=405,new Error("Method not allowed. Allowed methods: GET, POST.");const w=new URL(f.url),_=a(/\/payment_presets\/(.+)\/payment_methods/,{presetId:1}).exec(w.pathname).groups.presetId,[g,P,S]=await Promise.all([o(u(d)),o(u(m)),o(u(h(_)))]);if("GET"===f.method){const e=parseInt(null!==(t=w.searchParams.get("offset"))&&void 0!==t?t:"0"),a=parseInt(null!==(s=w.searchParams.get("limit"))&&void 0!==s?s:"20"),r=new URL(S._links["fx:payment_method_set_hosted_payment_gateways"].href);r.searchParams.set("offset",String(Math.max(0,e-1))),r.searchParams.set("limit",String(a));const d=null===(n=S._links["fx:payment_gateway"])||void 0===n?void 0:n.href,[m,p]=await Promise.all([d&&0===e?o(u(d)):null,o(u(r.toString()))]),h=await Promise.all(p._embedded["fx:payment_method_set_hosted_payment_gateways"].map((async e=>o(u(e._links["fx:hosted_payment_gateway"].href))))),y=function(e){var t,a;const{paymentMethodSetHostedPaymentGateways:s,hostedPaymentGatewaysHelper:n,hostedPaymentGateways:r,paymentGatewaysHelper:o,paymentPresetId:i,paymentGateway:l,query:d,base:m}=e,p=new URLSearchParams(d),h=parseInt(null!==(t=p.get("offset"))&&void 0!==t?t:"0"),y=parseInt(null!==(a=p.get("limit"))&&void 0!==a?a:"20"),f=s.total_items+(l?1:0),u=s.returned_items+(l&&"not-on-page"!==l?1:0),w=new URL(`/payment_presets/${i}/payment_methods`,m);w.search=d;const _=new URL(w.toString()),g=new URL(w.toString()),P=new URL(w.toString()),S=new URL(w.toString());_.searchParams.set("limit",String(y)),_.searchParams.set("offset",String(h)),g.searchParams.set("limit",String(y)),g.searchParams.set("offset",String(Math.max(0,f-y))),P.searchParams.set("limit",String(y)),P.searchParams.set("offset",String(Math.max(0,h-y))),S.searchParams.set("limit",String(y)),S.searchParams.set("offset",String(Math.min(h+y,Math.max(0,f-y))));const U=[...l&&"not-on-page"!==l?[l]:[],...r].map((e=>{const t=s._embedded["fx:payment_method_set_hosted_payment_gateways"].find((t=>t.hosted_payment_gateway_uri===e._links.self.href));return c(t?{paymentMethodSetHostedPaymentGatewayId:new URL(t._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:e,paymentPresetId:i,helper:n.values[e.type],base:m}:{paymentPresetId:i,paymentGateway:e,helper:o.values[e.type],base:m})}));return{_links:{first:{href:_.toString()},last:{href:g.toString()},prev:{href:P.toString()},next:{href:S.toString()},self:{href:w.toString()}},_embedded:{"fx:payment_methods":U},returned_items:u,total_items:f,offset:h,limit:y}}({paymentMethodSetHostedPaymentGateways:p,hostedPaymentGatewaysHelper:g,paymentGatewaysHelper:P,hostedPaymentGateways:h,paymentPresetId:_,paymentGateway:m||(d?"not-on-page":void 0),query:new URL(f.url).search,base:new URL(f.url).origin});i=200,l=JSON.stringify(y)}else{const e=await f.clone().json(),t=!!g.values[null!==(r=e.type)&&void 0!==r?r:""];if(delete e.helper,t){const t=await o(u(p,{method:"POST",body:JSON.stringify(e)})),a=await o(u(S._links["fx:payment_method_set_hosted_payment_gateways"].href,{method:"POST",body:JSON.stringify({payment_method_set_uri:S._links.self.href,hosted_payment_gateway_uri:t._links.self.href})})),s=c({paymentMethodSetHostedPaymentGatewayId:new URL(a._links.self.href).pathname.split("/").pop(),hostedPaymentGateway:t,paymentPresetId:_,helper:g.values[t.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(s)}else{const t=u(y,{method:f.method,body:JSON.stringify(e)}),a=await o(t),s={gateway_uri:a._links.self.href};await Promise.all([o(u(S._links.self.href,{method:"PATCH",body:JSON.stringify(s)})),S.gateway_uri?o(u(S.gateway_uri,{method:"DELETE"})):null]);const n=c({paymentPresetId:_,paymentGateway:a,helper:P.values[a.type],base:new URL(f.url).origin});i=200,l=JSON.stringify(n)}}}catch(e){l=e instanceof Error?e.message:String(e),i=null!=i?i:500}return new Response(l,{status:i})}const w=["_links"];function _(e){const{paymentMethodSet:t,base:a}=e,{_links:r}=t,o=s(t,w),i=new URL(t._links.self.href).pathname.split("/").pop(),l=new URL(`./payment_presets/${i}`,a),d=new URL(`./payment_presets/${i}/payment_methods`,a),m=new URL(`./payment_presets/${i}/fraud_protections`,a),p=new URL(`./payment_presets/${i}/available_payment_methods`,a),h=new URL(`./payment_presets/${i}/available_fraud_protections`,a);return n({_links:{self:{href:l.toString()},"fx:store":r["fx:store"],"fx:payment_methods":{href:d.toString()},"fx:fraud_protections":{href:m.toString()},"fx:available_payment_methods":{href:p.toString()},"fx:available_fraud_protections":{href:h.toString()}}},o)}const g=["_embedded","_links"];async function P(e){let t,a;try{const{paymentMethodSetsUrl:r,request:i,fetch:l}=e;if(!["GET","POST"].includes(i.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, POST.");const d=new URL(i.url),m=new URL(r);let p;if(m.search=d.search,"POST"===i.method){const e=l(m.toString(),{method:"POST",body:await i.text()});p=_({paymentMethodSet:await o(e),base:d.origin})}else p=function(e){const{paymentMethodSets:t,base:a}=e,{_embedded:r,_links:o}=t,i=s(t,g),l=new URL("./payment_presets",a),d=new URL(o.first.href);l.search=d.search;const m=new URL("./payment_presets",a),p=new URL(o.last.href);m.search=p.search;const h=new URL("./payment_presets",a),y=new URL(o.prev.href);h.search=y.search;const f=new URL("./payment_presets",a),c=new URL(o.next.href);f.search=c.search;const u=new URL("./payment_presets",a),w=new URL(o.self.href);return u.search=w.search,n(n({},i),{},{_links:{first:{href:l.toString()},last:{href:m.toString()},prev:{href:h.toString()},next:{href:f.toString()},self:{href:u.toString()}},_embedded:{"fx:payment_presets":r["fx:payment_method_sets"].map((e=>_({paymentMethodSet:e,base:a})))}})}({paymentMethodSets:await o(l(m.toString())),base:d.origin});a=JSON.stringify(p),t=200}catch(e){a=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(a,{status:t})}async function S(e){let t,s;try{const{getPaymentMethodSetUrl:n,request:r,fetch:i}=e;if(!["GET","PATCH","DELETE"].includes(r.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const l=a(/payment_presets\/(.+)/,{presetId:1}).exec(r.url).groups.presetId,d=new URL(r.url),m=new URL(n(l));m.search=d.search;const p=await o(i(m.toString(),{method:r.method,body:"PATCH"===r.method?await r.text():null}));s="DELETE"===r.method?JSON.stringify({message:"Payment preset was successfully deleted."}):JSON.stringify(_({paymentMethodSet:p,base:new URL(r.url).origin}))}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}async function U(e){let t,s;try{const{hostedPaymentGatewaysHelperUrl:n,paymentGatewaysHelperUrl:r,getPaymentMethodSetHostedPaymentGatewayUrl:i,getHostedPaymentGatewayUrl:l,getPaymentMethodSetUrl:d,getPaymentGatewayUrl:m,request:p,fetch:h}=e;if(!["GET","PATCH","DELETE"].includes(p.method))throw t=405,new Error("Method not allowed. Allowed methods: GET, PATCH, DELETE.");const y=a(/\/payment_presets\/(.+)\/payment_methods\/(.+)/,{presetId:1,methodId:2}),{presetId:f,methodId:u}=y.exec(p.url).groups,w=u.startsWith("H"),_=d(f),g=u.substring(1,w?u.indexOf("C"):void 0),P=o(h(n)),S=o(h(r));if("DELETE"===p.method)if(w){const e=i(u.substring(u.indexOf("C")+1));await o(h(e,{method:"DELETE"}))}else{const e={gateway_uri:""},t=JSON.stringify(e);await o(h(_,{method:"PATCH",body:t}))}let U=await p.text();try{const e=JSON.parse(U);delete e.helper,U=JSON.stringify(e)}catch(e){}if(w){const e=h(l(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await P,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentMethodSetHostedPaymentGatewayId:u.substring(u.indexOf("C")+1),hostedPaymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}else{const e=h(m(g),{method:p.method,body:"PATCH"===p.method?U:null}),t=await S,a=await o(e);s="DELETE"===p.method?JSON.stringify({message:"Payment method was successfully deleted."}):JSON.stringify(c({paymentGateway:a,paymentPresetId:f,helper:t.values[a.type],base:new URL(p.url).origin}))}}catch(e){s=e instanceof Error?e.message:String(e),t=null!=t?t:500}return new Response(s,{status:t})}class b extends e{constructor(){super(...arguments),this.paymentMethodSetHostedPaymentGatewayBaseUrl=null,this.paymentMethodSetHostedPaymentGatewaysUrl=null,this.hostedPaymentGatewaysHelperUrl=null,this.hostedPaymentGatewayBaseUrl=null,this.hostedPaymentGatewaysUrl=null,this.paymentGatewaysHelperUrl=null,this.paymentMethodSetBaseUrl=null,this.paymentMethodSetsUrl=null,this.fraudProtectionBaseUrl=null,this.fraudProtectionsUrl=null,this.paymentGatewayBaseUrl=null,this.paymentGatewaysUrl=null,this.__api=new r(this),this.__fetch=this.__api.fetch.bind(this.__api),this.__handleFetch=e=>{var s,n,r,o,l;if(!(e instanceof t))return;if(!e.request.url.startsWith("https://foxy-payments-api.element/"))return;if(e.defaultPrevented)return;const{paymentMethodSetHostedPaymentGatewaysUrl:m,hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g}=this,b=null!==(s=this.paymentMethodSetHostedPaymentGatewayBaseUrl)&&void 0!==s?s:this.paymentMethodSetHostedPaymentGatewaysUrl,G=null!==(n=this.hostedPaymentGatewayBaseUrl)&&void 0!==n?n:this.hostedPaymentGatewaysUrl,L=null!==(r=this.paymentMethodSetBaseUrl)&&void 0!==r?r:this.paymentMethodSetsUrl,E=null!==(o=this.fraudProtectionBaseUrl)&&void 0!==o?o:this.fraudProtectionsUrl,R=null!==(l=this.paymentGatewayBaseUrl)&&void 0!==l?l:this.paymentGatewaysUrl;if(null===m)return;if(null===b)return;if(null===p)return;if(null===f)return;if(null===c)return;if(null===G)return;if(null===w)return;if(null===L)return;if(null===_)return;if(null===E)return;if(null===g)return;if(null===R)return;const v=e=>t=>{const a=new URL(e);return a.pathname.endsWith("/")||(a.pathname+="/"),a.pathname+=t,a.toString()},x=function(e){const t=[[a(/\/payment_presets\/(.+?)\/payment_methods\/(.+?)/,{presetId:1,methodId:2}),U],[a(/\/payment_presets\/(.+?)\/available_fraud_protections/,{presetId:1}),d],[a(/\/payment_presets\/(.+?)\/available_payment_methods/,{presetId:1}),i],[a(/\/payment_presets\/(.+?)\/fraud_protections\/(.+?)/,{presetId:1,protectionId:2}),y],[a(/\/payment_presets\/(.+?)\/fraud_protections/,{presetId:1}),h],[a(/\/payment_presets\/(.+?)\/payment_methods/,{presetId:1}),u],[a(/\/payment_presets\/(.+?)/,{presetId:1}),S],[/\/payment_presets/,P]];for(const[a,s]of t)if(a.test(new URL(e.request.url).pathname))return s(e);return null}({hostedPaymentGatewaysHelperUrl:p,paymentGatewaysHelperUrl:f,hostedPaymentGatewaysUrl:c,paymentMethodSetsUrl:w,fraudProtectionsUrl:_,paymentGatewaysUrl:g,getPaymentMethodSetHostedPaymentGatewayUrl:v(m),getHostedPaymentGatewayUrl:v(G),getPaymentMethodSetUrl:v(L),getFraudProtectionUrl:v(E),getPaymentGatewayUrl:v(R),request:e.request,fetch:this.__fetch});x&&(e.preventDefault(),e.respondWith(x))}}static get properties(){return{paymentMethodSetHostedPaymentGatewayBaseUrl:{attribute:"payment-method-set-hosted-payment-gateway-base-url"},paymentMethodSetHostedPaymentGatewaysUrl:{attribute:"payment-method-set-hosted-payment-gateways-url"},hostedPaymentGatewaysHelperUrl:{attribute:"hosted-payment-gateways-helper-url"},hostedPaymentGatewayBaseUrl:{attribute:"hosted-payment-gateway-base-url"},hostedPaymentGatewaysUrl:{attribute:"hosted-payment-gateways-url"},paymentGatewaysHelperUrl:{attribute:"payment-gateways-helper-url"},paymentMethodSetBaseUrl:{attribute:"payment-method-set-base-url"},paymentMethodSetsUrl:{attribute:"payment-method-sets-url"},fraudProtectionBaseUrl:{attribute:"fraud-protection-base-url"},fraudProtectionsUrl:{attribute:"fraud-protections-url"},paymentGatewayBaseUrl:{attribute:"payment-gateway-base-url"},paymentGatewaysUrl:{attribute:"payment-gateways-url"}}}connectedCallback(){super.connectedCallback(),this.addEventListener("fetch",this.__handleFetch)}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("fetch",this.__handleFetch)}}customElements.define("foxy-payments-api",b);export{b as PaymentsApi};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./shared-
|
|
1
|
+
import"./shared-4903b2e3.js";import"./shared-5513e830.js";import{_ as e}from"./shared-d1195c27.js";import{s as l,h as t,c as a,L as s}from"./shared-dc73b9a5.js";import{T as n,O as r}from"./shared-8874ec69.js";import{o}from"./shared-8438d4ca.js";import{c as i}from"./shared-4e709717.js";import{i as d}from"./shared-9803aa7c.js";import{a as u}from"./shared-79d0699c.js";import{r as c}from"./shared-a0c6a159.js";import{R as v,T as p,a as b}from"./shared-b726120d.js";import{I as h}from"./shared-17a61265.js";import{C as f}from"./shared-d1cb97c6.js";import"./shared-adcfd50a.js";let g;const m=l(g||(g=(e=>e)`
|
|
2
2
|
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
3
|
<path d="M26.4 14.7399C26.4 15.2922 25.9523 15.7399 25.4 15.7399H10.6C10.0477 15.7399 9.60001 15.2922 9.60001 14.7399V14.2C9.60001 13.6477 10.0477 13.2 10.6 13.2H25.4C25.9523 13.2 26.4 13.6477 26.4 14.2V14.7399ZM26.4 21.8C26.4 22.3523 25.9523 22.8 25.4 22.8H10.6C10.0477 22.8 9.60001 22.3523 9.60001 21.8V21.2601C9.60001 20.7078 10.0477 20.2601 10.6 20.2601H25.4C25.9523 20.2601 26.4 20.7078 26.4 21.2601V21.8Z" class="fill-current"/>
|
|
4
4
|
</svg>
|
|
@@ -61,4 +61,4 @@ import"./shared-56bf05ef.js";import"./shared-90a47948.js";import{_ as e}from"./s
|
|
|
61
61
|
<svg class="w-full h-full" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
62
62
|
<path d="M11 11V14H16.5V26H19.5V14H25V11H11Z" class="fill-current"/>
|
|
63
63
|
</svg>
|
|
64
|
-
`));let R,U,G,W,F,J=e=>e;function K(e){var l,a,s;const n=null===(a=null===(l=e.list)||void 0===l?void 0:l.every((l=>l.value!==e.value)))||void 0===a||a;return t(R||(R=J` <label class="${0}"> <div class="relative flex-1 min-w-0 overflow-hidden"> <select class="${0}" ?disabled="${0}" @change="${0}"> ${0} ${0} </select> </div> ${0} </label> `),i({"flex items-center transition-colors group text-tertiary":!0,"cursor-pointer hover-bg-contrast-5":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),i({"bg-transparent relative appearance-none flex h-m px-s":!0,"font-medium w-full max-w-full whitespace-nowrap focus-outline-none":!0,"text-tertiary":n&&!e.disabled,"text-body":!n&&!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":!n&&e.readonly,"cursor-pointer":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),e.disabled||e.readonly,(l=>{const t=l.currentTarget,a=t.options[t.options.selectedIndex].value;e.onChange(a)}),n?t(U||(U=J` <option value="" disabled="disabled" ?selected="${0}">${0}</option> `),n,e.t(e.label)):"",null===(s=e.list)||void 0===s?void 0:s.map((({label:l,value:a})=>t(G||(G=J` <option value="${0}" ?selected="${0}"> ${0} </option> `),a,a===e.value,e.t(l)))),n?"":t(W||(W=J` <span class="${0}"> ${0} </span> ${0} `),i({"font-tnum text-xs font-medium border mr-s px-xs rounded-s border-current inline-block":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.clearable&&!e.readonly?t(F||(F=J` <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="icon-inline text-l" icon="icons:remove-circle-outline"> </iron-icon> </button> `),e.t("delete"),i({"w-s h-s mr-xs flex items-center justify-center transition-colors rounded-full":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"hover-bg-contrast-5 hover-text-error text-body":!e.disabled,"text-disabled":e.disabled}),e.disabled,(()=>e.onChange(""))):""))}let P,Q,X,Y,ee,le=e=>e;function te(e){var l;const a=`${null!==(l=e.id)&&void 0!==l?l:String(Math.floor(Math.random()*Math.pow(10,8)))}-list`,s=!!e.displayValue;let n=e.value;if("date"===e.type){const l=new Date(e.value);n=isNaN(l.getTime())?"":u(l)}return t(P||(P=le` <label class="relative flex items-center cursor-text group text-tertiary"> <div class="relative flex-1 min-w-0 overflow-hidden"> ${0} <input placeholder="${0}" class="${0}" list="${0}" type="${0}" max="${0}" .value="${0}" ?disabled="${0}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} ${0} </label> `),s?t(Q||(Q=le` <div aria-hidden="true" class="${0}"> <div class="truncate">${0}</div> </div> `),i({"absolute inset-0 h-m px-s font-medium flex items-center":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.displayValue)):"",n||"date"===e.type?"":e.t(e.label),i({"bg-base relative flex h-m px-s font-medium w-full":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly,"flex max-w-full whitespace-nowrap":!0,"focus-outline-none":!0,"opacity-0 focus-opacity-100":s}),d(e.list?a:void 0),"date"===e.type?"datetime-local":e.type,d("date"===e.type?"9999-12-31T23:59":""),n,e.disabled||e.readonly,(l=>{const t=l.currentTarget;let a=t.value;try{if("date"===e.type){const e=new Date(t.value);isNaN(e.getTime())||(a=e.toISOString())}}catch(e){}e.onChange(a)}),i({"font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s":!0,"inline-block":!!n||"date"===e.type,"sr-only":!n&&"date"!==e.type,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.list?t(X||(X=le` <datalist id="${0}"> ${0} </datalist> `),a,e.list.map((({label:l,value:a})=>t(Y||(Y=le`<option value="${0}">${0}</option>`),a,e.t(l))))):"",e.disabled||e.readonly?"":t(ee||(ee=le` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}let ae,se,ne=e=>e;let re,oe=e=>e;function ie({parsedValue:l,disabled:t,readonly:a,options:s,option:n,t:r,onChange:o}){return te({displayValue:null==n?void 0:n.label,disabled:t,readonly:a,value:l.path,label:"field",list:s.map((l=>e(e({},l),{},{value:l.path}))),type:"text",id:"path",t:r,onChange:e=>o({operator:null,value:"",path:e})})}let de,ue=e=>e;let ce,ve,pe=e=>e;function be(l){var a,s;const{parsedValue:d,isFullSize:u,isNested:v,readonly:p,disabled:b,options:f,t:h,onConvert:g,onDelete:C,onChange:x}=l,V=null!==(a=f.find((e=>e.path===d.path)))&&void 0!==a?a:null,H=null!==(s=null==V?void 0:V.type)&&void 0!==s?s:n.Any,M=d.operator,O={parsedValue:d,operators:l.operators,disabled:b,readonly:p,options:f,option:V,t:h,onChange:x},N={[n.Attribute]:B,[n.Boolean]:_,[n.Number]:z,[n.String]:q,[n.Date]:S,[n.Any]:I};return t(ce||(ce=pe` <div class="flex items-center space-x-s" aria-label="${0}"> <div class="${0}"> <div class="bg-contrast-10"> <div class="grid gap-1px grid-vertical sm-grid-horizontal"> <div class="bg-base" title="${0}"> <div class="${0}" aria-hidden="true"> ${0} </div> </div> <div class="bg-base"> ${0} </div> <div class="bg-base">${0}</div> <div class="bg-base"> ${0} </div> </div> </div> </div> <div class="${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:remove-circle-outline"> </iron-icon> </button> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:add-circle-outline"> </iron-icon> </button> </div> </div> `),h("query_builder_rule"),i({"flex-1 bg-base rounded overflow-hidden border":!0,"border-contrast-10":!v&&!p,"border-contrast-50":!!v||p,"border-dashed":p,"border-solid":!p}),h(`type_${H}`),i({"w-m h-m":!0,"text-tertiary":!p&&!b,"text-disabled":p||b}),V?N[H]:I,d.path&&(H===n.Attribute||d.name)?t(ve||(ve=pe` <div class="bg-contrast-10 grid gap-1px grid-cols-1 sm-grid-cols-2"> <div class="bg-base">${0}</div> <div class="bg-base">${0}</div> </div> `),ie(O),function(l){var t;return te({disabled:l.disabled,readonly:l.readonly,value:null!==(t=l.parsedValue.name)&&void 0!==t?t:"",label:"name",type:"text",t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{name:t}))})}(O)):ie(O),function(l){const a=l.parsedValue.operator,s={[r.GreaterThan]:y,[r.GreaterThanOrEqual]:o,[r.In]:w,[r.IsDefined]:$,[r.LessThan]:L,[r.LessThanOrEqual]:Z,[r.Not]:j},d={[n.Attribute]:[r.In,r.Not,r.IsDefined],[n.Boolean]:[],[n.String]:[r.In,r.Not],[n.Number]:[r.In,r.Not,r.GreaterThan,r.LessThan,r.GreaterThanOrEqual,r.LessThanOrEqual],[n.Date]:[r.In,r.Not],[n.Any]:Object.values(r)},u=(l.option?d[l.option.type]:l.parsedValue.name?Object.values(r):Object.values(r).filter((e=>e!==r.IsDefined))).filter((e=>l.operators.includes(e))),c=l.disabled||l.readonly||0===u.length||!l.parsedValue.path;return t(re||(re=oe` <button title="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div aria-hidden="true">${0}</div> </button> `),l.t(`operator_${null!=a?a:"equal"}`),i({"flex items-center justify-center w-m h-m transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50":!0,"text-body hover-bg-contrast-5":!c&&u.length>1,"cursor-default text-tertiary":!c&&u.length<=1,"text-disabled cursor-default":c}),c||u.length<=1,(()=>{var t;const s=a?u.indexOf(a):-1,n=null!==(t=u[s+1])&&void 0!==t?t:null;l.onChange(e(e({},l.parsedValue),{},{operator:n,value:l.parsedValue.value}))}),a?s[a]:m)}(O),M===r.In?function(l){var a,s,r,o;const i=(null===(a=l.option)||void 0===a?void 0:a.list)?K:te,d=l.parsedValue.value.split(","),u=null!==(r=null===(s=l.option)||void 0===s?void 0:s.type)&&void 0!==r?r:n.Any,v=u===n.Number?"number":u===n.Date?"date":"text",p=null===(o=l.option)||void 0===o?void 0:o.list,b=[...d.filter((e=>!!e))];return l.readonly||b.push(null),t(ae||(ae=ne` <div class="bg-contrast-10 grid grid-cols-1 gap-1px"> ${0} </div> `),c(b,((e,l)=>l),((a,s)=>{var n;return t(se||(se=ne` <div class="bg-base"> ${0} </div> `),i({type:v,list:p,t:l.t,value:null!=a?a:"",label:a?String(s+1):"add_value",disabled:l.disabled,readonly:l.readonly,clearable:!0,displayValue:null===(n=null==p?void 0:p.find((e=>e.value===a)))||void 0===n?void 0:n.label,onChange:t=>{t?d[s]=t:d.splice(s,1),l.onChange(e(e({},l.parsedValue),{},{value:d.join(",")}))}}))})))}(O):M===r.IsDefined?function(l){return K({readonly:l.readonly,disabled:l.disabled,value:l.parsedValue.value,label:"value",list:[{label:"is_defined_true",value:"true"},{label:"is_defined_false",value:"false"}],t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{value:t}))})}(O):H===n.Boolean?function(l){var t,a,s,n,r,o;const{parsedValue:i,option:d,readonly:u,disabled:c,t:v,onChange:p}=l,b=null!==(s=null===(a=null===(t=null==d?void 0:d.list)||void 0===t?void 0:t.find((e=>"false"===e.value)))||void 0===a?void 0:a.label)&&void 0!==s?s:"false",f=[{label:null!==(o=null===(r=null===(n=null==d?void 0:d.list)||void 0===n?void 0:n.find((e=>"true"===e.value)))||void 0===r?void 0:r.label)&&void 0!==o?o:"true",value:"true"},{label:b,value:"false"}];return K({disabled:c,readonly:u,value:i.value,label:"value",list:f,t:v,onChange:l=>p(e(e({},i),{},{value:l}))})}(O):null===M&&[n.Number,n.Date].includes(H)?function(l){var a,s,r;const{t:o,parsedValue:i,option:d,readonly:u,disabled:c,onChange:v}=l,p=i.value.split(".."),b=p.length>=1?p[0]:"",f=p.length>=2?p[1]:"",h=(null==d?void 0:d.list)?K:te,g=null!==(a=null==d?void 0:d.type)&&void 0!==a?a:n.Any,m=g===n.Number?"number":g===n.Date?"date":"text",C=null==d?void 0:d.list;return t(de||(de=ue` <div class="grid bg-contrast-10 gap-1px grid-cols-1 grid-rows-2 sm-grid-cols-2 sm-grid-rows-1"> <div class="bg-base"> ${0} </div> <div class="bg-base"> ${0} </div> </div> `),h({displayValue:null===(s=null==C?void 0:C.find((e=>e.value===b)))||void 0===s?void 0:s.label,readonly:u,disabled:c,value:b,label:"range_from",type:m,list:C,t:o,onChange:l=>v(e(e({},i),{},{value:`${l}..${f}`}))}),h({displayValue:null===(r=null==C?void 0:C.find((e=>e.value===f)))||void 0===r?void 0:r.label,readonly:u,disabled:c,label:"range_to",value:f,type:m,list:C,t:o,onChange:l=>v(e(e({},i),{},{value:`${b}..${l}`}))}))}(O):function(l){var t,a,s,r;const{t:o,option:i,parsedValue:d,readonly:u,disabled:c,onChange:v}=l,p=(null==i?void 0:i.list)?K:te,b=null!==(t=null==i?void 0:i.type)&&void 0!==t?t:n.Any;return p({displayValue:null===(s=null===(a=null==i?void 0:i.list)||void 0===a?void 0:a.find((e=>e.value===d.value)))||void 0===s?void 0:s.label,readonly:u,disabled:c||!d.path,value:null!==(r=d.value)&&void 0!==r?r:"",label:"value",type:b===n.Number?"number":b===n.Date?"date":"text",list:null==i?void 0:i.list,t:o,onChange:l=>v(e(e({},d),{},{value:l}))})}(O),i({"-mr-s self-start flex-col sm-flex-row flex-shrink-0 items-center":!0,"border-t border-b border-transparent divide-y divide-transparent":!0,hidden:!!u||p,flex:!u}),h("delete"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0":!d.path}),b||p||!d.path,C,h("add_or_clause"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-success hover-bg-contrast-5":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0":!d.path||!!v||l.disableOr}),b||p||!d.path,g)}let fe,he,ge,me,Ce=e=>e;function ye(l){const a=l.parsedValues.some((e=>Array.isArray(e))),s=t(fe||(fe=Ce`<div class="${0}"></div>`),a?"h-xs":"mt-s"),n=t(he||(he=Ce` <div class="flex items-center h-s"> <div class="w-m text-center leading-none uppercase font-medium text-xs text-contrast-30"> ${0} </div> <div class="flex-1 border-t border-contrast-20"></div> <div class="w-m ml-s flex-shrink-0"></div> <div class="hidden sm-block w-m flex-shrink-0"></div> </div> `),l.t("or"));return t(ge||(ge=Ce` <div aria-label="${0}"> ${0} </div> `),l.t("query_builder_group"),c([...l.parsedValues,null],((e,l)=>String(l)),((a,r)=>{const o=r>0?l.isNested?n:s:"";return null===a?[o,be({operators:l.operators,disableOr:l.disableOr,isFullSize:!l.isNested&&0===l.parsedValues.length,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,parsedValue:{path:"",operator:null,value:""},t:l.t,onChange:e=>l.onChange([...l.parsedValues,e])})]:Array.isArray(a)?[o,t(me||(me=Ce` <div class="bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s"> ${0} </div> `),ye({parsedValues:a,disableOr:l.disableOr,operators:l.operators,isNested:!0,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues],a=e;t[r]=e.length>1?a:a[0],l.onChange(t)}}))]:[o,be({parsedValue:a,disableOr:l.disableOr,operators:l.operators,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues];t[r]=e,l.onChange(t)},onDelete:()=>{const e=l.parsedValues.filter(((e,l)=>l!==r));l.onChange(e)},onConvert:()=>{const t=[...l.parsedValues];t[r]=[a,e(e({},a),{},{operator:null,value:""})],l.onChange(t)}})]})))}function xe(e){var l;const[t,a]=e.split("=").map(decodeURIComponent),s=null!==(l=Object.values(r).find((e=>t.endsWith(`:${e}`))))&&void 0!==l?l:null;let n,o=t.substring(0,s?t.lastIndexOf(":"):void 0);const i=t.lastIndexOf("[");return o.endsWith("]")&&-1!==i&&(n=o.substring(i+1,o.length-1),o=o.substring(0,i),o.endsWith(":name")&&(o=o.substring(0,o.length-5))),{name:n,path:o,value:a,operator:s}}function we(e){let l=e.path;return e.name&&(l+=`:name[${e.name}]`),e.operator&&(l+=`:${e.operator}`),l=`${encodeURIComponent(l)}=${encodeURIComponent(e.value)}`,"="===l?"":l}function Ve(e){const l=e.reduce(((e,l)=>{if(Array.isArray(l)){const t=[l[0].value,l.slice(1).map((e=>we(e)))].join("|");e.push(`${l[0].path}=${encodeURIComponent(t)}`)}else"zoom"!==l.path&&e.push(we(l));return e}),[]),t=$e(e).join(",");return t&&l.push(`zoom=${encodeURIComponent(t)}`),l.join("&")}function $e(e){return e.map((e=>{if(Array.isArray(e))return $e(e);if(e.name)return[e.path];const l=e.path.split(":");return l.slice(0,l.length-1)})).flat().sort(((e,l)=>l.length-e.length)).filter(((e,l,t)=>t.every(((t,a)=>(a>=l||t!==e)&&!t.startsWith(`${e}:`)))))}let He;const Le=a(He||(He=(e=>e)`.gap-1px{gap:1px}.grid-vertical{grid-template:auto/var(--lumo-size-m) 1fr}:host([sm]) .sm-grid-horizontal{grid-template:auto/var(--lumo-size-m) 1fr var(--lumo-size-m) 1fr}`)),Me=h(v(p(b(f(s),"query-builder"))));class Ze extends Me{constructor(){super(...arguments),this.operators=Object.values(r),this.disableOr=!1,this.options=null,this.value=null}static get properties(){return e(e({},super.properties),{},{disableOr:{type:Boolean,attribute:"disable-or"},operators:{type:Array},options:{type:Array},value:{type:String}})}static get styles(){return[super.styles,Le]}render(){var e,l,t;const a=new Set(["zoom","limit","offset","order","fields"]),s=[],n=[];var r;return(r=null!==(e=this.value)&&void 0!==e?e:"",r.split("&").filter((e=>!!e)).map((e=>{const[l,t]=e.split("=").map(decodeURIComponent);return(null==t?void 0:t.includes("|"))?`${encodeURIComponent(l)}=${t}`.split("|").map((e=>xe(e))):xe(e)}))).forEach((e=>{Array.isArray(e)||!a.has(e.path)?n.push(e):s.push(e)})),ye({parsedValues:n,disableOr:this.disableOr,operators:null!==(l=this.operators)&&void 0!==l?l:[],disabled:this.disabled,readonly:this.readonly,options:null!==(t=this.options)&&void 0!==t?t:[],t:this.t.bind(this),onChange:e=>{this.value=Ve([...e,...s]),this.dispatchEvent(new Ze.ChangeEvent("change"))}})}}Ze.ChangeEvent=class extends CustomEvent{},Ze.Operator=r,Ze.Type=n,customElements.define("foxy-query-builder",Ze);export{Ze as QueryBuilder};
|
|
64
|
+
`));let R,U,G,W,F,J=e=>e;function K(e){var l,a,s;const n=null===(a=null===(l=e.list)||void 0===l?void 0:l.every((l=>l.value!==e.value)))||void 0===a||a;return t(R||(R=J` <label class="${0}"> <div class="relative flex-1 min-w-0 overflow-hidden"> <select class="${0}" ?disabled="${0}" @change="${0}"> ${0} ${0} </select> </div> ${0} </label> `),i({"flex items-center transition-colors group text-tertiary":!0,"cursor-pointer hover-bg-contrast-5":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),i({"bg-transparent relative appearance-none flex h-m px-s":!0,"font-medium w-full max-w-full whitespace-nowrap focus-outline-none":!0,"text-tertiary":n&&!e.disabled,"text-body":!n&&!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":!n&&e.readonly,"cursor-pointer":!e.disabled&&!e.readonly,"cursor-default":e.disabled||e.readonly}),e.disabled||e.readonly,(l=>{const t=l.currentTarget,a=t.options[t.options.selectedIndex].value;e.onChange(a)}),n?t(U||(U=J` <option value="" disabled="disabled" ?selected="${0}">${0}</option> `),n,e.t(e.label)):"",null===(s=e.list)||void 0===s?void 0:s.map((({label:l,value:a})=>t(G||(G=J` <option value="${0}" ?selected="${0}"> ${0} </option> `),a,a===e.value,e.t(l)))),n?"":t(W||(W=J` <span class="${0}"> ${0} </span> ${0} `),i({"font-tnum text-xs font-medium border mr-s px-xs rounded-s border-current inline-block":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.clearable&&!e.readonly?t(F||(F=J` <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="icon-inline text-l" icon="icons:remove-circle-outline"> </iron-icon> </button> `),e.t("delete"),i({"w-s h-s mr-xs flex items-center justify-center transition-colors rounded-full":!0,"focus-outline-none focus-ring-2 focus-ring-primary-50":!0,"hover-bg-contrast-5 hover-text-error text-body":!e.disabled,"text-disabled":e.disabled}),e.disabled,(()=>e.onChange(""))):""))}let P,Q,X,Y,ee,le=e=>e;function te(e){var l;const a=`${null!==(l=e.id)&&void 0!==l?l:String(Math.floor(Math.random()*Math.pow(10,8)))}-list`,s=!!e.displayValue;let n=e.value;if("date"===e.type){const l=new Date(e.value);n=isNaN(l.getTime())?"":u(l)}return t(P||(P=le` <label class="relative flex items-center cursor-text group text-tertiary"> <div class="relative flex-1 min-w-0 overflow-hidden"> ${0} <input placeholder="${0}" class="${0}" list="${0}" type="${0}" max="${0}" .value="${0}" ?disabled="${0}" @input="${0}"> </div> <span class="${0}"> ${0} </span> ${0} ${0} </label> `),s?t(Q||(Q=le` <div aria-hidden="true" class="${0}"> <div class="truncate">${0}</div> </div> `),i({"absolute inset-0 h-m px-s font-medium flex items-center":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.displayValue)):"",n||"date"===e.type?"":e.t(e.label),i({"bg-base relative flex h-m px-s font-medium w-full":!0,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly,"flex max-w-full whitespace-nowrap":!0,"focus-outline-none":!0,"opacity-0 focus-opacity-100":s}),d(e.list?a:void 0),"date"===e.type?"datetime-local":e.type,d("date"===e.type?"9999-12-31T23:59":""),n,e.disabled||e.readonly,(l=>{const t=l.currentTarget;let a=t.value;try{if("date"===e.type){const e=new Date(t.value);isNaN(e.getTime())||(a=e.toISOString())}}catch(e){}e.onChange(a)}),i({"font-tnum text-xs font-medium border border-current mr-s px-xs rounded-s":!0,"inline-block":!!n||"date"===e.type,"sr-only":!n&&"date"!==e.type,"text-body":!e.disabled&&!e.readonly,"text-disabled":e.disabled,"text-secondary":e.readonly}),e.t(e.label),e.list?t(X||(X=le` <datalist id="${0}"> ${0} </datalist> `),a,e.list.map((({label:l,value:a})=>t(Y||(Y=le`<option value="${0}">${0}</option>`),a,e.t(l))))):"",e.disabled||e.readonly?"":t(ee||(ee=le` <div class="absolute inset-0 transition-colors bg-transparent group-hover-bg-contrast-5 pointer-events-none"></div> `)))}let ae,se,ne=e=>e;let re,oe=e=>e;function ie({parsedValue:l,disabled:t,readonly:a,options:s,option:n,t:r,onChange:o}){return te({displayValue:null==n?void 0:n.label,disabled:t,readonly:a,value:l.path,label:"field",list:s.map((l=>e(e({},l),{},{value:l.path}))),type:"text",id:"path",t:r,onChange:e=>o({operator:null,value:"",path:e})})}let de,ue=e=>e;let ce,ve,pe=e=>e;function be(l){var a,s;const{parsedValue:d,isFullSize:u,isNested:v,readonly:p,disabled:b,options:h,t:f,onConvert:g,onDelete:C,onChange:x}=l,V=null!==(a=h.find((e=>e.path===d.path)))&&void 0!==a?a:null,H=null!==(s=null==V?void 0:V.type)&&void 0!==s?s:n.Any,M=d.operator,O={parsedValue:d,operators:l.operators,disabled:b,readonly:p,options:h,option:V,t:f,onChange:x},N={[n.Attribute]:B,[n.Boolean]:_,[n.Number]:z,[n.String]:q,[n.Date]:S,[n.Any]:I};return t(ce||(ce=pe` <div class="flex items-center space-x-s" aria-label="${0}"> <div class="${0}"> <div class="bg-contrast-10"> <div class="grid gap-1px grid-vertical sm-grid-horizontal"> <div class="bg-base" title="${0}"> <div class="${0}" aria-hidden="true"> ${0} </div> </div> <div class="bg-base"> ${0} </div> <div class="bg-base">${0}</div> <div class="bg-base"> ${0} </div> </div> </div> </div> <div class="${0}"> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:remove-circle-outline"> </iron-icon> </button> <button aria-label="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <iron-icon aria-hidden="true" class="m-auto icon-inline text-xl" icon="icons:add-circle-outline"> </iron-icon> </button> </div> </div> `),f("query_builder_rule"),i({"flex-1 bg-base rounded overflow-hidden border":!0,"border-contrast-10":!v&&!p,"border-contrast-50":!!v||p,"border-dashed":p,"border-solid":!p}),f(`type_${H}`),i({"w-m h-m":!0,"text-tertiary":!p&&!b,"text-disabled":p||b}),V?N[H]:I,d.path&&(H===n.Attribute||d.name)?t(ve||(ve=pe` <div class="bg-contrast-10 grid gap-1px grid-cols-1 sm-grid-cols-2"> <div class="bg-base">${0}</div> <div class="bg-base">${0}</div> </div> `),ie(O),function(l){var t;return te({disabled:l.disabled,readonly:l.readonly,value:null!==(t=l.parsedValue.name)&&void 0!==t?t:"",label:"name",type:"text",t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{name:t}))})}(O)):ie(O),function(l){const a=l.parsedValue.operator,s={[r.GreaterThan]:y,[r.GreaterThanOrEqual]:o,[r.In]:w,[r.IsDefined]:$,[r.LessThan]:L,[r.LessThanOrEqual]:Z,[r.Not]:j},d={[n.Attribute]:[r.In,r.Not,r.IsDefined],[n.Boolean]:[],[n.String]:[r.In,r.Not],[n.Number]:[r.In,r.Not,r.GreaterThan,r.LessThan,r.GreaterThanOrEqual,r.LessThanOrEqual],[n.Date]:[r.In,r.Not],[n.Any]:Object.values(r)},u=(l.option?d[l.option.type]:l.parsedValue.name?Object.values(r):Object.values(r).filter((e=>e!==r.IsDefined))).filter((e=>l.operators.includes(e))),c=l.disabled||l.readonly||0===u.length||!l.parsedValue.path;return t(re||(re=oe` <button title="${0}" class="${0}" ?disabled="${0}" @click="${0}"> <div aria-hidden="true">${0}</div> </button> `),l.t(`operator_${null!=a?a:"equal"}`),i({"flex items-center justify-center w-m h-m transition-colors":!0,"focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50":!0,"text-body hover-bg-contrast-5":!c&&u.length>1,"cursor-default text-tertiary":!c&&u.length<=1,"text-disabled cursor-default":c}),c||u.length<=1,(()=>{var t;const s=a?u.indexOf(a):-1,n=null!==(t=u[s+1])&&void 0!==t?t:null;l.onChange(e(e({},l.parsedValue),{},{operator:n,value:l.parsedValue.value}))}),a?s[a]:m)}(O),M===r.In?function(l){var a,s,r,o;const i=(null===(a=l.option)||void 0===a?void 0:a.list)?K:te,d=l.parsedValue.value.split(","),u=null!==(r=null===(s=l.option)||void 0===s?void 0:s.type)&&void 0!==r?r:n.Any,v=u===n.Number?"number":u===n.Date?"date":"text",p=null===(o=l.option)||void 0===o?void 0:o.list,b=[...d.filter((e=>!!e))];return l.readonly||b.push(null),t(ae||(ae=ne` <div class="bg-contrast-10 grid grid-cols-1 gap-1px"> ${0} </div> `),c(b,((e,l)=>l),((a,s)=>{var n;return t(se||(se=ne` <div class="bg-base"> ${0} </div> `),i({type:v,list:p,t:l.t,value:null!=a?a:"",label:a?String(s+1):"add_value",disabled:l.disabled,readonly:l.readonly,clearable:!0,displayValue:null===(n=null==p?void 0:p.find((e=>e.value===a)))||void 0===n?void 0:n.label,onChange:t=>{t?d[s]=t:d.splice(s,1),l.onChange(e(e({},l.parsedValue),{},{value:d.join(",")}))}}))})))}(O):M===r.IsDefined?function(l){return K({readonly:l.readonly,disabled:l.disabled,value:l.parsedValue.value,label:"value",list:[{label:"is_defined_true",value:"true"},{label:"is_defined_false",value:"false"}],t:l.t,onChange:t=>l.onChange(e(e({},l.parsedValue),{},{value:t}))})}(O):H===n.Boolean?function(l){var t,a,s,n,r,o;const{parsedValue:i,option:d,readonly:u,disabled:c,t:v,onChange:p}=l,b=null!==(s=null===(a=null===(t=null==d?void 0:d.list)||void 0===t?void 0:t.find((e=>"false"===e.value)))||void 0===a?void 0:a.label)&&void 0!==s?s:"false",h=[{label:null!==(o=null===(r=null===(n=null==d?void 0:d.list)||void 0===n?void 0:n.find((e=>"true"===e.value)))||void 0===r?void 0:r.label)&&void 0!==o?o:"true",value:"true"},{label:b,value:"false"}];return K({disabled:c,readonly:u,value:i.value,label:"value",list:h,t:v,onChange:l=>p(e(e({},i),{},{value:l}))})}(O):null===M&&[n.Number,n.Date].includes(H)?function(l){var a,s,r;const{t:o,parsedValue:i,option:d,readonly:u,disabled:c,onChange:v}=l,p=i.value.split(".."),b=p.length>=1?p[0]:"",h=p.length>=2?p[1]:"",f=(null==d?void 0:d.list)?K:te,g=null!==(a=null==d?void 0:d.type)&&void 0!==a?a:n.Any,m=g===n.Number?"number":g===n.Date?"date":"text",C=null==d?void 0:d.list;return t(de||(de=ue` <div class="grid bg-contrast-10 gap-1px grid-cols-1 grid-rows-2 sm-grid-cols-2 sm-grid-rows-1"> <div class="bg-base"> ${0} </div> <div class="bg-base"> ${0} </div> </div> `),f({displayValue:null===(s=null==C?void 0:C.find((e=>e.value===b)))||void 0===s?void 0:s.label,readonly:u,disabled:c,value:b,label:"range_from",type:m,list:C,t:o,onChange:l=>v(e(e({},i),{},{value:`${l}..${h}`}))}),f({displayValue:null===(r=null==C?void 0:C.find((e=>e.value===h)))||void 0===r?void 0:r.label,readonly:u,disabled:c,label:"range_to",value:h,type:m,list:C,t:o,onChange:l=>v(e(e({},i),{},{value:`${b}..${l}`}))}))}(O):function(l){var t,a,s,r;const{t:o,option:i,parsedValue:d,readonly:u,disabled:c,onChange:v}=l,p=(null==i?void 0:i.list)?K:te,b=null!==(t=null==i?void 0:i.type)&&void 0!==t?t:n.Any;return p({displayValue:null===(s=null===(a=null==i?void 0:i.list)||void 0===a?void 0:a.find((e=>e.value===d.value)))||void 0===s?void 0:s.label,readonly:u,disabled:c||!d.path,value:null!==(r=d.value)&&void 0!==r?r:"",label:"value",type:b===n.Number?"number":b===n.Date?"date":"text",list:null==i?void 0:i.list,t:o,onChange:l=>v(e(e({},d),{},{value:l}))})}(O),i({"-mr-s self-start flex-col sm-flex-row flex-shrink-0 items-center":!0,"border-t border-b border-transparent divide-y divide-transparent":!0,hidden:!!u||p,flex:!u}),f("delete"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-secondary hover-bg-contrast-5 hover-text-error":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0":!d.path}),b||p||!d.path,C,f("add_or_clause"),i({"box-content flex w-m h-m rounded-full transition-colors":!0,"text-success hover-bg-contrast-5":!b,"cursor-default text-disabled":b,"focus-outline-none focus-ring-2 ring-primary-50":!0,"opacity-0":!d.path||!!v||l.disableOr}),b||p||!d.path,g)}let he,fe,ge,me,Ce=e=>e;function ye(l){const a=l.parsedValues.some((e=>Array.isArray(e))),s=t(he||(he=Ce`<div class="${0}"></div>`),a?"h-xs":"mt-s"),n=t(fe||(fe=Ce` <div class="flex items-center h-s"> <div class="w-m text-center leading-none uppercase font-medium text-xs text-contrast-30"> ${0} </div> <div class="flex-1 border-t border-contrast-20"></div> <div class="w-m ml-s flex-shrink-0"></div> <div class="hidden sm-block w-m flex-shrink-0"></div> </div> `),l.t("or"));return t(ge||(ge=Ce` <div aria-label="${0}"> ${0} </div> `),l.t("query_builder_group"),c([...l.parsedValues,null],((e,l)=>String(l)),((a,r)=>{const o=r>0?l.isNested?n:s:"";return null===a?[o,be({operators:l.operators,disableOr:l.disableOr,isFullSize:!l.isNested&&0===l.parsedValues.length,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,parsedValue:{path:"",operator:null,value:""},t:l.t,onChange:e=>l.onChange([...l.parsedValues,e])})]:Array.isArray(a)?[o,t(me||(me=Ce` <div class="bg-contrast-10 rounded-t-l rounded-b-l p-s -m-s"> ${0} </div> `),ye({parsedValues:a,disableOr:l.disableOr,operators:l.operators,isNested:!0,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues],a=e;t[r]=e.length>1?a:a[0],l.onChange(t)}}))]:[o,be({parsedValue:a,disableOr:l.disableOr,operators:l.operators,isNested:l.isNested,disabled:l.disabled,readonly:l.readonly,options:l.options,t:l.t,onChange:e=>{const t=[...l.parsedValues];t[r]=e,l.onChange(t)},onDelete:()=>{const e=l.parsedValues.filter(((e,l)=>l!==r));l.onChange(e)},onConvert:()=>{const t=[...l.parsedValues];t[r]=[a,e(e({},a),{},{operator:null,value:""})],l.onChange(t)}})]})))}function xe(e){var l;const[t,a]=e.split("=").map(decodeURIComponent),s=null!==(l=Object.values(r).find((e=>t.endsWith(`:${e}`))))&&void 0!==l?l:null;let n,o=t.substring(0,s?t.lastIndexOf(":"):void 0);const i=t.lastIndexOf("[");return o.endsWith("]")&&-1!==i&&(n=o.substring(i+1,o.length-1),o=o.substring(0,i),o.endsWith(":name")&&(o=o.substring(0,o.length-5))),{name:n,path:o,value:a,operator:s}}function we(e){let l=e.path;return e.name&&(l+=`:name[${e.name}]`),e.operator&&(l+=`:${e.operator}`),l=`${encodeURIComponent(l)}=${encodeURIComponent(e.value)}`,"="===l?"":l}function Ve(e){const l=e.reduce(((e,l)=>{if(Array.isArray(l)){const t=[l[0].value,l.slice(1).map((e=>we(e)))].join("|");e.push(`${l[0].path}=${encodeURIComponent(t)}`)}else"zoom"!==l.path&&e.push(we(l));return e}),[]),t=$e(e).join(",");return t&&l.push(`zoom=${encodeURIComponent(t)}`),l.join("&")}function $e(e){return e.map((e=>{if(Array.isArray(e))return $e(e);if(e.name)return[e.path];const l=e.path.split(":");return l.slice(0,l.length-1)})).flat().sort(((e,l)=>l.length-e.length)).filter(((e,l,t)=>t.every(((t,a)=>(a>=l||t!==e)&&!t.startsWith(`${e}:`)))))}let He;const Le=a(He||(He=(e=>e)`.gap-1px{gap:1px}.grid-vertical{grid-template:auto/var(--lumo-size-m) 1fr}:host([sm]) .sm-grid-horizontal{grid-template:auto/var(--lumo-size-m) 1fr var(--lumo-size-m) 1fr}`)),Me=f(v(p(b(h(s),"query-builder"))));class Ze extends Me{constructor(){super(...arguments),this.operators=Object.values(r),this.disableOr=!1,this.options=null,this.value=null}static get properties(){return e(e({},super.properties),{},{disableOr:{type:Boolean,attribute:"disable-or"},operators:{type:Array},options:{type:Array},value:{type:String}})}static get styles(){return[super.styles,Le]}render(){var e,l,t;const a=new Set(["zoom","limit","offset","order","fields"]),s=[],n=[];var r;return(r=null!==(e=this.value)&&void 0!==e?e:"",r.split("&").filter((e=>!!e)).map((e=>{const[l,t]=e.split("=").map(decodeURIComponent);return(null==t?void 0:t.includes("|"))?`${encodeURIComponent(l)}=${t}`.split("|").map((e=>xe(e))):xe(e)}))).forEach((e=>{Array.isArray(e)||!a.has(e.path)?n.push(e):s.push(e)})),ye({parsedValues:n,disableOr:this.disableOr,operators:null!==(l=this.operators)&&void 0!==l?l:[],disabled:this.disabled,readonly:this.readonly,options:null!==(t=this.options)&&void 0!==t?t:[],t:this.t.bind(this),onChange:e=>{this.value=Ve([...e,...s]),this.dispatchEvent(new Ze.ChangeEvent("change"))}})}}Ze.ChangeEvent=class extends CustomEvent{},Ze.Operator=r,Ze.Type=n,customElements.define("foxy-query-builder",Ze);export{Ze as QueryBuilder};
|