'use strict';
import { apiPost, apiGetWithOData, apiGet } from '../../../../fd-toolbox/api/api-client.js';
import { apiPathNames } from '../../../../fd-toolbox/api/api-path-names.js';
import { getODataBuilder } from '../../../../fd-toolbox/odata/odata-builder-funcs.js';
import { oDataOperators } from '../../../../fd-toolbox/enums/enums.js';
import { subscriptionStatuses } from '../../../meta/core/resources/enums/payment-enums.js';
import { subscriptionProps } from '../../../meta/subscription-plan/subscription-props.js';
import { oDataFilterTypes, oDataLogicalOperationTypes } from '../../../../fd-toolbox/odata/odata-enums.js';
import { first } from '../../../../fd-toolbox/server/collections/single-funcs.js';

var __defProp=Object['defineProperty'],__name=(_0x5c69f5,_0xffbbfb)=>__defProp(_0x5c69f5,'name',{'value':_0xffbbfb,'configurable':!![]});async function createSubscription(_0x4b55d7){await apiPost(apiPathNames['createSubscription'],{'pricingId':_0x4b55d7});}__name(createSubscription,'createSubscription');async function fetchActiveOrTrialSubscription(){const _0x4b5894=getActiveOrTrialSubscriptionODataConfig(),{data:_0x485785=[]}=await apiGetWithOData(apiPathNames['subscription'],_0x4b5894);return first(_0x485785);}__name(fetchActiveOrTrialSubscription,'fetchActiveOrTrialSubscription');async function hasAnySubscription(){const {data:_0x27ef8e=[]}=await apiGet(apiPathNames['subscription']);return _0x27ef8e['length']>0x815+0x240b+-0x2c20;}__name(hasAnySubscription,'hasAnySubscription');function hasScheduledCancelation(_0x165053,_0x2dfe48){const _0x49caa0=_0x165053?.['pricingId']===_0x2dfe48;return Boolean((_0x165053?.['pendingPricingId']??_0x165053?.['endDate'])&&_0x49caa0);}__name(hasScheduledCancelation,'hasScheduledCancelation');function getActiveOrTrialSubscriptionODataConfig(){const _0x4383b0=getODataBuilder();return _0x4383b0['expand'](subscriptionProps['pricing']),_0x4383b0['filter'](subscriptionProps['status'],subscriptionStatuses['active'],oDataOperators['equal'],{'comparisonType':oDataFilterTypes['number']}),_0x4383b0['filter'](subscriptionProps['status'],subscriptionStatuses['trialing'],oDataOperators['equal'],{'type':oDataFilterTypes['number'],'logicalOperationType':oDataLogicalOperationTypes['or']}),_0x4383b0['build']();}__name(getActiveOrTrialSubscriptionODataConfig,'getActiveOrTrialSubscriptionODataConfig');

export { createSubscription, fetchActiveOrTrialSubscription, hasAnySubscription, hasScheduledCancelation };
