2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
var app=function(){"use strict";function e(){}function t(e){return e()}function n(){return Object.create(null)}function r(e){e.forEach(t)}function o(e){return"function"==typeof e}function i(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function a(e,t){e.appendChild(t)}function s(e,t,n){e.insertBefore(t,n||null)}function u(e){e.parentNode.removeChild(e)}function c(e){return document.createElement(e)}function f(e){return document.createTextNode(e)}function l(){return f(" ")}function d(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function p(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function h(e,t){(null!=t||e.value)&&(e.value=t)}let m;function g(e){m=e}const y=[],v=[],b=[],w=[],x=Promise.resolve();let E=!1;function S(e){b.push(e)}let C=!1;const $=new Set;function R(){if(!C){C=!0;do{for(let e=0;e<y.length;e+=1){const t=y[e];g(t),j(t.$$)}for(y.length=0;v.length;)v.pop()();for(let e=0;e<b.length;e+=1){const t=b[e];$.has(t)||($.add(t),t())}b.length=0}while(y.length);for(;w.length;)w.pop()();E=!1,C=!1,$.clear()}}function j(e){if(null!==e.fragment){e.update(),r(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(S)}}const A=new Set;function N(e,t){-1===e.$$.dirty[0]&&(y.push(e),E||(E=!0,x.then(R)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function O(i,a,s,c,f,l,d=[-1]){const p=m;g(i);const h=a.props||{},y=i.$$={fragment:null,ctx:null,props:l,update:e,not_equal:f,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(p?p.$$.context:[]),callbacks:n(),dirty:d};let v=!1;if(y.ctx=s?s(i,h,(e,t,...n)=>{const r=n.length?n[0]:t;return y.ctx&&f(y.ctx[e],y.ctx[e]=r)&&(y.bound[e]&&y.bound[e](r),v&&N(i,e)),t}):[],y.update(),v=!0,r(y.before_update),y.fragment=!!c&&c(y.ctx),a.target){if(a.hydrate){const e=function(e){return Array.from(e.childNodes)}(a.target);y.fragment&&y.fragment.l(e),e.forEach(u)}else y.fragment&&y.fragment.c();a.intro&&((b=i.$$.fragment)&&b.i&&(A.delete(b),b.i(w))),function(e,n,i){const{fragment:a,on_mount:s,on_destroy:u,after_update:c}=e.$$;a&&a.m(n,i),S(()=>{const n=s.map(t).filter(o);u?u.push(...n):r(n),e.$$.on_mount=[]}),c.forEach(S)}(i,a.target,a.anchor),R()}var b,w;g(p)}var T=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},U=Object.prototype.toString;function k(e){return"[object Array]"===U.call(e)}function B(e){return void 0===e}function L(e){return null!==e&&"object"==typeof e}function _(e){return"[object Function]"===U.call(e)}function q(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),k(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var P={isArray:k,isArrayBuffer:function(e){return"[object ArrayBuffer]"===U.call(e)},isBuffer:function(e){return null!==e&&!B(e)&&null!==e.constructor&&!B(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:L,isUndefined:B,isDate:function(e){return"[object Date]"===U.call(e)},isFile:function(e){return"[object File]"===U.call(e)},isBlob:function(e){return"[object Blob]"===U.call(e)},isFunction:_,isStream:function(e){return L(e)&&_(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:q,merge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]=n}for(var r=0,o=arguments.length;r<o;r++)q(arguments[r],n);return t},deepMerge:function e(){var t={};function n(n,r){"object"==typeof t[r]&&"object"==typeof n?t[r]=e(t[r],n):t[r]="object"==typeof n?e({},n):n}for(var r=0,o=arguments.length;r<o;r++)q(arguments[r],n);return t},extend:function(e,t,n){return q(t,(function(t,r){e[r]=n&&"function"==typeof t?T(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}};function D(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var F=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(P.isURLSearchParams(t))r=t.toString();else{var o=[];P.forEach(t,(function(e,t){null!=e&&(P.isArray(e)?t+="[]":e=[e],P.forEach(e,(function(e){P.isDate(e)?e=e.toISOString():P.isObject(e)&&(e=JSON.stringify(e)),o.push(D(t)+"="+D(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e};function H(){this.handlers=[]}H.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},H.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},H.prototype.forEach=function(e){P.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var z=H,M=function(e,t,n){return P.forEach(n,(function(n){e=n(e,t)})),e},I=function(e){return!(!e||!e.__CANCEL__)},X=function(e,t){P.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},J=function(e,t,n,r,o){return function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}(new Error(e),t,n,r,o)},V=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],K=P.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=P.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},G=P.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),P.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),P.isString(r)&&a.push("path="+r),P.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Q=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;P.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",s=e.auth.password||"";o.Authorization="Basic "+btoa(a+":"+s)}var u,c,f=(u=e.baseURL,c=e.url,u&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(c)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(u,c):c);if(i.open(e.method.toUpperCase(),F(f,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r,o,a,s,u,c="getAllResponseHeaders"in i?(r=i.getAllResponseHeaders(),u={},r?(P.forEach(r.split("\n"),(function(e){if(s=e.indexOf(":"),o=P.trim(e.substr(0,s)).toLowerCase(),a=P.trim(e.substr(s+1)),o){if(u[o]&&V.indexOf(o)>=0)return;u[o]="set-cookie"===o?(u[o]?u[o]:[]).concat([a]):u[o]?u[o]+", "+a:a}})),u):u):null,f={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:c,config:e,request:i};!function(e,t,n){var r=n.config.validateStatus;!r||r(n.status)?e(n):t(J("Request failed with status code "+n.status,n.config,null,n.request,n))}(t,n,f),i=null}},i.onabort=function(){i&&(n(J("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(J("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(J(t,e,"ECONNABORTED",i)),i=null},P.isStandardBrowserEnv()){var l=G,d=(e.withCredentials||K(f))&&e.xsrfCookieName?l.read(e.xsrfCookieName):void 0;d&&(o[e.xsrfHeaderName]=d)}if("setRequestHeader"in i&&P.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),P.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),void 0===r&&(r=null),i.send(r)}))},W={"Content-Type":"application/x-www-form-urlencoded"};function Y(e,t){!P.isUndefined(e)&&P.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Z,ee={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Z=Q),Z),transformRequest:[function(e,t){return X(t,"Accept"),X(t,"Content-Type"),P.isFormData(e)||P.isArrayBuffer(e)||P.isBuffer(e)||P.isStream(e)||P.isFile(e)||P.isBlob(e)?e:P.isArrayBufferView(e)?e.buffer:P.isURLSearchParams(e)?(Y(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):P.isObject(e)?(Y(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};ee.headers={common:{Accept:"application/json, text/plain, */*"}},P.forEach(["delete","get","head"],(function(e){ee.headers[e]={}})),P.forEach(["post","put","patch"],(function(e){ee.headers[e]=P.merge(W)}));var te=ee;function ne(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var re=function(e){return ne(e),e.headers=e.headers||{},e.data=M(e.data,e.headers,e.transformRequest),e.headers=P.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),P.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||te.adapter)(e).then((function(t){return ne(e),t.data=M(t.data,t.headers,e.transformResponse),t}),(function(t){return I(t)||(ne(e),t&&t.response&&(t.response.data=M(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},oe=function(e,t){t=t||{};var n={},r=["url","method","params","data"],o=["headers","auth","proxy"],i=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];P.forEach(r,(function(e){void 0!==t[e]&&(n[e]=t[e])})),P.forEach(o,(function(r){P.isObject(t[r])?n[r]=P.deepMerge(e[r],t[r]):void 0!==t[r]?n[r]=t[r]:P.isObject(e[r])?n[r]=P.deepMerge(e[r]):void 0!==e[r]&&(n[r]=e[r])})),P.forEach(i,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])}));var a=r.concat(o).concat(i),s=Object.keys(t).filter((function(e){return-1===a.indexOf(e)}));return P.forEach(s,(function(r){void 0!==t[r]?n[r]=t[r]:void 0!==e[r]&&(n[r]=e[r])})),n};function ie(e){this.defaults=e,this.interceptors={request:new z,response:new z}}ie.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=oe(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[re,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},ie.prototype.getUri=function(e){return e=oe(this.defaults,e),F(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},P.forEach(["delete","get","head","options"],(function(e){ie.prototype[e]=function(t,n){return this.request(P.merge(n||{},{method:e,url:t}))}})),P.forEach(["post","put","patch"],(function(e){ie.prototype[e]=function(t,n,r){return this.request(P.merge(r||{},{method:e,url:t,data:n}))}}));var ae=ie;function se(e){this.message=e}se.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},se.prototype.__CANCEL__=!0;var ue=se;function ce(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new ue(e),t(n.reason))}))}ce.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ce.source=function(){var e;return{token:new ce((function(t){e=t})),cancel:e}};var fe=ce;function le(e){var t=new ae(e),n=T(ae.prototype.request,t);return P.extend(n,ae.prototype,t),P.extend(n,t),n}var de=le(te);de.Axios=ae,de.create=function(e){return le(oe(de.defaults,e))},de.Cancel=ue,de.CancelToken=fe,de.isCancel=I,de.all=function(e){return Promise.all(e)},de.spread=function(e){return function(t){return e.apply(null,t)}};var pe=de,he=de;pe.default=he;var me=pe;function ge(e){let t,n,r,o;return{c(){t=c("div"),n=c("div"),r=c("a"),o=f(e[1]),p(r,"class","result"),p(r,"href",e[1]),p(n,"class","mui-col-lg-12"),p(n,"id","link"),p(t,"class","mui-row")},m(e,i){s(e,t,i),a(t,n),a(n,r),a(r,o)},p(e,t){2&t&&function(e,t){t=""+t,e.data!==t&&(e.data=t)}(o,e[1]),2&t&&p(r,"href",e[1])},d(e){e&&u(t)}}}function ye(t){let n,o,i,m,g,y,v,b,w,x,E,S,C,$,R,j=t[1].length>0&&ge(t);return{c(){n=c("main"),o=c("div"),i=c("div"),i.textContent="nURL",m=l(),g=c("div"),g.textContent="nurl.co",y=l(),v=c("div"),b=c("div"),w=c("input"),x=l(),E=c("button"),S=f("SHORTEN"),$=l(),j&&j.c(),p(i,"class","mui--text-display3"),p(g,"class","mui--text-subhead"),p(w,"id","url-field"),p(w,"placeholder","Paste a link..."),p(w,"type","url"),p(b,"class","mui-textfield"),p(E,"class","mui-btn mui-btn--raised mui-btn--accent btn-shorten"),p(E,"id","btn-shorten"),p(E,"type","button"),E.disabled=C=!t[2],p(v,"class","mui-panel"),p(o,"class","mui-container-fluid")},m(e,u,c){s(e,n,u),a(n,o),a(o,i),a(o,m),a(o,g),a(o,y),a(o,v),a(v,b),a(b,w),h(w,t[0]),a(v,x),a(v,E),a(E,S),a(v,$),j&&j.m(v,null),c&&r(R),R=[d(w,"input",t[5]),d(E,"click",t[3])]},p(e,[t]){1&t&&h(w,e[0]),4&t&&C!==(C=!e[2])&&(E.disabled=C),e[1].length>0?j?j.p(e,t):(j=ge(e),j.c(),j.m(v,null)):j&&(j.d(1),j=null)},i:e,o:e,d(e){e&&u(n),j&&j.d(),r(R)}}}let ve=/([a-z]{1,2}tps?):\/\/((?:(?!(?:\/|#|\?|&)).)+)(?:(\/(?:(?:(?:(?!(?:#|\?|&)).)+\/))?))?(?:((?:(?!(?:\.|$|\?|#)).)+))?(?:(\.(?:(?!(?:\?|$|#)).)+))?(?:(\?(?:(?!(?:$|#)).)+))?(?:(#.+))?/i;function be(e,t,n){let r,o="",i="";async function a(e){await me.post("/api/v1/shorten",e).then(e=>{200===e.status&&(console.log(">> shortUrl",e.data.shortUrl),n(1,i=e.data.shortUrl))}).catch(e=>{console.error(e)})}return e.$$.update=()=>{1&e.$$.dirty&&n(0,o=o.trim()),1&e.$$.dirty&&n(2,r=ve.test(o))},[o,i,r,async function(){console.log("Shorten...");const e={url:o};await a(e)},a,function(){o=this.value,n(0,o)}]}return new class extends class{$destroy(){!function(e,t){const n=e.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=e}$on(e,t){const n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}$set(){}}{constructor(e){super(),O(this,e,be,ye,i,{})}}({target:document.body,props:{}})}();
|