@foxy.io/elements 1.31.0 → 1.31.1-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.
Files changed (35) hide show
  1. package/dist/cdn/foxy-admin-subscription-form.js +1 -1
  2. package/dist/cdn/foxy-cart-form.js +1 -1
  3. package/dist/cdn/foxy-coupon-form.js +1 -1
  4. package/dist/cdn/foxy-customer-form.js +1 -1
  5. package/dist/cdn/foxy-customer-portal-settings-form.js +1 -1
  6. package/dist/cdn/foxy-customer-portal.js +1 -1
  7. package/dist/cdn/foxy-customer.js +1 -1
  8. package/dist/cdn/foxy-gift-card-code-form.js +1 -1
  9. package/dist/cdn/foxy-gift-card-form.js +1 -1
  10. package/dist/cdn/foxy-item-card.js +1 -1
  11. package/dist/cdn/foxy-item-form.js +1 -1
  12. package/dist/cdn/foxy-native-integration-form.js +1 -1
  13. package/dist/cdn/foxy-store-form.js +1 -1
  14. package/dist/cdn/foxy-store-shipping-method-form.js +1 -1
  15. package/dist/cdn/foxy-subscription-form.js +1 -1
  16. package/dist/cdn/foxy-transaction.js +1 -1
  17. package/dist/cdn/foxy-webhook-form.js +1 -1
  18. package/dist/cdn/{shared-638468a5.js → shared-60d586ba.js} +1 -1
  19. package/dist/cdn/shared-7c411b0a.js +1 -0
  20. package/dist/cdn/translations/admin-subscription-form/en.json +3 -3
  21. package/dist/elements/internal/InternalDateControl/InternalDateControl.js +12 -6
  22. package/dist/elements/internal/InternalDateControl/InternalDateControl.js.map +1 -1
  23. package/dist/elements/internal/InternalDateControl/vaadinStyles.js +8 -0
  24. package/dist/elements/internal/InternalDateControl/vaadinStyles.js.map +1 -1
  25. package/dist/elements/internal/InternalPasswordControl/InternalPasswordControl.js +15 -2
  26. package/dist/elements/internal/InternalPasswordControl/InternalPasswordControl.js.map +1 -1
  27. package/dist/elements/internal/InternalPasswordControl/generateRandomPassword.d.ts +3 -2
  28. package/dist/elements/internal/InternalPasswordControl/generateRandomPassword.js.map +1 -1
  29. package/dist/elements/public/CustomerForm/CustomerForm.d.ts +1 -0
  30. package/dist/elements/public/CustomerForm/CustomerForm.js +6 -1
  31. package/dist/elements/public/CustomerForm/CustomerForm.js.map +1 -1
  32. package/dist/elements/public/ItemCard/ItemCard.js +2 -1
  33. package/dist/elements/public/ItemCard/ItemCard.js.map +1 -1
  34. package/package.json +1 -1
  35. package/dist/cdn/shared-dfc33ff6.js +0 -1
