{"version":3,"file":"embedded_signup_controller-DmzA5sqr.js","sources":["../../../app/javascript/controllers/whatsapp/embedded_signup_controller.js"],"sourcesContent":["import ApplicationController from \"../application_controller\"\n\nexport default class extends ApplicationController {\n static targets = [\"error\", \"codeInput\", \"submitButton\", \"facebookLoginButton\"]\n\n initialize() {\n this.facebookLoginCallback = this.facebookLoginCallback.bind(this)\n }\n\n connect() {\n const appId = this.valueOfMetaTag(\"meta-app-id\")\n\n window.fbAsyncInit = function () {\n FB.init({\n appId,\n cookie: true,\n xfbml: true,\n version: 'v20.0'\n });\n };\n\n window.fbAsyncInit()\n }\n\n start() {\n const config = {\n config_id: 1343256599651519,\n override_default_response_type: true,\n response_type: 'code',\n extras: {\n feature: 'whatsapp_embedded_signup'\n }\n }\n\n window.FB.login(this.facebookLoginCallback, config);\n }\n\n facebookLoginCallback(response) {\n if (response.authResponse) {\n this.codeInputTarget.value = response.authResponse.code\n\n this.enable(this.submitButtonTarget)\n // this.submitButtonTarget.innerText = this.submitButtonTarget.dataset.disableWith\n this.submitButtonTarget.click()\n } else {\n this.show(this.errorTarget)\n }\n }\n}\n"],"names":["embedded_signup_controller","ApplicationController","appId","config","response","__publicField"],"mappings":"uNAEe,MAAKA,UAASC,CAAsB,CAGjD,YAAa,CACX,KAAK,sBAAwB,KAAK,sBAAsB,KAAK,IAAI,CACrE,CAEE,SAAU,CACR,MAAMC,EAAQ,KAAK,eAAe,aAAa,EAE/C,OAAO,YAAc,UAAY,CAC/B,GAAG,KAAK,CACN,MAAAA,EACA,OAAQ,GACR,MAAO,GACP,QAAS,OACjB,CAAO,CACF,EAED,OAAO,YAAW,CACtB,CAEE,OAAQ,CACN,MAAMC,EAAS,CACb,UAAW,gBACX,+BAAgC,GAChC,cAAe,OACf,OAAQ,CACN,QAAS,0BACjB,CACA,EAEI,OAAO,GAAG,MAAM,KAAK,sBAAuBA,CAAM,CACtD,CAEE,sBAAsBC,EAAU,CAC1BA,EAAS,cACX,KAAK,gBAAgB,MAAQA,EAAS,aAAa,KAEnD,KAAK,OAAO,KAAK,kBAAkB,EAEnC,KAAK,mBAAmB,MAAK,GAE7B,KAAK,KAAK,KAAK,WAAW,CAEhC,CACA,CA7CEC,EADkBL,EACX,UAAU,CAAC,QAAS,YAAa,eAAgB,qBAAqB"}