@qonto/embed-sdk 0.38.0 → 0.39.0

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.
@@ -1,6 +1,7 @@
1
1
  import type { CardDataObject, DisplayCardSettings } from './cards.types';
2
2
  import type { OperationSettings } from '@validation/operation-settings-validation';
3
3
  import type { NetworkCallDescriptor } from '@common/network/network';
4
+ import type { EmbedAuthLinkDataObject } from '@auth-links/auth-links.types';
4
5
  interface GetCardsParams {
5
6
  membershipId?: string;
6
7
  accessToken: string;
@@ -11,6 +12,10 @@ interface GetCardParams {
11
12
  accessToken: string;
12
13
  stagingToken?: string;
13
14
  }
15
+ interface PrepareGetCardIframeURLParams {
16
+ accessToken?: string;
17
+ stagingToken?: string;
18
+ }
14
19
  export type GetCardIframeUrlParams = DisplayCardSettings & Pick<OperationSettings, 'accessToken' | 'stagingToken' | 'mfaPreference'>;
15
20
  export declare function prepareGetCardsCall({ membershipId, accessToken, stagingToken, }: {
16
21
  membershipId?: string;
@@ -24,6 +29,7 @@ export declare function prepareGetCardCall({ cardId, accessToken, stagingToken,
24
29
  stagingToken?: string;
25
30
  }): NetworkCallDescriptor;
26
31
  export declare function getCard({ cardId, accessToken, stagingToken, }: GetCardParams): Promise<CardDataObject>;
27
- export declare function getCardIframeURL(getCardIframeUrlParams: GetCardIframeUrlParams): Promise<string>;
32
+ export declare function prepareGetCardIframeUrl({ accessToken, stagingToken, }: PrepareGetCardIframeURLParams): NetworkCallDescriptor;
33
+ export declare function getCardIframeURL(getCardIframeUrlParams: GetCardIframeUrlParams): Promise<EmbedAuthLinkDataObject>;
28
34
  export {};
29
35
  //# sourceMappingURL=cards.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cards.api.d.ts","sourceRoot":"","sources":["../../src/cards/cards.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GACtD,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAiBxB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAY5C;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAYzC;AAED,wBAAsB,gBAAgB,CACpC,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,MAAM,CAAC,CAgCjB"}
1
+ {"version":3,"file":"cards.api.d.ts","sourceRoot":"","sources":["../../src/cards/cards.api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAI5E,UAAU,cAAc;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,6BAA6B;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GACtD,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC,CAAC;AAE5E,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAiBxB;AAED,wBAAsB,QAAQ,CAAC,EAC7B,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAY5C;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,WAAW,EACX,YAAY,GACb,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAYzC;AAED,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,YAAY,GACb,EAAE,6BAA6B,GAAG,qBAAqB,CAMvD;AAED,wBAAsB,gBAAgB,CACpC,sBAAsB,EAAE,sBAAsB,GAC7C,OAAO,CAAC,uBAAuB,CAAC,CAQlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAavB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAMnD;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,QAAQ,CAC5B,cAAc,CAAC,EAAE,UAAU,CAAC;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrD,OAAO,CAAC,IAAI,EAAE,CAAC,CAkCjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAC,EAC5B,YAAY,EACZ,iBAAiB,GAClB,EAAE,UAAU,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAsClC"}
1
+ {"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/cards/cards.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,IAAI,EAET,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAC;AAavB,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,2CAA2C,CAAC;AAQnD;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,QAAQ,CAC5B,cAAc,CAAC,EAAE,UAAU,CAAC;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrD,OAAO,CAAC,IAAI,EAAE,CAAC,CAkCjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAC,EAC5B,YAAY,EACZ,iBAAiB,GAClB,EAAE,UAAU,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAC9B,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,GAC1C,OAAO,CAAC,uBAAuB,CAAC,CAmDlC"}
@@ -1,8 +1,17 @@
1
+ import type { OperationSettings } from '@validation/operation-settings-validation';
1
2
  interface IframeUrlDecorationParams {
3
+ cardId: string;
2
4
  allowPinReveal?: boolean;
3
5
  allowBlocking?: boolean;
4
6
  debugMode?: boolean;
5
7
  }
6
8
  export declare function getPopulatedIframeURL(iframeURL: string, params: IframeUrlDecorationParams): string;
9
+ export declare function createEmbedUI({ decorationParams, operationSettings, cardIframeUrl, }: {
10
+ decorationParams: IframeUrlDecorationParams;
11
+ operationSettings: OperationSettings;
12
+ cardIframeUrl: string;
13
+ }): Promise<{
14
+ destroyEmbedUI: () => void;
15
+ }>;
7
16
  export {};
8
17
  //# sourceMappingURL=cards.helper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cards.helper.d.ts","sourceRoot":"","sources":["../../src/cards/cards.helper.ts"],"names":[],"mappings":"AAGA,UAAU,yBAAyB;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,yBAAyB,GAChC,MAAM,CAiBR"}
1
+ {"version":3,"file":"cards.helper.d.ts","sourceRoot":"","sources":["../../src/cards/cards.helper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAEnF,UAAU,yBAAyB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,yBAAyB,GAChC,MAAM,CAkBR;AAED,wBAAsB,aAAa,CAAC,EAClC,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,GACd,EAAE;IACD,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;CACvB;;GAmBA"}
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class a extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class i extends a{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new i;return n.getAccessToken()}class s extends a{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},m={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},f=3e4,g={ACCEPT:"ACCEPT",REJECT:"REJECT"},p={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"};var T=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},AMOUNT_REQUIRING_ATTACHMENTS:f,AUTH_LINK_ACTIONS:p,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:m,TRANSACTION_STATUSES:{PENDING:"pending",DECLINED:"declined",COMPLETED:"completed"},TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"},VOP_CHECK_RESULTS:{MATCH_RESULT_MATCH:"MATCH_RESULT_MATCH",MATCH_RESULT_NO_MATCH:"MATCH_RESULT_NO_MATCH",MATCH_RESULT_CLOSE_MATCH:"MATCH_RESULT_CLOSE_MATCH",MATCH_RESULT_NOT_POSSIBLE:"MATCH_RESULT_NOT_POSSIBLE",MATCH_RESULT_UNSPECIFIED:"MATCH_RESULT_UNSPECIFIED"},VOP_DECISIONS:g});class h{constructor(){this.mfaPreference=m.PASSKEY,this.debugMode=!1}static getInstance(){return h.instance||(h.instance=new h),h.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=m.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const y=h.getInstance(),_="https://embed.qonto.com",b="https://embed-js{branch}.staging.qonto.co",k="https://embed.dev.qonto.co",I={[d.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:b,IFRAME_URL:`${b}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:k,IFRAME_URL:`${k}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class w{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(t)?t:u.SANDBOX}static getInstance(){return w.instance||(w.instance=new w),w.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return I.production;{const e=I[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=w.getInstance(),A={requiresUI:!1};function S(e,{requiresUI:t}=A){const n=e?.uiParentElementId||y.getUIParentElementId();if(t&&!n)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const a=e?.mfaPreference||y.getMFAPreference();if(a){const e=(i=Object.values(m),E.isProductionEnvironment()?i.filter((e=>e!==m.MOCK)):i);if(!e.includes(a))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(E.isProductionEnvironment()&&a===m.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const r=e?.debugMode||y.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||y.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:n,mfaPreference:a,debugMode:r,proxyRequestFunction:o}}const R=Object.values(l);function L(e){if(!function(e){return R.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${R.join(", ")}.`);return e}function v(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&S(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&L(e.locale),e}class P{constructor(){this.currentLocale="en"}static getInstance(){return P.instance||(P.instance=new P),P.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const D=P.getInstance();const O={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:i,environment:r,branch:s,locale:o}=v(e);t&&n.setAccessToken(t),a&&n.setStagingToken(a),o&&D.setLocale(o),i&&y.setSettings(i),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),D.setDefaultLocale(),y.clearSettings()},constants:T},{initialize:N,logout:U,constants:C}=O;class M extends a{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function q(){return"undefined"!=typeof window&&"undefined"!=typeof document}function $(){return!q()}function F({accessToken:e,stagingToken:t,idempotencyKey:a,mfaPreference:i}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),a&&r.append("X-Qonto-Idempotency-Key",a);const o=i||y.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",D.getLocale()),r}async function B({path:e,options:t}){const n=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,a=await fetch(n,{...t,headers:F(t.headers),body:JSON.stringify(t.body)}),i=await a.json();if(!a.ok)throw i.errors?new M(i.errors.map((e=>`${e.code}: ${e.detail}`))):new M(`${i.code}: ${i.detail}`);return i}function x(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return a=n,$()?Buffer.from(a).toString("base64"):btoa(a);var a}function K(e){return JSON.parse((t=e,$()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function G({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function H({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}var j;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(j||(j={}));const Y={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var z,V;function W(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function J(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function X(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function Q(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(z||(z={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(V||(V={}));const Z=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],ee=[...Z,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function te(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return W(e,Z),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:i,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:l,cardLevel:m}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(m),g=J({membershipId:t,organizationId:n,bankAccountId:a}),p=X({hasDailyLimit:i,hasTransactionLimit:r}),T=Q({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),h=ne(u),y=ae(l),_=[...f,...g,...p,...T,...h,...y];if(_.length>0)throw new s(_)}(e),e}(e):function(e){W(e,ee),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:i,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:l,cardLevel:m,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:T,hasAtmOption:h,hasAtmDailyLimit:y,atmDailyLimit:_,atmMonthlyLimit:b,address:k,cardDesign:I,typeOfPrint:w}=e,E=function(e){return Object.values(V).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(m),A=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),S=J({membershipId:t,organizationId:n,bankAccountId:a}),R=X({hasDailyLimit:i,hasTransactionLimit:r,hasAtmOption:h,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:T}),L=Q({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:b}),v=ne(u),P=ae(l),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(I),O=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(k,T),N=[...E,...S,...R,...L,...v,...P,...A,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function ne(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function ae(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class ie extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const re=[];for(let e=0;e<256;++e)re.push((e+256).toString(16).slice(1));let se;const oe=new Uint8Array(16);var ce={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function de(e,t,n){if(ce.randomUUID&&!e)return ce.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!se){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");se=crypto.getRandomValues.bind(crypto)}return se(oe)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=15&a[6]|64,a[8]=63&a[8]|128,function(e,t=0){return(re[e[t+0]]+re[e[t+1]]+re[e[t+2]]+re[e[t+3]]+"-"+re[e[t+4]]+re[e[t+5]]+"-"+re[e[t+6]]+re[e[t+7]]+"-"+re[e[t+8]]+re[e[t+9]]+"-"+re[e[t+10]]+re[e[t+11]]+re[e[t+12]]+re[e[t+13]]+re[e[t+14]]+re[e[t+15]]).toLowerCase()}(a)}function ue({actionId:e,actionData:t}){const n=y.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||de()}}}class le{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new ie(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",i),t(new ie(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),i=t=>{t.data.eventId===o.READY&&(clearTimeout(a),window.removeEventListener("message",i),e(this))};window.addEventListener("message",i),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new ie("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=ue(e);return new Promise(((e,n)=>{const a=i=>{if(i.data?.actionId===t.actionId){if("error"===i.data.status)return this.removeMessageListener(t.actionId,a),n(new ie(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(i.data.payload)}`));this.removeMessageListener(t.actionId,a),e(i.data.payload)}};this.addMessageListener(t.actionId,a),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function me({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const i=a||!1,r=n||D.getLocale(),s=E.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${i}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function fe({parentElementId:e,iframeUrl:t}){return new le({parentElementId:e,iframeUrl:t}).initialize()}function ge(e){return"virtual"===e.cardLevel?function(e){const t=Te(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:de(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=Te(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:de(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function pe(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function Te(e){const t=Object.values(Y);return(e||[]).filter((e=>t.includes(e)))}const he="--qonto-embed";function ye(e){return!e.href||e.href.startsWith(window.location.origin)}function _e(e){return"CSSStyleRule"===e.constructor.name}function be(e=he){return q()?function(e,t){return[...e].filter(ye).reduce(((e,n)=>[...n.cssRules].filter(_e).reduce(((e,n)=>{if("style"in n){const a=[...n.style].map((e=>[e.trim(),n.style.getPropertyValue(e).trim()])).filter((([e])=>e.startsWith(t))).reduce(((e,[n,a])=>({...e,[n.replace(`${t}-`,"")]:a})),{});return{...e,...a}}return e}),e)),{})}(document.styleSheets,e):{}}const ke={getCards:async function(e){try{const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new s("membershipId must be a string");const{proxyRequestFunction:n,stagingToken:a}=S(e?.operationSettings||{});if(n){const e=x(G({membershipId:t,stagingToken:a})),i=await n(e);return K(i).body.cards.map((e=>pe(e)))}{const n=e?.operationSettings?.accessToken||r(),i=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a=G({membershipId:e,accessToken:t,stagingToken:n}),{cards:i}=await B(a);return i}({membershipId:t,accessToken:n,stagingToken:a});return i.map((e=>pe(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:t}){try{!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId parameter is required for the called function");const t=J({cardId:e.cardId});if(t.length>0)throw new s(t)}(e);const n=e.cardId,{proxyRequestFunction:a,stagingToken:i}=S(t||{});if(a){const e=x(H({cardId:n,stagingToken:i})),t=await a(e),r=K(t).body.cards;if(Array.isArray(r)&&r.length>0)return pe(r[0]);throw new s("Unable to retrieve card data")}{const e=t?.accessToken||r(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const a=H({cardId:e,accessToken:t,stagingToken:n}),{cards:i}=await B(a);return i[0]}({cardId:n,accessToken:e,stagingToken:i});return pe(a)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:a,debugMode:i}=S(e.operationSettings,{requiresUI:!0});te(e.cardSettings);const s=me({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:i}),o=await fe({iframeUrl:s,parentElementId:a}),c=ge(e.cardSettings),d=await o.postMessage(c);return o.destroy(),pe(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:a,debugMode:i}=S(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=J({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=me({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:i}),d=await fe({iframeUrl:o,parentElementId:a}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),l=await d.postMessage(u);return d.destroy(),pe(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:a,debugMode:i,mfaPreference:o}=S(e.operationSettings,{requiresUI:!0}),c=n||r();!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=J({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=X(n);if(a.length>0)throw new s(a)}(e.cardSettings);const d=await async function(e){const{accessToken:t,stagingToken:n,mfaPreference:a}=e,i={method:"GET",headers:F({accessToken:t,stagingToken:n,mfaPreference:a})},r=E.getEnvironmentUrls().THIRD_PARTY_API_URL,s=await fetch(`${r}/v2/cards/${e.cardId}/data_view`,i),o=await s.json();if(!s.ok)throw o.errors?new M(o.errors.map((e=>`${e.code}: ${e.detail}`))):new M(`${o.code}: ${o.detail}`);return o.iframe_url}({...e.cardSettings,accessToken:c,stagingToken:a,mfaPreference:o}),{allowPinReveal:u,allowBlocking:l}=e.cardSettings,m=function(e,t){const n=new URL(e);"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const a=be(he);return Object.keys(a).length>0&&n.searchParams.set("customization",JSON.stringify(a)),n.toString()}(d,{allowPinReveal:u,allowBlocking:l,debugMode:i}),f=await fe({iframeUrl:m,parentElementId:t});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}},Ie=ke;function we(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function Ee({endpointUrl:e,paginationSettings:t}){return function({url:e,searchParams:t}){const n=new URL(e.toString());for(const[e,a]of t.entries())n.searchParams.append(e,a);return n}({url:new URL(e),searchParams:we(t)})}function Ae(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function Se(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function Re(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const Le="/v2/sepa/beneficiaries";function ve({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},i=we(e),r=i.size?`?${i.toString()}`:"";return{path:`${Le}${r}`,options:a}}function Pe({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${Le}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function De({accessToken:e,stagingToken:t,beneficiaryId:n}){const a=Pe({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:i}=await B(a);return i}function Oe({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=de()}){return{path:Le,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:a},body:{beneficiary:Re(e)}}}}function Ne({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${Le}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}function Ue({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${Le}/${e.id}`,options:c}}const Ce=[{name:"name"},{name:"iban"}];const Me={getBeneficiaries:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:i}=S(e?.operationSettings||{});if(n){const e=x(ve({paginationSettings:i})),t=K(await n(e)),a=t.body.beneficiaries.map((e=>Se(e))),r=Ae(t.body.meta);return{beneficiaries:a,...r?{meta:r}:{}}}{const e=a||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a=ve({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:i,meta:r}=await B(a);return{beneficiaries:i,meta:r}}({accessToken:e,stagingToken:t,paginationSettings:i}),s=n.beneficiaries.map((e=>Se(e))),o=Ae(n.meta);return{beneficiaries:s,...o?{meta:o}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:a,accessToken:i,stagingToken:o}=S(t||{});if(a){const e=x(Pe({beneficiaryId:n}));return Se(K(await a(e)).body.beneficiary)}{const e=i||r();return Se(await De({beneficiaryId:n,accessToken:e,stagingToken:o}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");W(e,Ce);const t=J({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t);return e}(e),{proxyRequestFunction:a,accessToken:i,stagingToken:o,idempotencyKey:c}=S(t||{});if(a){const e=x(Oe({beneficiary:n,idempotencyKey:c}));return Se(K(await a(e)).body.beneficiary)}{const e=i||r(),t=await async function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=de()}){const i=Oe({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a}),{beneficiary:r}=await B(i);return r}({beneficiary:n,accessToken:e,stagingToken:o,idempotencyKey:c});return Se(t)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:a,activityTag:i}=e||{};if(!t)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!i)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=J({name:n,email:a,activityTag:i});if(r.length>0)throw new s(r);return{id:t,name:n,email:a,activityTag:i}}(e),{stagingToken:a,idempotencyKey:i,mfaPreference:o,proxyRequestFunction:c}=S(t),d={beneficiaryParamsBeingEdited:n,idempotencyKey:i,mfaPreference:o};if(c){const e=x(Ue(d));return Se(K(await c(e)).body.beneficiary)}{const e=t?.accessToken||r(),n=await async function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i}){const r=Ue({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i}),{beneficiary:s}=await B(r);return s}({...d,accessToken:e,stagingToken:a});return Se(n)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:a,accessToken:i,stagingToken:o}=S(t||{});if(a){const e=x(Ne({beneficiaryIds:n}));return K(await a(e)).body.beneficiaries.map(Se)}{const e=i||r(),t=await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const a=Ne({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:i}=await B(a);return i}({beneficiaryIds:n,accessToken:e,stagingToken:o});return t.map(Se)}}},qe=Me;function $e(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Fe(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}function Be(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function xe(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}function Ke(e){return{name:e.name,iban:e.iban}}const Ge="/v2/sepa",He=`${Ge}/transfers`;function je({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},i=we(e),r=i.size?`?${i.toString()}`:"";return{path:`${He}${r}`,options:a}}function Ye({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${He}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function ze({sepaPayee:e,accessToken:t,stagingToken:n}){const a=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ge}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await B(a)}const Ve="/v2/sepa/bulk_transfers";async function We({sepaPayees:e,accessToken:t,stagingToken:n}){const a=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ge}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Ke)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await B(a)}function Je(e){if(!e)throw new s("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new s("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new s("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new s("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new s(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new s(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new s(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new s(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=J({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),a=Q({amount:e.amount}),i=[...n,...a].flat();if(i.length>0)throw new s(i);if(e.amount>f&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new s(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const Xe="browser",Qe="server";class Ze extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case Xe:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case Qe:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const et=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function tt(e,t){const n=t?.locale||D.getLocale(),a=new URL(e);return n&&a.searchParams.append("lang",n),t?.mfaPreference&&a.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&a.searchParams.append("idempotencyKey",t.idempotencyKey),a.toString()}function nt({accessToken:e,stagingToken:t,action:n,callbackUrl:a}){const i={post_authn_action:n};return a&&(i.callback_url=a),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:i}}}}function at(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}const it={request:async function({requestSettings:e,operationSettings:t}){!function(e){if(!e||"object"!=typeof e)throw new s("requestSettings must be an object");const t=e,{action:n,callbackUrl:a}=e;W(t,[{name:"action"}]);const i=J(t),r=Object.values(p);if(r.includes(n)||i.push(`action must be one of ${r.join(", ")}`),i.length>0)throw new s(i);if(void 0!==a&&""===a.trim())throw new s("callbackUrl cannot be empty")}(e);const{proxyRequestFunction:n,stagingToken:a}=S(t||{});if(n){const t=x(nt({stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}));return at(K(await n(t)).body)}{const n=t?.accessToken||r();return at(await async function(e){const t=nt({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await B(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}({accessToken:n,stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}))}}};const rt={getSepaTransfers:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:i}=S(e?.operationSettings||{});if(n){const e=x(je({paginationSettings:i})),t=K(await n(e)),a=t.body.transfers.map(Be),r=Ae(t.body.meta);return{transfers:a,...r?{meta:r}:{}}}{const e=a||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a=je({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:i,meta:r}=await B(a);return{transfers:i,meta:r}}({accessToken:e,stagingToken:t,paginationSettings:i}),s=n.transfers.map(Be),o=Ae(n.meta);return{transfers:s,...o?{meta:o}:{}}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:i,stagingToken:o}=S(t||{});if(a){const e=x(Ye({sepaTransferId:n}));return Be(K(await a(e)).body.transfer)}{const e=i||r(),t=await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a=Ye({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:i}=await B(a);return i}({sepaTransferId:n,accessToken:e,stagingToken:o});return Be(t)}},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const a=t?.accessToken||r(),i=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||de();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(W(e,et),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...J({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...Q({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>f&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u=await async function({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:Se(await De({beneficiaryId:e?.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}({sepaTransferSettings:e,operationSettings:{accessToken:a,stagingToken:i||void 0}}),l={name:u.name,iban:u.iban},m=await ze({sepaPayee:l,accessToken:a,stagingToken:i||void 0});var p;if((yield(p=m,{matchResult:p.match_result,matchedName:p.matched_name}))===g.REJECT)return;const T={...e,beneficiary:u};if(T.beneficiary?.trusted)d=await async function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:a,idempotencyKey:i}){const r=xe(e),s={method:"POST",headers:F({accessToken:n,stagingToken:a,idempotencyKey:i}),body:JSON.stringify({transfer:r,vop_proof_token:t})},o=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${He}`,c=await fetch(o,s),d=await c.json();if(d.errors)throw new M(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.transfer}({transfer:T,vopProofToken:m.proof_token.token,accessToken:a,stagingToken:i||void 0,idempotencyKey:o});else{if(!q())throw new Ze(Xe);const{uiParentElementId:e,debugMode:n}=S(t,{requiresUI:!0});let r;try{const t=me({accessToken:a,stagingToken:i||void 0,debugMode:n});r=await fe({iframeUrl:t,parentElementId:e});const s=xe(T);d=await r.postMessage(ue({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}}))}finally{r?.destroy()}}return Be(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||r(),a=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a={method:"POST",headers:F({accessToken:t,stagingToken:n})},i=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${He}/${e}/cancel`,r=await fetch(i,a);if(204!==r.status){const e=await r.json();if(e.errors)throw new M(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:a,accessToken:n,stagingToken:t?.stagingToken})},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new s("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new s("callbackUrl must be a string");return e.callbackUrl}(e),{proxyRequestFunction:a,stagingToken:i,accessToken:o}=S(t||{}),c=a?{proxyRequestFunction:a}:{stagingToken:i,accessToken:o||r()},d=await it.request({requestSettings:{action:p.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:c});return{...d,url:tt(d.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:t}=e||{},n=t?.accessToken||r(),{stagingToken:a,paginationSettings:i}=S(t||{}),s=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:F({accessToken:e,stagingToken:t})},i=Ee({endpointUrl:new URL(`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ve}`),paginationSettings:n}),r=await fetch(i,a);if(!r.ok)throw new M("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new M(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:n,stagingToken:a,paginationSettings:i}),o=s.bulkTransfers?.map($e),c=Ae(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||r(),{stagingToken:a}=S(t||{}),i=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return $e(await async function({accessToken:e,stagingToken:t,bulkTransferId:n}){const a={method:"GET",headers:F({accessToken:e,stagingToken:t})},i=new URL(`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${Ve}/${n}`),r=await fetch(i,a),s=await r.json();if(s.errors)throw new M(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:n,stagingToken:a,bulkTransferId:i}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const a=t?.accessToken||r(),i=t?.stagingToken||n.getStagingToken(),s=t?.idempotencyKey||de();Je(e);const{uiParentElementId:o,debugMode:d}=S(t,{requiresUI:!0});if(!q())throw new Ze(Xe);const u=new Map;for(const t of e.bulkTransfers){const e=t.beneficiary.iban;e&&!u.has(e)&&u.set(e,{name:t.beneficiary.name,iban:e})}const l=Array.from(u.values()),m=await We({sepaPayees:l,accessToken:a,stagingToken:i||void 0});if((yield m.requests.map(Fe))===g.REJECT)return;let f,p;try{const t=me({accessToken:a,stagingToken:i||void 0,debugMode:d});p=await fe({iframeUrl:t,parentElementId:o});const n={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};f=await p.postMessage(ue({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:n,idempotencyKey:s}}))}finally{p?.destroy()}return $e(f)}}},st={GOOD:"good",SERVICE:"service"},ot={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},ct=e=>{if(!(e=>Object.values(ot).includes(e))(e))throw new s(`currency ${e} is not valid, valid currencies are ${Object.values(ot).join(", ")}`)},dt={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},ut=e=>{if(!(e=>Object.values(dt).includes(e))(e))throw new s(`unit ${e} is not valid, valid units are ${Object.values(dt).join(", ")}`)},lt=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],mt=[{name:"currency"},{name:"value"}];const ft=e=>{if(!Object.values(st).includes(e))throw new s(`type ${e} is not valid, valid types are ${Object.values(st).join(", ")}`)},gt={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e})=>{const{items:t,authUrl:n}=e;!function(e){if(!e)throw new s("authUrl is required for the called function");const t=J({authUrl:e});if(t.length>0)throw new s(t);try{new URL(e)}catch{throw new s("authUrl is not a valid URL")}}(n),function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{W(e,lt),W(e.unitPrice,mt);const t=[...J({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...Q({quantity:e.quantity})].flat();if(t.length>0)throw new s(t);ft(e.type),ct(e.unitPrice.currency),ut(e.measureUnit)}))}(t);const a=new URLSearchParams({...t?{items:JSON.stringify(t)}:{}});return a.toString()?`${n}?${a.toString()}`:n}},pt=({accessToken:e,stagingToken:t})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}),Tt=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),ht={getBankAccounts:async e=>{const{stagingToken:t,proxyRequestFunction:n}=S(e);if(n){const e=pt({stagingToken:t}),a=await n(x(e)),{body:i}=K(a);return i.bank_accounts.map(Tt)}{const n=e.accessToken||r(),a=await(async({accessToken:e,stagingToken:t})=>{const n=pt({accessToken:e,stagingToken:t});return await B(n)})({accessToken:n,stagingToken:t});return a.bank_accounts.map(Tt)}}},yt="/v2/transactions";function _t({bankAccountId:e,iban:t,status:n,updatedAtFrom:a,updatedAtTo:i,emittedAtFrom:r,emittedAtTo:s,settledAtFrom:o,settledAtTo:c,side:d,operationType:u,withAttachments:l,paginationSettings:m,accessToken:f,stagingToken:g}){const p={method:"GET",headers:{accessToken:f,stagingToken:g}},T=new URLSearchParams;e&&T.append("bank_account_id",e),t&&T.append("iban",t),n&&T.append("status",n),a&&T.append("updated_at_from",a),i&&T.append("updated_at_to",i),r&&T.append("emitted_at_from",r),s&&T.append("emitted_at_to",s),o&&T.append("settled_at_from",o),c&&T.append("settled_at_to",c),d&&T.append("side",d),u&&T.append("operation_type",u),void 0!==l&&T.append("with_attachments",String(l));const h=we(m);for(const[e,t]of h)T.append(e,t);const y=T.toString();return{path:`${yt}${y?`?${y}`:""}`,options:p}}function bt({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${yt}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function kt(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const It={getTransactions:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:i}=S(e?.operationSettings||{}),s={...e?.transactionSettings||{},paginationSettings:i};if(n){const e=x(_t(s)),t=K(await n(e));return{transactions:t.body.transactions.map(kt),meta:t.body.meta}}{const e=a||r(),n=await async function(e){const t=_t(e),{transactions:n,meta:a}=await B(t);return{transactions:n,meta:a}}({...s,accessToken:e,stagingToken:t});return{transactions:n.transactions.map(kt),meta:n.meta}}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{proxyRequestFunction:n,accessToken:a,stagingToken:i}=S(t||{}),{transactionId:o}=function(e){if(!e)throw new s("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new s("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new s("transactionSettings.transactionId must be a string.");return e}(e);if(n){const e=x(bt({transactionId:o}));return kt(K(await n(e)).body.transaction)}{const e=a||r();return kt(await async function(e){const t=bt(e),{transaction:n}=await B(t);return n}({transactionId:o,accessToken:e,stagingToken:i}))}}},wt=It;e.authLinks=it,e.beneficiaries=qe,e.cards=Ie,e.constants=C,e.initialize=N,e.logout=U,e.organizations=ht,e.paymentLinks=gt,e.sepaTransfers=rt,e.transactions=wt}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbed={})}(this,(function(e){"use strict";class t{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return t.instance||(t.instance=new t),t.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const n=t.getInstance();class a extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class i extends a{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid access token.\nEnsure you have called the initialize function with a valid access token."}}function r(){if(!n.hasAccessToken())throw new i;return n.getAccessToken()}class s extends a{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}const o={READY:"qonto.ready"},c={CARD_SEE:"card.see",CARD_SEE_DETAILS:"card.see-details",CARD_ORDER:"card.order",CARD_UNLOCK:"card.unlock",CARD_SHOW_PIN:"card.show.pin",CARD_SET_PIN:"card.set.pin",TRANSFER_SINGLE_CREATE:"transfer.single.create",TRANSFER_BULK_CREATE:"transfer.bulk.create",BENEFICIARIES_TRUST:"beneficiary.trust"},d={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={EN:"en",FR:"fr",DE:"de",ES:"es",IT:"it",PT:"pt"},m={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},f=3e4,g={ACCEPT:"ACCEPT",REJECT:"REJECT"},p={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"};var T=Object.freeze({__proto__:null,ACTIONS:c,ACTIVITY_TAGS:{ATM:"atm",FALLBACK:"fallback",FEES:"fees",FINANCE:"finance",FOOD_AND_GROCERY:"food_and_grocery",GAS_STATION:"gas_station",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",HOTEL_AND_LODGING:"hotel_and_lodging",INSURANCE:"insurance",IT_AND_ELECTRONICS:"it_and_electronics",LEGAL_AND_ACCOUNTING:"legal_and_accounting",LOGISTICS:"logistics",MANUFACTURING:"manufacturing",MARKETING:"marketing",OFFICE_RENTAL:"office_rental",OFFICE_SUPPLY:"office_supply",ONLINE_SERVICE:"online_service",OTHER_EXPENSE:"other_expense",OTHER_INCOME:"other_income",OTHER_SERVICE:"other_service",PENDING:"pending",REFUND:"refund",RESTAURANT_AND_BAR:"restaurant_and_bar",SALES:"sales",SALARY:"salary",SUBSCRIPTION:"subscription",TAX:"tax",TRANSPORT:"transport",TREASURY_AND_INTERCO:"treasury_and_interco",UTILITY:"utility",VOUCHER:"voucher"},AMOUNT_REQUIRING_ATTACHMENTS:f,AUTH_LINK_ACTIONS:p,BENEFICIARY_STATUSES:{PENDING:"pending",VALIDATED:"validated",DECLINED:"declined"},BRANCHES:u,ENVIRONMENTS:d,IFRAME_EVENTS:o,LOCALES:l,MFA_METHODS:m,TRANSACTION_STATUSES:{PENDING:"pending",DECLINED:"declined",COMPLETED:"completed"},TRANSFER_DECLINE_REASONS:{BENEFICIARY_BIC_INVALID:"beneficiary_bic_invalid",BENEFICIARY_IBAN_INVALID:"beneficiary_iban_invalid",BENEFICIARY_STATUS:"beneficiary_status",BENEFICIARY_NETWORK_RULES_ERROR:"beneficiary_network_rules_error",ORGANISATION_COMPLIANCE_REASONS:"organisation_compliance_reasons",DEBIT_ACCOUNT_INSUFFICIENT_FUNDS:"debit_account_insufficient_funds",QONTO_PROCESSING_FAILED:"qonto_processing_failed"},TRANSFER_STATUSES:{PENDING:"pending",PROCESSING:"processing",CANCELED:"canceled",DECLINED:"declined",SETTLED:"settled",FAILED:"failed",COMPLETED:"completed"},VOP_CHECK_RESULTS:{MATCH_RESULT_MATCH:"MATCH_RESULT_MATCH",MATCH_RESULT_NO_MATCH:"MATCH_RESULT_NO_MATCH",MATCH_RESULT_CLOSE_MATCH:"MATCH_RESULT_CLOSE_MATCH",MATCH_RESULT_NOT_POSSIBLE:"MATCH_RESULT_NOT_POSSIBLE",MATCH_RESULT_UNSPECIFIED:"MATCH_RESULT_UNSPECIFIED"},VOP_DECISIONS:g});class h{constructor(){this.mfaPreference=m.PASSKEY,this.debugMode=!1}static getInstance(){return h.instance||(h.instance=new h),h.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=m.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0}}const y=h.getInstance(),_="https://embed.qonto.com",b="https://embed-js{branch}.staging.qonto.co",k="https://embed.dev.qonto.co",I={[d.PRODUCTION]:{IFRAME_BASE_URL:_,IFRAME_URL:`${_}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[d.STAGING]:{IFRAME_BASE_URL:b,IFRAME_URL:`${b}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[d.LOCAL]:{IFRAME_BASE_URL:k,IFRAME_URL:`${k}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class w{constructor(){this.environment=d.PRODUCTION,this.branch=u.SANDBOX;const e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH;this.environment=Object.values(d).includes(e)?e:d.PRODUCTION,this.branch=Object.values(u).includes(t)?t:u.SANDBOX}static getInstance(){return w.instance||(w.instance=new w),w.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===d.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=d.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===d.PRODUCTION)return I.production;{const e=I[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const E=w.getInstance(),A={requiresUI:!1};function S(e,{requiresUI:t}=A){const n=e?.uiParentElementId||y.getUIParentElementId();if(t&&!n)throw new s("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");const a=e?.mfaPreference||y.getMFAPreference();if(a){const e=(i=Object.values(m),E.isProductionEnvironment()?i.filter((e=>e!==m.MOCK)):i);if(!e.includes(a))throw new s(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(E.isProductionEnvironment()&&a===m.MOCK)throw new s("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const r=e?.debugMode||y.getDebugMode();if(void 0!==r&&"boolean"!=typeof r)throw new s("operationSettings.debugMode must be a boolean.");const o=e?.proxyRequestFunction||y.getProxyRequestFunction();if(o&&"function"!=typeof o)throw new s("operationSettings.proxyRequestFunction must be a function.");return{...e,uiParentElementId:n,mfaPreference:a,debugMode:r,proxyRequestFunction:o}}const R=Object.values(l);function L(e){if(!function(e){return R.includes(e)}(e))throw new s(`Unsupported locale: ${e}. The locale must be one of: ${R.join(", ")}.`);return e}function P(e){if(!e?.accessToken&&!e?.operationSettings?.proxyRequestFunction)throw new s("Either operationSettings.proxyRequestFunction or access token is required when calling initialize()");return e?.operationSettings&&S(e.operationSettings),function(e){if(e.environment){if(!["production","staging","local"].includes(e.environment))throw new s('If provided, environment must be either "production" or "staging"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.environment.PRODUCTION" or "constants.environment.STAGING"');if(e.branch&&!["master","sandbox","qa"].includes(e.branch))throw new s('If provided, branch must be either "master", "sandbox" or "qa"\nYou can "import constants from @qonto/embed-sdk/common" and then use "constants.branch.MASTER" or "constants.environment.SANDBOX" and so on')}}(e),e.locale&&L(e.locale),e}class v{constructor(){this.currentLocale="en"}static getInstance(){return v.instance||(v.instance=new v),v.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const D=v.getInstance();const O={initialize:function(e){const{accessToken:t,stagingToken:a,operationSettings:i,environment:r,branch:s,locale:o}=P(e);t&&n.setAccessToken(t),a&&n.setStagingToken(a),o&&D.setLocale(o),i&&y.setSettings(i),r&&(E.setEnvironment(r),s&&E.setBranch(s))},logout:function(){n.clearAccessToken(),n.clearStagingToken(),D.setDefaultLocale(),y.clearSettings()},constants:T},{initialize:N,logout:U,constants:C}=O;class M extends a{constructor(e){super();const t=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${t}`}}function q(){return"undefined"!=typeof window&&"undefined"!=typeof document}function F(){return!q()}function $({accessToken:e,stagingToken:t,idempotencyKey:a,mfaPreference:i}){const r=new Headers;r.append("Authorization",`Bearer ${e}`);const s=t||n.getStagingToken();s&&r.append("X-Qonto-Staging-Token",s),a&&r.append("X-Qonto-Idempotency-Key",a);const o=i||y.getMFAPreference();return o&&r.append("X-Qonto-2fa-Preference",o),r.append("Content-Type","application/json"),r.append("Accept-Language",D.getLocale()),r}async function B({path:e,options:t}){const n=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,a=await fetch(n,{...t,headers:$(t.headers),body:JSON.stringify(t.body)}),i=await a.json();if(!a.ok)throw i.errors?new M(i.errors.map((e=>`${e.code}: ${e.detail}`))):new M(`${i.code}: ${i.detail}`);return i}function x(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return a=n,F()?Buffer.from(a).toString("base64"):btoa(a);var a}function K(e){return JSON.parse((t=e,F()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function G({accessToken:e,stagingToken:t,action:n,callbackUrl:a}){const i={post_authn_action:n};return a&&(i.callback_url=a),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:i}}}}function H({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function j({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function Y({accessToken:e,stagingToken:t}){return G({accessToken:e,stagingToken:t,action:p.CARD_DISPLAY})}var z;!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(z||(z={}));const V={TRANSPORT:"transport",RESTAURANT_AND_BAR:"restaurant_and_bar",FOOD_AND_GROCERY:"food_and_grocery",IT_AND_ELECTRONICS:"it_and_electronics",UTILITY:"utility",TAX:"tax",LEGAL_AND_ACCOUNTING:"legal_and_accounting",ATM:"atm",OFFICE_SUPPLY:"office_supply",HARDWARE_AND_EQUIPMENT:"hardware_and_equipment",FINANCE:"finance"};var W,J;function X(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new s(n.map((e=>`Missing required parameter: ${e}`)))}function Q(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function Z(e){return Object.entries(e).filter((([,e])=>void 0!==e&&!1!==e&&!0!==e)).map((([e])=>`${e} must be a boolean`))}function ee(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}!function(e){e.VIRTUAL="virtual"}(W||(W={})),function(e){e.METAL="metal",e.PLUS="plus",e.STANDARD="standard"}(J||(J={}));const te=[{name:"organizationId"},{name:"membershipId"},{name:"bankAccountId"},{name:"monthlyLimit"},{name:"cardLevel"}],ne=[...te,{name:"atmDailyLimit",requiredIfPresent:"hasAtmDailyLimit"},{name:"hasAtmDailyLimit",requiredIfPresent:"hasAtmOption"},{name:"atmMonthlyLimit",requiredIfPresent:"hasAtmOption"},{name:"shipToBusiness"},{name:"cardLevel"}];function ae(e){if(!e)throw new s("cardSettings parameter is required for the called function");return"virtual"===e.cardLevel?function(e){return X(e,te),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:i,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:l,cardLevel:m}=e,f=function(e){return"virtual"!==e?['cardLevel must be "virtual"']:[]}(m),g=Q({membershipId:t,organizationId:n,bankAccountId:a}),p=Z({hasDailyLimit:i,hasTransactionLimit:r}),T=ee({monthlyLimit:o,dailyLimit:c,transactionLimit:d}),h=ie(u),y=re(l),_=[...f,...g,...p,...T,...h,...y];if(_.length>0)throw new s(_)}(e),e}(e):function(e){X(e,ne),function(e){const{membershipId:t,organizationId:n,bankAccountId:a,hasDailyLimit:i,hasTransactionLimit:r,monthlyLimit:o,dailyLimit:c,transactionLimit:d,activeDays:u,categories:l,cardLevel:m,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,shipToBusiness:T,hasAtmOption:h,hasAtmDailyLimit:y,atmDailyLimit:_,atmMonthlyLimit:b,address:k,cardDesign:I,typeOfPrint:w}=e,E=function(e){return Object.values(J).includes(e)?[]:['cardLevel must be one of "standard", "plus", "metal"']}(m),A=function(e){const t=null!=e&&"string"!=typeof e,n=!["print","embossed",void 0,null].includes(e);return t||n?['typeOfPrint must be one of "print", "embossed" or null']:[]}(w),S=Q({membershipId:t,organizationId:n,bankAccountId:a}),R=Z({hasDailyLimit:i,hasTransactionLimit:r,hasAtmOption:h,hasNfcOption:f,hasForeignPaymentOption:g,hasOnlinePaymentOption:p,hasAtmDailyLimit:y,shipToBusiness:T}),L=ee({monthlyLimit:o,dailyLimit:c,transactionLimit:d,atmDailyLimit:_,atmMonthlyLimit:b}),P=ie(u),v=re(l),D=function(e){return["undefined","string"].includes(typeof e)?[]:["cardDesign must be a string"]}(I),O=function(e,t){if(t)return[];return!e||e.contactName&&e.firstLine&&e.zipCode&&e.city&&e.country?[]:["address must contain at least contactName, firstLine, zipCode, city and country properties"]}(k,T),N=[...E,...S,...R,...L,...P,...v,...A,...D,...O];if(N.length>0)throw new s(N)}(e)}(e)}function ie(e){const t=!Array.isArray(e)||!e.every((e=>Number.isInteger(e)&&e>0&&e<8));return void 0!==e&&t?["activeDays must be an array of integers between 1 and 7"]:[]}function re(e){const t=!Array.isArray(e)||e.some((e=>"string"!=typeof e));return void 0!==e&&t?["categories must be an array of strings"]:[]}class se extends a{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}const oe=[];for(let e=0;e<256;++e)oe.push((e+256).toString(16).slice(1));let ce;const de=new Uint8Array(16);var ue={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function le(e,t,n){if(ue.randomUUID&&!e)return ue.randomUUID();const a=(e=e||{}).random??e.rng?.()??function(){if(!ce){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ce=crypto.getRandomValues.bind(crypto)}return ce(de)}();if(a.length<16)throw new Error("Random bytes length must be >= 16");return a[6]=15&a[6]|64,a[8]=63&a[8]|128,function(e,t=0){return(oe[e[t+0]]+oe[e[t+1]]+oe[e[t+2]]+oe[e[t+3]]+"-"+oe[e[t+4]]+oe[e[t+5]]+"-"+oe[e[t+6]]+oe[e[t+7]]+"-"+oe[e[t+8]]+oe[e[t+9]]+"-"+oe[e[t+10]]+oe[e[t+11]]+oe[e[t+12]]+oe[e[t+13]]+oe[e[t+14]]+oe[e[t+15]]).toLowerCase()}(a)}function me({actionId:e,actionData:t}){const n=y.getMFAPreference();return{actionId:e,actionData:{...t,scaPreference:t.scaPreference||n,idempotencyKey:t.idempotencyKey||le()}}}class fe{constructor(e){this.options=e,this.iframe=null,this.parentElement=null,this.messageListeners=new Map,this.defaultTimeout=3e4;const t=new URL(e.iframeUrl);this.targetOrigin=`${t.protocol}//${t.host}`}async initialize(){if(this.iframe)return this;if(this.parentElement=document.getElementById(this.options.parentElementId),!this.parentElement)throw new se(`Could not install the authentication UI because the parent element with id ${this.options.parentElementId} was not found.\nPlease make sure to pass a valid parentElementId when calling the method.`);return new Promise(((e,t)=>{this.iframe=document.createElement("iframe"),this.iframe.src=this.options.iframeUrl,this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.style.border="none";const n=this.options.timeout||this.defaultTimeout,a=setTimeout((()=>{window.removeEventListener("message",i),t(new se(`Could not install the authentication UI because the timeout of ${n}ms was reached.\nPlease make sure the application can reach the Internet.`))}),n),i=t=>{t.data.eventId===o.READY&&(clearTimeout(a),window.removeEventListener("message",i),e(this))};window.addEventListener("message",i),this.parentElement?.appendChild(this.iframe)}))}postMessage(e){if(!this.iframe||!this.iframe.contentWindow)return Promise.reject(new se("Attempted to perform an Embed operation without having the authentication UI initialized."));const t=me(e);return new Promise(((e,n)=>{const a=i=>{if(i.data?.actionId===t.actionId){if("error"===i.data.status)return this.removeMessageListener(t.actionId,a),n(new se(`An error occurred when performing the action ${t.actionId}.\n${JSON.stringify(i.data.payload)}`));this.removeMessageListener(t.actionId,a),e(i.data.payload)}};this.addMessageListener(t.actionId,a),this.iframe?.contentWindow?.postMessage(t,this.targetOrigin)}))}addMessageListener(e,t){this.messageListeners.has(e)||this.messageListeners.set(e,[]);this.messageListeners.get(e).push(t),window.addEventListener("message",t)}removeMessageListener(e,t){const n=this.messageListeners.get(e);if(n){const e=n.indexOf(t);-1!==e&&(n.splice(e,1),window.removeEventListener("message",t))}}destroy(){this.messageListeners.forEach((e=>{e.forEach((e=>{window.removeEventListener("message",e)}))})),this.messageListeners.clear(),this.iframe&&this.parentElement&&(this.parentElement.removeChild(this.iframe),this.iframe=null)}}function ge({accessToken:e,stagingToken:t,locale:n,debugMode:a}){const i=a||!1,r=n||D.getLocale(),s=E.getEnvironmentUrls().IFRAME_URL,o=t?`;staging_token=${encodeURIComponent(t)}`:"";return`${s}?debug=${i}&lang=${encodeURIComponent(r)}#access_token=${encodeURIComponent(e)}${o}`}function pe({parentElementId:e,iframeUrl:t}){return new fe({parentElementId:e,iframeUrl:t}).initialize()}function Te(e){return"virtual"===e.cardLevel?function(e){const t=ye(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:le(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel}}}}}(e):function(e){const t=ye(e.categories);return{actionId:c.CARD_ORDER,actionData:{idempotencyKey:le(),body:{card:{payment_monthly_limit:e.monthlyLimit,payment_daily_limit:e.dailyLimit,payment_daily_limit_option:e.hasDailyLimit,payment_transaction_limit:e.transactionLimit,payment_transaction_limit_option:e.hasTransactionLimit,active_days:e.activeDays||[],holder_id:e.membershipId,organization_id:e.organizationId,bank_account_id:e.bankAccountId,categories:t,card_level:e.cardLevel,card_design:e.cardDesign,..."plus"===e.cardLevel&&{type_of_print:e.typeOfPrint},ship_to_business_address:e.shipToBusiness,atm_option:e.hasAtmOption,nfc_option:e.hasNfcOption,foreign_option:e.hasForeignPaymentOption,online_option:e.hasOnlinePaymentOption,atm_daily_limit:e.atmDailyLimit,atm_monthly_limit:e.atmMonthlyLimit,...!e.shipToBusiness&&{address:{contact_name:e.address?.contactName,first_line:e.address?.firstLine,second_line:e.address?.secondLine,third_line:e.address?.thirdLine,zipcode:e.address?.zipCode,city:e.address?.city,country:e.address?.country}}}}}}}(e)}function he(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}function ye(e){const t=Object.values(V);return(e||[]).filter((e=>t.includes(e)))}const _e="--qonto-embed";function be(e){return!e.href||e.href.startsWith(window.location.origin)}function ke(e){return"CSSStyleRule"===e.constructor.name}function Ie(e=_e){return q()?function(e,t){return[...e].filter(be).reduce(((e,n)=>[...n.cssRules].filter(ke).reduce(((e,n)=>{if("style"in n){const a=[...n.style].map((e=>[e.trim(),n.style.getPropertyValue(e).trim()])).filter((([e])=>e.startsWith(t))).reduce(((e,[n,a])=>({...e,[n.replace(`${t}-`,"")]:a})),{});return{...e,...a}}return e}),e)),{})}(document.styleSheets,e):{}}async function we({decorationParams:e,operationSettings:t,cardIframeUrl:n}){const{cardId:a,allowPinReveal:i,allowBlocking:r}=e,{uiParentElementId:s,debugMode:o}=t,c=function(e,t){const n=new URL(e);n.searchParams.set("cardId",t.cardId),"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const a=Ie(_e);return Object.keys(a).length>0&&n.searchParams.set("customization",JSON.stringify(a)),n.toString()}(n,{cardId:a,allowPinReveal:i,allowBlocking:r,debugMode:o}),d=await pe({iframeUrl:c,parentElementId:s});return{destroyEmbedUI:()=>{d.destroy()}}}const Ee={getCards:async function(e){try{const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new s("membershipId must be a string");const{proxyRequestFunction:n,stagingToken:a}=S(e?.operationSettings||{});if(n){const e=x(H({membershipId:t,stagingToken:a})),i=await n(e);return K(i).body.cards.map((e=>he(e)))}{const n=e?.operationSettings?.accessToken||r(),i=await async function({membershipId:e,accessToken:t,stagingToken:n}){const a=H({membershipId:e,accessToken:t,stagingToken:n}),{cards:i}=await B(a);return i}({membershipId:t,accessToken:n,stagingToken:a});return i.map((e=>he(e)))}}catch(e){return Promise.reject(e)}},getCard:async function({cardSettings:e,operationSettings:t}){try{!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId parameter is required for the called function");const t=Q({cardId:e.cardId});if(t.length>0)throw new s(t)}(e);const n=e.cardId,{proxyRequestFunction:a,stagingToken:i}=S(t||{});if(a){const e=x(j({cardId:n,stagingToken:i})),t=await a(e),r=K(t).body.cards;if(Array.isArray(r)&&r.length>0)return he(r[0]);throw new s("Unable to retrieve card data")}{const e=t?.accessToken||r(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const a=j({cardId:e,accessToken:t,stagingToken:n}),{cards:i}=await B(a);return i[0]}({cardId:n,accessToken:e,stagingToken:i});return he(a)}}catch(e){return Promise.reject(e)}},orderCard:async function(e){try{const t=r(),{uiParentElementId:a,debugMode:i}=S(e.operationSettings,{requiresUI:!0});ae(e.cardSettings);const s=ge({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:i}),o=await pe({iframeUrl:s,parentElementId:a}),c=Te(e.cardSettings),d=await o.postMessage(c);return o.destroy(),he(d)}catch(e){return Promise.reject(e)}},unlockCard:async function(e){try{const t=r(),{uiParentElementId:a,debugMode:i}=S(e.operationSettings,{requiresUI:!0});!function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=Q({cardId:e.cardId});if(t.length>0)throw new s(t)}(e.cardSettings);const o=ge({accessToken:t,stagingToken:n.getStagingToken()||void 0,debugMode:i}),d=await pe({iframeUrl:o,parentElementId:a}),u=function(e){return{actionId:c.CARD_UNLOCK,actionData:{body:{cardId:e.cardSettings.cardId}}}}(e),l=await d.postMessage(u);return d.destroy(),he(l)}catch(e){return Promise.reject(e)}},displayCard:async function(e){try{const{uiParentElementId:t,accessToken:n,stagingToken:a,debugMode:i,mfaPreference:o,proxyRequestFunction:c}=S(e.operationSettings,{requiresUI:!0});if(function(e){if(!e)throw new s("cardSettings parameter is required for the called function");if(!e.cardId)throw new s("cardId is required for the called function");const t=Q({cardId:e.cardId});if(t.length>0)throw new s(t);let n={};void 0!==e.allowPinReveal&&(n={allowPinReveal:e.allowPinReveal}),void 0!==e.allowBlocking&&(n={...n,allowBlocking:e.allowBlocking});const a=Z(n);if(a.length>0)throw new s(a)}(e.cardSettings),c){const n=x(Y({stagingToken:a})),r=await c(n),s=K(r).body;return we({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:i},cardIframeUrl:s.url})}{const s=n||r(),c=await async function(e){const t=Y(e),{embed_auth_link:n}=await B(t);return n}({...e.cardSettings,accessToken:s,stagingToken:a});return we({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:t,debugMode:i,mfaPreference:o},cardIframeUrl:c.url})}}catch(e){return Promise.reject(e)}}},Ae=Ee;function Se(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function Re({endpointUrl:e,paginationSettings:t}){return function({url:e,searchParams:t}){const n=new URL(e.toString());for(const[e,a]of t.entries())n.searchParams.append(e,a);return n}({url:new URL(e),searchParams:Se(t)})}function Le(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}function Pe(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function ve(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const De="/v2/sepa/beneficiaries";function Oe({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},i=Se(e),r=i.size?`?${i.toString()}`:"";return{path:`${De}${r}`,options:a}}function Ne({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${De}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Ue({accessToken:e,stagingToken:t,beneficiaryId:n}){const a=Ne({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:i}=await B(a);return i}function Ce({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=le()}){return{path:De,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:a},body:{beneficiary:ve(e)}}}}function Me({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${De}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}function qe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i}){const{name:r,email:s,activityTag:o}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i},body:{beneficiary:{name:r,email:s,activity_tag:o}}};return{path:`${De}/${e.id}`,options:c}}const Fe=[{name:"name"},{name:"iban"}];const $e={getBeneficiaries:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:i}=S(e?.operationSettings||{});if(n){const e=x(Oe({paginationSettings:i})),t=K(await n(e)),a=t.body.beneficiaries.map((e=>Pe(e))),r=Le(t.body.meta);return{beneficiaries:a,...r?{meta:r}:{}}}{const e=a||r(),n=await async function({paginationSettings:e,accessToken:t,stagingToken:n}){const a=Oe({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:i,meta:r}=await B(a);return{beneficiaries:i,meta:r}}({accessToken:e,stagingToken:t,paginationSettings:i}),s=n.beneficiaries.map((e=>Pe(e))),o=Le(n.meta);return{beneficiaries:s,...o?{meta:o}:{}}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("beneficiaryId must be a string");return e}(e?.beneficiaryId),{proxyRequestFunction:a,accessToken:i,stagingToken:o}=S(t||{});if(a){const e=x(Ne({beneficiaryId:n}));return Pe(K(await a(e)).body.beneficiary)}{const e=i||r();return Pe(await Ue({beneficiaryId:n,accessToken:e,stagingToken:o}))}},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new s("beneficiary must be an object");X(e,Fe);const t=Q({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new s(t);return e}(e),{proxyRequestFunction:a,accessToken:i,stagingToken:o,idempotencyKey:c}=S(t||{});if(a){const e=x(Ce({beneficiary:n,idempotencyKey:c}));return Pe(K(await a(e)).body.beneficiary)}{const e=i||r(),t=await async function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a=le()}){const i=Ce({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:a}),{beneficiary:r}=await B(i);return r}({beneficiary:n,accessToken:e,stagingToken:o,idempotencyKey:c});return Pe(t)}},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:a,activityTag:i}=e||{};if(!t)throw new s("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!a&&!i)throw new s("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const r=Q({name:n,email:a,activityTag:i});if(r.length>0)throw new s(r);return{id:t,name:n,email:a,activityTag:i}}(e),{stagingToken:a,idempotencyKey:i,mfaPreference:o,proxyRequestFunction:c}=S(t),d={beneficiaryParamsBeingEdited:n,idempotencyKey:i,mfaPreference:o};if(c){const e=x(qe(d));return Pe(K(await c(e)).body.beneficiary)}{const e=t?.accessToken||r(),n=await async function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i}){const r=qe({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:a,mfaPreference:i}),{beneficiary:s}=await B(r);return s}({...d,accessToken:e,stagingToken:a});return Pe(n)}},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new s("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{proxyRequestFunction:a,accessToken:i,stagingToken:o}=S(t||{});if(a){const e=x(Me({beneficiaryIds:n}));return K(await a(e)).body.beneficiaries.map(Pe)}{const e=i||r(),t=await async function({beneficiaryIds:e,accessToken:t,stagingToken:n}){const a=Me({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:i}=await B(a);return i}({beneficiaryIds:n,accessToken:e,stagingToken:o});return t.map(Pe)}}},Be=$e;function xe(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Ke(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}function Ge(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function He(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}function je(e){return{name:e.name,iban:e.iban}}const Ye="/v2/sepa",ze=`${Ye}/transfers`;function Ve({paginationSettings:e,accessToken:t,stagingToken:n}){const a={method:"GET",headers:{accessToken:t,stagingToken:n}},i=Se(e),r=i.size?`?${i.toString()}`:"";return{path:`${ze}${r}`,options:a}}function We({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${ze}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Je({sepaPayee:e,accessToken:t,stagingToken:n}){const a=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await B(a)}const Xe="/v2/sepa/bulk_transfers";async function Qe({sepaPayees:e,accessToken:t,stagingToken:n}){const a=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ye}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(je)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await B(a)}function Ze(e){if(!e)throw new s("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new s("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new s("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new s("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new s(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new s(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new s(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new s(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=Q({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),a=ee({amount:e.amount}),i=[...n,...a].flat();if(i.length>0)throw new s(i);if(e.amount>f&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new s(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const et="browser",tt="server";class nt extends Error{constructor(e){switch(super(),this.name="InvalidRuntimeError",e){case et:this.message="This code is running in a browser environment, but it is expected to run in a server environment.";break;case tt:this.message="This code is running in a server environment, but it is expected to run in a browser environment.";break;default:this.message="This code is not expected to run in this environment. Check if the function was server-only or browser-only."}}}const at=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];function it(e,t){const n=t?.locale||D.getLocale(),a=new URL(e);return n&&a.searchParams.append("lang",n),t?.mfaPreference&&a.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&a.searchParams.append("idempotencyKey",t.idempotencyKey),a.toString()}function rt(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}const st={request:async function({requestSettings:e,operationSettings:t}){!function(e){if(!e||"object"!=typeof e)throw new s("requestSettings must be an object");const t=e,{action:n,callbackUrl:a}=e;X(t,[{name:"action"}]);const i=Q(t),r=Object.values(p);if(r.includes(n)||i.push(`action must be one of ${r.join(", ")}`),i.length>0)throw new s(i);if(void 0!==a&&""===a.trim())throw new s("callbackUrl cannot be empty")}(e);const{proxyRequestFunction:n,stagingToken:a}=S(t||{});if(n){const t=x(G({stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}));return rt(K(await n(t)).body)}{const n=t?.accessToken||r();return rt(await async function(e){const t=G({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await B(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}({accessToken:n,stagingToken:a,action:e.action,callbackUrl:e.callbackUrl}))}}};const ot={getSepaTransfers:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:i}=S(e?.operationSettings||{});if(n){const e=x(Ve({paginationSettings:i})),t=K(await n(e)),a=t.body.transfers.map(Ge),r=Le(t.body.meta);return{transfers:a,...r?{meta:r}:{}}}{const e=a||r(),n=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a=Ve({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:i,meta:r}=await B(a);return{transfers:i,meta:r}}({accessToken:e,stagingToken:t,paginationSettings:i}),s=n.transfers.map(Ge),o=Le(n.meta);return{transfers:s,...o?{meta:o}:{}}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId),{proxyRequestFunction:a,accessToken:i,stagingToken:o}=S(t||{});if(a){const e=x(We({sepaTransferId:n}));return Ge(K(await a(e)).body.transfer)}{const e=i||r(),t=await async function({accessToken:e,stagingToken:t,sepaTransferId:n}){const a=We({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:i}=await B(a);return i}({sepaTransferId:n,accessToken:e,stagingToken:o});return Ge(t)}},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const a=t?.accessToken||r(),i=t?.stagingToken||n.getStagingToken(),o=t?.idempotencyKey||le();let d;!function(e){if(!e)throw new s("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new s("sepaTransferSettings must be an object");if(X(e,at),!e.beneficiaryId&&!e.beneficiary)throw new s("Either beneficiaryId or beneficiary must be provided");const t=[...Q({beneficiaryId:e.beneficiaryId,bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...ee({amount:e.amount})].flat();if(t.length>0)throw new s(t);if(e.amount>f&&(!e.attachmentIds||0===e.attachmentIds.length))throw new s("Attachments are required for transfers over €30,000")}(e);const u=await async function({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:Pe(await Ue({beneficiaryId:e?.beneficiaryId,accessToken:t?.accessToken,stagingToken:t?.stagingToken}))}({sepaTransferSettings:e,operationSettings:{accessToken:a,stagingToken:i||void 0}}),l={name:u.name,iban:u.iban},m=await Je({sepaPayee:l,accessToken:a,stagingToken:i||void 0});var p;if((yield(p=m,{matchResult:p.match_result,matchedName:p.matched_name}))===g.REJECT)return;const T={...e,beneficiary:u};if(T.beneficiary?.trusted)d=await async function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:a,idempotencyKey:i}){const r=He(e),s={method:"POST",headers:$({accessToken:n,stagingToken:a,idempotencyKey:i}),body:JSON.stringify({transfer:r,vop_proof_token:t})},o=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ze}`,c=await fetch(o,s),d=await c.json();if(d.errors)throw new M(d.errors.map((e=>`${e.code}: ${e.detail}`)));return d.transfer}({transfer:T,vopProofToken:m.proof_token.token,accessToken:a,stagingToken:i||void 0,idempotencyKey:o});else{if(!q())throw new nt(et);const{uiParentElementId:e,debugMode:n}=S(t,{requiresUI:!0});let r;try{const t=ge({accessToken:a,stagingToken:i||void 0,debugMode:n});r=await pe({iframeUrl:t,parentElementId:e});const s=He(T);d=await r.postMessage(me({actionId:c.TRANSFER_SINGLE_CREATE,actionData:{body:{transfer:{...s}},idempotencyKey:o}}))}finally{r?.destroy()}}return Ge(d)},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||r(),a=function(e){if(!e)throw new s("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new s("sepaTransferId must be a string");return e}(e?.sepaTransferId);await async function({sepaTransferId:e,accessToken:t,stagingToken:n}){const a={method:"POST",headers:$({accessToken:t,stagingToken:n})},i=`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${ze}/${e}/cancel`,r=await fetch(i,a);if(204!==r.status){const e=await r.json();if(e.errors)throw new M(e.errors.map((e=>`${e.code}: ${e.detail}`)))}}({sepaTransferId:a,accessToken:n,stagingToken:t?.stagingToken})},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new s("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new s("callbackUrl must be a string");return e.callbackUrl}(e),{proxyRequestFunction:a,stagingToken:i,accessToken:o}=S(t||{}),c=a?{proxyRequestFunction:a}:{stagingToken:i,accessToken:o||r()},d=await st.request({requestSettings:{action:p.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:c});return{...d,url:it(d.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{operationSettings:t}=e||{},n=t?.accessToken||r(),{stagingToken:a,paginationSettings:i}=S(t||{}),s=await async function({accessToken:e,stagingToken:t,paginationSettings:n}){const a={method:"GET",headers:$({accessToken:e,stagingToken:t})},i=Re({endpointUrl:new URL(`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}`),paginationSettings:n}),r=await fetch(i,a);if(!r.ok)throw new M("Failed to fetch SEPA bulk transfers");const s=await r.json();if(s.errors)throw new M(s.errors.map((e=>`${e.code}: ${e.detail}`)));return{bulkTransfers:s.bulk_transfers,meta:s.meta}}({accessToken:n,stagingToken:a,paginationSettings:i}),o=s.bulkTransfers?.map(xe),c=Le(s.meta);return{bulkTransfers:o,...c?{meta:c}:{}}},getBulkTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=t?.accessToken||r(),{stagingToken:a}=S(t||{}),i=function(e){if(!e)throw new s("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new s("bulkTransferId must be a string.");return e}(e?.bulkTransferId);return xe(await async function({accessToken:e,stagingToken:t,bulkTransferId:n}){const a={method:"GET",headers:$({accessToken:e,stagingToken:t})},i=new URL(`${E.getEnvironmentUrls().THIRD_PARTY_API_URL}${Xe}/${n}`),r=await fetch(i,a),s=await r.json();if(s.errors)throw new M(s.errors.map((e=>`${e.code}: ${e.detail}`)));return s.bulk_transfer}({accessToken:n,stagingToken:a,bulkTransferId:i}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const a=t?.accessToken||r(),i=t?.stagingToken||n.getStagingToken(),s=t?.idempotencyKey||le();Ze(e);const{uiParentElementId:o,debugMode:d}=S(t,{requiresUI:!0});if(!q())throw new nt(et);const u=new Map;for(const t of e.bulkTransfers){const e=t.beneficiary.iban;e&&!u.has(e)&&u.set(e,{name:t.beneficiary.name,iban:e})}const l=Array.from(u.values()),m=await Qe({sepaPayees:l,accessToken:a,stagingToken:i||void 0});if((yield m.requests.map(Ke))===g.REJECT)return;let f,p;try{const t=ge({accessToken:a,stagingToken:i||void 0,debugMode:d});p=await pe({iframeUrl:t,parentElementId:o});const n={bankAccountId:e.bankAccountId,bulkTransfers:e.bulkTransfers.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))};f=await p.postMessage(me({actionId:c.TRANSFER_BULK_CREATE,actionData:{body:n,idempotencyKey:s}}))}finally{p?.destroy()}return xe(f)}}},ct={GOOD:"good",SERVICE:"service"},dt={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},ut=e=>{if(!(e=>Object.values(dt).includes(e))(e))throw new s(`currency ${e} is not valid, valid currencies are ${Object.values(dt).join(", ")}`)},lt={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},mt=e=>{if(!(e=>Object.values(lt).includes(e))(e))throw new s(`unit ${e} is not valid, valid units are ${Object.values(lt).join(", ")}`)},ft=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],gt=[{name:"currency"},{name:"value"}];const pt=e=>{if(!Object.values(ct).includes(e))throw new s(`type ${e} is not valid, valid types are ${Object.values(ct).join(", ")}`)},Tt={getPaymentLinkCreationFlowUrl:({paymentLinkSettings:e})=>{const{items:t,authUrl:n}=e;!function(e){if(!e)throw new s("authUrl is required for the called function");const t=Q({authUrl:e});if(t.length>0)throw new s(t);try{new URL(e)}catch{throw new s("authUrl is not a valid URL")}}(n),function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{X(e,ft),X(e.unitPrice,gt);const t=[...Q({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...ee({quantity:e.quantity})].flat();if(t.length>0)throw new s(t);pt(e.type),ut(e.unitPrice.currency),mt(e.measureUnit)}))}(t);const a=new URLSearchParams({...t?{items:JSON.stringify(t)}:{}});return a.toString()?`${n}?${a.toString()}`:n}},ht=({accessToken:e,stagingToken:t})=>({path:"/v2/organizations/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}),yt=e=>({slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:e.balance,balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),_t={getBankAccounts:async e=>{const{stagingToken:t,proxyRequestFunction:n}=S(e);if(n){const e=ht({stagingToken:t}),a=await n(x(e)),{body:i}=K(a);return i.bank_accounts.map(yt)}{const n=e.accessToken||r(),a=await(async({accessToken:e,stagingToken:t})=>{const n=ht({accessToken:e,stagingToken:t});return await B(n)})({accessToken:n,stagingToken:t});return a.bank_accounts.map(yt)}}},bt="/v2/transactions";function kt({bankAccountId:e,iban:t,status:n,updatedAtFrom:a,updatedAtTo:i,emittedAtFrom:r,emittedAtTo:s,settledAtFrom:o,settledAtTo:c,side:d,operationType:u,withAttachments:l,paginationSettings:m,accessToken:f,stagingToken:g}){const p={method:"GET",headers:{accessToken:f,stagingToken:g}},T=new URLSearchParams;e&&T.append("bank_account_id",e),t&&T.append("iban",t),n&&T.append("status",n),a&&T.append("updated_at_from",a),i&&T.append("updated_at_to",i),r&&T.append("emitted_at_from",r),s&&T.append("emitted_at_to",s),o&&T.append("settled_at_from",o),c&&T.append("settled_at_to",c),d&&T.append("side",d),u&&T.append("operation_type",u),void 0!==l&&T.append("with_attachments",String(l));const h=Se(m);for(const[e,t]of h)T.append(e,t);const y=T.toString();return{path:`${bt}${y?`?${y}`:""}`,options:p}}function It({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${bt}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}function wt(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const Et={getTransactions:async function(e){const{stagingToken:t,proxyRequestFunction:n,accessToken:a,paginationSettings:i}=S(e?.operationSettings||{}),s={...e?.transactionSettings||{},paginationSettings:i};if(n){const e=x(kt(s)),t=K(await n(e));return{transactions:t.body.transactions.map(wt),meta:t.body.meta}}{const e=a||r(),n=await async function(e){const t=kt(e),{transactions:n,meta:a}=await B(t);return{transactions:n,meta:a}}({...s,accessToken:e,stagingToken:t});return{transactions:n.transactions.map(wt),meta:n.meta}}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{proxyRequestFunction:n,accessToken:a,stagingToken:i}=S(t||{}),{transactionId:o}=function(e){if(!e)throw new s("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new s("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new s("transactionSettings.transactionId must be a string.");return e}(e);if(n){const e=x(It({transactionId:o}));return wt(K(await n(e)).body.transaction)}{const e=a||r();return wt(await async function(e){const t=It(e),{transaction:n}=await B(t);return n}({transactionId:o,accessToken:e,stagingToken:i}))}}},At=Et;e.authLinks=st,e.beneficiaries=Be,e.cards=Ae,e.constants=C,e.initialize=N,e.logout=U,e.organizations=_t,e.paymentLinks=Tt,e.sepaTransfers=ot,e.transactions=At}));
@@ -1 +1 @@
1
- import{EmbedApiError as e}from"../errors/EmbedApiError.js";import{environmentManager as n}from"../common/environment/environment-manager.js";import{buildRequestHeaders as o,makeNetworkCall as r}from"../common/network/network.js";function s({membershipId:e,accessToken:n,stagingToken:o}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}}async function a({membershipId:e,accessToken:n,stagingToken:o}){const a=s({membershipId:e,accessToken:n,stagingToken:o}),{cards:t}=await r(a);return t}function t({cardId:e,accessToken:n,stagingToken:o}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:n,stagingToken:o}}}}async function c({cardId:e,accessToken:n,stagingToken:o}){const s=t({cardId:e,accessToken:n,stagingToken:o}),{cards:a}=await r(s);return a[0]}async function i(r){const{accessToken:s,stagingToken:a,mfaPreference:t}=r,c={method:"GET",headers:o({accessToken:s,stagingToken:a,mfaPreference:t})},i=n.getEnvironmentUrls().THIRD_PARTY_API_URL,d=await fetch(`${i}/v2/cards/${r.cardId}/data_view`,c),m=await d.json();if(!d.ok)throw m.errors?new e(m.errors.map((e=>`${e.code}: ${e.detail}`))):new e(`${m.code}: ${m.detail}`);return m.iframe_url}export{c as getCard,i as getCardIframeURL,a as getCards,t as prepareGetCardCall,s as prepareGetCardsCall};
1
+ import{makeNetworkCall as n}from"../common/network/network.js";import{prepareAuthLinkRequest as s}from"../auth-links/auth-links.api.js";import{AUTH_LINK_ACTIONS as e}from"../common/constants.js";function o({membershipId:n,accessToken:s,stagingToken:e}){return{path:n?`/v2/cards?holder_ids[]=${n}`:"/v2/cards",options:{method:"GET",headers:{accessToken:s,stagingToken:e}}}}async function a({membershipId:s,accessToken:e,stagingToken:a}){const t=o({membershipId:s,accessToken:e,stagingToken:a}),{cards:c}=await n(t);return c}function t({cardId:n,accessToken:s,stagingToken:e}){return{path:`/v2/cards?ids[]=${n}`,options:{method:"GET",headers:{accessToken:s,stagingToken:e}}}}async function c({cardId:s,accessToken:e,stagingToken:o}){const a=t({cardId:s,accessToken:e,stagingToken:o}),{cards:c}=await n(a);return c[0]}function r({accessToken:n,stagingToken:o}){return s({accessToken:n,stagingToken:o,action:e.CARD_DISPLAY})}async function i(s){const e=r(s),{embed_auth_link:o}=await n(e);return o}export{c as getCard,i as getCardIframeURL,a as getCards,t as prepareGetCardCall,r as prepareGetCardIframeUrl,o as prepareGetCardsCall};
@@ -1 +1 @@
1
- import{gatherQontoEmbedCssVariables as o}from"../customization/customization.js";import{CUSTOM_PROP_PREFIX as t}from"../customization/customization.constants.js";function e(e,a){const n=new URL(e);"boolean"==typeof a.allowPinReveal&&n.searchParams.set("canSeePin",a.allowPinReveal.toString()),"boolean"==typeof a.allowBlocking&&n.searchParams.set("canBlock",a.allowBlocking.toString()),!0===a.debugMode&&n.searchParams.set("debug",a.debugMode.toString());const s=o(t);return Object.keys(s).length>0&&n.searchParams.set("customization",JSON.stringify(s)),n.toString()}export{e as getPopulatedIframeURL};
1
+ import{gatherQontoEmbedCssVariables as a}from"../customization/customization.js";import{CUSTOM_PROP_PREFIX as e}from"../customization/customization.constants.js";import{createIframe as o}from"../iframe/iframe-manager.js";function t(o,t){const n=new URL(o);n.searchParams.set("cardId",t.cardId),"boolean"==typeof t.allowPinReveal&&n.searchParams.set("canSeePin",t.allowPinReveal.toString()),"boolean"==typeof t.allowBlocking&&n.searchParams.set("canBlock",t.allowBlocking.toString()),!0===t.debugMode&&n.searchParams.set("debug",t.debugMode.toString());const r=a(e);return Object.keys(r).length>0&&n.searchParams.set("customization",JSON.stringify(r)),n.toString()}async function n({decorationParams:a,operationSettings:e,cardIframeUrl:n}){const{cardId:r,allowPinReveal:i,allowBlocking:s}=a,{uiParentElementId:l,debugMode:c}=e,m=t(n,{cardId:r,allowPinReveal:i,allowBlocking:s,debugMode:c}),d=await o({iframeUrl:m,parentElementId:l});return{destroyEmbedUI:()=>{d.destroy()}}}export{n as createEmbedUI,t as getPopulatedIframeURL};
@@ -1 +1 @@
1
- import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{encodeNetworkCall as r,decodeNetworkResponse as n}from"../common/network/network.js";import{getCardIframeURL as a,prepareGetCardCall as o,getCard as s,prepareGetCardsCall as i,getCards as c}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as d,validateUnlockCardParams as m,validateOrderCardParams as g,validateGetCardParams as u}from"./cards.validate.js";import{createIframe as p,buildIframeUrl as l}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as f,serializeCard as k,serializeOrderCardPayload as y}from"./cards.serializer.js";import{validateOperationSettingsParams as w}from"../validation/operation-settings-validation.js";import{InvalidParametersError as T}from"../errors/InvalidParametersError.js";import{getPopulatedIframeURL as I}from"./cards.helper.js";async function h(e){try{const a=e?.cardSettings?.membershipId;if(a&&"string"!=typeof a)throw new T("membershipId must be a string");const{proxyRequestFunction:o,stagingToken:s}=w(e?.operationSettings||{});if(o){const e=i({membershipId:a,stagingToken:s}),t=r(e),c=await o(t);return n(c).body.cards.map((e=>k(e)))}{const r=e?.operationSettings?.accessToken||t();return(await c({membershipId:a,accessToken:r,stagingToken:s})).map((e=>k(e)))}}catch(e){return Promise.reject(e)}}async function j({cardSettings:e,operationSettings:a}){try{u(e);const i=e.cardId,{proxyRequestFunction:c,stagingToken:d}=w(a||{});if(c){const e=o({cardId:i,stagingToken:d}),t=r(e),a=await c(t),s=n(a).body.cards;if(Array.isArray(s)&&s.length>0)return k(s[0]);throw new T("Unable to retrieve card data")}{const e=a?.accessToken||t(),r=await s({cardId:i,accessToken:e,stagingToken:d});return k(r)}}catch(e){return Promise.reject(e)}}async function S(r){try{const n=t(),{uiParentElementId:a,debugMode:o}=w(r.operationSettings,{requiresUI:!0});g(r.cardSettings);const s=l({accessToken:n,stagingToken:e.getStagingToken()||void 0,debugMode:o}),i=await p({iframeUrl:s,parentElementId:a}),c=y(r.cardSettings),d=await i.postMessage(c);return i.destroy(),k(d)}catch(e){return Promise.reject(e)}}async function b(r){try{const n=t(),{uiParentElementId:a,debugMode:o}=w(r.operationSettings,{requiresUI:!0});m(r.cardSettings);const s=l({accessToken:n,stagingToken:e.getStagingToken()||void 0,debugMode:o}),i=await p({iframeUrl:s,parentElementId:a}),c=f(r),d=await i.postMessage(c);return i.destroy(),k(d)}catch(e){return Promise.reject(e)}}async function P(e){try{const{uiParentElementId:r,accessToken:n,stagingToken:o,debugMode:s,mfaPreference:i}=w(e.operationSettings,{requiresUI:!0}),c=n||t();d(e.cardSettings);const m=await a({...e.cardSettings,accessToken:c,stagingToken:o,mfaPreference:i}),{allowPinReveal:g,allowBlocking:u}=e.cardSettings,l=I(m,{allowPinReveal:g,allowBlocking:u,debugMode:s}),f=await p({iframeUrl:l,parentElementId:r});return{destroyEmbedUI:()=>{f.destroy()}}}catch(e){return Promise.reject(e)}}export{P as displayCard,j as getCard,h as getCards,S as orderCard,b as unlockCard};
1
+ import{authManager as e}from"../common/auth/auth.js";import{validatePresenceOfAuthToken as t}from"../common/auth/auth.validate.js";import{encodeNetworkCall as r,decodeNetworkResponse as n}from"../common/network/network.js";import{prepareGetCardIframeUrl as a,getCardIframeURL as o,prepareGetCardCall as s,getCard as i,prepareGetCardsCall as c,getCards as d}from"./cards.api.js";import"./cards.types.js";import{validateDisplayCardParams as m,validateUnlockCardParams as g,validateOrderCardParams as u,validateGetCardParams as p}from"./cards.validate.js";import{buildIframeUrl as f,createIframe as k}from"../iframe/iframe-manager.js";import{serializeUnlockCardPayload as l,serializeCard as y,serializeOrderCardPayload as T}from"./cards.serializer.js";import{validateOperationSettingsParams as I}from"../validation/operation-settings-validation.js";import{InvalidParametersError as S}from"../errors/InvalidParametersError.js";import{createEmbedUI as h}from"./cards.helper.js";async function b(e){try{const a=e?.cardSettings?.membershipId;if(a&&"string"!=typeof a)throw new S("membershipId must be a string");const{proxyRequestFunction:o,stagingToken:s}=I(e?.operationSettings||{});if(o){const e=c({membershipId:a,stagingToken:s}),t=r(e),i=await o(t);return n(i).body.cards.map((e=>y(e)))}{const r=e?.operationSettings?.accessToken||t();return(await d({membershipId:a,accessToken:r,stagingToken:s})).map((e=>y(e)))}}catch(e){return Promise.reject(e)}}async function j({cardSettings:e,operationSettings:a}){try{p(e);const o=e.cardId,{proxyRequestFunction:c,stagingToken:d}=I(a||{});if(c){const e=s({cardId:o,stagingToken:d}),t=r(e),a=await c(t),i=n(a).body.cards;if(Array.isArray(i)&&i.length>0)return y(i[0]);throw new S("Unable to retrieve card data")}{const e=a?.accessToken||t(),r=await i({cardId:o,accessToken:e,stagingToken:d});return y(r)}}catch(e){return Promise.reject(e)}}async function w(r){try{const n=t(),{uiParentElementId:a,debugMode:o}=I(r.operationSettings,{requiresUI:!0});u(r.cardSettings);const s=f({accessToken:n,stagingToken:e.getStagingToken()||void 0,debugMode:o}),i=await k({iframeUrl:s,parentElementId:a}),c=T(r.cardSettings),d=await i.postMessage(c);return i.destroy(),y(d)}catch(e){return Promise.reject(e)}}async function P(r){try{const n=t(),{uiParentElementId:a,debugMode:o}=I(r.operationSettings,{requiresUI:!0});g(r.cardSettings);const s=f({accessToken:n,stagingToken:e.getStagingToken()||void 0,debugMode:o}),i=await k({iframeUrl:s,parentElementId:a}),c=l(r),d=await i.postMessage(c);return i.destroy(),y(d)}catch(e){return Promise.reject(e)}}async function M(e){try{const{uiParentElementId:s,accessToken:i,stagingToken:c,debugMode:d,mfaPreference:g,proxyRequestFunction:u}=I(e.operationSettings,{requiresUI:!0});if(m(e.cardSettings),u){const t=a({stagingToken:c}),o=r(t),i=await u(o),m=n(i).body;return h({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:s,debugMode:d},cardIframeUrl:m.url})}{const r=i||t(),n=await o({...e.cardSettings,accessToken:r,stagingToken:c});return h({decorationParams:e.cardSettings,operationSettings:{uiParentElementId:s,debugMode:d,mfaPreference:g},cardIframeUrl:n.url})}}catch(e){return Promise.reject(e)}}export{M as displayCard,j as getCard,b as getCards,w as orderCard,P as unlockCard};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qonto/embed-sdk",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Library to embed Qonto features in your application",
5
5
  "type": "module",
6
6
  "exports": {