import * as React from 'react'; import noop from './helpers/noop'; import { CookieCategory, IConsent, ISiteCookiesApiResponse, ITCFConsent, ITCFGatpVendorList, ITCFGlobalVendorList, ITCFVendorCategory, PublicApiTCFCategory, } from './types/types'; export type CookieFirstPublicApi = { isErrorState: boolean; consent: IConsent | null; acceptedServices: IConsent; stealthMode: boolean | null; hasConsented: boolean; openPanel: (tab?: string) => void; closePanel: () => void; acceptCategory: ( category?: CookieCategory | CookieCategory[] ) => Promise; declineCategory: ( category?: CookieCategory | CookieCategory[] ) => Promise; acceptService: (service?: string | string[]) => Promise; declineService: (service?: string | string[]) => Promise; acceptAllCategories: () => Promise; acceptPreselectedCategories: () => Promise; deny: () => Promise; declineAllCategories: () => Promise; withdrawConsent: () => Promise; fetchLatestScan?: () => Promise; renderEmbeds: () => void; notifyViewChanged: () => void; changeLanguage: (newLang: string) => void; visitorId: string | null; consentTimestamp: number | null; TCFconsent: ITCFConsent | null; TCFeventStatus: string | boolean; TCFcountry: string | null; TCFgvl: ITCFGlobalVendorList | null; TCFgatp: ITCFGatpVendorList | null; TCFisEnabled: boolean | null; TCFgetConsentStructure?: () => ITCFConsent; TCFacceptCategory: (categories: PublicApiTCFCategory) => Promise; TCFdeclineCategory: (categories: PublicApiTCFCategory) => Promise; TCFacceptCategoryLegitimateInterest: ( categories: PublicApiTCFCategory ) => Promise; TCFdeclineCategoryLegitimateInterest: ( categories: PublicApiTCFCategory ) => Promise; TCFacceptVendor: (id: number | number[]) => Promise; TCFdeclineVendor: (id: number | number[]) => Promise; TCFacceptVendorLegitimateInterest: (id: number | number[]) => Promise; TCFdeclineVendorLegitimateInterest: (id: number | number[]) => Promise; TCFisVendorAccepted: (id: number) => boolean; TCFisVendorLegitimateInterestAccepted: (id: number) => boolean; TCFisCategoryAccepted: (name: ITCFVendorCategory, id: number) => boolean; TCFisCategoryLegitimateInterestAccepted: ( name: ITCFVendorCategory, id: number ) => boolean; TCFacceptGatpVendor: (id: number | number[]) => Promise; TCFdeclineGatpVendor: (id: number | number[]) => Promise; TCFisGatpVendorAccepted: (id: number) => boolean; updateConsent: (consent: IConsent, tcf?: ITCFConsent) => Promise; }; export const initialContext = { isErrorState: false, consent: null, acceptedServices: {}, openPanel: noop, closePanel: noop, updateConsent: async () => noop(), acceptCategory: async () => noop(), acceptService: async () => noop(), acceptAllCategories: async () => noop(), acceptPreselectedCategories: async () => noop(), declineAllCategories: async () => noop(), declineCategory: async () => noop(), declineService: async () => noop(), withdrawConsent: async () => noop(), deny: async () => noop(), renderEmbeds: () => noop(), notifyViewChanged: () => noop(), changeLanguage: () => noop(), visitorId: null, consentTimestamp: null, TCFconsent: null, TCFeventStatus: false, TCFcountry: null, TCFgvl: null, TCFgatp: null, TCFisEnabled: null, stealthMode: null, hasConsented: false, TCFacceptCategory: async () => noop(), TCFdeclineCategory: async () => noop(), TCFacceptCategoryLegitimateInterest: async () => noop(), TCFdeclineCategoryLegitimateInterest: async () => noop(), TCFacceptVendor: async () => noop(), TCFdeclineVendor: async () => noop(), TCFacceptVendorLegitimateInterest: async () => noop(), TCFdeclineVendorLegitimateInterest: async () => noop(), TCFisVendorAccepted: () => false, TCFisVendorLegitimateInterestAccepted: () => false, TCFisCategoryAccepted: () => false, TCFisCategoryLegitimateInterestAccepted: () => false, TCFacceptGatpVendor: async () => noop(), TCFdeclineGatpVendor: async () => noop(), TCFisGatpVendorAccepted: () => false, }; const context = React.createContext(initialContext); export default context;