@foxy.io/elements 1.60.5 → 1.60.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/foxy-payments-api-payment-method-form.js +1 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.d.ts +2 -0
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js +11 -1
- package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./shared-47f1af66.js";import"./shared-a99b7519.js";import"./shared-16ccc5a3.js";import"./shared-cf25faa5.js";import"./shared-a0496f20.js";import"./shared-7d10663b.js";import"./shared-d412fe96.js";import{I as e}from"./shared-318fa017.js";import"./foxy-nucleon-element.js";import"./foxy-spinner.js";import"./shared-f2e36f0f.js";import{l as t,_ as i,B as r}from"./shared-8f9014ff.js";import{g as n}from"./shared-bab2ea2c.js";import{a as s}from"./shared-45c7e449.js";import{c as o}from"./shared-87e17c02.js";import{i as a}from"./shared-53e42a77.js";import{h as l,s as c}from"./shared-ba5c42c7.js";import{c as u}from"./shared-4e709717.js";import{h as d}from"./shared-c7796413.js";import{s as h}from"./shared-791b4510.js";import{a as f}from"./shared-c85c1864.js";import"./shared-b8949649.js";import"./shared-442c25c1.js";import"./shared-e52affbe.js";import"./shared-cf151085.js";import"./shared-008f545f.js";import"./shared-cc142706.js";import"./shared-61c4d03e.js";import"./shared-61ade33e.js";import"./shared-3bce049d.js";import"./foxy-copy-to-clipboard.js";import"./shared-148b225a.js";import"./shared-203661bc.js";import"./shared-419d5254.js";import"./shared-720c03fa.js";import"./shared-222b23bb.js";import"./shared-930e68b7.js";import"./shared-b9142668.js";import"./shared-5212ef4f.js";import"./shared-753a50d4.js";import"./shared-64de5f0c.js";import"./shared-9decd661.js";import"./shared-14dccf44.js";import"./shared-d0aed1c1.js";import"./shared-819dd677.js";import"./shared-3be05a73.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-0e19bda5.js";function p(e){return Array.isArray?Array.isArray(e):"[object Array]"===C(e)}const m=1/0;function _(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-m?"-0":t}(e)}function y(e){return"string"==typeof e}function g(e){return"number"==typeof e}function v(e){return!0===e||!1===e||function(e){return x(e)&&null!==e}(e)&&"[object Boolean]"==C(e)}function x(e){return"object"==typeof e}function $(e){return null!=e}function A(e){return!e.trim().length}function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const b=e=>`Missing ${e} property in key`,M=e=>`Property 'weight' in key '${e}' must be a positive integer`,k=Object.prototype.hasOwnProperty;class F{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=B(e);this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function B(e){let t=null,i=null,r=null,n=1,s=null;if(y(e)||p(e))r=e,t=D(e),i=E(e);else{if(!k.call(e,"name"))throw new Error(b("name"));const o=e.name;if(r=o,k.call(e,"weight")&&(n=e.weight,n<=0))throw new Error(M(o));t=D(o),i=E(o),s=e.getFn}return{path:t,id:i,weight:n,src:r,getFn:s}}function D(e){return p(e)?e:e.split(".")}function E(e){return p(e)?e.join("."):e}var L={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...{useExtendedSearch:!1,getFn:function(e,t){let i=[],r=!1;const n=(e,t,s)=>{if($(e))if(t[s]){const o=e[t[s]];if(!$(o))return;if(s===t.length-1&&(y(o)||g(o)||v(o)))i.push(_(o));else if(p(o)){r=!0;for(let e=0,i=o.length;e<i;e+=1)n(o[e],t,s+1)}else t.length&&n(o,t,s+1)}else i.push(e)};return n(e,y(t)?t.split("."):t,0),r?i:i[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const S=/[^ ]+/g;class w{constructor({getFn:e=L.getFn,fieldNormWeight:t=L.fieldNormWeight}={}){this.norm=function(e=1,t=3){const i=new Map,r=Math.pow(10,t);return{get(t){const n=t.match(S).length;if(i.has(n))return i.get(n);const s=1/Math.pow(n,.5*e),o=parseFloat(Math.round(s*r)/r);return i.set(n,o),o},clear(){i.clear()}}}(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach(((e,t)=>{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,y(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();y(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t<i;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!$(e)||A(e))return;let i={v:e,i:t,n:this.norm.get(e)};this.records.push(i)}_addObject(e,t){let i={i:t,$:{}};this.keys.forEach(((t,r)=>{let n=t.getFn?t.getFn(e):this.getFn(e,t.path);if($(n))if(p(n)){let e=[];const t=[{nestedArrIndex:-1,value:n}];for(;t.length;){const{nestedArrIndex:i,value:r}=t.pop();if($(r))if(y(r)&&!A(r)){let t={v:r,i:i,n:this.norm.get(r)};e.push(t)}else p(r)&&r.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[r]=e}else if(y(n)&&!A(n)){let e={v:n,n:this.norm.get(n)};i.$[r]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function j(e,t,{getFn:i=L.getFn,fieldNormWeight:r=L.fieldNormWeight}={}){const n=new w({getFn:i,fieldNormWeight:r});return n.setKeys(e.map(B)),n.setSources(t),n.create(),n}function I(e,{errors:t=0,currentLocation:i=0,expectedLocation:r=0,distance:n=L.distance,ignoreLocation:s=L.ignoreLocation}={}){const o=t/e.length;if(s)return o;const a=Math.abs(r-i);return n?o+a/n:a?1:o}const V=32;function P(e,t,i,{location:r=L.location,distance:n=L.distance,threshold:s=L.threshold,findAllMatches:o=L.findAllMatches,minMatchCharLength:a=L.minMatchCharLength,includeMatches:l=L.includeMatches,ignoreLocation:c=L.ignoreLocation}={}){if(t.length>V)throw new Error(`Pattern length exceeds max of ${V}.`);const u=t.length,d=e.length,h=Math.max(0,Math.min(r,d));let f=s,p=h;const m=a>1||l,_=m?Array(d):[];let y;for(;(y=e.indexOf(t,p))>-1;){let e=I(t,{currentLocation:y,expectedLocation:h,distance:n,ignoreLocation:c});if(f=Math.min(e,f),p=y+u,m){let e=0;for(;e<u;)_[y+e]=1,e+=1}}p=-1;let g=[],v=1,x=u+d;const $=1<<u-1;for(let r=0;r<u;r+=1){let s=0,a=x;for(;s<a;){I(t,{errors:r,currentLocation:h+a,expectedLocation:h,distance:n,ignoreLocation:c})<=f?s=a:x=a,a=Math.floor((x-s)/2+s)}x=a;let l=Math.max(1,h-a+1),y=o?d:Math.min(h+a,d)+u,A=Array(y+2);A[y+1]=(1<<r)-1;for(let s=y;s>=l;s-=1){let o=s-1,a=i[e.charAt(o)];if(m&&(_[o]=+!!a),A[s]=(A[s+1]<<1|1)&a,r&&(A[s]|=(g[s+1]|g[s])<<1|1|g[s+1]),A[s]&$&&(v=I(t,{errors:r,currentLocation:o,expectedLocation:h,distance:n,ignoreLocation:c}),v<=f)){if(f=v,p=o,p<=h)break;l=Math.max(1,2*h-p)}}if(I(t,{errors:r+1,currentLocation:h,expectedLocation:h,distance:n,ignoreLocation:c})>f)break;g=A}const A={isMatch:p>=0,score:Math.max(.001,v)};if(m){const e=function(e=[],t=L.minMatchCharLength){let i=[],r=-1,n=-1,s=0;for(let o=e.length;s<o;s+=1){let o=e[s];o&&-1===r?r=s:o||-1===r||(n=s-1,n-r+1>=t&&i.push([r,n]),r=-1)}return e[s-1]&&s-r>=t&&i.push([r,s-1]),i}(_,a);e.length?l&&(A.indices=e):A.isMatch=!1}return A}function R(e){let t={};for(let i=0,r=e.length;i<r;i+=1){const n=e.charAt(i);t[n]=(t[n]||0)|1<<r-i-1}return t}const O=String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class N{constructor(e,{location:t=L.location,threshold:i=L.threshold,distance:r=L.distance,includeMatches:n=L.includeMatches,findAllMatches:s=L.findAllMatches,minMatchCharLength:o=L.minMatchCharLength,isCaseSensitive:a=L.isCaseSensitive,ignoreDiacritics:l=L.ignoreDiacritics,ignoreLocation:c=L.ignoreLocation}={}){if(this.options={location:t,threshold:i,distance:r,includeMatches:n,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreDiacritics:l,ignoreLocation:c},e=a?e:e.toLowerCase(),e=l?O(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const u=(e,t)=>{this.chunks.push({pattern:e,alphabet:R(e),startIndex:t})},d=this.pattern.length;if(d>V){let e=0;const t=d%V,i=d-t;for(;e<i;)u(this.pattern.substr(e,V),e),e+=V;if(t){const e=d-V;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:i,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=i?O(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}const{location:n,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let u=[],d=0,h=!1;this.chunks.forEach((({pattern:t,alphabet:i,startIndex:f})=>{const{isMatch:p,score:m,indices:_}=P(e,t,i,{location:n+f,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:r,ignoreLocation:c});p&&(h=!0),d+=m,p&&_&&(u=[...u,..._])}));let f={isMatch:h,score:h?d/this.chunks.length:1};return h&&r&&(f.indices=u),f}}class T{constructor(e){this.pattern=e}static isMultiMatch(e){return W(e,this.multiRegex)}static isSingleMatch(e){return W(e,this.singleRegex)}search(){}}function W(e,t){const i=e.match(t);return i?i[1]:null}class q extends T{constructor(e,{location:t=L.location,threshold:i=L.threshold,distance:r=L.distance,includeMatches:n=L.includeMatches,findAllMatches:s=L.findAllMatches,minMatchCharLength:o=L.minMatchCharLength,isCaseSensitive:a=L.isCaseSensitive,ignoreDiacritics:l=L.ignoreDiacritics,ignoreLocation:c=L.ignoreLocation}={}){super(e),this._bitapSearch=new N(e,{location:t,threshold:i,distance:r,includeMatches:n,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreDiacritics:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class z extends T{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const r=[],n=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+n,r.push([t,i-1]);const s=!!r.length;return{isMatch:s,score:s?0:1,indices:r}}}const Z=[class extends T{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},z,class extends T{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},q],H=Z.length,J=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const K=new Set([q.type,z.type]);class U{constructor(e,{isCaseSensitive:t=L.isCaseSensitive,ignoreDiacritics:i=L.ignoreDiacritics,includeMatches:r=L.includeMatches,minMatchCharLength:n=L.minMatchCharLength,ignoreLocation:s=L.ignoreLocation,findAllMatches:o=L.findAllMatches,location:a=L.location,threshold:l=L.threshold,distance:c=L.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:i,includeMatches:r,minMatchCharLength:n,findAllMatches:o,ignoreLocation:s,location:a,threshold:l,distance:c},e=t?e:e.toLowerCase(),e=i?O(e):e,this.pattern=e,this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(J).filter((e=>e&&!!e.trim())),r=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];let s=!1,o=-1;for(;!s&&++o<H;){const e=Z[o];let i=e.isMultiMatch(n);i&&(r.push(new e(i,t)),s=!0)}if(!s)for(o=-1;++o<H;){const e=Z[o];let i=e.isSingleMatch(n);if(i){r.push(new e(i,t));break}}}return r}))}(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:r,ignoreDiacritics:n}=this.options;e=r?e:e.toLowerCase(),e=n?O(e):e;let s=0,o=[],a=0;for(let r=0,n=t.length;r<n;r+=1){const n=t[r];o.length=0,s=0;for(let t=0,r=n.length;t<r;t+=1){const r=n[t],{isMatch:l,indices:c,score:u}=r.search(e);if(!l){a=0,s=0,o.length=0;break}if(s+=1,a+=u,i){const e=r.constructor.type;K.has(e)?o=[...o,...c]:o.push(c)}}if(s){let e={isMatch:!0,score:a/s};return i&&(e.indices=o),e}}return{isMatch:!1,score:1}}}const G=[];function Q(e,t){for(let i=0,r=G.length;i<r;i+=1){let r=G[i];if(r.condition(e,t))return new r(e,t)}return new N(e,t)}const X="$and",Y="$or",ee="$path",te="$val",ie=e=>!(!e[X]&&!e[Y]),re=e=>({[X]:Object.keys(e).map((t=>({[t]:e[t]})))});function ne(e,t,{auto:i=!0}={}){const r=e=>{let n=Object.keys(e);const s=(e=>!!e[ee])(e);if(!s&&n.length>1&&!ie(e))return r(re(e));if((e=>!p(e)&&x(e)&&!ie(e))(e)){const r=s?e[ee]:n[0],o=s?e[te]:e[r];if(!y(o))throw new Error((e=>`Invalid value for key ${e}`)(r));const a={keyId:E(r),pattern:o};return i&&(a.searcher=Q(o,t)),a}let o={children:[],operator:n[0]};return n.forEach((t=>{const i=e[t];p(i)&&i.forEach((e=>{o.children.push(r(e))}))})),o};return ie(e)||(e=re(e)),r(e)}function se(e,t){const i=e.matches;t.matches=[],$(i)&&i.forEach((e=>{if(!$(e.indices)||!e.indices.length)return;const{indices:i,value:r}=e;let n={indices:i,value:r};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}))}function oe(e,t){t.score=e.score}class ae{constructor(e,t={},i){this.options={...L,...t},this.options.useExtendedSearch,this._keyStore=new F(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof w))throw new Error("Incorrect 'index' type");this._myIndex=t||j(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){$(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,r=this._docs.length;i<r;i+=1){const n=this._docs[i];e(n,i)&&(this.removeAt(i),i-=1,r-=1,t.push(n))}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:i,includeScore:r,shouldSort:n,sortFn:s,ignoreFieldNorm:o}=this.options;let a=y(e)?y(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,{ignoreFieldNorm:t=L.ignoreFieldNorm}){e.forEach((e=>{let i=1;e.matches.forEach((({key:e,norm:r,score:n})=>{const s=e?e.weight:null;i*=Math.pow(0===n&&s?Number.EPSILON:n,(s||1)*(t?1:r))})),e.score=i}))}(a,{ignoreFieldNorm:o}),n&&a.sort(s),g(t)&&t>-1&&(a=a.slice(0,t)),function(e,t,{includeMatches:i=L.includeMatches,includeScore:r=L.includeScore}={}){const n=[];return i&&n.push(se),r&&n.push(oe),e.map((e=>{const{idx:i}=e,r={item:t[i],refIndex:i};return n.length&&n.forEach((t=>{t(e,r)})),r}))}(a,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(e){const t=Q(e,this.options),{records:i}=this._myIndex,r=[];return i.forEach((({v:e,i:i,n:n})=>{if(!$(e))return;const{isMatch:s,score:o,indices:a}=t.searchIn(e);s&&r.push({item:e,idx:i,matches:[{score:o,value:e,norm:n,indices:a}]})})),r}_searchLogical(e){const t=ne(e,this.options),i=(e,t,r)=>{if(!e.children){const{keyId:i,searcher:n}=e,s=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:n});return s&&s.length?[{idx:r,item:t,matches:s}]:[]}const n=[];for(let s=0,o=e.children.length;s<o;s+=1){const o=e.children[s],a=i(o,t,r);if(a.length)n.push(...a);else if(e.operator===X)return[]}return n},r=this._myIndex.records,n={},s=[];return r.forEach((({$:e,i:r})=>{if($(e)){let o=i(t,e,r);o.length&&(n[r]||(n[r]={idx:r,item:e,matches:[]},s.push(n[r])),o.forEach((({matches:e})=>{n[r].matches.push(...e)})))}})),s}_searchObjectList(e){const t=Q(e,this.options),{keys:i,records:r}=this._myIndex,n=[];return r.forEach((({$:e,i:r})=>{if(!$(e))return;let s=[];i.forEach(((i,r)=>{s.push(...this._findMatches({key:i,value:e[r],searcher:t}))})),s.length&&n.push({idx:r,item:e,matches:s})})),n}_findMatches({key:e,value:t,searcher:i}){if(!$(t))return[];let r=[];if(p(t))t.forEach((({v:t,i:n,n:s})=>{if(!$(t))return;const{isMatch:o,score:a,indices:l}=i.searchIn(t);o&&r.push({score:a,key:e,value:t,idx:n,norm:s,indices:l})}));else{const{v:n,n:s}=t,{isMatch:o,score:a,indices:l}=i.searchIn(n);o&&r.push({score:a,key:e,value:n,norm:s,indices:l})}return r}}ae.version="7.1.0",ae.createIndex=j,ae.parseIndex=function(e,{getFn:t=L.getFn,fieldNormWeight:i=L.fieldNormWeight}={}){const{keys:r,records:n}=e,s=new w({getFn:t,fieldNormWeight:i});return s.setKeys(r),s.setIndexRecords(n),s},ae.config=L,ae.parseQuery=ne,function(...e){G.push(...e)}(U);let le,ce,ue,de,he,fe,pe,me,_e,ye,ge,ve,xe,$e,Ae,Ce,be,Me,ke,Fe,Be,De,Ee,Le,Se,we,je,Ie,Ve,Pe,Re,Oe,Ne,Te,We,qe,ze,Ze,He,Je,Ke,Ue,Ge=e=>e;const Qe=["paypal_platform"],Xe=s(e,"payments-api-payment-method-form");class Ye extends Xe{constructor(){super(...arguments),this.paymentPreset=null,this.getImageSrc=null,this.getConnectRedirectUrl=null,this.store=null,this.__availablePaymentMethodsLoaderId="availablePaymentMethodsLoader",this.__paymentPresetLoaderId="paymentPresetLoader",this.__storeLoaderId="storeLoader",this.__threeDSecureResponseGetValue=()=>{var e;return null===(e=this.form.config_3d_secure)||void 0===e?void 0:e.endsWith("require_valid_response")},this.__threeDSecureResponseSetValue=e=>{const t=e?"_require_valid_response":"",i=this.form.config_3d_secure,r=(null==i?void 0:i.startsWith("all_cards"))?"all_cards":"maestro_only";this.edit({config_3d_secure:`${r}${t}`})},this.__threeDSecureToggleGetValue=()=>{const e=this.form.config_3d_secure;return(null==e?void 0:e.startsWith("all_cards"))?"all_cards":(null==e?void 0:e.startsWith("maestro_only"))?"maestro_only":"off"},this.__threeDSecureToggleSetValue=e=>{var t;let i="";"all_cards"!==e&&"maestro_only"!==e||(i=(null===(t=this.form.config_3d_secure)||void 0===t?void 0:t.endsWith("require_valid_response"))?`${e}_require_valid_response`:e),this.edit({config_3d_secure:i})},this.__threeDSecureToggleOptions=[{value:"off",label:"option_off"},{value:"all_cards",label:"option_all_cards"},{value:"maestro_only",label:"option_maestro_only"}],this.__cardVerificationOptions=[{label:"option_disabled",value:"disabled"},{label:"option_enabled_automatically",value:"enabled_automatically"},{label:"option_enabled_override",value:"enabled_override"}],this.__defaultTestCredentialsGetValue=()=>{const e=this.__additionalFieldsConfig;return this.__hasDefaultTestCredentials&&this.__defaultTestCredentials.every((([e,t])=>this.form[e]===t))&&this.__defaultTestFields.every((i=>t(e,i.id)===i.default_value))},this.__defaultTestCredentialsSetValue=e=>{const t=this.__additionalFieldsConfig,i={};this.__defaultTestCredentials.forEach((([t,r])=>i[t]=e?r:"")),this.__defaultTestFields.forEach((i=>{e?h(t,i.id,i.default_value):f(t,i.id)})),this.__defaultTestFields.length&&(i.additional_fields=JSON.stringify(t)),this.edit(i)},this.__search="",this.__connectState="idle",this.__connectKey=""}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E"}static get properties(){return i(i({},super.properties),{},{paymentPreset:{attribute:"payment-preset"},getImageSrc:{attribute:!1},getConnectRedirectUrl:{attribute:!1},store:{},__search:{attribute:!1},__connectState:{attribute:!1},__connectKey:{attribute:!1}})}static get v8n(){return[({description:e})=>!e||e.length<=100||"description:v8n_too_long",({type:e})=>!!e||"type:v8n_required",e=>{var t,i,r,n;const s=null!==(r=null===(i=null===(t=e.helper)||void 0===t?void 0:t.additional_fields)||void 0===i?void 0:i.blocks)&&void 0!==r?r:[];let o;try{o=JSON.parse(null!==(n=e.additional_fields)&&void 0!==n?n:"{}")}catch(e){o={}}for(const e of s)for(const t of e.fields)if("optional"in t&&!t.optional&&!d(o,t.id)&&"checkbox"!==t.type)return"additional-fields:v8n_invalid";return!0}]}get scopeCollection(){return"payment_settings"}get hiddenSelector(){return new r(`header:copy-json ${super.hiddenSelector}`.trimEnd())}renderHeader(...e){var t;return l(le||(le=Ge` <div> ${0} ${0} </div> `),super.renderHeader(...e),(null===(t=this.data)||void 0===t?void 0:t.type)||!this.form.type?l(ce||(ce=Ge``)):l(ue||(ue=Ge` <foxy-internal-button data-testid="select-another-button" theme="tertiary-inline" @click="${0}"> <foxy-i18n infer="" key="select_another_button_label"></foxy-i18n> </foxy-internal-button> `),(()=>this.undo())))}get headerTitleOptions(){var e;return{context:this.form.type?"selected":"new",name:null===(e=this.form.helper)||void 0===e?void 0:e.name}}get headerSubtitleOptions(){if(this.href){const e=n(this.href),t=this.headerCopyIdValue;return e.startsWith("R")?{context:"regular",id:t}:{context:"hosted",id:t}}return{}}get headerCopyIdValue(){if(this.href){const e=n(this.href);return e.startsWith("R")?e.slice(1):e.slice(1).split("C")[0]}return""}renderBody(){var e;const t=null===(e=this.__paymentPresetLoader)||void 0===e?void 0:e.data,i=l(de||(de=Ge` <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> `),a(null==t?void 0:t._links["fx:available_payment_methods"].href),this.__availablePaymentMethodsLoaderId,(()=>this.requestUpdate()),a(this.store),this.__storeLoaderId,(()=>this.requestUpdate()),a(this.paymentPreset),this.__paymentPresetLoaderId,(()=>this.requestUpdate()));return l(he||(he=Ge`${0}${0}${0}`),this.renderHeader(),this.form.type?this.__renderPaymentMethodConfig():this.__renderPaymentMethodSelector(),i)}get __groupedAvailablePaymentMethods(){var e;const t=Object.entries(null!==(e=this.__availablePaymentMethods)&&void 0!==e?e:{});return(this.__search?new ae(t,{keys:["1.name"],threshold:.25}).search(this.__search).map((e=>e.item)):t).sort(((e,t)=>e[1].name.localeCompare(t[1].name,"en"))).reduce(((e,[t,i])=>{if(i.is_deprecated)return e;const r=i.name.charAt(0).toUpperCase(),n=!/\w/.test(r)?"#":r,s=e.find((e=>e.name===n)),o=Qe.includes(t)?this.__getConnectChoices(t).map((e=>({type:t,helper:i,choice:e}))):[{type:t,helper:i}];return s?s.items.push(...o):e.push({name:n,items:o}),e}),[])}get __availablePaymentMethodsLoader(){return this.renderRoot.querySelector(`#${this.__availablePaymentMethodsLoaderId}`)}get __availablePaymentMethods(){var e,t;return null===(t=null===(e=this.__availablePaymentMethodsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values}get __paymentPresetLoader(){return this.renderRoot.querySelector(`#${this.__paymentPresetLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __liveBlocks(){var e,t,i;return null!==(i=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>e.is_live)))&&void 0!==i?i:[]}get __testBlocks(){var e,t,i;return null!==(i=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>!e.is_live)))&&void 0!==i?i:[]}get __defaultTestCredentials(){const e=this.form.helper;return[["test_account_id",null==e?void 0:e.test_id],["test_account_key",null==e?void 0:e.test_key],["test_third_party_key",null==e?void 0:e.test_third_party_key]].filter((e=>!!e[1]))}get __defaultTestFields(){return this.__testBlocks.flatMap((e=>e.fields)).filter((e=>"hidden"!==e.type&&"string"==typeof e.default_value)).filter((e=>""!==e.default_value))}get __hasDefaultTestCredentials(){return this.__defaultTestCredentials.length>0||this.__defaultTestFields.length>0}get __additionalFieldsConfig(){var e,t;try{return null!==(t=JSON.parse(null!==(e=this.form.additional_fields)&&void 0!==e?e:""))&&void 0!==t?t:{}}catch(e){return{}}}__renderPaymentMethodSelector(){const e=this.__availablePaymentMethodsLoader;return(null==e?void 0:e.data)?l(pe||(pe=Ge` <div> <input placeholder="${0}" class="w-full leading-m font-medium bg-contrast-5 rounded text-body transition-colors hover-bg-contrast-10 focus-bg-contrast-10 focus-outline-none focus-ring-2 focus-ring-primary-50" style="padding:var(--lumo-space-xs) calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" type="search" .value="${0}" @input="${0}"> <section data-testid="select-method-list"> ${0} </section> </div> `),this.t("search_placeholder"),this.__search,(e=>{this.__search=e.currentTarget.value}),this.__groupedAvailablePaymentMethods.map((({name:e,items:t})=>l(me||(me=Ge` <p class="font-medium text-tertiary py-m">${0}</p> <foxy-internal-summary-control infer="" label="" helper-text=""> ${0} </foxy-internal-summary-control> `),e,t.map(((e,i)=>this.__renderPaymentMethodButton(e,i,t.length))))))):l(fe||(fe=Ge` <foxy-spinner infer="list-spinner" state="${0}" error-type="${0}"> </foxy-spinner> `),(null==e?void 0:e.in("fail"))?"error":"busy",(null==e?void 0:e.accessDenied)?"access-denied":"generic")}__redirect(e){window.location.assign(e)}__getConnectChoices(e){return"paypal_platform"===e?[{key:"paypal_platform.ppcp",options:{paypal_product_type:"ppcp"}},{key:"paypal_platform.express_checkout",options:{paypal_product_type:"express_checkout"}}]:[{key:"default"}]}__getReconnectChoice(e){if("paypal_platform"===this.form.type){return{key:`paypal_platform.${e?"reconnect":"reconnect_with_cards"}`,options:{paypal_product_type:"ppcp"}}}return{key:"reconnect"}}async __connect(e,t){var i,r,n,s,o,a,l,c,u,d,h,f;const p=null===(r=null===(i=this.__paymentPresetLoader)||void 0===i?void 0:i.data)||void 0===r?void 0:r._links["fx:connect_gateway"],m=null!==(o=null===(s=null===(n=this.data)||void 0===n?void 0:n._links["fx:connect_gateway"])||void 0===s?void 0:s.href)&&void 0!==o?o:null==p?void 0:p.href;if(m&&this.paymentPreset&&"busy"!==this.__connectState){this.__connectState="busy",this.__connectKey=e.key,this.status=null;try{const i={type:t,final_redirect:null!==(l=null===(a=this.getConnectRedirectUrl)||void 0===a?void 0:a.call(this,this.paymentPreset))&&void 0!==l?l:window.location.href};e.options&&(i.options=e.options);const r=await this._fetch(m,{method:"POST",body:JSON.stringify(i)});if(!r.connection_url)throw new Error("No connection_url in the response.");this.__redirect(r.connection_url)}catch(t){let i="";if(t instanceof Response)try{const e=await t.json();i=null!==(h=null===(d=null===(u=null===(c=null==e?void 0:e._embedded)||void 0===c?void 0:c["fx:errors"])||void 0===u?void 0:u[0])||void 0===d?void 0:d.message)&&void 0!==h?h:""}catch(e){}const r=t instanceof Response&&403===t.status&&"ppcp"===(null===(f=e.options)||void 0===f?void 0:f.paypal_product_type)&&i.includes("'ppcp'");this.status=r?{key:"connect_error_ppcp_unsupported",type:"error"}:i?{key:"connect_error",options:{message:i},type:"error"}:{key:"connect_error_unknown",type:"error"},this.__connectState="idle"}}}__renderConnection(){var e,t,i,r;const n=null===(e=this.__paymentPresetLoader)||void 0===e?void 0:e.data;if(!n)return l(_e||(_e=Ge``));const s=n.is_live?"":"test_",o=null===(t=this.data)||void 0===t?void 0:t[`${s}account_id`],a=null!==(r=null===(i=this.data)||void 0===i?void 0:i[`${s}third_party_key`])&&void 0!==r?r:"",c=this.form.type,u=o?[this.__getReconnectChoice(a)]:this.__getConnectChoices(c),d="busy"===this.__connectState,h=this.readonlySelector.matches("connection",!0),f=d||this.disabledSelector.matches("connection",!0);return l(ye||(ye=Ge` <foxy-internal-summary-control infer="connection"> ${0} ${0} </foxy-internal-summary-control> `),o?l(ge||(ge=Ge` <p class="font-medium"> <foxy-i18n infer="" key="status_connected" .options="${0}"></foxy-i18n> </p> `),{email:o}):"",(h?[]:u).map((e=>l(ve||(ve=Ge` <div class="leading-xs"> <p class="font-medium"> <foxy-i18n infer="" key="${0}.label"></foxy-i18n> </p> <p class="text-s text-secondary"> <foxy-i18n infer="" key="${0}.description"></foxy-i18n> </p> </div> <div> <foxy-internal-button data-testid="connect-${0}" theme="tertiary-inline" ?disabled="${0}" @click="${0}"> ${0} </foxy-internal-button> </div> `),e.key,e.key,e.key,f,(()=>this.__connect(e,c)),d&&this.__connectKey===e.key?l(xe||(xe=Ge`<foxy-spinner layout="no-label" infer="connect-spinner"></foxy-spinner>`)):l($e||($e=Ge`<foxy-i18n infer="" key="${0}.button"></foxy-i18n>`),e.key)))))}__renderPaymentMethodConfig(){var e,t;if(this.form.type&&Qe.includes(this.form.type))return l(Ae||(Ae=Ge` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> </foxy-internal-summary-control> ${0} ${0} `),this.__renderConnection(),super.renderBody());return this.form.type&&["stripe_connect","stripe_v2","square_up","quickbook_payments","amazon_mws","paypal_platform"].includes(this.form.type)?l(Ce||(Ce=Ge` <div class="flex items-start rounded border border-primary" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px);padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p> <foxy-i18n infer="" key="no_oauth_support_message"></foxy-i18n> <br> <a target="_blank" class="mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50" href="https://admin.foxycart.com"> admin.foxycart.com </a> </p> </div> `),c(be||(be=Ge`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`))):l(Me||(Me=Ge` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> ${0} ${0} </foxy-internal-summary-control> ${0} ${0} `),(null===(e=this.form.helper)||void 0===e?void 0:e.supports_auth_only)?l(ke||(ke=Ge` <foxy-internal-switch-control infer="use-auth-only" helper-text-as-tooltip> </foxy-internal-switch-control> `)):"",(null===(t=this.form.helper)||void 0===t?void 0:t.supports_3d_secure)?l(Fe||(Fe=Ge` <foxy-internal-select-control layout="summary-item" infer="three-d-secure-toggle" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-select-control> ${0} `),this.__threeDSecureToggleGetValue,this.__threeDSecureToggleSetValue,this.__threeDSecureToggleOptions,this.form.config_3d_secure?l(Be||(Be=Ge` <foxy-internal-switch-control layout="summary-item" infer="three-d-secure-response" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),this.__threeDSecureResponseGetValue,this.__threeDSecureResponseSetValue):""):"",["live","test"].map(((e,t)=>{var i,r,n,s,u,d,h,f,p,m,_,y,g,v,x;const $=o(this.currentUserScope,"stores"),A=0===t?"":`${e}_`,C=0===t?"":`${e}-`,b=0===t?this.__liveBlocks:this.__testBlocks,M=`${e}-group`,k="test"===e&&this.__defaultTestCredentialsGetValue();if("live"===e&&$&&!(null===(i=this.__storeLoader)||void 0===i?void 0:i.data))return l(De||(De=Ge``));if("live"===e&&$&&!(null===(n=null===(r=this.__storeLoader)||void 0===r?void 0:r.data)||void 0===n?void 0:n.is_active))return l(Ee||(Ee=Ge` <foxy-internal-summary-control infer="${0}-group"> <div class="flex items-start" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p><foxy-i18n infer="" key="inactive_message"></foxy-i18n></p> </div> </foxy-internal-summary-control> `),e,c(Le||(Le=Ge`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`)));const F=!0===(null===(u=null===(s=this.__storeLoader)||void 0===s?void 0:s.data)||void 0===u?void 0:u.is_active)&&("test"===e&&!0===(null===(h=null===(d=this.__paymentPresetLoader)||void 0===d?void 0:d.data)||void 0===h?void 0:h.is_live)||"live"===e&&!1===(null===(p=null===(f=this.__paymentPresetLoader)||void 0===f?void 0:f.data)||void 0===p?void 0:p.is_live));return l(Se||(Se=Ge` <foxy-internal-summary-control helper-text="${0}" layout="section" label="${0}" infer="${0}"> <foxy-internal-summary-control infer="" label="" helper-text=""> ${0} ${0} ${0} ${0} ${0} ${0} </foxy-internal-summary-control> ${0} </foxy-internal-summary-control> `),a(F?this.t(`${M}.helper_text_inactive`):void 0),a(F?this.t(`${M}.label_inactive`):void 0),M,"test"===e&&this.__hasDefaultTestCredentials?l(we||(we=Ge` <foxy-internal-switch-control infer="default-credentials" helper-text-as-tooltip .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),this.__defaultTestCredentialsGetValue,this.__defaultTestCredentialsSetValue):"",!(null===(m=this.form.helper)||void 0===m?void 0:m.id_description)||k&&this.form.helper.test_id?"":l(je||(je=Ge` <foxy-internal-text-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}account-id"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.id_description,C),!(null===(_=this.form.helper)||void 0===_?void 0:_.third_party_key_description)||k&&this.form.helper.test_third_party_key?"":l(Ie||(Ie=Ge` <foxy-internal-password-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}third-party-key"> </foxy-internal-password-control> `),this.t("default_additional_field_placeholder"),this.form.helper.third_party_key_description,C),!(null===(y=this.form.helper)||void 0===y?void 0:y.key_description)||k&&this.form.helper.test_key?"":l(Ve||(Ve=Ge` <foxy-internal-password-control placeholder="${0}" layout="summary-item" helper-text="" label="${0}" infer="${0}account-key"> </foxy-internal-password-control> `),this.t("default_additional_field_placeholder"),this.form.helper.key_description,C),b.map((e=>this.__renderBlock(e,k?this.__defaultTestFields:[]))),(null===(g=this.form.helper)||void 0===g?void 0:g.supports_card_verification)?l(Pe||(Pe=Ge` <foxy-internal-select-control helper-text="${0}" layout="summary-item" infer="${0}card-verification" .options="${0}" .getValue="${0}"> </foxy-internal-select-control> `),this.t(`${M}.${C}card-verification.helper_text_${this.form[`${A}card_verification`]||"disabled"}`),C,this.__cardVerificationOptions,(()=>this.form[`${A}card_verification`]||"disabled")):"",(null===(v=this.form.helper)||void 0===v?void 0:v.supports_card_verification)&&(null===(x=this.form[`${A}card_verification`])||void 0===x?void 0:x.startsWith("enabled_"))?l(Re||(Re=Ge` <foxy-internal-summary-control layout="details" class="mt-s" infer="${0}card-verification-config"> ${0} </foxy-internal-summary-control> `),C,["visa","mastercard","american-express","discover","default"].map((e=>{var t;return l(Oe||(Oe=Ge` <foxy-internal-number-control json-template="${0}" json-path="verification_amounts.${0}" property="${0}card_verification_config" layout="summary-item" infer="${0}card-verification-config-verification-amounts-${0}" step="0.01" min="0"> </foxy-internal-number-control> `),a(null===(t=this.form.helper)||void 0===t?void 0:t.card_verification_config),e.replace(/-/g,"_"),A,C,e)}))):"")})),super.renderBody())}__renderPaymentMethodButton({type:e,helper:t,choice:i},r,n){var s,o;const c=Ye.defaultImageSrc,d=null!==(o=null===(s=this.getImageSrc)||void 0===s?void 0:s.call(this,e))&&void 0!==o?o:c,h="busy"===this.__connectState,f=h&&!!i&&this.__connectKey===i.key,p=!!i&&"default"!==i.key;return l(Ne||(Ne=Ge` <button class="${0}" data-testid="${0}" ?disabled="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" @click="${0}"> <figure class="relative flex items-center" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <figcaption class="${0}"> <span class="font-medium"> ${0}​ </span> ${0} </figcaption> </figure> </button> `),u({"relative w-full block text-left bg-contrast-5 overflow-hidden":!0,"focus-outline-none focus-ring-inset focus-ring-2 focus-ring-primary-50":!0,"transition-colors hover-bg-contrast-10":!t.conflict,"cursor-default":!!t.conflict,"rounded-t":0===r,"rounded-b":r===n-1}),a(i?`connect-${i.key}`:void 0),!!t.conflict||h,(()=>i?this.__connect(i,e):this.edit({type:e,helper:t})),f?l(Te||(Te=Ge` <foxy-spinner data-testid="connect-spinner" class="h-m w-m flex items-center justify-center flex-shrink-0" layout="no-label" infer="connect-spinner"> </foxy-spinner> `)):l(We||(We=Ge` <img class="${0}" src="${0}" alt="" @error="${0}"> `),u({"h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs":!0,"filter grayscale":!!t.conflict}),d,(e=>e.currentTarget.src=c)),u({"min-w-0 flex-1 grid leading-xs":!0,"text-disabled":!!t.conflict}),p?this.t(`connection.${i.key}.label`):t.name,t.conflict?l(qe||(qe=Ge`<span class="text-xs"> ${0}</span>`),this.t("conflict_message",t.conflict)):i?l(ze||(ze=Ge` <span class="text-xs text-secondary"> ${0} ${0} </span> `),p?this.t(`connection.${i.key}.description`):"",this.t("connection.redirect_notice")):"")}__renderBlock(e,i=[]){return l(Ze||(Ze=Ge`${0}`),e.fields.map((r=>{var n,s,o;if("hidden"===r.type||i.includes(r))return;const a=["additional-fields",r.id].join("-").replace(/_/g,"-"),c=()=>{var i,n;try{const e=JSON.parse(null!==(i=this.form.additional_fields)&&void 0!==i?i:"{}");return null!==(n=t(e,r.id))&&void 0!==n?n:e.default_value}catch(t){return e.is_live?r.default_value:void 0}},u=e=>{var t;let i={};try{i=JSON.parse(null!==(t=this.form.additional_fields)&&void 0!==t?t:"")}catch(e){}this.edit({additional_fields:JSON.stringify(h(i,r.id,e))})},d=r.options;return l(He||(He=Ge` ${0} `),"checkbox"===r.type?l(Je||(Je=Ge` <foxy-internal-switch-control helper-text="${0}" label="${0}" infer="${0}" helper-text-as-tooltip .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),null!==(n=r.description)&&void 0!==n?n:"",r.name,a,c,u):"select"===r.type?l(Ke||(Ke=Ge` <foxy-internal-select-control placeholder="${0}" helper-text="${0}" layout="summary-item" label="${0}" infer="${0}" .options="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-select-control> `),this.t("default_additional_field_select_placeholder"),null!==(s=r.description)&&void 0!==s?s:"",r.name,a,d.map((({name:e,value:t})=>({label:e,value:t}))),c,u):l(Ue||(Ue=Ge` <foxy-internal-text-control helper-text="${0}" placeholder="${0}" layout="summary-item" label="${0}" infer="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-text-control> `),null!==(o=r.description)&&void 0!==o?o:"",this.t("default_additional_field_placeholder"),r.name,a,c,u))})))}}customElements.define("foxy-payments-api-payment-method-form",Ye);export{Ye as PaymentsApiPaymentMethodForm};
|
|
1
|
+
import"./shared-47f1af66.js";import"./shared-a99b7519.js";import"./shared-16ccc5a3.js";import"./shared-cf25faa5.js";import"./shared-a0496f20.js";import"./shared-7d10663b.js";import"./shared-d412fe96.js";import{I as e}from"./shared-318fa017.js";import"./foxy-nucleon-element.js";import"./foxy-spinner.js";import"./shared-f2e36f0f.js";import{l as t,_ as i,B as r}from"./shared-8f9014ff.js";import{g as n}from"./shared-bab2ea2c.js";import{a as s}from"./shared-45c7e449.js";import{c as o}from"./shared-87e17c02.js";import{i as a}from"./shared-53e42a77.js";import{h as l,s as c}from"./shared-ba5c42c7.js";import{c as u}from"./shared-4e709717.js";import{h as d}from"./shared-c7796413.js";import{s as h}from"./shared-791b4510.js";import{a as f}from"./shared-c85c1864.js";import"./shared-b8949649.js";import"./shared-442c25c1.js";import"./shared-e52affbe.js";import"./shared-cf151085.js";import"./shared-008f545f.js";import"./shared-cc142706.js";import"./shared-61c4d03e.js";import"./shared-61ade33e.js";import"./shared-3bce049d.js";import"./foxy-copy-to-clipboard.js";import"./shared-148b225a.js";import"./shared-203661bc.js";import"./shared-419d5254.js";import"./shared-720c03fa.js";import"./shared-222b23bb.js";import"./shared-930e68b7.js";import"./shared-b9142668.js";import"./shared-5212ef4f.js";import"./shared-753a50d4.js";import"./shared-64de5f0c.js";import"./shared-9decd661.js";import"./shared-14dccf44.js";import"./shared-d0aed1c1.js";import"./shared-819dd677.js";import"./shared-3be05a73.js";import"./shared-69c98b7b.js";import"./shared-cd96ff03.js";import"./shared-da4f9115.js";import"./shared-9496e995.js";import"./shared-0e19bda5.js";function p(e){return Array.isArray?Array.isArray(e):"[object Array]"===C(e)}const _=1/0;function m(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-_?"-0":t}(e)}function y(e){return"string"==typeof e}function g(e){return"number"==typeof e}function v(e){return!0===e||!1===e||function(e){return x(e)&&null!==e}(e)&&"[object Boolean]"==C(e)}function x(e){return"object"==typeof e}function $(e){return null!=e}function A(e){return!e.trim().length}function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const b=e=>`Missing ${e} property in key`,M=e=>`Property 'weight' in key '${e}' must be a positive integer`,k=Object.prototype.hasOwnProperty;class F{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=B(e);this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function B(e){let t=null,i=null,r=null,n=1,s=null;if(y(e)||p(e))r=e,t=D(e),i=E(e);else{if(!k.call(e,"name"))throw new Error(b("name"));const o=e.name;if(r=o,k.call(e,"weight")&&(n=e.weight,n<=0))throw new Error(M(o));t=D(o),i=E(o),s=e.getFn}return{path:t,id:i,weight:n,src:r,getFn:s}}function D(e){return p(e)?e:e.split(".")}function E(e){return p(e)?e.join("."):e}var L={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...{useExtendedSearch:!1,getFn:function(e,t){let i=[],r=!1;const n=(e,t,s)=>{if($(e))if(t[s]){const o=e[t[s]];if(!$(o))return;if(s===t.length-1&&(y(o)||g(o)||v(o)))i.push(m(o));else if(p(o)){r=!0;for(let e=0,i=o.length;e<i;e+=1)n(o[e],t,s+1)}else t.length&&n(o,t,s+1)}else i.push(e)};return n(e,y(t)?t.split("."):t,0),r?i:i[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}};const S=/[^ ]+/g;class w{constructor({getFn:e=L.getFn,fieldNormWeight:t=L.fieldNormWeight}={}){this.norm=function(e=1,t=3){const i=new Map,r=Math.pow(10,t);return{get(t){const n=t.match(S).length;if(i.has(n))return i.get(n);const s=1/Math.pow(n,.5*e),o=parseFloat(Math.round(s*r)/r);return i.set(n,o),o},clear(){i.clear()}}}(t,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach(((e,t)=>{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,y(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();y(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t<i;t+=1)this.records[t].i-=1}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size(){return this.records.length}_addString(e,t){if(!$(e)||A(e))return;let i={v:e,i:t,n:this.norm.get(e)};this.records.push(i)}_addObject(e,t){let i={i:t,$:{}};this.keys.forEach(((t,r)=>{let n=t.getFn?t.getFn(e):this.getFn(e,t.path);if($(n))if(p(n)){let e=[];const t=[{nestedArrIndex:-1,value:n}];for(;t.length;){const{nestedArrIndex:i,value:r}=t.pop();if($(r))if(y(r)&&!A(r)){let t={v:r,i:i,n:this.norm.get(r)};e.push(t)}else p(r)&&r.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[r]=e}else if(y(n)&&!A(n)){let e={v:n,n:this.norm.get(n)};i.$[r]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function j(e,t,{getFn:i=L.getFn,fieldNormWeight:r=L.fieldNormWeight}={}){const n=new w({getFn:i,fieldNormWeight:r});return n.setKeys(e.map(B)),n.setSources(t),n.create(),n}function I(e,{errors:t=0,currentLocation:i=0,expectedLocation:r=0,distance:n=L.distance,ignoreLocation:s=L.ignoreLocation}={}){const o=t/e.length;if(s)return o;const a=Math.abs(r-i);return n?o+a/n:a?1:o}const V=32;function P(e,t,i,{location:r=L.location,distance:n=L.distance,threshold:s=L.threshold,findAllMatches:o=L.findAllMatches,minMatchCharLength:a=L.minMatchCharLength,includeMatches:l=L.includeMatches,ignoreLocation:c=L.ignoreLocation}={}){if(t.length>V)throw new Error(`Pattern length exceeds max of ${V}.`);const u=t.length,d=e.length,h=Math.max(0,Math.min(r,d));let f=s,p=h;const _=a>1||l,m=_?Array(d):[];let y;for(;(y=e.indexOf(t,p))>-1;){let e=I(t,{currentLocation:y,expectedLocation:h,distance:n,ignoreLocation:c});if(f=Math.min(e,f),p=y+u,_){let e=0;for(;e<u;)m[y+e]=1,e+=1}}p=-1;let g=[],v=1,x=u+d;const $=1<<u-1;for(let r=0;r<u;r+=1){let s=0,a=x;for(;s<a;){I(t,{errors:r,currentLocation:h+a,expectedLocation:h,distance:n,ignoreLocation:c})<=f?s=a:x=a,a=Math.floor((x-s)/2+s)}x=a;let l=Math.max(1,h-a+1),y=o?d:Math.min(h+a,d)+u,A=Array(y+2);A[y+1]=(1<<r)-1;for(let s=y;s>=l;s-=1){let o=s-1,a=i[e.charAt(o)];if(_&&(m[o]=+!!a),A[s]=(A[s+1]<<1|1)&a,r&&(A[s]|=(g[s+1]|g[s])<<1|1|g[s+1]),A[s]&$&&(v=I(t,{errors:r,currentLocation:o,expectedLocation:h,distance:n,ignoreLocation:c}),v<=f)){if(f=v,p=o,p<=h)break;l=Math.max(1,2*h-p)}}if(I(t,{errors:r+1,currentLocation:h,expectedLocation:h,distance:n,ignoreLocation:c})>f)break;g=A}const A={isMatch:p>=0,score:Math.max(.001,v)};if(_){const e=function(e=[],t=L.minMatchCharLength){let i=[],r=-1,n=-1,s=0;for(let o=e.length;s<o;s+=1){let o=e[s];o&&-1===r?r=s:o||-1===r||(n=s-1,n-r+1>=t&&i.push([r,n]),r=-1)}return e[s-1]&&s-r>=t&&i.push([r,s-1]),i}(m,a);e.length?l&&(A.indices=e):A.isMatch=!1}return A}function R(e){let t={};for(let i=0,r=e.length;i<r;i+=1){const n=e.charAt(i);t[n]=(t[n]||0)|1<<r-i-1}return t}const O=String.prototype.normalize?e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,""):e=>e;class N{constructor(e,{location:t=L.location,threshold:i=L.threshold,distance:r=L.distance,includeMatches:n=L.includeMatches,findAllMatches:s=L.findAllMatches,minMatchCharLength:o=L.minMatchCharLength,isCaseSensitive:a=L.isCaseSensitive,ignoreDiacritics:l=L.ignoreDiacritics,ignoreLocation:c=L.ignoreLocation}={}){if(this.options={location:t,threshold:i,distance:r,includeMatches:n,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreDiacritics:l,ignoreLocation:c},e=a?e:e.toLowerCase(),e=l?O(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const u=(e,t)=>{this.chunks.push({pattern:e,alphabet:R(e),startIndex:t})},d=this.pattern.length;if(d>V){let e=0;const t=d%V,i=d-t;for(;e<i;)u(this.pattern.substr(e,V),e),e+=V;if(t){const e=d-V;u(this.pattern.substr(e),e)}}else u(this.pattern,0)}searchIn(e){const{isCaseSensitive:t,ignoreDiacritics:i,includeMatches:r}=this.options;if(e=t?e:e.toLowerCase(),e=i?O(e):e,this.pattern===e){let t={isMatch:!0,score:0};return r&&(t.indices=[[0,e.length-1]]),t}const{location:n,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let u=[],d=0,h=!1;this.chunks.forEach((({pattern:t,alphabet:i,startIndex:f})=>{const{isMatch:p,score:_,indices:m}=P(e,t,i,{location:n+f,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:r,ignoreLocation:c});p&&(h=!0),d+=_,p&&m&&(u=[...u,...m])}));let f={isMatch:h,score:h?d/this.chunks.length:1};return h&&r&&(f.indices=u),f}}class T{constructor(e){this.pattern=e}static isMultiMatch(e){return W(e,this.multiRegex)}static isSingleMatch(e){return W(e,this.singleRegex)}search(){}}function W(e,t){const i=e.match(t);return i?i[1]:null}class q extends T{constructor(e,{location:t=L.location,threshold:i=L.threshold,distance:r=L.distance,includeMatches:n=L.includeMatches,findAllMatches:s=L.findAllMatches,minMatchCharLength:o=L.minMatchCharLength,isCaseSensitive:a=L.isCaseSensitive,ignoreDiacritics:l=L.ignoreDiacritics,ignoreLocation:c=L.ignoreLocation}={}){super(e),this._bitapSearch=new N(e,{location:t,threshold:i,distance:r,includeMatches:n,findAllMatches:s,minMatchCharLength:o,isCaseSensitive:a,ignoreDiacritics:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class z extends T{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const r=[],n=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+n,r.push([t,i-1]);const s=!!r.length;return{isMatch:s,score:s?0:1,indices:r}}}const Z=[class extends T{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},z,class extends T{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends T{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},q],H=Z.length,J=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/;const K=new Set([q.type,z.type]);class U{constructor(e,{isCaseSensitive:t=L.isCaseSensitive,ignoreDiacritics:i=L.ignoreDiacritics,includeMatches:r=L.includeMatches,minMatchCharLength:n=L.minMatchCharLength,ignoreLocation:s=L.ignoreLocation,findAllMatches:o=L.findAllMatches,location:a=L.location,threshold:l=L.threshold,distance:c=L.distance}={}){this.query=null,this.options={isCaseSensitive:t,ignoreDiacritics:i,includeMatches:r,minMatchCharLength:n,findAllMatches:o,ignoreLocation:s,location:a,threshold:l,distance:c},e=t?e:e.toLowerCase(),e=i?O(e):e,this.pattern=e,this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(J).filter((e=>e&&!!e.trim())),r=[];for(let e=0,n=i.length;e<n;e+=1){const n=i[e];let s=!1,o=-1;for(;!s&&++o<H;){const e=Z[o];let i=e.isMultiMatch(n);i&&(r.push(new e(i,t)),s=!0)}if(!s)for(o=-1;++o<H;){const e=Z[o];let i=e.isSingleMatch(n);if(i){r.push(new e(i,t));break}}}return r}))}(this.pattern,this.options)}static condition(e,t){return t.useExtendedSearch}searchIn(e){const t=this.query;if(!t)return{isMatch:!1,score:1};const{includeMatches:i,isCaseSensitive:r,ignoreDiacritics:n}=this.options;e=r?e:e.toLowerCase(),e=n?O(e):e;let s=0,o=[],a=0;for(let r=0,n=t.length;r<n;r+=1){const n=t[r];o.length=0,s=0;for(let t=0,r=n.length;t<r;t+=1){const r=n[t],{isMatch:l,indices:c,score:u}=r.search(e);if(!l){a=0,s=0,o.length=0;break}if(s+=1,a+=u,i){const e=r.constructor.type;K.has(e)?o=[...o,...c]:o.push(c)}}if(s){let e={isMatch:!0,score:a/s};return i&&(e.indices=o),e}}return{isMatch:!1,score:1}}}const G=[];function Q(e,t){for(let i=0,r=G.length;i<r;i+=1){let r=G[i];if(r.condition(e,t))return new r(e,t)}return new N(e,t)}const X="$and",Y="$or",ee="$path",te="$val",ie=e=>!(!e[X]&&!e[Y]),re=e=>({[X]:Object.keys(e).map((t=>({[t]:e[t]})))});function ne(e,t,{auto:i=!0}={}){const r=e=>{let n=Object.keys(e);const s=(e=>!!e[ee])(e);if(!s&&n.length>1&&!ie(e))return r(re(e));if((e=>!p(e)&&x(e)&&!ie(e))(e)){const r=s?e[ee]:n[0],o=s?e[te]:e[r];if(!y(o))throw new Error((e=>`Invalid value for key ${e}`)(r));const a={keyId:E(r),pattern:o};return i&&(a.searcher=Q(o,t)),a}let o={children:[],operator:n[0]};return n.forEach((t=>{const i=e[t];p(i)&&i.forEach((e=>{o.children.push(r(e))}))})),o};return ie(e)||(e=re(e)),r(e)}function se(e,t){const i=e.matches;t.matches=[],$(i)&&i.forEach((e=>{if(!$(e.indices)||!e.indices.length)return;const{indices:i,value:r}=e;let n={indices:i,value:r};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}))}function oe(e,t){t.score=e.score}class ae{constructor(e,t={},i){this.options={...L,...t},this.options.useExtendedSearch,this._keyStore=new F(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof w))throw new Error("Incorrect 'index' type");this._myIndex=t||j(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){$(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,r=this._docs.length;i<r;i+=1){const n=this._docs[i];e(n,i)&&(this.removeAt(i),i-=1,r-=1,t.push(n))}return t}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:t=-1}={}){const{includeMatches:i,includeScore:r,shouldSort:n,sortFn:s,ignoreFieldNorm:o}=this.options;let a=y(e)?y(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,{ignoreFieldNorm:t=L.ignoreFieldNorm}){e.forEach((e=>{let i=1;e.matches.forEach((({key:e,norm:r,score:n})=>{const s=e?e.weight:null;i*=Math.pow(0===n&&s?Number.EPSILON:n,(s||1)*(t?1:r))})),e.score=i}))}(a,{ignoreFieldNorm:o}),n&&a.sort(s),g(t)&&t>-1&&(a=a.slice(0,t)),function(e,t,{includeMatches:i=L.includeMatches,includeScore:r=L.includeScore}={}){const n=[];return i&&n.push(se),r&&n.push(oe),e.map((e=>{const{idx:i}=e,r={item:t[i],refIndex:i};return n.length&&n.forEach((t=>{t(e,r)})),r}))}(a,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(e){const t=Q(e,this.options),{records:i}=this._myIndex,r=[];return i.forEach((({v:e,i:i,n:n})=>{if(!$(e))return;const{isMatch:s,score:o,indices:a}=t.searchIn(e);s&&r.push({item:e,idx:i,matches:[{score:o,value:e,norm:n,indices:a}]})})),r}_searchLogical(e){const t=ne(e,this.options),i=(e,t,r)=>{if(!e.children){const{keyId:i,searcher:n}=e,s=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:n});return s&&s.length?[{idx:r,item:t,matches:s}]:[]}const n=[];for(let s=0,o=e.children.length;s<o;s+=1){const o=e.children[s],a=i(o,t,r);if(a.length)n.push(...a);else if(e.operator===X)return[]}return n},r=this._myIndex.records,n={},s=[];return r.forEach((({$:e,i:r})=>{if($(e)){let o=i(t,e,r);o.length&&(n[r]||(n[r]={idx:r,item:e,matches:[]},s.push(n[r])),o.forEach((({matches:e})=>{n[r].matches.push(...e)})))}})),s}_searchObjectList(e){const t=Q(e,this.options),{keys:i,records:r}=this._myIndex,n=[];return r.forEach((({$:e,i:r})=>{if(!$(e))return;let s=[];i.forEach(((i,r)=>{s.push(...this._findMatches({key:i,value:e[r],searcher:t}))})),s.length&&n.push({idx:r,item:e,matches:s})})),n}_findMatches({key:e,value:t,searcher:i}){if(!$(t))return[];let r=[];if(p(t))t.forEach((({v:t,i:n,n:s})=>{if(!$(t))return;const{isMatch:o,score:a,indices:l}=i.searchIn(t);o&&r.push({score:a,key:e,value:t,idx:n,norm:s,indices:l})}));else{const{v:n,n:s}=t,{isMatch:o,score:a,indices:l}=i.searchIn(n);o&&r.push({score:a,key:e,value:n,norm:s,indices:l})}return r}}ae.version="7.1.0",ae.createIndex=j,ae.parseIndex=function(e,{getFn:t=L.getFn,fieldNormWeight:i=L.fieldNormWeight}={}){const{keys:r,records:n}=e,s=new w({getFn:t,fieldNormWeight:i});return s.setKeys(r),s.setIndexRecords(n),s},ae.config=L,ae.parseQuery=ne,function(...e){G.push(...e)}(U);let le,ce,ue,de,he,fe,pe,_e,me,ye,ge,ve,xe,$e,Ae,Ce,be,Me,ke,Fe,Be,De,Ee,Le,Se,we,je,Ie,Ve,Pe,Re,Oe,Ne,Te,We,qe,ze,Ze,He,Je,Ke,Ue,Ge=e=>e;const Qe=["paypal_platform"],Xe=s(e,"payments-api-payment-method-form");class Ye extends Xe{constructor(){super(...arguments),this.paymentPreset=null,this.getImageSrc=null,this.getConnectRedirectUrl=null,this.store=null,this.__availablePaymentMethodsLoaderId="availablePaymentMethodsLoader",this.__paymentPresetLoaderId="paymentPresetLoader",this.__storeLoaderId="storeLoader",this.__threeDSecureResponseGetValue=()=>{var e;return null===(e=this.form.config_3d_secure)||void 0===e?void 0:e.endsWith("require_valid_response")},this.__threeDSecureResponseSetValue=e=>{const t=e?"_require_valid_response":"",i=this.form.config_3d_secure,r=(null==i?void 0:i.startsWith("all_cards"))?"all_cards":"maestro_only";this.edit({config_3d_secure:`${r}${t}`})},this.__threeDSecureToggleGetValue=()=>{const e=this.form.config_3d_secure;return(null==e?void 0:e.startsWith("all_cards"))?"all_cards":(null==e?void 0:e.startsWith("maestro_only"))?"maestro_only":"off"},this.__threeDSecureToggleSetValue=e=>{var t;let i="";"all_cards"!==e&&"maestro_only"!==e||(i=(null===(t=this.form.config_3d_secure)||void 0===t?void 0:t.endsWith("require_valid_response"))?`${e}_require_valid_response`:e),this.edit({config_3d_secure:i})},this.__threeDSecureToggleOptions=[{value:"off",label:"option_off"},{value:"all_cards",label:"option_all_cards"},{value:"maestro_only",label:"option_maestro_only"}],this.__cardVerificationOptions=[{label:"option_disabled",value:"disabled"},{label:"option_enabled_automatically",value:"enabled_automatically"},{label:"option_enabled_override",value:"enabled_override"}],this.__defaultTestCredentialsGetValue=()=>{const e=this.__additionalFieldsConfig;return this.__hasDefaultTestCredentials&&this.__defaultTestCredentials.every((([e,t])=>this.form[e]===t))&&this.__defaultTestFields.every((i=>t(e,i.id)===i.default_value))},this.__defaultTestCredentialsSetValue=e=>{const t=this.__additionalFieldsConfig,i={};this.__defaultTestCredentials.forEach((([t,r])=>i[t]=e?r:"")),this.__defaultTestFields.forEach((i=>{e?h(t,i.id,i.default_value):f(t,i.id)})),this.__defaultTestFields.length&&(i.additional_fields=JSON.stringify(t)),this.edit(i)},this.__search="",this.__connectState="idle",this.__connectKey=""}static get defaultImageSrc(){return"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E"}static get properties(){return i(i({},super.properties),{},{paymentPreset:{attribute:"payment-preset"},getImageSrc:{attribute:!1},getConnectRedirectUrl:{attribute:!1},store:{},__search:{attribute:!1},__connectState:{attribute:!1},__connectKey:{attribute:!1}})}static get v8n(){return[({description:e})=>!e||e.length<=100||"description:v8n_too_long",({type:e})=>!!e||"type:v8n_required",e=>{var t,i,r,n;const s=null!==(r=null===(i=null===(t=e.helper)||void 0===t?void 0:t.additional_fields)||void 0===i?void 0:i.blocks)&&void 0!==r?r:[];let o;try{o=JSON.parse(null!==(n=e.additional_fields)&&void 0!==n?n:"{}")}catch(e){o={}}for(const e of s)for(const t of e.fields)if("optional"in t&&!t.optional&&!d(o,t.id)&&"checkbox"!==t.type)return"additional-fields:v8n_invalid";return!0}]}get scopeCollection(){return"payment_settings"}get hiddenSelector(){return new r(`header:copy-json ${super.hiddenSelector}`.trimEnd())}renderHeader(...e){var t;return l(le||(le=Ge` <div> ${0} ${0} </div> `),super.renderHeader(...e),(null===(t=this.data)||void 0===t?void 0:t.type)||!this.form.type?l(ce||(ce=Ge``)):l(ue||(ue=Ge` <foxy-internal-button data-testid="select-another-button" theme="tertiary-inline" @click="${0}"> <foxy-i18n infer="" key="select_another_button_label"></foxy-i18n> </foxy-internal-button> `),(()=>this.undo())))}get headerTitleOptions(){var e;return{context:this.form.type?"selected":"new",name:null===(e=this.form.helper)||void 0===e?void 0:e.name}}get headerSubtitleOptions(){if(this.href){const e=n(this.href),t=this.headerCopyIdValue;return e.startsWith("R")?{context:"regular",id:t}:{context:"hosted",id:t}}return{}}get headerCopyIdValue(){if(this.href){const e=n(this.href);return e.startsWith("R")?e.slice(1):e.slice(1).split("C")[0]}return""}renderBody(){var e;const t=null===(e=this.__paymentPresetLoader)||void 0===e?void 0:e.data,i=l(de||(de=Ge` <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> `),a(null==t?void 0:t._links["fx:available_payment_methods"].href),this.__availablePaymentMethodsLoaderId,(()=>this.requestUpdate()),a(this.store),this.__storeLoaderId,(()=>this.requestUpdate()),a(this.paymentPreset),this.__paymentPresetLoaderId,(()=>this.requestUpdate()));return l(he||(he=Ge`${0}${0}${0}`),this.renderHeader(),this.form.type?this.__renderPaymentMethodConfig():this.__renderPaymentMethodSelector(),i)}get __groupedAvailablePaymentMethods(){var e;const t=Object.entries(null!==(e=this.__availablePaymentMethods)&&void 0!==e?e:{});return(this.__search?new ae(t,{keys:["1.name"],threshold:.25}).search(this.__search).map((e=>e.item)):t).sort(((e,t)=>e[1].name.localeCompare(t[1].name,"en"))).reduce(((e,[t,i])=>{if(i.is_deprecated)return e;const r=i.name.charAt(0).toUpperCase(),n=!/\w/.test(r)?"#":r,s=e.find((e=>e.name===n)),o=Qe.includes(t)?this.__getConnectChoices(t).map((e=>({type:t,helper:i,choice:e}))):[{type:t,helper:i}];return s?s.items.push(...o):e.push({name:n,items:o}),e}),[])}get __availablePaymentMethodsLoader(){return this.renderRoot.querySelector(`#${this.__availablePaymentMethodsLoaderId}`)}get __availablePaymentMethods(){var e,t;return null===(t=null===(e=this.__availablePaymentMethodsLoader)||void 0===e?void 0:e.data)||void 0===t?void 0:t.values}get __paymentPresetLoader(){return this.renderRoot.querySelector(`#${this.__paymentPresetLoaderId}`)}get __storeLoader(){return this.renderRoot.querySelector(`#${this.__storeLoaderId}`)}get __liveBlocks(){var e,t,i;return null!==(i=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>e.is_live)))&&void 0!==i?i:[]}get __testBlocks(){var e,t,i;return null!==(i=null===(t=null===(e=this.form.helper)||void 0===e?void 0:e.additional_fields)||void 0===t?void 0:t.blocks.filter((e=>!e.is_live)))&&void 0!==i?i:[]}get __defaultTestCredentials(){const e=this.form.helper;return[["test_account_id",null==e?void 0:e.test_id],["test_account_key",null==e?void 0:e.test_key],["test_third_party_key",null==e?void 0:e.test_third_party_key]].filter((e=>!!e[1]))}get __defaultTestFields(){return this.__testBlocks.flatMap((e=>e.fields)).filter((e=>"hidden"!==e.type&&"string"==typeof e.default_value)).filter((e=>""!==e.default_value))}get __hasDefaultTestCredentials(){return this.__defaultTestCredentials.length>0||this.__defaultTestFields.length>0}get __additionalFieldsConfig(){var e,t;try{return null!==(t=JSON.parse(null!==(e=this.form.additional_fields)&&void 0!==e?e:""))&&void 0!==t?t:{}}catch(e){return{}}}__renderPaymentMethodSelector(){const e=this.__availablePaymentMethodsLoader;return(null==e?void 0:e.data)?l(pe||(pe=Ge` <div> <input placeholder="${0}" class="w-full leading-m font-medium bg-contrast-5 rounded text-body transition-colors hover-bg-contrast-10 focus-bg-contrast-10 focus-outline-none focus-ring-2 focus-ring-primary-50" style="padding:var(--lumo-space-xs) calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" type="search" .value="${0}" @input="${0}"> <section data-testid="select-method-list"> ${0} </section> </div> `),this.t("search_placeholder"),this.__search,(e=>{this.__search=e.currentTarget.value}),this.__groupedAvailablePaymentMethods.map((({name:e,items:t})=>l(_e||(_e=Ge` <p class="font-medium text-tertiary py-m">${0}</p> <foxy-internal-summary-control infer="" label="" helper-text=""> ${0} </foxy-internal-summary-control> `),e,t.map(((e,i)=>this.__renderPaymentMethodButton(e,i,t.length))))))):l(fe||(fe=Ge` <foxy-spinner infer="list-spinner" state="${0}" error-type="${0}"> </foxy-spinner> `),(null==e?void 0:e.in("fail"))?"error":"busy",(null==e?void 0:e.accessDenied)?"access-denied":"generic")}__redirect(e){window.location.assign(e)}__getConnectChoices(e){return"paypal_platform"===e?[{key:"paypal_platform.ppcp",options:{paypal_product_type:"ppcp"}},{key:"paypal_platform.express_checkout",options:{paypal_product_type:"express_checkout"}}]:[{key:"default"}]}__getReconnectChoice(e){if("paypal_platform"===this.form.type){return{key:`paypal_platform.${e?"reconnect":"reconnect_with_cards"}`,options:{paypal_product_type:"ppcp"}}}return{key:"reconnect"}}async __connect(e,t){var i,r,n,s,o,a,l,c,u,d,h,f;const p=null===(r=null===(i=this.__paymentPresetLoader)||void 0===i?void 0:i.data)||void 0===r?void 0:r._links["fx:connect_gateway"],_=null!==(o=null===(s=null===(n=this.data)||void 0===n?void 0:n._links["fx:connect_gateway"])||void 0===s?void 0:s.href)&&void 0!==o?o:null==p?void 0:p.href;if(_&&this.paymentPreset&&"busy"!==this.__connectState){this.__connectState="busy",this.__connectKey=e.key,this.status=null;try{const i={type:t,final_redirect:null!==(l=null===(a=this.getConnectRedirectUrl)||void 0===a?void 0:a.call(this,this.paymentPreset))&&void 0!==l?l:window.location.href};e.options&&(i.options=e.options);const r=await this._fetch(_,{method:"POST",body:JSON.stringify(i)});if(!r.connection_url)throw new Error("No connection_url in the response.");this.__redirect(r.connection_url)}catch(t){let i="";if(t instanceof Response)try{const e=await t.json();i=null!==(h=null===(d=null===(u=null===(c=null==e?void 0:e._embedded)||void 0===c?void 0:c["fx:errors"])||void 0===u?void 0:u[0])||void 0===d?void 0:d.message)&&void 0!==h?h:""}catch(e){}const r=t instanceof Response&&403===t.status&&"ppcp"===(null===(f=e.options)||void 0===f?void 0:f.paypal_product_type)&&i.includes("'ppcp'");this.status=r?{key:"connect_error_ppcp_unsupported",type:"error"}:i?{key:"connect_error",options:{message:i},type:"error"}:{key:"connect_error_unknown",type:"error"},this.__connectState="idle"}}}__renderConnection(){var e,t,i,r;const n=null===(e=this.__paymentPresetLoader)||void 0===e?void 0:e.data;if(!n)return l(me||(me=Ge``));const s=n.is_live?"":"test_",o=null===(t=this.data)||void 0===t?void 0:t[`${s}account_id`],a=null!==(r=null===(i=this.data)||void 0===i?void 0:i[`${s}third_party_key`])&&void 0!==r?r:"",c=this.form.type,u=o?[this.__getReconnectChoice(a)]:this.__getConnectChoices(c),d="busy"===this.__connectState,h=this.readonlySelector.matches("connection",!0),f=d||this.disabledSelector.matches("connection",!0);return l(ye||(ye=Ge` <foxy-internal-summary-control infer="connection"> ${0} ${0} </foxy-internal-summary-control> `),o?l(ge||(ge=Ge` <p class="font-medium"> <foxy-i18n infer="" key="status_connected" .options="${0}"></foxy-i18n> </p> `),{email:o}):"",(h?[]:u).map((e=>l(ve||(ve=Ge` <div class="leading-xs"> <p class="font-medium"> <foxy-i18n infer="" key="${0}.label"></foxy-i18n> </p> <p class="text-s text-secondary"> <foxy-i18n infer="" key="${0}.description"></foxy-i18n> </p> </div> <div> <foxy-internal-button data-testid="connect-${0}" theme="tertiary-inline" ?disabled="${0}" @click="${0}"> ${0} </foxy-internal-button> </div> `),e.key,e.key,e.key,f,(()=>this.__connect(e,c)),d&&this.__connectKey===e.key?l(xe||(xe=Ge`<foxy-spinner layout="no-label" infer="connect-spinner"></foxy-spinner>`)):l($e||($e=Ge`<foxy-i18n infer="" key="${0}.button"></foxy-i18n>`),e.key)))))}__renderPaymentMethodConfig(){var e,t;if(this.form.type&&Qe.includes(this.form.type))return l(Ae||(Ae=Ge` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> </foxy-internal-summary-control> ${0} ${0} `),this.__renderConnection(),super.renderBody());return this.form.type&&["stripe_connect","stripe_v2","square_up","quickbook_payments","amazon_mws","paypal_platform"].includes(this.form.type)?l(Ce||(Ce=Ge` <div class="flex items-start rounded border border-primary" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px);padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p> <foxy-i18n infer="" key="no_oauth_support_message"></foxy-i18n> <br> <a target="_blank" class="mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50" href="https://admin.foxycart.com"> admin.foxycart.com </a> </p> </div> `),c(be||(be=Ge`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`))):l(Me||(Me=Ge` <foxy-internal-summary-control infer="general"> <foxy-internal-text-control layout="summary-item" infer="description"> </foxy-internal-text-control> ${0} ${0} </foxy-internal-summary-control> ${0} ${0} `),(null===(e=this.form.helper)||void 0===e?void 0:e.supports_auth_only)?l(ke||(ke=Ge` <foxy-internal-switch-control infer="use-auth-only" helper-text-as-tooltip> </foxy-internal-switch-control> `)):"",(null===(t=this.form.helper)||void 0===t?void 0:t.supports_3d_secure)?l(Fe||(Fe=Ge` <foxy-internal-select-control layout="summary-item" infer="three-d-secure-toggle" .getValue="${0}" .setValue="${0}" .options="${0}"> </foxy-internal-select-control> ${0} `),this.__threeDSecureToggleGetValue,this.__threeDSecureToggleSetValue,this.__threeDSecureToggleOptions,this.form.config_3d_secure?l(Be||(Be=Ge` <foxy-internal-switch-control layout="summary-item" infer="three-d-secure-response" .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),this.__threeDSecureResponseGetValue,this.__threeDSecureResponseSetValue):""):"",["live","test"].map(((e,t)=>{var i,r,n,s,u,d,h,f,p,_,m,y,g,v,x;const $=o(this.currentUserScope,"stores"),A=0===t?"":`${e}_`,C=0===t?"":`${e}-`,b=0===t?this.__liveBlocks:this.__testBlocks,M=`${e}-group`,k="test"===e&&this.__defaultTestCredentialsGetValue();if("live"===e&&$&&!(null===(i=this.__storeLoader)||void 0===i?void 0:i.data))return l(De||(De=Ge``));if("live"===e&&$&&!(null===(n=null===(r=this.__storeLoader)||void 0===r?void 0:r.data)||void 0===n?void 0:n.is_active))return l(Ee||(Ee=Ge` <foxy-internal-summary-control infer="${0}-group"> <div class="flex items-start" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <p><foxy-i18n infer="" key="inactive_message"></foxy-i18n></p> </div> </foxy-internal-summary-control> `),e,c(Le||(Le=Ge`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="flex-shrink-0 text-primary" style="width: 1.25em"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`)));const F=!0===(null===(u=null===(s=this.__storeLoader)||void 0===s?void 0:s.data)||void 0===u?void 0:u.is_active)&&("test"===e&&!0===(null===(h=null===(d=this.__paymentPresetLoader)||void 0===d?void 0:d.data)||void 0===h?void 0:h.is_live)||"live"===e&&!1===(null===(p=null===(f=this.__paymentPresetLoader)||void 0===f?void 0:f.data)||void 0===p?void 0:p.is_live));return l(Se||(Se=Ge` <foxy-internal-summary-control helper-text="${0}" layout="section" label="${0}" infer="${0}"> <foxy-internal-summary-control infer="" label="" helper-text=""> ${0} ${0} ${0} ${0} ${0} ${0} </foxy-internal-summary-control> ${0} </foxy-internal-summary-control> `),a(F?this.t(`${M}.helper_text_inactive`):void 0),a(F?this.t(`${M}.label_inactive`):void 0),M,"test"===e&&this.__hasDefaultTestCredentials?l(we||(we=Ge` <foxy-internal-switch-control infer="default-credentials" helper-text-as-tooltip .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),this.__defaultTestCredentialsGetValue,this.__defaultTestCredentialsSetValue):"",!(null===(_=this.form.helper)||void 0===_?void 0:_.id_description)||k&&this.form.helper.test_id?"":l(je||(je=Ge` <foxy-internal-text-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}account-id"> </foxy-internal-text-control> `),this.t("default_additional_field_placeholder"),this.form.helper.id_description,C),!(null===(m=this.form.helper)||void 0===m?void 0:m.third_party_key_description)||k&&this.form.helper.test_third_party_key?"":l(Ie||(Ie=Ge` <foxy-internal-password-control placeholder="${0}" helper-text="" layout="summary-item" label="${0}" infer="${0}third-party-key"> </foxy-internal-password-control> `),this.t("default_additional_field_placeholder"),this.form.helper.third_party_key_description,C),!(null===(y=this.form.helper)||void 0===y?void 0:y.key_description)||k&&this.form.helper.test_key?"":l(Ve||(Ve=Ge` <foxy-internal-password-control placeholder="${0}" layout="summary-item" helper-text="" label="${0}" infer="${0}account-key"> </foxy-internal-password-control> `),this.t("default_additional_field_placeholder"),this.form.helper.key_description,C),b.map((e=>this.__renderBlock(e,k?this.__defaultTestFields:[]))),(null===(g=this.form.helper)||void 0===g?void 0:g.supports_card_verification)?l(Pe||(Pe=Ge` <foxy-internal-select-control helper-text="${0}" layout="summary-item" infer="${0}card-verification" .options="${0}" .getValue="${0}"> </foxy-internal-select-control> `),this.t(`${M}.${C}card-verification.helper_text_${this.form[`${A}card_verification`]||"disabled"}`),C,this.__cardVerificationOptions,(()=>this.form[`${A}card_verification`]||"disabled")):"",(null===(v=this.form.helper)||void 0===v?void 0:v.supports_card_verification)&&(null===(x=this.form[`${A}card_verification`])||void 0===x?void 0:x.startsWith("enabled_"))?l(Re||(Re=Ge` <foxy-internal-summary-control layout="details" class="mt-s" infer="${0}card-verification-config"> ${0} </foxy-internal-summary-control> `),C,["visa","mastercard","american-express","discover","default"].map((e=>{var t;return l(Oe||(Oe=Ge` <foxy-internal-number-control json-template="${0}" json-path="verification_amounts.${0}" property="${0}card_verification_config" layout="summary-item" infer="${0}card-verification-config-verification-amounts-${0}" step="0.01" min="0"> </foxy-internal-number-control> `),a(null===(t=this.form.helper)||void 0===t?void 0:t.card_verification_config),e.replace(/-/g,"_"),A,C,e)}))):"")})),super.renderBody())}__select(e,t){const i={type:e,helper:t};t.supports_card_verification&&(i.card_verification=i.test_card_verification=t.card_verification,i.card_verification_config=i.test_card_verification_config=t.card_verification_config),this.edit(i)}__renderPaymentMethodButton({type:e,helper:t,choice:i},r,n){var s,o;const c=Ye.defaultImageSrc,d=null!==(o=null===(s=this.getImageSrc)||void 0===s?void 0:s.call(this,e))&&void 0!==o?o:c,h="busy"===this.__connectState,f=h&&!!i&&this.__connectKey===i.key,p=!!i&&"default"!==i.key;return l(Ne||(Ne=Ge` <button class="${0}" data-testid="${0}" ?disabled="${0}" style="padding:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)" @click="${0}"> <figure class="relative flex items-center" style="gap:calc(.625em + (var(--lumo-border-radius)/ 4) - 1px)"> ${0} <figcaption class="${0}"> <span class="font-medium"> ${0}​ </span> ${0} </figcaption> </figure> </button> `),u({"relative w-full block text-left bg-contrast-5 overflow-hidden":!0,"focus-outline-none focus-ring-inset focus-ring-2 focus-ring-primary-50":!0,"transition-colors hover-bg-contrast-10":!t.conflict,"cursor-default":!!t.conflict,"rounded-t":0===r,"rounded-b":r===n-1}),a(i?`connect-${i.key}`:void 0),!!t.conflict||h,(()=>i?this.__connect(i,e):this.__select(e,t)),f?l(Te||(Te=Ge` <foxy-spinner data-testid="connect-spinner" class="h-m w-m flex items-center justify-center flex-shrink-0" layout="no-label" infer="connect-spinner"> </foxy-spinner> `)):l(We||(We=Ge` <img class="${0}" src="${0}" alt="" @error="${0}"> `),u({"h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs":!0,"filter grayscale":!!t.conflict}),d,(e=>e.currentTarget.src=c)),u({"min-w-0 flex-1 grid leading-xs":!0,"text-disabled":!!t.conflict}),p?this.t(`connection.${i.key}.label`):t.name,t.conflict?l(qe||(qe=Ge`<span class="text-xs"> ${0}</span>`),this.t("conflict_message",t.conflict)):i?l(ze||(ze=Ge` <span class="text-xs text-secondary"> ${0} ${0} </span> `),p?this.t(`connection.${i.key}.description`):"",this.t("connection.redirect_notice")):"")}__renderBlock(e,i=[]){return l(Ze||(Ze=Ge`${0}`),e.fields.map((r=>{var n,s,o;if("hidden"===r.type||i.includes(r))return;const a=["additional-fields",r.id].join("-").replace(/_/g,"-"),c=()=>{var i,n;try{const e=JSON.parse(null!==(i=this.form.additional_fields)&&void 0!==i?i:"{}");return null!==(n=t(e,r.id))&&void 0!==n?n:e.default_value}catch(t){return e.is_live?r.default_value:void 0}},u=e=>{var t;let i={};try{i=JSON.parse(null!==(t=this.form.additional_fields)&&void 0!==t?t:"")}catch(e){}this.edit({additional_fields:JSON.stringify(h(i,r.id,e))})},d=r.options;return l(He||(He=Ge` ${0} `),"checkbox"===r.type?l(Je||(Je=Ge` <foxy-internal-switch-control helper-text="${0}" label="${0}" infer="${0}" helper-text-as-tooltip .getValue="${0}" .setValue="${0}"> </foxy-internal-switch-control> `),null!==(n=r.description)&&void 0!==n?n:"",r.name,a,c,u):"select"===r.type?l(Ke||(Ke=Ge` <foxy-internal-select-control placeholder="${0}" helper-text="${0}" layout="summary-item" label="${0}" infer="${0}" .options="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-select-control> `),this.t("default_additional_field_select_placeholder"),null!==(s=r.description)&&void 0!==s?s:"",r.name,a,d.map((({name:e,value:t})=>({label:e,value:t}))),c,u):l(Ue||(Ue=Ge` <foxy-internal-text-control helper-text="${0}" placeholder="${0}" layout="summary-item" label="${0}" infer="${0}" .getValue="${0}" .setValue="${0}"> </foxy-internal-text-control> `),null!==(o=r.description)&&void 0!==o?o:"",this.t("default_additional_field_placeholder"),r.name,a,c,u))})))}}customElements.define("foxy-payments-api-payment-method-form",Ye);export{Ye as PaymentsApiPaymentMethodForm};
|
|
@@ -79,6 +79,8 @@ export declare class PaymentsApiPaymentMethodForm extends Base<Data> {
|
|
|
79
79
|
private __connect;
|
|
80
80
|
private __renderConnection;
|
|
81
81
|
private __renderPaymentMethodConfig;
|
|
82
|
+
/** Selects a payment method and prefills card verification with the gateway defaults. */
|
|
83
|
+
private __select;
|
|
82
84
|
private __renderPaymentMethodButton;
|
|
83
85
|
private __renderBlock;
|
|
84
86
|
}
|
|
@@ -694,6 +694,16 @@ export class PaymentsApiPaymentMethodForm extends Base {
|
|
|
694
694
|
${super.renderBody()}
|
|
695
695
|
`;
|
|
696
696
|
}
|
|
697
|
+
/** Selects a payment method and prefills card verification with the gateway defaults. */
|
|
698
|
+
__select(type, helper) {
|
|
699
|
+
const edit = { type, helper };
|
|
700
|
+
if (helper.supports_card_verification) {
|
|
701
|
+
edit.card_verification = edit.test_card_verification = helper.card_verification;
|
|
702
|
+
edit.card_verification_config = edit.test_card_verification_config =
|
|
703
|
+
helper.card_verification_config;
|
|
704
|
+
}
|
|
705
|
+
this.edit(edit);
|
|
706
|
+
}
|
|
697
707
|
__renderPaymentMethodButton({ type, helper, choice }, index, total) {
|
|
698
708
|
var _a, _b;
|
|
699
709
|
const defaultSrc = PaymentsApiPaymentMethodForm.defaultImageSrc;
|
|
@@ -715,7 +725,7 @@ export class PaymentsApiPaymentMethodForm extends Base {
|
|
|
715
725
|
data-testid=${ifDefined(choice ? `connect-${choice.key}` : undefined)}
|
|
716
726
|
?disabled=${!!helper.conflict || isBusy}
|
|
717
727
|
style="padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)"
|
|
718
|
-
@click=${() => (choice ? this.__connect(choice, type) : this.
|
|
728
|
+
@click=${() => (choice ? this.__connect(choice, type) : this.__select(type, helper))}
|
|
719
729
|
>
|
|
720
730
|
<figure
|
|
721
731
|
class="relative flex items-center"
|
package/dist/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaymentsApiPaymentMethodForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,GAAG,MAAM,eAA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A;;8BAEc,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;8BACvB,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC;;wBAEpD,KAAK,CAAC,IAAI;wBACV,KAAK;4BACD,QAAQ;4BACR,QAAQ;;;aAGvB;OACN,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["import type { AvailablePaymentMethods, PaymentPreset } from '../PaymentsApi/api/types';\nimport type { Block, Data } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { ScopeCollection } from '../../../utils/user-scope';\n\nimport { BooleanSelector, getResourceId } from '@foxy.io/sdk/core';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\n\nimport Fuse from 'fuse.js';\nimport has from 'lodash-es/has';\nimport get from 'lodash-es/get';\nimport set from 'lodash-es/set';\nimport unset from 'lodash-es/unset';\n\ntype ConnectChoice = {\n key: string;\n options?: Rels.ConnectGateway['props']['options'];\n};\n\ntype PaymentMethod = {\n helper: AvailablePaymentMethods['values'][string];\n choice?: ConnectChoice;\n type: string;\n};\n\n/** OAuth gateways that connect through fx:connect_gateway. Other OAuth gateways show a notice. */\nconst connectableGateways = ['paypal_platform'];\n\nconst NS = 'payments-api-payment-method-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_method` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-method-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentMethodForm extends Base<Data> {\n static get defaultImageSrc(): string {\n return \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E\";\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n paymentPreset: { attribute: 'payment-preset' },\n getImageSrc: { attribute: false },\n getConnectRedirectUrl: { attribute: false },\n store: {},\n __search: { attribute: false },\n __connectState: { attribute: false },\n __connectKey: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !v || v.length <= 100 || 'description:v8n_too_long',\n ({ type: v }) => !!v || 'type:v8n_required',\n\n form => {\n const blocks = form.helper?.additional_fields?.blocks ?? [];\n let additionalFields: Record<string, unknown>;\n\n try {\n additionalFields = JSON.parse(form.additional_fields ?? '{}');\n } catch {\n additionalFields = {};\n }\n\n for (const block of blocks) {\n for (const field of block.fields) {\n if ('optional' in (field as Record<string, unknown>)) {\n if (!(field as Record<string, unknown>).optional) {\n if (!has(additionalFields, field.id)) {\n if (field.type !== 'checkbox') {\n return 'additional-fields:v8n_invalid';\n }\n }\n }\n }\n }\n }\n\n return true;\n },\n ];\n }\n\n /** URL of the linked `fx:payment_preset` resource from the virtual Payments API. */\n paymentPreset: string | null = null;\n\n /** A function that returns a URL of a payment method icon based on the given type. */\n getImageSrc: ((type: string) => string) | null = null;\n\n /**\n * Returns the URL the gateway sends the merchant back to after a connection.\n * Receives the `payment-preset` URL. The API appends a `status` query parameter.\n * Defaults to the current page URL.\n */\n getConnectRedirectUrl: ((paymentPreset: string) => string) | null = null;\n\n /** URL of the linked `fx:store` resource. */\n store: string | null = null;\n\n private readonly __availablePaymentMethodsLoaderId = 'availablePaymentMethodsLoader';\n\n private readonly __paymentPresetLoaderId = 'paymentPresetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __threeDSecureResponseGetValue = () => {\n return this.form.config_3d_secure?.endsWith('require_valid_response');\n };\n\n private readonly __threeDSecureResponseSetValue = (newValue: boolean) => {\n const postfix = newValue ? '_require_valid_response' : '';\n const config = this.form.config_3d_secure;\n const type = config?.startsWith('all_cards') ? 'all_cards' : 'maestro_only';\n\n this.edit({ config_3d_secure: `${type}${postfix}` as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleGetValue = () => {\n const config = this.form.config_3d_secure;\n\n if (config?.startsWith('all_cards')) return 'all_cards';\n if (config?.startsWith('maestro_only')) return 'maestro_only';\n\n return 'off';\n };\n\n private readonly __threeDSecureToggleSetValue = (\n newValue: 'off' | 'all_cards' | 'maestro_only'\n ) => {\n let newFormValue = '';\n\n if (newValue === 'all_cards' || newValue === 'maestro_only') {\n if (this.form.config_3d_secure?.endsWith('require_valid_response')) {\n newFormValue = `${newValue}_require_valid_response`;\n } else {\n newFormValue = newValue;\n }\n }\n\n this.edit({ config_3d_secure: newFormValue as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleOptions = [\n { value: 'off', label: 'option_off' },\n { value: 'all_cards', label: 'option_all_cards' },\n { value: 'maestro_only', label: 'option_maestro_only' },\n ];\n\n private readonly __cardVerificationOptions = [\n { label: 'option_disabled', value: 'disabled' },\n { label: 'option_enabled_automatically', value: 'enabled_automatically' },\n { label: 'option_enabled_override', value: 'enabled_override' },\n ];\n\n /** On when every test credential with a default is set to that default. */\n private readonly __defaultTestCredentialsGetValue = () => {\n const config = this.__additionalFieldsConfig;\n\n return (\n this.__hasDefaultTestCredentials &&\n this.__defaultTestCredentials.every(([key, value]) => this.form[key] === value) &&\n this.__defaultTestFields.every(field => get(config, field.id) === field.default_value)\n );\n };\n\n /** Fills in the defaults when turned on. Clears the same fields when turned off. */\n private readonly __defaultTestCredentialsSetValue = (newValue: boolean) => {\n const config = this.__additionalFieldsConfig;\n const edit: Partial<Data> = {};\n\n this.__defaultTestCredentials.forEach(([key, value]) => (edit[key] = newValue ? value : ''));\n this.__defaultTestFields.forEach(field => {\n if (newValue) set(config, field.id, field.default_value);\n else unset(config, field.id);\n });\n\n if (this.__defaultTestFields.length) edit.additional_fields = JSON.stringify(config);\n this.edit(edit);\n };\n\n private __search = '';\n\n private __connectState: 'idle' | 'busy' = 'idle';\n\n /** Key of the connect choice whose connection URL is being fetched. */\n private __connectKey = '';\n\n get scopeCollection(): ScopeCollection | null {\n return 'payment_settings';\n }\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`header:copy-json ${super.hiddenSelector}`.trimEnd());\n }\n\n renderHeader(...params: Parameters<InternalForm<Data>['renderHeader']>): TemplateResult {\n return html`\n <div>\n ${super.renderHeader(...params)}\n ${this.data?.type || !this.form.type\n ? html``\n : html`\n <foxy-internal-button\n data-testid=\"select-another-button\"\n theme=\"tertiary-inline\"\n @click=${() => this.undo()}\n >\n <foxy-i18n infer=\"\" key=\"select_another_button_label\"></foxy-i18n>\n </foxy-internal-button>\n `}\n </div>\n `;\n }\n\n get headerTitleOptions(): Record<string, unknown> {\n return {\n context: this.form.type ? 'selected' : 'new',\n name: this.form.helper?.name,\n };\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n if (this.href) {\n const vId = getResourceId(this.href) as string;\n const id = this.headerCopyIdValue;\n if (vId.startsWith('R')) return { context: 'regular', id };\n return { context: 'hosted', id };\n }\n\n return {};\n }\n\n get headerCopyIdValue(): string | number {\n if (this.href) {\n const id = getResourceId(this.href) as string;\n return id.startsWith('R') ? id.slice(1) : id.slice(1).split('C')[0];\n } else {\n return '';\n }\n }\n\n renderBody(): TemplateResult {\n const paymentPreset = this.__paymentPresetLoader?.data;\n\n const loaders = html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(paymentPreset?._links['fx:available_payment_methods'].href)}\n id=${this.__availablePaymentMethodsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.store)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.paymentPreset)}\n id=${this.__paymentPresetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n\n return html`${this.renderHeader()}${this.form.type\n ? this.__renderPaymentMethodConfig()\n : this.__renderPaymentMethodSelector()}${loaders}`;\n }\n\n private get __groupedAvailablePaymentMethods() {\n const allMethods = Object.entries(this.__availablePaymentMethods ?? {});\n const filteredMethods = this.__search\n ? new Fuse(allMethods, { keys: ['1.name'], threshold: 0.25 })\n .search(this.__search)\n .map(v => v.item)\n : allMethods;\n\n return filteredMethods\n .sort((a, b) => a[1].name.localeCompare(b[1].name, 'en'))\n .reduce((groups, [type, helper]) => {\n if (helper.is_deprecated) return groups;\n\n const firstChar = helper.name.charAt(0).toUpperCase();\n const isSpecialCharacter = !/\\w/.test(firstChar);\n const name = isSpecialCharacter ? '#' : firstChar;\n const group = groups.find(group => group.name === name);\n\n const items: PaymentMethod[] = connectableGateways.includes(type)\n ? this.__getConnectChoices(type).map(choice => ({ type, helper, choice }))\n : [{ type, helper }];\n\n if (group) {\n group.items.push(...items);\n } else {\n groups.push({ name, items });\n }\n\n return groups;\n }, [] as { name: string; items: PaymentMethod[] }[]);\n }\n\n private get __availablePaymentMethodsLoader() {\n type Loader = NucleonElement<AvailablePaymentMethods>;\n return this.renderRoot.querySelector<Loader>(`#${this.__availablePaymentMethodsLoaderId}`);\n }\n\n private get __availablePaymentMethods() {\n return this.__availablePaymentMethodsLoader?.data?.values;\n }\n\n private get __paymentPresetLoader() {\n type Loader = NucleonElement<PaymentPreset>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentPresetLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n private get __liveBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => block.is_live) ?? [];\n }\n\n private get __testBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => !block.is_live) ?? [];\n }\n\n /** Top-level test credentials with a non-empty default for the selected gateway. */\n private get __defaultTestCredentials() {\n type Key = 'test_account_id' | 'test_account_key' | 'test_third_party_key';\n const helper = this.form.helper;\n const credentials: [Key, string | undefined][] = [\n ['test_account_id', helper?.test_id],\n ['test_account_key', helper?.test_key],\n ['test_third_party_key', helper?.test_third_party_key],\n ];\n\n return credentials.filter((entry): entry is [Key, string] => !!entry[1]);\n }\n\n /** Visible test additional fields with a non-empty default for the selected gateway. */\n private get __defaultTestFields() {\n return this.__testBlocks\n .flatMap(block => block.fields)\n .filter(field => field.type !== 'hidden' && typeof field.default_value === 'string')\n .filter(field => field.default_value !== '');\n }\n\n private get __hasDefaultTestCredentials() {\n return this.__defaultTestCredentials.length > 0 || this.__defaultTestFields.length > 0;\n }\n\n private get __additionalFieldsConfig(): Record<string, unknown> {\n try {\n return JSON.parse(this.form.additional_fields ?? '') ?? {};\n } catch {\n return {};\n }\n }\n\n private __renderPaymentMethodSelector() {\n const loader = this.__availablePaymentMethodsLoader;\n\n if (!loader?.data) {\n return html`\n <foxy-spinner\n infer=\"list-spinner\"\n state=${loader?.in('fail') ? 'error' : 'busy'}\n error-type=${loader?.accessDenied ? 'access-denied' : 'generic'}\n >\n </foxy-spinner>\n `;\n }\n\n return html`\n <div>\n <input\n placeholder=${this.t('search_placeholder')}\n class=\"w-full leading-m font-medium bg-contrast-5 rounded text-body transition-colors hover-bg-contrast-10 focus-bg-contrast-10 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n style=\"padding: var(--lumo-space-xs) calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n type=\"search\"\n .value=${this.__search}\n @input=${(evt: Event) => {\n this.__search = (evt.currentTarget as HTMLInputElement).value;\n }}\n />\n\n <section data-testid=\"select-method-list\">\n ${this.__groupedAvailablePaymentMethods.map(({ name, items }) => {\n return html`\n <p class=\"font-medium text-tertiary py-m\">${name}</p>\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${items.map((item, index) =>\n this.__renderPaymentMethodButton(item, index, items.length)\n )}\n </foxy-internal-summary-control>\n `;\n })}\n </section>\n </div>\n `;\n }\n\n private __redirect(url: string) {\n window.location.assign(url);\n }\n\n private __getConnectChoices(type: string): ConnectChoice[] {\n if (type === 'paypal_platform') {\n return [\n { key: 'paypal_platform.ppcp', options: { paypal_product_type: 'ppcp' } },\n {\n key: 'paypal_platform.express_checkout',\n options: { paypal_product_type: 'express_checkout' },\n },\n ];\n }\n\n return [{ key: 'default' }];\n }\n\n private __getReconnectChoice(thirdPartyKey: string): ConnectChoice {\n if (this.form.type === 'paypal_platform') {\n // An empty third-party key means the account is connected for PayPal only, without cards.\n const key = thirdPartyKey ? 'reconnect' : 'reconnect_with_cards';\n return { key: `paypal_platform.${key}`, options: { paypal_product_type: 'ppcp' } };\n }\n\n return { key: 'reconnect' };\n }\n\n private async __connect(choice: ConnectChoice, type: string) {\n const presetLink = this.__paymentPresetLoader?.data?._links['fx:connect_gateway'];\n const href = this.data?._links['fx:connect_gateway']?.href ?? presetLink?.href;\n if (!href || !this.paymentPreset || this.__connectState === 'busy') return;\n\n this.__connectState = 'busy';\n this.__connectKey = choice.key;\n this.status = null;\n\n try {\n const body: Rels.ConnectGateway['props'] = {\n type,\n final_redirect: this.getConnectRedirectUrl?.(this.paymentPreset) ?? window.location.href,\n };\n\n if (choice.options) body.options = choice.options;\n\n const response = await this._fetch<{ connection_url: string | null }>(href, {\n method: 'POST',\n body: JSON.stringify(body),\n });\n\n // The API answers 201 with a null URL when the gateway itself fails to create one.\n if (!response.connection_url) throw new Error('No connection_url in the response.');\n\n // State stays busy on purpose: the spinner keeps going until the browser leaves the page.\n this.__redirect(response.connection_url);\n } catch (err) {\n let message = '';\n\n if (err instanceof Response) {\n try {\n const json = await err.json();\n message = json?._embedded?.['fx:errors']?.[0]?.message ?? '';\n } catch {\n // not a vnd.error response\n }\n }\n\n // The API's country error names raw option values ('ppcp', 'express_checkout'), so we\n // replace it with our own text. It's the only 403 our requests can get that mentions 'ppcp'.\n const isPpcpUnsupported =\n err instanceof Response &&\n err.status === 403 &&\n choice.options?.paypal_product_type === 'ppcp' &&\n message.includes(\"'ppcp'\");\n\n if (isPpcpUnsupported) {\n this.status = { key: 'connect_error_ppcp_unsupported', type: 'error' };\n } else if (message) {\n this.status = { key: 'connect_error', options: { message }, type: 'error' };\n } else {\n this.status = { key: 'connect_error_unknown', type: 'error' };\n }\n\n this.__connectState = 'idle';\n }\n }\n\n private __renderConnection() {\n const preset = this.__paymentPresetLoader?.data;\n if (!preset) return html``;\n\n const prefix = preset.is_live ? '' : 'test_';\n const email = this.data?.[`${prefix}account_id` as const];\n const thirdPartyKey = this.data?.[`${prefix}third_party_key` as const] ?? '';\n const type = this.form.type as string;\n const choices = email\n ? [this.__getReconnectChoice(thirdPartyKey)]\n : this.__getConnectChoices(type);\n const isBusy = this.__connectState === 'busy';\n const isReadonly = this.readonlySelector.matches('connection', true);\n const isDisabled = isBusy || this.disabledSelector.matches('connection', true);\n\n return html`\n <foxy-internal-summary-control infer=\"connection\">\n ${email\n ? html`\n <p class=\"font-medium\">\n <foxy-i18n infer=\"\" key=\"status_connected\" .options=${{ email }}></foxy-i18n>\n </p>\n `\n : ''}\n ${(isReadonly ? [] : choices).map(\n choice => html`\n <div class=\"leading-xs\">\n <p class=\"font-medium\">\n <foxy-i18n infer=\"\" key=\"${choice.key}.label\"></foxy-i18n>\n </p>\n <p class=\"text-s text-secondary\">\n <foxy-i18n infer=\"\" key=\"${choice.key}.description\"></foxy-i18n>\n </p>\n </div>\n <div>\n <foxy-internal-button\n data-testid=\"connect-${choice.key}\"\n theme=\"tertiary-inline\"\n ?disabled=${isDisabled}\n @click=${() => this.__connect(choice, type)}\n >\n ${isBusy && this.__connectKey === choice.key\n ? html`<foxy-spinner layout=\"no-label\" infer=\"connect-spinner\"></foxy-spinner>`\n : html`<foxy-i18n infer=\"\" key=\"${choice.key}.button\"></foxy-i18n>`}\n </foxy-internal-button>\n </div>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __renderPaymentMethodConfig() {\n if (this.form.type && connectableGateways.includes(this.form.type)) {\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n ${this.__renderConnection()} ${super.renderBody()}\n `;\n }\n\n const oauthGateways = [\n 'stripe_connect',\n 'stripe_v2',\n 'square_up',\n 'quickbook_payments',\n 'amazon_mws',\n 'paypal_platform',\n ];\n\n if (this.form.type && oauthGateways.includes(this.form.type)) {\n return html`\n <div\n class=\"flex items-start rounded border border-primary\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px); padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p>\n <foxy-i18n infer=\"\" key=\"no_oauth_support_message\"></foxy-i18n>\n <br />\n <a\n target=\"_blank\"\n class=\"mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=\"https://admin.foxycart.com\"\n >\n admin.foxycart.com\n </a>\n </p>\n </div>\n `;\n }\n\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n ${this.form.helper?.supports_auth_only\n ? html`\n <foxy-internal-switch-control infer=\"use-auth-only\" helper-text-as-tooltip>\n </foxy-internal-switch-control>\n `\n : ''}\n ${this.form.helper?.supports_3d_secure\n ? html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"three-d-secure-toggle\"\n .getValue=${this.__threeDSecureToggleGetValue}\n .setValue=${this.__threeDSecureToggleSetValue}\n .options=${this.__threeDSecureToggleOptions}\n >\n </foxy-internal-select-control>\n\n ${this.form.config_3d_secure\n ? html`\n <foxy-internal-switch-control\n layout=\"summary-item\"\n infer=\"three-d-secure-response\"\n .getValue=${this.__threeDSecureResponseGetValue}\n .setValue=${this.__threeDSecureResponseSetValue}\n >\n </foxy-internal-switch-control>\n `\n : ''}\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${['live', 'test'].map((type, index) => {\n // Without stores_read the store never loads, so live credentials show without the\n // inactive store notice.\n const canReadStore = canReadCollection(this.currentUserScope, 'stores');\n const propertyPrefix = index === 0 ? '' : (`${type}_` as '' | 'test_');\n const inferPrefix = index === 0 ? '' : `${type}-`;\n const blocks = index === 0 ? this.__liveBlocks : this.__testBlocks;\n const scope = `${type}-group`;\n const useDefaults = type === 'test' && this.__defaultTestCredentialsGetValue();\n\n if (type === 'live' && canReadStore && !this.__storeLoader?.data) return html``;\n if (type === 'live' && canReadStore && !this.__storeLoader?.data?.is_active) {\n return html`\n <foxy-internal-summary-control infer=\"${type}-group\">\n <div\n class=\"flex items-start\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p><foxy-i18n infer=\"\" key=\"inactive_message\"></foxy-i18n></p>\n </div>\n </foxy-internal-summary-control>\n `;\n }\n\n const showInactiveSetText =\n this.__storeLoader?.data?.is_active === true &&\n ((type === 'test' && this.__paymentPresetLoader?.data?.is_live === true) ||\n (type === 'live' && this.__paymentPresetLoader?.data?.is_live === false));\n\n return html`\n <foxy-internal-summary-control\n helper-text=${ifDefined(\n showInactiveSetText ? this.t(`${scope}.helper_text_inactive`) : void 0\n )}\n layout=\"section\"\n label=${ifDefined(showInactiveSetText ? this.t(`${scope}.label_inactive`) : void 0)}\n infer=${scope}\n >\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${type === 'test' && this.__hasDefaultTestCredentials\n ? html`\n <foxy-internal-switch-control\n infer=\"default-credentials\"\n helper-text-as-tooltip\n .getValue=${this.__defaultTestCredentialsGetValue}\n .setValue=${this.__defaultTestCredentialsSetValue}\n >\n </foxy-internal-switch-control>\n `\n : ''}\n ${this.form.helper?.id_description && !(useDefaults && this.form.helper.test_id)\n ? html`\n <foxy-internal-text-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.id_description}\n infer=\"${inferPrefix}account-id\"\n >\n </foxy-internal-text-control>\n `\n : ''}\n ${this.form.helper?.third_party_key_description &&\n !(useDefaults && this.form.helper.test_third_party_key)\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.third_party_key_description}\n infer=\"${inferPrefix}third-party-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${this.form.helper?.key_description && !(useDefaults && this.form.helper.test_key)\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n helper-text=\"\"\n label=${this.form.helper.key_description}\n infer=\"${inferPrefix}account-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${blocks.map(block =>\n this.__renderBlock(block, useDefaults ? this.__defaultTestFields : [])\n )}\n ${this.form.helper?.supports_card_verification\n ? html`\n <foxy-internal-select-control\n helper-text=${this.t(\n `${scope}.${inferPrefix}card-verification.helper_text_${\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n }`\n )}\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification\"\n .options=${this.__cardVerificationOptions}\n .getValue=${() => {\n return (\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n );\n }}\n >\n </foxy-internal-select-control>\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${this.form.helper?.supports_card_verification &&\n this.form[`${propertyPrefix}card_verification` as const]?.startsWith('enabled_')\n ? html`\n <foxy-internal-summary-control\n layout=\"details\"\n class=\"mt-s\"\n infer=\"${inferPrefix}card-verification-config\"\n >\n ${['visa', 'mastercard', 'american-express', 'discover', 'default'].map(\n type => {\n return html`\n <foxy-internal-number-control\n json-template=${ifDefined(this.form.helper?.card_verification_config)}\n json-path=\"verification_amounts.${type.replace(/-/g, '_')}\"\n property=\"${propertyPrefix}card_verification_config\"\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification-config-verification-amounts-${type}\"\n step=\"0.01\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n `;\n }\n )}\n </foxy-internal-summary-control>\n `\n : ''}\n </foxy-internal-summary-control>\n `;\n })}\n ${super.renderBody()}\n `;\n }\n\n private __renderPaymentMethodButton(\n { type, helper, choice }: PaymentMethod,\n index: number,\n total: number\n ) {\n const defaultSrc = PaymentsApiPaymentMethodForm.defaultImageSrc;\n const src = this.getImageSrc?.(type) ?? defaultSrc;\n const onError = (evt: Event) => ((evt.currentTarget as HTMLImageElement).src = defaultSrc);\n const isBusy = this.__connectState === 'busy';\n const isConnecting = isBusy && !!choice && this.__connectKey === choice.key;\n const hasChoiceLabel = !!choice && choice.key !== 'default';\n\n return html`\n <button\n class=${classMap({\n 'relative w-full block text-left bg-contrast-5 overflow-hidden': true,\n 'focus-outline-none focus-ring-inset focus-ring-2 focus-ring-primary-50': true,\n 'transition-colors hover-bg-contrast-10': !helper.conflict,\n 'cursor-default': !!helper.conflict,\n 'rounded-t': index === 0,\n 'rounded-b': index === total - 1,\n })}\n data-testid=${ifDefined(choice ? `connect-${choice.key}` : undefined)}\n ?disabled=${!!helper.conflict || isBusy}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n @click=${() => (choice ? this.__connect(choice, type) : this.edit({ type, helper }))}\n >\n <figure\n class=\"relative flex items-center\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${isConnecting\n ? html`\n <foxy-spinner\n data-testid=\"connect-spinner\"\n class=\"h-m w-m flex items-center justify-center flex-shrink-0\"\n layout=\"no-label\"\n infer=\"connect-spinner\"\n >\n </foxy-spinner>\n `\n : html`\n <img\n class=${classMap({\n 'h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs':\n true,\n 'filter grayscale': !!helper.conflict,\n })}\n src=${src}\n alt=\"\"\n @error=${onError}\n />\n `}\n <figcaption\n class=${classMap({\n 'min-w-0 flex-1 grid leading-xs': true,\n 'text-disabled': !!helper.conflict,\n })}\n >\n <span class=\"font-medium\">\n ${hasChoiceLabel\n ? this.t(`connection.${choice!.key}.label`)\n : helper.name}​\n </span>\n ${helper.conflict\n ? html`<span class=\"text-xs\"> ${this.t('conflict_message', helper.conflict)}</span>`\n : choice\n ? html`\n <span class=\"text-xs text-secondary\">\n ${hasChoiceLabel ? this.t(`connection.${choice.key}.description`) : ''}\n ${this.t('connection.redirect_notice')}\n </span>\n `\n : ''}\n </figcaption>\n </figure>\n </button>\n `;\n }\n\n private __renderBlock(block: Block, hiddenFields: Block['fields'] = []) {\n return html`${block.fields.map(field => {\n if (field.type === 'hidden' || hiddenFields.includes(field)) return;\n const scope = ['additional-fields', field.id].join('-').replace(/_/g, '-');\n\n const getValue = () => {\n try {\n const config = JSON.parse(this.form.additional_fields ?? '{}');\n return get(config, field.id) ?? config.default_value;\n } catch {\n // Test defaults are filled in explicitly with the default credentials switch.\n return block.is_live ? field.default_value : undefined;\n }\n };\n\n const setValue = (newValue: unknown) => {\n let config: Record<string, unknown> = {};\n\n try {\n config = JSON.parse(this.form.additional_fields ?? '');\n } catch {\n // ignore\n }\n\n this.edit({ additional_fields: JSON.stringify(set(config, field.id, newValue)) });\n };\n\n type Option = { name: string; value: string };\n const options = (field as { options?: Option[] }).options;\n\n return html`\n ${field.type === 'checkbox'\n ? html`\n <foxy-internal-switch-control\n helper-text=${field.description ?? ''}\n label=${field.name}\n infer=${scope}\n helper-text-as-tooltip\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-switch-control>\n `\n : field.type === 'select'\n ? html`\n <foxy-internal-select-control\n placeholder=${this.t('default_additional_field_select_placeholder')}\n helper-text=${field.description ?? ''}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .options=${options!.map(({ name, value }) => ({ label: name, value }))}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-select-control>\n `\n : html`\n <foxy-internal-text-control\n helper-text=${field.description ?? ''}\n placeholder=${this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-text-control>\n `}\n `;\n })}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PaymentsApiPaymentMethodForm.js","sourceRoot":"","sources":["../../../../src/elements/public/PaymentsApiPaymentMethodForm/PaymentsApiPaymentMethodForm.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,qCAAkC;AAC9D,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AAEpD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AAapC,kGAAkG;AAClG,MAAM,mBAAmB,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAEhD,MAAM,EAAE,GAAG,kCAAkC,CAAC;AAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,4BAA6B,SAAQ,IAAU;IAA5D;;QAoDE,oFAAoF;QACpF,kBAAa,GAAkB,IAAI,CAAC;QAEpC,sFAAsF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,CAAC,CAAC,IAAI,CAAA;;8BAEc,MAAA,KAAK,CAAC,WAAW,mCAAI,EAAE;8BACvB,IAAI,CAAC,CAAC,CAAC,sCAAsC,CAAC;;wBAEpD,KAAK,CAAC,IAAI;wBACV,KAAK;4BACD,QAAQ;4BACR,QAAQ;;;aAGvB;OACN,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["import type { AvailablePaymentMethods, PaymentPreset } from '../PaymentsApi/api/types';\nimport type { Block, Data } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonV8N } from '../NucleonElement/types';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { ScopeCollection } from '../../../utils/user-scope';\n\nimport { BooleanSelector, getResourceId } from '@foxy.io/sdk/core';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { canReadCollection } from '../../../utils/user-scope';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html, svg } from 'lit-html';\nimport { classMap } from '../../../utils/class-map';\n\nimport Fuse from 'fuse.js';\nimport has from 'lodash-es/has';\nimport get from 'lodash-es/get';\nimport set from 'lodash-es/set';\nimport unset from 'lodash-es/unset';\n\ntype ConnectChoice = {\n key: string;\n options?: Rels.ConnectGateway['props']['options'];\n};\n\ntype PaymentMethod = {\n helper: AvailablePaymentMethods['values'][string];\n choice?: ConnectChoice;\n type: string;\n};\n\n/** OAuth gateways that connect through fx:connect_gateway. Other OAuth gateways show a notice. */\nconst connectableGateways = ['paypal_platform'];\n\nconst NS = 'payments-api-payment-method-form';\nconst Base = TranslatableMixin(InternalForm, NS);\n\n/**\n * Form element for the `fx:payment_method` resource of Payments API.\n *\n * _Payments API is a client-side virtual API layer built on top of hAPI\n * in an attempt to streamline access to stores' payment method settings\n * that is currently a bit quirky due to the legacy functionality. To use\n * this element with hAPI, wrap it into a foxy-payments-api node._\n *\n * @element foxy-payments-api-payment-method-form\n * @since 1.21.0\n */\nexport class PaymentsApiPaymentMethodForm extends Base<Data> {\n static get defaultImageSrc(): string {\n return \"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 44 44'%3E%3Cpath fill='%23fff' d='m29.3 14 14-14H32.1l-14 14h11.2Zm2.7 9.9 12-12V.7L30.62 14.1A2 2 0 0 1 32 16v7.9ZM13.31 44h11.18L44 24.5V13.3l-12 12V28a2 2 0 0 1-2 2h-2.69l-14 14Zm-1.41 0H.7l14-14h11.2l-14 14Zm14 0h11.2l6.9-6.9V25.9L25.9 44Zm12.6 0H44v-5.5L38.5 44Z'/%3E%3Cpath fill='%23fff' d='M30 28H14v-6h16v6Zm0-10v-2H14v2h16ZM0 43.3l13.4-13.4A2 2 0 0 1 12 28v-7.9L0 32.12V43.3Z'/%3E%3Cpath fill='%23fff' d='M16.7 14H14c-1.11 0-1.99.89-1.99 2v2.7L0 30.7V19.52L19.52 0H30.7l-14 14Zm1.4-14H6.92L0 6.92V18.1L18.1 0ZM5.5 0H0v5.5L5.5 0Z'/%3E%3C/svg%3E\";\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n paymentPreset: { attribute: 'payment-preset' },\n getImageSrc: { attribute: false },\n getConnectRedirectUrl: { attribute: false },\n store: {},\n __search: { attribute: false },\n __connectState: { attribute: false },\n __connectKey: { attribute: false },\n };\n }\n\n static get v8n(): NucleonV8N<Data> {\n return [\n ({ description: v }) => !v || v.length <= 100 || 'description:v8n_too_long',\n ({ type: v }) => !!v || 'type:v8n_required',\n\n form => {\n const blocks = form.helper?.additional_fields?.blocks ?? [];\n let additionalFields: Record<string, unknown>;\n\n try {\n additionalFields = JSON.parse(form.additional_fields ?? '{}');\n } catch {\n additionalFields = {};\n }\n\n for (const block of blocks) {\n for (const field of block.fields) {\n if ('optional' in (field as Record<string, unknown>)) {\n if (!(field as Record<string, unknown>).optional) {\n if (!has(additionalFields, field.id)) {\n if (field.type !== 'checkbox') {\n return 'additional-fields:v8n_invalid';\n }\n }\n }\n }\n }\n }\n\n return true;\n },\n ];\n }\n\n /** URL of the linked `fx:payment_preset` resource from the virtual Payments API. */\n paymentPreset: string | null = null;\n\n /** A function that returns a URL of a payment method icon based on the given type. */\n getImageSrc: ((type: string) => string) | null = null;\n\n /**\n * Returns the URL the gateway sends the merchant back to after a connection.\n * Receives the `payment-preset` URL. The API appends a `status` query parameter.\n * Defaults to the current page URL.\n */\n getConnectRedirectUrl: ((paymentPreset: string) => string) | null = null;\n\n /** URL of the linked `fx:store` resource. */\n store: string | null = null;\n\n private readonly __availablePaymentMethodsLoaderId = 'availablePaymentMethodsLoader';\n\n private readonly __paymentPresetLoaderId = 'paymentPresetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __threeDSecureResponseGetValue = () => {\n return this.form.config_3d_secure?.endsWith('require_valid_response');\n };\n\n private readonly __threeDSecureResponseSetValue = (newValue: boolean) => {\n const postfix = newValue ? '_require_valid_response' : '';\n const config = this.form.config_3d_secure;\n const type = config?.startsWith('all_cards') ? 'all_cards' : 'maestro_only';\n\n this.edit({ config_3d_secure: `${type}${postfix}` as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleGetValue = () => {\n const config = this.form.config_3d_secure;\n\n if (config?.startsWith('all_cards')) return 'all_cards';\n if (config?.startsWith('maestro_only')) return 'maestro_only';\n\n return 'off';\n };\n\n private readonly __threeDSecureToggleSetValue = (\n newValue: 'off' | 'all_cards' | 'maestro_only'\n ) => {\n let newFormValue = '';\n\n if (newValue === 'all_cards' || newValue === 'maestro_only') {\n if (this.form.config_3d_secure?.endsWith('require_valid_response')) {\n newFormValue = `${newValue}_require_valid_response`;\n } else {\n newFormValue = newValue;\n }\n }\n\n this.edit({ config_3d_secure: newFormValue as Data['config_3d_secure'] });\n };\n\n private readonly __threeDSecureToggleOptions = [\n { value: 'off', label: 'option_off' },\n { value: 'all_cards', label: 'option_all_cards' },\n { value: 'maestro_only', label: 'option_maestro_only' },\n ];\n\n private readonly __cardVerificationOptions = [\n { label: 'option_disabled', value: 'disabled' },\n { label: 'option_enabled_automatically', value: 'enabled_automatically' },\n { label: 'option_enabled_override', value: 'enabled_override' },\n ];\n\n /** On when every test credential with a default is set to that default. */\n private readonly __defaultTestCredentialsGetValue = () => {\n const config = this.__additionalFieldsConfig;\n\n return (\n this.__hasDefaultTestCredentials &&\n this.__defaultTestCredentials.every(([key, value]) => this.form[key] === value) &&\n this.__defaultTestFields.every(field => get(config, field.id) === field.default_value)\n );\n };\n\n /** Fills in the defaults when turned on. Clears the same fields when turned off. */\n private readonly __defaultTestCredentialsSetValue = (newValue: boolean) => {\n const config = this.__additionalFieldsConfig;\n const edit: Partial<Data> = {};\n\n this.__defaultTestCredentials.forEach(([key, value]) => (edit[key] = newValue ? value : ''));\n this.__defaultTestFields.forEach(field => {\n if (newValue) set(config, field.id, field.default_value);\n else unset(config, field.id);\n });\n\n if (this.__defaultTestFields.length) edit.additional_fields = JSON.stringify(config);\n this.edit(edit);\n };\n\n private __search = '';\n\n private __connectState: 'idle' | 'busy' = 'idle';\n\n /** Key of the connect choice whose connection URL is being fetched. */\n private __connectKey = '';\n\n get scopeCollection(): ScopeCollection | null {\n return 'payment_settings';\n }\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`header:copy-json ${super.hiddenSelector}`.trimEnd());\n }\n\n renderHeader(...params: Parameters<InternalForm<Data>['renderHeader']>): TemplateResult {\n return html`\n <div>\n ${super.renderHeader(...params)}\n ${this.data?.type || !this.form.type\n ? html``\n : html`\n <foxy-internal-button\n data-testid=\"select-another-button\"\n theme=\"tertiary-inline\"\n @click=${() => this.undo()}\n >\n <foxy-i18n infer=\"\" key=\"select_another_button_label\"></foxy-i18n>\n </foxy-internal-button>\n `}\n </div>\n `;\n }\n\n get headerTitleOptions(): Record<string, unknown> {\n return {\n context: this.form.type ? 'selected' : 'new',\n name: this.form.helper?.name,\n };\n }\n\n get headerSubtitleOptions(): Record<string, unknown> {\n if (this.href) {\n const vId = getResourceId(this.href) as string;\n const id = this.headerCopyIdValue;\n if (vId.startsWith('R')) return { context: 'regular', id };\n return { context: 'hosted', id };\n }\n\n return {};\n }\n\n get headerCopyIdValue(): string | number {\n if (this.href) {\n const id = getResourceId(this.href) as string;\n return id.startsWith('R') ? id.slice(1) : id.slice(1).split('C')[0];\n } else {\n return '';\n }\n }\n\n renderBody(): TemplateResult {\n const paymentPreset = this.__paymentPresetLoader?.data;\n\n const loaders = html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(paymentPreset?._links['fx:available_payment_methods'].href)}\n id=${this.__availablePaymentMethodsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.store)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.paymentPreset)}\n id=${this.__paymentPresetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n `;\n\n return html`${this.renderHeader()}${this.form.type\n ? this.__renderPaymentMethodConfig()\n : this.__renderPaymentMethodSelector()}${loaders}`;\n }\n\n private get __groupedAvailablePaymentMethods() {\n const allMethods = Object.entries(this.__availablePaymentMethods ?? {});\n const filteredMethods = this.__search\n ? new Fuse(allMethods, { keys: ['1.name'], threshold: 0.25 })\n .search(this.__search)\n .map(v => v.item)\n : allMethods;\n\n return filteredMethods\n .sort((a, b) => a[1].name.localeCompare(b[1].name, 'en'))\n .reduce((groups, [type, helper]) => {\n if (helper.is_deprecated) return groups;\n\n const firstChar = helper.name.charAt(0).toUpperCase();\n const isSpecialCharacter = !/\\w/.test(firstChar);\n const name = isSpecialCharacter ? '#' : firstChar;\n const group = groups.find(group => group.name === name);\n\n const items: PaymentMethod[] = connectableGateways.includes(type)\n ? this.__getConnectChoices(type).map(choice => ({ type, helper, choice }))\n : [{ type, helper }];\n\n if (group) {\n group.items.push(...items);\n } else {\n groups.push({ name, items });\n }\n\n return groups;\n }, [] as { name: string; items: PaymentMethod[] }[]);\n }\n\n private get __availablePaymentMethodsLoader() {\n type Loader = NucleonElement<AvailablePaymentMethods>;\n return this.renderRoot.querySelector<Loader>(`#${this.__availablePaymentMethodsLoaderId}`);\n }\n\n private get __availablePaymentMethods() {\n return this.__availablePaymentMethodsLoader?.data?.values;\n }\n\n private get __paymentPresetLoader() {\n type Loader = NucleonElement<PaymentPreset>;\n return this.renderRoot.querySelector<Loader>(`#${this.__paymentPresetLoaderId}`);\n }\n\n private get __storeLoader() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n return this.renderRoot.querySelector<Loader>(`#${this.__storeLoaderId}`);\n }\n\n private get __liveBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => block.is_live) ?? [];\n }\n\n private get __testBlocks() {\n return this.form.helper?.additional_fields?.blocks.filter(block => !block.is_live) ?? [];\n }\n\n /** Top-level test credentials with a non-empty default for the selected gateway. */\n private get __defaultTestCredentials() {\n type Key = 'test_account_id' | 'test_account_key' | 'test_third_party_key';\n const helper = this.form.helper;\n const credentials: [Key, string | undefined][] = [\n ['test_account_id', helper?.test_id],\n ['test_account_key', helper?.test_key],\n ['test_third_party_key', helper?.test_third_party_key],\n ];\n\n return credentials.filter((entry): entry is [Key, string] => !!entry[1]);\n }\n\n /** Visible test additional fields with a non-empty default for the selected gateway. */\n private get __defaultTestFields() {\n return this.__testBlocks\n .flatMap(block => block.fields)\n .filter(field => field.type !== 'hidden' && typeof field.default_value === 'string')\n .filter(field => field.default_value !== '');\n }\n\n private get __hasDefaultTestCredentials() {\n return this.__defaultTestCredentials.length > 0 || this.__defaultTestFields.length > 0;\n }\n\n private get __additionalFieldsConfig(): Record<string, unknown> {\n try {\n return JSON.parse(this.form.additional_fields ?? '') ?? {};\n } catch {\n return {};\n }\n }\n\n private __renderPaymentMethodSelector() {\n const loader = this.__availablePaymentMethodsLoader;\n\n if (!loader?.data) {\n return html`\n <foxy-spinner\n infer=\"list-spinner\"\n state=${loader?.in('fail') ? 'error' : 'busy'}\n error-type=${loader?.accessDenied ? 'access-denied' : 'generic'}\n >\n </foxy-spinner>\n `;\n }\n\n return html`\n <div>\n <input\n placeholder=${this.t('search_placeholder')}\n class=\"w-full leading-m font-medium bg-contrast-5 rounded text-body transition-colors hover-bg-contrast-10 focus-bg-contrast-10 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n style=\"padding: var(--lumo-space-xs) calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n type=\"search\"\n .value=${this.__search}\n @input=${(evt: Event) => {\n this.__search = (evt.currentTarget as HTMLInputElement).value;\n }}\n />\n\n <section data-testid=\"select-method-list\">\n ${this.__groupedAvailablePaymentMethods.map(({ name, items }) => {\n return html`\n <p class=\"font-medium text-tertiary py-m\">${name}</p>\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${items.map((item, index) =>\n this.__renderPaymentMethodButton(item, index, items.length)\n )}\n </foxy-internal-summary-control>\n `;\n })}\n </section>\n </div>\n `;\n }\n\n private __redirect(url: string) {\n window.location.assign(url);\n }\n\n private __getConnectChoices(type: string): ConnectChoice[] {\n if (type === 'paypal_platform') {\n return [\n { key: 'paypal_platform.ppcp', options: { paypal_product_type: 'ppcp' } },\n {\n key: 'paypal_platform.express_checkout',\n options: { paypal_product_type: 'express_checkout' },\n },\n ];\n }\n\n return [{ key: 'default' }];\n }\n\n private __getReconnectChoice(thirdPartyKey: string): ConnectChoice {\n if (this.form.type === 'paypal_platform') {\n // An empty third-party key means the account is connected for PayPal only, without cards.\n const key = thirdPartyKey ? 'reconnect' : 'reconnect_with_cards';\n return { key: `paypal_platform.${key}`, options: { paypal_product_type: 'ppcp' } };\n }\n\n return { key: 'reconnect' };\n }\n\n private async __connect(choice: ConnectChoice, type: string) {\n const presetLink = this.__paymentPresetLoader?.data?._links['fx:connect_gateway'];\n const href = this.data?._links['fx:connect_gateway']?.href ?? presetLink?.href;\n if (!href || !this.paymentPreset || this.__connectState === 'busy') return;\n\n this.__connectState = 'busy';\n this.__connectKey = choice.key;\n this.status = null;\n\n try {\n const body: Rels.ConnectGateway['props'] = {\n type,\n final_redirect: this.getConnectRedirectUrl?.(this.paymentPreset) ?? window.location.href,\n };\n\n if (choice.options) body.options = choice.options;\n\n const response = await this._fetch<{ connection_url: string | null }>(href, {\n method: 'POST',\n body: JSON.stringify(body),\n });\n\n // The API answers 201 with a null URL when the gateway itself fails to create one.\n if (!response.connection_url) throw new Error('No connection_url in the response.');\n\n // State stays busy on purpose: the spinner keeps going until the browser leaves the page.\n this.__redirect(response.connection_url);\n } catch (err) {\n let message = '';\n\n if (err instanceof Response) {\n try {\n const json = await err.json();\n message = json?._embedded?.['fx:errors']?.[0]?.message ?? '';\n } catch {\n // not a vnd.error response\n }\n }\n\n // The API's country error names raw option values ('ppcp', 'express_checkout'), so we\n // replace it with our own text. It's the only 403 our requests can get that mentions 'ppcp'.\n const isPpcpUnsupported =\n err instanceof Response &&\n err.status === 403 &&\n choice.options?.paypal_product_type === 'ppcp' &&\n message.includes(\"'ppcp'\");\n\n if (isPpcpUnsupported) {\n this.status = { key: 'connect_error_ppcp_unsupported', type: 'error' };\n } else if (message) {\n this.status = { key: 'connect_error', options: { message }, type: 'error' };\n } else {\n this.status = { key: 'connect_error_unknown', type: 'error' };\n }\n\n this.__connectState = 'idle';\n }\n }\n\n private __renderConnection() {\n const preset = this.__paymentPresetLoader?.data;\n if (!preset) return html``;\n\n const prefix = preset.is_live ? '' : 'test_';\n const email = this.data?.[`${prefix}account_id` as const];\n const thirdPartyKey = this.data?.[`${prefix}third_party_key` as const] ?? '';\n const type = this.form.type as string;\n const choices = email\n ? [this.__getReconnectChoice(thirdPartyKey)]\n : this.__getConnectChoices(type);\n const isBusy = this.__connectState === 'busy';\n const isReadonly = this.readonlySelector.matches('connection', true);\n const isDisabled = isBusy || this.disabledSelector.matches('connection', true);\n\n return html`\n <foxy-internal-summary-control infer=\"connection\">\n ${email\n ? html`\n <p class=\"font-medium\">\n <foxy-i18n infer=\"\" key=\"status_connected\" .options=${{ email }}></foxy-i18n>\n </p>\n `\n : ''}\n ${(isReadonly ? [] : choices).map(\n choice => html`\n <div class=\"leading-xs\">\n <p class=\"font-medium\">\n <foxy-i18n infer=\"\" key=\"${choice.key}.label\"></foxy-i18n>\n </p>\n <p class=\"text-s text-secondary\">\n <foxy-i18n infer=\"\" key=\"${choice.key}.description\"></foxy-i18n>\n </p>\n </div>\n <div>\n <foxy-internal-button\n data-testid=\"connect-${choice.key}\"\n theme=\"tertiary-inline\"\n ?disabled=${isDisabled}\n @click=${() => this.__connect(choice, type)}\n >\n ${isBusy && this.__connectKey === choice.key\n ? html`<foxy-spinner layout=\"no-label\" infer=\"connect-spinner\"></foxy-spinner>`\n : html`<foxy-i18n infer=\"\" key=\"${choice.key}.button\"></foxy-i18n>`}\n </foxy-internal-button>\n </div>\n `\n )}\n </foxy-internal-summary-control>\n `;\n }\n\n private __renderPaymentMethodConfig() {\n if (this.form.type && connectableGateways.includes(this.form.type)) {\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n </foxy-internal-summary-control>\n\n ${this.__renderConnection()} ${super.renderBody()}\n `;\n }\n\n const oauthGateways = [\n 'stripe_connect',\n 'stripe_v2',\n 'square_up',\n 'quickbook_payments',\n 'amazon_mws',\n 'paypal_platform',\n ];\n\n if (this.form.type && oauthGateways.includes(this.form.type)) {\n return html`\n <div\n class=\"flex items-start rounded border border-primary\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px); padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p>\n <foxy-i18n infer=\"\" key=\"no_oauth_support_message\"></foxy-i18n>\n <br />\n <a\n target=\"_blank\"\n class=\"mt-xs inline-block rounded font-medium text-primary transition-colors cursor-pointer hover-opacity-80 focus-outline-none focus-ring-2 focus-ring-primary-50\"\n href=\"https://admin.foxycart.com\"\n >\n admin.foxycart.com\n </a>\n </p>\n </div>\n `;\n }\n\n return html`\n <foxy-internal-summary-control infer=\"general\">\n <foxy-internal-text-control layout=\"summary-item\" infer=\"description\">\n </foxy-internal-text-control>\n\n ${this.form.helper?.supports_auth_only\n ? html`\n <foxy-internal-switch-control infer=\"use-auth-only\" helper-text-as-tooltip>\n </foxy-internal-switch-control>\n `\n : ''}\n ${this.form.helper?.supports_3d_secure\n ? html`\n <foxy-internal-select-control\n layout=\"summary-item\"\n infer=\"three-d-secure-toggle\"\n .getValue=${this.__threeDSecureToggleGetValue}\n .setValue=${this.__threeDSecureToggleSetValue}\n .options=${this.__threeDSecureToggleOptions}\n >\n </foxy-internal-select-control>\n\n ${this.form.config_3d_secure\n ? html`\n <foxy-internal-switch-control\n layout=\"summary-item\"\n infer=\"three-d-secure-response\"\n .getValue=${this.__threeDSecureResponseGetValue}\n .setValue=${this.__threeDSecureResponseSetValue}\n >\n </foxy-internal-switch-control>\n `\n : ''}\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${['live', 'test'].map((type, index) => {\n // Without stores_read the store never loads, so live credentials show without the\n // inactive store notice.\n const canReadStore = canReadCollection(this.currentUserScope, 'stores');\n const propertyPrefix = index === 0 ? '' : (`${type}_` as '' | 'test_');\n const inferPrefix = index === 0 ? '' : `${type}-`;\n const blocks = index === 0 ? this.__liveBlocks : this.__testBlocks;\n const scope = `${type}-group`;\n const useDefaults = type === 'test' && this.__defaultTestCredentialsGetValue();\n\n if (type === 'live' && canReadStore && !this.__storeLoader?.data) return html``;\n if (type === 'live' && canReadStore && !this.__storeLoader?.data?.is_active) {\n return html`\n <foxy-internal-summary-control infer=\"${type}-group\">\n <div\n class=\"flex items-start\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${svg`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 20 20\" fill=\"currentColor\" aria-hidden=\"true\" class=\"flex-shrink-0 text-primary\" style=\"width: 1.25em\"><path fill-rule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\" clip-rule=\"evenodd\"></path></svg>`}\n <p><foxy-i18n infer=\"\" key=\"inactive_message\"></foxy-i18n></p>\n </div>\n </foxy-internal-summary-control>\n `;\n }\n\n const showInactiveSetText =\n this.__storeLoader?.data?.is_active === true &&\n ((type === 'test' && this.__paymentPresetLoader?.data?.is_live === true) ||\n (type === 'live' && this.__paymentPresetLoader?.data?.is_live === false));\n\n return html`\n <foxy-internal-summary-control\n helper-text=${ifDefined(\n showInactiveSetText ? this.t(`${scope}.helper_text_inactive`) : void 0\n )}\n layout=\"section\"\n label=${ifDefined(showInactiveSetText ? this.t(`${scope}.label_inactive`) : void 0)}\n infer=${scope}\n >\n <foxy-internal-summary-control infer=\"\" label=\"\" helper-text=\"\">\n ${type === 'test' && this.__hasDefaultTestCredentials\n ? html`\n <foxy-internal-switch-control\n infer=\"default-credentials\"\n helper-text-as-tooltip\n .getValue=${this.__defaultTestCredentialsGetValue}\n .setValue=${this.__defaultTestCredentialsSetValue}\n >\n </foxy-internal-switch-control>\n `\n : ''}\n ${this.form.helper?.id_description && !(useDefaults && this.form.helper.test_id)\n ? html`\n <foxy-internal-text-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.id_description}\n infer=\"${inferPrefix}account-id\"\n >\n </foxy-internal-text-control>\n `\n : ''}\n ${this.form.helper?.third_party_key_description &&\n !(useDefaults && this.form.helper.test_third_party_key)\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n helper-text=\"\"\n layout=\"summary-item\"\n label=${this.form.helper.third_party_key_description}\n infer=\"${inferPrefix}third-party-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${this.form.helper?.key_description && !(useDefaults && this.form.helper.test_key)\n ? html`\n <foxy-internal-password-control\n placeholder=${this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n helper-text=\"\"\n label=${this.form.helper.key_description}\n infer=\"${inferPrefix}account-key\"\n >\n </foxy-internal-password-control>\n `\n : ''}\n ${blocks.map(block =>\n this.__renderBlock(block, useDefaults ? this.__defaultTestFields : [])\n )}\n ${this.form.helper?.supports_card_verification\n ? html`\n <foxy-internal-select-control\n helper-text=${this.t(\n `${scope}.${inferPrefix}card-verification.helper_text_${\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n }`\n )}\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification\"\n .options=${this.__cardVerificationOptions}\n .getValue=${() => {\n return (\n this.form[`${propertyPrefix}card_verification` as const] || 'disabled'\n );\n }}\n >\n </foxy-internal-select-control>\n `\n : ''}\n </foxy-internal-summary-control>\n\n ${this.form.helper?.supports_card_verification &&\n this.form[`${propertyPrefix}card_verification` as const]?.startsWith('enabled_')\n ? html`\n <foxy-internal-summary-control\n layout=\"details\"\n class=\"mt-s\"\n infer=\"${inferPrefix}card-verification-config\"\n >\n ${['visa', 'mastercard', 'american-express', 'discover', 'default'].map(\n type => {\n return html`\n <foxy-internal-number-control\n json-template=${ifDefined(this.form.helper?.card_verification_config)}\n json-path=\"verification_amounts.${type.replace(/-/g, '_')}\"\n property=\"${propertyPrefix}card_verification_config\"\n layout=\"summary-item\"\n infer=\"${inferPrefix}card-verification-config-verification-amounts-${type}\"\n step=\"0.01\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n `;\n }\n )}\n </foxy-internal-summary-control>\n `\n : ''}\n </foxy-internal-summary-control>\n `;\n })}\n ${super.renderBody()}\n `;\n }\n\n /** Selects a payment method and prefills card verification with the gateway defaults. */\n private __select(type: string, helper: PaymentMethod['helper']) {\n const edit: Partial<Data> = { type, helper };\n\n if (helper.supports_card_verification) {\n edit.card_verification = edit.test_card_verification = helper.card_verification;\n edit.card_verification_config = edit.test_card_verification_config =\n helper.card_verification_config;\n }\n\n this.edit(edit);\n }\n\n private __renderPaymentMethodButton(\n { type, helper, choice }: PaymentMethod,\n index: number,\n total: number\n ) {\n const defaultSrc = PaymentsApiPaymentMethodForm.defaultImageSrc;\n const src = this.getImageSrc?.(type) ?? defaultSrc;\n const onError = (evt: Event) => ((evt.currentTarget as HTMLImageElement).src = defaultSrc);\n const isBusy = this.__connectState === 'busy';\n const isConnecting = isBusy && !!choice && this.__connectKey === choice.key;\n const hasChoiceLabel = !!choice && choice.key !== 'default';\n\n return html`\n <button\n class=${classMap({\n 'relative w-full block text-left bg-contrast-5 overflow-hidden': true,\n 'focus-outline-none focus-ring-inset focus-ring-2 focus-ring-primary-50': true,\n 'transition-colors hover-bg-contrast-10': !helper.conflict,\n 'cursor-default': !!helper.conflict,\n 'rounded-t': index === 0,\n 'rounded-b': index === total - 1,\n })}\n data-testid=${ifDefined(choice ? `connect-${choice.key}` : undefined)}\n ?disabled=${!!helper.conflict || isBusy}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n @click=${() => (choice ? this.__connect(choice, type) : this.__select(type, helper))}\n >\n <figure\n class=\"relative flex items-center\"\n style=\"gap: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n >\n ${isConnecting\n ? html`\n <foxy-spinner\n data-testid=\"connect-spinner\"\n class=\"h-m w-m flex items-center justify-center flex-shrink-0\"\n layout=\"no-label\"\n infer=\"connect-spinner\"\n >\n </foxy-spinner>\n `\n : html`\n <img\n class=${classMap({\n 'h-m w-m object-cover rounded-full bg-contrast-20 flex-shrink-0 shadow-xs':\n true,\n 'filter grayscale': !!helper.conflict,\n })}\n src=${src}\n alt=\"\"\n @error=${onError}\n />\n `}\n <figcaption\n class=${classMap({\n 'min-w-0 flex-1 grid leading-xs': true,\n 'text-disabled': !!helper.conflict,\n })}\n >\n <span class=\"font-medium\">\n ${hasChoiceLabel\n ? this.t(`connection.${choice!.key}.label`)\n : helper.name}​\n </span>\n ${helper.conflict\n ? html`<span class=\"text-xs\"> ${this.t('conflict_message', helper.conflict)}</span>`\n : choice\n ? html`\n <span class=\"text-xs text-secondary\">\n ${hasChoiceLabel ? this.t(`connection.${choice.key}.description`) : ''}\n ${this.t('connection.redirect_notice')}\n </span>\n `\n : ''}\n </figcaption>\n </figure>\n </button>\n `;\n }\n\n private __renderBlock(block: Block, hiddenFields: Block['fields'] = []) {\n return html`${block.fields.map(field => {\n if (field.type === 'hidden' || hiddenFields.includes(field)) return;\n const scope = ['additional-fields', field.id].join('-').replace(/_/g, '-');\n\n const getValue = () => {\n try {\n const config = JSON.parse(this.form.additional_fields ?? '{}');\n return get(config, field.id) ?? config.default_value;\n } catch {\n // Test defaults are filled in explicitly with the default credentials switch.\n return block.is_live ? field.default_value : undefined;\n }\n };\n\n const setValue = (newValue: unknown) => {\n let config: Record<string, unknown> = {};\n\n try {\n config = JSON.parse(this.form.additional_fields ?? '');\n } catch {\n // ignore\n }\n\n this.edit({ additional_fields: JSON.stringify(set(config, field.id, newValue)) });\n };\n\n type Option = { name: string; value: string };\n const options = (field as { options?: Option[] }).options;\n\n return html`\n ${field.type === 'checkbox'\n ? html`\n <foxy-internal-switch-control\n helper-text=${field.description ?? ''}\n label=${field.name}\n infer=${scope}\n helper-text-as-tooltip\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-switch-control>\n `\n : field.type === 'select'\n ? html`\n <foxy-internal-select-control\n placeholder=${this.t('default_additional_field_select_placeholder')}\n helper-text=${field.description ?? ''}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .options=${options!.map(({ name, value }) => ({ label: name, value }))}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-select-control>\n `\n : html`\n <foxy-internal-text-control\n helper-text=${field.description ?? ''}\n placeholder=${this.t('default_additional_field_placeholder')}\n layout=\"summary-item\"\n label=${field.name}\n infer=${scope}\n .getValue=${getValue}\n .setValue=${setValue}\n >\n </foxy-internal-text-control>\n `}\n `;\n })}`;\n }\n}\n"]}
|