{"version":3,"file":"helpers.lpCNts2Z.js","sources":["../../../../../../src/lib/utils/campaign-store/store.ts","../../../../../../src/lib/utils/campaign-store/index.ts","../../../../../../src/lib/utils/cta-services-mapper-utils.ts","../../../../../../src/lib/utils/cta-flow/helpers.ts"],"sourcesContent":["import { getDeviceInfo } from '$lib/utils/browser-utils';\nimport { derived, get, type Readable, writable, type Writable } from 'svelte/store';\nimport type {\n CampaignData,\n CampaignDataHistoryEntry,\n CampaignType,\n ICampaignStore,\n QueryCampaignData,\n} from './types';\nimport { useCtaServicesApiClient } from '$lib/api/CtaServicesApiClientFactory';\nimport { browser } from '$app/environment';\n\ninterface LocalStorageWritable extends Writable { }\n\nfunction localStorageWritable(key: string, initialValue: T): LocalStorageWritable {\n const _writable = writable(initialValue);\n const jsonStr = localStorage.getItem(key);\n if (jsonStr) {\n try {\n _writable.set(JSON.parse(jsonStr));\n } catch (e) {\n //FAILING WHEN PARSING A STRING\n //@ts-ignore\n _writable.set(jsonStr);\n }\n }\n _writable.subscribe((current) => {\n localStorage.setItem(key, JSON.stringify(current));\n });\n\n return _writable;\n}\n\nclass QueueArray extends Array {\n private _maxLength: number;\n\n constructor(maxLength: number) {\n super();\n this._maxLength = maxLength;\n }\n\n push(...items: T[]): number {\n if (this.length === this.maxLength) {\n this.shift();\n }\n return Array.prototype.push.apply(this, items);\n }\n\n get maxLength() {\n return this._maxLength;\n }\n}\n\nexport class CampaignStore implements ICampaignStore {\n private static DEFAULT_KEY = 'CAMPAIGN_DATA';\n private static FIRST_CLICK_KEY = 'FIRSTCLICK_CAMPAIGN_DATA';\n private static HISTORY_KEY = 'HISTORY_CAMPAIGN_DATA';\n private static WEBID_KEY = 'webid';\n\n private static _instance: CampaignStore;\n\n private _campaignData: LocalStorageWritable;\n private _firstClickCampaignData: LocalStorageWritable;\n private _historyCampaignData: LocalStorageWritable>;\n private _webid: LocalStorageWritable;\n\n private constructor() {\n if (browser) {\n this._campaignData = localStorageWritable(CampaignStore.DEFAULT_KEY, null);\n this._firstClickCampaignData = localStorageWritable(CampaignStore.FIRST_CLICK_KEY, null);\n this._historyCampaignData = localStorageWritable(\n CampaignStore.HISTORY_KEY,\n new QueueArray(20)\n );\n this._webid = localStorageWritable(CampaignStore.WEBID_KEY, '');\n } else {\n this._campaignData = writable(null);\n this._firstClickCampaignData = writable(null);\n this._historyCampaignData = writable(new QueueArray(20));\n this._webid = writable('');\n }\n }\n\n public static getInstance() {\n if (CampaignStore._instance == null) {\n CampaignStore._instance = new CampaignStore();\n }\n return CampaignStore._instance;\n }\n\n public clearCampaignData() {\n this._campaignData.set(null);\n }\n\n public parseAndStoreFirstClickCampaignData(params: Record) {\n const queryData: QueryCampaignData = this.parseCampaignData(params);\n const deviceInfo = getDeviceInfo();\n\n this._firstClickCampaignData.update((currentData) => {\n if (!currentData) {\n return {\n fbclid: queryData.fbclid,\n gclid: queryData.gclid,\n gclsrc: queryData.gclsrc,\n referrer: document.URL,\n utm_campaign: queryData.utm_campaign,\n utm_medium: queryData.utm_medium,\n utm_source: queryData.utm_source,\n type: this.getCampaignType(queryData),\n device: deviceInfo ? {\n type: deviceInfo.device,\n version: deviceInfo.osVersion,\n browser: deviceInfo.browser,\n browserVersion: deviceInfo.browserVersion,\n } : undefined,\n };\n } else if (this.isDeviceEmpty(currentData)) {\n // If device object was empty or string (as in previouse version) update it\n return {\n fbclid: currentData.fbclid,\n gclid: currentData.gclid,\n gclsrc: currentData.gclsrc,\n referrer: currentData.referrer,\n utm_campaign: currentData.utm_campaign,\n utm_medium: currentData.utm_medium,\n utm_source: currentData.utm_source,\n type: currentData.type,\n device: deviceInfo ? {\n type: deviceInfo.device,\n version: deviceInfo.osVersion,\n browser: deviceInfo.browser,\n browserVersion: deviceInfo.browserVersion,\n } : undefined,\n };\n }\n\n return {\n fbclid: currentData.fbclid,\n gclid: currentData.gclid,\n gclsrc: currentData.gclsrc,\n referrer: currentData.referrer,\n utm_campaign: currentData.utm_campaign,\n utm_medium: currentData.utm_medium,\n utm_source: currentData.utm_source,\n type: currentData.type,\n device: currentData.device,\n };\n });\n }\n\n public parseCampaignData(params: Record): QueryCampaignData {\n return {\n utm_campaign: params['utm_campaign'] || '',\n utm_source: params['utm_source'] || '',\n utm_medium: params['utm_medium'] || '',\n fbclid: params['fbclid'] || '',\n gclid: params['gclid'] || '',\n gclsrc: params['glsrc'] || '',\n };\n }\n\n public async parseAndUpdateCampaignData(params: Record) {\n const now = new Date();\n const queryData: QueryCampaignData = this.parseCampaignData(params);\n const deviceInfo = getDeviceInfo();\n\n this._campaignData.update((currentData: CampaignData | null) => {\n return {\n referrer: document.URL, // tracked referrer is the current document URL with all parameters\n utm_campaign: queryData.utm_campaign || currentData?.utm_campaign || '',\n utm_source: queryData.utm_source || currentData?.utm_source || '',\n utm_medium: queryData.utm_medium || currentData?.utm_medium || '',\n fbclid: queryData.fbclid || currentData?.fbclid || '',\n gclid: queryData.gclid || currentData?.gclid || '',\n gclsrc: queryData.gclsrc || currentData?.gclsrc || '',\n };\n });\n\n const history = get(this._historyCampaignData);\n const previousEntry = history[history.length - 1];\n const newEntry: CampaignDataHistoryEntry = {\n time: now.toISOString(),\n referrer: document.URL,\n utm_campaign: queryData.utm_campaign,\n utm_source: queryData.utm_source,\n utm_medium: queryData.utm_medium,\n fbclid: queryData.fbclid,\n gclid: queryData.gclid,\n gclsrc: queryData.gclsrc,\n type: this.getCampaignType(queryData),\n device: deviceInfo ? {\n type: deviceInfo.device,\n version: deviceInfo.osVersion,\n browser: deviceInfo.browser,\n browserVersion: deviceInfo.browserVersion,\n } : undefined,\n };\n\n if (this.shouldStore(newEntry, previousEntry)) {\n const client = useCtaServicesApiClient();\n const webid = get(this._webid);\n const result = await client.getSessionHistory({\n webid: webid ? webid : undefined,\n referrer: newEntry.referrer,\n utmCampaignName: newEntry.utm_campaign,\n utmCampaignSource: newEntry.utm_source,\n utmCampaignMedium: newEntry.utm_medium,\n utmCampaignTerm: '',\n utmCampaignContent: '',\n fbclid: newEntry.fbclid,\n gclid: newEntry.gclid,\n gclsrc: newEntry.gclsrc,\n type: newEntry.type,\n device: newEntry.device ? newEntry.device.type : undefined,\n deviceVersion: newEntry.device ? newEntry.device.version : undefined,\n browser: newEntry.device ? newEntry.device.browser : undefined,\n browserVersion: newEntry.device ? newEntry.device.browserVersion : undefined,\n });\n\n history.push(newEntry);\n this._historyCampaignData.set(history);\n this._webid.set(result.id);\n }\n }\n\n get webid(): Readable {\n return derived(this._webid, (value) => value);\n }\n\n get campaignData(): Readable {\n return derived(this._campaignData, (value) => value);\n }\n\n get firstClickCampaignData(): Readable {\n return derived(this._firstClickCampaignData, (value) => value);\n }\n\n /****************** PRIVATE METHODS HELPERS ***********************/\n\n private isDeviceEmpty(campaignData: CampaignData) {\n return typeof campaignData.device !== 'object' || Object.keys(campaignData.device).length === 0;\n }\n\n private shouldStore(newEntry: CampaignDataHistoryEntry, oldEntry: CampaignDataHistoryEntry) {\n if (newEntry && oldEntry) {\n // Compare objects\n if (newEntry.type === 'direct' && oldEntry.type === 'direct') {\n return false;\n }\n\n const equal = JSON.stringify({ ...newEntry, time: undefined }) === JSON.stringify({ ...oldEntry, time: undefined });\n\n const hours = 8;\n const milliseconds = hours * 60 * 60 * 1000;\n\n const newTime = new Date(newEntry.time).getTime();\n const oldTime = new Date(oldEntry.time).getTime();\n\n return !equal || newTime - oldTime > milliseconds;\n }\n return true;\n }\n\n /**\n * Get the campaign type based on the query campaign data\n * @param queryData The campaign data of the url query\n * @returns The campaign type\n */\n private getCampaignType(queryData: QueryCampaignData): CampaignType | undefined {\n if (\n document.referrer &&\n !queryData.fbclid &&\n !queryData.gclid &&\n !queryData.gclsrc &&\n !queryData.utm_campaign &&\n !queryData.utm_medium &&\n !queryData.utm_medium &&\n !queryData.utm_source\n ) {\n return 'organic';\n } else if (\n document.referrer &&\n (queryData.fbclid ||\n queryData.gclid ||\n queryData.gclsrc ||\n queryData.utm_campaign ||\n queryData.utm_medium ||\n queryData.utm_medium ||\n queryData.utm_source)\n ) {\n return 'adv';\n } else if (\n !document.referrer &&\n !queryData.fbclid &&\n !queryData.gclid &&\n !queryData.gclsrc &&\n !queryData.utm_campaign &&\n !queryData.utm_medium &&\n !queryData.utm_medium &&\n !queryData.utm_source\n ) {\n return 'direct';\n }\n\n return undefined;\n }\n}\n","export type { CampaignData, ICampaignStore } from './types';\n\nimport { CampaignStore } from './store';\n\nexport const useCampaignStore = CampaignStore.getInstance;\n","import { WebsiteSessionData } from \"$lib/api/generated/cta-services\"\n\n/**\n * Maps from the campaign data type to the website session data type\n * @param type The campaign data type\n * @returns The website session data type\n */\nexport const fromCampaignDataTypesToWebsiteSessionDataTypes = (type?: 'direct' | 'adv' | 'organic'): WebsiteSessionData.type | undefined => {\n return type == 'adv' ? WebsiteSessionData.type.ADV : type == 'direct' ? WebsiteSessionData.type.DIRECT : type == 'organic' ? WebsiteSessionData.type.ORGANIC : undefined\n}","import type { SessionModel } from '@24hbs/utils';\nimport { useCampaignStore } from '$lib/utils/campaign-store';\nimport {\n B2B_FONDO_NUOVE_COMPETENZE,\n B2B_FORMAZIONE_INTERAZIENDALE_A_CATALOGO,\n B2B_FORMAZIONE_SU_MISURA,\n B2B_HR_FOR_BREAKFAST,\n B2B_LE_MASTERCLASS\n} from '$lib/utils/custom-courses';\nimport { useSessionStore } from '$lib/utils/session-store';\nimport { get } from 'svelte/store';\nimport type {\n BuyCTAData,\n DownloadBrochureCTAData,\n RequestInfoCTAData,\n SendApplicationFormCTAData,\n UserWebsiteData,\n} from './types';\nimport type { Page } from '@sveltejs/kit';\nimport { useOktaStore } from '../auth-store';\nimport { useCtaServicesApiClient } from \"$lib/api/CtaServicesApiClientFactory\";\nimport { fromCampaignDataTypesToWebsiteSessionDataTypes } from '../cta-services-mapper-utils';\nimport type { GtmEventData } from '../gtm-store/types';\nimport { GtmStore } from '../gtm-store';\nimport { sha256Hex } from '../formatter';\nimport type { SubmitAdmissionRequestResponse } from '$lib/api/generated/cta-services/models/SubmitAdmissionRequestResponse';\nimport type { SubmitDownloadBrochureResponse } from '$lib/api/generated/cta-services/models/SubmitDownloadBrochureResponse';\nimport type { BookEventResponse } from '$lib/api/generated/cta-services/models/BookEventResponse';\nimport type { SubmitOrientationRequestResponse } from '$lib/api/generated/cta-services/models/SubmitOrientationRequestResponse';\nimport type { SignupResponse } from '$lib/api/generated/cta-services/models/SignupResponse';\nimport type { SubmitScholarshipRequestResponse } from '$lib/api/generated/cta-services/models/SubmitScholarshipRequestResponse';\nimport type { SubmitInformationRequestResponse } from '$lib/api/generated/cta-services/models/SubmitInformationRequestResponse';\nimport type { IInitiatives } from '$lib/utils/contentful/types';\n\nconst getUserAndWebsiteData = (): UserWebsiteData => {\n const userInfo = get(useOktaStore().userInfo);\n const pendingUserInfo = get(useSessionStore().pendingUserInfo);\n const companyStatus = get(useSessionStore().companyStatus);\n\n\n const campaignStore = useCampaignStore();\n const campaignData = get(campaignStore.campaignData);\n const webid = get(campaignStore.webid);\n return {\n id: userInfo?.id || pendingUserInfo?.id || '',\n bsid: userInfo?.bsid || pendingUserInfo?.bsid || '',\n email: userInfo?.email || pendingUserInfo?.email || '',\n name: userInfo?.name || pendingUserInfo?.name || '',\n surname: userInfo?.surname || pendingUserInfo?.lastname || '',\n phone: userInfo?.phone || pendingUserInfo?.phone || '',\n consent1: userInfo?.subscribe || pendingUserInfo?.subscribe || false,\n consent2: userInfo?.businessUseConsent || pendingUserInfo?.businessUseConsent || false,\n consent3: userInfo?.profilingConsent || pendingUserInfo?.profilingConsent || false,\n referrer: campaignData?.referrer || '',\n utmCampaignSource: campaignData?.utm_source || '',\n utmCampaignMedium: campaignData?.utm_medium || '',\n utmCampaignName: campaignData?.utm_campaign || '',\n utmCampaignTerm: '',\n utmCampaignContent: '',\n fbclid: campaignData?.fbclid || '',\n gclid: campaignData?.gclid || '',\n gclsrc: campaignData?.gclsrc || '',\n websiteSessionData: {\n referrer: campaignData?.referrer || '',\n utmCampaignSource: campaignData?.utm_source || '',\n utmCampaignMedium: campaignData?.utm_medium || '',\n utmCampaignName: campaignData?.utm_campaign || '',\n utmCampaignTerm: '',\n utmCampaignContent: '',\n fbclid: campaignData?.fbclid || '',\n gclid: campaignData?.gclid || '',\n gclsrc: campaignData?.gclsrc || '',\n type: fromCampaignDataTypesToWebsiteSessionDataTypes(campaignData?.type),\n webid: webid || undefined,\n },\n b2b: companyStatus,\n device: campaignData?.device,\n };\n};\n\nconst buildQueryString = (parameters: Record) => {\n return Object.keys(parameters)\n .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(parameters[k])}`)\n .join('&');\n};\n\n/**\n * Build the shopify checkout permalink from given details\n *\n * @param bsid The user unique id\n * @param email The user unique email\n * @param name The user name\n * @param surname The user surname\n * @param phone The user phone number\n * @param productCode The product code\n * @param options The list of options eventually selected by the user\n *\n * @returns The shopify permalink\n */\nconst buildShopifyLink = async (\n bsid: string,\n email: string,\n name: string,\n surname: string,\n phone: string,\n productCode: string,\n options?: string[]\n): Promise => {\n const client = useCtaServicesApiClient();\n const result = await client.checkoutShopify({\n email: email,\n name: name,\n surname: surname,\n bsid: bsid.startsWith('BS') ? bsid : `BS${bsid}`,\n productCode: productCode,\n options: options ? options : undefined,\n phone: phone,\n });\n\n if (!result || !result.multipassUrl) {\n throw new Error('Invalid response from the server');\n }\n\n return result.multipassUrl;\n};\n\nconst buildBrochureConfirmationPath = (coursePath: string, type: 'booking' | 'download', sessionId: number, productCode?: string) => {\n //console.log({productCode});\n if (productCode === B2B_FONDO_NUOVE_COMPETENZE.model.sessions[B2B_FONDO_NUOVE_COMPETENZE.model.idMainSession].productCode) {\n return B2B_FONDO_NUOVE_COMPETENZE.downloadBrochureConfirmationPath;\n }\n if (productCode === B2B_FORMAZIONE_INTERAZIENDALE_A_CATALOGO.model.sessions[B2B_FORMAZIONE_INTERAZIENDALE_A_CATALOGO.model.idMainSession].productCode) {\n return B2B_FORMAZIONE_INTERAZIENDALE_A_CATALOGO.downloadBrochureConfirmationPath;\n }\n if (productCode === B2B_FORMAZIONE_SU_MISURA.model.sessions[B2B_FORMAZIONE_SU_MISURA.model.idMainSession].productCode) {\n return B2B_FORMAZIONE_SU_MISURA.downloadBrochureConfirmationPath;\n }\n if (productCode === B2B_HR_FOR_BREAKFAST.model.sessions[B2B_HR_FOR_BREAKFAST.model.idMainSession].productCode) {\n return B2B_HR_FOR_BREAKFAST.downloadBrochureConfirmationPath;\n }\n if (productCode === B2B_LE_MASTERCLASS.model.sessions[B2B_LE_MASTERCLASS.model.idMainSession].productCode) {\n return B2B_LE_MASTERCLASS.downloadBrochureConfirmationPath;\n }\n return `${coursePath}/${sessionId}/${type}_brochure`;\n};\n\nconst requestHasUserRequiredFields = (request: any): boolean => {\n return request.name && request.phone && request.email && request.consent1;\n};\n\nconst ctaRequestBuilders = {\n downloadBrochure: (session: SessionModel, page: Page, customValues: any = {}, customPath: string | null = null): DownloadBrochureCTAData => {\n return {\n productCode: session.productCode,\n category: session.category,\n courseTypeFull: session.courseTypeFull,\n courseTitle: session.title,\n price: session.priceNoVat,\n discountPrice: session.discountPrice,\n lessionMode: session.lessionMode,\n sessionId: session.idSession,\n brochureAvailable: session.brochureAvailable,\n brochureBooking: session.brochureBooking,\n brochureUrl: session.brochureUrl,\n courseUrl: !customPath ? `${page.url.origin}/formazione/${session.slug}/${session.idSession}` : `${page.url.origin}/${customPath}`,\n courseHost: `${page.url.origin}`,\n coursePath: !customPath ? `/formazione/${session.slug}` : customPath,\n courseReferrerName:\n session.sessionContacts && session.sessionContacts.editorialContact ? session.sessionContacts.editorialContact : '',\n courseReferrerEmail:\n session.sessionContacts && session.sessionContacts.editorialEmail ? session.sessionContacts.editorialEmail : '',\n endDate: session.endDate,\n startDate: session.startDate,\n rank: session.ranking,\n ...customValues\n };\n },\n sendApplicationForm: (session: SessionModel, customPath: string | null = null): SendApplicationFormCTAData => {\n return {\n productCode: session.productCode,\n sessionId: session.idSession.toString(),\n coursePath: !customPath ? `/formazione/${session.slug}` : customPath,\n };\n },\n requestInfo: (session: SessionModel, customPath: string | null = null): RequestInfoCTAData => {\n return {\n productCode: session.productCode,\n sessionId: session.idSession.toString(),\n coursePath: !customPath ? `/formazione/${session.slug}` : customPath,\n };\n },\n buy: (session: SessionModel, customPath: string | null = null): BuyCTAData => {\n return {\n sessionId: session.idSession,\n upselling: session.packages && session.packages.length > 0 && session.options.length > 0,\n upsellingHasPackages: session.packages && session.packages.length > 1 && session.options.length > 0,\n productCode: session.productCode,\n coursePath: !customPath ? `/formazione/${session.slug}` : customPath,\n category: session.category,\n endDate: session.endDate,\n startDate: session.startDate,\n rank: session.ranking,\n };\n },\n bookInitiative: (initiative: IInitiatives, slug: string) => {\n\n if (!initiative) {\n throw new Error('Initiative is required');\n }\n\n if (!slug) {\n throw new Error('Slug is required');\n }\n\n return {\n initiativePath: `/eventi/${slug}`,\n bookingConfig: {\n useCta: initiative.fields.bookingConfig.useCta,\n url: initiative.fields.bookingConfig.url,\n title: initiative.fields.title,\n date: initiative.fields.date,\n type: initiative.fields.type,\n sessionId: initiative.fields.bookingConfig.sessionId,\n courseId: initiative.fields.bookingConfig.courseId,\n },\n };\n },\n};\n\ntype AwinCtaResponse =\n | SubmitAdmissionRequestResponse\n | SubmitDownloadBrochureResponse\n | BookEventResponse\n | SubmitOrientationRequestResponse\n | SignupResponse\n | SubmitScholarshipRequestResponse\n | SubmitInformationRequestResponse;\n\nconst pushCtaEvent = (response: AwinCtaResponse, type: GtmEventData['type']) => {\n\n const body = response.event && response.event.body ? response.event.body : response;\n const gtmRequest = {\n event: 'AwinBBevent',\n cta_uid: response.uid,\n type: type,\n category: type,\n session_value: body.discountPrice ? body.discountPrice : body.price,\n course_title: body.courseTitle,\n course_type: body.courseTypeFull,\n course_thematic_area: body.category,\n session_code: body.sessionId,\n user_bsid: body.bsid,\n user_hashed_email: body.email ? sha256Hex(body.email) : undefined\n }\n\n GtmStore.pushEvent(\n gtmRequest,\n false\n );\n}\n\nexport const createCtaEvent = (type: GtmEventData['type']) => {\n return (response: AwinCtaResponse) => {\n pushCtaEvent(response, type);\n };\n}\n\n\nexport {\n getUserAndWebsiteData,\n buildQueryString,\n buildShopifyLink,\n buildBrochureConfirmationPath,\n requestHasUserRequiredFields,\n ctaRequestBuilders,\n};\n"],"names":["localStorageWritable","key","initialValue","_writable","writable","jsonStr","current","QueueArray","maxLength","__publicField","items","_CampaignStore","params","queryData","deviceInfo","getDeviceInfo","currentData","now","history","get","previousEntry","newEntry","client","useCtaServicesApiClient","webid","result","derived","value","campaignData","oldEntry","equal","milliseconds","newTime","oldTime","CampaignStore","useCampaignStore","fromCampaignDataTypesToWebsiteSessionDataTypes","type","WebsiteSessionData","getUserAndWebsiteData","userInfo","useOktaStore","pendingUserInfo","useSessionStore","companyStatus","campaignStore","buildShopifyLink","bsid","email","name","surname","phone","productCode","options","buildBrochureConfirmationPath","coursePath","sessionId","B2B_FONDO_NUOVE_COMPETENZE","B2B_FORMAZIONE_INTERAZIENDALE_A_CATALOGO","B2B_FORMAZIONE_SU_MISURA","B2B_HR_FOR_BREAKFAST","B2B_LE_MASTERCLASS","ctaRequestBuilders","session","page","customValues","customPath","initiative","slug","pushCtaEvent","response","body","gtmRequest","sha256Hex","GtmStore","createCtaEvent"],"mappings":"soBAcA,SAASA,EAAwBC,EAAaC,EAA0C,CAChF,MAAAC,EAAYC,EAAYF,CAAY,EACpCG,EAAU,aAAa,QAAQJ,CAAG,EACxC,GAAII,EACE,GAAA,CACFF,EAAU,IAAI,KAAK,MAAME,CAAO,CAAC,OACvB,CAGVF,EAAU,IAAIE,CAAO,CAAA,CAGf,OAAAF,EAAA,UAAWG,GAAY,CAC/B,aAAa,QAAQL,EAAK,KAAK,UAAUK,CAAO,CAAC,CAAA,CAClD,EAEMH,CACT,CAEA,MAAMI,UAAsB,KAAS,CAGnC,YAAYC,EAAmB,CACvB,MAAA,EAHAC,EAAA,mBAIN,KAAK,WAAaD,CAAA,CAGpB,QAAQE,EAAoB,CACtB,OAAA,KAAK,SAAW,KAAK,WACvB,KAAK,MAAM,EAEN,MAAM,UAAU,KA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