@@ -1 +1 @@
1
- import"./shared-9b2d6d62.js";import"./shared-0a6a28ce.js";import"./shared-6e859df6.js";import"./shared-56bf05ef.js";import"./shared-90a47948.js";import{I as e}from"./shared-0e055562.js";import"./shared-388e9240.js";import"./shared-c388e926.js";import"./shared-0f67d020.js";import"./shared-51c4a6dd.js";import"./foxy-transaction-card.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-37efab30.js";import{_ as t,B as a}from"./shared-0f6e4584.js";import"./shared-b08ca8d0.js";import"./shared-029d623b.js";import{h as s}from"./shared-dc73b9a5.js";import{S as i,R as r,a as n}from"./shared-fb34e84c.js";import{c as o}from"./shared-4e709717.js";import{C as d}from"./shared-f11b2116.js";import"./shared-fc1dfa64.js";import{S as l}from"./shared-d1c10d58.js";import{G as c}from"./shared-a49a2300.js";import"./shared-8f3398dc.js";import"./shared-19884cf4.js";import"./shared-c2776a33.js";import"./shared-a207423c.js";import"./shared-453d8f75.js";import"./shared-4b346553.js";import{p as u}from"./shared-f34aeb6c.js";import{s as m}from"./shared-79d0699c.js";import{i as h}from"./shared-9803aa7c.js";import{p as f}from"./shared-01b2cad8.js";import{j as _}from"./shared-6d645dc5.js";import"./shared-44ce656d.js";import"./shared-09b4185a.js";import"./shared-280f868d.js";import"./shared-e24da82e.js";import"./shared-651c44fa.js";import"./shared-b8198665.js";import"./shared-61ade33e.js";import"./shared-f2968508.js";import"./shared-d8c3067b.js";import"./shared-7d38cb8a.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-6474675f.js";import"./shared-ee36b83f.js";import"./shared-6918312e.js";import"./foxy-copy-to-clipboard.js";import"./foxy-spinner.js";import"./shared-bab2ea2c.js";import"./shared-61b6ef6e.js";import"./foxy-collection-page.js";import"./shared-a0c6a159.js";import"./shared-99940888.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./foxy-pagination.js";import"./shared-d132bd37.js";import"./shared-43e2c3f6.js";import"./shared-3ee151ce.js";import"./shared-f3773d62.js";import"./shared-f407c2cb.js";import"./shared-21bc5d5e.js";import"./shared-ac0368ec.js";import"./shared-245f8836.js";import"./shared-16c17e32.js";import"./shared-da9e048f.js";import"./shared-56a559fd.js";function p(e){return function*(e){const t=[];for(const a of e.settings.subscriptions.allowFrequencyModification)if(_(a.jsonataQuery).evaluate(e.subscription))for(const e of a.values)!t.includes(e)&&(t.push(e),yield e)}({settings:{subscriptions:{allowFrequencyModification:e.settings.subscriptions.allow_frequency_modification.map((e=>({jsonataQuery:e.jsonata_query,values:e.values})))}},subscription:e.subscription})}class y extends Error{constructor(e){super(`Invalid frequency "${e}".`)}}function v(e){const t=864e5,a=31*t;if(".5m"===e)return a/2;const s=parseInt(e.substring(0,e.length-1));if(isNaN(s))throw new y(e);if(e.endsWith("y"))return 31536e6*s;if(e.endsWith("m"))return s*a;if(e.endsWith("w"))return 6048e5*s;if(e.endsWith("d"))return s*t;throw new y(e)}function x(e,t){if("boolean"==typeof t)return t;const a=t.filter((t=>Boolean(_(t.jsonataQuery).evaluate(e)))).reduce(((e,t)=>{var a,s,i,r,n;if(t.min){const a=e.min?v(e.min):1/0;v(t.min)<a&&(e.min=t.min)}if(t.max){const a=e.max?v(e.max):-1/0;v(t.max)>a&&(e.max=t.max)}if("day"===(null===(a=t.allowedDays)||void 0===a?void 0:a.type)){const a=[...null!==(s=e.allowedDaysOfWeek)&&void 0!==s?s:[],...t.allowedDays.days];e.allowedDaysOfWeek=Array.from(new Set(a))}if("month"===(null===(i=t.allowedDays)||void 0===i?void 0:i.type)){const a=[...null!==(r=e.allowedDaysOfMonth)&&void 0!==r?r:[],...t.allowedDays.days];e.allowedDaysOfMonth=Array.from(new Set(a))}if(t.disallowedDates){const a=[...null!==(n=e.disallowedDates)&&void 0!==n?n:[],...t.disallowedDates];e.disallowedDates=Array.from(new Set(a))}return e}),{});return 0!==Object.keys(a).length&&a}function g(e){const[t,a,s]=e.split("-").map((e=>parseInt(e)));return new Date(t,a-1,s)}function b(e){const t=e.settings.subscriptions.allow_next_date_modification;let a;return a="boolean"==typeof t?t:t.map((e=>({allowedDays:e.allowed_days,disallowedDates:e.disallowed_dates,jsonataQuery:e.jsonata_query,max:e.max,min:e.min}))),function(e){var t,a;const s=g(e.value),i=s.getTime(),r=x(e.subscription,e.settings.subscriptions.allowNextDateModification);if("boolean"==typeof r)return r;if(!1===(null===(t=r.allowedDaysOfMonth)||void 0===t?void 0:t.includes(s.getDate())))return!1;if(!1===(null===(a=r.allowedDaysOfWeek)||void 0===a?void 0:a.includes(s.getDay())))return!1;if(r.disallowedDates&&r.disallowedDates.find((e=>{const[t,a]=e.split("..").map((e=>g(e).getTime()));return i===t||void 0!==a&&i>=t&&i<=a})))return!1;if(r.min){const e=f(r.min);if(null!==e&&Date.now()+e>=i)return!1}if(r.max){const e=f(r.max);if(null!==e&&Date.now()+e<=i)return!1}return!0}({settings:{subscriptions:{allowNextDateModification:a}},subscription:e.subscription,value:e.value})}let $,j,D,w,S,T,q,E,k,H,C,L=e=>e;const A=i(r(n(e,"subscription-form")));class I extends A{constructor(){super(...arguments),this.getTransactionPageHref=(e,t)=>null==t?void 0:t._links["fx:receipt"].href,this.getCustomerPageHref=null,this.customerAddresses=null,this.itemCategories=null,this.localeCodes=null,this.settings=null,this.coupons=null,this.__transactionTemplateLoaderId="transactionTemplateLoader",this.__defaultTemplateSetLoaderId="defaultTemplateSetLoader",this.__localeCodesHelperLoaderId="localeCodesLoader",this.__templateSetLoaderId="templateSetLoader",this.__storeLoaderId="storeLoader",this.__renderItemsActions=()=>s($||($=L` <div class="flex" data-testid="items:actions"> ${0} <foxy-i18n data-testid="items:actions-label" class="flex-1 text-s font-medium text-secondary" lang="${0}" key="item_plural" ns="${0}"> </foxy-i18n> ${0} </div> `),this.renderTemplateOrSlot("items:actions:before"),this.lang,this.ns,this.renderTemplateOrSlot("items:actions:after")),this.__renderItems=()=>{var e;let t;try{const a=this.__transactionTemplate,s=new URL(null!==(e=null==a?void 0:a._links["fx:items"].href)&&void 0!==e?e:"");s.searchParams.set("zoom","item_options"),t=s.toString()}catch(e){t=void 0}return s(j||(j=L` <div data-testid="items" class="space-y-xs sm-col-span-2"> ${0} <foxy-internal-async-list-control first="${0}" infer="items" item="foxy-item-card" .itemProps="${0}"> </foxy-internal-async-list-control> </div> `),this.hiddenSelector.matches("items:actions",!0)?"":this.__renderItemsActions(),h(t),{"locale-codes":this.localeCodes})},this.__renderEndDate=()=>{var e;const{data:t,lang:a,ns:i}=this;return s(D||(D=L` <div data-testid="end-date"> ${0} <x-group frame> <foxy-i18n key="end_date" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <foxy-internal-calendar start="${0}" value="${0}" lang="${0}" ?readonly="${0}" ?disabled="${0}" .checkAvailability="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("end-date:before"),i,a,h(null===(e=null==t?void 0:t.end_date)||void 0===e?void 0:e.substr(0,10)),h(null==t?void 0:t.end_date),a,!this.__isEndDateEditable,this.disabledSelector.matches("end-date",!0),this.__checkEndDateAvailability,(e=>{const t=e.target;this.edit({end_date:t.value})}),this.renderTemplateOrSlot("end-date:after"))},this.__checkNextTransactionDateAvailability=e=>{const{settings:t,data:a}=this;if(t&&a){return b({value:m(e),settings:t,subscription:a})}return e.getTime()>=Date.now()},this.__checkStartDateAvailability=e=>e.getTime()>=Date.now(),this.__checkEndDateAvailability=e=>{const t=new Date;return t.setDate(t.getDate()+1),t.setHours(0,0,0,0),e.getTime()>=t.getTime()},this.__renderStartDate=()=>{const{data:e,lang:t,ns:a}=this;return s(w||(w=L` <div data-testid="start-date"> ${0} <x-group frame> <foxy-i18n key="start_date" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <foxy-internal-calendar start="${0}" value="${0}" lang="${0}" ?readonly="${0}" ?disabled="${0}" .checkAvailability="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("start-date:before"),a,t,h(null==e?void 0:e.start_date.substr(0,10)),h(null==e?void 0:e.start_date),t,!this.__isStartDateEditable,this.disabledSelector.matches("start-date",!0),this.__checkStartDateAvailability,(e=>{const t=e.target;this.edit({start_date:t.value})}),this.renderTemplateOrSlot("start-date:after"))},this.__renderNextTransactionDate=()=>{const{data:e,lang:t,ns:a}=this,i=!!(null==e?void 0:e.is_active);return s(S||(S=L` <div data-testid="next-transaction-date"> ${0} <x-group frame> <foxy-i18n key="next_transaction_date" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <foxy-internal-calendar start="${0}" value="${0}" lang="${0}" ?readonly="${0}" ?disabled="${0}" .checkAvailability="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("next-transaction-date:before"),a,t,h(null==e?void 0:e.next_transaction_date.substr(0,10)),h(null==e?void 0:e.next_transaction_date),t,!i||this.readonlySelector.matches("next-transaction-date",!0),!e||this.disabledSelector.matches("next-transaction-date",!0),this.__checkNextTransactionDateAvailability,(e=>{const t=e.target;this.edit({next_transaction_date:t.value})}),this.renderTemplateOrSlot("next-transaction-date:after"))},this.__renderFrequencyAsDropdown=()=>{const{data:e}=this,t=!!(null==e?void 0:e.is_active),a=this.__frequencies.map((e=>({label:this.t(".5m"===e?"twice_a_month":"frequency",u(e)),value:e})));return s(T||(T=L` <vaadin-combo-box item-value-path="value" item-label-path="label" data-testid="frequency" ?disabled="${0}" ?readonly="${0}" class="w-full" label="${0}" value="${0}" .items="${0}" @change="${0}"> </vaadin-combo-box> `),!e||this.disabledSelector.matches("frequency",!0),e&&(!t||this.readonlySelector.matches("frequency",!0)),this.t("frequency_label").toString(),h(this.form.frequency),a,(e=>{this.edit({frequency:e.target.value})}))},this.__renderFrequencyAsRadioList=()=>{var e;const{data:t,lang:a,ns:i}=this;return s(q||(q=L` <x-group frame> <foxy-i18n key="frequency_label" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <x-choice default-custom-value="1d" data-testid="frequency" type="frequency" ns="${0}" ?custom="${0}" .items="${0}" .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> ${0} </x-choice> </x-group> `),i,a,i,null===this.settings,this.__frequencies,null!==(e=this.form.frequency)&&void 0!==e?e:null,!t||this.disabledSelector.matches("frequency",!0),t&&(!t.is_active||this.readonlySelector.matches("frequency",!0)),(e=>{this.edit({frequency:e.target.value})}),this.__frequencies.map((e=>s(E||(E=L` <foxy-i18n options="${0}" slot="${0}-label" lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> `),JSON.stringify(u(e)),e,a,".5m"===e?"twice_a_month":"frequency",i))))},this.__renderFrequency=()=>s(k||(k=L` <div class="sm-col-span-2"> ${0} ${0} ${0} </div> `),this.renderTemplateOrSlot("frequency:before"),this.settings&&this.__frequencies.length>4?this.__renderFrequencyAsDropdown():this.__renderFrequencyAsRadioList(),this.renderTemplateOrSlot("frequency:after")),this.__renderCustomer=()=>{var e,t;const a=null===(e=this.data)||void 0===e?void 0:e._links["fx:customer"].href,i=a?null===(t=this.getCustomerPageHref)||void 0===t?void 0:t.call(this,a):void 0;return s(H||(H=L` <div data-testid="customer" class="sm-col-span-2"> ${0} <foxy-i18n infer="customer" class="block text-s font-medium leading-xs mb-xs" key="label"> </foxy-i18n> <a class="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" href="${0}"> <foxy-customer-card infer="customer" href="${0}"></foxy-customer-card> </a> ${0} </div> `),this.renderTemplateOrSlot("customer:before"),o({"block rounded transition-colors":!0,"ring-1 ring-contrast-10":!i,"cursor-pointer bg-contrast-5 hover-bg-contrast-10":!!i,"focus-outline-none focus-ring-2 focus-ring-primary-50":!!i}),h(i),h(a),this.renderTemplateOrSlot("customer:after"))}}static get scopedElements(){return{"foxy-internal-timestamps-control":customElements.get("foxy-internal-timestamps-control"),"foxy-internal-async-list-control":customElements.get("foxy-internal-async-list-control"),"foxy-internal-number-control":customElements.get("foxy-internal-number-control"),"foxy-internal-submit-control":customElements.get("foxy-internal-submit-control"),"foxy-internal-delete-control":customElements.get("foxy-internal-delete-control"),"foxy-internal-undo-control":customElements.get("foxy-internal-undo-control"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-internal-calendar":customElements.get("foxy-internal-calendar"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"foxy-customer-card":customElements.get("foxy-customer-card"),"vaadin-combo-box":customElements.get("vaadin-combo-box"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-nucleon":customElements.get("foxy-nucleon"),"vcf-tooltip":customElements.get("vcf-tooltip"),"foxy-i18n":customElements.get("foxy-i18n"),"iron-icon":customElements.get("iron-icon"),"x-skeleton":l,"x-choice":d,"x-group":c}}static get properties(){return t(t({},super.properties),{},{getTransactionPageHref:{attribute:!1},getCustomerPageHref:{attribute:!1},customerAddresses:{attribute:"customer-addresses"},itemCategories:{attribute:"item-categories"},localeCodes:{attribute:"locale-codes"},settings:{type:Object},coupons:{}})}get hiddenSelector(){return new a(`items:pagination:card:autorenew-icon ${super.hiddenSelector}`)}get headerTitleOptions(){if(this.data&&this.__currencyCode){const e=u(this.data.frequency),a=this.__transactionTemplate,s=`${null==a?void 0:a.total_order} ${this.__currencyCode}`,i=this.__currencyDisplay,r=this.__currencyCode?".5m"===this.data.frequency?"twice_a_month":"recurring":"existing";return t(t({},e),{},{amount:s,currencyDisplay:i,context:r})}return{}}get headerSubtitleOptions(){var e,t,a;let s,i=null;if(null===(e=this.data)||void 0===e?void 0:e.first_failed_transaction_date)s="failed",i=this.data.first_failed_transaction_date;else if(null===(t=this.data)||void 0===t?void 0:t.end_date){s=new Date(this.data.end_date).getTime()>Date.now()?"will_be_cancelled":"cancelled",i=this.data.end_date}else(null===(a=this.data)||void 0===a?void 0:a.is_active)?new Date(this.data.start_date)>new Date?(s="will_be_active",i=this.data.start_date):(s="active",i=this.data.next_transaction_date):s="inactive";return{date:i,context:s}}renderBody(){var e,t,a,i,r;let n;try{const a=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:transactions"].href)&&void 0!==t?t:"");a.searchParams.set("order","transaction_date desc"),a.searchParams.set("zoom","items"),n=a.toString()}catch(e){n=void 0}return s(C||(C=L` ${0} <div class="relative grid grid-cols-1 sm-grid-cols-2 gap-l"> <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> <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> ${0} ${0} ${0} ${0} ${0} ${0} <foxy-internal-number-control suffix="${0}" infer="past-due-amount" class="sm-col-span-2" min="0"> </foxy-internal-number-control> <foxy-internal-async-list-control first="${0}" class="sm-col-span-2" infer="attributes" limit="5" form="foxy-attribute-form" item="foxy-attribute-card"> </foxy-internal-async-list-control> <foxy-internal-async-list-control first="${0}" class="sm-col-span-2" infer="transactions" limit="5" item="foxy-transaction-card" hide-delete-button .getPageHref="${0}"> </foxy-internal-async-list-control> <foxy-internal-timestamps-control infer="timestamps" class="sm-col-span-2"> </foxy-internal-timestamps-control> </div> `),this.renderHeader(),h(this.__transactionTemplateHref),this.__transactionTemplateLoaderId,(()=>this.requestUpdate()),h(this.__defaultTemplateSetHref),this.__defaultTemplateSetLoaderId,(()=>this.requestUpdate()),h(this.__localeCodesHelperHref),this.__localeCodesHelperLoaderId,(()=>this.requestUpdate()),h(this.__templateSetHref),this.__templateSetLoaderId,(()=>this.requestUpdate()),h(this.__storeHref),this.__storeLoaderId,(()=>this.requestUpdate()),this.hiddenSelector.matches("customer",!0)?"":this.__renderCustomer(),this.hiddenSelector.matches("items",!0)?"":this.__renderItems(),this.__isFrequencyVisible?this.__renderFrequency():"",this.__isStartDateVisible?this.__renderStartDate():"",this.__isNextTransactionDateVisible?this.__renderNextTransactionDate():"",this.__isEndDateVisible?this.__renderEndDate():"",h(null!==(a=this.__currencyCode)&&void 0!==a?a:void 0),h(null===(r=null===(i=this.data)||void 0===i?void 0:i._links["fx:attributes"])||void 0===r?void 0:r.href),h(n),this.getTransactionPageHref)}get __transactionTemplateHref(){var e;const t=this.data;return(null===(e=null==t?void 0:t._embedded)||void 0===e?void 0:e["fx:transaction_template"])||null==t?void 0:t._links["fx:transaction_template"].href}get __defaultTemplateSetHref(){var e,t,a;if(""===(null===(e=this.__transactionTemplate)||void 0===e?void 0:e.template_set_uri))try{const e=new URL(null!==(a=null===(t=this.__store)||void 0===t?void 0:t._links["fx:template_sets"].href)&&void 0!==a?a:"");return e.searchParams.set("code","DEFAULT"),e.toString()}catch(e){}}get __localeCodesHelperHref(){var e;if(this.__defaultTemplateSetHref||this.__templateSetHref)return null!==(e=this.localeCodes)&&void 0!==e?e:void 0}get __templateSetHref(){const e=this.__transactionTemplate;if(!(null==e?void 0:e.currency_code))return(null==e?void 0:e.template_set_uri)||void 0}get __storeHref(){var e,t;return null===(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:store"])||void 0===t?void 0:t.href}get __transactionTemplate(){var e,t,a;const s=this.data,i=null===(e=null==s?void 0:s._embedded)||void 0===e?void 0:e["fx:transaction_template"],r=`#${this.__transactionTemplateLoaderId}`;return null!==(a=null!=i?i:null===(t=this.renderRoot.querySelector(r))||void 0===t?void 0:t.data)&&void 0!==a?a:null}get __defaultTemplateSet(){var e,t;const a=`#${this.__defaultTemplateSetLoaderId}`,s=this.renderRoot.querySelector(a);return null!==(t=null===(e=null==s?void 0:s.data)||void 0===e?void 0:e._embedded["fx:template_sets"][0])&&void 0!==t?t:null}get __localeCodesHelper(){var e,t;const a=`#${this.__localeCodesHelperLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(a))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __templateSet(){var e,t;const a=`#${this.__templateSetLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(a))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __store(){var e,t;const a=`#${this.__storeLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(a))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __isNextTransactionDateVisible(){if(this.hiddenSelector.matches("next-transaction-date",!0))return!1;if(null===this.data)return!1;if(this.data.end_date&&new Date(this.data.end_date).getTime()<=Date.now())return!1;if(!1===this.data.is_active)return!1;if(null===this.settings)return!0;const e=this.settings.subscriptions.allow_next_date_modification;return!!function(e,t){let a;return a="boolean"==typeof t?t:t.map((e=>({allowedDays:e.allowed_days,disallowedDates:e.disallowed_dates,jsonataQuery:e.jsonata_query,max:e.max,min:e.min}))),x(e,a)}(this.data,e)}get __isStartDateVisible(){return!this.hiddenSelector.matches("start-date",!0)&&this.__isNextTransactionDateVisible}get __isEndDateVisible(){return!this.hiddenSelector.matches("end-date",!0)&&(null!==this.data&&(!(this.data.end_date&&new Date(this.data.end_date).getTime()<=Date.now())&&(!1!==this.data.is_active&&!this.settings)))}get __isStartDateEditable(){return!this.readonlySelector.matches("start-date",!0)&&(null!==this.data&&(!(this.data.end_date&&new Date(this.data.end_date)<=new Date)&&(!1!==this.data.is_active&&(!(this.data.start_date&&new Date(this.data.start_date)<=new Date)&&null===this.settings))))}get __isEndDateEditable(){return!this.readonlySelector.matches("end-date",!0)&&(null!==this.data&&(!(this.data.end_date&&new Date(this.data.end_date)<=new Date)&&(!1!==this.data.is_active&&null===this.settings)))}get __isFrequencyVisible(){if(this.hiddenSelector.matches("frequency",!0))return!1;if(null===this.data)return!1;if(this.data.end_date&&new Date(this.data.end_date).getTime()<=Date.now())return!1;if(!1===this.data.is_active)return!1;if(null===this.settings)return!0;return!p({subscription:this.data,settings:this.settings}).next().done}get __frequencies(){if(!this.settings||!this.data)return[".5m","1m","1y"];const e=p({subscription:this.data,settings:this.settings});return Array.from(e)}get __currencyCode(){var e,t,a,s;const i=this.__transactionTemplate;if(null==i?void 0:i.currency_code)return i.currency_code;const r=this.__localeCodesHelper,n=null===(t=null!==(e=this.__templateSet)&&void 0!==e?e:this.__defaultTemplateSet)||void 0===t?void 0:t.locale_code,o=n?null==r?void 0:r.values[n]:void 0;return o&&null!==(s=null===(a=/Currency: ([A-Z]{3})/g.exec(o))||void 0===a?void 0:a[1])&&void 0!==s?s:null}get __currencyDisplay(){var e;return(null===(e=this.__store)||void 0===e?void 0:e.use_international_currency_symbol)?"code":"symbol"}}customElements.define("foxy-subscription-form",I);export{I as SubscriptionForm};
1
+ import"./shared-9b2d6d62.js";import"./shared-0a6a28ce.js";import"./shared-6e859df6.js";import"./shared-56bf05ef.js";import"./shared-90a47948.js";import{I as e}from"./shared-0e055562.js";import"./shared-388e9240.js";import"./shared-c388e926.js";import"./shared-0f67d020.js";import"./shared-51c4a6dd.js";import"./foxy-transaction-card.js";import"./foxy-nucleon-element.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-customer-card.js";import"./foxy-item-card.js";import"./shared-37efab30.js";import{_ as t,B as a}from"./shared-0f6e4584.js";import"./shared-b08ca8d0.js";import"./shared-029d623b.js";import{h as s}from"./shared-dc73b9a5.js";import{S as i,R as r,a as n}from"./shared-fb34e84c.js";import{c as o}from"./shared-4e709717.js";import{C as d}from"./shared-f11b2116.js";import"./shared-fc1dfa64.js";import{S as l}from"./shared-d1c10d58.js";import{G as c}from"./shared-a49a2300.js";import"./shared-8f3398dc.js";import"./shared-19884cf4.js";import"./shared-c2776a33.js";import"./shared-a207423c.js";import"./shared-453d8f75.js";import"./shared-4b346553.js";import{p as u}from"./shared-f34aeb6c.js";import{s as m}from"./shared-79d0699c.js";import{i as h}from"./shared-9803aa7c.js";import{p as f}from"./shared-01b2cad8.js";import{j as _}from"./shared-6d645dc5.js";import"./shared-44ce656d.js";import"./shared-09b4185a.js";import"./shared-280f868d.js";import"./shared-e24da82e.js";import"./shared-651c44fa.js";import"./shared-b8198665.js";import"./shared-61ade33e.js";import"./shared-f2968508.js";import"./shared-d8c3067b.js";import"./shared-7d38cb8a.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-6474675f.js";import"./shared-ee36b83f.js";import"./shared-6918312e.js";import"./foxy-copy-to-clipboard.js";import"./foxy-spinner.js";import"./shared-bab2ea2c.js";import"./shared-61b6ef6e.js";import"./foxy-collection-page.js";import"./shared-a0c6a159.js";import"./shared-99940888.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./foxy-pagination.js";import"./shared-d132bd37.js";import"./shared-43e2c3f6.js";import"./shared-3ee151ce.js";import"./shared-f3773d62.js";import"./shared-f407c2cb.js";import"./shared-21bc5d5e.js";import"./shared-6ac0d05e.js";import"./shared-ac0368ec.js";import"./shared-245f8836.js";import"./shared-16c17e32.js";import"./shared-da9e048f.js";import"./shared-56a559fd.js";function p(e){return function*(e){const t=[];for(const a of e.settings.subscriptions.allowFrequencyModification)if(_(a.jsonataQuery).evaluate(e.subscription))for(const e of a.values)!t.includes(e)&&(t.push(e),yield e)}({settings:{subscriptions:{allowFrequencyModification:e.settings.subscriptions.allow_frequency_modification.map((e=>({jsonataQuery:e.jsonata_query,values:e.values})))}},subscription:e.subscription})}class y extends Error{constructor(e){super(`Invalid frequency "${e}".`)}}function v(e){const t=864e5,a=31*t;if(".5m"===e)return a/2;const s=parseInt(e.substring(0,e.length-1));if(isNaN(s))throw new y(e);if(e.endsWith("y"))return 31536e6*s;if(e.endsWith("m"))return s*a;if(e.endsWith("w"))return 6048e5*s;if(e.endsWith("d"))return s*t;throw new y(e)}function x(e,t){if("boolean"==typeof t)return t;const a=t.filter((t=>Boolean(_(t.jsonataQuery).evaluate(e)))).reduce(((e,t)=>{var a,s,i,r,n;if(t.min){const a=e.min?v(e.min):1/0;v(t.min)<a&&(e.min=t.min)}if(t.max){const a=e.max?v(e.max):-1/0;v(t.max)>a&&(e.max=t.max)}if("day"===(null===(a=t.allowedDays)||void 0===a?void 0:a.type)){const a=[...null!==(s=e.allowedDaysOfWeek)&&void 0!==s?s:[],...t.allowedDays.days];e.allowedDaysOfWeek=Array.from(new Set(a))}if("month"===(null===(i=t.allowedDays)||void 0===i?void 0:i.type)){const a=[...null!==(r=e.allowedDaysOfMonth)&&void 0!==r?r:[],...t.allowedDays.days];e.allowedDaysOfMonth=Array.from(new Set(a))}if(t.disallowedDates){const a=[...null!==(n=e.disallowedDates)&&void 0!==n?n:[],...t.disallowedDates];e.disallowedDates=Array.from(new Set(a))}return e}),{});return 0!==Object.keys(a).length&&a}function g(e){const[t,a,s]=e.split("-").map((e=>parseInt(e)));return new Date(t,a-1,s)}function b(e){const t=e.settings.subscriptions.allow_next_date_modification;let a;return a="boolean"==typeof t?t:t.map((e=>({allowedDays:e.allowed_days,disallowedDates:e.disallowed_dates,jsonataQuery:e.jsonata_query,max:e.max,min:e.min}))),function(e){var t,a;const s=g(e.value),i=s.getTime(),r=x(e.subscription,e.settings.subscriptions.allowNextDateModification);if("boolean"==typeof r)return r;if(!1===(null===(t=r.allowedDaysOfMonth)||void 0===t?void 0:t.includes(s.getDate())))return!1;if(!1===(null===(a=r.allowedDaysOfWeek)||void 0===a?void 0:a.includes(s.getDay())))return!1;if(r.disallowedDates&&r.disallowedDates.find((e=>{const[t,a]=e.split("..").map((e=>g(e).getTime()));return i===t||void 0!==a&&i>=t&&i<=a})))return!1;if(r.min){const e=f(r.min);if(null!==e&&Date.now()+e>=i)return!1}if(r.max){const e=f(r.max);if(null!==e&&Date.now()+e<=i)return!1}return!0}({settings:{subscriptions:{allowNextDateModification:a}},subscription:e.subscription,value:e.value})}let $,j,D,w,S,T,q,E,k,H,C,L=e=>e;const A=i(r(n(e,"subscription-form")));class I extends A{constructor(){super(...arguments),this.getTransactionPageHref=(e,t)=>null==t?void 0:t._links["fx:receipt"].href,this.getCustomerPageHref=null,this.customerAddresses=null,this.itemCategories=null,this.localeCodes=null,this.settings=null,this.coupons=null,this.__transactionTemplateLoaderId="transactionTemplateLoader",this.__defaultTemplateSetLoaderId="defaultTemplateSetLoader",this.__localeCodesHelperLoaderId="localeCodesLoader",this.__templateSetLoaderId="templateSetLoader",this.__storeLoaderId="storeLoader",this.__renderItemsActions=()=>s($||($=L` <div class="flex" data-testid="items:actions"> ${0} <foxy-i18n data-testid="items:actions-label" class="flex-1 text-s font-medium text-secondary" lang="${0}" key="item_plural" ns="${0}"> </foxy-i18n> ${0} </div> `),this.renderTemplateOrSlot("items:actions:before"),this.lang,this.ns,this.renderTemplateOrSlot("items:actions:after")),this.__renderItems=()=>{var e;let t;try{const a=this.__transactionTemplate,s=new URL(null!==(e=null==a?void 0:a._links["fx:items"].href)&&void 0!==e?e:"");s.searchParams.set("zoom","item_options"),t=s.toString()}catch(e){t=void 0}return s(j||(j=L` <div data-testid="items" class="space-y-xs sm-col-span-2"> ${0} <foxy-internal-async-list-control first="${0}" infer="items" item="foxy-item-card" .itemProps="${0}"> </foxy-internal-async-list-control> </div> `),this.hiddenSelector.matches("items:actions",!0)?"":this.__renderItemsActions(),h(t),{"locale-codes":this.localeCodes})},this.__renderEndDate=()=>{var e;const{data:t,lang:a,ns:i}=this;return s(D||(D=L` <div data-testid="end-date"> ${0} <x-group frame> <foxy-i18n key="end_date" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <foxy-internal-calendar start="${0}" value="${0}" lang="${0}" ?readonly="${0}" ?disabled="${0}" .checkAvailability="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("end-date:before"),i,a,h(null===(e=null==t?void 0:t.end_date)||void 0===e?void 0:e.substr(0,10)),h(null==t?void 0:t.end_date),a,!this.__isEndDateEditable,this.disabledSelector.matches("end-date",!0),this.__checkEndDateAvailability,(e=>{const t=e.target;this.edit({end_date:t.value})}),this.renderTemplateOrSlot("end-date:after"))},this.__checkNextTransactionDateAvailability=e=>{const{settings:t,data:a}=this;if(t&&a){return b({value:m(e),settings:t,subscription:a})}return e.getTime()>=Date.now()},this.__checkStartDateAvailability=e=>e.getTime()>=Date.now(),this.__checkEndDateAvailability=e=>{const t=new Date;return t.setDate(t.getDate()+1),t.setHours(0,0,0,0),e.getTime()>=t.getTime()},this.__renderStartDate=()=>{const{data:e,lang:t,ns:a}=this;return s(w||(w=L` <div data-testid="start-date"> ${0} <x-group frame> <foxy-i18n key="start_date" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <foxy-internal-calendar start="${0}" value="${0}" lang="${0}" ?readonly="${0}" ?disabled="${0}" .checkAvailability="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("start-date:before"),a,t,h(null==e?void 0:e.start_date.substr(0,10)),h(null==e?void 0:e.start_date),t,!this.__isStartDateEditable,this.disabledSelector.matches("start-date",!0),this.__checkStartDateAvailability,(e=>{const t=e.target;this.edit({start_date:t.value})}),this.renderTemplateOrSlot("start-date:after"))},this.__renderNextTransactionDate=()=>{const{data:e,lang:t,ns:a}=this,i=!!(null==e?void 0:e.is_active);return s(S||(S=L` <div data-testid="next-transaction-date"> ${0} <x-group frame> <foxy-i18n key="next_transaction_date" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <foxy-internal-calendar start="${0}" value="${0}" lang="${0}" ?readonly="${0}" ?disabled="${0}" .checkAvailability="${0}" @change="${0}"> </foxy-internal-calendar> </x-group> ${0} </div> `),this.renderTemplateOrSlot("next-transaction-date:before"),a,t,h(null==e?void 0:e.next_transaction_date.substr(0,10)),h(null==e?void 0:e.next_transaction_date),t,!i||this.readonlySelector.matches("next-transaction-date",!0),!e||this.disabledSelector.matches("next-transaction-date",!0),this.__checkNextTransactionDateAvailability,(e=>{const t=e.target;this.edit({next_transaction_date:t.value})}),this.renderTemplateOrSlot("next-transaction-date:after"))},this.__renderFrequencyAsDropdown=()=>{const{data:e}=this,t=!!(null==e?void 0:e.is_active),a=this.__frequencies.map((e=>({label:this.t(".5m"===e?"twice_a_month":"frequency",u(e)),value:e})));return s(T||(T=L` <vaadin-combo-box item-value-path="value" item-label-path="label" data-testid="frequency" ?disabled="${0}" ?readonly="${0}" class="w-full" label="${0}" value="${0}" .items="${0}" @change="${0}"> </vaadin-combo-box> `),!e||this.disabledSelector.matches("frequency",!0),e&&(!t||this.readonlySelector.matches("frequency",!0)),this.t("frequency_label").toString(),h(this.form.frequency),a,(e=>{this.edit({frequency:e.target.value})}))},this.__renderFrequencyAsRadioList=()=>{var e;const{data:t,lang:a,ns:i}=this;return s(q||(q=L` <x-group frame> <foxy-i18n key="frequency_label" ns="${0}" lang="${0}" slot="header"></foxy-i18n> <x-choice default-custom-value="1d" data-testid="frequency" type="frequency" ns="${0}" ?custom="${0}" .items="${0}" .value="${0}" ?disabled="${0}" ?readonly="${0}" @change="${0}"> ${0} </x-choice> </x-group> `),i,a,i,null===this.settings,this.__frequencies,null!==(e=this.form.frequency)&&void 0!==e?e:null,!t||this.disabledSelector.matches("frequency",!0),t&&(!t.is_active||this.readonlySelector.matches("frequency",!0)),(e=>{this.edit({frequency:e.target.value})}),this.__frequencies.map((e=>s(E||(E=L` <foxy-i18n options="${0}" slot="${0}-label" lang="${0}" key="${0}" ns="${0}"> </foxy-i18n> `),JSON.stringify(u(e)),e,a,".5m"===e?"twice_a_month":"frequency",i))))},this.__renderFrequency=()=>s(k||(k=L` <div class="sm-col-span-2"> ${0} ${0} ${0} </div> `),this.renderTemplateOrSlot("frequency:before"),this.settings&&this.__frequencies.length>4?this.__renderFrequencyAsDropdown():this.__renderFrequencyAsRadioList(),this.renderTemplateOrSlot("frequency:after")),this.__renderCustomer=()=>{var e,t;const a=null===(e=this.data)||void 0===e?void 0:e._links["fx:customer"].href,i=a?null===(t=this.getCustomerPageHref)||void 0===t?void 0:t.call(this,a):void 0;return s(H||(H=L` <div data-testid="customer" class="sm-col-span-2"> ${0} <foxy-i18n infer="customer" class="block text-s font-medium leading-xs mb-xs" key="label"> </foxy-i18n> <a class="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" href="${0}"> <foxy-customer-card infer="customer" href="${0}"></foxy-customer-card> </a> ${0} </div> `),this.renderTemplateOrSlot("customer:before"),o({"block rounded transition-colors":!0,"ring-1 ring-contrast-10":!i,"cursor-pointer bg-contrast-5 hover-bg-contrast-10":!!i,"focus-outline-none focus-ring-2 focus-ring-primary-50":!!i}),h(i),h(a),this.renderTemplateOrSlot("customer:after"))}}static get scopedElements(){return{"foxy-internal-timestamps-control":customElements.get("foxy-internal-timestamps-control"),"foxy-internal-async-list-control":customElements.get("foxy-internal-async-list-control"),"foxy-internal-number-control":customElements.get("foxy-internal-number-control"),"foxy-internal-submit-control":customElements.get("foxy-internal-submit-control"),"foxy-internal-delete-control":customElements.get("foxy-internal-delete-control"),"foxy-internal-undo-control":customElements.get("foxy-internal-undo-control"),"foxy-copy-to-clipboard":customElements.get("foxy-copy-to-clipboard"),"foxy-internal-calendar":customElements.get("foxy-internal-calendar"),"foxy-internal-sandbox":customElements.get("foxy-internal-sandbox"),"foxy-customer-card":customElements.get("foxy-customer-card"),"vaadin-combo-box":customElements.get("vaadin-combo-box"),"foxy-spinner":customElements.get("foxy-spinner"),"foxy-nucleon":customElements.get("foxy-nucleon"),"vcf-tooltip":customElements.get("vcf-tooltip"),"foxy-i18n":customElements.get("foxy-i18n"),"iron-icon":customElements.get("iron-icon"),"x-skeleton":l,"x-choice":d,"x-group":c}}static get properties(){return t(t({},super.properties),{},{getTransactionPageHref:{attribute:!1},getCustomerPageHref:{attribute:!1},customerAddresses:{attribute:"customer-addresses"},itemCategories:{attribute:"item-categories"},localeCodes:{attribute:"locale-codes"},settings:{type:Object},coupons:{}})}get hiddenSelector(){return new a(`items:pagination:card:autorenew-icon ${super.hiddenSelector}`)}get headerTitleOptions(){if(this.data&&this.__currencyCode){const e=u(this.data.frequency),a=this.__transactionTemplate,s=`${null==a?void 0:a.total_order} ${this.__currencyCode}`,i=this.__currencyDisplay,r=this.__currencyCode?".5m"===this.data.frequency?"twice_a_month":"recurring":"existing";return t(t({},e),{},{amount:s,currencyDisplay:i,context:r})}return{}}get headerSubtitleOptions(){var e,t,a;let s,i=null;if(null===(e=this.data)||void 0===e?void 0:e.first_failed_transaction_date)s="failed",i=this.data.first_failed_transaction_date;else if(null===(t=this.data)||void 0===t?void 0:t.end_date){s=new Date(this.data.end_date).getTime()>Date.now()?"will_be_cancelled":"cancelled",i=this.data.end_date}else(null===(a=this.data)||void 0===a?void 0:a.is_active)?new Date(this.data.start_date)>new Date?(s="will_be_active",i=this.data.start_date):(s="active",i=this.data.next_transaction_date):s="inactive";return{date:i,context:s}}renderBody(){var e,t,a,i,r;let n;try{const a=new URL(null!==(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:transactions"].href)&&void 0!==t?t:"");a.searchParams.set("order","transaction_date desc"),a.searchParams.set("zoom","items"),n=a.toString()}catch(e){n=void 0}return s(C||(C=L` ${0} <div class="relative grid grid-cols-1 sm-grid-cols-2 gap-l"> <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> <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> ${0} ${0} ${0} ${0} ${0} ${0} <foxy-internal-number-control suffix="${0}" infer="past-due-amount" class="sm-col-span-2" min="0"> </foxy-internal-number-control> <foxy-internal-async-list-control first="${0}" class="sm-col-span-2" infer="attributes" limit="5" form="foxy-attribute-form" item="foxy-attribute-card"> </foxy-internal-async-list-control> <foxy-internal-async-list-control first="${0}" class="sm-col-span-2" infer="transactions" limit="5" item="foxy-transaction-card" hide-delete-button .getPageHref="${0}"> </foxy-internal-async-list-control> <foxy-internal-timestamps-control infer="timestamps" class="sm-col-span-2"> </foxy-internal-timestamps-control> </div> `),this.renderHeader(),h(this.__transactionTemplateHref),this.__transactionTemplateLoaderId,(()=>this.requestUpdate()),h(this.__defaultTemplateSetHref),this.__defaultTemplateSetLoaderId,(()=>this.requestUpdate()),h(this.__localeCodesHelperHref),this.__localeCodesHelperLoaderId,(()=>this.requestUpdate()),h(this.__templateSetHref),this.__templateSetLoaderId,(()=>this.requestUpdate()),h(this.__storeHref),this.__storeLoaderId,(()=>this.requestUpdate()),this.hiddenSelector.matches("customer",!0)?"":this.__renderCustomer(),this.hiddenSelector.matches("items",!0)?"":this.__renderItems(),this.__isFrequencyVisible?this.__renderFrequency():"",this.__isStartDateVisible?this.__renderStartDate():"",this.__isNextTransactionDateVisible?this.__renderNextTransactionDate():"",this.__isEndDateVisible?this.__renderEndDate():"",h(null!==(a=this.__currencyCode)&&void 0!==a?a:void 0),h(null===(r=null===(i=this.data)||void 0===i?void 0:i._links["fx:attributes"])||void 0===r?void 0:r.href),h(n),this.getTransactionPageHref)}get __transactionTemplateHref(){var e;const t=this.data;return(null===(e=null==t?void 0:t._embedded)||void 0===e?void 0:e["fx:transaction_template"])||null==t?void 0:t._links["fx:transaction_template"].href}get __defaultTemplateSetHref(){var e,t,a;if(""===(null===(e=this.__transactionTemplate)||void 0===e?void 0:e.template_set_uri))try{const e=new URL(null!==(a=null===(t=this.__store)||void 0===t?void 0:t._links["fx:template_sets"].href)&&void 0!==a?a:"");return e.searchParams.set("code","DEFAULT"),e.toString()}catch(e){}}get __localeCodesHelperHref(){var e;if(this.__defaultTemplateSetHref||this.__templateSetHref)return null!==(e=this.localeCodes)&&void 0!==e?e:void 0}get __templateSetHref(){const e=this.__transactionTemplate;if(!(null==e?void 0:e.currency_code))return(null==e?void 0:e.template_set_uri)||void 0}get __storeHref(){var e,t;return null===(t=null===(e=this.data)||void 0===e?void 0:e._links["fx:store"])||void 0===t?void 0:t.href}get __transactionTemplate(){var e,t,a;const s=this.data,i=null===(e=null==s?void 0:s._embedded)||void 0===e?void 0:e["fx:transaction_template"],r=`#${this.__transactionTemplateLoaderId}`;return null!==(a=null!=i?i:null===(t=this.renderRoot.querySelector(r))||void 0===t?void 0:t.data)&&void 0!==a?a:null}get __defaultTemplateSet(){var e,t;const a=`#${this.__defaultTemplateSetLoaderId}`,s=this.renderRoot.querySelector(a);return null!==(t=null===(e=null==s?void 0:s.data)||void 0===e?void 0:e._embedded["fx:template_sets"][0])&&void 0!==t?t:null}get __localeCodesHelper(){var e,t;const a=`#${this.__localeCodesHelperLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(a))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __templateSet(){var e,t;const a=`#${this.__templateSetLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(a))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __store(){var e,t;const a=`#${this.__storeLoaderId}`;return null!==(t=null===(e=this.renderRoot.querySelector(a))||void 0===e?void 0:e.data)&&void 0!==t?t:null}get __isNextTransactionDateVisible(){if(this.hiddenSelector.matches("next-transaction-date",!0))return!1;if(null===this.data)return!1;if(this.data.end_date&&new Date(this.data.end_date).getTime()<=Date.now())return!1;if(!1===this.data.is_active)return!1;if(null===this.settings)return!0;const e=this.settings.subscriptions.allow_next_date_modification;return!!function(e,t){let a;return a="boolean"==typeof t?t:t.map((e=>({allowedDays:e.allowed_days,disallowedDates:e.disallowed_dates,jsonataQuery:e.jsonata_query,max:e.max,min:e.min}))),x(e,a)}(this.data,e)}get __isStartDateVisible(){return!this.hiddenSelector.matches("start-date",!0)&&this.__isNextTransactionDateVisible}get __isEndDateVisible(){return!this.hiddenSelector.matches("end-date",!0)&&(null!==this.data&&(!(this.data.end_date&&new Date(this.data.end_date).getTime()<=Date.now())&&(!1!==this.data.is_active&&!this.settings)))}get __isStartDateEditable(){return!this.readonlySelector.matches("start-date",!0)&&(null!==this.data&&(!(this.data.end_date&&new Date(this.data.end_date)<=new Date)&&(!1!==this.data.is_active&&(!(this.data.start_date&&new Date(this.data.start_date)<=new Date)&&null===this.settings))))}get __isEndDateEditable(){return!this.readonlySelector.matches("end-date",!0)&&(null!==this.data&&(!(this.data.end_date&&new Date(this.data.end_date)<=new Date)&&(!1!==this.data.is_active&&null===this.settings)))}get __isFrequencyVisible(){if(this.hiddenSelector.matches("frequency",!0))return!1;if(null===this.data)return!1;if(this.data.end_date&&new Date(this.data.end_date).getTime()<=Date.now())return!1;if(!1===this.data.is_active)return!1;if(null===this.settings)return!0;return!p({subscription:this.data,settings:this.settings}).next().done}get __frequencies(){if(!this.settings||!this.data)return[".5m","1m","1y"];const e=p({subscription:this.data,settings:this.settings});return Array.from(e)}get __currencyCode(){var e,t,a,s;const i=this.__transactionTemplate;if(null==i?void 0:i.currency_code)return i.currency_code;const r=this.__localeCodesHelper,n=null===(t=null!==(e=this.__templateSet)&&void 0!==e?e:this.__defaultTemplateSet)||void 0===t?void 0:t.locale_code,o=n?null==r?void 0:r.values[n]:void 0;return o&&null!==(s=null===(a=/Currency: ([A-Z]{3})/g.exec(o))||void 0===a?void 0:a[1])&&void 0!==s?s:null}get __currencyDisplay(){var e;return(null===(e=this.__store)||void 0===e?void 0:e.use_international_currency_symbol)?"code":"symbol"}}customElements.define("foxy-subscription-form",I);export{I as SubscriptionForm};
@@ -1 +1 @@
1
- import"./foxy-billing-address-card.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-custom-field-form.js";import"./foxy-custom-field-card.js";import"./foxy-copy-to-clipboard.js";import"./foxy-nucleon-element.js";import"./foxy-shipment-card.js";import"./foxy-payment-card.js";import"./foxy-webhook-card.js";import"./foxy-webhook-form.js";import"./foxy-item-card.js";import"./foxy-item-form.js";import"./shared-37efab30.js";import"./shared-388e9240.js";import"./shared-8cd578ee.js";import"./shared-937b497c.js";import{I as t}from"./shared-0e055562.js";import"./shared-6e859df6.js";import"./shared-6918312e.js";import{a as e}from"./shared-7d38cb8a.js";import{_ as o,B as i}from"./shared-0f6e4584.js";import{h as r,s}from"./shared-dc73b9a5.js";import{N as n}from"./shared-24d71d01.js";import"./foxy-customer-card.js";import"./foxy-swipe-actions.js";import"./foxy-spinner.js";import{g as a}from"./shared-bab2ea2c.js";import{i as d}from"./shared-9803aa7c.js";import{c as l}from"./shared-4e709717.js";import{R as c,a as u}from"./shared-fb34e84c.js";import"./shared-3ee151ce.js";import"./shared-f3773d62.js";import"./shared-56bf05ef.js";import"./shared-90a47948.js";import"./shared-44ce656d.js";import"./shared-51c4a6dd.js";import"./shared-0b01f721.js";import"./shared-343d1fd7.js";import"./shared-f7a1193f.js";import"./shared-c286c5ad.js";import"./shared-cd96ff03.js";import"./shared-522a172d.js";import"./shared-12a7a15d.js";import"./shared-6474675f.js";import"./shared-ee36b83f.js";import"./shared-f407c2cb.js";import"./shared-b08ca8d0.js";import"./shared-09b4185a.js";import"./shared-61ade33e.js";import"./shared-a207423c.js";import"./shared-21bc5d5e.js";import"./shared-a0c6a159.js";import"./shared-fc1dfa64.js";import"./shared-9b2d6d62.js";import"./shared-029d623b.js";import"./shared-0cc5420d.js";import"./shared-61b6ef6e.js";import"./shared-fb0ca5e2.js";import"./shared-6ac0d05e.js";import"./shared-2bf89a21.js";import"./shared-dfc33ff6.js";import"./shared-2a5c89a4.js";import"./shared-4b346553.js";import"./shared-b8198665.js";import"./shared-8f3398dc.js";import"./shared-08e0a194.js";import"./shared-22ba9566.js";import"./foxy-webhook-status-card.js";import"./foxy-webhook-log-card.js";import"./shared-f34aeb6c.js";import"./shared-e778071b.js";import"./foxy-form-dialog.js";import"./shared-99940888.js";import"./shared-5a2f398c.js";import"./shared-d132bd37.js";import"./shared-ac0368ec.js";import"./shared-16c17e32.js";import"./shared-0a6a28ce.js";import"./shared-280f868d.js";import"./shared-c2776a33.js";import"./shared-e24da82e.js";import"./shared-19884cf4.js";import"./shared-651c44fa.js";import"./shared-f2968508.js";import"./shared-d8c3067b.js";import"./shared-c388e926.js";import"./shared-638468a5.js";import"./shared-0700fd80.js";import"./shared-56a559fd.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-category-card.js";import"./foxy-discount-builder.js";import"./shared-8438d4ca.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./foxy-collection-page.js";import"./foxy-pagination.js";let f,p=t=>t;customElements.define("foxy-internal-transaction-post-action-control",class extends e{constructor(){super(...arguments),this.theme=null,this.href=null,this.__state="idle"}static get properties(){return o(o({},super.properties),{},{__state:{type:String},theme:{type:String},href:{type:String}})}renderControl(){const t=this.__state,e="fail"===t?"error":"idle"===t?this.theme:"";return r(f||(f=p` <foxy-internal-confirm-dialog header="header" infer="confirm" id="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> <vaadin-button theme="${0} tertiary-inline" ?disabled="${0}" @click="${0}"> <foxy-i18n key="${0}" infer=""></foxy-i18n> </vaadin-button> `),(t=>!t.detail.cancelled&&this.__submit()),e,"busy"===t||this.disabled,(t=>{this.renderRoot.querySelector("#confirm").show(t.currentTarget)}),t)}async __submit(){var t;if("busy"!==this.__state)try{this.__state="busy";const e=new n.API(this),o=await e.fetch(null!==(t=this.href)&&void 0!==t?t:"",{method:"POST"});this.__state=o.ok?"idle":"fail",o.ok&&this.dispatchEvent(new CustomEvent("done"))}catch(t){this.__state="fail"}}});let m,h,_,y,v=t=>t;customElements.define("foxy-internal-transaction-customer-control",class extends e{constructor(){super(...arguments),this.__copyEmailState="idle",this.__copyIdState="idle"}static get properties(){return o(o({},super.properties),{},{__copyEmailState:{attribute:!1},__copyIdState:{attribute:!1}})}renderControl(){var t,e,o,i;const n=this.nucleon,c=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t._links["fx:customer"].href,u=c?null===(e=null==n?void 0:n.getCustomerPageHref)||void 0===e?void 0:e.call(n,c):void 0;return r(m||(m=v` <foxy-i18n infer="" class="block text-s font-medium leading-xs mb-xs" key="label"> </foxy-i18n> <foxy-swipe-actions> <a class="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" href="${0}"> <foxy-customer-card infer="" href="${0}"></foxy-customer-card> </a> <div class="h-full grid grid-cols-2 gap-s ml-s" slot="action"> ${0} ${0} </div> </foxy-swipe-actions> `),l({"block ring-inset rounded transition-colors":!0,"ring-1 ring-contrast-10":!u,"cursor-pointer bg-contrast-5 hover-bg-contrast-10":!!u,"focus-outline-none focus-ring-2 focus-ring-primary-50":!!u}),d(u),d(c),this.__renderCopyAction(s(h||(h=v`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.2rem; height: 1.2rem"><path fill-rule="evenodd" d="M9.493 2.852a.75.75 0 0 0-1.486-.204L7.545 6H4.198a.75.75 0 0 0 0 1.5h3.14l-.69 5H3.302a.75.75 0 0 0 0 1.5h3.14l-.435 3.148a.75.75 0 0 0 1.486.204L7.955 14h2.986l-.434 3.148a.75.75 0 0 0 1.486.204L12.456 14h3.346a.75.75 0 0 0 0-1.5h-3.14l.69-5h3.346a.75.75 0 0 0 0-1.5h-3.14l.435-3.148a.75.75 0 0 0-1.486-.204L12.045 6H9.059l.434-3.148ZM8.852 7.5l-.69 5h2.986l.69-5H8.852Z" clip-rule="evenodd" /></svg>`)),"copy_id_caption","__copyIdState",c?String(a(c)):""),this.__renderCopyAction(s(_||(_=v`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.2rem; height: 1.2rem"><path fill-rule="evenodd" d="M5.404 14.596A6.5 6.5 0 1 1 16.5 10a1.25 1.25 0 0 1-2.5 0 4 4 0 1 0-.571 2.06A2.75 2.75 0 0 0 18 10a8 8 0 1 0-2.343 5.657.75.75 0 0 0-1.06-1.06 6.5 6.5 0 0 1-9.193 0ZM10 7.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z" clip-rule="evenodd" /></svg>`)),"copy_email_caption","__copyEmailState",null!==(i=null===(o=null==n?void 0:n.data)||void 0===o?void 0:o.customer_email)&&void 0!==i?i:""))}__renderCopyAction(t,e,o,i){const s=this[o],n="fail"===s?"error":"done"===s?"end":"busy";return r(y||(y=v` <button class="relative transition-colors bg-contrast-5 text-body hover-bg-contrast-10 rounded h-full py-0 px-m focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50" ?disabled="${0}" @click="${0}" @focusout="${0}" @mouseout="${0}"> <div class="${0}"> ${0} <foxy-i18n class="mt-xs text-s font-medium leading-none" infer="" key="${0}"> </foxy-i18n> </div> <div class="${0}"> <foxy-spinner layout="no-label" state="${0}" infer="spinner"> </foxy-spinner> </div> </button> `),"idle"!==s,(()=>"idle"===s&&this.__copy(i,o)),(t=>"idle"!==s&&t.stopPropagation()),(t=>"idle"!==s&&t.stopPropagation()),l({"relative flex flex-col items-center justify-center transition-opacity":!0,"opacity-0":"idle"!==s}),t,e,l({"absolute inset-0 flex items-center justify-center transition-opacity":!0,"opacity-0":"idle"===s}),n)}async __copy(t,e){this[e]="busy";try{await navigator.clipboard.writeText(t),this[e]="done"}catch(t){this[e]="fail"}setTimeout((()=>this[e]="idle"),3e3)}});let x,b,g,j,w,$,k=t=>t;customElements.define("foxy-internal-transaction-actions-control",class extends e{renderControl(){var t,e,o,i,s,n,a,d,l,c;return r(x||(x=k` <div class="flex flex-wrap gap-x-m gap-y-xs"> ${0} ${0} ${0} ${0} ${0} </div> `),(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:capture"])?this.__renderCaptureAction():"",(null===(i=null===(o=this.nucleon)||void 0===o?void 0:o.data)||void 0===i?void 0:i._links["fx:void"])?this.__renderVoidAction():"",(null===(n=null===(s=this.nucleon)||void 0===s?void 0:s.data)||void 0===n?void 0:n._links["fx:refund"])?this.__renderRefundAction():"",(null===(d=null===(a=this.nucleon)||void 0===a?void 0:a.data)||void 0===d?void 0:d._links["fx:send_emails"])?this.__renderSendEmailsAction():"",(null===(c=null===(l=this.nucleon)||void 0===l?void 0:l.data)||void 0===c?void 0:c._links["fx:subscription"])?this.__renderSubscriptionAction():"")}__renderSendEmailsAction(){var t,e;return r(b||(b=k` <foxy-internal-transaction-post-action-control infer="send-emails" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:send_emails"].href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderCaptureAction(){var t,e;return r(g||(g=k` <foxy-internal-transaction-post-action-control theme="success" infer="capture" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:capture"].href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderVoidAction(){var t,e,o;return r(j||(j=k` <foxy-internal-transaction-post-action-control theme="error" infer="void" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(o=null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:void"])||void 0===o?void 0:o.href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderRefundAction(){var t,e,o;return r(w||(w=k` <foxy-internal-transaction-post-action-control infer="refund" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(o=null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:refund"])||void 0===o?void 0:o.href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderSubscriptionAction(){var t,e,o;const i=this.nucleon,s=null===(e=null===(t=null==i?void 0:i.data)||void 0===t?void 0:t._links["fx:subscription"])||void 0===e?void 0:e.href,n=s?null===(o=null==i?void 0:i.getSubscriptionPageHref)||void 0===o?void 0:o.call(i,s):void 0;return r($||($=k` <a class="rounded text-m font-medium text-primary cursor-pointer transition-opacity hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n infer="subscription" key="caption"></foxy-i18n> </a> `),d(n))}});let S,P,A,C,H,L,E,I,R,B,q=t=>t;customElements.define("foxy-internal-transaction-summary-control",class extends e{constructor(){super(...arguments),this.__storeLoaderId="storeLoader"}renderControl(){var t,e,o,i,s,n,a,l,c;const u=null===(t=this.nucleon)||void 0===t?void 0:t.data;if(!u)return r(S||(S=q``));const f=null!==(o=null===(e=null==u?void 0:u._embedded)||void 0===e?void 0:e["fx:applied_taxes"])&&void 0!==o?o:[],p=null!==(s=null===(i=u._embedded)||void 0===i?void 0:i["fx:shipments"])&&void 0!==s?s:[];return r(P||(P=q` <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <p class="grid gap-x-s text-right text-s leading-m border-dashed border rounded border-contrast-20 whitespace-nowrap overflow-auto" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 2px);grid-template-columns:1fr min-content"> <span><foxy-i18n key="subtotal" infer=""></foxy-i18n>&colon;</span> <span>${0}</span> ${0} ${0} ${0} ${0} <span class="col-span-2 border-t border-dashed border-contrast-20 my-s"></span> <span class="col-span-2 flex gap-s justify-between items-center"> ${0} <span class="text-xl font-medium leading-xs"> <foxy-i18n infer="" key="total"></foxy-i18n>&colon; ${0} </span> </span> </p> `),d(this.__storeHref),this.__storeLoaderId,(()=>this.requestUpdate()),this.__renderPrice(u.total_item_price),0===p.length||0===u.total_shipping?r(A||(A=q` <span><foxy-i18n infer="" key="total_shipping"></foxy-i18n>&colon;</span> <span>${0} </span> `),this.__renderPrice(u.total_shipping,!0)):p.map((t=>r(C||(C=q` <span>${0}&colon;</span> <span>${0}</span> `),t.shipping_service_description,this.__renderPrice(t.total_shipping,!0)))),0===f.length||0===u.total_tax?r(H||(H=q` <span><foxy-i18n infer="" key="total_tax"></foxy-i18n>&colon;</span> <span>${0}</span> `),this.__renderPrice(u.total_tax,!0)):f.map((t=>r(L||(L=q` <span>${0}&colon;</span> <span>${0}</span> `),t.name,this.__renderPrice(t.amount,!0)))),null===(a=null===(n=null==u?void 0:u._embedded)||void 0===n?void 0:n["fx:applied_gift_card_codes"])||void 0===a?void 0:a.map((t=>{var e;return r(E||(E=q` <span>${0}&colon;</span> <span>${0}</span> `),t._embedded["fx:gift_card"].name,this.__renderPrice(null!==(e=t.balance_adjustment)&&void 0!==e?e:0,!0))})),null===(c=null===(l=null==u?void 0:u._embedded)||void 0===l?void 0:l["fx:discounts"])||void 0===c?void 0:c.map((t=>r(I||(I=q` <span data-testclass="discount">${0}&colon;</span> <span>${0}</span> `),t.name,this.__renderPrice(t.amount,!0)))),this.__renderStatus(),this.__renderPrice(u.total_order))}get __storeHref(){var t,e,o;return null===(o=null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:store"])||void 0===o?void 0:o.href}get __store(){var t,e;const o=`#${this.__storeLoaderId}`;return null!==(e=null===(t=this.renderRoot.querySelector(o))||void 0===t?void 0:t.data)&&void 0!==e?e:null}__renderPrice(t,e=!1){var o,i,s;const n=(null===(o=this.__store)||void 0===o?void 0:o.use_international_currency_symbol)?"code":"symbol",a=null===(s=null===(i=this.nucleon)||void 0===i?void 0:i.data)||void 0===s?void 0:s.currency_code;return r(R||(R=q` <foxy-i18n class="${0}" infer="" key="price" .options="${0}"> </foxy-i18n> `),e&&0!==t?t>0?"text-success":"text-error":"",{currencyDisplay:n,signDisplay:e?"exceptZero":"auto",amount:`${t} ${a}`})}__renderStatus(){var t,e;const o=(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e.status)||"completed";let i="";return i=["capturing","captured","approved","authorized","pending"].includes(o)?"text-success bg-success-10":o&&"completed"!==o?["problem","pending_fraud_review","rejected","declined"].includes(o)?"text-error-contrast bg-error":"bg-contrast-5 text-body":"text-success-contrast bg-success",r(B||(B=q` <foxy-i18n infer="" class="${0} rounded-s py-xs px-s font-medium text-s leading-xs" key="status_${0}"></foxy-i18n> `),i,o)}});let G,T,U,Z=t=>t;const M=c(u(t,"transaction"));class O extends M{constructor(){var t;super(...arguments),t=this,this.hostedPaymentGatewaysHelper=null,this.paymentGatewaysHelper=null,this.localeCodes=null,this.getSubscriptionPageHref=null,this.getCustomerPageHref=null,this.__webhooksBulkActions=[{name:"refeed",onClick:async function(e){if(!t.data)return;const o=t.data._links["fx:send_webhooks"].href,i=new O.API(t),r=await i.fetch(o,{method:"POST",body:JSON.stringify({refeed_hooks:e.map((t=>a(t._links.self.href))),event:"refeed"})});if(e.forEach((t=>{O.Rumour("").share({related:[...e.map((t=>t._links["fx:logs"].href)),...e.map((t=>t._links["fx:statuses"].href))],source:t._links.self.href,data:t})})),!r.ok)throw new Error(await r.text())}}]}static get properties(){return o(o({},super.properties),{},{hostedPaymentGatewaysHelper:{attribute:"hosted-payment-gateways-helper"},paymentGatewaysHelper:{attribute:"payment-gateways-helper"},getSubscriptionPageHref:{attribute:!1},getCustomerPageHref:{attribute:!1},localeCodes:{attribute:"locale-codes"}})}get readonlySelector(){var t,e,o;const r=["billing-addresses","datafeed","webhooks:dialog:url",super.readonlySelector];return Boolean(null!==(e=null===(t=this.data)||void 0===t?void 0:t._links["fx:void"])&&void 0!==e?e:null===(o=this.data)||void 0===o?void 0:o._links["fx:refund"])||r.push("items","attributes","custom-fields"),new i(r.join(" ").trim())}get hiddenSelector(){var t,e,o,r;const s=["billing-addresses:dialog:delete","billing-addresses:dialog:timestamps","webhooks:dialog:header:copy-json","webhooks:dialog:header:copy-id","webhooks:dialog:timestamps","webhooks:dialog:name","webhooks:dialog:query","webhooks:dialog:encryption-key","webhooks:dialog:delete",super.readonlySelector],n=null===(t=this.data)||void 0===t?void 0:t.type;return(null===(e=this.data)||void 0===e?void 0:e._links["fx:subscription"])||s.unshift("subscription"),"subscription_modification"===n&&s.unshift("actions"),"updateinfo"===n&&s.unshift("not=customer,subscription,payments,custom-fields,attributes"),"subscription_cancellation"===n&&s.unshift("not=customer,subscription,custom-fields,attributes"),(null===(r=null===(o=this.__storeLoader)||void 0===o?void 0:o.data)||void 0===r?void 0:r.use_webhook)||s.unshift("datafeed"),new i(s.join(" ").trim())}get headerSubtitleOptions(){var t,e,o,i,r;const s=null===(t=this.data)||void 0===t?void 0:t.source,n=null===(e=this.data)||void 0===e?void 0:e.type;let a="";return"updateinfo"===n?a=!s||(null==s?void 0:s.startsWith("cit_"))?"customer_changed_payment_method":"mit_uoe"===s?"admin_changed_payment_method_with_uoe":"mit_api"===s?"integration_changed_payment_method":"admin_changed_payment_method":"subscription_modification"===n?a=!s||(null==s?void 0:s.startsWith("cit_"))?"customer_changed_subscription":"mit_uoe"===s?"admin_changed_subscription_with_uoe":"mit_api"===s?"integration_changed_subscription":"admin_changed_subscription":"subscription_renewal"===n?"mit_recurring"===s?a="subscription_renewal_attempt":"mit_recurring_reattempt_automated"===s?a="subscription_renewal_automated_reattempt":"mit_recurring_reattempt_manual"===s&&(a="subscription_renewal_manual_reattempt"):"subscription_cancellation"===n?"cit_recurring_cancellation"===s?a="customer_canceled_subscription":"mit_recurring_cancellation"===s&&(a="admin_canceled_subscription"):(null===(o=this.data)||void 0===o?void 0:o._links["fx:subscription"])?(null==s?void 0:s.startsWith("cit_"))?a="customer_subscribed":"mit_uoe"===s?a="admin_subscribed_with_uoe":"mit_api"===s&&(a="integration_subscribed"):(null==s?void 0:s.startsWith("cit_"))?a="customer_placed_order":"mit_uoe"===s?a="admin_placed_order_with_uoe":"mit_api"===s&&(a="integration_placed_order"),{transaction_date:null===(i=this.data)||void 0===i?void 0:i.transaction_date,ip_country:null===(r=this.data)||void 0===r?void 0:r.ip_country,context:a}}get headerCopyIdValue(){var t,e,o;return null!==(o=null===(e=null===(t=this.data)||void 0===t?void 0:t.display_id)||void 0===e?void 0:e.toString())&&void 0!==o?o:""}renderHeaderActions(){return r(G||(G=Z` <foxy-internal-transaction-actions-control infer="actions"> </foxy-internal-transaction-actions-control> `))}renderBody(){var t,e,o,i,s,n,a,l,c,u,f,p,m,h,_;let y,v,x;const b=this.hiddenSelector;if(this.data)try{const o=new URL(this.data._links["fx:shipments"].href),i=new URL(null!==(e=null===(t=this.__storeLoader)||void 0===t?void 0:t.data._links["fx:webhooks"].href)&&void 0!==e?e:""),r=new URL(this.data._links["fx:items"].href);o.searchParams.set("zoom","items:item_category"),i.searchParams.set("event_resource","transaction"),r.searchParams.set("zoom","item_options"),y=o.toString(),v=i.toString(),x=r.toString()}catch(t){}return r(T||(T=Z` ${0} ${0} <foxy-internal-transaction-customer-control infer="customer"> </foxy-internal-transaction-customer-control> <div class="grid gap-s" ?hidden="${0}"> <foxy-internal-async-list-control infer="items" class="min-w-0" first="${0}" limit="10" item="foxy-item-card" form="foxy-item-form" alert wide .related="${0}" .itemProps="${0}" .formProps="${0}"> </foxy-internal-async-list-control> <foxy-internal-transaction-summary-control infer="summary" class="min-w-0"> </foxy-internal-transaction-summary-control> </div> <foxy-internal-async-list-control infer="billing-addresses" first="${0}" item="foxy-billing-address-card" form="foxy-address-form" hide-create-button hide-delete-button alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="payments" first="${0}" item="foxy-payment-card" .itemProps="${0}"> </foxy-internal-async-list-control> <div class="grid gap-m sm-grid-cols-2" ?hidden="${0}"> <foxy-internal-async-list-control infer="custom-fields" class="min-w-0" first="${0}" limit="5" form="foxy-custom-field-form" item="foxy-custom-field-card" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="attributes" class="min-w-0" first="${0}" limit="5" form="foxy-attribute-form" item="foxy-attribute-card" alert> </foxy-internal-async-list-control> </div> <foxy-internal-async-list-control infer="shipments" first="${0}" item="foxy-shipment-card"> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="webhooks" first="${0}" item="foxy-webhook-card" form="foxy-webhook-form" hide-create-button hide-delete-button alert .bulkActions="${0}" .itemProps="${0}" .formProps="${0}"> </foxy-internal-async-list-control> <foxy-internal-summary-control infer="datafeed"> <foxy-internal-switch-control infer="data-is-fed"></foxy-internal-switch-control> <foxy-internal-transaction-post-action-control infer="process-webhook" href="${0}"> </foxy-internal-transaction-post-action-control> </foxy-internal-summary-control> <foxy-nucleon class="hidden" infer="" href="${0}" id="storeLoader" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),["problem","pending_fraud_review","rejected","declined"].includes(null!==(i=null===(o=this.data)||void 0===o?void 0:o.status)&&void 0!==i?i:"")?r(U||(U=Z` <p class="leading-xs text-body rounded bg-error-10 block" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> <foxy-i18n infer="header" key="alert_status_${0}"></foxy-i18n> </p> `),null===(s=this.data)||void 0===s?void 0:s.status):"",b.matches("items",!0)&&b.matches("summary",!0),d(x),[this.href],{"locale-codes":this.localeCodes},{"item-categories":null===(a=null===(n=this.__storeLoader)||void 0===n?void 0:n.data)||void 0===a?void 0:a._links["fx:item_categories"].href,"locale-codes":this.localeCodes,store:null===(l=this.data)||void 0===l?void 0:l._links["fx:store"].href},d(null===(c=this.data)||void 0===c?void 0:c._links["fx:billing_addresses"].href),d(null===(u=this.data)||void 0===u?void 0:u._links["fx:payments"].href),{"hosted-payment-gateways-helper":this.hostedPaymentGatewaysHelper,"payment-gateways-helper":this.paymentGatewaysHelper},b.matches("custom-fields",!0)&&b.matches("attributes",!0),d(null===(f=this.data)||void 0===f?void 0:f._links["fx:custom_fields"].href),d(null===(p=this.data)||void 0===p?void 0:p._links["fx:attributes"].href),d(y),d(v),this.__webhooksBulkActions,{"resource-uri":this.href},{"resource-uri":this.href},d(null===(h=null===(m=this.data)||void 0===m?void 0:m._links["fx:process_webhook"])||void 0===h?void 0:h.href),d(null===(_=this.data)||void 0===_?void 0:_._links["fx:store"].href),(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector("#storeLoader")}}customElements.define("foxy-transaction",O);export{O as Transaction};
1
+ import"./foxy-billing-address-card.js";import"./foxy-attribute-card.js";import"./foxy-attribute-form.js";import"./foxy-custom-field-form.js";import"./foxy-custom-field-card.js";import"./foxy-copy-to-clipboard.js";import"./foxy-nucleon-element.js";import"./foxy-shipment-card.js";import"./foxy-payment-card.js";import"./foxy-webhook-card.js";import"./foxy-webhook-form.js";import"./foxy-item-card.js";import"./foxy-item-form.js";import"./shared-37efab30.js";import"./shared-388e9240.js";import"./shared-8cd578ee.js";import"./shared-937b497c.js";import{I as t}from"./shared-0e055562.js";import"./shared-6e859df6.js";import"./shared-6918312e.js";import{a as e}from"./shared-7d38cb8a.js";import{_ as o,B as i}from"./shared-0f6e4584.js";import{h as r,s}from"./shared-dc73b9a5.js";import{N as n}from"./shared-24d71d01.js";import"./foxy-customer-card.js";import"./foxy-swipe-actions.js";import"./foxy-spinner.js";import{g as a}from"./shared-bab2ea2c.js";import{i as d}from"./shared-9803aa7c.js";import{c as l}from"./shared-4e709717.js";import{R as c,a as u}from"./shared-fb34e84c.js";import"./shared-3ee151ce.js";import"./shared-f3773d62.js";import"./shared-56bf05ef.js";import"./shared-90a47948.js";import"./shared-44ce656d.js";import"./shared-51c4a6dd.js";import"./shared-0b01f721.js";import"./shared-343d1fd7.js";import"./shared-f7a1193f.js";import"./shared-c286c5ad.js";import"./shared-cd96ff03.js";import"./shared-522a172d.js";import"./shared-12a7a15d.js";import"./shared-6474675f.js";import"./shared-ee36b83f.js";import"./shared-f407c2cb.js";import"./shared-b08ca8d0.js";import"./shared-09b4185a.js";import"./shared-61ade33e.js";import"./shared-a207423c.js";import"./shared-21bc5d5e.js";import"./shared-a0c6a159.js";import"./shared-fc1dfa64.js";import"./shared-9b2d6d62.js";import"./shared-029d623b.js";import"./shared-0cc5420d.js";import"./shared-61b6ef6e.js";import"./shared-fb0ca5e2.js";import"./shared-6ac0d05e.js";import"./shared-2bf89a21.js";import"./shared-7c411b0a.js";import"./shared-2a5c89a4.js";import"./shared-4b346553.js";import"./shared-b8198665.js";import"./shared-8f3398dc.js";import"./shared-08e0a194.js";import"./shared-22ba9566.js";import"./foxy-webhook-status-card.js";import"./foxy-webhook-log-card.js";import"./shared-f34aeb6c.js";import"./shared-e778071b.js";import"./foxy-form-dialog.js";import"./shared-99940888.js";import"./shared-5a2f398c.js";import"./shared-d132bd37.js";import"./shared-ac0368ec.js";import"./shared-16c17e32.js";import"./shared-0a6a28ce.js";import"./shared-280f868d.js";import"./shared-c2776a33.js";import"./shared-e24da82e.js";import"./shared-19884cf4.js";import"./shared-651c44fa.js";import"./shared-f2968508.js";import"./shared-d8c3067b.js";import"./shared-c388e926.js";import"./shared-60d586ba.js";import"./shared-0700fd80.js";import"./shared-56a559fd.js";import"./shared-79d0699c.js";import"./shared-43e2c3f6.js";import"./foxy-discount-detail-card.js";import"./foxy-coupon-detail-card.js";import"./foxy-item-category-card.js";import"./foxy-discount-builder.js";import"./shared-8438d4ca.js";import"./foxy-item-option-card.js";import"./foxy-item-option-form.js";import"./foxy-collection-page.js";import"./foxy-pagination.js";let p,f=t=>t;customElements.define("foxy-internal-transaction-post-action-control",class extends e{constructor(){super(...arguments),this.theme=null,this.href=null,this.__state="idle"}static get properties(){return o(o({},super.properties),{},{__state:{type:String},theme:{type:String},href:{type:String}})}renderControl(){const t=this.__state,e="fail"===t?"error":"idle"===t?this.theme:"";return r(p||(p=f` <foxy-internal-confirm-dialog header="header" infer="confirm" id="confirm" @hide="${0}"> </foxy-internal-confirm-dialog> <vaadin-button theme="${0} tertiary-inline" ?disabled="${0}" @click="${0}"> <foxy-i18n key="${0}" infer=""></foxy-i18n> </vaadin-button> `),(t=>!t.detail.cancelled&&this.__submit()),e,"busy"===t||this.disabled,(t=>{this.renderRoot.querySelector("#confirm").show(t.currentTarget)}),t)}async __submit(){var t;if("busy"!==this.__state)try{this.__state="busy";const e=new n.API(this),o=await e.fetch(null!==(t=this.href)&&void 0!==t?t:"",{method:"POST"});this.__state=o.ok?"idle":"fail",o.ok&&this.dispatchEvent(new CustomEvent("done"))}catch(t){this.__state="fail"}}});let m,h,_,y,v=t=>t;customElements.define("foxy-internal-transaction-customer-control",class extends e{constructor(){super(...arguments),this.__copyEmailState="idle",this.__copyIdState="idle"}static get properties(){return o(o({},super.properties),{},{__copyEmailState:{attribute:!1},__copyIdState:{attribute:!1}})}renderControl(){var t,e,o,i;const n=this.nucleon,c=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t._links["fx:customer"].href,u=c?null===(e=null==n?void 0:n.getCustomerPageHref)||void 0===e?void 0:e.call(n,c):void 0;return r(m||(m=v` <foxy-i18n infer="" class="block text-s font-medium leading-xs mb-xs" key="label"> </foxy-i18n> <foxy-swipe-actions> <a class="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" href="${0}"> <foxy-customer-card infer="" href="${0}"></foxy-customer-card> </a> <div class="h-full grid grid-cols-2 gap-s ml-s" slot="action"> ${0} ${0} </div> </foxy-swipe-actions> `),l({"block ring-inset rounded transition-colors":!0,"ring-1 ring-contrast-10":!u,"cursor-pointer bg-contrast-5 hover-bg-contrast-10":!!u,"focus-outline-none focus-ring-2 focus-ring-primary-50":!!u}),d(u),d(c),this.__renderCopyAction(s(h||(h=v`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.2rem; height: 1.2rem"><path fill-rule="evenodd" d="M9.493 2.852a.75.75 0 0 0-1.486-.204L7.545 6H4.198a.75.75 0 0 0 0 1.5h3.14l-.69 5H3.302a.75.75 0 0 0 0 1.5h3.14l-.435 3.148a.75.75 0 0 0 1.486.204L7.955 14h2.986l-.434 3.148a.75.75 0 0 0 1.486.204L12.456 14h3.346a.75.75 0 0 0 0-1.5h-3.14l.69-5h3.346a.75.75 0 0 0 0-1.5h-3.14l.435-3.148a.75.75 0 0 0-1.486-.204L12.045 6H9.059l.434-3.148ZM8.852 7.5l-.69 5h2.986l.69-5H8.852Z" clip-rule="evenodd" /></svg>`)),"copy_id_caption","__copyIdState",c?String(a(c)):""),this.__renderCopyAction(s(_||(_=v`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.2rem; height: 1.2rem"><path fill-rule="evenodd" d="M5.404 14.596A6.5 6.5 0 1 1 16.5 10a1.25 1.25 0 0 1-2.5 0 4 4 0 1 0-.571 2.06A2.75 2.75 0 0 0 18 10a8 8 0 1 0-2.343 5.657.75.75 0 0 0-1.06-1.06 6.5 6.5 0 0 1-9.193 0ZM10 7.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z" clip-rule="evenodd" /></svg>`)),"copy_email_caption","__copyEmailState",null!==(i=null===(o=null==n?void 0:n.data)||void 0===o?void 0:o.customer_email)&&void 0!==i?i:""))}__renderCopyAction(t,e,o,i){const s=this[o],n="fail"===s?"error":"done"===s?"end":"busy";return r(y||(y=v` <button class="relative transition-colors bg-contrast-5 text-body hover-bg-contrast-10 rounded h-full py-0 px-m focus-outline-none focus-ring-2 focus-ring-inset focus-ring-primary-50" ?disabled="${0}" @click="${0}" @focusout="${0}" @mouseout="${0}"> <div class="${0}"> ${0} <foxy-i18n class="mt-xs text-s font-medium leading-none" infer="" key="${0}"> </foxy-i18n> </div> <div class="${0}"> <foxy-spinner layout="no-label" state="${0}" infer="spinner"> </foxy-spinner> </div> </button> `),"idle"!==s,(()=>"idle"===s&&this.__copy(i,o)),(t=>"idle"!==s&&t.stopPropagation()),(t=>"idle"!==s&&t.stopPropagation()),l({"relative flex flex-col items-center justify-center transition-opacity":!0,"opacity-0":"idle"!==s}),t,e,l({"absolute inset-0 flex items-center justify-center transition-opacity":!0,"opacity-0":"idle"===s}),n)}async __copy(t,e){this[e]="busy";try{await navigator.clipboard.writeText(t),this[e]="done"}catch(t){this[e]="fail"}setTimeout((()=>this[e]="idle"),3e3)}});let x,b,g,j,w,$,k=t=>t;customElements.define("foxy-internal-transaction-actions-control",class extends e{renderControl(){var t,e,o,i,s,n,a,d,l,c;return r(x||(x=k` <div class="flex flex-wrap gap-x-m gap-y-xs"> ${0} ${0} ${0} ${0} ${0} </div> `),(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:capture"])?this.__renderCaptureAction():"",(null===(i=null===(o=this.nucleon)||void 0===o?void 0:o.data)||void 0===i?void 0:i._links["fx:void"])?this.__renderVoidAction():"",(null===(n=null===(s=this.nucleon)||void 0===s?void 0:s.data)||void 0===n?void 0:n._links["fx:refund"])?this.__renderRefundAction():"",(null===(d=null===(a=this.nucleon)||void 0===a?void 0:a.data)||void 0===d?void 0:d._links["fx:send_emails"])?this.__renderSendEmailsAction():"",(null===(c=null===(l=this.nucleon)||void 0===l?void 0:l.data)||void 0===c?void 0:c._links["fx:subscription"])?this.__renderSubscriptionAction():"")}__renderSendEmailsAction(){var t,e;return r(b||(b=k` <foxy-internal-transaction-post-action-control infer="send-emails" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:send_emails"].href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderCaptureAction(){var t,e;return r(g||(g=k` <foxy-internal-transaction-post-action-control theme="success" infer="capture" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:capture"].href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderVoidAction(){var t,e,o;return r(j||(j=k` <foxy-internal-transaction-post-action-control theme="error" infer="void" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(o=null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:void"])||void 0===o?void 0:o.href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderRefundAction(){var t,e,o;return r(w||(w=k` <foxy-internal-transaction-post-action-control infer="refund" href="${0}" @done="${0}"> </foxy-internal-transaction-post-action-control> `),d(null===(o=null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:refund"])||void 0===o?void 0:o.href),(()=>{var t;return null===(t=this.nucleon)||void 0===t?void 0:t.refresh()}))}__renderSubscriptionAction(){var t,e,o;const i=this.nucleon,s=null===(e=null===(t=null==i?void 0:i.data)||void 0===t?void 0:t._links["fx:subscription"])||void 0===e?void 0:e.href,n=s?null===(o=null==i?void 0:i.getSubscriptionPageHref)||void 0===o?void 0:o.call(i,s):void 0;return r($||($=k` <a class="rounded text-m font-medium text-primary cursor-pointer transition-opacity hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50" href="${0}"> <foxy-i18n infer="subscription" key="caption"></foxy-i18n> </a> `),d(n))}});let S,P,A,C,H,L,E,I,R,B,q=t=>t;customElements.define("foxy-internal-transaction-summary-control",class extends e{constructor(){super(...arguments),this.__storeLoaderId="storeLoader"}renderControl(){var t,e,o,i,s,n,a,l,c;const u=null===(t=this.nucleon)||void 0===t?void 0:t.data;if(!u)return r(S||(S=q``));const p=null!==(o=null===(e=null==u?void 0:u._embedded)||void 0===e?void 0:e["fx:applied_taxes"])&&void 0!==o?o:[],f=null!==(s=null===(i=u._embedded)||void 0===i?void 0:i["fx:shipments"])&&void 0!==s?s:[];return r(P||(P=q` <foxy-nucleon infer="" href="${0}" id="${0}" @update="${0}"> </foxy-nucleon> <p class="grid gap-x-s text-right text-s leading-m border-dashed border rounded border-contrast-20 whitespace-nowrap overflow-auto" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 2px);grid-template-columns:1fr min-content"> <span><foxy-i18n key="subtotal" infer=""></foxy-i18n>&colon;</span> <span>${0}</span> ${0} ${0} ${0} ${0} <span class="col-span-2 border-t border-dashed border-contrast-20 my-s"></span> <span class="col-span-2 flex gap-s justify-between items-center"> ${0} <span class="text-xl font-medium leading-xs"> <foxy-i18n infer="" key="total"></foxy-i18n>&colon; ${0} </span> </span> </p> `),d(this.__storeHref),this.__storeLoaderId,(()=>this.requestUpdate()),this.__renderPrice(u.total_item_price),0===f.length||0===u.total_shipping?r(A||(A=q` <span><foxy-i18n infer="" key="total_shipping"></foxy-i18n>&colon;</span> <span>${0} </span> `),this.__renderPrice(u.total_shipping,!0)):f.map((t=>r(C||(C=q` <span>${0}&colon;</span> <span>${0}</span> `),t.shipping_service_description,this.__renderPrice(t.total_shipping,!0)))),0===p.length||0===u.total_tax?r(H||(H=q` <span><foxy-i18n infer="" key="total_tax"></foxy-i18n>&colon;</span> <span>${0}</span> `),this.__renderPrice(u.total_tax,!0)):p.map((t=>r(L||(L=q` <span>${0}&colon;</span> <span>${0}</span> `),t.name,this.__renderPrice(t.amount,!0)))),null===(a=null===(n=null==u?void 0:u._embedded)||void 0===n?void 0:n["fx:applied_gift_card_codes"])||void 0===a?void 0:a.map((t=>{var e;return r(E||(E=q` <span>${0}&colon;</span> <span>${0}</span> `),t._embedded["fx:gift_card"].name,this.__renderPrice(null!==(e=t.balance_adjustment)&&void 0!==e?e:0,!0))})),null===(c=null===(l=null==u?void 0:u._embedded)||void 0===l?void 0:l["fx:discounts"])||void 0===c?void 0:c.map((t=>r(I||(I=q` <span data-testclass="discount">${0}&colon;</span> <span>${0}</span> `),t.name,this.__renderPrice(t.amount,!0)))),this.__renderStatus(),this.__renderPrice(u.total_order))}get __storeHref(){var t,e,o;return null===(o=null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e._links["fx:store"])||void 0===o?void 0:o.href}get __store(){var t,e;const o=`#${this.__storeLoaderId}`;return null!==(e=null===(t=this.renderRoot.querySelector(o))||void 0===t?void 0:t.data)&&void 0!==e?e:null}__renderPrice(t,e=!1){var o,i,s;const n=(null===(o=this.__store)||void 0===o?void 0:o.use_international_currency_symbol)?"code":"symbol",a=null===(s=null===(i=this.nucleon)||void 0===i?void 0:i.data)||void 0===s?void 0:s.currency_code;return r(R||(R=q` <foxy-i18n class="${0}" infer="" key="price" .options="${0}"> </foxy-i18n> `),e&&0!==t?t>0?"text-success":"text-error":"",{currencyDisplay:n,signDisplay:e?"exceptZero":"auto",amount:`${t} ${a}`})}__renderStatus(){var t,e;const o=(null===(e=null===(t=this.nucleon)||void 0===t?void 0:t.data)||void 0===e?void 0:e.status)||"completed";let i="";return i=["capturing","captured","approved","authorized","pending"].includes(o)?"text-success bg-success-10":o&&"completed"!==o?["problem","pending_fraud_review","rejected","declined"].includes(o)?"text-error-contrast bg-error":"bg-contrast-5 text-body":"text-success-contrast bg-success",r(B||(B=q` <foxy-i18n infer="" class="${0} rounded-s py-xs px-s font-medium text-s leading-xs" key="status_${0}"></foxy-i18n> `),i,o)}});let G,T,U,Z=t=>t;const M=c(u(t,"transaction"));class O extends M{constructor(){var t;super(...arguments),t=this,this.hostedPaymentGatewaysHelper=null,this.paymentGatewaysHelper=null,this.localeCodes=null,this.getSubscriptionPageHref=null,this.getCustomerPageHref=null,this.__webhooksBulkActions=[{name:"refeed",onClick:async function(e){if(!t.data)return;const o=t.data._links["fx:send_webhooks"].href,i=new O.API(t),r=await i.fetch(o,{method:"POST",body:JSON.stringify({refeed_hooks:e.map((t=>a(t._links.self.href))),event:"refeed"})});if(e.forEach((t=>{O.Rumour("").share({related:[...e.map((t=>t._links["fx:logs"].href)),...e.map((t=>t._links["fx:statuses"].href))],source:t._links.self.href,data:t})})),!r.ok)throw new Error(await r.text())}}]}static get properties(){return o(o({},super.properties),{},{hostedPaymentGatewaysHelper:{attribute:"hosted-payment-gateways-helper"},paymentGatewaysHelper:{attribute:"payment-gateways-helper"},getSubscriptionPageHref:{attribute:!1},getCustomerPageHref:{attribute:!1},localeCodes:{attribute:"locale-codes"}})}get readonlySelector(){var t,e,o;const r=["billing-addresses","datafeed","webhooks:dialog:url",super.readonlySelector];return Boolean(null!==(e=null===(t=this.data)||void 0===t?void 0:t._links["fx:void"])&&void 0!==e?e:null===(o=this.data)||void 0===o?void 0:o._links["fx:refund"])||r.push("items","attributes","custom-fields"),new i(r.join(" ").trim())}get hiddenSelector(){var t,e,o,r;const s=["billing-addresses:dialog:delete","billing-addresses:dialog:timestamps","webhooks:dialog:header:copy-json","webhooks:dialog:header:copy-id","webhooks:dialog:timestamps","webhooks:dialog:name","webhooks:dialog:query","webhooks:dialog:encryption-key","webhooks:dialog:delete",super.readonlySelector],n=null===(t=this.data)||void 0===t?void 0:t.type;return(null===(e=this.data)||void 0===e?void 0:e._links["fx:subscription"])||s.unshift("subscription"),"subscription_modification"===n&&s.unshift("actions"),"updateinfo"===n&&s.unshift("not=customer,subscription,payments,custom-fields,attributes"),"subscription_cancellation"===n&&s.unshift("not=customer,subscription,custom-fields,attributes"),(null===(r=null===(o=this.__storeLoader)||void 0===o?void 0:o.data)||void 0===r?void 0:r.use_webhook)||s.unshift("datafeed"),new i(s.join(" ").trim())}get headerSubtitleOptions(){var t,e,o,i,r;const s=null===(t=this.data)||void 0===t?void 0:t.source,n=null===(e=this.data)||void 0===e?void 0:e.type;let a="";return"updateinfo"===n?a=!s||(null==s?void 0:s.startsWith("cit_"))?"customer_changed_payment_method":"mit_uoe"===s?"admin_changed_payment_method_with_uoe":"mit_api"===s?"integration_changed_payment_method":"admin_changed_payment_method":"subscription_modification"===n?a=!s||(null==s?void 0:s.startsWith("cit_"))?"customer_changed_subscription":"mit_uoe"===s?"admin_changed_subscription_with_uoe":"mit_api"===s?"integration_changed_subscription":"admin_changed_subscription":"subscription_renewal"===n?"mit_recurring"===s?a="subscription_renewal_attempt":"mit_recurring_reattempt_automated"===s?a="subscription_renewal_automated_reattempt":"mit_recurring_reattempt_manual"===s&&(a="subscription_renewal_manual_reattempt"):"subscription_cancellation"===n?"cit_recurring_cancellation"===s?a="customer_canceled_subscription":"mit_recurring_cancellation"===s&&(a="admin_canceled_subscription"):(null===(o=this.data)||void 0===o?void 0:o._links["fx:subscription"])?(null==s?void 0:s.startsWith("cit_"))?a="customer_subscribed":"mit_uoe"===s?a="admin_subscribed_with_uoe":"mit_api"===s&&(a="integration_subscribed"):(null==s?void 0:s.startsWith("cit_"))?a="customer_placed_order":"mit_uoe"===s?a="admin_placed_order_with_uoe":"mit_api"===s&&(a="integration_placed_order"),{transaction_date:null===(i=this.data)||void 0===i?void 0:i.transaction_date,ip_country:null===(r=this.data)||void 0===r?void 0:r.ip_country,context:a}}get headerCopyIdValue(){var t,e,o;return null!==(o=null===(e=null===(t=this.data)||void 0===t?void 0:t.display_id)||void 0===e?void 0:e.toString())&&void 0!==o?o:""}renderHeaderActions(){return r(G||(G=Z` <foxy-internal-transaction-actions-control infer="actions"> </foxy-internal-transaction-actions-control> `))}renderBody(){var t,e,o,i,s,n,a,l,c,u,p,f,m,h,_;let y,v,x;const b=this.hiddenSelector;if(this.data)try{const o=new URL(this.data._links["fx:shipments"].href),i=new URL(null!==(e=null===(t=this.__storeLoader)||void 0===t?void 0:t.data._links["fx:webhooks"].href)&&void 0!==e?e:""),r=new URL(this.data._links["fx:items"].href);o.searchParams.set("zoom","items:item_category"),i.searchParams.set("event_resource","transaction"),r.searchParams.set("zoom","item_options"),y=o.toString(),v=i.toString(),x=r.toString()}catch(t){}return r(T||(T=Z` ${0} ${0} <foxy-internal-transaction-customer-control infer="customer"> </foxy-internal-transaction-customer-control> <div class="grid gap-s" ?hidden="${0}"> <foxy-internal-async-list-control infer="items" class="min-w-0" first="${0}" limit="10" item="foxy-item-card" form="foxy-item-form" alert wide .related="${0}" .itemProps="${0}" .formProps="${0}"> </foxy-internal-async-list-control> <foxy-internal-transaction-summary-control infer="summary" class="min-w-0"> </foxy-internal-transaction-summary-control> </div> <foxy-internal-async-list-control infer="billing-addresses" first="${0}" item="foxy-billing-address-card" form="foxy-address-form" hide-create-button hide-delete-button alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="payments" first="${0}" item="foxy-payment-card" .itemProps="${0}"> </foxy-internal-async-list-control> <div class="grid gap-m sm-grid-cols-2" ?hidden="${0}"> <foxy-internal-async-list-control infer="custom-fields" class="min-w-0" first="${0}" limit="5" form="foxy-custom-field-form" item="foxy-custom-field-card" alert> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="attributes" class="min-w-0" first="${0}" limit="5" form="foxy-attribute-form" item="foxy-attribute-card" alert> </foxy-internal-async-list-control> </div> <foxy-internal-async-list-control infer="shipments" first="${0}" item="foxy-shipment-card"> </foxy-internal-async-list-control> <foxy-internal-async-list-control infer="webhooks" first="${0}" item="foxy-webhook-card" form="foxy-webhook-form" hide-create-button hide-delete-button alert .bulkActions="${0}" .itemProps="${0}" .formProps="${0}"> </foxy-internal-async-list-control> <foxy-internal-summary-control infer="datafeed"> <foxy-internal-switch-control infer="data-is-fed"></foxy-internal-switch-control> <foxy-internal-transaction-post-action-control infer="process-webhook" href="${0}"> </foxy-internal-transaction-post-action-control> </foxy-internal-summary-control> <foxy-nucleon class="hidden" infer="" href="${0}" id="storeLoader" @update="${0}"> </foxy-nucleon> `),this.renderHeader(),["problem","pending_fraud_review","rejected","declined"].includes(null!==(i=null===(o=this.data)||void 0===o?void 0:o.status)&&void 0!==i?i:"")?r(U||(U=Z` <p class="leading-xs text-body rounded bg-error-10 block" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> <foxy-i18n infer="header" key="alert_status_${0}"></foxy-i18n> </p> `),null===(s=this.data)||void 0===s?void 0:s.status):"",b.matches("items",!0)&&b.matches("summary",!0),d(x),[this.href],{"locale-codes":this.localeCodes},{"item-categories":null===(a=null===(n=this.__storeLoader)||void 0===n?void 0:n.data)||void 0===a?void 0:a._links["fx:item_categories"].href,"locale-codes":this.localeCodes,store:null===(l=this.data)||void 0===l?void 0:l._links["fx:store"].href},d(null===(c=this.data)||void 0===c?void 0:c._links["fx:billing_addresses"].href),d(null===(u=this.data)||void 0===u?void 0:u._links["fx:payments"].href),{"hosted-payment-gateways-helper":this.hostedPaymentGatewaysHelper,"payment-gateways-helper":this.paymentGatewaysHelper},b.matches("custom-fields",!0)&&b.matches("attributes",!0),d(null===(p=this.data)||void 0===p?void 0:p._links["fx:custom_fields"].href),d(null===(f=this.data)||void 0===f?void 0:f._links["fx:attributes"].href),d(y),d(v),this.__webhooksBulkActions,{"resource-uri":this.href},{"resource-uri":this.href},d(null===(h=null===(m=this.data)||void 0===m?void 0:m._links["fx:process_webhook"])||void 0===h?void 0:h.href),d(null===(_=this.data)||void 0===_?void 0:_._links["fx:store"].href),(()=>this.requestUpdate()))}get __storeLoader(){return this.renderRoot.querySelector("#storeLoader")}}customElements.define("foxy-transaction",O);export{O as Transaction};
@@ -1 +1 @@
1
- import"./shared-f407c2cb.js";import"./shared-388e9240.js";import"./shared-dfc33ff6.js";import"./shared-08e0a194.js";import{I as r}from"./shared-0e055562.js";import"./foxy-webhook-status-card.js";import"./foxy-webhook-log-card.js";import{_ as e,B as t}from"./shared-0f6e4584.js";import{g as o}from"./shared-bab2ea2c.js";import{a as s}from"./shared-fb34e84c.js";import{i as a}from"./shared-9803aa7c.js";import{h as i}from"./shared-dc73b9a5.js";import"./shared-b08ca8d0.js";import"./shared-44ce656d.js";import"./shared-09b4185a.js";import"./shared-61ade33e.js";import"./shared-a207423c.js";import"./shared-90a47948.js";import"./shared-7d38cb8a.js";import"./shared-51c4a6dd.js";import"./shared-37efab30.js";import"./shared-343d1fd7.js";import"./shared-f7a1193f.js";import"./shared-0b01f721.js";import"./shared-24d71d01.js";import"./shared-c286c5ad.js";import"./shared-cd96ff03.js";import"./shared-522a172d.js";import"./shared-12a7a15d.js";import"./shared-6474675f.js";import"./shared-ee36b83f.js";import"./shared-4e709717.js";import"./shared-61b6ef6e.js";import"./shared-280f868d.js";import"./shared-c2776a33.js";import"./shared-e24da82e.js";import"./shared-6e859df6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-56bf05ef.js";import"./shared-a0c6a159.js";import"./shared-99940888.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-6918312e.js";import"./shared-fc1dfa64.js";import"./foxy-pagination.js";import"./shared-2a5c89a4.js";import"./shared-4b346553.js";import"./shared-b8198665.js";import"./shared-8f3398dc.js";import"./shared-22ba9566.js";import"./foxy-copy-to-clipboard.js";import"./shared-9b2d6d62.js";import"./shared-029d623b.js";import"./shared-3ee151ce.js";import"./shared-f3773d62.js";let n,d,c=r=>r;class p extends(s(r,"webhook-form")){constructor(){super(...arguments),this.resourceUri=null,this.__encryptionKeyGeneratorOptions={separator:"",length:512},this.__eventResources=[{value:"subscription",label:"event_resource_subscription"},{value:"transaction",label:"event_resource_transaction"},{value:"customer",label:"event_resource_customer"}]}static get properties(){return e(e({},super.properties),{},{resourceUri:{attribute:"resource-uri"}})}static get v8n(){return[({name:r})=>!!r||"name:v8n_required",({name:r})=>!!r&&r.length<=255||"name:v8n_too_long",({url:r})=>!r||r.length<=1e3||"url:v8n_too_long",({query:r})=>!r||r.length<=1e3||"query:v8n_too_long",({encryption_key:r})=>!!r||"encryption-key:v8n_required",({encryption_key:r})=>!r||r.length<=1e3||"encryption-key:v8n_too_long"]}get hiddenSelector(){const r=[super.hiddenSelector.toString()];return this.data&&r.unshift("event-resource"),new t(r.join(" ").trim())}get headerSubtitleOptions(){var r,e;const t=null===(r=this.data)||void 0===r?void 0:r.format;return{context:"json"===t?null===(e=this.data)||void 0===e?void 0:e.event_resource:t}}edit(r){super.edit(r),this.form.format||super.edit({format:"json"}),this.form.version||super.edit({version:2})}renderBody(){var r,e,t,s;const p=this.resourceUri?o(this.resourceUri):null;let l,h;try{const t=new URL(null!==(e=null===(r=this.data)||void 0===r?void 0:r._links["fx:statuses"].href)&&void 0!==e?e:"");null!==p&&t.searchParams.set("resource_id",String(p)),t.searchParams.set("order","date_created desc"),l=t.toString()}catch(r){l=void 0}try{const r=new URL(null!==(s=null===(t=this.data)||void 0===t?void 0:t._links["fx:logs"].href)&&void 0!==s?s:"");null!==p&&r.searchParams.set("resource_id",String(p)),r.searchParams.set("order","date_created desc"),h=r.toString()}catch(r){h=void 0}return i(n||(n=c` ${0} <foxy-internal-text-control infer="name"></foxy-internal-text-control> <foxy-internal-radio-group-control infer="event-resource" .options="${0}"> </foxy-internal-radio-group-control> <foxy-internal-text-control infer="query"></foxy-internal-text-control> <foxy-internal-text-control infer="url"></foxy-internal-text-control> <foxy-internal-password-control infer="encryption-key" show-generator .generatorOptions="${0}"> </foxy-internal-password-control> ${0} ${0} `),this.renderHeader(),this.__eventResources,this.__encryptionKeyGeneratorOptions,this.data?i(d||(d=c` <foxy-internal-async-list-control first="${0}" infer="statuses" limit="10" item="foxy-webhook-status-card"> </foxy-internal-async-list-control> <foxy-internal-async-list-control first="${0}" infer="logs" limit="10" item="foxy-webhook-log-card"> </foxy-internal-async-list-control> `),a(l),a(h)):"",super.renderBody())}}customElements.define("foxy-webhook-form",p);export{p as WebhookForm};
1
+ import"./shared-f407c2cb.js";import"./shared-388e9240.js";import"./shared-7c411b0a.js";import"./shared-08e0a194.js";import{I as r}from"./shared-0e055562.js";import"./foxy-webhook-status-card.js";import"./foxy-webhook-log-card.js";import{_ as e,B as t}from"./shared-0f6e4584.js";import{g as o}from"./shared-bab2ea2c.js";import{a as s}from"./shared-fb34e84c.js";import{i as a}from"./shared-9803aa7c.js";import{h as i}from"./shared-dc73b9a5.js";import"./shared-b08ca8d0.js";import"./shared-44ce656d.js";import"./shared-09b4185a.js";import"./shared-61ade33e.js";import"./shared-a207423c.js";import"./shared-90a47948.js";import"./shared-7d38cb8a.js";import"./shared-51c4a6dd.js";import"./shared-37efab30.js";import"./shared-343d1fd7.js";import"./shared-f7a1193f.js";import"./shared-0b01f721.js";import"./shared-24d71d01.js";import"./shared-c286c5ad.js";import"./shared-cd96ff03.js";import"./shared-522a172d.js";import"./shared-12a7a15d.js";import"./shared-6474675f.js";import"./shared-ee36b83f.js";import"./shared-4e709717.js";import"./shared-61b6ef6e.js";import"./shared-280f868d.js";import"./shared-c2776a33.js";import"./shared-e24da82e.js";import"./shared-6e859df6.js";import"./foxy-collection-page.js";import"./foxy-spinner.js";import"./shared-56bf05ef.js";import"./shared-a0c6a159.js";import"./shared-99940888.js";import"./foxy-swipe-actions.js";import"./foxy-form-dialog.js";import"./shared-6918312e.js";import"./shared-fc1dfa64.js";import"./foxy-pagination.js";import"./shared-2a5c89a4.js";import"./shared-4b346553.js";import"./shared-b8198665.js";import"./shared-8f3398dc.js";import"./shared-22ba9566.js";import"./foxy-copy-to-clipboard.js";import"./shared-9b2d6d62.js";import"./shared-029d623b.js";import"./shared-3ee151ce.js";import"./shared-f3773d62.js";let n,d,c=r=>r;class p extends(s(r,"webhook-form")){constructor(){super(...arguments),this.resourceUri=null,this.__encryptionKeyGeneratorOptions={separator:"",length:512},this.__eventResources=[{value:"subscription",label:"event_resource_subscription"},{value:"transaction",label:"event_resource_transaction"},{value:"customer",label:"event_resource_customer"}]}static get properties(){return e(e({},super.properties),{},{resourceUri:{attribute:"resource-uri"}})}static get v8n(){return[({name:r})=>!!r||"name:v8n_required",({name:r})=>!!r&&r.length<=255||"name:v8n_too_long",({url:r})=>!r||r.length<=1e3||"url:v8n_too_long",({query:r})=>!r||r.length<=1e3||"query:v8n_too_long",({encryption_key:r})=>!!r||"encryption-key:v8n_required",({encryption_key:r})=>!r||r.length<=1e3||"encryption-key:v8n_too_long"]}get hiddenSelector(){const r=[super.hiddenSelector.toString()];return this.data&&r.unshift("event-resource"),new t(r.join(" ").trim())}get headerSubtitleOptions(){var r,e;const t=null===(r=this.data)||void 0===r?void 0:r.format;return{context:"json"===t?null===(e=this.data)||void 0===e?void 0:e.event_resource:t}}edit(r){super.edit(r),this.form.format||super.edit({format:"json"}),this.form.version||super.edit({version:2})}renderBody(){var r,e,t,s;const p=this.resourceUri?o(this.resourceUri):null;let l,h;try{const t=new URL(null!==(e=null===(r=this.data)||void 0===r?void 0:r._links["fx:statuses"].href)&&void 0!==e?e:"");null!==p&&t.searchParams.set("resource_id",String(p)),t.searchParams.set("order","date_created desc"),l=t.toString()}catch(r){l=void 0}try{const r=new URL(null!==(s=null===(t=this.data)||void 0===t?void 0:t._links["fx:logs"].href)&&void 0!==s?s:"");null!==p&&r.searchParams.set("resource_id",String(p)),r.searchParams.set("order","date_created desc"),h=r.toString()}catch(r){h=void 0}return i(n||(n=c` ${0} <foxy-internal-text-control infer="name"></foxy-internal-text-control> <foxy-internal-radio-group-control infer="event-resource" .options="${0}"> </foxy-internal-radio-group-control> <foxy-internal-text-control infer="query"></foxy-internal-text-control> <foxy-internal-text-control infer="url"></foxy-internal-text-control> <foxy-internal-password-control infer="encryption-key" show-generator .generatorOptions="${0}"> </foxy-internal-password-control> ${0} ${0} `),this.renderHeader(),this.__eventResources,this.__encryptionKeyGeneratorOptions,this.data?i(d||(d=c` <foxy-internal-async-list-control first="${0}" infer="statuses" limit="10" item="foxy-webhook-status-card"> </foxy-internal-async-list-control> <foxy-internal-async-list-control first="${0}" infer="logs" limit="10" item="foxy-webhook-log-card"> </foxy-internal-async-list-control> `),a(l),a(h)):"",super.renderBody())}}customElements.define("foxy-webhook-form",p);export{p as WebhookForm};
@@ -1 +1 @@
1
- import"./shared-0700fd80.js";import{I as e}from"./shared-7d38cb8a.js";import{w as t}from"./shared-fb34e84c.js";import{c as a,h as r}from"./shared-dc73b9a5.js";import{_ as o}from"./shared-0f6e4584.js";import{s as i}from"./shared-79d0699c.js";import{p as l}from"./shared-43e2c3f6.js";import{i as s}from"./shared-9803aa7c.js";let n;function m(e){return new Array(7).fill(new Date).map(((t,a)=>{for(;t.getDay()!==a;)t.setDate(t.getDate()+1);return t.toLocaleDateString(e,{weekday:"short"})}))}function h(e){return new Array(7).fill(new Date).map(((t,a)=>{for(;t.getDay()!==a;)t.setDate(t.getDate()+1);return t.toLocaleDateString(e,{weekday:"long"})}))}t("vaadin-date-picker-text-field",a(n||(n=(e=>e)`:host([theme~=summary-item])::before{display:none}:host([theme~=summary-item]) .vaadin-text-field-container{display:grid;grid-template-columns:auto 1fr;grid-template-rows:repeat(3,min-content);gap:0 var(--lumo-space-m)}:host([theme~=summary-item]) [part=label]{font:normal var(--lumo-font-size-m) var(--lumo-font-family);color:var(--lumo-body-text-color)!important;grid-row:1;-webkit-text-fill-color:var(--lumo-body-text-color)!important}:host([theme~=summary-item]) [part=helper-text]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-secondary-text-color)!important;grid-row:2}:host([theme~=summary-item]) [part=helper-text]::before{display:none}:host([theme~=summary-item]) [part=error-message]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-error-text-color);grid-row:3}:host([theme~=summary-item]) [part=error-message],:host([theme~=summary-item]) [part=helper-text],:host([theme~=summary-item]) [part=label]{line-height:var(--lumo-line-height-xs);grid-column:1;padding:0}:host([theme~=summary-item]) [part=input-field]{grid-column:2;grid-row:1;padding:0;background:0 0;align-self:start;height:1em;--lumo-icon-size-m:1rem}:host([theme~=summary-item]) [part=input-field]::after,:host([theme~=summary-item][readonly]) [part=input-field] slot[name=suffix]{display:none}:host([theme~=summary-item]) [part=value]{line-height:var(--lumo-line-height-xs);text-align:right;min-height:auto;padding:0;margin-right:var(--lumo-space-xs);-webkit-mask-image:none}:host([theme~=summary-item][readonly]) [part=value]{margin-right:0}`)));let u,d=e=>e;customElements.define("foxy-internal-date-control",class extends e{constructor(){super(...arguments),this.format=null,this.layout=null}static get properties(){return o(o({},super.properties),{},{format:{},layout:{}})}renderControl(){var e,t;let a;return a="unix"===this.format?i(new Date(1e3*(null!==(e=this._value)&&void 0!==e?e:0))):"iso-long"===this.format?i(new Date(this._value)):this._value,r(u||(u=d` <vaadin-date-picker error-message="${0}" placeholder="${0}" helper-text="${0}" label="${0}" class="w-full" theme="${0}" ?disabled="${0}" ?readonly="${0}" .checkValidity="${0}" .value="${0}" .i18n="${0}" @keydown="${0}" @change="${0}"> </vaadin-date-picker> `),s(this._errorMessage),this.placeholder,this.helperText,this.label,null!==(t=this.layout)&&void 0!==t?t:"standalone",this.disabled,this.readonly,this._checkValidity,a,this.__pickerI18n,(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}),(e=>{var t,a,r,o;const i=e.currentTarget;"unix"===this.format?this._value=Math.floor((null!==(a=null===(t=l(i.value))||void 0===t?void 0:t.getTime())&&void 0!==a?a:0)/1e3):"iso-long"===this.format?this._value=null!==(o=null===(r=l(i.value))||void 0===r?void 0:r.toISOString())&&void 0!==o?o:null:this._value=i.value}))}get __pickerI18n(){return{monthNames:(e=this.lang||"en",new Array(12).fill(new Date).map(((t,a)=>(t.setMonth(a),t.toLocaleDateString(e,{month:"long"}))))),weekdays:h(this.lang||"en"),weekdaysShort:m(this.lang||"en"),firstDayOfWeek:0,week:this.t("week"),calendar:this.t("calendar"),clear:this.t("clear"),today:this.t("today"),cancel:this.t("cancel"),referenceDate:"",parseDate:null,formatTitle:(e,t)=>e+" "+t,formatDate:e=>this.t("display_value",{value:new Date(e.year,e.month,e.day)})};var e}});
1
+ import"./shared-0700fd80.js";import{I as e}from"./shared-7d38cb8a.js";import{w as t}from"./shared-fb34e84c.js";import{c as a,h as r}from"./shared-dc73b9a5.js";import{_ as o}from"./shared-0f6e4584.js";import{s as i}from"./shared-79d0699c.js";import{p as l}from"./shared-43e2c3f6.js";import{i as s}from"./shared-9803aa7c.js";let n;function m(e){return new Array(7).fill(new Date).map(((t,a)=>{for(;t.getDay()!==a;)t.setDate(t.getDate()+1);return t.toLocaleDateString(e,{weekday:"short"})}))}function h(e){return new Array(7).fill(new Date).map(((t,a)=>{for(;t.getDay()!==a;)t.setDate(t.getDate()+1);return t.toLocaleDateString(e,{weekday:"long"})}))}t("vaadin-date-picker-text-field",a(n||(n=(e=>e)`:host([theme~=summary-item])::before{display:none}:host([theme~=summary-item]) .vaadin-text-field-container{display:grid;grid-template-columns:auto 1fr;grid-template-rows:repeat(3,min-content);gap:0 var(--lumo-space-m)}:host([theme~=summary-item]) [part=label]{font:normal var(--lumo-font-size-m) var(--lumo-font-family);color:var(--lumo-body-text-color)!important;grid-row:1;-webkit-text-fill-color:var(--lumo-body-text-color)!important}:host([theme~=summary-item]) [part=helper-text]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-secondary-text-color)!important;grid-row:2}:host([theme~=summary-item]) [part=helper-text]::before{display:none}:host([theme~=summary-item]) [part=error-message]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-error-text-color);grid-row:3}:host([theme~=summary-item]) [part=error-message],:host([theme~=summary-item]) [part=helper-text],:host([theme~=summary-item]) [part=label]{line-height:var(--lumo-line-height-xs);grid-column:1;padding:0}:host([theme~=summary-item]) [part=input-field]{grid-column:2;grid-row:1;padding:0;background:0 0;align-self:start;height:1em;--lumo-icon-size-m:1rem}:host([theme~=summary-item]) [part=input-field]::after,:host([theme~=summary-item][readonly]) [part=input-field] slot[name=suffix]{display:none}:host([theme~=summary-item]) [part=value]{line-height:var(--lumo-line-height-xs);text-align:right;min-height:auto;padding:0;margin-right:var(--lumo-space-xs);-webkit-mask-image:none}:host([theme~=summary-item][readonly]) [part=value]{margin-right:0}:host([theme~=summary-item]) [part=clear-button]{transform:scale(1.5)}:host([has-value]) slot[name=suffix]{display:none}`)));let u,d=e=>e;customElements.define("foxy-internal-date-control",class extends e{constructor(){super(...arguments),this.format=null,this.layout=null}static get properties(){return o(o({},super.properties),{},{format:{},layout:{}})}renderControl(){var e,t;let a;return a="0000-00-00"!==this._value&&this._value?"unix"===this.format?i(new Date(1e3*(null!==(e=this._value)&&void 0!==e?e:0))):"iso-long"===this.format?i(new Date(this._value)):this._value:"",r(u||(u=d` <vaadin-date-picker error-message="${0}" placeholder="${0}" helper-text="${0}" label="${0}" class="w-full" theme="${0}" ?disabled="${0}" ?readonly="${0}" .checkValidity="${0}" .value="${0}" .i18n="${0}" clear-button-visible @keydown="${0}" @change="${0}"> </vaadin-date-picker> `),s(this._errorMessage),this.placeholder,this.helperText,this.label,null!==(t=this.layout)&&void 0!==t?t:"standalone",this.disabled,this.readonly,this._checkValidity,a,this.__pickerI18n,(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}),(e=>{var t,a,r,o;const i=e.currentTarget;"unix"===this.format?this._value=Math.floor((null!==(a=null===(t=l(i.value))||void 0===t?void 0:t.getTime())&&void 0!==a?a:0)/1e3):"iso-long"===this.format?this._value=null!==(o=null===(r=l(i.value))||void 0===r?void 0:r.toISOString())&&void 0!==o?o:null:this._value=i.value}))}get __pickerI18n(){return{monthNames:(e=this.lang||"en",new Array(12).fill(new Date).map(((t,a)=>(t.setMonth(a),t.toLocaleDateString(e,{month:"long"}))))),weekdays:h(this.lang||"en"),weekdaysShort:m(this.lang||"en"),firstDayOfWeek:0,week:this.t("week"),calendar:this.t("calendar"),clear:this.t("clear"),today:this.t("today"),cancel:this.t("cancel"),referenceDate:"",parseDate:null,formatTitle:(e,t)=>e+" "+t,formatDate:e=>this.t("display_value",{value:new Date(e.year,e.month,e.day)})};var e}});
@@ -0,0 +1 @@
1
+ import"./shared-2a5c89a4.js";import"./shared-b8198665.js";import{I as e}from"./shared-7d38cb8a.js";import{w as t}from"./shared-fb34e84c.js";import{c as r,h as a,s as o}from"./shared-dc73b9a5.js";import{_ as l}from"./shared-0f6e4584.js";import{i as s}from"./shared-9803aa7c.js";import{c as i}from"./shared-4e709717.js";let n;function m(e){var t,r,a;const o=null!==(t=null==e?void 0:e.separator)&&void 0!==t?t:"-",l=null!==(r=null==e?void 0:e.charset)&&void 0!==r?r:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=null!==(a=null==e?void 0:e.length)&&void 0!==a?a:18;let i="";for(let e=0;e<s;e++)o&&e>0&&e%6==0&&(i+=o),i+=l[Math.floor(Math.random()*l.length)];return i}t("vaadin-password-field",r(n||(n=(e=>e)`:host([theme~=summary-item])::before{display:none}:host([theme~=summary-item]) .vaadin-text-field-container{display:grid;grid-template-columns:auto auto;grid-template-rows:repeat(3,min-content);gap:0 var(--lumo-space-m)}:host([theme~=summary-item]) [part=label]{font:normal var(--lumo-font-size-m) var(--lumo-font-family);color:var(--lumo-body-text-color)!important;grid-row:1;-webkit-text-fill-color:var(--lumo-body-text-color)!important}:host([theme~=summary-item]) [part=helper-text]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-secondary-text-color)!important;grid-row:2}:host([theme~=summary-item]) [part=helper-text]::before{display:none}:host([theme~=summary-item]) [part=error-message]{font:normal var(--lumo-font-size-s) var(--lumo-font-family);color:var(--lumo-error-text-color);grid-row:3}:host([theme~=summary-item]) [part=error-message],:host([theme~=summary-item]) [part=helper-text],:host([theme~=summary-item]) [part=label]{line-height:var(--lumo-line-height-xs);grid-column:1;padding:0}:host([theme~=summary-item]) [part=input-field]{grid-column:2;grid-row:1;padding:0;background:0 0;align-self:start;height:1em;--lumo-icon-size-m:1rem}:host([theme~=summary-item]) [part=input-field]::after,:host([theme~=summary-item][readonly]) [part=input-field] slot[name=suffix]{display:none}:host([theme~=summary-item]) [part=value]{line-height:var(--lumo-line-height-xs);text-align:right;min-height:auto;padding:0;margin-right:var(--lumo-space-xs);-webkit-mask-image:none}:host([theme~=summary-item][readonly]) [part=value]{margin-right:0}`)));let d,h,u,p=e=>e;customElements.define("foxy-internal-password-control",class extends e{constructor(){super(...arguments),this.generatorOptions=null,this.showGenerator=!1,this.layout=null}static get properties(){return l(l({},super.properties),{},{generatorOptions:{type:Object,attribute:"generator-options"},showGenerator:{type:Boolean,attribute:"show-generator"},layout:{}})}renderControl(){var e;return a(d||(d=p` <vaadin-password-field error-message="${0}" helper-text="${0}" placeholder="${0}" label="${0}" theme="${0}" class="w-full" ?disabled="${0}" ?readonly="${0}" .checkValidity="${0}" .value="${0}" @keydown="${0}" @input="${0}"> ${0} </vaadin-password-field> `),s(this._errorMessage),this.helperText,this.placeholder,this.label,s(null!==(e=this.layout)&&void 0!==e?e:void 0),this.disabled,this.readonly,this._checkValidity,this._value,(e=>{var t;return"Enter"===e.key&&(null===(t=this.nucleon)||void 0===t?void 0:t.submit())}),(e=>{const t=e.currentTarget;this._value=t.value}),this.showGenerator?this.__renderGenerator():"")}get _value(){var e;return null!==(e=super._value)&&void 0!==e?e:""}set _value(e){super._value=e}__renderGenerator(){return a(h||(h=p` <div data-testid="generator" class="${0}" slot="suffix" @click="${0}"> ${0} </div> `),i({"w-s h-s flex items-center justify-center cursor-default transition-colors":!0,"text-contrast-60 hover-text-contrast-80":!this.disabled&&!this.readonly,"text-contrast-20":this.disabled||this.readonly}),(()=>{var e,t,r,a;let o,l=!1,s=0;do{o=m(null!==(e=this.generatorOptions)&&void 0!==e?e:void 0),l=null===(a=null===(r=null===(t=this.generatorOptions)||void 0===t?void 0:t.checkStrength)||void 0===r?void 0:r.call(t,o))||void 0===a||a,s++}while(!l&&s<100);if(!l)throw new Error("Failed to generate a strong password.");this._value=o;const i=this.renderRoot.querySelector("vaadin-password-field");null==i||i._setPasswordVisible(!0)}),o(u||(u=p`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" style="width: 1.15em; height: 1.15em"><path d="M15.98 1.804a1 1 0 00-1.96 0l-.24 1.192a1 1 0 01-.784.785l-1.192.238a1 1 0 000 1.962l1.192.238a1 1 0 01.785.785l.238 1.192a1 1 0 001.962 0l.238-1.192a1 1 0 01.785-.785l1.192-.238a1 1 0 000-1.962l-1.192-.238a1 1 0 01-.785-.785l-.238-1.192zM6.949 5.684a1 1 0 00-1.898 0l-.683 2.051a1 1 0 01-.633.633l-2.051.683a1 1 0 000 1.898l2.051.684a1 1 0 01.633.632l.683 2.051a1 1 0 001.898 0l.683-2.051a1 1 0 01.633-.633l2.051-.683a1 1 0 000-1.898l-2.051-.683a1 1 0 01-.633-.633L6.95 5.684zM13.949 13.684a1 1 0 00-1.898 0l-.184.551a1 1 0 01-.632.633l-.551.183a1 1 0 000 1.898l.551.183a1 1 0 01.633.633l.183.551a1 1 0 001.898 0l.184-.551a1 1 0 01.632-.633l.551-.183a1 1 0 000-1.898l-.551-.184a1 1 0 01-.633-.632l-.183-.551z" /></svg>`)))}});
@@ -33,7 +33,7 @@
33
33
  "start-date": {
34
34
  "label": "Start date",
35
35
  "helper_text": "",
36
- "placeholder": "",
36
+ "placeholder": "Not set",
37
37
  "display_value": "{{ value, date }}",
38
38
  "week": "Week",
39
39
  "calendar": "Calendar",
@@ -44,7 +44,7 @@
44
44
  "end-date": {
45
45
  "label": "End date",
46
46
  "helper_text": "",
47
- "placeholder": "",
47
+ "placeholder": "Not set",
48
48
  "display_value": "{{ value, date }}",
49
49
  "week": "Week",
50
50
  "calendar": "Calendar",
@@ -71,7 +71,7 @@
71
71
  "next-transaction-date": {
72
72
  "label": "Next payment date",
73
73
  "helper_text": "",
74
- "placeholder": "",
74
+ "placeholder": "Not set",
75
75
  "display_value": "{{ value, date }}",
76
76
  "week": "Week",
77
77
  "calendar": "Calendar",
@@ -30,14 +30,19 @@ export class InternalDateControl extends InternalEditableControl {
30
30
  renderControl() {
31
31
  var _a, _b;
32
32
  let value;
33
- if (this.format === 'unix') {
34
- value = serializeDate(new Date(((_a = this._value) !== null && _a !== void 0 ? _a : 0) * 1000));
35
- }
36
- else if (this.format === 'iso-long') {
37
- value = serializeDate(new Date(this._value));
33
+ if (this._value === '0000-00-00' || !this._value) {
34
+ value = '';
38
35
  }
39
36
  else {
40
- value = this._value;
37
+ if (this.format === 'unix') {
38
+ value = serializeDate(new Date(((_a = this._value) !== null && _a !== void 0 ? _a : 0) * 1000));
39
+ }
40
+ else if (this.format === 'iso-long') {
41
+ value = serializeDate(new Date(this._value));
42
+ }
43
+ else {
44
+ value = this._value;
45
+ }
41
46
  }
42
47
  return html `
43
48
  <vaadin-date-picker
@@ -52,6 +57,7 @@ export class InternalDateControl extends InternalEditableControl {
52
57
  .checkValidity=${this._checkValidity}
53
58
  .value=${value}
54
59
  .i18n=${this.__pickerI18n}
60
+ clear-button-visible
55
61
  @keydown=${(evt) => { var _a; return evt.key === 'Enter' && ((_a = this.nucleon) === null || _a === void 0 ? void 0 : _a.submit()); }}
56
62
  @change=${(evt) => {
57
63
  var _a, _b, _c, _d;
@@ -1 +1 @@
1
- {"version":3,"file":"InternalDateControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalDateControl/InternalDateControl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,aAAa,EAAE,yCAAsC;AAC9D,OAAO,EAAE,SAAS,EAAE,qCAAkC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,kCAA+B;AAC9D,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,aAAa,EAAE,2BAAwB;AAEhD;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,uBAAuB;IAAhE;;QASE,kHAAkH;QAClH,WAAM,GAA+B,IAAI,CAAC;QAE1C,wEAAwE;QACxE,WAAM,GAAyC,IAAI,CAAC;IA8DtD,CAAC;IA1EC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;IAQD,aAAa;;QACX,IAAI,KAAa,CAAC;QAElB,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;YAC1B,KAAK,GAAG,aAAa,CAAC,IAAI,IAAI,CAAC,OAAE,IAAI,CAAC,MAAiB,mCAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;SACxE;aAAM,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE;YACrC,KAAK,GAAG,aAAa,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAgB,CAAC,CAAC,CAAC;SACxD;aAAM;YACL,KAAK,GAAG,IAAI,CAAC,MAAgB,CAAC;SAC/B;QAED,OAAO,IAAI,CAAA;;wBAES,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;sBAC/B,IAAI,CAAC,WAAW;sBAChB,IAAI,CAAC,UAAU;gBACrB,IAAI,CAAC,KAAK;;gBAEV,MAAA,IAAI,CAAC,MAAM,mCAAI,YAAY;oBACvB,IAAI,CAAC,QAAQ;oBACb,IAAI,CAAC,QAAQ;yBACR,IAAI,CAAC,cAAc;iBAC3B,KAAK;gBACN,IAAI,CAAC,YAAY;mBACd,CAAC,GAAkB,EAAE,EAAE,WAAC,OAAA,GAAG,CAAC,GAAG,KAAK,OAAO,WAAI,IAAI,CAAC,OAAO,0CAAE,MAAM,GAAE,CAAA,EAAA;kBACtE,CAAC,GAAgB,EAAE,EAAE;;YAC7B,MAAM,KAAK,GAAG,GAAG,CAAC,aAAkC,CAAC;YAErD,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,aAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,OAAO,qCAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;aAC3E;iBAAM,IAAI,IAAI,CAAC,MAAM,KAAK,UAAU,EAAE;gBACrC,IAAI,CAAC,MAAM,eAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,WAAW,qCAAM,IAAI,CAAC;aAC7D;iBAAM;gBACL,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;aAC3B;QACH,CAAC;;;KAGJ,CAAC;IACJ,CAAC;IAED,IAAY,YAAY;QACtB,OAAO;YACL,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;YAC5C,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;YAChD,aAAa,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC;YACtD,cAAc,EAAE,CAAC;YACjB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;YACpB,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC;YAC5B,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YACtB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YACtB,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;YACxB,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;YAClD,UAAU,EAAE,CAAC,CAA+C,EAAE,EAAE;gBAC9D,OAAO,IAAI,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9E,CAAC;SACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { TemplateResult, PropertyDeclarations } from 'lit-element';\nimport type { DatePickerElement } from '@vaadin/vaadin-date-picker';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { serializeDate } from '../../../utils/serialize-date';\nimport { parseDate } from '../../../utils/parse-date';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-element';\n\nimport { getWeekdayShortNames } from './getWeekdayShortNames';\nimport { getWeekdayLongNames } from './getWeekdayLongNames';\nimport { getMonthNames } from './getMonthNames';\n\n/**\n * Internal control displaying a basic date picker box.\n *\n * @since 1.17.0\n * @element foxy-internal-date-control\n */\nexport class InternalDateControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n format: {},\n layout: {},\n };\n }\n\n /** Date format. If `unix`, expects and outputs a UNIX timestamp (number), otherwise defaults to ISO 8601 date. */\n format: 'unix' | 'iso-long' | null = null;\n\n /** Use summary item layout inside `<foxy-internal-summary-control>`. */\n layout: 'summary-item' | 'standalone' | null = null;\n\n renderControl(): TemplateResult {\n let value: string;\n\n if (this.format === 'unix') {\n value = serializeDate(new Date(((this._value as number) ?? 0) * 1000));\n } else if (this.format === 'iso-long') {\n value = serializeDate(new Date(this._value as string));\n } else {\n value = this._value as string;\n }\n\n return html`\n <vaadin-date-picker\n error-message=${ifDefined(this._errorMessage)}\n placeholder=${this.placeholder}\n helper-text=${this.helperText}\n label=${this.label}\n class=\"w-full\"\n theme=${this.layout ?? 'standalone'}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .checkValidity=${this._checkValidity}\n .value=${value}\n .i18n=${this.__pickerI18n}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as DatePickerElement;\n\n if (this.format === 'unix') {\n this._value = Math.floor((parseDate(field.value)?.getTime() ?? 0) / 1000);\n } else if (this.format === 'iso-long') {\n this._value = parseDate(field.value)?.toISOString() ?? null;\n } else {\n this._value = field.value;\n }\n }}\n >\n </vaadin-date-picker>\n `;\n }\n\n private get __pickerI18n() {\n return {\n monthNames: getMonthNames(this.lang || 'en'),\n weekdays: getWeekdayLongNames(this.lang || 'en'),\n weekdaysShort: getWeekdayShortNames(this.lang || 'en'),\n firstDayOfWeek: 0,\n week: this.t('week'),\n calendar: this.t('calendar'),\n clear: this.t('clear'),\n today: this.t('today'),\n cancel: this.t('cancel'),\n referenceDate: '',\n parseDate: null,\n formatTitle: (m: string, y: string) => m + ' ' + y,\n formatDate: (d: { day: number; month: number; year: number }) => {\n return this.t('display_value', { value: new Date(d.year, d.month, d.day) });\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"InternalDateControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalDateControl/InternalDateControl.ts"],"names":[],"mappings":"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","sourcesContent":["import type { TemplateResult, PropertyDeclarations } from 'lit-element';\nimport type { DatePickerElement } from '@vaadin/vaadin-date-picker';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { serializeDate } from '../../../utils/serialize-date';\nimport { parseDate } from '../../../utils/parse-date';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-element';\n\nimport { getWeekdayShortNames } from './getWeekdayShortNames';\nimport { getWeekdayLongNames } from './getWeekdayLongNames';\nimport { getMonthNames } from './getMonthNames';\n\n/**\n * Internal control displaying a basic date picker box.\n *\n * @since 1.17.0\n * @element foxy-internal-date-control\n */\nexport class InternalDateControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n format: {},\n layout: {},\n };\n }\n\n /** Date format. If `unix`, expects and outputs a UNIX timestamp (number), otherwise defaults to ISO 8601 date. */\n format: 'unix' | 'iso-long' | null = null;\n\n /** Use summary item layout inside `<foxy-internal-summary-control>`. */\n layout: 'summary-item' | 'standalone' | null = null;\n\n renderControl(): TemplateResult {\n let value: string;\n\n if (this._value === '0000-00-00' || !this._value) {\n value = '';\n } else {\n if (this.format === 'unix') {\n value = serializeDate(new Date(((this._value as number) ?? 0) * 1000));\n } else if (this.format === 'iso-long') {\n value = serializeDate(new Date(this._value as string));\n } else {\n value = this._value as string;\n }\n }\n\n return html`\n <vaadin-date-picker\n error-message=${ifDefined(this._errorMessage)}\n placeholder=${this.placeholder}\n helper-text=${this.helperText}\n label=${this.label}\n class=\"w-full\"\n theme=${this.layout ?? 'standalone'}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .checkValidity=${this._checkValidity}\n .value=${value}\n .i18n=${this.__pickerI18n}\n clear-button-visible\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @change=${(evt: CustomEvent) => {\n const field = evt.currentTarget as DatePickerElement;\n\n if (this.format === 'unix') {\n this._value = Math.floor((parseDate(field.value)?.getTime() ?? 0) / 1000);\n } else if (this.format === 'iso-long') {\n this._value = parseDate(field.value)?.toISOString() ?? null;\n } else {\n this._value = field.value;\n }\n }}\n >\n </vaadin-date-picker>\n `;\n }\n\n private get __pickerI18n() {\n return {\n monthNames: getMonthNames(this.lang || 'en'),\n weekdays: getWeekdayLongNames(this.lang || 'en'),\n weekdaysShort: getWeekdayShortNames(this.lang || 'en'),\n firstDayOfWeek: 0,\n week: this.t('week'),\n calendar: this.t('calendar'),\n clear: this.t('clear'),\n today: this.t('today'),\n cancel: this.t('cancel'),\n referenceDate: '',\n parseDate: null,\n formatTitle: (m: string, y: string) => m + ' ' + y,\n formatDate: (d: { day: number; month: number; year: number }) => {\n return this.t('display_value', { value: new Date(d.year, d.month, d.day) });\n },\n };\n }\n}\n"]}
@@ -69,5 +69,13 @@ registerStyles('vaadin-date-picker-text-field', css `:host([theme~='summary-item
69
69
  :host([theme~='summary-item'][readonly]) [part='value']{
70
70
  margin-right:0;
71
71
  }
72
+
73
+ :host([theme~='summary-item']) [part='clear-button']{
74
+ transform:scale(1.5);
75
+ }
76
+
77
+ :host([has-value]) slot[name='suffix']{
78
+ display:none;
79
+ }
72
80
  `);
73
81
  //# sourceMappingURL=vaadinStyles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vaadinStyles.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalDateControl/vaadinStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,cAAc,CACZ,+BAA+B,EAC/B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEF,CACF,CAAC","sourcesContent":["import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles';\nimport { css } from 'lit-element';\n\nregisterStyles(\n 'vaadin-date-picker-text-field',\n css`\n :host([theme~='summary-item'])::before {\n display: none;\n }\n\n :host([theme~='summary-item']) .vaadin-text-field-container {\n display: grid;\n grid-template-columns: auto 1fr;\n grid-template-rows: repeat(3, min-content);\n gap: 0 var(--lumo-space-m);\n }\n\n :host([theme~='summary-item']) [part='label'] {\n font: normal var(--lumo-font-size-m) var(--lumo-font-family);\n color: var(--lumo-body-text-color) !important;\n grid-row: 1;\n -webkit-text-fill-color: var(--lumo-body-text-color) !important;\n }\n\n :host([theme~='summary-item']) [part='helper-text'] {\n font: normal var(--lumo-font-size-s) var(--lumo-font-family);\n color: var(--lumo-secondary-text-color) !important;\n grid-row: 2;\n }\n\n :host([theme~='summary-item']) [part='helper-text']::before {\n display: none;\n }\n\n :host([theme~='summary-item']) [part='error-message'] {\n font: normal var(--lumo-font-size-s) var(--lumo-font-family);\n color: var(--lumo-error-text-color);\n grid-row: 3;\n }\n\n :host([theme~='summary-item']) [part='error-message'],\n :host([theme~='summary-item']) [part='helper-text'],\n :host([theme~='summary-item']) [part='label'] {\n line-height: var(--lumo-line-height-xs);\n grid-column: 1;\n padding: 0;\n }\n\n :host([theme~='summary-item']) [part='input-field'] {\n grid-column: 2;\n grid-row: 1;\n padding: 0;\n background: transparent;\n align-self: start;\n height: 1em;\n\n --lumo-icon-size-m: 1rem;\n }\n\n :host([theme~='summary-item']) [part='input-field']::after,\n :host([theme~='summary-item'][readonly]) [part='input-field'] slot[name='suffix'] {\n display: none;\n }\n\n :host([theme~='summary-item']) [part='value'] {\n line-height: var(--lumo-line-height-xs);\n text-align: right;\n min-height: auto;\n padding: 0;\n margin-right: var(--lumo-space-xs);\n -webkit-mask-image: none;\n }\n\n :host([theme~='summary-item'][readonly]) [part='value'] {\n margin-right: 0;\n }\n `\n);\n"]}
1
+ {"version":3,"file":"vaadinStyles.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalDateControl/vaadinStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,cAAc,CACZ,+BAA+B,EAC/B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EF,CACF,CAAC","sourcesContent":["import { registerStyles } from '@vaadin/vaadin-themable-mixin/register-styles';\nimport { css } from 'lit-element';\n\nregisterStyles(\n 'vaadin-date-picker-text-field',\n css`\n :host([theme~='summary-item'])::before {\n display: none;\n }\n\n :host([theme~='summary-item']) .vaadin-text-field-container {\n display: grid;\n grid-template-columns: auto 1fr;\n grid-template-rows: repeat(3, min-content);\n gap: 0 var(--lumo-space-m);\n }\n\n :host([theme~='summary-item']) [part='label'] {\n font: normal var(--lumo-font-size-m) var(--lumo-font-family);\n color: var(--lumo-body-text-color) !important;\n grid-row: 1;\n -webkit-text-fill-color: var(--lumo-body-text-color) !important;\n }\n\n :host([theme~='summary-item']) [part='helper-text'] {\n font: normal var(--lumo-font-size-s) var(--lumo-font-family);\n color: var(--lumo-secondary-text-color) !important;\n grid-row: 2;\n }\n\n :host([theme~='summary-item']) [part='helper-text']::before {\n display: none;\n }\n\n :host([theme~='summary-item']) [part='error-message'] {\n font: normal var(--lumo-font-size-s) var(--lumo-font-family);\n color: var(--lumo-error-text-color);\n grid-row: 3;\n }\n\n :host([theme~='summary-item']) [part='error-message'],\n :host([theme~='summary-item']) [part='helper-text'],\n :host([theme~='summary-item']) [part='label'] {\n line-height: var(--lumo-line-height-xs);\n grid-column: 1;\n padding: 0;\n }\n\n :host([theme~='summary-item']) [part='input-field'] {\n grid-column: 2;\n grid-row: 1;\n padding: 0;\n background: transparent;\n align-self: start;\n height: 1em;\n\n --lumo-icon-size-m: 1rem;\n }\n\n :host([theme~='summary-item']) [part='input-field']::after,\n :host([theme~='summary-item'][readonly]) [part='input-field'] slot[name='suffix'] {\n display: none;\n }\n\n :host([theme~='summary-item']) [part='value'] {\n line-height: var(--lumo-line-height-xs);\n text-align: right;\n min-height: auto;\n padding: 0;\n margin-right: var(--lumo-space-xs);\n -webkit-mask-image: none;\n }\n\n :host([theme~='summary-item'][readonly]) [part='value'] {\n margin-right: 0;\n }\n\n :host([theme~='summary-item']) [part='clear-button'] {\n transform: scale(1.5);\n }\n\n :host([has-value]) slot[name='suffix'] {\n display: none;\n }\n `\n);\n"]}
@@ -67,8 +67,21 @@ export class InternalPasswordControl extends InternalEditableControl {
67
67
  })}
68
68
  slot="suffix"
69
69
  @click=${() => {
70
- var _a;
71
- this._value = generateRandomPassword((_a = this.generatorOptions) !== null && _a !== void 0 ? _a : void 0);
70
+ var _a, _b, _c, _d;
71
+ let isStrong = false;
72
+ let newValue;
73
+ let attempts = 0;
74
+ do {
75
+ newValue = generateRandomPassword((_a = this.generatorOptions) !== null && _a !== void 0 ? _a : void 0);
76
+ isStrong = (_d = (_c = (_b = this.generatorOptions) === null || _b === void 0 ? void 0 : _b.checkStrength) === null || _c === void 0 ? void 0 : _c.call(_b, newValue)) !== null && _d !== void 0 ? _d : true;
77
+ attempts++;
78
+ } while (!isStrong && attempts < 100);
79
+ if (isStrong) {
80
+ this._value = newValue;
81
+ }
82
+ else {
83
+ throw new Error('Failed to generate a strong password.');
84
+ }
72
85
  const field = this.renderRoot.querySelector('vaadin-password-field');
73
86
  // @ts-expect-error: this is a private method but it's ok since the version is fixed
74
87
  field === null || field === void 0 ? void 0 : field._setPasswordVisible(true);
@@ -1 +1 @@
1
- {"version":3,"file":"InternalPasswordControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalPasswordControl/InternalPasswordControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,8DAA2D;AAC7F,OAAO,EAAE,sBAAsB,EAAE,oCAAiC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD;;;;;GAKG;AACH,MAAM,OAAO,uBAAwB,SAAQ,uBAAuB;IAApE;;QAUE,qBAAgB,GAA4B,IAAI,CAAC;QAEjD,sDAAsD;QACtD,kBAAa,GAAG,KAAK,CAAC;QAEtB,WAAM,GAAyC,IAAI,CAAC;IAuDtD,CAAC;IArEC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,gBAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE;YAClE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE;YAC7D,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;IASD,aAAa;;QACX,OAAO,IAAI,CAAA;;wBAES,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;sBAC/B,IAAI,CAAC,UAAU;sBACf,IAAI,CAAC,WAAW;gBACtB,IAAI,CAAC,KAAK;gBACV,SAAS,OAAC,IAAI,CAAC,MAAM,mCAAI,KAAK,CAAC,CAAC;;oBAE5B,IAAI,CAAC,QAAQ;oBACb,IAAI,CAAC,QAAQ;yBACR,IAAI,CAAC,cAAc;iBAC3B,IAAI,CAAC,MAAM;mBACT,CAAC,GAAkB,EAAE,EAAE,WAAC,OAAA,GAAG,CAAC,GAAG,KAAK,OAAO,WAAI,IAAI,CAAC,OAAO,0CAAE,MAAM,GAAE,CAAA,EAAA;iBACvE,CAAC,GAAgB,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAG,GAAG,CAAC,aAAqC,CAAC;YACvD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QAC3B,CAAC;;UAEC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE;;KAEvD,CAAC;IACJ,CAAC;IAED,IAAc,MAAM;;QAClB,aAAQ,KAAK,CAAC,MAA6B,mCAAI,EAAE,CAAC;IACpD,CAAC;IAED,IAAc,MAAM,CAAC,QAAgB;QACnC,KAAK,CAAC,MAAM,GAAG,QAA+B,CAAC;IACjD,CAAC;IAEO,iBAAiB;QACvB,OAAO,IAAI,CAAA;;;gBAGC,QAAQ,CAAC;YACf,2EAA2E,EAAE,IAAI;YACjF,yCAAyC,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ;YAC3E,kBAAkB,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ;SACnD,CAAC;;iBAEO,GAAG,EAAE;;YACZ,IAAI,CAAC,MAAM,GAAG,sBAAsB,OAAC,IAAI,CAAC,gBAAgB,mCAAI,KAAK,CAAC,CAAC,CAAC;YACtE,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;YACrE,oFAAoF;YACpF,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,CAAC,IAAI,EAAE;QACnC,CAAC;;UAEC,GAAG,CAAA,g1BAAg1B;;KAEx1B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { PasswordFieldElement } from '@vaadin/vaadin-text-field/vaadin-password-field';\nimport type { GeneratorOptions } from './generateRandomPassword';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { generateRandomPassword } from './generateRandomPassword';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-element';\nimport { classMap } from '../../../utils/class-map';\n\n/**\n * Internal control displaying a basic password box.\n *\n * @since 1.17.0\n * @element foxy-internal-password-field-control\n */\nexport class InternalPasswordControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n generatorOptions: { type: Object, attribute: 'generator-options' },\n showGenerator: { type: Boolean, attribute: 'show-generator' },\n layout: {},\n };\n }\n\n generatorOptions: null | GeneratorOptions = null;\n\n /** If true, renders the password generator button. */\n showGenerator = false;\n\n layout: 'standalone' | 'summary-item' | null = null;\n\n renderControl(): TemplateResult {\n return html`\n <vaadin-password-field\n error-message=${ifDefined(this._errorMessage)}\n helper-text=${this.helperText}\n placeholder=${this.placeholder}\n label=${this.label}\n theme=${ifDefined(this.layout ?? void 0)}\n class=\"w-full\"\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .checkValidity=${this._checkValidity}\n .value=${this._value}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @input=${(evt: CustomEvent) => {\n const area = evt.currentTarget as PasswordFieldElement;\n this._value = area.value;\n }}\n >\n ${this.showGenerator ? this.__renderGenerator() : ''}\n </vaadin-password-field>\n `;\n }\n\n protected get _value(): string {\n return (super._value as string | undefined) ?? '';\n }\n\n protected set _value(newValue: string) {\n super._value = newValue as unknown | undefined;\n }\n\n private __renderGenerator(): TemplateResult {\n return html`\n <div\n data-testid=\"generator\"\n class=${classMap({\n 'w-s h-s flex items-center justify-center cursor-default transition-colors': true,\n 'text-contrast-60 hover-text-contrast-80': !this.disabled && !this.readonly,\n 'text-contrast-20': this.disabled || this.readonly,\n })}\n slot=\"suffix\"\n @click=${() => {\n this._value = generateRandomPassword(this.generatorOptions ?? void 0);\n const field = this.renderRoot.querySelector('vaadin-password-field');\n // @ts-expect-error: this is a private method but it's ok since the version is fixed\n field?._setPasswordVisible(true);\n }}\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1.15em; height: 1.15em\"><path d=\"M15.98 1.804a1 1 0 00-1.96 0l-.24 1.192a1 1 0 01-.784.785l-1.192.238a1 1 0 000 1.962l1.192.238a1 1 0 01.785.785l.238 1.192a1 1 0 001.962 0l.238-1.192a1 1 0 01.785-.785l1.192-.238a1 1 0 000-1.962l-1.192-.238a1 1 0 01-.785-.785l-.238-1.192zM6.949 5.684a1 1 0 00-1.898 0l-.683 2.051a1 1 0 01-.633.633l-2.051.683a1 1 0 000 1.898l2.051.684a1 1 0 01.633.632l.683 2.051a1 1 0 001.898 0l.683-2.051a1 1 0 01.633-.633l2.051-.683a1 1 0 000-1.898l-2.051-.683a1 1 0 01-.633-.633L6.95 5.684zM13.949 13.684a1 1 0 00-1.898 0l-.184.551a1 1 0 01-.632.633l-.551.183a1 1 0 000 1.898l.551.183a1 1 0 01.633.633l.183.551a1 1 0 001.898 0l.184-.551a1 1 0 01.632-.633l.551-.183a1 1 0 000-1.898l-.551-.184a1 1 0 01-.633-.632l-.183-.551z\" /></svg>`}\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"InternalPasswordControl.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalPasswordControl/InternalPasswordControl.ts"],"names":[],"mappings":"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","sourcesContent":["import type { PropertyDeclarations, TemplateResult } from 'lit-element';\nimport type { PasswordFieldElement } from '@vaadin/vaadin-text-field/vaadin-password-field';\nimport type { GeneratorOptions } from './generateRandomPassword';\n\nimport { InternalEditableControl } from '../InternalEditableControl/InternalEditableControl';\nimport { generateRandomPassword } from './generateRandomPassword';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-element';\nimport { classMap } from '../../../utils/class-map';\n\n/**\n * Internal control displaying a basic password box.\n *\n * @since 1.17.0\n * @element foxy-internal-password-field-control\n */\nexport class InternalPasswordControl extends InternalEditableControl {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n generatorOptions: { type: Object, attribute: 'generator-options' },\n showGenerator: { type: Boolean, attribute: 'show-generator' },\n layout: {},\n };\n }\n\n generatorOptions: null | GeneratorOptions = null;\n\n /** If true, renders the password generator button. */\n showGenerator = false;\n\n layout: 'standalone' | 'summary-item' | null = null;\n\n renderControl(): TemplateResult {\n return html`\n <vaadin-password-field\n error-message=${ifDefined(this._errorMessage)}\n helper-text=${this.helperText}\n placeholder=${this.placeholder}\n label=${this.label}\n theme=${ifDefined(this.layout ?? void 0)}\n class=\"w-full\"\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n .checkValidity=${this._checkValidity}\n .value=${this._value}\n @keydown=${(evt: KeyboardEvent) => evt.key === 'Enter' && this.nucleon?.submit()}\n @input=${(evt: CustomEvent) => {\n const area = evt.currentTarget as PasswordFieldElement;\n this._value = area.value;\n }}\n >\n ${this.showGenerator ? this.__renderGenerator() : ''}\n </vaadin-password-field>\n `;\n }\n\n protected get _value(): string {\n return (super._value as string | undefined) ?? '';\n }\n\n protected set _value(newValue: string) {\n super._value = newValue as unknown | undefined;\n }\n\n private __renderGenerator(): TemplateResult {\n return html`\n <div\n data-testid=\"generator\"\n class=${classMap({\n 'w-s h-s flex items-center justify-center cursor-default transition-colors': true,\n 'text-contrast-60 hover-text-contrast-80': !this.disabled && !this.readonly,\n 'text-contrast-20': this.disabled || this.readonly,\n })}\n slot=\"suffix\"\n @click=${() => {\n let isStrong = false;\n let newValue: string;\n let attempts = 0;\n\n do {\n newValue = generateRandomPassword(this.generatorOptions ?? void 0);\n isStrong = this.generatorOptions?.checkStrength?.(newValue) ?? true;\n attempts++;\n } while (!isStrong && attempts < 100);\n\n if (isStrong) {\n this._value = newValue;\n } else {\n throw new Error('Failed to generate a strong password.');\n }\n\n const field = this.renderRoot.querySelector('vaadin-password-field');\n // @ts-expect-error: this is a private method but it's ok since the version is fixed\n field?._setPasswordVisible(true);\n }}\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" style=\"width: 1.15em; height: 1.15em\"><path d=\"M15.98 1.804a1 1 0 00-1.96 0l-.24 1.192a1 1 0 01-.784.785l-1.192.238a1 1 0 000 1.962l1.192.238a1 1 0 01.785.785l.238 1.192a1 1 0 001.962 0l.238-1.192a1 1 0 01.785-.785l1.192-.238a1 1 0 000-1.962l-1.192-.238a1 1 0 01-.785-.785l-.238-1.192zM6.949 5.684a1 1 0 00-1.898 0l-.683 2.051a1 1 0 01-.633.633l-2.051.683a1 1 0 000 1.898l2.051.684a1 1 0 01.633.632l.683 2.051a1 1 0 001.898 0l.683-2.051a1 1 0 01.633-.633l2.051-.683a1 1 0 000-1.898l-2.051-.683a1 1 0 01-.633-.633L6.95 5.684zM13.949 13.684a1 1 0 00-1.898 0l-.184.551a1 1 0 01-.632.633l-.551.183a1 1 0 000 1.898l.551.183a1 1 0 01.633.633l.183.551a1 1 0 001.898 0l.184-.551a1 1 0 01.632-.633l.551-.183a1 1 0 000-1.898l-.551-.184a1 1 0 01-.633-.632l-.183-.551z\" /></svg>`}\n </div>\n `;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  export declare type GeneratorOptions = {
2
- length?: number;
3
- charset?: string;
2
+ checkStrength?: (value: string) => boolean;
4
3
  separator?: string;
4
+ charset?: string;
5
+ length?: number;
5
6
  };
6
7
  export declare function generateRandomPassword(opts?: GeneratorOptions): string;
@@ -1 +1 @@
1
- {"version":3,"file":"generateRandomPassword.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalPasswordControl/generateRandomPassword.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CAAC,IAAuB;;IAC5D,MAAM,SAAS,SAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,mCAAI,GAAG,CAAC;IACzC,MAAM,OAAO,SAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,mCAAI,gEAAgE,CAAC;IAClG,MAAM,MAAM,SAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,mCAAI,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,SAAS,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC;QAC3D,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;KAC/D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["export type GeneratorOptions = { length?: number; charset?: string; separator?: string };\n\nexport function generateRandomPassword(opts?: GeneratorOptions): string {\n const separator = opts?.separator ?? '-';\n const charset = opts?.charset ?? 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const length = opts?.length ?? 18;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n if (separator && i > 0 && i % 6 === 0) result += separator;\n result += charset[Math.floor(Math.random() * charset.length)];\n }\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"generateRandomPassword.js","sourceRoot":"","sources":["../../../../src/elements/internal/InternalPasswordControl/generateRandomPassword.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,sBAAsB,CAAC,IAAuB;;IAC5D,MAAM,SAAS,SAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,mCAAI,GAAG,CAAC;IACzC,MAAM,OAAO,SAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,mCAAI,gEAAgE,CAAC;IAClG,MAAM,MAAM,SAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,mCAAI,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,SAAS,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC;QAC3D,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;KAC/D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["export type GeneratorOptions = {\n checkStrength?: (value: string) => boolean;\n separator?: string;\n charset?: string;\n length?: number;\n};\n\nexport function generateRandomPassword(opts?: GeneratorOptions): string {\n const separator = opts?.separator ?? '-';\n const charset = opts?.charset ?? 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const length = opts?.length ?? 18;\n let result = '';\n\n for (let i = 0; i < length; i++) {\n if (separator && i > 0 && i % 6 === 0) result += separator;\n result += charset[Math.floor(Math.random() * charset.length)];\n }\n\n return result;\n}\n"]}
@@ -22,6 +22,7 @@ export declare class CustomerForm extends Base<Data> {
22
22
  passwordless: boolean;
23
23
  /** Full `fx:customer_portal_settings` resource from Customer API. If present, switches this element into the Customer API mode, enabling client verification. */
24
24
  settings: Settings | null;
25
+ private readonly __passwordGeneratorOptions;
25
26
  private readonly __isAnonymousGetValue;
26
27
  private readonly __isAnonymousSetValue;
27
28
  private readonly __isAnonymousOptions;
@@ -22,6 +22,9 @@ export class CustomerForm extends Base {
22
22
  this.passwordless = false;
23
23
  /** Full `fx:customer_portal_settings` resource from Customer API. If present, switches this element into the Customer API mode, enabling client verification. */
24
24
  this.settings = null;
25
+ this.__passwordGeneratorOptions = {
26
+ checkStrength: value => passwordStrength(value).id >= 2,
27
+ };
25
28
  this.__isAnonymousGetValue = () => {
26
29
  var _a;
27
30
  return ((_a = this.form) === null || _a === void 0 ? void 0 : _a.is_anonymous) === false ? 'false' : 'true';
@@ -117,8 +120,9 @@ export class CustomerForm extends Base {
117
120
  return new BooleanSelector(Array.from(hidden).join(' ').trim());
118
121
  }
119
122
  get headerTitleOptions() {
123
+ var _a, _b;
120
124
  const data = this.data;
121
- if (!data || data.first_name.trim() || data.last_name.trim())
125
+ if (!data || ((_a = data.first_name) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = data.last_name) === null || _b === void 0 ? void 0 : _b.trim()))
122
126
  return super.headerTitleOptions;
123
127
  return { ...super.headerTitleOptions, context: 'no_name' };
124
128
  }
@@ -175,6 +179,7 @@ export class CustomerForm extends Base {
175
179
  helper-text=${this.__passwordHelperText}
176
180
  infer="password"
177
181
  show-generator
182
+ .generatorOptions=${this.__passwordGeneratorOptions}
178
183
  >
179
184
  </foxy-internal-password-control>
180
185