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EAAAA,cAAA,cAAQ,yCAEVA,EAAAA,cAAA,UAAQqC,QA5DS,WACjBlC,QAAQC,IAAI,UACZsG,EAAAA,EAAAA,IAAgBtD,EAAMkC,GAAUvC,MAAK,SAAC4D,GACpCxG,QAAQC,IAAI,SAAUuG,EACxB,GACF,GAuD+B,mDAC7B3G,EAAAA,cAAA,UAAQqC,QAtDY,WACpBlC,QAAQC,IAAI,aACZsG,EAAAA,EAAAA,IAAgBtD,EAAMoC,GAAkBzC,MAAK,SAAC4D,GAC5CxG,QAAQC,IAAI,SAAUuG,EACxB,GACF,GAiDkC,sDAChC3G,EAAAA,cAAA,OAAK4G,UAAU,kBAAkB,aAAW,GAAG,YAAU,GAAG,mBAAiB,GAAG,cAAY,GAAG,wBAAsB,QAAQ,uBAAqB,UAClJ5G,EAAAA,cAAA,OAAKzB,GAAG,cAGZ,C,+/CC1LyB,IAEnBsI,EAAU,SAAAC,I,sRAAAC,CAAAF,EAAAC,GAAA,I,MAAAE,EAAAC,EAAAJ,GAAA,SAAAA,IAAA,O,4FAAAK,CAAA,KAAAL,GAAAG,EAAAG,MAAA,KAAAC,UAAA,CAOb,O,EAPaP,G,EAAA,EAAA1E,IAAA,SAAAd,MACd,WACE,OACErB,EAAAA,cAACA,EAAAA,SAAc,KAAC,cACFqH,KAAK1G,MAAM2G,SAG7B,M,8EAACT,CAAA,CAPa,CAAS7G,EAAAA,WAazB,W,2CCTAuH,E,OAAAA,IAJuB,CACrBC,OAAQC,0CACRC,WAAYD,4B","sources":["webpack://ec/./app/javascript/channels/ sync _channel\\.js$","webpack://ec/./app/javascript/components/ sync ^\\.\\/.*$","webpack://ec/./app/javascript/application.js","webpack://ec/./app/javascript/channels/index.js","webpack://ec/./app/javascript/components/HelloReact.tsx","webpack://ec/./app/javascript/components/QuestionForm.tsx","webpack://ec/./app/javascript/components/SigninForm.tsx","webpack://ec/./app/javascript/components/SignupForm.tsx","webpack://ec/./app/javascript/components/my_subdirectory/HelloWorld.js","webpack://ec/./app/javascript/libs/firebase/index.tsx"],"sourcesContent":["function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nwebpackEmptyContext.id = 463;\nmodule.exports = webpackEmptyContext;","var map = {\n\t\"./HelloReact\": 724,\n\t\"./HelloReact.tsx\": 724,\n\t\"./QuestionForm\": 363,\n\t\"./QuestionForm.tsx\": 363,\n\t\"./SigninForm\": 156,\n\t\"./SigninForm.tsx\": 156,\n\t\"./SignupForm\": 491,\n\t\"./SignupForm.tsx\": 491,\n\t\"./my_subdirectory/HelloWorld\": 573,\n\t\"./my_subdirectory/HelloWorld.js\": 573\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = 982;","// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You're encouraged to place your actual application logic in\n// a relevant structure within app/javascript and only use these pack files to reference\n// that code so it'll be compiled.\n\nimport Rails from \"@rails/ujs\";\nimport Turbolinks from \"turbolinks\";\nimport * as ActiveStorage from \"@rails/activestorage\";\nimport \"channels\";\n\nrequire(\"./libs/firebase\");\n\nRails.start();\nTurbolinks.start();\nActiveStorage.start();\n// Support component names relative to this directory:\nvar componentRequireContext = require.context(\"components\", true);\nvar ReactRailsUJS = require(\"react_ujs\");\nReactRailsUJS.useContext(componentRequireContext);\n","// Load all the channels within this directory and all subdirectories.\n// Channel files must be named *_channel.js.\n\nconst channels = require.context('.', true, /_channel\\.js$/)\nchannels.keys().forEach(channels)\n","import React from 'react'\nimport { useForm } from \"react-hook-form\";\n\ntype HelloReactProps = {\n name: string;\n}\n\nfunction Form() {\n const { register, handleSubmit, watch, formState: { errors } } = useForm();\n const onSubmit = data => console.log(data);\n\n return (\n
\n \n
\n \n
\n {errors.exampleRequired && This field is required}\n
\n \n
\n )\n\n}\n\nconst HelloReact: React.FC = (props: HelloReactProps) => (\n <>\n
Helloaaaa {props.name}!
\n
\n \n)\n\nHelloReact.defaultProps = {\n name: 'aaa'\n}\n\n\nexport default HelloReact","import React from 'react'\nimport { useForm, useFieldArray } from \"react-hook-form\";\n\ntype QuestionChoice = {\n value: string\n}\n\ntype QuestionForm = {\n title: string\n description: string\n answerType: string\n questionChoices: QuestionChoice[]\n}\n\nfunction QuestionForm({ questionnaireId }) {\n const { register, control, handleSubmit, watch, formState: { errors } } = useForm({\n defaultValues: {\n title: '',\n description: '',\n answerType: 'text',\n questionChoices: [{ value: '' }]\n }\n });\n\n const onSubmit = data => {\n fetch(`/questionnaires/${questionnaireId}/questions`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n question: {\n title: data.title,\n description: data.description,\n answer_type: data.answerType,\n question_choices: data.questionChoices\n }\n })\n }).then(() => {\n window.location.href = `/questionnaires/${questionnaireId}`;\n })\n }\n\n const isChoice = ['single-choice', 'multi-choice'].includes(watch('answerType'))\n\n const { fields, append, remove } = useFieldArray({\n control,\n name: \"questionChoices\",\n });\n\n const ChoiceField = ({ fields }) => {\n return (\n fields.map((field, index) => {\n return (\n <>\n \n append({ value: '' })}\n >\n append\n \n {\n index > 0 &&\n remove(index)}\n >\n remove\n \n }\n {errors.questionChoices?.[index]?.value && (\n <>\n
\n This is required \n \n )}\n
\n \n )\n }\n )\n )\n }\n\n return (\n \n \n
\n \n
\n \n
\n {errors.answerType && This field is required}\n
\n {\n isChoice && (\n \n )\n }\n
\n \n \n )\n\n}\n\nexport default QuestionForm","import React, { useEffect } from \"react\";\nimport { getAuth, signInWithEmailAndPassword } from \"firebase/auth\";\nimport { useForm } from \"react-hook-form\";\n\nconst google = (window as any).google;\nconst auth = getAuth();\n\ntype SigninForm = {\n email: string;\n password: string;\n};\n\nconst getCsrfToken = () => {\n const ele = document.getElementsByName(\"csrf-token\") as NodeListOf\n\n return ele[0].content\n}\n\nconst SigninForm = () => {\n const {\n register,\n handleSubmit,\n watch,\n formState: { errors },\n } = useForm({\n defaultValues: {\n email: \"\",\n password: \"\",\n },\n });\n\n useEffect(() => {\n console.log('loaded')\n google.accounts.id.initialize({\n client_id: \"174519978598-lv1rssoftrg6mlb3ilqghe596gtv04fk.apps.googleusercontent.com\",\n callback: handleCredentialResponse\n });\n google.accounts.id.renderButton(\n document.getElementById(\"buttonDiv\"),\n { theme: \"outline\", size: \"large\" } // customization attributes\n );\n google.accounts.id.prompt(); // also display the One Tap dialog\n }, [])\n\n const handleCredentialResponse =(response) => {\n const data = { id: response.credential, 'authenticity_token': getCsrfToken() }\n\n fetch('/signin_with_google', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(data)\n }).then((res) => {\n if (res.ok) {\n location.href = '/questionnaires'\n return\n }\n console.log('res', res)\n window.alert(res.json())\n }).catch((e) => {\n console.log('err', e)\n })\n }\n\n const onSubmit = (data) => {\n const { email, password } = data;\n getCsrfToken()\n signInWithEmailAndPassword(auth, email, password)\n .then((userCredential) => {\n const user = userCredential.user;\n user.getIdToken().then((token) => {\n const data = { id: token, 'authenticity_token': getCsrfToken() }\n fetch('/signin', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n credentials: 'include',\n body: JSON.stringify(data)\n }).then((data) => {\n console.log('dad', data)\n location.href = '/questionnaires'\n })\n })\n })\n .catch((error) => {\n const errorCode = error.code;\n const errorMessage = error.message;\n });\n };\n\n return (\n <>\n
\n \n
\n \n
\n \n
\n
\n \n );\n};\n\nexport default SigninForm;\n","import React, { useEffect } from \"react\";\nimport {\n getAuth,\n createUserWithEmailAndPassword,\n FacebookAuthProvider,\n signInWithPopup,\n OAuthProvider,\n onAuthStateChanged,\n} from \"firebase/auth\";\nimport { useForm } from \"react-hook-form\";\n\nconst auth = getAuth();\n\nconst google = (window as any).google;\nconst FB = (window as any).FB;\n\nconst provider = new OAuthProvider('yahoo.com');\nconst facebookProvider = new FacebookAuthProvider();\n\ntype SignupForm = {\n email: string;\n password: string;\n};\n\nconst SignupForm = () => {\n const {\n register,\n handleSubmit,\n watch,\n formState: { errors },\n } = useForm({\n defaultValues: {\n email: \"\",\n password: \"\",\n },\n });\n\n useEffect(() => {\n if (google) {\n google.accounts.id.initialize({\n client_id: \"174519978598-lv1rssoftrg6mlb3ilqghe596gtv04fk.apps.googleusercontent.com\",\n callback: handleCredentialResponse\n });\n google.accounts.id.renderButton(\n document.getElementById(\"buttonDiv\"),\n { theme: \"outline\", size: \"large\" } // customization attributes\n );\n google.accounts.id.prompt(); // also display the One Tap dialog\n }\n FB.init({\n /**********************************************************************\n * TODO(Developer): Change the value below with your Facebook app ID. *\n **********************************************************************/\n appId : '1555730528564200',\n status : true,\n xfbml : true,\n version : 'v2.6'\n });\n FB.Event.subscribe('auth.authResponseChange', checkLoginState);\n }, [])\n\n const getCsrfToken = () => {\n const ele = document.getElementsByName(\"csrf-token\") as NodeListOf\n\n return ele[0].content\n }\n\n const checkLoginState = (response) => {\n if (response.authResponse) {\n // User is signed-in Facebook.\n const unsubscribe = onAuthStateChanged(auth, (firebaseUser) => {\n unsubscribe();\n console.log('firebaseUser', firebaseUser)\n // Check if we are already signed-in Firebase with the correct user.\n console.log('response', response)\n\n // Build Firebase credential with the Facebook auth token.\n const credential = FacebookAuthProvider.credential(response.authResponse.accessToken);\n console.log('credential', credential)\n\n const data = { id: credential.accessToken, 'authenticity_token': getCsrfToken() }\n\n fetch('/signup_with_facebook', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(data)\n }).then((data) => {\n console.log('data', data)\n // location.href = '/questionnaires'\n }).catch((e) => {\n console.log('err', e)\n })\n })\n }\n }\n\n function handleCredentialResponse(response) {\n console.log('res', response)\n const data = { id: response.credential, 'authenticity_token': getCsrfToken() }\n\n fetch('/signup_with_google', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(data)\n }).then((res) => {\n if (res.ok) {\n location.href = '/questionnaires'\n return\n }\n console.log('res', res)\n window.alert(res.json())\n }).catch((e) => {\n console.log('err', e)\n })\n }\n\n const yahooLogin = () => {\n console.log('yahoo')\n signInWithPopup(auth, provider).then((result) => {\n console.log('result', result)\n })\n }\n\n const facebookLogin = () => {\n console.log('facebook')\n signInWithPopup(auth, facebookProvider).then((result) => {\n console.log('result', result)\n })\n }\n\n const onSubmit = (data) => {\n const { email, password } = data;\n createUserWithEmailAndPassword(auth, email, password)\n .then((userCredential) => {\n const user = userCredential.user;\n user.getIdToken().then((token) => {\n const data = { id: token, 'authenticity_token': getCsrfToken()}\n fetch('/signup', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify(data)\n }).then((data) => {\n console.log('dad', data)\n location.href = '/questionnaires'\n })\n\n })\n })\n .catch((error) => {\n const errorCode = error.code;\n const errorMessage = error.message;\n });\n };\n\n return (\n <>\n \n
\n \n
\n \n
\n \n
\n \n \n
\n
\n \n );\n};\n\nexport default SignupForm;\n","import React from \"react\"\nimport PropTypes from \"prop-types\"\nclass HelloWorld extends React.Component {\n render() {\n return (\n \n Greetinga: {this.props.greeting}\n \n );\n }\n}\n\nHelloWorld.propTypes = {\n greeting: PropTypes.string\n};\nexport default HelloWorld\n","import { initializeApp } from \"firebase/app\";\n\nconst firebaseConfig = {\n apiKey: process.env.FIREBASE_API_KEY,\n authDomain: process.env.FIREBASE_AUTH_DOMAIN,\n};\ninitializeApp(firebaseConfig);\n"],"names":["webpackEmptyContext","req","e","Error","code","keys","resolve","id","module","exports","map","webpackContext","webpackContextResolve","__webpack_require__","o","Object","require","Rails","Turbolinks","ActiveStorage","componentRequireContext","useContext","channels","forEach","Form","_useForm","useForm","register","handleSubmit","errors","watch","formState","React","onSubmit","data","console","log","assign","placeholder","required","exampleRequired","type","HelloReact","props","name","defaultProps","_ref","questionnaireId","defaultValues","title","description","answerType","questionChoices","value","control","isChoice","includes","_useFieldArray","useFieldArray","fields","append","remove","ChoiceField","_ref2","field","index","_errors$questionChoic","key","concat","onClick","fetch","method","headers","body","JSON","stringify","question","answer_type","question_choices","then","window","location","href","google","auth","getAuth","getCsrfToken","document","getElementsByName","content","email","password","useEffect","accounts","initialize","client_id","callback","handleCredentialResponse","renderButton","getElementById","theme","size","prompt","response","credential","res","ok","alert","json","signInWithEmailAndPassword","userCredential","user","getIdToken","token","credentials","error","message","FB","provider","OAuthProvider","facebookProvider","FacebookAuthProvider","init","appId","status","xfbml","version","Event","subscribe","checkLoginState","authResponse","unsubscribe","onAuthStateChanged","firebaseUser","accessToken","src","async","createUserWithEmailAndPassword","signInWithPopup","result","className","HelloWorld","_React$Component","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","this","greeting","initializeApp","apiKey","process","authDomain"],"sourceRoot":""}