BizInboxAutoFollowUpAutomationContainer.react",["AsyncRequest","BizInboxAutoFollowUpAutomationContainerQuery.graphql","BizInboxAutomationContext","BizInboxAutomationCreationLayout.react","BizInboxAutomationFbtUtils","BizInboxAutomationRuleMutation","BizInboxAutomationSaveChangesToast.react","BizInboxAutomationTypes","BizInboxGating","BizInboxStateContext","GeoToast.react","RelayHooks","XPagesMessengerPreviewControllerRouteBuilder","bizInboxAutomationReducer","react","useBizInboxAutomationMessageActionStates","useBizInboxAutomationPlatformPayload","useBizInboxAutomationReducers","useGeoToaster"],(function(t,n,r,o,a,i,l){"use strict";var e,s,u=s||(s=o("react")),c=s,d=c.useCallback,m=c.useContext,p=c.useEffect,_=c.useRef,f=c.useState,g=e!==void 0?e:e=n("BizInboxAutoFollowUpAutomationContainerQuery.graphql");function h(){var e,t,n,a=m(r("BizInboxStateContext")),i=a.pageID,l=a.pageName,s=m(r("BizInboxAutomationContext")),c=s.automationID,h=r("useGeoToaster")(),y=h.add,C=_(!0),b=_(),v=r("useBizInboxAutomationReducers")([r("bizInboxAutomationReducer")]),S=o("RelayHooks").useRelayEnvironment(),R=o("RelayHooks").useLazyLoadQuery(g,{pageID:i!=null?i:""},{fetchPolicy:o("BizInboxGating").shouldCacheAutomationQuery()?"store-or-network":"network-only"}),L=(e=c!=null?R.biz_inbox_automation_rule_query.find(function(e){return e.rule_id===c}):R.biz_inbox_automation_rule_query[0])!=null?e:null,E=L?{ruleID:L.rule_id,ruleStatus:L.rule_status,assetTypes:L.asset_types.map(function(e){switch(e){case"MESSENGER":return"MESSENGER";case"IG":return"INSTAGRAM_DIRECT";case"WHATS_APP":return"WEC";default:return"MESSENGER"}}),actionData:(function(){var e=L.action_data_list.find(function(e){return e.text!=null});return e?{actionID:e.action_id,actionType:"SEND_MESSAGE",text:e.text||""}:{actionID:null,actionType:"SEND_MESSAGE",text:""}})()}:{ruleID:null,ruleStatus:null,assetTypes:[],actionData:{actionID:null,actionType:"SEND_MESSAGE",text:""}},k=r("useBizInboxAutomationPlatformPayload")(E.assetTypes&&E.assetTypes.length>0?E.assetTypes:["MESSENGER"]),I=k.platformEnableStatus,T=k.setPlatformEnableStatus,D=k.enabledPlatforms,x=f(null),$=x[0],P=x[1],N=r("useBizInboxAutomationMessageActionStates")((t=(n=E.actionData)==null?void 0:n.text)!=null?t:"",null,null),M=N.editorState,w=N.setEditorState,A=N.supportedMacros,F=N.buttonsPayload,O=f({responseMediaAttachment:null,responseCTAs:null,platform:"MESSENGER"}),B=O[0],W=O[1],q=d(function(e){P(null),W(e)},[W]),U=M.getCurrentContent().getPlainText();p(function(){C.current?C.current=!1:v({isEditMode:!0,type:"auto_response.edit_mode"})},[v,U,I,F]),p(function(){return function(){if(C.current===!1){var e;(e=b.current)==null||e.abandon()}}},void 0);function V(){return{triggerType:"no_condition",description:o("BizInboxAutomationFbtUtils").getAutomationTriggerDescription("followup_question",l),platformPayload:{platformEnableStatus:I,setPlatformEnableStatus:T,enabledPlatforms:D}}}function H(){var e={nameError:!1,keywordsError:!1,messageError:!1};return M.getCurrentContent().getPlainText().trim().length===0&&(e.messageError=!0),j(e),Object.entries(e).flat().includes(!0)}var G=f({nameError:!1,keywordsError:!1,messageError:!1}),z=G[0],j=G[1];function K(){var e,t=[{actionType:"SEND_MESSAGE",editorState:M,setEditorState:w,supportedMacros:A,messageError:(e=z.messageError)!=null?e:!1,buttonsPayload:F,setButtonsPayload:q,validationResult:$}];return{actionPayloads:t,description:o("BizInboxAutomationFbtUtils").getAutomationActionDescription("followup_question")}}function Q(){var e,t=((e=R.viewer)==null?void 0:e.is_fwa_user)===!0,n="Is this what you are looking for?",r=M.getCurrentContent().getPlainText();return t?{previewText:[n,r],previewType:o("BizInboxAutomationTypes").BizInboxPreviewType.SEND_MESSAGE,attachments:F!=null&&F.responseMediaAttachment?[F.responseMediaAttachment]:null}:{previewText:[n,r],previewType:o("BizInboxAutomationTypes").BizInboxPreviewType.SEND_MESSAGE,handleShowAutomationPreview:J,attachments:F!=null&&F.responseMediaAttachment?[F.responseMediaAttachment]:null}}function X(){return{handleAutomationSave:ee,handleShowPreview:J}}var Y={automationType:"followup_question",trigger:V(),actionSection:K(),preview:Q(),footer:X()};function J(){Z("followup_question",M.getCurrentContent().getPlainText())}function Z(e,t){var n={automation_type:e,media:F==null?void 0:F.responseMediaAttachment,ctas:null,text:t},a=r("XPagesMessengerPreviewControllerRouteBuilder").buildUri({json:JSON.stringify(n),page_id:i});b.current=new(r("AsyncRequest"))().setURI(a).setHandler(function(){y(u.jsx(r("GeoToast.react"),{heading:o("BizInboxAutomationFbtUtils").getAutomationPreviewSentMessage()}))}).setMethod("POST"),b.current.send()}function ee(e){var t,n,a=H();if(a){v({isSavingAutomation:!1,type:"auto_response.saving_status"}),y(u.jsx(r("BizInboxAutomationSaveChangesToast.react"),{isSuccess:!1}));return}v({isEditMode:!1,type:"auto_response.edit_mode"}),v({isSavingAutomation:!0,type:"auto_response.saving_status"});var l=D.map(function(e){switch(e){case"MESSENGER":return"MESSENGER";case"INSTAGRAM_DIRECT":return"IG";case"WEC":return"WHATS_APP";default:return"MESSENGER"}}),s={rule_id:E.ruleID,page_id:i,rule_name:E.ruleID!=null?null:"Auto Follow-Up Automation - "+new Date().toISOString(),predefined_usecase:"FOLLOWUP_QUESTION",asset_type:l,condition_type:"ALL_OF",condition_data:[{condition_field_type:"FOLLOWUP_QUESTION",followup_question_condition_data:{condition_field_type:"FOLLOWUP_QUESTION",timing:1,enable_auto_followup_on_page_question:!0}}],action_data:[{action_id:(t=E.actionData)==null?void 0:t.actionID,action_type:"SEND_MESSAGE",send_message_action_data:{attachments:B.responseMediaAttachment?[B.responseMediaAttachment]:[],ctas:(n=B.responseCTAs)!=null?n:[],dynamic_text:null,message_text:M.getCurrentContent().getPlainText()}}],rule_status:l.length>0?"active":"paused",trigger_type:"NEW_MESSAGE_SENT",followup_question_link_status:null,next_linked_automation_rule_id:null};o("BizInboxAutomationRuleMutation").commit(S,s,{onSuccess:function(){e("followup_question",!0,D)},onFailure:function(){e("followup_question",!1,D)}})}return u.jsx(r("BizInboxAutomationCreationLayout.react"),{creationPayload:Y})}h.displayName=h.name+" [from "+i.id+"]",l.default=h}),98);
-----
BizInboxAutoFollowUpAutomationContainerQuery.graphql",["BizInboxAutoFollowUpAutomationContainerQuery_facebookRelayOperation"],(function(t,n,r,o,a,i){"use strict";var e=(function(){var e=[{defaultValue:null,kind:"LocalArgument",name:"pageID"}],t=[{kind:"Variable",name:"asset_id",variableName:"pageID"},{kind:"Literal",name:"predefined_usecases",value:["FOLLOWUP_QUESTION"]}],r={alias:null,args:null,kind:"ScalarField",name:"rule_id",storageKey:null},o={alias:null,args:null,kind:"ScalarField",name:"rule_status",storageKey:null},a={alias:null,args:null,kind:"ScalarField",name:"asset_types",storageKey:null},i={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"action_id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"text",storageKey:null}],type:"BizInboxAutomatedSendMessageActionResponse",abstractKey:null},l={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:e,kind:"Fragment",metadata:null,name:"BizInboxAutoFollowUpAutomationContainerQuery",selections:[{alias:null,args:t,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[r,o,a,{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"action_data_list",plural:!0,selections:[i],storageKey:null}],storageKey:null},l],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:e,kind:"Operation",name:"BizInboxAutoFollowUpAutomationContainerQuery",selections:[{alias:null,args:t,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[r,o,a,{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},i],storageKey:null}],storageKey:null},l]},params:{id:n("BizInboxAutoFollowUpAutomationContainerQuery_facebookRelayOperation"),metadata:{},name:"BizInboxAutoFollowUpAutomationContainerQuery",operationKind:"query",text:null}}})();a.exports=e}),null);
-----
BizInboxAutoFollowUpAutomationContainerQuery_facebookRelayOperation",[],(function(t,n,r,o,a,i){a.exports="25433213829629875"}),null);
-----
-----
BizInboxAutoFollowUpAutomationContainerQuery.graphql",["BizInboxAutoFollowUpAutomationContainerQuery_facebookRelayOperation"],(function(t,n,r,o,a,i){"use strict";var e=(function(){var e=[{defaultValue:null,kind:"LocalArgument",name:"pageID"}],t=[{kind:"Variable",name:"asset_id",variableName:"pageID"},{kind:"Literal",name:"predefined_usecases",value:["FOLLOWUP_QUESTION"]}],r={alias:null,args:null,kind:"ScalarField",name:"rule_id",storageKey:null},o={alias:null,args:null,kind:"ScalarField",name:"rule_status",storageKey:null},a={alias:null,args:null,kind:"ScalarField",name:"asset_types",storageKey:null},i={kind:"InlineFragment",selections:[{alias:null,args:null,kind:"ScalarField",name:"action_id",storageKey:null},{alias:null,args:null,kind:"ScalarField",name:"text",storageKey:null}],type:"BizInboxAutomatedSendMessageActionResponse",abstractKey:null},l={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:e,kind:"Fragment",metadata:null,name:"BizInboxAutoFollowUpAutomationContainerQuery",selections:[{alias:null,args:t,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[r,o,a,{alias:null,args:null,concreteType:null,kind:"LinkedField",name:"action_data_list",plural:!0,selections:[i],storageKey:null}],storageKey:null},l],type:"Query",abstractKey:null},kind:"Request",operation:{argumentDefinitions:e,kind:"Operation",name:"BizInboxAutoFollowUpAutomationContainerQuery",selections:[{alias:null,args:t,concreteType:"BizInboxAutomationRuleResponse",kind:"LinkedField",name:"biz_inbox_automation_rule_query",plural:!0,selections:[r,o,a,{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},i],storageKey:null}],storageKey:null},l]},params:{id:n("BizInboxAutoFollowUpAutomationContainerQuery_facebookRelayOperation"),metadata:{},name:"BizInboxAutoFollowUpAutomationContainerQuery",operationKind:"query",text:null}}})();a.exports=e}),null);
-----
BizInboxAutoFollowUpAutomationContainerQuery_facebookRelayOperation",[],(function(t,n,r,o,a,i){a.exports="25433213829629875"}),null);
-----