{ "version": 3, "sources": ["../../../../src/assets/mcui-js/widgetDataTs.ts"], "sourcesContent": ["import {\r\n isArray,\r\n isArrayOfType,\r\n isBoolean,\r\n isNil,\r\n isObject,\r\n isString,\r\n type Nil,\r\n} from \"@mcwd/typescript-type-guards\";\r\nimport type { LanguageCountryLocale } from \"./types-and-definitions/locale-defs/Locales.js\";\r\nimport type { LinkDownloadType } from \"./tracking/LinkDownloadType.js\";\r\n\r\ninterface TypeCheckFnGeneric {\r\n (value: OrigType): value is T;\r\n}\r\n\r\ninterface TypeCheckFn extends TypeCheckFnGeneric {\r\n (value: unknown): value is T;\r\n} \r\n\r\ninterface TypeCheckFnGenericWithArgs {\r\n (value: OrigType, ...args: any[]): value is T;\r\n}\r\n\r\n\r\ninterface TypeCheckFnWithArgs extends TypeCheckFnGenericWithArgs {\r\n (value: unknown, ...args: any[]): value is T;\r\n}\r\n\r\ninterface TypeCheckFnWithSingleArg extends TypeCheckFnWithArgs {\r\n (value: unknown, arg1: A1, ...args: any[]): value is T;\r\n}\r\n\r\nfunction hasPropWithType(\r\n val: object,\r\n prop: TKey,\r\n typeCheckFn: TypeCheckFn\r\n): val is Record {\r\n return prop in val && typeCheckFn(val[prop as string]);\r\n}\r\n\r\nfunction hasOptionalPropWithType(\r\n val: object,\r\n prop: TKey,\r\n typeCheckFn: TypeCheckFn\r\n): val is Partial> {\r\n return !(prop in val) || typeCheckFn(val[prop as string]);\r\n}\r\n\r\nfunction checkConditionOrThrow(value: T, condition: ((val: T) => boolean), throwOnMissing: boolean, errorMessage: string): value is T2 {\r\n if (condition(value)) {\r\n return true;\r\n }\r\n else if (throwOnMissing) {\r\n throw new Error(errorMessage);\r\n }\r\n else return false;\r\n}\r\n\r\nfunction checkIsTypeOrThrow(value: T, condition: TypeCheckFnGeneric, throwOnMissing: boolean, errorMessage: string): value is T2 {\r\n return checkConditionOrThrow(value, condition, throwOnMissing, errorMessage);\r\n}\r\n\r\nfunction formatErrorMessage(messageLabel: string, ...errors: unknown[]) {\r\n const message = errors.map(err => {\r\n return ((err as Error)?.message ?? \"ERROR IS NULL\")\r\n ?.split('\\n')\r\n ?.map(e => ` ${e}`) // Indent\r\n .join('\\n');\r\n }).join(\"\\n\\n\"); // Double space between errors\r\n return `${messageLabel}: \\n${message}`;\r\n}\r\n\r\n\r\nconst InternalDataVersion = [\"Create\", \"Parse\", \"Final\"] as const;\r\ntype InternalDataVersion = (typeof InternalDataVersion)[number];\r\n\r\nconst UserDataVersion = [\"Create\", \"Final\"] as const satisfies readonly InternalDataVersion[];\r\ntype UserDataVersion = (typeof UserDataVersion)[number];\r\n\r\nexport const DataVersion = UserDataVersion;\r\nexport type DataVersion = UserDataVersion;\r\n\r\ninterface BaseResource {\r\n id: string;\r\n legacyId: string;\r\n salesforceOfferId?: string | Nil;\r\n title: string;\r\n gatingLevel: \"Full Gate\" | \"Partial Gate\" | \"Ungated\";\r\n language: \"en\" | Exclude\r\n}\r\n\r\nexport interface DocumentResource extends BaseResource {\r\n description?: string | Nil;\r\n docType: string;\r\n icon?: string | Nil;\r\n iconAltText?: string | Nil;\r\n thumbnail?: string | Nil;\r\n thumbnailAltText?: string | Nil;\r\n CoverImage?: string | Nil;\r\n AltText?: string | Nil;\r\n}\r\n\r\nexport interface VideoResource extends BaseResource {\r\n description: string,\r\n youTubeId: string;\r\n runtime?: string | Nil;\r\n}\r\n\r\nexport interface VideoResourceWithDocs extends BaseResource, VideoResource {\r\n documentList: DocumentResource[];\r\n}\r\n\r\nfunction isBaseResource(val: unknown, throwOnMissing = false): val is BaseResource {\r\n return (\r\n checkIsTypeOrThrow(val, isObject, throwOnMissing, `resource is not an object`) &&\r\n checkConditionOrThrow(val, x => hasPropWithType(x, \"id\", isString), throwOnMissing, `resource does not gave property 'id' of type string`) &&\r\n checkConditionOrThrow(val, x => {\r\n return hasOptionalPropWithType(x, \"legacyId\", isString) || hasOptionalPropWithType<\"legacyId\", Nil>(val, \"legacyId\", isNil);\r\n }, throwOnMissing, `resource does not have property 'legacyId' of type string | Nil`) &&\r\n checkConditionOrThrow(val, x => hasPropWithType(x, \"title\", isString), throwOnMissing, `resource does not have property 'title' of type string`) \r\n //checkConditionOrThrow(val, x => hasOptionalPropWithType(x, \"salesforceOfferId\", isString), throwOnMissing, `resource does not have property 'salesforceOfferId' of type string`)\r\n );\r\n}\r\n\r\nfunction isDocument(val: unknown, throwOnMissing = false): val is DocumentResource {\r\n try {\r\n return checkIsTypeOrThrow(val, ((x: unknown) => isBaseResource(x, throwOnMissing)) as TypeCheckFn, throwOnMissing, `document is not of type BaseResource`) &&\r\n checkConditionOrThrow(val, x => hasOptionalPropWithType(x, \"description\", (y => (isString(y) || isNil(y))) as TypeCheckFn), throwOnMissing, `document does not have property 'description' of type string | Nil`) &&\r\n checkConditionOrThrow(val, x => hasPropWithType(x, \"docType\", isString), throwOnMissing, `document does not have property 'docType' of type string`) &&\r\n checkConditionOrThrow(val, x => hasPropWithType(x, \"icon\", isString), throwOnMissing, `document does not have property 'icon' of type string`);\r\n }\r\n catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isDocument\", err), { cause: err });\r\n }\r\n}\r\n\r\nfunction isVideoOnly(val: unknown): val is VideoResource {\r\n return isBaseResource(val) && hasPropWithType(val, \"youTubeId\", isString);\r\n}\r\n\r\nfunction isVideoWithDocs(val: unknown): val is VideoResourceWithDocs {\r\n return isVideoOnly(val) && hasPropWithType(val, \"documentList\", isDocumentArray);\r\n}\r\n\r\nexport function isDocumentArray(val: unknown): val is DocumentResource[] {\r\n return isArrayOfType(val, isDocument);\r\n}\r\n\r\nexport function isVideoArray(val: unknown): val is VideoResource[] {\r\n return isArrayOfType(val, isVideoOnly);\r\n}\r\n\r\nexport function isVideoWithDocsArray(val: unknown): val is VideoResourceWithDocs[] {\r\n return isArrayOfType(val, isVideoWithDocs);\r\n}\r\n\r\ninterface CreateDocumentObjectProperties {\r\n isFilteredOrChosen?: boolean;\r\n selectedListWillBeSingleDocument?: boolean;\r\n sourceList: DocumentResource[];\r\n}\r\n\r\ntype ParsedDocumentObjectProperties = Required;\r\n\r\ninterface CreateVideoObjectProperties {\r\n isFilteredOrChosen?: boolean;\r\n sourceList: TVideo[];\r\n}\r\n\r\ntype ParsedVideoObjectProperties = Required>;\r\n\r\ninterface SelectedSingleResource {\r\n selected: TResource;\r\n}\r\n\r\ninterface SelectedMultiResource {\r\n selected: TResource[];\r\n}\r\n\r\nfunction isCreateDocumentObjectProperties(val: unknown): val is CreateDocumentObjectProperties {\r\n return (\r\n isObject(val) &&\r\n hasOptionalPropWithType(val, \"isFilteredOrChosen\", isBoolean) &&\r\n hasOptionalPropWithType(val, \"selectedListWillBeSingleDocument\", isBoolean) &&\r\n hasPropWithType(val, \"sourceList\", isDocumentArray)\r\n );\r\n}\r\n\r\nfunction isParsedDocumentObjectProperties(\r\n val: unknown\r\n): val is ParsedDocumentObjectProperties {\r\n return (\r\n isObject(val) &&\r\n hasPropWithType(val, \"isFilteredOrChosen\", isBoolean) &&\r\n hasPropWithType(val, \"selectedListWillBeSingleDocument\", isBoolean) &&\r\n hasPropWithType(val, \"sourceList\", isDocumentArray)\r\n );\r\n}\r\n\r\nfunction isSelectedSingleResource<\r\n TResource extends DocumentResource | VideoResource | VideoResourceWithDocs\r\n>(\r\n val: unknown,\r\n typeCheckFn: TypeCheckFn\r\n): val is SelectedSingleResource {\r\n return isObject(val) && hasPropWithType(val, \"selected\", typeCheckFn);\r\n}\r\n\r\nfunction isSelectedMultiResource(\r\n val: unknown,\r\n typeCheckFn: TypeCheckFnWithSingleArg,\r\n throwOnMissing = false,\r\n): val is SelectedMultiResource {\r\n try {\r\n return checkIsTypeOrThrow(val, isObject, throwOnMissing, `selectedMultiResource<> is not an object`) &&\r\n checkConditionOrThrow(val, x => hasPropWithType(x, \"selected\", isArray), throwOnMissing, `selectedMultiResource<>.selected is not an array: ${JSON.stringify(val)}`) &&\r\n checkConditionOrThrow(\r\n val.selected,\r\n x => isArrayOfType(x, y => typeCheckFn(y, throwOnMissing)),\r\n throwOnMissing,\r\n `selectedMultiResource<>.selected is not of type TResource[]: ${JSON.stringify(val.selected)}`\r\n );\r\n }\r\n catch(err: unknown) {\r\n throw new Error(formatErrorMessage(\"isSelectedMultiResource\", err), { cause: err });\r\n }\r\n}\r\n\r\nfunction isCreateVideoObjectProperties(\r\n val: unknown\r\n): val is CreateVideoObjectProperties {\r\n return (\r\n isObject(val) &&\r\n hasOptionalPropWithType(val, \"isFilteredOrChosen\", isBoolean) &&\r\n hasPropWithType(val, \"sourceList\", isVideoArray)\r\n );\r\n}\r\n\r\nfunction isCreateVideoWithDocsObjectProperties(\r\n val: unknown\r\n): val is CreateVideoObjectProperties {\r\n return (\r\n isObject(val) &&\r\n hasOptionalPropWithType(val, \"isFilteredOrChosen\", isBoolean) &&\r\n hasPropWithType(val, \"sourceList\", isVideoWithDocsArray)\r\n );\r\n}\r\n\r\nfunction isParsedVideoObjectProperties(\r\n val: unknown\r\n): val is ParsedVideoObjectProperties {\r\n return (\r\n isObject(val) &&\r\n hasPropWithType(val, \"isFilteredOrChosen\", isBoolean) &&\r\n hasPropWithType(val, \"sourceList\", isVideoArray)\r\n );\r\n}\r\n\r\nfunction isParsedVideoWithDocsObjectProperties(\r\n val: unknown\r\n): val is ParsedVideoObjectProperties {\r\n return (\r\n isObject(val) &&\r\n hasPropWithType(val, \"isFilteredOrChosen\", isBoolean) &&\r\n hasPropWithType(val, \"sourceList\", isVideoWithDocsArray)\r\n );\r\n}\r\n\r\ninterface Widget {\r\n name: string;\r\n instanceId: string;\r\n variation?: string | Nil;\r\n}\r\n\r\nfunction isWidget(val: unknown): val is Widget {\r\n return (\r\n isObject(val) &&\r\n hasPropWithType(val, \"name\", isString) &&\r\n hasPropWithType(val, \"instanceId\", isString) &&\r\n (hasOptionalPropWithType(val, \"variation\", isString) || hasOptionalPropWithType(val, \"variation\", isNil))\r\n );\r\n}\r\n\r\nexport const FormSetupType = [\"ResourceForm\", \"VideoForm\", \"GatedVideoForm\", \"ContactForm\", \"PostEventForm\", \"MaturityForm\"] as const;\r\nexport type FormSetupType = (typeof FormSetupType)[number];\r\n\r\nexport const SetupType = [\"YouTube\", ...FormSetupType] as const;\r\nexport type SetupType = (typeof SetupType)[number];\r\n\r\nfunction isFormSetupType(val: unknown): val is FormSetupType {\r\n return isString(val) && FormSetupType.includes(val as FormSetupType);\r\n}\r\n\r\nfunction isSetupType(val: unknown): val is SetupType {\r\n return isString(val) && SetupType.includes(val as SetupType);\r\n}\r\n\r\ninterface CreateFormTrackingObject {\r\n usePageOfferId?: boolean | Nil;\r\n offerId?: string | Nil;\r\n ctaText?: string | Nil;\r\n ctaType?: string | Nil;\r\n}\r\n\r\nexport interface FinalFormTrackingObject {\r\n usePageOfferId: boolean;\r\n offerId?: string | Nil;\r\n ctaText?: string | Nil;\r\n ctaType?: LinkDownloadType | Nil;\r\n}\r\n\r\nfunction isCreateFormTrackingObject(\r\n val: unknown\r\n): val is CreateFormTrackingObject {\r\n return (\r\n isObject(val) &&\r\n (hasOptionalPropWithType(val, \"usePageOfferId\", isString) || hasOptionalPropWithType(val, \"usePageOfferId\", isNil)) &&\r\n (hasOptionalPropWithType(val, \"offerId\", isString) || hasOptionalPropWithType(val, \"offerId\", isNil)) &&\r\n (hasOptionalPropWithType(val, \"ctaText\", isString) || hasOptionalPropWithType(val, \"ctaText\", isNil)) &&\r\n (hasOptionalPropWithType(val, \"ctaType\", isString) || hasOptionalPropWithType(val, \"ctaType\", isNil))\r\n );\r\n}\r\n\r\nfunction isFinalFormTrackingObject(\r\n val: unknown,\r\n throwOnMissing = false\r\n): val is FinalFormTrackingObject {\r\n try {\r\n return checkIsTypeOrThrow(val, isObject, throwOnMissing, \"tracking value is not an object!\") &&\r\n checkConditionOrThrow(\r\n val,\r\n x => hasPropWithType(x, \"usePageOfferId\", isBoolean),\r\n throwOnMissing,\r\n `tracking.usePageOfferId is not of type boolean`\r\n ) &&\r\n checkConditionOrThrow(\r\n val,\r\n x => (hasOptionalPropWithType(x, \"offerId\", isString) || hasOptionalPropWithType(val, \"offerId\", isNil)),\r\n throwOnMissing,\r\n `tracking?.offerId is not of type string | Nil`\r\n )\r\n && (hasOptionalPropWithType(val, \"ctaText\", isString) || hasOptionalPropWithType(val, \"ctaText\", isNil))\r\n && (hasOptionalPropWithType(val, \"ctaType\", isString) || hasOptionalPropWithType(val, \"ctaType\", isNil));\r\n }\r\n catch(err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalFormTrackingObject\", err), { cause: err });\r\n }\r\n}\r\n\r\ninterface BaseSetupObject {\r\n type: TSetupType;\r\n}\r\n\r\ntype BaseForm = {\r\n name: string\r\n}\r\n\r\nexport type BaseFormSetupObject<\r\n TDataVersion extends InternalDataVersion,\r\n TFormSetupType extends FormSetupType = FormSetupType,\r\n TFormObject extends BaseForm & Record = BaseForm & Record\r\n> = { type: TFormSetupType; form: TFormObject } & (TDataVersion extends \"Create\" ? { tracking?: CreateFormTrackingObject } : { tracking: FinalFormTrackingObject });\r\n\r\nexport type FormObjectWithDocument<\r\n TDataVersion extends InternalDataVersion,\r\n> = BaseForm & {\r\n document: TDataVersion extends \"Create\"\r\n ? CreateDocumentObjectProperties\r\n : TDataVersion extends \"Parse\"\r\n ? ParsedDocumentObjectProperties\r\n : TDataVersion extends \"Final\"\r\n ? SelectedMultiResource\r\n : never\r\n}\r\n\r\nexport interface FormObjectWithVideo<\r\n TDataVersion extends InternalDataVersion,\r\n TVideo extends VideoResource | VideoResourceWithDocs\r\n> extends BaseForm {\r\n video: TDataVersion extends \"Create\"\r\n ? CreateVideoObjectProperties\r\n : TDataVersion extends \"Parse\"\r\n ? ParsedVideoObjectProperties\r\n : TDataVersion extends \"Final\"\r\n ? SelectedSingleResource\r\n : never;\r\n}\r\n\r\ntype ResourceFormSetup = BaseFormSetupObject>;\r\ntype ContactFormSetup = BaseFormSetupObject;\r\nexport interface YouTubeSetup extends BaseSetupObject {\r\n type: \"YouTube\";\r\n youTubeId: string;\r\n}\r\n\r\nexport type CreateResourceFormSetup = ResourceFormSetup<\"Create\">;\r\ntype ParsedResourceFormSetup = ResourceFormSetup<\"Parse\">;\r\nexport type FinalResourceFormSetup = ResourceFormSetup<\"Final\">;\r\nfunction isBaseSetupObject(val: unknown): val is BaseSetupObject {\r\n return isObject(val) && hasPropWithType(val, \"type\", isSetupType);\r\n}\r\n\r\nfunction isBaseFormSetupObject(\r\n val: unknown,\r\n dataVersion: TDataVersion,\r\n throwOnMissing = false\r\n): val is BaseFormSetupObject {\r\n try {\r\n return (\r\n checkIsTypeOrThrow(\r\n val,\r\n isObject,\r\n throwOnMissing,\r\n \"setup is not an object!\"\r\n ) &&\r\n checkConditionOrThrow(\r\n val,\r\n (x) => hasPropWithType(x, \"type\", isFormSetupType),\r\n throwOnMissing,\r\n `setup does not have a property 'type' that matches a FormSetupType: ${FormSetupType.toString()}`\r\n ) &&\r\n (dataVersion === \"Create\"\r\n ? checkConditionOrThrow(\r\n val,\r\n (x) =>\r\n hasOptionalPropWithType(x, \"tracking\", isCreateFormTrackingObject),\r\n throwOnMissing,\r\n `setup does not have a property \"tracking\" of type CreateFormTrackingObject`\r\n )\r\n : checkConditionOrThrow(\r\n val,\r\n (x) => hasPropWithType(x, \"tracking\", isFinalFormTrackingObject),\r\n throwOnMissing,\r\n `setup does not have a property \"tracking\" of type FinalFormTrackingObject`\r\n )) &&\r\n checkConditionOrThrow(\r\n val,\r\n (x) => hasPropWithType(x, \"form\", isObject),\r\n throwOnMissing,\r\n `setup does not have a property \"form\" of type object`\r\n )\r\n );\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isBaseFormSetupObject\", err), { cause: err });\r\n }\r\n}\r\n\r\nexport function isYoutubeSetup(val: unknown, throwOnMissing = false): val is YouTubeSetup {\r\n try {\r\n return checkIsTypeOrThrow(val, isBaseSetupObject, throwOnMissing, `\"setup\" is not of type \"BaseSetupObject\"`) &&\r\n checkConditionOrThrow(val.type, x => x === \"YouTube\", throwOnMissing, \"type is not equal to 'YouTube'\") &&\r\n checkConditionOrThrow(val, x => hasPropWithType(x, \"youTubeId\", isString), throwOnMissing, \"setup does not have property 'youTubeId' of type string\");\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isYoutubeSetup\", err), { cause: err });\r\n }\r\n}\r\n\r\nfunction isFormObjectWithDocument(\r\n val: unknown,\r\n typeCheckFn: TypeCheckFn<\r\n TDataVersion extends \"Create\"\r\n ? CreateDocumentObjectProperties\r\n : TDataVersion extends \"Parse\"\r\n ? ParsedDocumentObjectProperties\r\n : TDataVersion extends \"Final\"\r\n ? SelectedMultiResource\r\n : never\r\n >\r\n): val is FormObjectWithDocument {\r\n return isObject(val) && hasPropWithType(val, \"document\", typeCheckFn);\r\n}\r\n\r\nfunction isFormObjectWithVideo<\r\n TDataVersion extends InternalDataVersion,\r\n TVideo extends VideoResource | VideoResourceWithDocs\r\n>(\r\n val: unknown,\r\n typeCheckFn: TypeCheckFn<\r\n TDataVersion extends \"Create\"\r\n ? CreateVideoObjectProperties\r\n : TDataVersion extends \"Parse\"\r\n ? ParsedVideoObjectProperties\r\n : TDataVersion extends \"Final\"\r\n ? SelectedSingleResource : never\r\n >\r\n): val is FormObjectWithVideo {\r\n return isObject(val) && hasPropWithType(val, \"video\", typeCheckFn);\r\n}\r\n\r\nfunction isCreateResourceFormSetup(\r\n val: unknown\r\n): val is CreateResourceFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Create\") &&\r\n val.type === \"ResourceForm\" &&\r\n isFormObjectWithDocument(val.form, isCreateDocumentObjectProperties)\r\n );\r\n}\r\n\r\nfunction isParsedResourceFormSetup(\r\n val: unknown\r\n): val is ParsedResourceFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Parse\") &&\r\n val.type === \"ResourceForm\" &&\r\n isFormObjectWithDocument(val.form, isParsedDocumentObjectProperties)\r\n );\r\n}\r\n\r\nfunction isFinalResourceFormSetup(val: unknown, throwOnMissing = false): val is FinalResourceFormSetup {\r\n try {\r\n return checkConditionOrThrow>(val, x => isBaseFormSetupObject<\"Final\">(x, \"Final\", throwOnMissing), throwOnMissing, `\"setup\" is not of type \"BaseFormSetupObject<'Final'>\"`) &&\r\n checkConditionOrThrow(val.type, x => x === \"ResourceForm\", throwOnMissing, \"type is not equal to 'ResourceForm'\") &&\r\n checkConditionOrThrow, BaseFormSetupObject<\"Final\"> & Record<\"form\", object>>(\r\n val,\r\n x => hasPropWithType(x, \"form\", isObject),\r\n throwOnMissing,\r\n \"setup does not have property 'form' of type object\"\r\n ) &&\r\n checkConditionOrThrow>(\r\n val.form,\r\n x => hasPropWithType(x, \"document\", (y => isSelectedMultiResource(y, isDocument, throwOnMissing)) as TypeCheckFn>),\r\n throwOnMissing,\r\n \"'setup.form' is not of type SelectedMultiResource\"\r\n );\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalResourceFormSetup\", err), { cause: err });\r\n }\r\n\r\n}\r\n\r\nexport interface CreateVideoFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Create\", \"VideoForm\", FormObjectWithVideo<\"Create\", VideoResourceWithDocs>> {\r\n type: \"VideoForm\";\r\n form: FormObjectWithVideo<\"Create\", VideoResourceWithDocs>;\r\n}\r\n\r\ninterface ParsedVideoFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Parse\", \"VideoForm\", FormObjectWithVideo<\"Parse\", VideoResourceWithDocs>> {\r\n type: \"VideoForm\";\r\n form: FormObjectWithVideo<\"Parse\", VideoResourceWithDocs>;\r\n}\r\nexport interface FinalVideoFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Final\", \"VideoForm\", FormObjectWithVideo<\"Final\", VideoResourceWithDocs>> {\r\n type: \"VideoForm\";\r\n form: FormObjectWithVideo<\"Final\", VideoResourceWithDocs> & FormObjectWithDocument<\"Final\">;\r\n}\r\n\r\nfunction isCreateVideoFormSetup(val: unknown): val is CreateVideoFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Create\") &&\r\n val.type === \"VideoForm\" &&\r\n hasPropWithType(val, \"form\", isObject) &&\r\n isFormObjectWithVideo(val.form, isCreateVideoWithDocsObjectProperties)\r\n );\r\n}\r\n\r\nfunction isParsedVideoFormSetup(val: unknown): val is ParsedVideoFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Parse\") &&\r\n val.type === \"VideoForm\" &&\r\n hasPropWithType(val, \"form\", isObject) &&\r\n isFormObjectWithVideo(val.form, isParsedVideoWithDocsObjectProperties)\r\n );\r\n}\r\n\r\n\r\nfunction isFinalVideoFormSetup(val: unknown, throwOnMissing = false): val is FinalVideoFormSetup {\r\n try {\r\n return checkConditionOrThrow>(\r\n val, x => isBaseFormSetupObject<\"Final\">(x, \"Final\", throwOnMissing), throwOnMissing, `\"setup\" is not of type \"BaseFormSetupObject<'Final'>\"`) &&\r\n checkConditionOrThrow(val.type, x => x === \"VideoForm\", throwOnMissing, \"type is not equal to 'VideoForm'\") &&\r\n checkConditionOrThrow, BaseFormSetupObject<\"Final\"> & Record<\"form\", object>>(\r\n val,\r\n x => hasPropWithType(x, \"form\", isObject),\r\n throwOnMissing,\r\n \"setup does not have property 'form' of type object\"\r\n ) &&\r\n checkConditionOrThrow>(\r\n val.form,\r\n x => hasPropWithType(x, \"document\", ((y: unknown) => isSelectedMultiResource(y, isDocument, throwOnMissing)) as TypeCheckFn>),\r\n throwOnMissing,\r\n `'setup.form' is not of type SelectedMultiResource`\r\n ) &&\r\n checkConditionOrThrow>(\r\n val.form, (x => {\r\n return isFormObjectWithVideo<\"Final\", VideoResourceWithDocs>(x, (y: unknown) => isSelectedSingleResource(y, isVideoWithDocs)); \r\n }),\r\n throwOnMissing,\r\n \"'setup.form' is not of type SelectedSingleResource\"\r\n );\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalVideoFormSetup\", err), { cause: err });\r\n }\r\n}\r\nexport interface FinalPostEventFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Final\", \"PostEventForm\", FormObjectWithVideo<\"Final\", VideoResource>> {\r\n type: \"PostEventForm\";\r\n form: FormObjectWithVideo<\"Final\", VideoResource> & FormObjectWithDocument<\"Final\">;\r\n gatingLevel: \"Full Gate\" | \"Partial Gate\" | \"Ungated\";\r\n}\r\nexport function isFinalPostEventFormSetup(val: unknown, throwOnMissing = false): val is FinalPostEventFormSetup {\r\n try {\r\n return checkConditionOrThrow>(\r\n val, x => isBaseFormSetupObject<\"Final\">(x, \"Final\", throwOnMissing), throwOnMissing, `\"setup\" is not of type \"BaseFormSetupObject<'Final'>\"`) &&\r\n checkConditionOrThrow(val.type, x => x === \"PostEventForm\", throwOnMissing, \"type is not equal to 'PostEventForm'\") &&\r\n checkConditionOrThrow, BaseFormSetupObject<\"Final\"> & Record<\"form\", object>>(\r\n val,\r\n x => hasPropWithType(x, \"form\", isObject),\r\n throwOnMissing,\r\n \"setup does not have property 'form' of type object\"\r\n ) &&\r\n checkConditionOrThrow | SelectedMultiResource>(\r\n val.form,\r\n x => {\r\n return hasPropWithType(\r\n x,\r\n \"document\",\r\n (y: unknown) => isSelectedMultiResource(y, isDocument, false)\r\n ) ||\r\n isFormObjectWithVideo<\"Final\", VideoResource>(\r\n x,\r\n (y: unknown): y is SelectedSingleResource => isSelectedSingleResource(y, isVideoOnly)\r\n );\r\n }, throwOnMissing,\r\n `'setup.form' is not of type SelectedMultiResource | SelectedMultiResource`\r\n );\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalPostEventFormSetup\", err), { cause: err });\r\n }\r\n}\r\n\r\nexport interface CreateGatedVideoFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Create\", \"GatedVideoForm\", FormObjectWithVideo<\"Create\", VideoResource>> {\r\n type: \"GatedVideoForm\";\r\n form: FormObjectWithVideo<\"Create\", VideoResource>;\r\n}\r\ninterface ParsedGatedVideoFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Parse\", \"GatedVideoForm\", FormObjectWithVideo<\"Parse\", VideoResource>> {\r\n type: \"GatedVideoForm\";\r\n form: FormObjectWithVideo<\"Parse\", VideoResource>;\r\n}\r\nexport interface FinalGatedVideoFormSetup extends BaseSetupObject, BaseFormSetupObject<\"Final\", \"GatedVideoForm\", FormObjectWithVideo<\"Final\", VideoResource>> {\r\n type: \"GatedVideoForm\";\r\n form: FormObjectWithVideo<\"Final\", VideoResource>;\r\n}\r\n\r\nfunction isCreateGatedVideoFormSetup(\r\n val: unknown\r\n): val is CreateGatedVideoFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Create\") &&\r\n val.type === \"GatedVideoForm\" &&\r\n hasPropWithType(val, \"form\", isObject) &&\r\n isFormObjectWithVideo(val.form, isCreateVideoObjectProperties)\r\n );\r\n}\r\n\r\nfunction isParsedGatedVideoFormSetup(\r\n val: unknown\r\n): val is ParsedGatedVideoFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Create\") &&\r\n val.type === \"GatedVideoForm\" &&\r\n hasPropWithType(val, \"form\", isObject) &&\r\n isFormObjectWithVideo(val.form, isParsedVideoObjectProperties)\r\n );\r\n}\r\n\r\nfunction isFinalGatedVideoFormSetup(val: unknown, throwOnMissing = false): val is FinalGatedVideoFormSetup {\r\n try {\r\n return checkConditionOrThrow>(val, x => isBaseFormSetupObject<\"Final\">(x, \"Final\", throwOnMissing), throwOnMissing, `\"setup\" is not of type \"BaseFormSetupObject<'Final'>\"`) &&\r\n checkConditionOrThrow(val.type, x => x === \"GatedVideoForm\", throwOnMissing, \"type is not equal to 'GatedVideoForm'\") &&\r\n checkConditionOrThrow, BaseFormSetupObject<\"Final\"> & Record<\"form\", object>>(\r\n val,\r\n x => hasPropWithType(x, \"form\", isObject),\r\n throwOnMissing,\r\n \"setup does not have property 'form' of type object\"\r\n ) &&\r\n checkConditionOrThrow>(\r\n val.form, (x => {\r\n return isFormObjectWithVideo<\"Final\", VideoResource>(x, ((y) => isSelectedSingleResource(y, isVideoOnly)) as TypeCheckFn>); }),\r\n throwOnMissing,\r\n \"'setup.form' is not of type SelectedSingleResource\"\r\n );\r\n }\r\n catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalGatedVideoFormSetup\", err), { cause: err });\r\n }\r\n}\r\n\r\n\r\nexport type FinalContactFormSetup = ContactFormSetup<\"Final\">;\r\n\r\nfunction isFinalContactFormSetup(val: unknown, throwOnMissing = false): val is FinalContactFormSetup {\r\n return (\r\n isBaseFormSetupObject(val, \"Final\", throwOnMissing) &&\r\n val.type === \"ContactForm\" &&\r\n hasPropWithType(val, \"form\", isObject)\r\n );\r\n}\r\n\r\nexport type AnyCreateSetupObject =\r\n | YouTubeSetup\r\n | CreateResourceFormSetup\r\n | CreateVideoFormSetup\r\n | CreateGatedVideoFormSetup;\r\n\r\nexport type AnyParsedSetupObject =\r\n | YouTubeSetup\r\n | ParsedResourceFormSetup\r\n | ParsedVideoFormSetup\r\n | ParsedGatedVideoFormSetup;\r\n\r\nexport type AnyAppStateFinalSetupObject =\r\n | YouTubeSetup\r\n | FinalResourceFormSetup\r\n | FinalVideoFormSetup\r\n | FinalGatedVideoFormSetup\r\n | FinalPostEventFormSetup;\r\n\r\nexport type AnyOtherFinalSetupObject = FinalContactFormSetup;\r\n\r\nexport type AnyFormFinalSetupObject =\r\n | FinalResourceFormSetup\r\n | FinalVideoFormSetup\r\n | FinalGatedVideoFormSetup\r\n | FinalContactFormSetup\r\n | FinalPostEventFormSetup;\r\n\r\nexport function isAnyFormFinalSetupObject(value: unknown, throwOnMissing = false): value is AnyFormFinalSetupObject {\r\n try {\r\n if (checkConditionOrThrow(value, isObject, throwOnMissing, \"'setup' value is not an object\")) {\r\n const errors: unknown[] = [];\r\n try { if (isFinalResourceFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalVideoFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalGatedVideoFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalContactFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalPostEventFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n if (errors.length > 0 && throwOnMissing) {\r\n throw new Error(formatErrorMessage(\"setup is not of type 'AnyFormFinalSetupObject'\", ...errors), { cause: errors });\r\n }\r\n }\r\n return false;\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isAnyFormFinalSetupObject\", err), { cause: err });\r\n }\r\n}\r\n\r\nexport type CreateSingleSetupObject = SetupObjectTypes;\r\ntype ParsedSingleSetupObject = SetupObjectTypes; \r\nexport type FinalAppStateSingleSetupObject = SetupObjectTypes;\r\nexport type FinalOtherSingleSetupObject = SetupObjectTypes;\r\n\r\nfunction isCreateSingleSetupObject(value: unknown): value is CreateSingleSetupObject {\r\n return isBaseSetupObject(value) && (\r\n isYoutubeSetup(value) || isCreateResourceFormSetup(value) || isCreateVideoFormSetup(value) || isCreateGatedVideoFormSetup(value)\r\n );\r\n}\r\nfunction isParsedSingleSetupObject(value: unknown): value is ParsedSingleSetupObject {\r\n return isBaseSetupObject(value) && (\r\n isYoutubeSetup(value) || isParsedResourceFormSetup(value) || isParsedVideoFormSetup(value) || isParsedGatedVideoFormSetup(value)\r\n );\r\n}\r\n\r\nfunction isFinalAppStateSingleSetupObject(value: unknown, throwOnMissing = false): value is FinalAppStateSingleSetupObject {\r\n try {\r\n if (checkConditionOrThrow(value, isBaseSetupObject, throwOnMissing, \"'setup' value is not of type BaseSetupObject\")) {\r\n const errors: unknown[] = [];\r\n try { if (isYoutubeSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalResourceFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalVideoFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n try { if (isFinalGatedVideoFormSetup(value, throwOnMissing)) { return true; } } catch (err: unknown) { errors.push(err); }\r\n if (errors.length > 0 && throwOnMissing) {\r\n throw new Error(formatErrorMessage(\"setup is not of type 'FinalAppStateSingleSetupObject'\", errors), { cause: errors });\r\n }\r\n }\r\n return false;\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalAppStateSingleSetupObject\", err), { cause: err });\r\n }\r\n}\r\n\r\nfunction isFinalOtherSingleSetupObject(value: unknown): value is FinalOtherSingleSetupObject {\r\n return isBaseSetupObject(value) && isFinalContactFormSetup(value);\r\n}\r\n\r\ninterface BaseMultiSetupObject extends BaseSetupObject {\r\n setupName: string;\r\n}\r\nfunction isBaseMultiSetupObject(value: unknown): value is BaseMultiSetupObject {\r\n return isBaseSetupObject(value) && hasPropWithType(value, \"setupName\", isString);\r\n}\r\n\r\nexport type CreateMultipleSetupObject = CreateSingleSetupObject> = BaseMultiSetupObject & TSetup;\r\ntype ParsedMultipleSetupObject = ParsedSingleSetupObject> = BaseMultiSetupObject & TSetup;\r\nexport type FinalMultipleSetupObject = FinalAppStateSingleSetupObject> = BaseMultiSetupObject & TSetup;\r\n\r\nfunction isCreateMultipleSetupObject(value: unknown): value is CreateMultipleSetupObject {\r\n return isBaseMultiSetupObject(value) && isCreateSingleSetupObject(value);\r\n}\r\nfunction isParsedMultipleSetupObject(value: unknown): value is ParsedMultipleSetupObject {\r\n return isBaseMultiSetupObject(value) && isParsedSingleSetupObject(value);\r\n}\r\nfunction isFinalMultipleSetupObject(value: unknown, throwOnMissing = false): value is FinalMultipleSetupObject {\r\n try {\r\n return isFinalAppStateSingleSetupObject(value, throwOnMissing) && isBaseMultiSetupObject(value);\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalMultipleSetupObject\", err), { cause: err });\r\n }\r\n}\r\n\r\nexport interface CreateWidgetData {\r\n widget: Widget;\r\n setup:\r\n | (\r\n AllowSingleItemInSetup extends true\r\n ? CreateSingleSetupObject | [CreateSingleSetupObject]\r\n : [CreateSingleSetupObject] \r\n ) \r\n | [CreateMultipleSetupObject, ...CreateMultipleSetupObject[]];\r\n}\r\n\r\ninterface ParsedWidgetData {\r\n widget: Widget;\r\n setup: SingleItemSetup extends true\r\n ? (ParsedSingleSetupObject | ParsedMultipleSetupObject)\r\n : ([ParsedSingleSetupObject] | [ParsedMultipleSetupObject, ...ParsedMultipleSetupObject[]]);\r\n}\r\n\r\nexport interface FinalWidgetData {\r\n widget: Widget;\r\n setup: SetupObjectTypes extends AnyAppStateFinalSetupObject\r\n ? (FinalAppStateSingleSetupObject | FinalMultipleSetupObject)\r\n : (SetupObjectTypes extends AnyOtherFinalSetupObject? FinalOtherSingleSetupObject : never)\r\n}\r\n\r\nexport function isCreateWidgetData(value: unknown, allowSingleItemInSetup: AllowSingleItemInSetup): value is CreateWidgetData {\r\n return isObject(value) &&\r\n hasPropWithType(value, \"widget\", isWidget) &&\r\n hasPropWithType(value, \"setup\", (x => {\r\n return (allowSingleItemInSetup && isCreateSingleSetupObject(x)) || (\r\n isArray(x) &&\r\n x.length > 0 && (\r\n (x.length === 1 && isArrayOfType(x, isCreateSingleSetupObject)) ||\r\n isArrayOfType(x, isCreateMultipleSetupObject)\r\n )\r\n );\r\n }) as TypeCheckFn[\"setup\"]>);\r\n}\r\n\r\nfunction isParsedWidgetData(value: unknown, singleItemInSetup: SingleItemSetup): value is ParsedWidgetData {\r\n return isObject(value) &&\r\n hasPropWithType(value, \"widget\", isWidget) &&\r\n hasPropWithType(value, \"setup\", (x => {\r\n return (singleItemInSetup && isParsedSingleSetupObject(x)) || (\r\n isArray(x) && x.length > 0 && (\r\n (x.length === 1\r\n ? isArrayOfType(x, isParsedSingleSetupObject)\r\n : isArrayOfType(x, isParsedMultipleSetupObject)\r\n )\r\n ));\r\n }) as TypeCheckFn[\"setup\"]>);\r\n}\r\n\r\nfunction isObjectWithWidgetProp(value: object, throwOnMissing: boolean): value is object & Record<\"widget\", Widget> {\r\n return checkConditionOrThrow>(value, (x => hasPropWithType(x, \"widget\", isWidget)), throwOnMissing, \"'value.widget' is not a widget object: \" + JSON.stringify(value));\r\n}\r\n\r\nfunction isObjectWithFinalSetupProp(value: object, throwOnMissing = false): value is object & Record<\"setup\", AnyAppStateFinalSetupObject[] | AnyOtherFinalSetupObject[]> {\r\n try {\r\n if (\"setup\" in value) {\r\n if (isArray(value.setup)) {\r\n if (value.setup.length === 1) {\r\n return checkConditionOrThrow(\r\n value.setup,\r\n x => (isArrayOfType(x, y => isFinalAppStateSingleSetupObject(y, throwOnMissing)) || isArrayOfType(x, isFinalOtherSingleSetupObject)),\r\n throwOnMissing,\r\n \"'value.setup' is not an array of type AnyAppStateFinalSetupObject or AnyOtherFinalSetupObject: \" + JSON.stringify(value.setup)\r\n );\r\n }\r\n else {\r\n return checkConditionOrThrow(value.setup, (x => isArrayOfType(x, isFinalMultipleSetupObject)),\r\n throwOnMissing,\r\n \"'value.setup' is not an array of type FinalMultipleSetupObject: \" + JSON.stringify(value.setup)\r\n );\r\n }\r\n }\r\n else {\r\n return checkConditionOrThrow(\r\n value.setup,\r\n x => {\r\n return isFinalAppStateSingleSetupObject(x, throwOnMissing) || isFinalOtherSingleSetupObject(x);\r\n },\r\n throwOnMissing,\r\n \"'value.setup' is not an object of type AnyAppStateFinalSetupObject or AnyOtherFinalSetupObject: \" + JSON.stringify(value.setup)\r\n );\r\n }\r\n }\r\n else {\r\n throw new Error(\"'value.setup' is not defined\");\r\n }\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isObjectWithFinalSetupProp\", err), { cause: err });\r\n }\r\n\r\n}\r\n\r\nexport function isFinalWidgetData(value: unknown, throwOnMissing = false): value is FinalWidgetData {\r\n try {\r\n return checkIsTypeOrThrow(value, isObject, throwOnMissing, \"'value' is not an object.\") &&\r\n isObjectWithWidgetProp(value, throwOnMissing) &&\r\n isObjectWithFinalSetupProp(value, throwOnMissing);\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFinalWidgetData\", err), { cause: err });\r\n }\r\n}\r\n\r\ntype SetupTypeToFinalSetupObject =\r\n TSetup extends \"YouTubeSetup\"\r\n ? YouTubeSetup\r\n : TSetup extends \"ResourceForm\"\r\n ? ResourceFormSetup<\"Final\">\r\n : TSetup extends \"VideoForm\"\r\n ? FinalVideoFormSetup\r\n : TSetup extends \"PostEventForm\"\r\n ? FinalPostEventFormSetup\r\n : TSetup extends \"GatedVideoForm\"\r\n ? FinalGatedVideoFormSetup\r\n : TSetup extends \"ContactForm\"\r\n ? ContactFormSetup<\"Final\">\r\n : never;\r\n\r\nexport type FormWidgetData = FinalWidgetData>;\r\nexport function isFormWidgetData(\r\n value: unknown,\r\n setupType?: TSetupType | TSetupType[],\r\n throwOnMissing = false\r\n): value is (typeof setupType extends Nil? FormWidgetData : FormWidgetData) {\r\n try {\r\n setupType ??= FormSetupType as unknown as TSetupType[];\r\n setupType = (isArray(setupType) ? setupType : [setupType]);\r\n return checkIsTypeOrThrow(value, isObject, throwOnMissing, \"'value' is not an object.\") &&\r\n isObjectWithWidgetProp(value, throwOnMissing) &&\r\n (\"setup\" in value) &&\r\n isAnyFormFinalSetupObject(value.setup, throwOnMissing) &&\r\n checkConditionOrThrow>(\r\n value.setup,\r\n (s) => (setupType as string[]).includes(s.type),\r\n throwOnMissing,\r\n `setup type of type ${value.setup.type} does not match any of the provided types in ${setupType.toString()}`\r\n );\r\n } catch (err: unknown) {\r\n throw new Error(formatErrorMessage(\"isFormWidgetData\", err), {cause: err });\r\n }\r\n}\r\n\r\nfunction assignDefaultValues(dataObj: CreateWidgetData) {\r\n dataObj.setup = isArray(dataObj.setup) ? dataObj.setup : [dataObj.setup];\r\n\r\n // Iterate through each setup object and assign default values\r\n dataObj.setup.forEach((setup) => {\r\n // Defaults for \"form\" property\r\n if (isBaseFormSetupObject(setup, \"Create\")) {\r\n const form = setup.form;\r\n // Defaults for \"document\" property\r\n if (isFormObjectWithDocument(form, isCreateDocumentObjectProperties)) {\r\n const document = form.document;\r\n // \"selectedListWillBeSingleDocument\" defaults to false unless sourceList contains only one document and sourceList is not being filtered\r\n document.selectedListWillBeSingleDocument ??=\r\n (document.sourceList || []).length === 1 &&\r\n document.isFilteredOrChosen !== true;\r\n // \"isFilteredOrChosen\" defaults to false\r\n document.isFilteredOrChosen ??= false;\r\n\r\n // \"description\" defaults to \"\" for all documents\r\n const sourceList = document.sourceList;\r\n sourceList.forEach((doc) => {\r\n doc.description = doc.description ?? \"\";\r\n });\r\n }\r\n\r\n // Defaults for \"video\" property\r\n\r\n if (isFormObjectWithVideo(form, isCreateVideoObjectProperties)) {\r\n const video = (form.video as CreateVideoObjectProperties);\r\n // \"isFilteredOrChosen\" defaults to false\r\n video.isFilteredOrChosen = video.isFilteredOrChosen ?? false;\r\n }\r\n\r\n if (isBaseFormSetupObject(setup, \"Create\")) {\r\n // Set the default \"tracking.usePageOfferId\" setting to false\r\n setup.tracking ??= { usePageOfferId: false };\r\n setup.tracking.usePageOfferId ??= false;\r\n }\r\n }\r\n });\r\n return dataObj as unknown as CreateWidgetData;\r\n}\r\n\r\nfunction removeUnwantedProps(setup: CreateSingleSetupObject) {\r\n if (isObject(setup) && [\"YouTube\", \"GatedVideoForm\"].includes(setup.type)) {\r\n if (hasPropWithType(setup, \"form\", isObject) && hasPropWithType(setup.form, \"video\", isObject)) {\r\n setup.form.video.sourceList.forEach((el) => {\r\n if (hasPropWithType(el, \"documentList\", isArray)) {\r\n delete (el as Partial).documentList;\r\n }\r\n });\r\n }\r\n }\r\n}\r\n\r\nconst getModifiers = {\r\n setupName(widgetDataObj: ParsedWidgetData, setupName?: string): ParsedWidgetData {\r\n const { setup, ...remainingWidgetData } = widgetDataObj;\r\n\r\n if (setup.length === 1) {\r\n return { setup: setup[0], ...remainingWidgetData };\r\n } else {\r\n const setupItem = setup.find(\r\n (s) => (\"setupName\" in s) && s.setupName === setupName\r\n );\r\n if (isNil(setupItem)) {\r\n throw new Error(\"Couldn't find setupName: \" + (setupName ?? \"NULL\"));\r\n }\r\n return {\r\n setup: setupItem,\r\n ...remainingWidgetData,\r\n };\r\n }\r\n },\r\n videoSelector(widgetDataObj: ParsedWidgetData & Partial>, videoId: string) {\r\n const { setup, ...remainingWidgetData } = widgetDataObj;\r\n if (hasPropWithType(setup, \"form\", isObject) && isFormObjectWithVideo(setup.form, isParsedVideoObjectProperties)) {\r\n const { form, ...remainingSetup } = setup;\r\n const video = (form.video as ParsedVideoObjectProperties).sourceList.find((vid) => {\r\n return vid.id === videoId;\r\n }) as VideoResource | VideoResourceWithDocs | Nil;\r\n if (isNil(video)) {\r\n throw new Error(\"Could not find video with ID: \" + videoId);\r\n }\r\n (form.video as unknown as SelectedSingleResource).selected = video;\r\n if (\"documentList\" in video) {\r\n return {\r\n ...remainingWidgetData,\r\n setup: {\r\n ...remainingSetup,\r\n form: {\r\n ...form,\r\n document: { selected: video.documentList },\r\n },\r\n },\r\n };\r\n }\r\n return {\r\n ...remainingWidgetData,\r\n setup: { ...remainingSetup, form },\r\n };\r\n }\r\n return widgetDataObj;\r\n },\r\n documentSelector(widgetDataObj: ParsedWidgetData, documentIds: string[]) {\r\n if (\"form\" in widgetDataObj.setup && \"document\" in widgetDataObj.setup.form) {\r\n if (documentIds.length === 0) {\r\n ((widgetDataObj.setup as unknown as FinalResourceFormSetup).form.document).selected =\r\n [...(widgetDataObj.setup as unknown as ParsedResourceFormSetup).form.document.sourceList];\r\n } else {\r\n const documents = (widgetDataObj.setup as unknown as ParsedResourceFormSetup).form.document.sourceList.filter((doc) => {\r\n return documentIds.includes(doc.id);\r\n });\r\n (widgetDataObj.setup as unknown as FinalResourceFormSetup).form.document.selected = documents;\r\n }\r\n }\r\n return widgetDataObj;\r\n },\r\n\r\n cleanup(widgetDataObj: FinalWidgetData) {\r\n const setup = widgetDataObj.setup;\r\n\r\n if (isBaseFormSetupObject(setup, \"Parse\")) {\r\n const tracking = setup.tracking;\r\n if (tracking && \"usePageOfferId\" in tracking && tracking.usePageOfferId === true) {\r\n tracking.offerId = window.AppState.PageOfferId as string | Nil;\r\n }\r\n if (isParsedVideoFormSetup(setup) || isParsedGatedVideoFormSetup(setup)) {\r\n if (\"sourceList\" in setup.form.video) {\r\n if (\"selected\" in setup.form.video === false) {\r\n if ((setup.form.video as any).sourceList.length === 1) {\r\n (setup.form.video as unknown as SelectedSingleResource).selected = ((setup.form.video as any).sourceList[0] as (VideoResource | VideoResourceWithDocs));\r\n const selected = (setup.form.video as SelectedSingleResource).selected;\r\n const docList = \"documentList\" in selected ? selected.documentList : [];\r\n\r\n if (docList.length > 0) {\r\n (setup as FinalVideoFormSetup).form.document = { selected: docList };\r\n }\r\n }\r\n else {\r\n throw new Error(\"WidgetData.Get: Videos were not filtered, more than one is being returned.\");\r\n }\r\n }\r\n delete (setup.form.video as Partial>).sourceList;\r\n delete (setup.form.video as unknown as { documentList: any }).documentList;\r\n }\r\n if (\"offerId\" in tracking === false && isArray(setup.form.video.selected) === false) {\r\n tracking.offerId = setup.form.video.selected.salesforceOfferId;\r\n }\r\n delete setup.form.video.selected.salesforceOfferId;\r\n }\r\n else if (isParsedResourceFormSetup(setup)) {\r\n if (\"sourceList\" in setup.form.document) {\r\n if (\"selected\" in setup.form.document === false) {\r\n (setup.form.document as unknown as SelectedMultiResource).selected = [...((setup.form.document as any).sourceList as DocumentResource[])];\r\n }\r\n delete (setup.form.document as Partial).sourceList;\r\n }\r\n if (\"offerId\" in tracking === false && setup.form.document.selectedListWillBeSingleDocument) {\r\n tracking.offerId = setup.form.document.selected[0].salesforceOfferId;\r\n }\r\n delete (setup.form.document as Partial).selectedListWillBeSingleDocument;\r\n delete (setup.form.document as Partial).isFilteredOrChosen;\r\n // [setup.form.document.selected].flat().forEach((doc) => {\r\n // delete doc.salesforceOfferId;\r\n // });\r\n }\r\n }\r\n return setup as unknown as FinalWidgetData;\r\n },\r\n} as const;\r\n\r\ntype ModifierKeys = keyof typeof getModifiers;\r\n\r\nexport type ModifiersObj = {\r\n [K in ModifierKeys]?: Parameters[1] | undefined\r\n}\r\n\r\nconst rawDataArray: ParsedWidgetData[] = [];\r\n\r\nexport function AddWidgetData (widgetDataObj: CreateWidgetData) {\r\n if (isNil(widgetDataObj)) {\r\n console.error(\r\n \"WidgetData.Add: Main Parameter 'widgetDataObj' is not set.\"\r\n );\r\n return;\r\n }\r\n\r\n else if (isCreateWidgetData(widgetDataObj, true) === false) {\r\n throw new Error(\"WidgetData doesn't match the type definition\");\r\n }\r\n\r\n // Assign default values before checking for required props\r\n const parsed = assignDefaultValues(widgetDataObj);\r\n // Check top level widgetDataObj requirements are met\r\n if (hasPropWithType(parsed, \"setup\", isArray)) {\r\n parsed.setup.forEach((setup) => {\r\n if (hasPropWithType(setup, \"tracking\", isObject) && hasPropWithType(setup.tracking, \"salesforce\", isObject)) {\r\n setup.tracking = { ...setup.tracking.salesforce, ...setup.tracking };\r\n }\r\n removeUnwantedProps(setup);\r\n });\r\n }\r\n\r\n rawDataArray.push(parsed as ParsedWidgetData);\r\n\r\n if (isParsedWidgetData(parsed, false) === false) {\r\n throw new Error(\"Parsed widget data does not match the type definition.\");\r\n }\r\n}\r\n\r\nexport function GetWidgetData(widgetInstanceId: string, modifiersObj?: ModifiersObj | undefined): FinalWidgetData {\r\n modifiersObj = modifiersObj || {};\r\n const originalWidgetDataObj = rawDataArray.find(function (data) {\r\n return data.widget.instanceId === widgetInstanceId;\r\n });\r\n // Clone the widget data since we're making changes to the result\r\n const rawWidgetDataObj = JSON.parse(\r\n JSON.stringify(originalWidgetDataObj)\r\n ) as ParsedWidgetData;\r\n\r\n const widgetDataObj = getModifiers.setupName(rawWidgetDataObj, modifiersObj.setupName);\r\n if (hasPropWithType(modifiersObj, \"setupName\", isString)) {\r\n delete (modifiersObj as Partial).setupName;\r\n }\r\n\r\n // Iterate through passed modifiers\r\n if (isObject(modifiersObj)) {\r\n (Object.keys(modifiersObj) as ModifierKeys[]).forEach((key: ModifierKeys) => {\r\n if (key in getModifiers && modifiersObj && (isNil(modifiersObj?.[key]) === false)) {\r\n (getModifiers[key] as (...args: any[]) => void)(\r\n widgetDataObj,\r\n modifiersObj[key]\r\n );\r\n } else {\r\n console.error(\r\n `WidgetData.Get: getModifiers does not contain the key '${key}'`\r\n );\r\n }\r\n });\r\n }\r\n\r\n // Cleanup modifier\r\n getModifiers.cleanup(widgetDataObj as FinalWidgetData);\r\n\r\n if (isFinalWidgetData(widgetDataObj) === false) {\r\n throw new Error(\"WidgetData is not formatted correctly\");\r\n }\r\n\r\n return widgetDataObj as FinalWidgetData;\r\n}\r\n\r\nexport function GetRawWidgetData () {\r\n return rawDataArray;\r\n}\r\n\r\n\r\nexport interface IAppStateWidgetData {\r\n Add: typeof AddWidgetData;\r\n Get: typeof GetWidgetData;\r\n __getRawWidgetData: typeof GetRawWidgetData;\r\n}\r\n"], "mappings": "+EAiCA,SAASA,EACPC,EACAC,EACAC,EACwB,CACxB,OAAOD,KAAQD,GAAOE,EAAYF,EAAIC,CAAc,CAAC,CACvD,CAEA,SAASE,EACPH,EACAC,EACAC,EACiC,CACjC,MAAO,EAAED,KAAQD,IAAQE,EAAYF,EAAIC,CAAc,CAAC,CAC1D,CAEA,SAASG,EAAuCC,EAAUC,EAAkCC,EAAyBC,EAAmC,CACtJ,GAAIF,EAAUD,CAAK,EACjB,MAAO,GAEJ,GAAIE,EACP,MAAM,IAAI,MAAMC,CAAY,EAEzB,MAAO,EACd,CAEA,SAASC,EAAoCJ,EAAUC,EAAsCC,EAAyBC,EAAmC,CACvJ,OAAOJ,EAA6BC,EAAOC,EAAWC,EAAgBC,CAAY,CACpF,CAEA,SAASE,EAAmBC,KAAyBC,EAAmB,CACtE,IAAMC,EAAUD,EAAO,IAAIE,IAChBA,GAAe,SAAW,kBAC/B,MAAM;AAAA,CAAI,GACV,IAAIC,GAAK,KAAKA,CAAC,EAAE,EAClB,KAAK;AAAA,CAAI,CACb,EAAE,KAAK;AAAA;AAAA,CAAM,EACd,MAAO,GAAGJ,CAAY;AAAA,EAAOE,CAAO,EACtC,CA0CA,SAASG,EAAeC,EAAcC,EAAiB,GAA4B,CACjF,OACEC,EAAmBF,EAAKG,EAAUF,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AM,MACLU,GAAOT,EAAuB,SAASS,EAAE,IAAI,EAC9CR,EACA,sBAAsBF,EAAM,MAAM,IAAI,gDAAgDC,EAAU,SAAS,CAAC,EAC5G,CACJ,OAASU,EAAc,CACrB,MAAM,IAAI,MAAMC,EAAmB,mBAAoBD,CAAG,EAAG,CAAC,MAAOA,CAAI,CAAC,CAC5E,CACF", "names": ["hasPropWithType", "val", "prop", "typeCheckFn", "hasOptionalPropWithType", "checkConditionOrThrow", "value", "condition", "throwOnMissing", "errorMessage", "checkIsTypeOrThrow", "formatErrorMessage", "messageLabel", "errors", "message", "err", "e", "isBaseResource", "val", "throwOnMissing", "checkIsTypeOrThrow", "isObject", "checkConditionOrThrow", "x", "hasPropWithType", "isString", "hasOptionalPropWithType", "isNil", "isDocument", "y", "err", "formatErrorMessage", "isVideoOnly", "isVideoWithDocs", "isDocumentArray", "isArrayOfType", "isVideoArray", "isVideoWithDocsArray", "isSelectedSingleResource", "val", "typeCheckFn", "isObject", "hasPropWithType", "isSelectedMultiResource", "throwOnMissing", "checkIsTypeOrThrow", "checkConditionOrThrow", "x", "isArray", "isArrayOfType", "err", "formatErrorMessage", "isWidget", "val", "isObject", "hasPropWithType", "isString", "hasOptionalPropWithType", "isNil", "FormSetupType", "SetupType", "isFormSetupType", "isCreateFormTrackingObject", "val", "isObject", "hasOptionalPropWithType", "isString", "isNil", "isFinalFormTrackingObject", "throwOnMissing", "checkIsTypeOrThrow", "checkConditionOrThrow", "x", "hasPropWithType", "isBoolean", "err", "formatErrorMessage", "isBaseFormSetupObject", "val", "dataVersion", "throwOnMissing", "checkIsTypeOrThrow", "isObject", "checkConditionOrThrow", "x", "hasPropWithType", "isFormSetupType", "FormSetupType", "hasOptionalPropWithType", "isCreateFormTrackingObject", "isFinalFormTrackingObject", "err", "formatErrorMessage", "isFormObjectWithVideo", "val", "typeCheckFn", "isObject", "hasPropWithType", "isFinalResourceFormSetup", "val", "throwOnMissing", "checkConditionOrThrow", "x", "isBaseFormSetupObject", "hasPropWithType", "isObject", "y", "isSelectedMultiResource", "isDocument", "err", "formatErrorMessage", "isFinalVideoFormSetup", "val", "throwOnMissing", "checkConditionOrThrow", "x", "isBaseFormSetupObject", "hasPropWithType", "isObject", "y", "isSelectedMultiResource", "isDocument", "isFormObjectWithVideo", "isSelectedSingleResource", "isVideoWithDocs", "err", "formatErrorMessage", "isFinalPostEventFormSetup", "isVideoOnly", "isFinalGatedVideoFormSetup", "val", "throwOnMissing", "checkConditionOrThrow", "x", "isBaseFormSetupObject", "hasPropWithType", "isObject", "isFormObjectWithVideo", "y", "isSelectedSingleResource", "isVideoOnly", "err", "formatErrorMessage", "isFinalContactFormSetup", "isAnyFormFinalSetupObject", "value", "errors", "isFinalResourceFormSetup", "isFinalVideoFormSetup", "isFinalPostEventFormSetup", "isObjectWithWidgetProp", "value", "throwOnMissing", "checkConditionOrThrow", "x", "hasPropWithType", "isWidget", "isFormWidgetData", "value", "setupType", "throwOnMissing", "FormSetupType", "isArray", "checkIsTypeOrThrow", "isObject", "isObjectWithWidgetProp", "isAnyFormFinalSetupObject", "checkConditionOrThrow", "s", "err", "formatErrorMessage"] }