@foxy.io/elements 1.11.0-beta.1 → 1.11.0-beta.2

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.
@@ -969,4 +969,4 @@ This program is available under Apache License Version 2.0, available at https:/
969
969
 
970
970
  <iron-media-query query="[[_fullscreenMediaQuery]]" query-matches="{{_fullscreen}}">
971
971
  </iron-media-query>
972
- `}static get is(){return"vaadin-date-picker"}static get version(){return"4.4.1"}static get properties(){return{clearButtonVisible:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1,reflectToAttribute:!0},errorMessage:String,placeholder:String,helperText:{type:String,value:""},readonly:{type:Boolean,value:!1,reflectToAttribute:!0},invalid:{type:Boolean,reflectToAttribute:!0,notify:!0,value:!1},_userInputValue:String}}static get observers(){return["_userInputValueChanged(_userInputValue)","_setClearButtonLabel(i18n.clear)"]}ready(){super.ready(),re(this,(()=>this._inputElement.validate=()=>{})),this._inputElement.addEventListener("change",(e=>{""!==this._inputElement.value||e.__fromClearButton||(this.__dispatchChange=!0)}))}_onVaadinOverlayClose(e){this._openedWithFocusRing&&this.hasAttribute("focused")?this.focusElement.setAttribute("focus-ring",""):this.hasAttribute("focused")||this.focusElement.blur(),e.detail.sourceEvent&&-1!==e.detail.sourceEvent.composedPath().indexOf(this)&&e.preventDefault()}_toggle(e){e.stopPropagation(),this[this._overlayInitialized&&this.$.overlay.opened?"close":"open"]()}_input(){return this.$.input}set _inputValue(e){this._inputElement.value=e}get _inputValue(){return this._inputElement.value}_getAriaExpanded(e){return Boolean(e).toString()}get focusElement(){return this._input()||this}_setClearButtonLabel(e){this._inputElement.shadowRoot.querySelector('[part="clear-button"]').setAttribute("aria-label",e)}}customElements.define(Js.is,Js);class Zs extends $t{}let ei,ti,si,ii,ai=e=>e;class ni extends W{constructor(){super(...arguments),this.value=[],this.disabled=!1,this.__startValue="",this.__endValue=""}static get scopedElements(){return{"vaadin-date-picker":Js,"vaadin-button":N,"x-skeleton":G,"iron-icon":customElements.get("iron-icon"),"x-i18n":X,"x-list":Ct}}static get properties(){return C(C({},super.properties),{},{value:{type:Array},disabled:{type:Boolean}})}render(){const e=this.value.length>=20||this.disabled||!this._isI18nReady;return E(ei||(ei=ai` <x-list data-testid="list" .value="${0}" .disabled="${0}" @change="${0}"> ${0} <div class="sm-flex sm-items-end"> <div class="grid grid-cols-2 gap-s"> <vaadin-date-picker data-testid="start" .label="${0}" .value="${0}" .disabled="${0}" .placeholder="${0}" @change="${0}"> </vaadin-date-picker> <vaadin-date-picker data-testid="end" .min="${0}" .label="${0}" .value="${0}" .disabled="${0}" .placeholder="${0}" clear-button-visible @change="${0}"> </vaadin-date-picker> </div> <vaadin-button .disabled="${0}" data-testid="submit" class="w-full mt-s sm-mt-0 sm-w-auto sm-ml-s" @click="${0}"> <x-i18n .lang="${0}" .key="ndmod.add_${0}" .ns="${0}"> </x-i18n> <iron-icon icon="icons:add" slot="suffix"></iron-icon> </vaadin-button> </div> ${0} </x-list> `),this.value,this.disabled||!this._isI18nReady,this.__handleListChange,this.value.map(((e,t)=>this._isI18nReady?E(ti||(ti=ai`<span slot="${0}" class="truncate">${0}</span>`),t,Ms(e,this.lang)):E(si||(si=ai`<x-skeleton slot="${0}">${0}</x-skeleton>`),t,e))),this._t("ndmod.range_start").toString(),this.__startValue,e,this._isI18nReady?this._t("ndmod.select").toString():"",this.__handleStartValueChange,this.__startValue,this._t("ndmod.range_end").toString(),this.__endValue,e||!this.__startValue,this._isI18nReady?this._t("ndmod.select").toString():"",this.__handleEndValueChange,e||!this.__startValue,this.__submit,this.lang,this.__endValue?"range":"single",this.ns,this.value.length>0?E(ii||(ii=ai` <x-i18n .ns="${0}" .lang="${0}" key="ndmod.add_range_hint" class="${0}"> </x-i18n> `),this.ns,this.lang,ue({"block text-xs mt-xs text-center sm-text-left":!0,"text-tertiary":this.value.length<20,"text-primary":this.value.length>=20})):"")}updated(){const e=this.constructor.getScopedTagName("vaadin-date-picker"),t=this.shadowRoot.querySelectorAll(e);Array.from(t).forEach((e=>e.validate()))}__handleStartValueChange(e){e.stopPropagation(),this.__startValue=e.target.value;const t=$e(this.__endValue),s=$e(this.__startValue);t&&t.getTime()<s.getTime()&&(this.__endValue=""),this.requestUpdate()}__handleEndValueChange(e){e.stopPropagation(),this.__endValue=e.target.value,this.requestUpdate()}__submit(){this.__startValue&&this.__endValue?this.value=[...this.value,[this.__startValue,this.__endValue].join("..")]:this.value=[...this.value,this.__startValue],this.__sendChange(),this.__startValue="",this.__endValue=""}__handleListChange(e){this.value=e.detail,this.__sendChange()}__sendChange(){this.dispatchEvent(new Zs(this.value))}}class ri extends CustomEvent{constructor(e){super("change",{detail:e})}}let oi,li,di=e=>e;class hi extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.type="min",this.__items=["none","custom"]}static get scopedElements(){return{"vaadin-text-field":customElements.get("vaadin-text-field"),"x-frequency-input":os,"x-choice":Z,"x-group":be,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:String},type:{type:String}})}render(){return E(oi||(oi=di` <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="${0}"> </x-i18n> <x-choice data-testid="choice" .disabled="${0}" .value="${0}" .items="${0}" @change="${0}"> <x-i18n slot="none-label" .ns="${0}" .lang="${0}" key="ndmod.none"></x-i18n> <x-i18n slot="custom-label" .ns="${0}" .lang="${0}" key="ndmod.custom"></x-i18n> ${0} </x-choice> </x-group> `),this.ns,this.lang,`ndmod.${this.type}`,this.disabled,this.__choice,this.__items,this.__handleChoiceChange,this.ns,this.lang,this.ns,this.lang,this.__choice===this.__items[1]?E(li||(li=di` <div slot="${0}" class="space-y-s"> <x-frequency-input data-testid="input" .value="${0}" .disabled="${0}" @change="${0}"> </x-frequency-input> <p class="text-s text-tertiary leading-s">${0}</p> </div> `),this.__items[1],this.value,this.disabled,this.__handleNewValueChange,this.__hint):"")}get __choice(){return this.__items[this.value?1:0]}get __hint(){var e;if(!this._isI18nReady)return"";const{count:t,units:s}=xe(null!==(e=this.value)&&void 0!==e?e:"");return this._t(`ndmod.${this.type}Hint`,{duration:this._t("duration",{count:t,units:this._t(null!=s?s:"",{count:t})})})}__handleNewValueChange(e){this.value=e.detail,this.__sendChange()}__handleChoiceChange(e){this.value=e.detail===this.__items[0]?void 0:"1w",this.__sendChange()}__sendChange(){this.dispatchEvent(new ri(this.value))}}class ui extends CustomEvent{constructor(e){super("change",{detail:e})}}class ci extends CustomEvent{constructor(){super("remove")}}let pi,_i,mi,vi,gi,fi,yi,bi,xi,wi=e=>e;class $i extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.value={jsonataQuery:"*"},this.open=!1}static get scopedElements(){return{"x-disallowed-dates":ni,"x-jsonata-input":ys,"x-offset-input":hi,"x-allowed-days":Rs,"iron-icon":customElements.get("iron-icon"),"x-warning":ke,"x-group":be,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:Object},open:{type:Boolean}})}render(){const{min:e,max:t,allowedDays:s,jsonataQuery:i,disallowedDates:a}=this.value,n=e||t,r=s&&s.days.length>0,o=a&&a.length>0,l=this.open?"":"rounded-b-l";return E(pi||(pi=wi` <x-group frame> <details data-testid="details" class="${0}" ?open="${0}" @toggle="${0}"> <summary class="${0} cursor-pointer relative leading-s rounded-t-l focus-outline-none focus-shadow-outline"> <div class="p-m mr-xl text-m text-header font-medium space-y-s"> <div> <x-i18n .ns="${0}" .lang="${0}" key="${0}"> ${0} </x-i18n> </div> ${0} </div> <button data-testid="remove" .disabled="${0}" class="flex items-center justify-center rounded absolute top-0 right-0 text-tertiary hover-text-secondary disabled-text-tertiary disabled-opacity-50 disabled-cursor-default focus-outline-none focus-shadow-outline" style="width:54px;height:54px" @click="${0}"> <iron-icon icon="lumo:cross"></iron-icon> </button> </summary> <article class="space-y-l"> <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="ndmod.match"> </x-i18n> <x-jsonata-input data-testid="jsonata" .ns="${0}" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-jsonata-input> </x-group> <div class="flex flex-col md-flex-row"> <div class="mb-l md-mb-0 md-w-1-2 md-border-r md-border-contrast-10"> <x-offset-input data-testid="min" type="min" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-offset-input> </div> <div class="md-w-1-2"> <x-offset-input data-testid="max" type="max" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-offset-input> </div> </div> ${0} <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="ndmod.allowed"> </x-i18n> <x-allowed-days data-testid="allowed" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-allowed-days> </x-group> <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="ndmod.excluded"> </x-i18n> <x-disallowed-dates data-testid="disallowed" .ns="${0}" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-disallowed-dates> </x-group> </article> </details> </x-group> `),ue({"font-lumo":!0,"pointer-events-none":!this._isI18nReady}),this.open,(()=>this.open=!this.open),l,this.ns,this.lang,`ndmod.${"*"===i?"all":"some"}Title`,"*"!==i?this.__renderJSONataSummary(i):"",n||r||o?E(_i||(_i=wi` <div> ${0} </div> `),se(n&&this.__renderMinMaxSummary(e,t),r&&this.__renderAllowedSummary(s),o&&this.__renderDisallowedSummary(a))):"",this.disabled||!this._isI18nReady,is((()=>this.dispatchEvent(new ci))),this.ns,this.lang,this.ns,this.lang,i,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{jsonataQuery:e.detail}),this.__sendUpdate()}),this.lang,e,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{min:e.detail}),this.__sendUpdate()}),this.lang,t,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{max:e.detail}),this.__sendUpdate()}),-1===this.__compareDurations(e,t)?E(mi||(mi=wi` <x-warning class="mx-m" data-testid="warning"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.minWarning"> </x-i18n> </x-warning> `),this.ns,this.lang):"",this.ns,this.lang,this.lang,s,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{allowedDays:e.detail}),this.__sendUpdate()}),this.ns,this.lang,this.ns,this.lang,null!=a?a:[],this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{disallowedDates:e.detail}),this.__sendUpdate()}))}__sendUpdate(){this.dispatchEvent(new ui(this.value))}__getEstimatedDaysFrom(e){const{count:t,units:s}=xe(e);return t*{y:365,m:31,w:7,d:1}[s]}__compareDurations(e,t){return e===t?0:e&&t?this.__getEstimatedDaysFrom(e)<this.__getEstimatedDaysFrom(t)?1:-1:1}__renderJSONataSummary(e){return E(vi||(vi=wi` <code class="inline-block rounded bg-success-10 text-success px-xs text-xs leading-s"> ${0} </code> `),e)}__renderMinMaxContent(e){if(e){const{count:t,units:s}=e;return E(gi||(gi=wi` ${0} <x-i18n .ns="${0}" .lang="${0}" key="${0}" .opts="${0}"></x-i18n> `),t,this.ns,this.lang,s,{count:t})}return E(fi||(fi=wi`<x-i18n .ns="${0}" .lang="${0}" key="ndmod.any"></x-i18n>`),this.ns,this.lang)}__renderMinMaxSummary(e,t){return E(yi||(yi=wi` <div class="text-s text-tertiary font-normal"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.range"> <span>:</span> <span class="text-secondary"> ${0} &mdash; ${0} </span> </x-i18n> </div> `),this.ns,this.lang,this.__renderMinMaxContent(e?xe(e):void 0),this.__renderMinMaxContent(t?xe(t):void 0))}__renderAllowedSummary({type:e,days:t}){return E(bi||(bi=wi` <div class="text-s text-tertiary font-normal"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.allowed"> <span>:</span> <span class="text-secondary"> ${0} ${0} </span> </x-i18n> </div> `),this.ns,this.lang,"month"===e?t.join(", "):"","day"===e?t.map((e=>ie(e,this.lang,"short"))).join(", "):"")}__renderDisallowedSummary(e){return E(xi||(xi=wi` <div class="text-s text-tertiary font-normal"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.excluded"> <span>:</span> <span class="text-secondary"> ${0} </span> </x-i18n> </div> `),this.ns,this.lang,e.map((e=>Ms(e,this.lang))).join("; "))}}class ki extends CustomEvent{constructor(e){super("change",{detail:e})}}let Di,Si,Ci,Ei=e=>e;class Ii extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.value=!1}static get scopedElements(){return{"x-next-date-modification-rule":$i,"vaadin-button":customElements.get("vaadin-button"),"x-section":Nt,"iron-icon":customElements.get("iron-icon"),"x-switch":Yt,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:Array}})}render(){const e=!this._isI18nReady||this.disabled||!this.value||Array.isArray(this.value)&&this.value.length>=10;return E(Di||(Di=Ei` <x-section> <x-switch slot="title" class="-my-xs" data-testid="toggle" .checked="${0}" .disabled="${0}" @change="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.title" class="text-l"></x-i18n> </x-switch> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.subtitle" slot="subtitle" class="mr-xl"> </x-i18n> ${0} <div class="mt-m sm-flex sm-items-center"> <vaadin-button class="w-full sm-w-auto" data-testid="add" theme="primary" .disabled="${0}" @click="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.add"></x-i18n> <iron-icon icon="lumo:plus" slot="suffix"></iron-icon> </vaadin-button> <x-i18n .lang="${0}" .ns="${0}" key="ndmod.add_hint" class="${0}"> </x-i18n> </div> </x-section> `),Boolean(this.value),this.disabled||!this._isI18nReady,this.__toggleValue,this.ns,this.lang,this.ns,this.lang,this.value?E(Si||(Si=Ei` ${0} `),this.__normalizedValue.map(((e,t,s)=>E(Ci||(Ci=Ei` <x-next-date-modification-rule data-testid="rule" .disabled="${0}" .value="${0}" .lang="${0}" @remove="${0}" @change="${0}"> </x-next-date-modification-rule> `),this.disabled||!this._isI18nReady,e,this.lang,(()=>{this.value=s.filter(((e,s)=>s!==t)),this.__sendChange()}),(e=>{this.value=s.map(((s,i)=>i===t?e.detail:s)),this.__sendChange()}))))):"",e,this.__addRule,this.ns,this.lang,this.lang,this.ns,ue({"text-xs text-center block font-lumo mt-xs transition duration-200 sm-mt-0 sm-ml-m":!0,"text-tertiary":Array.isArray(this.value)&&this.value.length<10,"text-primary":Array.isArray(this.value)&&this.value.length>=10,hidden:!Array.isArray(this.value)||0===this.value.length}))}get __normalizedValue(){return"boolean"==typeof this.value?[]:this.value}__addRule(){this.value=[...this.__normalizedValue,{jsonataQuery:"*"}],this.__sendChange()}__toggleValue(){this.value=!this.value,this.__sendChange()}__sendChange(){this.dispatchEvent(new ki(this.value))}}class Ai extends $t{}let Mi,Ti,Oi,Vi=e=>e;class ji extends W{constructor(){super(...arguments),this.value=[],this.disabled=!1,this.__errorCode="invalid",this.__invalid=!1,this.__newValue=""}static get scopedElements(){return{"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"x-skeleton":G,"iron-icon":customElements.get("iron-icon"),"x-group":be,"x-list":Ct,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{value:{type:Array},invalid:{type:Boolean},disabled:{type:Boolean}})}render(){return E(Mi||(Mi=Vi` <x-group frame> <x-list data-testid="list" .disabled="${0}" .value="${0}" @change="${0}"> ${0} <div class="flex flex-col sm-flex-row sm-items-start"> <vaadin-text-field data-testid="input" class="mb-s sm-mb-0 sm-mr-s" .placeholder="${0}" .errorMessage="${0}" .disabled="${0}" .invalid="${0}" .value="${0}" @keypress="${0}" @change="${0}" @input="${0}"> </vaadin-text-field> <div class="sm-flex sm-items-center"> <vaadin-button class="w-full sm-w-auto" data-testid="button" .disabled="${0}" @click="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="origins.add"></x-i18n> <iron-icon icon="lumo:plus" slot="suffix"></iron-icon> </vaadin-button> <x-i18n .lang="${0}" .ns="${0}" key="origins.add_hint" class="${0}"> </x-i18n> </div> </div> </x-list> </x-group> `),this.disabled||!this._isI18nReady,this.value,this.__handleChange,this.value.map(((e,t)=>this._isI18nReady?E(Ti||(Ti=Vi` <div class="flex items-center" slot="${0}"> <img height="16" width="16" class="mr-m" src="https://www.google.com/s2/favicons?domain=${0}"> ${0} </div> `),t,e,e):E(Oi||(Oi=Vi`<x-skeleton slot="${0}">${0}</x-skeleton>`),t,e))),this._isI18nReady?"https://foxy.io":"",this._t(`origins.${this.__errorCode}`).toString(),this.disabled||!this._isI18nReady,this.__invalid,this.__newValue,(e=>"Enter"===e.key&&this.__submit()),(e=>e.stopPropagation()),this.__handleInput,!this._isI18nReady||this.disabled||this.__invalid||this.value.length>=10,this.__submit,this.ns,this.lang,this.lang,this.ns,ue({"text-xs text-center block font-lumo mt-xs transition duration-200 sm-mt-0 sm-ml-m":!0,"text-tertiary":this.value.length<10,"text-primary":this.value.length>=10,hidden:0===this.value.length}))}__sendChange(){this.dispatchEvent(new Ai(this.value))}__handleInput(e){this.__newValue=e.target.value;try{const e=new URL(this.__newValue),t="https:"===e.protocol,s="localhost"===e.hostname;this.__invalid=!s&&!t,this.__errorCode="https_only"}catch(e){this.__invalid=this.__newValue.length>0,this.__errorCode="invalid"}this.requestUpdate()}__submit(){this.__newValue.length>0&&(this.value=[...this.value,new URL(this.__newValue).origin],this.__newValue="",this.__invalid=!1,this.__sendChange()),this.requestUpdate()}__handleChange(e){this.value=e.detail,this.__sendChange()}}class Fi extends CustomEvent{constructor(e){super("change",{detail:e})}}let Ri,Pi=e=>e;class Ni extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.value=!1}static get scopedElements(){return{"x-section":Nt,"x-switch":Yt,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:Array}})}render(){return E(Ri||(Ri=Pi` <x-section> <x-switch slot="title" class="-my-xs" data-testid="toggle" .checked="${0}" .disabled="${0}" @change="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="sso.title" class="text-l"></x-i18n> </x-switch> <x-i18n .ns="${0}" .lang="${0}" key="sso.subtitle" slot="subtitle" class="mr-xl"> </x-i18n> </x-section> `),Boolean(this.value),this.disabled||!this._isI18nReady,this.__toggleValue,this.ns,this.lang,this.ns,this.lang)}__toggleValue(){this.value=!this.value,this.__sendChange()}__sendChange(){this.dispatchEvent(new Fi(this.value))}}const Bi=ae.assign({error:(e,t)=>t.data.type}),zi=ae.assign({oldResource:(e,t)=>t.data.resource,newResource:(e,t)=>t.data.resource,store:(e,t)=>t.data.store}),qi=ae.assign({oldResource:e=>e.newResource}),Yi=ae.assign({invalid:[],newResource:({oldResource:e})=>e}),Li=ae.assign({invalid:[],newResource:e=>({allowedOrigins:[],subscriptions:{allowFrequencyModification:[],allowNextDateModification:!1},jwtSharedSecret:wt(72,(()=>bt(35).toString(36))).join(""),sessionLifespanInMinutes:40320,sso:!1,date_created:(new Date).toISOString(),date_modified:(new Date).toISOString(),_links:{"fx:store":e.store._links.self,curies:e.store._links.curies,self:e.store._links["fx:customer_portal_settings"]}})}),Wi=ae.assign({newResource:null}),Hi=ae.assign({error:"setup_needed"}),Ui=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{allowedOrigins:s})}}),Xi=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{subscriptions:C(C({},e.subscriptions),{},{allowFrequencyModification:s})})}}),Ki=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{subscriptions:C(C({},e.subscriptions),{},{allowNextDateModification:s})})}}),Qi=ae.assign({invalid:(e,t)=>{const s="sessionLifespanInMinutes",i=t.invalid;return e.invalid.filter((e=>e!==s)).concat(...i?[s]:[])},newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{sessionLifespanInMinutes:s})}}),Gi=ae.assign({invalid:(e,t)=>{const s="jwtSharedSecret",i=t.invalid;return e.invalid.filter((e=>e!==s)).concat(...i?[s]:[])},newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{jwtSharedSecret:s})}}),Ji=ae.assign({oldResource:null,newResource:null,store:null,error:null,href:(e,t)=>t.data}),Zi=ae.assign({newResource:({newResource:e},t)=>{const s=t.data;return C(C({},e),{},{sso:s})}}),ea={SET_SSO:{target:"#cps.idle",actions:"setSSO"},SET_SECRET:{target:"#cps.idle",actions:"setSecret"},SET_ORIGINS:{target:"#cps.idle",actions:"setOrigins"},SET_SESSION:{target:"#cps.idle",actions:"setSession"},SET_FREQUENCY_MODIFICATION:{target:"#cps.idle",actions:"setFrequencyModification"},SET_NEXT_DATE_MODIFICATION:{target:"#cps.idle",actions:"setNextDateModification"}},ta={initial:"unknown",states:{unknown:{always:[{target:"invalid",cond:"isInvalid"},{target:"valid"}]},invalid:{},valid:{}}},sa=A({id:"cps",initial:"unknown",context:{oldResource:null,newResource:null,invalid:[],store:null,error:null,href:null},states:{unknown:{always:[{target:"error",cond:"isSetupNeeded",actions:"requireSetup"},{target:"idle",cond:"isLoaded"},{target:"busy"}]},error:{on:{RELOAD:{target:"busy.loading"}}},busy:{initial:"loading",states:{loading:{invoke:{src:"load",onDone:{target:"#cps.idle.clean",actions:"handleLoadingSuccess"},onError:{target:"#cps.error",actions:"handleError"}}},saving:{invoke:{src:"save",onDone:{target:"#cps.idle.clean",actions:"handleSavingSuccess"},onError:{target:"#cps.error",actions:"handleError"}}}}},idle:{initial:"unknown",on:{DISABLE:{target:"#cps.idle",actions:"remove"},ENABLE:{target:"#cps.idle",actions:"create"},RESET:{target:"#cps.idle",actions:"reset"}},states:{unknown:{always:[{target:"clean",cond:"isClean"},{target:"dirty"}]},clean:{initial:"unknown",states:{unknown:{always:[{target:"enabled",cond:"isEnabled"},{target:"disabled"}]},enabled:{on:ea},disabled:{}}},dirty:{on:{SAVE:"#cps.busy.saving"},initial:"unknown",states:{unknown:{always:[{target:"created",cond:"isCreated"},{target:"deleted",cond:"isDeleted"},{target:"updated"}]},created:C({on:ea},ta),updated:C({on:ea},ta),deleted:{}}}}}},on:{SET_HREF:{actions:"setHref",target:"unknown"}}},{guards:{isClean:e=>M(e.newResource,e.oldResource),isLoaded:e=>null!==e.store,isInvalid:e=>e.invalid.length>0,isEnabled:e=>null!==e.oldResource,isCreated:e=>null===e.oldResource&&null!==e.newResource,isDeleted:e=>null!==e.oldResource&&null===e.newResource,isSetupNeeded:e=>null===e.href},actions:{setFrequencyModification:Xi,setNextDateModification:Ki,setOrigins:Ui,setSession:Qi,setSecret:Gi,setHref:Ji,setSSO:Zi,handleLoadingSuccess:zi,handleSavingSuccess:qi,handleError:Bi,create:Li,reset:Yi,remove:Wi,requireSetup:Hi}});let ia,aa,na,ra,oa=e=>e;function la(e){if(!e.ok)throw new Y(401===e.status?"unauthorized":"unknown")}class da extends CustomEvent{constructor(){super("ready")}}class ha extends CustomEvent{constructor(){super("update")}}class ua extends W{constructor(){super("customer-portal-settings"),this.rel="customer_portal_settings",this.__machine=sa.withConfig({services:{load:()=>this.__load(),save:()=>this.__save()}}),this.__service=De(this.__machine).onTransition((({changed:e})=>e&&this.requestUpdate())).onChange((()=>this.requestUpdate())).start()}static get scopedElements(){return{"iron-icon":customElements.get("iron-icon"),"vaadin-button":customElements.get("vaadin-button"),"x-frequency-modification":As,"x-next-date-modification":Ii,"x-session-duration":Jt,"x-session-secret":ss,"x-loading-screen":Mt,"x-error-screen":q,"x-origins-list":ji,"x-sso-switch":Ni,"x-skeleton":G,"x-section":Nt,"x-switch":Yt,"x-i18n":X,"x-page":jt}}static get properties(){return C(C({},super.properties),{},{href:{type:String,noAccessor:!0}})}get href(){return this.__service.state.context.href}set href(e){this.__service.send({type:"SET_HREF",data:e})}render(){var e,t,s,i,a,n;if(this.__service.state.matches("error"))return E(ia||(ia=oa` <x-error-screen data-testid="error" lang="${0}" type="${0}" reload @reload="${0}"> </x-error-screen> `),this.lang,this.__service.state.context.error,this.__reload);const{newResource:r}=this.__service.state.context,o=this.__service.state.matches("idle.dirty.created"),l=this.__service.state.matches("idle.dirty.deleted"),d=this.__service.state.matches("idle.dirty.updated"),h=this.__service.state.matches("idle.clean.enabled"),u=this.__service.state.matches("idle.dirty.updated.invalid")||this.__service.state.matches("idle.dirty.created.invalid");return E(aa||(aa=oa` <x-page class="relative"> <x-switch slot="title" data-testid="switch" .disabled="${0}" .checked="${0}" @change="${0}"> <x-i18n key="title" class="text-xxl" .ns="${0}" .lang="${0}"> <sup class="text-tertiary"> <x-i18n key="beta" .ns="${0}" .lang="${0}"> </x-i18n> </sup> </x-i18n> </x-switch> <x-i18n class="block mr-xl" slot="subtitle" key="subtitle" .ns="${0}" .lang="${0}"> </x-i18n> <x-section> <x-i18n slot="title" key="origins.title" .ns="${0}" .lang="${0}"></x-i18n> <x-i18n slot="subtitle" key="origins.subtitle" .ns="${0}" .lang="${0}"></x-i18n> <x-origins-list data-testid="origins" .lang="${0}" .ns="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-origins-list> </x-section> <x-frequency-modification data-testid="fmod" .lang="${0}" .ns="${0}" .value="${0}" ?disabled="${0}" @change="${0}"> </x-frequency-modification> <x-next-date-modification data-testid="ndmod" .lang="${0}" .ns="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-next-date-modification> <x-sso-switch data-testid="sso" .lang="${0}" .ns="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-sso-switch> <x-section> <x-i18n slot="title" key="advanced.title" .ns="${0}" .lang="${0}"></x-i18n> <x-i18n slot="subtitle" key="advanced.subtitle" .ns="${0}" .lang="${0}"> </x-i18n> <x-session-duration data-testid="session" .disabled="${0}" .value="${0}" .lang="${0}" .ns="${0}" @change="${0}"> </x-session-duration> <x-session-secret data-testid="secret" .disabled="${0}" .value="${0}" .lang="${0}" .ns="${0}" @change="${0}"> </x-session-secret> </x-section> ${0} </x-page> `),!this.__service.state.matches("idle")||!this._isI18nReady,h||o||d,(e=>{this.__service.send(e.detail?"ENABLE":"DISABLE")}),this.ns,this.lang,this.ns,this.lang,this.ns,this.lang,this.ns,this.lang,this.ns,this.lang,this.lang,this.ns,null!==(e=null==r?void 0:r.allowedOrigins)&&void 0!==e?e:[],!r,(e=>{this.__service.send({type:"SET_ORIGINS",value:e.detail})}),this.lang,this.ns,null!==(t=null==r?void 0:r.subscriptions.allowFrequencyModification)&&void 0!==t?t:[],!r,(e=>{this.__service.send({type:"SET_FREQUENCY_MODIFICATION",value:e.detail})}),this.lang,this.ns,null!==(s=null==r?void 0:r.subscriptions.allowNextDateModification)&&void 0!==s&&s,!r,(e=>{this.__service.send({type:"SET_NEXT_DATE_MODIFICATION",value:e.detail})}),this.lang,this.ns,null!==(i=null==r?void 0:r.sso)&&void 0!==i&&i,!r,(e=>{this.__service.send({type:"SET_SSO",value:e.detail})}),this.ns,this.lang,this.ns,this.lang,!r||!this._isI18nReady,null!==(a=null==r?void 0:r.sessionLifespanInMinutes)&&void 0!==a?a:1,this.lang,this.ns,(({detail:e})=>{this.__service.send(C({type:"SET_SESSION"},e))}),!r||!this._isI18nReady,null!==(n=null==r?void 0:r.jwtSharedSecret)&&void 0!==n?n:"",this.lang,this.ns,(({detail:e})=>{this.__service.send(C({type:"SET_SECRET"},e))}),this.__service.state.matches("idle.dirty")?E(na||(na=oa` <div class="sticky flex justify-between rounded-t-l rounded-b-l shadow-m -mx-s p-s bg-contrast" style="bottom:var(--lumo-space-m)"> <vaadin-button data-testid="save" theme="primary ${0}" .disabled="${0}" @click="${0}"> <x-i18n lang="${0}" ns="${0}" key="save_${0}"> </x-i18n> </vaadin-button> <vaadin-button style="--lumo-contrast:var(--lumo-base-color)" data-testid="reset" theme="contrast tertiary" @click="${0}"> <x-i18n lang="${0}" key="undo_all"></x-i18n> <iron-icon icon="lumo:reload" slot="suffix"></iron-icon> </vaadin-button> </div> `),l?"error":"success",u,(()=>this.__service.send("SAVE")),this.lang,this.ns,o?"create":l?"delete":"update",(()=>this.__service.send("RESET")),this.lang):this.__service.state.matches("busy")?E(ra||(ra=oa`<x-loading-screen data-testid="loading" class="mt-0"></x-loading-screen>`)):"")}async __reload(){this.__service.stop(),this.__service.onTransition((({changed:e})=>e&&this.requestUpdate())).onChange((()=>this.requestUpdate())).start()}async __load(){if(null===this.href)throw new Y("setup_needed");try{await this.updateComplete;const e=await Wt.emit({source:this,init:[this.href]});let t,s;if(e.status.toString().startsWith("4")){t=null;const e=await Wt.emit({source:this,init:["/"]});la(e);const i=(await e.json())._links["fx:store"].href,a=await Wt.emit({source:this,init:[i]});la(a),s=await a.json()}else{la(e),t=await e.json();const i=t._links["fx:store"].href,a=await Wt.emit({source:this,init:[i]});la(a),s=await a.json()}return{store:s,resource:t}}catch(e){if(e instanceof Y)throw e;if(e instanceof Lt)throw new Y("setup_needed");throw new Y("unknown")}finally{await this.updateComplete,this.dispatchEvent(new da)}}async __save(){try{const e=this.__service.state.context,t=ht(e.newResource,5),s=t?"PUT":"DELETE";t&&(delete t._links,delete t.date_created,delete t.date_modified);const i={method:s,body:t?JSON.stringify(t):void 0};la(await Wt.emit({source:this,init:[this.href,i]}))}catch(e){if(e instanceof Y)throw e;if(e instanceof Lt)throw new Y("setup_needed");throw new Y("unknown")}finally{await this.updateComplete,this.dispatchEvent(new ha)}}}customElements.define("foxy-customer-portal-settings",ua);export{ua as CustomerPortalSettings};
972
+ `}static get is(){return"vaadin-date-picker"}static get version(){return"4.4.1"}static get properties(){return{clearButtonVisible:{type:Boolean,value:!1},disabled:{type:Boolean,value:!1,reflectToAttribute:!0},errorMessage:String,placeholder:String,helperText:{type:String,value:""},readonly:{type:Boolean,value:!1,reflectToAttribute:!0},invalid:{type:Boolean,reflectToAttribute:!0,notify:!0,value:!1},_userInputValue:String}}static get observers(){return["_userInputValueChanged(_userInputValue)","_setClearButtonLabel(i18n.clear)"]}ready(){super.ready(),re(this,(()=>this._inputElement.validate=()=>{})),this._inputElement.addEventListener("change",(e=>{""!==this._inputElement.value||e.__fromClearButton||(this.__dispatchChange=!0)}))}_onVaadinOverlayClose(e){this._openedWithFocusRing&&this.hasAttribute("focused")?this.focusElement.setAttribute("focus-ring",""):this.hasAttribute("focused")||this.focusElement.blur(),e.detail.sourceEvent&&-1!==e.detail.sourceEvent.composedPath().indexOf(this)&&e.preventDefault()}_toggle(e){e.stopPropagation(),this[this._overlayInitialized&&this.$.overlay.opened?"close":"open"]()}_input(){return this.$.input}set _inputValue(e){this._inputElement.value=e}get _inputValue(){return this._inputElement.value}_getAriaExpanded(e){return Boolean(e).toString()}get focusElement(){return this._input()||this}_setClearButtonLabel(e){this._inputElement.shadowRoot.querySelector('[part="clear-button"]').setAttribute("aria-label",e)}}customElements.define(Js.is,Js);class Zs extends $t{}let ei,ti,si,ii,ai=e=>e;class ni extends W{constructor(){super(...arguments),this.value=[],this.disabled=!1,this.__startValue="",this.__endValue=""}static get scopedElements(){return{"vaadin-date-picker":Js,"vaadin-button":N,"x-skeleton":G,"iron-icon":customElements.get("iron-icon"),"x-i18n":X,"x-list":Ct}}static get properties(){return C(C({},super.properties),{},{value:{type:Array},disabled:{type:Boolean}})}render(){const e=this.value.length>=20||this.disabled||!this._isI18nReady;return E(ei||(ei=ai` <x-list data-testid="list" .value="${0}" .disabled="${0}" @change="${0}"> ${0} <div class="sm-flex sm-items-end"> <div class="grid grid-cols-2 gap-s"> <vaadin-date-picker data-testid="start" .label="${0}" .value="${0}" .disabled="${0}" .placeholder="${0}" @change="${0}"> </vaadin-date-picker> <vaadin-date-picker data-testid="end" .min="${0}" .label="${0}" .value="${0}" .disabled="${0}" .placeholder="${0}" clear-button-visible @change="${0}"> </vaadin-date-picker> </div> <vaadin-button .disabled="${0}" data-testid="submit" class="w-full mt-s sm-mt-0 sm-w-auto sm-ml-s" @click="${0}"> <x-i18n .lang="${0}" .key="ndmod.add_${0}" .ns="${0}"> </x-i18n> <iron-icon icon="icons:add" slot="suffix"></iron-icon> </vaadin-button> </div> ${0} </x-list> `),this.value,this.disabled||!this._isI18nReady,this.__handleListChange,this.value.map(((e,t)=>this._isI18nReady?E(ti||(ti=ai`<span slot="${0}" class="truncate">${0}</span>`),t,Ms(e,this.lang)):E(si||(si=ai`<x-skeleton slot="${0}">${0}</x-skeleton>`),t,e))),this._t("ndmod.range_start").toString(),this.__startValue,e,this._isI18nReady?this._t("ndmod.select").toString():"",this.__handleStartValueChange,this.__startValue,this._t("ndmod.range_end").toString(),this.__endValue,e||!this.__startValue,this._isI18nReady?this._t("ndmod.select").toString():"",this.__handleEndValueChange,e||!this.__startValue,this.__submit,this.lang,this.__endValue?"range":"single",this.ns,this.value.length>0?E(ii||(ii=ai` <x-i18n .ns="${0}" .lang="${0}" key="ndmod.add_range_hint" class="${0}"> </x-i18n> `),this.ns,this.lang,ue({"block text-xs mt-xs text-center sm-text-left":!0,"text-tertiary":this.value.length<20,"text-primary":this.value.length>=20})):"")}updated(){const e=this.constructor.getScopedTagName("vaadin-date-picker"),t=this.shadowRoot.querySelectorAll(e);Array.from(t).forEach((e=>e.validate()))}__handleStartValueChange(e){e.stopPropagation(),this.__startValue=e.target.value;const t=$e(this.__endValue),s=$e(this.__startValue);t&&t.getTime()<s.getTime()&&(this.__endValue=""),this.requestUpdate()}__handleEndValueChange(e){e.stopPropagation(),this.__endValue=e.target.value,this.requestUpdate()}__submit(){this.__startValue&&this.__endValue?this.value=[...this.value,[this.__startValue,this.__endValue].join("..")]:this.value=[...this.value,this.__startValue],this.__sendChange(),this.__startValue="",this.__endValue=""}__handleListChange(e){this.value=e.detail,this.__sendChange()}__sendChange(){this.dispatchEvent(new Zs(this.value))}}class ri extends CustomEvent{constructor(e){super("change",{detail:e})}}let oi,li,di=e=>e;class hi extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.type="min",this.__items=["none","custom"]}static get scopedElements(){return{"vaadin-text-field":customElements.get("vaadin-text-field"),"x-frequency-input":os,"x-choice":Z,"x-group":be,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:String},type:{type:String}})}render(){return E(oi||(oi=di` <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="${0}"> </x-i18n> <x-choice data-testid="choice" .disabled="${0}" .value="${0}" .items="${0}" @change="${0}"> <x-i18n slot="none-label" .ns="${0}" .lang="${0}" key="ndmod.none"></x-i18n> <x-i18n slot="custom-label" .ns="${0}" .lang="${0}" key="ndmod.custom"></x-i18n> ${0} </x-choice> </x-group> `),this.ns,this.lang,`ndmod.${this.type}`,this.disabled,this.__choice,this.__items,this.__handleChoiceChange,this.ns,this.lang,this.ns,this.lang,this.__choice===this.__items[1]?E(li||(li=di` <div slot="${0}" class="space-y-s"> <x-frequency-input data-testid="input" .value="${0}" .disabled="${0}" @change="${0}"> </x-frequency-input> <p class="text-s text-tertiary leading-s">${0}</p> </div> `),this.__items[1],this.value,this.disabled,this.__handleNewValueChange,this.__hint):"")}get __choice(){return this.__items[this.value?1:0]}get __hint(){var e;if(!this._isI18nReady)return"";const{count:t,units:s}=xe(null!==(e=this.value)&&void 0!==e?e:"");return this._t(`ndmod.${this.type}Hint`,{duration:this._t("duration",{count:t,units:this._t(null!=s?s:"",{count:t})})})}__handleNewValueChange(e){this.value=e.detail,this.__sendChange()}__handleChoiceChange(e){this.value=e.detail===this.__items[0]?void 0:"1w",this.__sendChange()}__sendChange(){this.dispatchEvent(new ri(this.value))}}class ui extends CustomEvent{constructor(e){super("change",{detail:e})}}class ci extends CustomEvent{constructor(){super("remove")}}let pi,_i,mi,vi,gi,fi,yi,bi,xi,wi=e=>e;class $i extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.value={jsonataQuery:"*"},this.open=!1}static get scopedElements(){return{"x-disallowed-dates":ni,"x-jsonata-input":ys,"x-offset-input":hi,"x-allowed-days":Rs,"iron-icon":customElements.get("iron-icon"),"x-warning":ke,"x-group":be,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:Object},open:{type:Boolean}})}render(){const{min:e,max:t,allowedDays:s,jsonataQuery:i,disallowedDates:a}=this.value,n=e||t,r=s&&s.days.length>0,o=a&&a.length>0,l=this.open?"":"rounded-b-l";return E(pi||(pi=wi` <x-group frame> <details data-testid="details" class="${0}" ?open="${0}" @toggle="${0}"> <summary class="${0} cursor-pointer relative leading-s rounded-t-l focus-outline-none focus-shadow-outline"> <div class="p-m mr-xl text-m text-header font-medium space-y-s"> <div> <x-i18n .ns="${0}" .lang="${0}" key="${0}"> ${0} </x-i18n> </div> ${0} </div> <button data-testid="remove" .disabled="${0}" class="flex items-center justify-center rounded absolute top-0 right-0 text-tertiary hover-text-secondary disabled-text-tertiary disabled-opacity-50 disabled-cursor-default focus-outline-none focus-shadow-outline" style="width:54px;height:54px" @click="${0}"> <iron-icon icon="lumo:cross"></iron-icon> </button> </summary> <article class="space-y-l"> <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="ndmod.match"> </x-i18n> <x-jsonata-input data-testid="jsonata" .ns="${0}" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-jsonata-input> </x-group> <div class="flex flex-col md-flex-row"> <div class="mb-l md-mb-0 md-w-1-2 md-border-r md-border-contrast-10"> <x-offset-input data-testid="min" type="min" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-offset-input> </div> <div class="md-w-1-2"> <x-offset-input data-testid="max" type="max" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-offset-input> </div> </div> ${0} <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="ndmod.allowed"> </x-i18n> <x-allowed-days data-testid="allowed" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-allowed-days> </x-group> <x-group> <x-i18n slot="header" .ns="${0}" .lang="${0}" key="ndmod.excluded"> </x-i18n> <x-disallowed-dates data-testid="disallowed" .ns="${0}" .lang="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-disallowed-dates> </x-group> </article> </details> </x-group> `),ue({"font-lumo":!0,"pointer-events-none":!this._isI18nReady}),this.open,(()=>this.open=!this.open),l,this.ns,this.lang,`ndmod.${"*"===i?"all":"some"}Title`,"*"!==i?this.__renderJSONataSummary(i):"",n||r||o?E(_i||(_i=wi` <div> ${0} </div> `),se(n&&this.__renderMinMaxSummary(e,t),r&&this.__renderAllowedSummary(s),o&&this.__renderDisallowedSummary(a))):"",this.disabled||!this._isI18nReady,is((()=>this.dispatchEvent(new ci))),this.ns,this.lang,this.ns,this.lang,i,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{jsonataQuery:e.detail}),this.__sendUpdate()}),this.lang,e,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{min:e.detail}),this.__sendUpdate()}),this.lang,t,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{max:e.detail}),this.__sendUpdate()}),-1===this.__compareDurations(e,t)?E(mi||(mi=wi` <x-warning class="mx-m" data-testid="warning"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.minWarning"> </x-i18n> </x-warning> `),this.ns,this.lang):"",this.ns,this.lang,this.lang,s,this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{allowedDays:e.detail}),this.__sendUpdate()}),this.ns,this.lang,this.ns,this.lang,null!=a?a:[],this.disabled||!this._isI18nReady,(e=>{this.value=C(C({},this.value),{},{disallowedDates:e.detail}),this.__sendUpdate()}))}__sendUpdate(){this.dispatchEvent(new ui(this.value))}__getEstimatedDaysFrom(e){const{count:t,units:s}=xe(e);return t*{y:365,m:31,w:7,d:1}[s]}__compareDurations(e,t){return e===t?0:e&&t?this.__getEstimatedDaysFrom(e)<this.__getEstimatedDaysFrom(t)?1:-1:1}__renderJSONataSummary(e){return E(vi||(vi=wi` <code class="inline-block rounded bg-success-10 text-success px-xs text-xs leading-s"> ${0} </code> `),e)}__renderMinMaxContent(e){if(e){const{count:t,units:s}=e;return E(gi||(gi=wi` ${0} <x-i18n .ns="${0}" .lang="${0}" key="${0}" .opts="${0}"></x-i18n> `),t,this.ns,this.lang,s,{count:t})}return E(fi||(fi=wi`<x-i18n .ns="${0}" .lang="${0}" key="ndmod.any"></x-i18n>`),this.ns,this.lang)}__renderMinMaxSummary(e,t){return E(yi||(yi=wi` <div class="text-s text-tertiary font-normal"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.range"> <span>:</span> <span class="text-secondary"> ${0} &mdash; ${0} </span> </x-i18n> </div> `),this.ns,this.lang,this.__renderMinMaxContent(e?xe(e):void 0),this.__renderMinMaxContent(t?xe(t):void 0))}__renderAllowedSummary({type:e,days:t}){return E(bi||(bi=wi` <div class="text-s text-tertiary font-normal"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.allowed"> <span>:</span> <span class="text-secondary"> ${0} ${0} </span> </x-i18n> </div> `),this.ns,this.lang,"month"===e?t.join(", "):"","day"===e?t.map((e=>ie(e,this.lang,"short"))).join(", "):"")}__renderDisallowedSummary(e){return E(xi||(xi=wi` <div class="text-s text-tertiary font-normal"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.excluded"> <span>:</span> <span class="text-secondary"> ${0} </span> </x-i18n> </div> `),this.ns,this.lang,e.map((e=>Ms(e,this.lang))).join("; "))}}class ki extends CustomEvent{constructor(e){super("change",{detail:e})}}let Di,Si,Ci,Ei=e=>e;class Ii extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.value=!1}static get scopedElements(){return{"x-next-date-modification-rule":$i,"vaadin-button":customElements.get("vaadin-button"),"x-section":Nt,"iron-icon":customElements.get("iron-icon"),"x-switch":Yt,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:Array}})}render(){const e=!this._isI18nReady||this.disabled||!this.value||Array.isArray(this.value)&&this.value.length>=10;return E(Di||(Di=Ei` <x-section> <x-switch slot="title" class="-my-xs" data-testid="toggle" .checked="${0}" .disabled="${0}" @change="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.title" class="text-l"></x-i18n> </x-switch> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.subtitle" slot="subtitle" class="mr-xl"> </x-i18n> ${0} <div class="mt-m sm-flex sm-items-center"> <vaadin-button class="w-full sm-w-auto" data-testid="add" theme="primary" .disabled="${0}" @click="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="ndmod.add"></x-i18n> <iron-icon icon="lumo:plus" slot="suffix"></iron-icon> </vaadin-button> <x-i18n .lang="${0}" .ns="${0}" key="ndmod.add_hint" class="${0}"> </x-i18n> </div> </x-section> `),Boolean(this.value),this.disabled||!this._isI18nReady,this.__toggleValue,this.ns,this.lang,this.ns,this.lang,this.value?E(Si||(Si=Ei` ${0} `),this.__normalizedValue.map(((e,t,s)=>E(Ci||(Ci=Ei` <x-next-date-modification-rule data-testid="rule" .disabled="${0}" .value="${0}" .lang="${0}" @remove="${0}" @change="${0}"> </x-next-date-modification-rule> `),this.disabled||!this._isI18nReady,e,this.lang,(()=>{this.value=s.filter(((e,s)=>s!==t)),this.__sendChange()}),(e=>{this.value=s.map(((s,i)=>i===t?e.detail:s)),this.__sendChange()}))))):"",e,this.__addRule,this.ns,this.lang,this.lang,this.ns,ue({"text-xs text-center block font-lumo mt-xs transition duration-200 sm-mt-0 sm-ml-m":!0,"text-tertiary":Array.isArray(this.value)&&this.value.length<10,"text-primary":Array.isArray(this.value)&&this.value.length>=10,hidden:!Array.isArray(this.value)||0===this.value.length}))}get __normalizedValue(){return"boolean"==typeof this.value?[]:this.value}__addRule(){this.value=[...this.__normalizedValue,{jsonataQuery:"*"}],this.__sendChange()}__toggleValue(){this.value=!this.value,this.__sendChange()}__sendChange(){this.dispatchEvent(new ki(this.value))}}class Ai extends $t{}let Mi,Ti,Oi,Vi=e=>e;class ji extends W{constructor(){super(...arguments),this.value=[],this.disabled=!1,this.__errorCode="invalid",this.__invalid=!1,this.__newValue=""}static get scopedElements(){return{"vaadin-text-field":customElements.get("vaadin-text-field"),"vaadin-button":customElements.get("vaadin-button"),"x-skeleton":G,"iron-icon":customElements.get("iron-icon"),"x-group":be,"x-list":Ct,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{value:{type:Array},invalid:{type:Boolean},disabled:{type:Boolean}})}render(){return E(Mi||(Mi=Vi` <x-group frame> <x-list data-testid="list" .disabled="${0}" .value="${0}" @change="${0}"> ${0} <div class="flex flex-col sm-flex-row sm-items-start"> <vaadin-text-field data-testid="input" class="mb-s sm-mb-0 sm-mr-s" .placeholder="${0}" .errorMessage="${0}" .disabled="${0}" .invalid="${0}" .value="${0}" @keypress="${0}" @change="${0}" @input="${0}"> </vaadin-text-field> <div class="sm-flex sm-items-center"> <vaadin-button class="w-full sm-w-auto" data-testid="button" .disabled="${0}" @click="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="origins.add"></x-i18n> <iron-icon icon="lumo:plus" slot="suffix"></iron-icon> </vaadin-button> <x-i18n .lang="${0}" .ns="${0}" key="origins.add_hint" class="${0}"> </x-i18n> </div> </div> </x-list> </x-group> `),this.disabled||!this._isI18nReady,this.value,this.__handleChange,this.value.map(((e,t)=>this._isI18nReady?E(Ti||(Ti=Vi` <div class="flex items-center" slot="${0}"> <img height="16" width="16" class="mr-m" src="https://www.google.com/s2/favicons?domain=${0}"> ${0} </div> `),t,e,e):E(Oi||(Oi=Vi`<x-skeleton slot="${0}">${0}</x-skeleton>`),t,e))),this._isI18nReady?"https://foxy.io":"",this._t(`origins.${this.__errorCode}`).toString(),this.disabled||!this._isI18nReady,this.__invalid,this.__newValue,(e=>"Enter"===e.key&&this.__submit()),(e=>e.stopPropagation()),this.__handleInput,!this._isI18nReady||this.disabled||this.__invalid||this.value.length>=10,this.__submit,this.ns,this.lang,this.lang,this.ns,ue({"text-xs text-center block font-lumo mt-xs transition duration-200 sm-mt-0 sm-ml-m":!0,"text-tertiary":this.value.length<10,"text-primary":this.value.length>=10,hidden:0===this.value.length}))}__sendChange(){this.dispatchEvent(new Ai(this.value))}__handleInput(e){this.__newValue=e.target.value;try{const e=new URL(this.__newValue),t="https:"===e.protocol,s="localhost"===e.hostname;this.__invalid=!s&&!t,this.__errorCode="https_only"}catch(e){this.__invalid=this.__newValue.length>0,this.__errorCode="invalid"}this.requestUpdate()}__submit(){this.__newValue.length>0&&(this.value=[...this.value,new URL(this.__newValue).origin],this.__newValue="",this.__invalid=!1,this.__sendChange()),this.requestUpdate()}__handleChange(e){this.value=e.detail,this.__sendChange()}}class Fi extends CustomEvent{constructor(e){super("change",{detail:e})}}let Ri,Pi=e=>e;class Ni extends W{constructor(){super("customer-portal-settings"),this.disabled=!1,this.value=!1}static get scopedElements(){return{"x-section":Nt,"x-switch":Yt,"x-i18n":X}}static get properties(){return C(C({},super.properties),{},{disabled:{type:Boolean},value:{type:Array}})}render(){return E(Ri||(Ri=Pi` <x-section> <x-switch slot="title" class="-my-xs" data-testid="toggle" .checked="${0}" .disabled="${0}" @change="${0}"> <x-i18n .ns="${0}" .lang="${0}" key="sso.title" class="text-l"></x-i18n> </x-switch> <x-i18n .ns="${0}" .lang="${0}" key="sso.subtitle" slot="subtitle" class="mr-xl"> </x-i18n> </x-section> `),Boolean(this.value),this.disabled||!this._isI18nReady,this.__toggleValue,this.ns,this.lang,this.ns,this.lang)}__toggleValue(){this.value=!this.value,this.__sendChange()}__sendChange(){this.dispatchEvent(new Fi(this.value))}}const Bi=ae.assign({error:(e,t)=>t.data.type}),zi=ae.assign({oldResource:(e,t)=>t.data.resource,newResource:(e,t)=>t.data.resource,store:(e,t)=>t.data.store}),qi=ae.assign({oldResource:e=>e.newResource}),Yi=ae.assign({invalid:[],newResource:({oldResource:e})=>e}),Li=ae.assign({invalid:[],newResource:e=>({allowedOrigins:[],subscriptions:{allowFrequencyModification:[],allowNextDateModification:!1},jwtSharedSecret:wt(72,(()=>bt(35).toString(36))).join(""),sessionLifespanInMinutes:40320,sso:!1,date_created:(new Date).toISOString(),date_modified:(new Date).toISOString(),_links:{"fx:store":e.store._links.self,curies:e.store._links.curies,self:e.store._links["fx:customer_portal_settings"]}})}),Wi=ae.assign({newResource:null}),Hi=ae.assign({error:"setup_needed"}),Ui=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{allowedOrigins:s})}}),Xi=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{subscriptions:C(C({},e.subscriptions),{},{allowFrequencyModification:s})})}}),Ki=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{subscriptions:C(C({},e.subscriptions),{},{allowNextDateModification:s})})}}),Qi=ae.assign({invalid:(e,t)=>{const s="sessionLifespanInMinutes",i=t.invalid;return e.invalid.filter((e=>e!==s)).concat(...i?[s]:[])},newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{sessionLifespanInMinutes:s})}}),Gi=ae.assign({invalid:(e,t)=>{const s="jwtSharedSecret",i=t.invalid;return e.invalid.filter((e=>e!==s)).concat(...i?[s]:[])},newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{jwtSharedSecret:s})}}),Ji=ae.assign({oldResource:null,newResource:null,store:null,error:null,href:(e,t)=>t.data}),Zi=ae.assign({newResource:({newResource:e},t)=>{const s=t.value;return C(C({},e),{},{sso:s})}}),ea={SET_SSO:{target:"#cps.idle",actions:"setSSO"},SET_SECRET:{target:"#cps.idle",actions:"setSecret"},SET_ORIGINS:{target:"#cps.idle",actions:"setOrigins"},SET_SESSION:{target:"#cps.idle",actions:"setSession"},SET_FREQUENCY_MODIFICATION:{target:"#cps.idle",actions:"setFrequencyModification"},SET_NEXT_DATE_MODIFICATION:{target:"#cps.idle",actions:"setNextDateModification"}},ta={initial:"unknown",states:{unknown:{always:[{target:"invalid",cond:"isInvalid"},{target:"valid"}]},invalid:{},valid:{}}},sa=A({id:"cps",initial:"unknown",context:{oldResource:null,newResource:null,invalid:[],store:null,error:null,href:null},states:{unknown:{always:[{target:"error",cond:"isSetupNeeded",actions:"requireSetup"},{target:"idle",cond:"isLoaded"},{target:"busy"}]},error:{on:{RELOAD:{target:"busy.loading"}}},busy:{initial:"loading",states:{loading:{invoke:{src:"load",onDone:{target:"#cps.idle.clean",actions:"handleLoadingSuccess"},onError:{target:"#cps.error",actions:"handleError"}}},saving:{invoke:{src:"save",onDone:{target:"#cps.idle.clean",actions:"handleSavingSuccess"},onError:{target:"#cps.error",actions:"handleError"}}}}},idle:{initial:"unknown",on:{DISABLE:{target:"#cps.idle",actions:"remove"},ENABLE:{target:"#cps.idle",actions:"create"},RESET:{target:"#cps.idle",actions:"reset"}},states:{unknown:{always:[{target:"clean",cond:"isClean"},{target:"dirty"}]},clean:{initial:"unknown",states:{unknown:{always:[{target:"enabled",cond:"isEnabled"},{target:"disabled"}]},enabled:{on:ea},disabled:{}}},dirty:{on:{SAVE:"#cps.busy.saving"},initial:"unknown",states:{unknown:{always:[{target:"created",cond:"isCreated"},{target:"deleted",cond:"isDeleted"},{target:"updated"}]},created:C({on:ea},ta),updated:C({on:ea},ta),deleted:{}}}}}},on:{SET_HREF:{actions:"setHref",target:"unknown"}}},{guards:{isClean:e=>M(e.newResource,e.oldResource),isLoaded:e=>null!==e.store,isInvalid:e=>e.invalid.length>0,isEnabled:e=>null!==e.oldResource,isCreated:e=>null===e.oldResource&&null!==e.newResource,isDeleted:e=>null!==e.oldResource&&null===e.newResource,isSetupNeeded:e=>null===e.href},actions:{setFrequencyModification:Xi,setNextDateModification:Ki,setOrigins:Ui,setSession:Qi,setSecret:Gi,setHref:Ji,setSSO:Zi,handleLoadingSuccess:zi,handleSavingSuccess:qi,handleError:Bi,create:Li,reset:Yi,remove:Wi,requireSetup:Hi}});let ia,aa,na,ra,oa=e=>e;function la(e){if(!e.ok)throw new Y(401===e.status?"unauthorized":"unknown")}class da extends CustomEvent{constructor(){super("ready")}}class ha extends CustomEvent{constructor(){super("update")}}class ua extends W{constructor(){super("customer-portal-settings"),this.rel="customer_portal_settings",this.__machine=sa.withConfig({services:{load:()=>this.__load(),save:()=>this.__save()}}),this.__service=De(this.__machine).onTransition((({changed:e})=>e&&this.requestUpdate())).onChange((()=>this.requestUpdate())).start()}static get scopedElements(){return{"iron-icon":customElements.get("iron-icon"),"vaadin-button":customElements.get("vaadin-button"),"x-frequency-modification":As,"x-next-date-modification":Ii,"x-session-duration":Jt,"x-session-secret":ss,"x-loading-screen":Mt,"x-error-screen":q,"x-origins-list":ji,"x-sso-switch":Ni,"x-skeleton":G,"x-section":Nt,"x-switch":Yt,"x-i18n":X,"x-page":jt}}static get properties(){return C(C({},super.properties),{},{href:{type:String,noAccessor:!0}})}get href(){return this.__service.state.context.href}set href(e){this.__service.send({type:"SET_HREF",data:e})}render(){var e,t,s,i,a,n;if(this.__service.state.matches("error"))return E(ia||(ia=oa` <x-error-screen data-testid="error" lang="${0}" type="${0}" reload @reload="${0}"> </x-error-screen> `),this.lang,this.__service.state.context.error,this.__reload);const{newResource:r}=this.__service.state.context,o=this.__service.state.matches("idle.dirty.created"),l=this.__service.state.matches("idle.dirty.deleted"),d=this.__service.state.matches("idle.dirty.updated"),h=this.__service.state.matches("idle.clean.enabled"),u=this.__service.state.matches("idle.dirty.updated.invalid")||this.__service.state.matches("idle.dirty.created.invalid");return E(aa||(aa=oa` <x-page class="relative"> <x-switch slot="title" data-testid="switch" .disabled="${0}" .checked="${0}" @change="${0}"> <x-i18n key="title" class="text-xxl" .ns="${0}" .lang="${0}"> <sup class="text-tertiary"> <x-i18n key="beta" .ns="${0}" .lang="${0}"> </x-i18n> </sup> </x-i18n> </x-switch> <x-i18n class="block mr-xl" slot="subtitle" key="subtitle" .ns="${0}" .lang="${0}"> </x-i18n> <x-section> <x-i18n slot="title" key="origins.title" .ns="${0}" .lang="${0}"></x-i18n> <x-i18n slot="subtitle" key="origins.subtitle" .ns="${0}" .lang="${0}"></x-i18n> <x-origins-list data-testid="origins" .lang="${0}" .ns="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-origins-list> </x-section> <x-frequency-modification data-testid="fmod" .lang="${0}" .ns="${0}" .value="${0}" ?disabled="${0}" @change="${0}"> </x-frequency-modification> <x-next-date-modification data-testid="ndmod" .lang="${0}" .ns="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-next-date-modification> <x-sso-switch data-testid="sso" .lang="${0}" .ns="${0}" .value="${0}" .disabled="${0}" @change="${0}"> </x-sso-switch> <x-section> <x-i18n slot="title" key="advanced.title" .ns="${0}" .lang="${0}"></x-i18n> <x-i18n slot="subtitle" key="advanced.subtitle" .ns="${0}" .lang="${0}"> </x-i18n> <x-session-duration data-testid="session" .disabled="${0}" .value="${0}" .lang="${0}" .ns="${0}" @change="${0}"> </x-session-duration> <x-session-secret data-testid="secret" .disabled="${0}" .value="${0}" .lang="${0}" .ns="${0}" @change="${0}"> </x-session-secret> </x-section> ${0} </x-page> `),!this.__service.state.matches("idle")||!this._isI18nReady,h||o||d,(e=>{this.__service.send(e.detail?"ENABLE":"DISABLE")}),this.ns,this.lang,this.ns,this.lang,this.ns,this.lang,this.ns,this.lang,this.ns,this.lang,this.lang,this.ns,null!==(e=null==r?void 0:r.allowedOrigins)&&void 0!==e?e:[],!r,(e=>{this.__service.send({type:"SET_ORIGINS",value:e.detail})}),this.lang,this.ns,null!==(t=null==r?void 0:r.subscriptions.allowFrequencyModification)&&void 0!==t?t:[],!r,(e=>{this.__service.send({type:"SET_FREQUENCY_MODIFICATION",value:e.detail})}),this.lang,this.ns,null!==(s=null==r?void 0:r.subscriptions.allowNextDateModification)&&void 0!==s&&s,!r,(e=>{this.__service.send({type:"SET_NEXT_DATE_MODIFICATION",value:e.detail})}),this.lang,this.ns,null!==(i=null==r?void 0:r.sso)&&void 0!==i&&i,!r,(e=>{this.__service.send({type:"SET_SSO",value:e.detail})}),this.ns,this.lang,this.ns,this.lang,!r||!this._isI18nReady,null!==(a=null==r?void 0:r.sessionLifespanInMinutes)&&void 0!==a?a:1,this.lang,this.ns,(({detail:e})=>{this.__service.send(C({type:"SET_SESSION"},e))}),!r||!this._isI18nReady,null!==(n=null==r?void 0:r.jwtSharedSecret)&&void 0!==n?n:"",this.lang,this.ns,(({detail:e})=>{this.__service.send(C({type:"SET_SECRET"},e))}),this.__service.state.matches("idle.dirty")?E(na||(na=oa` <div class="sticky flex justify-between rounded-t-l rounded-b-l shadow-m -mx-s p-s bg-contrast" style="bottom:var(--lumo-space-m)"> <vaadin-button data-testid="save" theme="primary ${0}" .disabled="${0}" @click="${0}"> <x-i18n lang="${0}" ns="${0}" key="save_${0}"> </x-i18n> </vaadin-button> <vaadin-button style="--lumo-contrast:var(--lumo-base-color)" data-testid="reset" theme="contrast tertiary" @click="${0}"> <x-i18n lang="${0}" key="undo_all"></x-i18n> <iron-icon icon="lumo:reload" slot="suffix"></iron-icon> </vaadin-button> </div> `),l?"error":"success",u,(()=>this.__service.send("SAVE")),this.lang,this.ns,o?"create":l?"delete":"update",(()=>this.__service.send("RESET")),this.lang):this.__service.state.matches("busy")?E(ra||(ra=oa`<x-loading-screen data-testid="loading" class="mt-0"></x-loading-screen>`)):"")}async __reload(){this.__service.stop(),this.__service.onTransition((({changed:e})=>e&&this.requestUpdate())).onChange((()=>this.requestUpdate())).start()}async __load(){if(null===this.href)throw new Y("setup_needed");try{await this.updateComplete;const e=await Wt.emit({source:this,init:[this.href]});let t,s;if(e.status.toString().startsWith("4")){t=null;const e=await Wt.emit({source:this,init:["/"]});la(e);const i=(await e.json())._links["fx:store"].href,a=await Wt.emit({source:this,init:[i]});la(a),s=await a.json()}else{la(e),t=await e.json();const i=t._links["fx:store"].href,a=await Wt.emit({source:this,init:[i]});la(a),s=await a.json()}return{store:s,resource:t}}catch(e){if(e instanceof Y)throw e;if(e instanceof Lt)throw new Y("setup_needed");throw new Y("unknown")}finally{await this.updateComplete,this.dispatchEvent(new da)}}async __save(){try{const e=this.__service.state.context,t=ht(e.newResource,5),s=t?"PUT":"DELETE";t&&(delete t._links,delete t.date_created,delete t.date_modified);const i={method:s,body:t?JSON.stringify(t):void 0};la(await Wt.emit({source:this,init:[this.href,i]}))}catch(e){if(e instanceof Y)throw e;if(e instanceof Lt)throw new Y("setup_needed");throw new Y("unknown")}finally{await this.updateComplete,this.dispatchEvent(new ha)}}}customElements.define("foxy-customer-portal-settings",ua);export{ua as CustomerPortalSettings};
@@ -121,7 +121,7 @@ const setHref = actions.assign({
121
121
  });
122
122
  const setSSO = actions.assign({
123
123
  newResource: ({ newResource }, evt) => {
124
- const sso = evt.data;
124
+ const sso = evt.value;
125
125
  return { ...newResource, sso };
126
126
  },
127
127
  });
@@ -1 +1 @@
1
- {"version":3,"file":"machine.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortalSettings/machine.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAEpC,iBAAiB;AAEjB,MAAM,OAAO,GAAG,CAAC,GAAkC,EAAW,EAAE;IAC9D,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,GAAkC,EAAW,EAAE;IAC/D,OAAO,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,GAAkC,EAAW,EAAE;IAChE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,GAAkC,EAAW,EAAE;IAChE,OAAO,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;AAClC,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,GAAkC,EAAW,EAAE;IAChE,OAAO,GAAG,CAAC,WAAW,KAAK,IAAI,IAAI,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,GAAkC,EAAW,EAAE;IAChE,OAAO,GAAG,CAAC,WAAW,KAAK,IAAI,IAAI,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,GAAkC,EAA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EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE;gCACxC,EAAE,MAAM,EAAE,SAAS,EAAE;6BACtB;yBACF;wBACD,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE;wBACrC,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE;wBACrC,OAAO,EAAE,EAAE;qBACZ;iBACF;aACF;SACF;KACF;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE;KACpD;CACF,EACD;IACE,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE;IACxF,OAAO,EAAE;QACP,wBAAwB;QACxB,uBAAuB;QACvB,UAAU;QACV,UAAU;QACV,SAAS;QACT,OAAO;QACP,MAAM;QACN,oBAAoB;QACpB,mBAAmB;QACnB,WAAW;QACX,MAAM;QACN,KAAK;QACL,MAAM;QACN,YAAY;KACb;CACF,CACF,CAAC","sourcesContent":["import {\n CustomerPortalSettingsContext,\n CustomerPortalSettingsLoadErrorEvent,\n CustomerPortalSettingsLoadSuccessEvent,\n CustomerPortalSettingsSetFrequencyModificationEvent,\n CustomerPortalSettingsSetHrefEvent,\n CustomerPortalSettingsSetNextDateModificationEvent,\n CustomerPortalSettingsSetOriginsEvent,\n CustomerPortalSettingsSetSSOEvent,\n CustomerPortalSettingsSetSecretEvent,\n CustomerPortalSettingsSetSessionEvent,\n} from './types';\nimport { Machine, actions } from 'xstate';\n\nimport isEqual from 'lodash-es/isEqual';\nimport random from 'lodash-es/random';\nimport times from 'lodash-es/times';\n\n// #region guards\n\nconst isClean = (ctx: CustomerPortalSettingsContext): boolean => {\n return isEqual(ctx.newResource, ctx.oldResource);\n};\n\nconst isLoaded = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.store !== null;\n};\n\nconst isInvalid = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.invalid.length > 0;\n};\n\nconst isEnabled = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.oldResource !== null;\n};\n\nconst isCreated = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.oldResource === null && ctx.newResource !== null;\n};\n\nconst isDeleted = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.oldResource !== null && ctx.newResource === null;\n};\n\nconst isSetupNeeded = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.href === null;\n};\n\n// #endregion guards\n\n// #region actions\n\nconst handleError = actions.assign<CustomerPortalSettingsContext>({\n error: (_, evt) => (evt as CustomerPortalSettingsLoadErrorEvent).data.type,\n});\n\nconst handleLoadingSuccess = actions.assign<CustomerPortalSettingsContext>({\n oldResource: (_, evt) => (evt as CustomerPortalSettingsLoadSuccessEvent).data.resource,\n newResource: (_, evt) => (evt as CustomerPortalSettingsLoadSuccessEvent).data.resource,\n store: (_, evt) => (evt as CustomerPortalSettingsLoadSuccessEvent).data.store,\n});\n\nconst handleSavingSuccess = actions.assign<CustomerPortalSettingsContext>({\n oldResource: ctx => ctx.newResource,\n});\n\nconst reset = actions.assign<CustomerPortalSettingsContext>({\n invalid: [],\n newResource: ({ oldResource }) => oldResource,\n});\n\nconst create = actions.assign<CustomerPortalSettingsContext>({\n invalid: [],\n newResource: ctx => ({\n allowedOrigins: [],\n subscriptions: { allowFrequencyModification: [], allowNextDateModification: false },\n jwtSharedSecret: times(72, () => random(35).toString(36)).join(''),\n sessionLifespanInMinutes: 40320,\n sso: false,\n date_created: new Date().toISOString(),\n date_modified: new Date().toISOString(),\n _links: {\n 'fx:store': ctx.store!._links.self,\n 'curies': ctx.store!._links.curies,\n 'self': ctx.store!._links['fx:customer_portal_settings'],\n },\n }),\n});\n\nconst remove = actions.assign<CustomerPortalSettingsContext>({\n newResource: null,\n});\n\nconst requireSetup = actions.assign<CustomerPortalSettingsContext>({\n error: 'setup_needed',\n});\n\nconst setOrigins = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const allowedOrigins = (evt as CustomerPortalSettingsSetOriginsEvent).value;\n return { ...newResource!, allowedOrigins };\n },\n});\n\nconst setFrequencyModification = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const typedEvt = evt as CustomerPortalSettingsSetFrequencyModificationEvent;\n const allowFrequencyModification = typedEvt.value;\n return {\n ...newResource!,\n subscriptions: { ...newResource!.subscriptions, allowFrequencyModification },\n };\n },\n});\n\nconst setNextDateModification = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const typedEvt = evt as CustomerPortalSettingsSetNextDateModificationEvent;\n const allowNextDateModification = typedEvt.value;\n return {\n ...newResource!,\n subscriptions: { ...newResource!.subscriptions, allowNextDateModification },\n };\n },\n});\n\nconst setSession = actions.assign<CustomerPortalSettingsContext>({\n invalid: (ctx, evt) => {\n const key = 'sessionLifespanInMinutes';\n const invalid = (evt as CustomerPortalSettingsSetSecretEvent).invalid;\n return ctx.invalid.filter(v => v !== key).concat(...(invalid ? ([key] as const) : []));\n },\n newResource: ({ newResource }, evt) => {\n const sessionLifespanInMinutes = (evt as CustomerPortalSettingsSetSessionEvent).value;\n return { ...newResource!, sessionLifespanInMinutes };\n },\n});\n\nconst setSecret = actions.assign<CustomerPortalSettingsContext>({\n invalid: (ctx, evt) => {\n const key = 'jwtSharedSecret';\n const invalid = (evt as CustomerPortalSettingsSetSecretEvent).invalid;\n return ctx.invalid.filter(v => v !== key).concat(...(invalid ? ([key] as const) : []));\n },\n newResource: ({ newResource }, evt) => {\n const jwtSharedSecret = (evt as CustomerPortalSettingsSetSecretEvent).value;\n return { ...newResource!, jwtSharedSecret };\n },\n});\n\nconst setHref = actions.assign<CustomerPortalSettingsContext>({\n oldResource: null,\n newResource: null,\n store: null,\n error: null,\n href: (_, evt) => (evt as CustomerPortalSettingsSetHrefEvent).data,\n});\n\nconst setSSO = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const sso = (evt as CustomerPortalSettingsSetSSOEvent).data;\n return { ...newResource!, sso };\n },\n});\n\n// #endregion actions\n\nconst setters = {\n SET_SSO: { target: '#cps.idle', actions: 'setSSO' },\n SET_SECRET: { target: '#cps.idle', actions: 'setSecret' },\n SET_ORIGINS: { target: '#cps.idle', actions: 'setOrigins' },\n SET_SESSION: { target: '#cps.idle', actions: 'setSession' },\n SET_FREQUENCY_MODIFICATION: {\n target: '#cps.idle',\n actions: 'setFrequencyModification',\n },\n SET_NEXT_DATE_MODIFICATION: {\n target: '#cps.idle',\n actions: 'setNextDateModification',\n },\n};\n\nconst validity = {\n initial: 'unknown',\n states: {\n unknown: {\n always: [{ target: 'invalid', cond: 'isInvalid' }, { target: 'valid' }],\n },\n invalid: {},\n valid: {},\n },\n};\n\nexport const machine = Machine<CustomerPortalSettingsContext>(\n {\n id: 'cps',\n initial: 'unknown',\n context: {\n oldResource: null,\n newResource: null,\n invalid: [],\n store: null,\n error: null,\n href: null,\n },\n states: {\n unknown: {\n always: [\n { target: 'error', cond: 'isSetupNeeded', actions: 'requireSetup' },\n { target: 'idle', cond: 'isLoaded' },\n { target: 'busy' },\n ],\n },\n error: { on: { RELOAD: { target: 'busy.loading' } } },\n busy: {\n initial: 'loading',\n states: {\n loading: {\n invoke: {\n src: 'load',\n onDone: {\n target: '#cps.idle.clean',\n actions: 'handleLoadingSuccess',\n },\n onError: {\n target: '#cps.error',\n actions: 'handleError',\n },\n },\n },\n saving: {\n invoke: {\n src: 'save',\n onDone: {\n target: '#cps.idle.clean',\n actions: 'handleSavingSuccess',\n },\n onError: {\n target: '#cps.error',\n actions: 'handleError',\n },\n },\n },\n },\n },\n idle: {\n initial: 'unknown',\n on: {\n DISABLE: { target: '#cps.idle', actions: 'remove' },\n ENABLE: { target: '#cps.idle', actions: 'create' },\n RESET: { target: '#cps.idle', actions: 'reset' },\n },\n states: {\n unknown: {\n always: [{ target: 'clean', cond: 'isClean' }, { target: 'dirty' }],\n },\n clean: {\n initial: 'unknown',\n states: {\n unknown: {\n always: [{ target: 'enabled', cond: 'isEnabled' }, { target: 'disabled' }],\n },\n enabled: { on: setters },\n disabled: {},\n },\n },\n dirty: {\n on: { SAVE: '#cps.busy.saving' },\n initial: 'unknown',\n states: {\n unknown: {\n always: [\n { target: 'created', cond: 'isCreated' },\n { target: 'deleted', cond: 'isDeleted' },\n { target: 'updated' },\n ],\n },\n created: { on: setters, ...validity },\n updated: { on: setters, ...validity },\n deleted: {},\n },\n },\n },\n },\n },\n on: {\n SET_HREF: { actions: 'setHref', target: 'unknown' },\n },\n },\n {\n guards: { isClean, isLoaded, isInvalid, isEnabled, isCreated, isDeleted, isSetupNeeded },\n actions: {\n setFrequencyModification,\n setNextDateModification,\n setOrigins,\n setSession,\n setSecret,\n setHref,\n setSSO,\n handleLoadingSuccess,\n handleSavingSuccess,\n handleError,\n create,\n reset,\n remove,\n requireSetup,\n },\n }\n);\n"]}
1
+ {"version":3,"file":"machine.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortalSettings/machine.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAEpC,iBAAiB;AAEjB,MAAM,OAAO,GAAG,CAAC,GAAkC,EAAW,EAAE;IAC9D,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,GAAkC,EAAW,EAAE;IAC/D,OAAO,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,GAAkC,EAAW,EAAE;IAChE,OA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ourcesContent":["import {\n CustomerPortalSettingsContext,\n CustomerPortalSettingsLoadErrorEvent,\n CustomerPortalSettingsLoadSuccessEvent,\n CustomerPortalSettingsSetFrequencyModificationEvent,\n CustomerPortalSettingsSetHrefEvent,\n CustomerPortalSettingsSetNextDateModificationEvent,\n CustomerPortalSettingsSetOriginsEvent,\n CustomerPortalSettingsSetSSOEvent,\n CustomerPortalSettingsSetSecretEvent,\n CustomerPortalSettingsSetSessionEvent,\n} from './types';\nimport { Machine, actions } from 'xstate';\n\nimport isEqual from 'lodash-es/isEqual';\nimport random from 'lodash-es/random';\nimport times from 'lodash-es/times';\n\n// #region guards\n\nconst isClean = (ctx: CustomerPortalSettingsContext): boolean => {\n return isEqual(ctx.newResource, ctx.oldResource);\n};\n\nconst isLoaded = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.store !== null;\n};\n\nconst isInvalid = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.invalid.length > 0;\n};\n\nconst isEnabled = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.oldResource !== null;\n};\n\nconst isCreated = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.oldResource === null && ctx.newResource !== null;\n};\n\nconst isDeleted = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.oldResource !== null && ctx.newResource === null;\n};\n\nconst isSetupNeeded = (ctx: CustomerPortalSettingsContext): boolean => {\n return ctx.href === null;\n};\n\n// #endregion guards\n\n// #region actions\n\nconst handleError = actions.assign<CustomerPortalSettingsContext>({\n error: (_, evt) => (evt as CustomerPortalSettingsLoadErrorEvent).data.type,\n});\n\nconst handleLoadingSuccess = actions.assign<CustomerPortalSettingsContext>({\n oldResource: (_, evt) => (evt as CustomerPortalSettingsLoadSuccessEvent).data.resource,\n newResource: (_, evt) => (evt as CustomerPortalSettingsLoadSuccessEvent).data.resource,\n store: (_, evt) => (evt as CustomerPortalSettingsLoadSuccessEvent).data.store,\n});\n\nconst handleSavingSuccess = actions.assign<CustomerPortalSettingsContext>({\n oldResource: ctx => ctx.newResource,\n});\n\nconst reset = actions.assign<CustomerPortalSettingsContext>({\n invalid: [],\n newResource: ({ oldResource }) => oldResource,\n});\n\nconst create = actions.assign<CustomerPortalSettingsContext>({\n invalid: [],\n newResource: ctx => ({\n allowedOrigins: [],\n subscriptions: { allowFrequencyModification: [], allowNextDateModification: false },\n jwtSharedSecret: times(72, () => random(35).toString(36)).join(''),\n sessionLifespanInMinutes: 40320,\n sso: false,\n date_created: new Date().toISOString(),\n date_modified: new Date().toISOString(),\n _links: {\n 'fx:store': ctx.store!._links.self,\n 'curies': ctx.store!._links.curies,\n 'self': ctx.store!._links['fx:customer_portal_settings'],\n },\n }),\n});\n\nconst remove = actions.assign<CustomerPortalSettingsContext>({\n newResource: null,\n});\n\nconst requireSetup = actions.assign<CustomerPortalSettingsContext>({\n error: 'setup_needed',\n});\n\nconst setOrigins = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const allowedOrigins = (evt as CustomerPortalSettingsSetOriginsEvent).value;\n return { ...newResource!, allowedOrigins };\n },\n});\n\nconst setFrequencyModification = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const typedEvt = evt as CustomerPortalSettingsSetFrequencyModificationEvent;\n const allowFrequencyModification = typedEvt.value;\n return {\n ...newResource!,\n subscriptions: { ...newResource!.subscriptions, allowFrequencyModification },\n };\n },\n});\n\nconst setNextDateModification = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const typedEvt = evt as CustomerPortalSettingsSetNextDateModificationEvent;\n const allowNextDateModification = typedEvt.value;\n return {\n ...newResource!,\n subscriptions: { ...newResource!.subscriptions, allowNextDateModification },\n };\n },\n});\n\nconst setSession = actions.assign<CustomerPortalSettingsContext>({\n invalid: (ctx, evt) => {\n const key = 'sessionLifespanInMinutes';\n const invalid = (evt as CustomerPortalSettingsSetSecretEvent).invalid;\n return ctx.invalid.filter(v => v !== key).concat(...(invalid ? ([key] as const) : []));\n },\n newResource: ({ newResource }, evt) => {\n const sessionLifespanInMinutes = (evt as CustomerPortalSettingsSetSessionEvent).value;\n return { ...newResource!, sessionLifespanInMinutes };\n },\n});\n\nconst setSecret = actions.assign<CustomerPortalSettingsContext>({\n invalid: (ctx, evt) => {\n const key = 'jwtSharedSecret';\n const invalid = (evt as CustomerPortalSettingsSetSecretEvent).invalid;\n return ctx.invalid.filter(v => v !== key).concat(...(invalid ? ([key] as const) : []));\n },\n newResource: ({ newResource }, evt) => {\n const jwtSharedSecret = (evt as CustomerPortalSettingsSetSecretEvent).value;\n return { ...newResource!, jwtSharedSecret };\n },\n});\n\nconst setHref = actions.assign<CustomerPortalSettingsContext>({\n oldResource: null,\n newResource: null,\n store: null,\n error: null,\n href: (_, evt) => (evt as CustomerPortalSettingsSetHrefEvent).data,\n});\n\nconst setSSO = actions.assign<CustomerPortalSettingsContext>({\n newResource: ({ newResource }, evt) => {\n const sso = (evt as CustomerPortalSettingsSetSSOEvent).value;\n return { ...newResource!, sso };\n },\n});\n\n// #endregion actions\n\nconst setters = {\n SET_SSO: { target: '#cps.idle', actions: 'setSSO' },\n SET_SECRET: { target: '#cps.idle', actions: 'setSecret' },\n SET_ORIGINS: { target: '#cps.idle', actions: 'setOrigins' },\n SET_SESSION: { target: '#cps.idle', actions: 'setSession' },\n SET_FREQUENCY_MODIFICATION: {\n target: '#cps.idle',\n actions: 'setFrequencyModification',\n },\n SET_NEXT_DATE_MODIFICATION: {\n target: '#cps.idle',\n actions: 'setNextDateModification',\n },\n};\n\nconst validity = {\n initial: 'unknown',\n states: {\n unknown: {\n always: [{ target: 'invalid', cond: 'isInvalid' }, { target: 'valid' }],\n },\n invalid: {},\n valid: {},\n },\n};\n\nexport const machine = Machine<CustomerPortalSettingsContext>(\n {\n id: 'cps',\n initial: 'unknown',\n context: {\n oldResource: null,\n newResource: null,\n invalid: [],\n store: null,\n error: null,\n href: null,\n },\n states: {\n unknown: {\n always: [\n { target: 'error', cond: 'isSetupNeeded', actions: 'requireSetup' },\n { target: 'idle', cond: 'isLoaded' },\n { target: 'busy' },\n ],\n },\n error: { on: { RELOAD: { target: 'busy.loading' } } },\n busy: {\n initial: 'loading',\n states: {\n loading: {\n invoke: {\n src: 'load',\n onDone: {\n target: '#cps.idle.clean',\n actions: 'handleLoadingSuccess',\n },\n onError: {\n target: '#cps.error',\n actions: 'handleError',\n },\n },\n },\n saving: {\n invoke: {\n src: 'save',\n onDone: {\n target: '#cps.idle.clean',\n actions: 'handleSavingSuccess',\n },\n onError: {\n target: '#cps.error',\n actions: 'handleError',\n },\n },\n },\n },\n },\n idle: {\n initial: 'unknown',\n on: {\n DISABLE: { target: '#cps.idle', actions: 'remove' },\n ENABLE: { target: '#cps.idle', actions: 'create' },\n RESET: { target: '#cps.idle', actions: 'reset' },\n },\n states: {\n unknown: {\n always: [{ target: 'clean', cond: 'isClean' }, { target: 'dirty' }],\n },\n clean: {\n initial: 'unknown',\n states: {\n unknown: {\n always: [{ target: 'enabled', cond: 'isEnabled' }, { target: 'disabled' }],\n },\n enabled: { on: setters },\n disabled: {},\n },\n },\n dirty: {\n on: { SAVE: '#cps.busy.saving' },\n initial: 'unknown',\n states: {\n unknown: {\n always: [\n { target: 'created', cond: 'isCreated' },\n { target: 'deleted', cond: 'isDeleted' },\n { target: 'updated' },\n ],\n },\n created: { on: setters, ...validity },\n updated: { on: setters, ...validity },\n deleted: {},\n },\n },\n },\n },\n },\n on: {\n SET_HREF: { actions: 'setHref', target: 'unknown' },\n },\n },\n {\n guards: { isClean, isLoaded, isInvalid, isEnabled, isCreated, isDeleted, isSetupNeeded },\n actions: {\n setFrequencyModification,\n setNextDateModification,\n setOrigins,\n setSession,\n setSecret,\n setHref,\n setSSO,\n handleLoadingSuccess,\n handleSavingSuccess,\n handleError,\n create,\n reset,\n remove,\n requireSetup,\n },\n }\n);\n"]}
@@ -28,7 +28,7 @@ export interface CustomerPortalSettingsSetHrefEvent {
28
28
  }
29
29
  export interface CustomerPortalSettingsSetSSOEvent {
30
30
  type: 'SET_SSO';
31
- data: boolean;
31
+ value: boolean;
32
32
  }
33
33
  export interface CustomerPortalSettingsSaveEvent {
34
34
  type: 'SAVE';
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortalSettings/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ErrorType, FriendlyError } from '../../private/ErrorScreen/ErrorScreen';\nimport { FxCustomerPortalSettings, FxStore } from '../../../types/hapi';\n\nexport interface CustomerPortalSettingsContext {\n oldResource: FxCustomerPortalSettings | null;\n newResource: FxCustomerPortalSettings | null;\n invalid: ('sessionLifespanInMinutes' | 'jwtSharedSecret')[];\n store: FxStore | null;\n error: ErrorType | null;\n href: string | null;\n}\n\nexport interface CustomerPortalSettingsLoadSuccessEvent {\n type: 'done.invoke.load';\n data: {\n resource: FxCustomerPortalSettings | null;\n store: FxStore;\n };\n}\n\nexport interface CustomerPortalSettingsLoadErrorEvent {\n type: 'error.execution';\n data: FriendlyError;\n}\n\nexport interface CustomerPortalSettingsResetEvent {\n type: 'RESET';\n}\n\nexport interface CustomerPortalSettingsSetHrefEvent {\n type: 'SET_HREF';\n data: string | null;\n}\n\nexport interface CustomerPortalSettingsSetSSOEvent {\n type: 'SET_SSO';\n data: boolean;\n}\n\nexport interface CustomerPortalSettingsSaveEvent {\n type: 'SAVE';\n}\n\nexport interface CustomerPortalSettingsSetOriginsEvent {\n type: 'SET_ORIGINS';\n value: string[];\n}\n\nexport interface CustomerPortalSettingsSetFrequencyModificationEvent {\n type: 'SET_FREQUENCY_MODIFICATION';\n value: FxCustomerPortalSettings['subscriptions']['allowFrequencyModification'];\n}\n\nexport interface CustomerPortalSettingsSetNextDateModificationEvent {\n type: 'SET_NEXT_DATE_MODIFICATION';\n value: FxCustomerPortalSettings['subscriptions']['allowNextDateModification'];\n}\n\nexport interface CustomerPortalSettingsSetSecretEvent {\n type: 'SET_SECRET';\n value: string;\n invalid: boolean;\n}\n\nexport interface CustomerPortalSettingsSetSessionEvent {\n type: 'SET_SESSION';\n value: number;\n invalid: boolean;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/elements/public/CustomerPortalSettings/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ErrorType, FriendlyError } from '../../private/ErrorScreen/ErrorScreen';\nimport { FxCustomerPortalSettings, FxStore } from '../../../types/hapi';\n\nexport interface CustomerPortalSettingsContext {\n oldResource: FxCustomerPortalSettings | null;\n newResource: FxCustomerPortalSettings | null;\n invalid: ('sessionLifespanInMinutes' | 'jwtSharedSecret')[];\n store: FxStore | null;\n error: ErrorType | null;\n href: string | null;\n}\n\nexport interface CustomerPortalSettingsLoadSuccessEvent {\n type: 'done.invoke.load';\n data: {\n resource: FxCustomerPortalSettings | null;\n store: FxStore;\n };\n}\n\nexport interface CustomerPortalSettingsLoadErrorEvent {\n type: 'error.execution';\n data: FriendlyError;\n}\n\nexport interface CustomerPortalSettingsResetEvent {\n type: 'RESET';\n}\n\nexport interface CustomerPortalSettingsSetHrefEvent {\n type: 'SET_HREF';\n data: string | null;\n}\n\nexport interface CustomerPortalSettingsSetSSOEvent {\n type: 'SET_SSO';\n value: boolean;\n}\n\nexport interface CustomerPortalSettingsSaveEvent {\n type: 'SAVE';\n}\n\nexport interface CustomerPortalSettingsSetOriginsEvent {\n type: 'SET_ORIGINS';\n value: string[];\n}\n\nexport interface CustomerPortalSettingsSetFrequencyModificationEvent {\n type: 'SET_FREQUENCY_MODIFICATION';\n value: FxCustomerPortalSettings['subscriptions']['allowFrequencyModification'];\n}\n\nexport interface CustomerPortalSettingsSetNextDateModificationEvent {\n type: 'SET_NEXT_DATE_MODIFICATION';\n value: FxCustomerPortalSettings['subscriptions']['allowNextDateModification'];\n}\n\nexport interface CustomerPortalSettingsSetSecretEvent {\n type: 'SET_SECRET';\n value: string;\n invalid: boolean;\n}\n\nexport interface CustomerPortalSettingsSetSessionEvent {\n type: 'SET_SESSION';\n value: number;\n invalid: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foxy.io/elements",
3
3
  "type": "module",
4
- "version": "1.11.0-beta.1",
4
+ "version": "1.11.0-beta.2",
5
5
  "description": "E-commerce web components by Foxy.",
6
6
  "repository": {
7
7
  "type": "git",