text: (this["webpackJsonpgoit-react-hw-08-phonebook"]=this["webpackJsonpgoit-react-hw-08-phonebook"]||[]).push([[3],{109:function(e,t,n){"use strict";var r,a=new Uint8Array(16);function c(){if(!r&&!(r="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!==typeof msCrypto&&"function"===typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(a)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var i=function(e){return"string"===typeof e&&o.test(e)},u=[],s=0;s<256;++s)u.push((s+256).toString(16).substr(1));var b=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(u[e[t+0]]+u[e[t+1]]+u[e[t+2]]+u[e[t+3]]+"-"+u[e[t+4]]+u[e[t+5]]+"-"+u[e[t+6]]+u[e[t+7]]+"-"+u[e[t+8]]+u[e[t+9]]+"-"+u[e[t+10]]+u[e[t+11]]+u[e[t+12]]+u[e[t+13]]+u[e[t+14]]+u[e[t+15]]).toLowerCase();if(!i(n))throw TypeError("Stringified UUID is invalid");return n};t.a=function(e,t,n){var r=(e=e||{}).random||(e.rng||c)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var a=0;a<16;++a)t[n+a]=r[a];return t}return b(r)}},115:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return v}));var r={};n.r(r),n.d(r,"getFilter",(function(){return d}));var a=n(1);function c(e){var t=e.title,n=e.children;return Object(a.jsxs)("section",{children:[Object(a.jsx)("h2",{children:t}),n]})}var o=n(4),i=n(0),u=n(20),s=n(27);function b(e){var t=e.id,n=e.name,r=e.number,c=Object(s.c)(),o=Object(u.a)(c,1)[0];return Object(a.jsxs)("li",{children:[Object(a.jsxs)("span",{children:[n,":"]}),Object(a.jsx)("span",{children:r}),Object(a.jsx)("button",{type:"button",id:t,onClick:function(){!function(e){o(e)}(t)},children:"Delete"})]})}var d=function(e){return e.filter.filter},j=n(32),l=n(19);function f(){var e=Object(s.d)(void 0,{refetchOnFocus:!0}),t=e.data,n=void 0===t?[]:t,c=e.error,u=e.isFetching,d=Object(o.e)(r.getFilter),f=Object(i.useMemo)((function(){var e=d.toLowerCase();return n.filter((function(t){return t.name.toLowerCase().includes(e)}))}),[d,n]);return c?l.b.error("There is an error: ".concat(c)):Object(a.jsxs)(a.Fragment,{children:[u&&Object(a.jsx)(j.a,{}),Object(a.jsx)("ul",{children:!u&&f.map((function(e){var t=e.id,n=e.name,r=e.number;return Object(a.jsx)(b,{id:t,name:n,number:r},t)}))}),0===n.length&&!u&&Object(a.jsx)("h1",{children:"No contacts in phonebook!"})]})}var h=n(109);function m(){var e=Object(i.useState)(""),t=Object(u.a)(e,2),n=t[0],r=t[1],c=Object(i.useState)(""),o=Object(u.a)(c,2),b=o[0],d=o[1],j=Object(s.d)().data,f=void 0===j?[]:j,m=Object(s.b)(),O=Object(u.a)(m,1)[0],p=function(e){var t=e.target,n=t.name,a=t.value;switch(n){case"name":r(a);break;case"number":d(a);break;default:return}},v=function(e){var t=e.name.toLowerCase();f.find((function(e){return e.name.toLowerCase()===t}))?l.b.warn("".concat(e.name," is already in contacts")):O(e)},x=Object(h.a)(),g=Object(h.a)();return Object(a.jsxs)("form",{onSubmit:function(e){e.preventDefault(),v({name:n,number:b}),r(""),d("")},children:[Object(a.jsx)("label",{htmlFor:x,children:"Name"}),Object(a.jsx)("input",{type:"text",name:"name",pattern:"^[a-zA-Z\u0430-\u044f\u0410-\u042f]+(([' -][a-zA-Z\u0430-\u044f\u0410-\u042f ])?[a-zA-Z\u0430-\u044f\u0410-\u042f]*)*$",title:"\u0418\u043c\u044f \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0431\u0443\u043a\u0432, \u0430\u043f\u043e\u0441\u0442\u0440\u043e\u0444\u0430, \u0442\u0438\u0440\u0435 \u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Adrian, Jacob Mercer, Charles de Batz de Castelmore d'Artagnan \u0438 \u0442. \u043f.",placeholder:"Please enter name",required:!0,value:n,id:x,onChange:p}),Object(a.jsx)("label",{htmlFor:g,children:"Number"}),Object(a.jsx)("input",{type:"tel",name:"number",pattern:"\\+?\\d{1,4}?[-.\\s]?\\(?\\d{1,3}?\\)?[-.\\s]?\\d{1,4}[-.\\s]?\\d{1,4}[-.\\s]?\\d{1,9}",title:"\u041d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0446\u0438\u0444\u0440 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u0435\u043b\u044b, \u0442\u0438\u0440\u0435, \u043a\u0440\u0443\u0433\u043b\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441 +",placeholder:"Please enter number",required:!0,value:b,id:g,onChange:p}),Object(a.jsx)("button",{type:"submit",children:"Add contact"})]})}var O=n(43);function p(){var e=Object(o.e)(r.getFilter),t=Object(o.d)(),n=Object(i.useCallback)((function(e){t(Object(O.b)(e.target.value))}),[t]);return Object(a.jsxs)("div",{children:[Object(a.jsx)("label",{htmlFor:Object(h.a)(),children:"Find contacts by name"}),Object(a.jsx)("input",{type:"text",value:e,id:Object(h.a)(),onChange:n})]})}function v(){return Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(c,{title:"Phonebook",children:Object(a.jsx)(m,{})}),Object(a.jsxs)(c,{title:"Contacts",children:[Object(a.jsx)(p,{}),Object(a.jsx)(f,{})]})]})}}}]);
  //# sourceMappingURL=3.753c0511.chunk.js.map