CTXChatBuilderDialogContainerUtils",["errorCode","errorDesc","fbt","AdCampaignDestination","AdsAPIObjectives","AdsError","AdsInterfacesLogger","AdsMessengerConstants","AdsMessengerContentEditorTabs","AdsMessengerPageWelcomeMessageDataManager","AdsMessengerProductInfoDataManager","AdsMessengerVideoUploadResetDataAction","AdsMessengerVisualEditorCustomerActionType","AdsMessengerVisualEditorLoggerEvents","AdsMessengerVisualEditorQRResponseType","AdsMessengerVisualEditorUtils","AdsUEditorAdgroupRemovePartnerAppWelcomeMessageFlowIdAction","AdsUEditorAdgroupSetCallToActionTypeDataAction","AdsUEditorAdgroupSetPartnerAppWelcomeMessageFlowIdAction","AdsUEditorAdgroupSetPerformanceBoosterDataAction","AdsUEditorHostIDs","AdsUEditorMessagingDestinationUtils","AdsWhatsAppFeatureGating","CTXChatBuilderDialogContainerUtilsQuery.graphql","CallToActionTypes","ClickToMessageCTDFeatureGating","ClickToMessageCTMPerformanceFeatureGating","ClickToMessageCTXMDFeatureGating","NudgeMessageUtils","PartnerFlowMessagingConstants","RelayHooks","SMCReconsiderationUtils","adsMessengerDataModelGetAutofillMessage","adsMessengerDataModelGetCallPromptMessage","adsMessengerDataModelGetIceBreakers","adsMessengerDataModelGetIsCallPromptEnabled","adsMessengerDataModelGetPhoneNumber","adsMessengerDataModelGetQRResponse","adsMessengerDataModelGetQuickReplies","adsMessengerDataModelGetReengagementDisabled","emptyFunction","first","getByPath","isStringNotNullAndNotWhitespaceOnly","isTruthy","react","setByPath"],(function(a,b,c,d,e,f,g,h,i,j){var k,l,m=l||d("react"),n=m.useCallback,o=m.useState;function p(a){return!a.templateName||a.templateName.length===0?new(c("AdsError"))(1815895,i._(function(a,b){return a._(/*BTDS*/"")},{}),{level:c("AdsError").Level.WARN}):null}function a(a){var c=k!==void 0?k:k=b("CTXChatBuilderDialogContainerUtilsQuery.graphql");a={input:{page_id:String(a.pageID)}};c=d("RelayHooks").useLazyLoadQuery(c,a);return(c=(a=c.welcome_message_flows)==null?void 0:a.has_welcome_message_flows)!=null?c:!1}function e(a,b,d){var e=p(a);return e!==null||b&&(a.errorSpec!==null||a.phoneNumberData.isPhoneNumberSwitchEnabled&&((e=a.phoneNumberData.phoneNumberView)==null?void 0:e.hasError())===!0||a.ordersData.isOrdersSwitchEnabled&&c("AdsMessengerProductInfoDataManager").validateProductInfoHasError(a.welcomeMessageJSON))||d||a.isEditDisabled===!0}function h(a,b){return!b&&!d("AdsUEditorMessagingDestinationUtils").destinationIncludesWhatsApp(a.destinationType)&&d("ClickToMessageCTXMDFeatureGating").isSimplifyJsonAdCreationEnabled(!0)}function q(a){a=o(a===!0?d("PartnerFlowMessagingConstants").SelectedJsonEditorTab.JsonCode:d("PartnerFlowMessagingConstants").SelectedJsonEditorTab.Flows);var b=a[0];a=a[1];return[b,a]}function r(a,b){a=a.welcomeMessageJSON;b&&d("AdsMessengerVisualEditorUtils").getWelcomeMessageDataType(a)==="JSON_SETUP"&&(a=a.message_data);return a}function s(){return function(a){return a!=null&&a.some(function(a){return a.additional_feature==="messenger_call_invitation"})}}function t(a,b){b!==c("AdsMessengerVisualEditorCustomerActionType").ICE_BREAKERS&&c("isTruthy")(a.welcomeMessageJSON.ai_generated_icebreaker_toggle_enabled)&&(c("setByPath")(a.welcomeMessageJSON,["ai_generated_icebreaker_toggle_enabled"],!1),a.onJSONChange(a.welcomeMessageJSON))}function u(a,b,e,g,h,i,j,k,l){return n(function(){var m;t(a,g);b(!0);c("AdsMessengerVideoUploadResetDataAction").dispatch({},{line:"305",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});if(a.errorSpec!=null)return;if(a.phoneNumberData.isPhoneNumberSwitchEnabled&&((m=a.phoneNumberData.phoneNumberView)==null?void 0:m.hasError())===!0){c("AdsInterfacesLogger").log({eventName:c("AdsMessengerVisualEditorLoggerEvents").CTM_CALL_ERROR_SHOWN});return}m=c("adsMessengerDataModelGetIceBreakers")(a.welcomeMessageJSON);d("AdsUEditorMessagingDestinationUtils").isCTM(a.destinationType)&&c("AdsUEditorAdgroupSetPerformanceBoosterDataAction").dispatch({adgroupIDs:a.adgroupIDs,hostID:c("AdsUEditorHostIDs").EDITING,isPerformanceBoosterEnabled:d("ClickToMessageCTMPerformanceFeatureGating").enablePerformanceBooster()},{line:"327",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});if(e(m)){var n;c("AdsInterfacesLogger").log({eventName:"ctm_ib_call_prompt_finish_without_saving",data:(m={},m.adgroup_id=c("first")((n=a.adgroupIDs)!=null?n:[]),m.page_id=a.pageID,m)})}if(a.ordersData.isOrdersSwitchEnabled&&c("AdsMessengerProductInfoDataManager").validateProductInfoHasError(a.welcomeMessageJSON))return;n=c("adsMessengerDataModelGetCallPromptMessage")(a.welcomeMessageJSON);if(n!==void 0&&n!==String(d("AdsMessengerConstants").DEFAULT_START_CONVERSATIONS_CALL_PROMPT_MESSAGE)){c("AdsInterfacesLogger").log({eventName:"ctm_call_prompt_edit_call_invitation",data:(m={},m.adgroup_id=c("first")(a.adgroupIDs),m.page_id=a.pageID,m)})}c("adsMessengerDataModelGetIsCallPromptEnabled")(a.welcomeMessageJSON)&&a.callPromptUpdateCTAEligible===!0&&c("AdsUEditorAdgroupSetCallToActionTypeDataAction").dispatch({callToActionType:c("CallToActionTypes").CONTACT_US,hostID:c("AdsUEditorHostIDs").EDITING,adgroupIDs:a.adgroupIDs},{line:"381",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});c("AdsInterfacesLogger").log({eventName:a.isExistingPost?c("AdsMessengerVisualEditorLoggerEvents").CTM_EP_FINISH_WITHOUT_SAVING:c("AdsMessengerVisualEditorLoggerEvents").CTM_FINISH_WITHOUT_SAVING,data:(n={},n.campaign_destination_type=a.destinationType,n.media_format=i,n.custom_event_type=d("ClickToMessageCTDFeatureGating").isEligibleForImageWelcomeMessage(!1),n)});(h===!1||j===!1)&&c("AdsUEditorAdgroupRemovePartnerAppWelcomeMessageFlowIdAction").dispatch({adgroupIDs:a.adgroupIDs,hostID:c("AdsUEditorHostIDs").EDITING},{line:"404",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});j&&a.selectedApp!=null&&a.selectedFlow!=null&&(c("AdsUEditorAdgroupSetPartnerAppWelcomeMessageFlowIdAction").dispatch({adgroupIDs:a.adgroupIDs,destinationType:a.destinationType,flowID:a.selectedFlow!=null?a.selectedFlow.id:"",hostID:c("AdsUEditorHostIDs").EDITING},{line:"414",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id}),c("AdsInterfacesLogger").log({eventName:"ctx_partner_app_flow_selected"}));a.onHide();if(k!=null&&!c("adsMessengerDataModelGetReengagementDisabled")(a.welcomeMessageJSON)){d("SMCReconsiderationUtils").logSMCReconsiderationAMEvents("finish_with_reconsideration_on",a.pageID,a.accountID,c("first")(a.adgroupIDs));((m=a.welcomeMessageJSON.reengagement)==null?void 0:m.include_products)===!0&&d("SMCReconsiderationUtils").logSMCReconsiderationAMEvents("finish_with_reconsideration_xma_on",a.pageID,a.accountID,c("first")(a.adgroupIDs))}d("NudgeMessageUtils").logSavingEventForNudge(l,a.destinationType,a.pageID,a.welcomeMessageJSON,a.accountID,a.isEditTemplate,a.adgroupIDs)},[e,g,h,k,j,i,a,b,l])}function v(a,b,c,e,f,g){return n(function(){var h;b(!0);c(!0);if(!!a.errorSpec||a.pageID==null)return;d("AdsMessengerVisualEditorUtils").getJSONSend(a.welcomeMessageJSON,a.pageID,function(){},g,f,a.objectStoryID,a.adgroupIDs[0],(h=e)!=null?h:a.destinationType,a.account)},[f,g,a.account,a.adgroupIDs,a.destinationType,a.errorSpec,a.objectStoryID,a.pageID,a.welcomeMessageJSON,e,b,c])}function w(a,b){return n(function(){a(!1),b(!0)},[a,b])}function x(a,b){return n(function(){var c=j._(/*BTDS*/"");a(c);b(!1)},[b,a])}function y(a,b,e){return n(function(f){var g=f;if(d("AdsMessengerVisualEditorUtils").getWelcomeMessageDataType(a.welcomeMessageJSON)==="JSON_SETUP"){var h=a.welcomeMessageJSON;c("setByPath")(h,["message_data"],f);g=h}a.onJSONChange(g);b&&e(!1)},[b,a,e])}function z(a,b){return n(function(){if(!a.errorSpec){var c=a.pageID;if(c==null)return;d("AdsMessengerVisualEditorUtils").getJSONSend(a.welcomeMessageJSON,c,function(){},b,function(){},a.objectStoryID)}},[b,a.errorSpec,a.objectStoryID,a.pageID,a.welcomeMessageJSON])}function A(a,b){return n(function(){a(!b)},[b,a])}function B(a,b,e,g,h,i,j,k){return n(function(){var l;t(a,b);e(!0);c("AdsMessengerVideoUploadResetDataAction").dispatch({},{line:"614",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});if(a.errorSpec)return;if(a.phoneNumberData.isPhoneNumberSwitchEnabled&&((l=a.phoneNumberData.phoneNumberView)==null?void 0:l.hasError())===!0){c("AdsInterfacesLogger").log({eventName:c("AdsMessengerVisualEditorLoggerEvents").CTM_CALL_ERROR_SHOWN});return}if(a.ordersData.isOrdersSwitchEnabled&&c("AdsMessengerProductInfoDataManager").validateProductInfoHasError(a.welcomeMessageJSON))return;c("getByPath")(a.welcomeMessageJSON,["is_visible"])===!1&&c("setByPath")(a.welcomeMessageJSON,["is_visible"],!0);c("getByPath")(a.welcomeMessageJSON,["is_user_editing"])===!0&&c("setByPath")(a.welcomeMessageJSON,["is_user_editing"],!1);c("getByPath")(a.welcomeMessageJSON,["show_none_action_guidance_card"])===!0&&c("setByPath")(a.welcomeMessageJSON,["show_none_action_guidance_card"],!1);var m=a.welcomeMessageJSON;l=c("adsMessengerDataModelGetIceBreakers")(m);d("AdsUEditorMessagingDestinationUtils").isCTM(a.destinationType)&&c("setByPath")(m,["performance_booster_enabled"],d("ClickToMessageCTMPerformanceFeatureGating").enablePerformanceBooster());var n=JSON.stringify(m);c("AdsMessengerPageWelcomeMessageDataManager").createCustomTemplate(a.adgroupIDs,String(a.pageID),n,a.templateName,c("AdsUEditorHostIDs").EDITING,a.accountID,a.isEditTemplate,a.isExistingPost,a.onHide(),c("emptyFunction"),a.destinationType);n=c("adsMessengerDataModelGetQuickReplies")(m);var o=c("adsMessengerDataModelGetAutofillMessage")(m);if(!d("AdsMessengerVisualEditorUtils").isVisualEditorData(m)||n==null&&l==null&&o==null)return;n==null?void 0:n.map(function(a,b){if(a){var d="";switch(a.response_type){case c("AdsMessengerVisualEditorQRResponseType").TEXT:d=c("adsMessengerDataModelGetQRResponse")(m,b)===""?c("AdsMessengerVisualEditorLoggerEvents").CTM_SAVE_QR_NULL_TEXT_RESPONSE:c("AdsMessengerVisualEditorLoggerEvents").CTM_SAVE_QR_TEXT_RESPONSE;break;case c("AdsMessengerVisualEditorQRResponseType").BOT:d=c("AdsMessengerVisualEditorLoggerEvents").CTM_SAVE_QR_BOT_RESPONSE;break;case c("AdsMessengerVisualEditorQRResponseType").NONE:d=c("AdsMessengerVisualEditorLoggerEvents").CTM_SAVE_QR_NONE_RESPONSE}c("AdsInterfacesLogger").log({eventName:d})}});l==null?void 0:l.map(function(a){if(c("isStringNotNullAndNotWhitespaceOnly")(a==null?void 0:a.title)){a=!c("isStringNotNullAndNotWhitespaceOnly")(a.response);c("AdsInterfacesLogger").log({eventName:c("AdsMessengerVisualEditorLoggerEvents").CTM_SAVE_IB_RESPONSE,data:{is_response_empty:a}})}});o=s();if(o(l)){c("AdsInterfacesLogger").log({eventName:"ctm_ib_call_prompt_save_and_finish",data:(n={},n.adgroup_id=c("first")((o=a.adgroupIDs)!=null?o:[]),n.page_id=a.pageID,n)})}l=c("adsMessengerDataModelGetCallPromptMessage")(a.welcomeMessageJSON);if(l!==void 0&&l!==String(d("AdsMessengerConstants").DEFAULT_START_CONVERSATIONS_CALL_PROMPT_MESSAGE)){c("AdsInterfacesLogger").log({eventName:"ctm_call_prompt_edit_call_invitation",data:(o={},o.adgroup_id=c("first")(a.adgroupIDs),o.page_id=a.pageID,o)})}c("adsMessengerDataModelGetIsCallPromptEnabled")(a.welcomeMessageJSON)&&a.callPromptUpdateCTAEligible===!0&&c("AdsUEditorAdgroupSetCallToActionTypeDataAction").dispatch({callToActionType:c("CallToActionTypes").CONTACT_US,hostID:c("AdsUEditorHostIDs").EDITING,adgroupIDs:a.adgroupIDs},{line:"789",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});n=c("adsMessengerDataModelGetPhoneNumber")(m);n!=null&&c("AdsInterfacesLogger").log({eventName:c("AdsMessengerVisualEditorLoggerEvents").CTM_CALL_TEMPLATE_CREATED_WITH_PHONE_NUMBER,message:n});a.editorTab!==c("AdsMessengerContentEditorTabs").USE_EXISTING&&(a.onTabChange(c("AdsMessengerContentEditorTabs").USE_EXISTING),a.onCreateNewTemplate&&a.onCreateNewTemplate());if(a.isExistingPost){c("AdsInterfacesLogger").log({eventName:c("AdsMessengerVisualEditorLoggerEvents").CTM_EP_SAVE_TEMPLATE,data:(l={},l.campaign_destination_type=a.destinationType,l.page_id=a.pageID,l.media_format=g,l.custom_event_type=d("ClickToMessageCTDFeatureGating").isEligibleForImageWelcomeMessage(!1),l.campaign_destination_type=a.destinationType,l)})}if(a.destinationType===c("AdCampaignDestination").WHATSAPP){o=d("AdsWhatsAppFeatureGating").isAutofillEligible(a.destinationType,a.objective);o&&(b===c("AdsMessengerVisualEditorCustomerActionType").AUTOFILL_MESSAGE?c("getByPath")(a.welcomeMessageJSON,["user_edit"])?((a.objective===c("AdsAPIObjectives").OUTCOME_AWARENESS||a.objective===c("AdsAPIObjectives").OUTCOME_SALES)&&c("AdsInterfacesLogger").log({eventName:"ctwa_template_created_with_customized_autofill_message_sales_awareness"}),c("AdsInterfacesLogger").log({eventName:"ctwa_template_created_with_customized_autofill_message"})):((a.objective===c("AdsAPIObjectives").OUTCOME_AWARENESS||a.objective===c("AdsAPIObjectives").OUTCOME_SALES)&&c("AdsInterfacesLogger").log({eventName:"ctwa_template_created_with_default_autofill_message_sales_awareness"}),c("AdsInterfacesLogger").log({eventName:"ctwa_template_created_with_default_autofill_message"})):b===c("AdsMessengerVisualEditorCustomerActionType").ICE_BREAKERS&&c("AdsInterfacesLogger").log({eventName:"ctwa_template_created_with_icebreaker"}))}(h===!1||i===!1)&&c("AdsUEditorAdgroupRemovePartnerAppWelcomeMessageFlowIdAction").dispatch({adgroupIDs:a.adgroupIDs,hostID:c("AdsUEditorHostIDs").EDITING},{line:"890",module:"CTXChatBuilderDialogContainerUtils.js",moduleID:f.id});if(j!=null)if(!c("adsMessengerDataModelGetReengagementDisabled")(a.welcomeMessageJSON)){d("SMCReconsiderationUtils").logSMCReconsiderationAMEvents("save_with_reconsideration_on",a.pageID,a.accountID,c("first")(a.adgroupIDs));((n=a.welcomeMessageJSON.reengagement)==null?void 0:n.include_products)===!0&&d("SMCReconsiderationUtils").logSMCReconsiderationAMEvents("save_with_reconsideration_xma_on",a.pageID,a.accountID,c("first")(a.adgroupIDs))}else d("SMCReconsiderationUtils").logSMCReconsiderationAMEvents("save_with_reconsideration_off",a.pageID,a.accountID,c("first")(a.adgroupIDs));d("NudgeMessageUtils").logSavingEventForNudge(k,a.destinationType,a.pageID,a.welcomeMessageJSON,a.accountID,a.isEditTemplate,a.adgroupIDs)},[a,b,e,h,i,j,k,g])}function C(a){return n(function(b){a(b),b===d("PartnerFlowMessagingConstants").SelectedJsonEditorTab.JsonCode&&c("AdsInterfacesLogger").log({eventName:"ctx_partner_app_switch_to_json_tab"})},[a])}function D(a,b,c){return b===d("PartnerFlowMessagingConstants").SelectedJsonEditorTab.JsonCode&&d("AdsUEditorMessagingDestinationUtils").isMultiDestination(a.destinationType)&&c&&!d("ClickToMessageCTXMDFeatureGating").isSimplifyJsonAdCreationEnabled(!0)}function E(a){return n(function(b){if(a.setSelectedFlow){a.setSelectedFlow(b);b=b==null?void 0:b.welcome_message_flow;if(b!=null){b=JSON.parse(b);var c={};c.message_data=b;c.type="JSON_SETUP";b=c;a.onJSONChange(b)}}},[a])}function F(a,b,e){return a.isUnifiedCreation||(a.objective===c("AdsAPIObjectives").LINK_CLICKS||a.objective===c("AdsAPIObjectives").OUTCOME_AWARENESS)&&a.destinationType===c("AdCampaignDestination").WHATSAPP||d("ClickToMessageCTXMDFeatureGating").enableUnifiedCreationCTXMDL1(a.objective,b,!1,a.isExistingPost)&&d("AdsUEditorMessagingDestinationUtils").isMultiDestination(e)}g.getDialogContainerTemplateError=p;g.useGetHasWelcomeMessageFlows=a;g.getDialogContainerFooterButtonDisabled=e;g.getShouldSimplifyJsonAdCreation=h;g.useGetSelectedJSONEditorTabState=q;g.getDialogContainerJSONEditorValue=r;g.getDoesIcebreakerHasCallPromptCallback=s;g.useGetOnClickFinishCallback=u;g.useGetOnClickPreviewCallback=v;g.useGetOnJSONSendSuccessCallback=w;g.useGetOnJSONError=x;g.useGetOnJSONChangeCallback=y;g.useGetOnPreviewButtonClickedCallback=z;g.useGetOnToggleSaveCheckboxCallback=A;g.useGetOnClickFinishAndSaveCallback=B;g.useGetOnSelectedTabChangeCallback=C;g.getShouldShowClickToMessengeronlyGuidanceCard=D;g.useGetSetSelectedFlowCallback=E;g.getIsUnifiedCreationStyleEnabled=F}),226);
-----
CTXChatBuilderDialogContainerUtilsQuery.graphql",[],(function(a,b,c,d,e,f){"use strict";a=function(){var a=[{defaultValue:null,kind:"LocalArgument",name:"input"}],b=[{alias:null,args:[{kind:"Variable",name:"data",variableName:"input"}],concreteType:"HasWelcomeMessageFlowsResponse",kind:"LinkedField",name:"welcome_message_flows",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"has_welcome_message_flows",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:a,kind:"Fragment",metadata:null,name:"CTXChatBuilderDialogContainerUtilsQuery",selections:b,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:a,kind:"Operation",name:"CTXChatBuilderDialogContainerUtilsQuery",selections:b},params:{id:"9802877483132739",metadata:{},name:"CTXChatBuilderDialogContainerUtilsQuery",operationKind:"query",text:null}}}();e.exports=a}),null);
-----
-----
CTXChatBuilderDialogContainerUtilsQuery.graphql",[],(function(a,b,c,d,e,f){"use strict";a=function(){var a=[{defaultValue:null,kind:"LocalArgument",name:"input"}],b=[{alias:null,args:[{kind:"Variable",name:"data",variableName:"input"}],concreteType:"HasWelcomeMessageFlowsResponse",kind:"LinkedField",name:"welcome_message_flows",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"has_welcome_message_flows",storageKey:null}],storageKey:null}];return{fragment:{argumentDefinitions:a,kind:"Fragment",metadata:null,name:"CTXChatBuilderDialogContainerUtilsQuery",selections:b,type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:a,kind:"Operation",name:"CTXChatBuilderDialogContainerUtilsQuery",selections:b},params:{id:"9802877483132739",metadata:{},name:"CTXChatBuilderDialogContainerUtilsQuery",operationKind:"query",text:null}}}();e.exports=a}),null);
-----