BizInboxPhoneNumberAutomationSettingsContainer.react",["fbt","AsyncRequest","BIZInboxClientLogger","BizInboxAutomationFbtUtils","BizInboxAutomationRuleMutation","BizInboxAutomationSaveChangesToast.react","BizInboxAutomationTypes","BizInboxGating","BizInboxOnboardingContext","BizInboxOnboardingUtils","BizInboxPhoneNumberAutomationCreationLayout.react","BizInboxPhoneNumberAutomationSettingsContainerQuery.graphql","BizInboxStateContext","GeoToast.react","RelayHooks","XPagesMessengerPreviewController","bizInboxAutomationReducer","bizInboxOnboardingReducer","react","useBizInboxAutomationMessageActionStates","useBizInboxAutomationPlatformPayload","useBizInboxAutomationReducers","useBizInboxOnboardingReducers","useBoolean","useGeoToaster"],(function(a,b,c,d,e,f,g,h){"use strict";var i,j,k=j||(j=d("react"));e=j;var l=e.useCallback,m=e.useContext,n=e.useEffect,o=e.useRef,p=e.useState,q=i!==void 0?i:i=b("BizInboxPhoneNumberAutomationSettingsContainerQuery.graphql");function a(){var a,b,e,f=m(c("BizInboxStateContext")),g=f.pageID,i=f.pageName;f=m(c("BizInboxOnboardingContext"));var j=f.tasksStatus;f=c("useGeoToaster")();var r=f.add,s=o(!0),t=o(),u=c("useBizInboxAutomationReducers")([c("bizInboxAutomationReducer")]),v=c("useBizInboxOnboardingReducers")([c("bizInboxOnboardingReducer")]),w=d("RelayHooks").useRelayEnvironment();f=d("RelayHooks").useLazyLoadQuery(q,{pageID:g!=null?g:""},{fetchPolicy:d("BizInboxGating").shouldCacheAutomationQuery()?"store-or-network":"network-only"});var x=f.biz_inbox_automation_rule_query.length>0?f.biz_inbox_automation_rule_query[0]:null,y=x?{ruleID:x.rule_id,ruleStatus:x.rule_status,assetTypes:x.asset_types.map(function(a){switch(a){case"MESSENGER":return"MESSENGER";case"IG":return"INSTAGRAM_DIRECT";case"WHATS_APP":return"WEC";default:return"MESSENGER"}}),actionData:function(){var a=x.action_data_list.find(function(a){return a.text!=null});return a?{actionID:a.action_id,actionType:"SEND_MESSAGE",text:a.text||"",ctas:a.ctas||[],attachments:a.attachments||[]}:{actionID:null,actionType:"SEND_MESSAGE",text:"",ctas:[],attachments:[]}}()}:{ruleID:null,ruleStatus:null,assetTypes:[],actionData:{actionID:null,actionType:"SEND_MESSAGE",text:"",ctas:[],attachments:[]}};a=(a=y.actionData)==null?void 0:a.attachments;b=(b=y.actionData)==null?void 0:b.ctas;var z=((e=f.viewer)==null?void 0:e.is_fwa_user)===!0;e=c("useBizInboxAutomationPlatformPayload")((e=y.assetTypes)!=null?e:[]);var A=e.platformEnableStatus,B=e.setPlatformEnableStatus,C=e.enabledPlatforms;e=c("useBizInboxAutomationMessageActionStates")((e=(e=y.actionData)==null?void 0:e.text)!=null?e:"",a!=null&&a.length>0?a[0]:null,b);var D=e.editorState,E=e.setEditorState,F=e.supportedMacros,G=e.buttonsPayload,H=e.setButtonsPayload;a=D.getCurrentContent().getPlainText();var I=f.biz_inbox_automation_rule_query.length>0;b=I?f.biz_inbox_automation_rule_query[0].action_data_list.some(function(a){return a.is_enabled===!0}):!1;e=c("useBoolean")(b);var J=e.value,K=e.set;f=l(function(a){K(a);if(I&&y.ruleID!=null){var b;b={rule_id:y.ruleID,page_id:g,rule_name:h._(/*BTDS*/"Phone automation").toString(),predefined_usecase:"PHONE_NUMBER",asset_type:["MESSENGER"],condition_type:"ALL_OF",condition_data:[{condition_field_type:"MESSAGE_PHONE_DETECTION"}],action_data:[{action_type:"SEND_MESSAGE",send_message_action_data:{attachments:G!=null&&G.responseMediaAttachment?[G.responseMediaAttachment]:[],ctas:(b=G==null?void 0:G.responseCTAs)!=null?b:[],dynamic_text:null,message_text:D.getCurrentContent().getPlainText()}},{action_type:"INITIATE_CALL",initiate_call_action_data:{is_enabled:a}}],rule_status:null,trigger_type:null,followup_question_link_status:null,next_linked_automation_rule_id:null};d("BizInboxAutomationRuleMutation").commit(w,b,{onSuccess:function(){r(k.jsx(c("GeoToast.react"),{heading:h._(/*BTDS*/"Call invite setting updated").toString()}))},onFailure:function(){K(!a),r(k.jsx(c("GeoToast.react"),{heading:h._(/*BTDS*/"Failed to update call invite setting").toString()}))}})}},[I,y.ruleID,g,G,D,w,r,K]);n(function(){s.current?s.current=!1:u({isEditMode:!0,type:"auto_response.edit_mode"})},[u,a,A,G,J]);n(function(){return function(){if(s.current===!1){var a;(a=t.current)==null||a.abandon()}}},void 0);function L(){return{triggerType:"no_condition",description:d("BizInboxAutomationFbtUtils").getAutomationTriggerDescription("custom_automation",i),platformPayload:{platformEnableStatus:A,setPlatformEnableStatus:B,enabledPlatforms:C}}}function M(){var a={nameError:!1,keywordsError:!1,messageError:!1};D.getCurrentContent().getPlainText().trim().length===0&&(a.messageError=!0);O(a);return Object.entries(a).flat().includes(!0)}b=p({nameError:!1,keywordsError:!1,messageError:!1});var N=b[0],O=b[1];function P(){var a;a=[{actionType:"SEND_MESSAGE",editorState:D,setEditorState:E,supportedMacros:F,messageError:(a=N.messageError)!=null?a:!1,buttonsPayload:G,setButtonsPayload:H}];return{actionPayloads:a,description:d("BizInboxAutomationFbtUtils").getAutomationActionDescription("custom_automation","PHONE_NUMBER")}}function Q(){var a=[];G!=null&&G.responseMediaAttachment&&a.push(G.responseMediaAttachment);if(J){var b={id:"call_invite_xma",type:"IMAGE",url:"call://business"};a.push(b)}if(z)return{previewText:[D.getCurrentContent().getPlainText()],previewType:d("BizInboxAutomationTypes").BizInboxPreviewType.SEND_MESSAGE,attachments:a.length>0?a:null};else return{previewText:[D.getCurrentContent().getPlainText()],previewType:d("BizInboxAutomationTypes").BizInboxPreviewType.SEND_MESSAGE,handleShowAutomationPreview:S,attachments:a.length>0?a:null}}function R(){return{handleAutomationSave:U,handleShowPreview:S}}e={automationType:"custom_automation",trigger:L(),actionSection:P(),preview:Q(),footer:R()};function S(){T("custom_automation",D.getCurrentContent().getPlainText())}function T(a,b){a={automation_type:a,media:G==null?void 0:G.responseMediaAttachment,ctas:null,text:b};b=c("XPagesMessengerPreviewController").getURIBuilder().setString("json",JSON.stringify(a)).setInt("page_id",g);t.current=new(c("AsyncRequest"))().setURI(b.getURI()).setHandler(function(){r(k.jsx(c("GeoToast.react"),{heading:d("BizInboxAutomationFbtUtils").getAutomationPreviewSentMessage()}))}).setMethod("POST");t.current.send()}function U(a){var b,e=M();if(e){u({isSavingAutomation:!1,type:"auto_response.saving_status"});r(k.jsx(c("BizInboxAutomationSaveChangesToast.react"),{isSuccess:!1}));return}u({isEditMode:!1,type:"auto_response.edit_mode"});u({isSavingAutomation:!0,type:"auto_response.saving_status"});e=(e=G==null?void 0:G.responseCTAs)!=null?e:[];var f=G==null?void 0:G.responseMediaAttachment;d("BIZInboxClientLogger").logIncompleteAutomationSaveClick(g,"MESSENGER",null,null,!1,e.length>0,f!=null);b={rule_id:(b=y.ruleID)!=null?b:null,page_id:g,rule_name:h._(/*BTDS*/"Phone automation").toString(),predefined_usecase:"PHONE_NUMBER",asset_type:["MESSENGER"],condition_type:"ALL_OF",condition_data:[{condition_field_type:"MESSAGE_PHONE_DETECTION"}],action_data:[{action_type:"SEND_MESSAGE",send_message_action_data:{attachments:f?[f]:[],ctas:e,dynamic_text:null,message_text:D.getCurrentContent().getPlainText()}},{action_type:"INITIATE_CALL",initiate_call_action_data:{is_enabled:J}}],rule_status:null,trigger_type:null,followup_question_link_status:null,next_linked_automation_rule_id:null};d("BizInboxAutomationRuleMutation").commit(w,b,{onSuccess:function(){a("custom_automation",!0,C),V()},onFailure:function(){a("custom_automation",!1,C)}})}function V(){d("BizInboxOnboardingUtils").bizInboxOnboardingTaskActionComplete(g,j,w,v,"INSTANT_REPLY")}return k.jsx(c("BizInboxPhoneNumberAutomationCreationLayout.react"),{creationPayload:e,isCallInviteEnabled:J,setIsCallInviteEnabled:f})}a.displayName=a.name+" [from "+f.id+"]";g["default"]=a}),226);
-----
BizInboxPhoneNumberAutomationSettingsContainerQuery.graphql",["BizInboxPhoneNumberAutomationSettingsContainerQuery_facebookRelayOperation"],(function(a,b,c,d,e,f){"use strict";a=function(){var a=[{defaultValue:null,kind:"LocalArgument",name:"pageID"}],c=[{kind:"Variable",name:"asset_id",variableName:"pageID"},{kind:"Literal",name:"predefined_usecases",value:["PHONE_NUMBER"]}],d={alias:null,args:null,kind:"ScalarField",name:"rule_id",storageKey:null},e={alias:null,args:null,kind:"ScalarField",name:"rule_status",storageKey:null},f={alias:null,args:null,kind:"ScalarField",name:"asset_types",storageKey:null},g={alias:null,args:null,kind:"ScalarField",name:"action_id",storageKey:null},h={alias:null,args:null,kind:"ScalarField",name:"url",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null};h={kind:"InlineFragment",selections:[g,{alias:null,args:null,kind:"ScalarField",name:"text",storageKey:null},{alias:null,args:null,concreteType:"BizInboxAutomationCTA",kind:"LinkedField",name:"ctas",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"content",storageKey:null},h,i],storageKey:null},{alias:null,args:null,concreteType:"BizInboxAutomationAttachment",kind:"LinkedField",name:"attachments",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},h,i],storageKey:null}],type:"BizInboxAutomatedSendMessageActionResponse",abstractKey:null};i={kind:"InlineFragment",selections:[g,{alias:null,args:null,kind:"ScalarField",name:"is_enabled",storageKey:null}],type:"BizInboxAutomatedInitiateCallActionResponse",abstractKey:null};g={alias:null,args:null,concreteType:"Viewer",kind:"LinkedField",name:"viewer",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"is_fwa_user",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:a,kind:"Fragment",metadata:null,name:"BizInboxPhoneNumberAutomationSettingsContainerQuery",selections:[{alias:null,args:c,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[d,e,f,{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"action_data_list",plural:!0,selections:[h,i],storageKey:null}],storageKey:null},g],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:a,kind:"Operation",name:"BizInboxPhoneNumberAutomationSettingsContainerQuery",selections:[{alias:null,args:c,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[d,e,f,{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"action_data_list",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},h,i],storageKey:null}],storageKey:null},g]},params:{id:b("BizInboxPhoneNumberAutomationSettingsContainerQuery_facebookRelayOperation"),metadata:{},name:"BizInboxPhoneNumberAutomationSettingsContainerQuery",operationKind:"query",text:null}}}();e.exports=a}),null);
-----
BizInboxPhoneNumberAutomationSettingsContainerQuery_facebookRelayOperation",[],(function(a,b,c,d,e,f){e.exports="24357519530536121"}),null);
-----
-----
BizInboxPhoneNumberAutomationSettingsContainerQuery.graphql",["BizInboxPhoneNumberAutomationSettingsContainerQuery_facebookRelayOperation"],(function(a,b,c,d,e,f){"use strict";a=function(){var a=[{defaultValue:null,kind:"LocalArgument",name:"pageID"}],c=[{kind:"Variable",name:"asset_id",variableName:"pageID"},{kind:"Literal",name:"predefined_usecases",value:["PHONE_NUMBER"]}],d={alias:null,args:null,kind:"ScalarField",name:"rule_id",storageKey:null},e={alias:null,args:null,kind:"ScalarField",name:"rule_status",storageKey:null},f={alias:null,args:null,kind:"ScalarField",name:"asset_types",storageKey:null},g={alias:null,args:null,kind:"ScalarField",name:"action_id",storageKey:null},h={alias:null,args:null,kind:"ScalarField",name:"url",storageKey:null},i={alias:null,args:null,kind:"ScalarField",name:"type",storageKey:null};h={kind:"InlineFragment",selections:[g,{alias:null,args:null,kind:"ScalarField",name:"text",storageKey:null},{alias:null,args:null,concreteType:"BizInboxAutomationCTA",kind:"LinkedField",name:"ctas",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"content",storageKey:null},h,i],storageKey:null},{alias:null,args:null,concreteType:"BizInboxAutomationAttachment",kind:"LinkedField",name:"attachments",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"id",storageKey:null},h,i],storageKey:null}],type:"BizInboxAutomatedSendMessageActionResponse",abstractKey:null};i={kind:"InlineFragment",selections:[g,{alias:null,args:null,kind:"ScalarField",name:"is_enabled",storageKey:null}],type:"BizInboxAutomatedInitiateCallActionResponse",abstractKey:null};g={alias:null,args:null,concreteType:"Viewer",kind:"LinkedField",name:"viewer",plural:!1,selections:[{alias:null,args:null,kind:"ScalarField",name:"is_fwa_user",storageKey:null}],storageKey:null};return{fragment:{argumentDefinitions:a,kind:"Fragment",metadata:null,name:"BizInboxPhoneNumberAutomationSettingsContainerQuery",selections:[{alias:null,args:c,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[d,e,f,{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"action_data_list",plural:!0,selections:[h,i],storageKey:null}],storageKey:null},g],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:a,kind:"Operation",name:"BizInboxPhoneNumberAutomationSettingsContainerQuery",selections:[{alias:null,args:c,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[d,e,f,{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"action_data_list",plural:!0,selections:[{alias:null,args:null,kind:"ScalarField",name:"__typename",storageKey:null},h,i],storageKey:null}],storageKey:null},g]},params:{id:b("BizInboxPhoneNumberAutomationSettingsContainerQuery_facebookRelayOperation"),metadata:{},name:"BizInboxPhoneNumberAutomationSettingsContainerQuery",operationKind:"query",text:null}}}();e.exports=a}),null);
-----
BizInboxPhoneNumberAutomationSettingsContainerQuery_facebookRelayOperation",[],(function(a,b,c,d,e,f){e.exports="24357519530536121"}),null);
-----