(this["webpackJsonpaqua-delivery-url-shortener"]=this["webpackJsonpaqua-delivery-url-shortener"]||[]).push([[0],{100:function(t,e,n){n(101),t.exports=n(159)},158:function(t,e,n){},159:function(t,e,n){"use strict";n.r(e);var r=n(7),a=n(0),i=n.n(a),c=n(16),s=n.n(c),o=n(32),l=n(25),u=n(33),h=n(68),b=(n(119),n(75)),d=n(35),f=n.n(d),j=n(56),m=(n(73),n(45)),p=n(57),O=n.n(p),k=n(38),v=n.n(k),x=n(74),g=n.n(x),y=function(t){return"".concat("@app",":").concat(t)};v.a.fallbacks=!0,v.a.defaultLocale="en";var _=function(t){var e=t.translations,n=t.locale;if(e&&(v.a.translations=e),n){var r=n.replace(/-.+/,"");localStorage.setItem(y("language"),r),v.a.locale=r,document.documentElement.setAttribute("lang",r)}},L=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return v.a.t(t,e)};v.a.locale,v.a;var w={title:"\u041f\u0438\u0448\u0438, \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0439!",linkCreationForm:{linkInput:"\u0412\u0430\u0448\u0430 \u0441\u0441\u044b\u043b\u043a\u0430",hashInput:"reklama",submitButton:"\u0421\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c"},linkList:{item:{copyButton:"\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c"}},messages:{copiedLink:"\u0421\u0441\u044b\u043b\u043a\u0430 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430",networkError:"\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u043e\u0437\u0436\u0435",hashTooltip:"\u0412\u043f\u0438\u0448\u0438\u0442\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0441\u0441\u044b\u043b\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0430\u0441\u044c. \u042d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e."}},S={title:"Write, shorten!",linkCreationForm:{linkInput:"Paste your link",hashInput:"promotion",submitButton:"Shorten"},linkList:{item:{copyButton:"Copy"}},messages:{copiedLink:"The link is copied to the clipboard",networkError:"An error occurred, please try again later",hashTooltip:"Enter a human-readable link address so that it is easy to remember. This is not necessary."}},N=function(t){var e=g()(t);return Object.keys(e).forEach((function(t){return e[t]=t})),g.a.unflatten(e,{object:!0})}(w),E={ru:w,en:S},T=function(t,e){return function(t){var e=function(t){return"string"===typeof t?L(t):L(t.path,t.config)};return Object(a.useMemo)((function(){return Array.isArray(t)?t.map((function(t){return e(t)})):Object.fromEntries(Object.entries(t).map((function(t){return[t[0],e(t[1])]})))}),[t])}(e(t(N)))},I=l.c.custom(m.a),R={hidden:{opacity:0},visible:{opacity:1}},U=function(t){var e=t.url,n=t.shortUrl,i=Object(a.useState)(!1),c=Object(o.a)(i,2),s=c[0],u=c[1],d=Object(a.useState)("auto"),m=Object(o.a)(d,2),p=m[0],k=m[1],v=Object(a.useMemo)((function(){return{hidden:{width:0,opacity:0},visible:{width:p,opacity:1}}}),[p]),x=Object(a.useRef)(null);Object(a.useEffect)((function(){var t,e=null===(t=x.current)||void 0===t?void 0:t.getBoundingClientRect();"auto"===p&&k((null===e||void 0===e?void 0:e.width)||"auto")}),[x,p]);var g=T((function(t){return t.linkList.item}),(function(t){return[t.copyButton]})),y=Object(o.a)(g,1)[0],_=Object(a.useRef)(null),L=Object(a.useCallback)(function(){var t=Object(j.a)(f.a.mark((function t(e){return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O()(e);case 3:u(!0),_.current&&clearTimeout(_.current),_.current=setTimeout((function(){return u(!1)}),2e3),t.next=11;break;case 8:t.prev=8,t.t0=t.catch(0),console.log(t.t0);case 11:case"end":return t.stop()}}),t,null,[[0,8]])})));return function(e){return t.apply(this,arguments)}}(),[_]);return Object(r.jsxs)(l.c.div,{className:"shorten-link-list-item",transition:{type:"spring",stiffness:50,mass:.8},layout:!0,children:[Object(r.jsxs)("div",{className:"shorten-link-list-item__links",children:[Object(r.jsx)(b.a.Link,{className:"shorten-link-list-item__link",style:{color:"#333",fontWeight:400},href:e,title:e,target:"_blank",children:e}),Object(r.jsx)(b.a.Link,{className:"shorten-link-list-item__link",href:n,title:n,target:"_blank",children:n})]}),Object(r.jsxs)(I,{className:"shorten-link-list-item__copy-button",size:"large",shape:"round",onClick:function(){return L(n)},style:{overflow:"hidden",boxSizing:"border-box"},children:[Object(r.jsx)(l.a,{initial:!1,children:!s&&Object(r.jsx)(l.c.span,{variants:v,initial:"hidden",animate:"visible",exit:"hidden",ref:x,children:y})}),Object(r.jsx)(l.a,{children:s&&Object(r.jsx)(l.c.span,{variants:R,initial:"hidden",animate:"visible",exit:"hidden",className:"shorten-link-list-item__check-icon",children:Object(r.jsx)(h.a,{})})})]})]})},B=Object(a.forwardRef)((function(t,e){var n=t.links;return Object(r.jsx)("div",{className:"shorten-link-list",ref:e,children:n.map((function(t){return Object(r.jsx)(U,Object(u.a)({},t),t.id)}))})})),C=(n(77),n(52)),A=n(99),z=n(98),F=(n(78),n(76)),M=n(97),P=n(71),q=n(37),J=n.n(q),W=n(94),D=Object(W.createLocalStorageStateHook)(y("links"),[]),H=function(t){return Object(u.a)(Object(u.a)({},t),{},{url:decodeURI(t.url),shortUrl:decodeURI(t.shortUrl)})},G=function(){var t=D(),e=Object(o.a)(t,2),n=e[0],r=e[1];return{links:n.map(H),setLinks:r}},K=n(65),Q=n.n(K),V=function(t){return!Q.a.single(t,{url:!0})},X=function(t){return!Q.a.isEmpty(t)},Y=function(t){return function(e){return!t.every((function(t){return t(e)}))}},Z=n(95),$={baseURL:"https://s.appsol.ru",api:{createShortLink:"/urls"}},tt=J.a.create({timeout:1e4,responseType:"json",baseURL:$.baseURL}),et=Object(Z.a)({axios:tt}),nt=function(){return et({url:$.api.createShortLink,method:"POST"},{manual:!0})},rt=(n(156),n(66)),at=Object.fromEntries(["success","error"].map((function(t){return[t,function(e){return function(t,e){return rt.b[t](Object(u.a)({className:"".concat("ant-message","-").concat(t)},e))}(t,e)}]}))),it=function(t,e){return e.findIndex((function(e){return e.id===t}))},ct=function(t){return/^\w+?:\/\//.test(t)?t:"http://".concat(t)},st=function(t){return V(ct(t))},ot=$.baseURL.replace("https://","")+"/",lt=function(t){var e=t.scrollLinksToStart,n=G(),i=n.links,c=n.setLinks,s=T((function(t){return t.linkCreationForm}),(function(t){return t})),h=s.linkInput,b=s.submitButton,d=s.hashInput,p=T((function(t){return t.messages}),(function(t){return t})),k=p.networkError,v=p.copiedLink,x=p.hashTooltip,g=nt(),y=Object(o.a)(g,2),_=y[0].loading,L=y[1],w=Object(a.useCallback)(function(){var t=Object(j.a)(f.a.mark((function t(n,r){var a,s,o,l,u,h,b,d,j,m;return f.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=n.link,s=n.hash,t.prev=1,o={url:ct(a),hash:s?(f=s,f.replace(/ +/g,"_")):void 0},t.next=5,L({data:o});case 5:l=t.sent,setTimeout(r.reset),u=l.data,h=u["@id"],b=i.slice(0,14),-1!==(d=it(h,i))&&b.splice(d,1),j={id:h,url:u.url,shortUrl:u.shortUrl},e(),c([j].concat(Object(M.a)(b))),O()(j.shortUrl),at.success({content:v}),t.next=22;break;case 19:t.prev=19,t.t0=t.catch(1),J.a.isAxiosError(t.t0)?at.error({content:k}):at.error({content:null===(m=t.t0.response)||void 0===m?void 0:m.data["hydra:description"]});case 22:case"end":return t.stop()}var f}),t,null,[[1,19]])})));return function(e,n){return t.apply(this,arguments)}}(),[L,c,i,e,v,k]);return Object(r.jsx)(P.b,{onSubmit:w,render:function(t){var e=t.handleSubmit,n=t.form.getState().valid;return Object(r.jsxs)(l.c.form,{className:"shorten-form",onSubmit:e,style:{display:"block",flexDirection:"column"},layout:!0,children:[Object(r.jsx)("div",{className:"shorten-form__blurred-background"}),Object(r.jsxs)(l.b,{children:[Object(r.jsx)(P.a,{name:"link",render:function(t){var e=t.input;return Object(r.jsx)(F.a,Object(u.a)({placeholder:h,className:"shorten-form__link-input",size:"large",autoFocus:!0,style:{flex:2}},e))},validate:Y([X,st])}),Object(r.jsx)(z.a,{className:"shorten-form__arrow"}),Object(r.jsxs)("div",{className:"shorten-form__hash-input-group",children:[Object(r.jsx)(P.a,{name:"hash",render:function(t){var e=t.input;return Object(r.jsx)(F.a,Object(u.a)({addonBefore:ot,addonAfter:Object(r.jsx)(C.a,{title:x,placement:"bottomRight",color:"white",arrowPointAtCenter:!0,children:Object(r.jsx)(A.a,{style:{cursor:"help"}})}),placeholder:d,className:"shorten-form__hash-input",size:"large",style:{flex:1}},e))}}),Object(r.jsx)(m.a,{htmlType:"submit",type:"primary",size:"large",className:"shorten-form__submit",loading:_,disabled:_||!n,children:b})]})]})]})}})},ut=(n(158),function(){var t=T((function(t){return t}),(function(t){return[t.title]})),e=Object(o.a)(t,1)[0];Object(a.useEffect)((function(){document.title=e}),[e]);var n=G().links,i=Object(a.useRef)(null),c=Object(a.useCallback)((function(){var t;null===(t=i.current)||void 0===t||t.scrollBy({top:0,left:0,behavior:"smooth"})}),[i]);return Object(r.jsx)("main",{className:"page",children:Object(r.jsx)(l.b,{children:Object(r.jsxs)(l.c.div,{className:"shorten-wrapper",layout:!0,children:[Object(r.jsx)(lt,{scrollLinksToStart:c}),Object(r.jsx)(B,{links:n,ref:i})]})})})});_({locale:localStorage.getItem(y("language"))||navigator.language||"en",translations:E});var ht=function(){return Object(r.jsx)(ut,{})};s.a.render(Object(r.jsx)(i.a.StrictMode,{children:Object(r.jsx)(ht,{})}),document.getElementById("root"))}},[[100,1,2]]]); //# sourceMappingURL=main.2404cb44.chunk.js.map