parcoursup/node_modules/rawth/rawth.min.js
lalBi94 7bc56c09b5 $
2023-03-05 13:23:23 +01:00

2 lines
7.0 KiB
JavaScript

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).rawth={})}(this,(function(e){"use strict";function r(e,r){void 0===r&&(r={});for(var t=function(e){for(var r=[],t=0;t<e.length;){var n=e[t];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)r.push({type:"CHAR",index:t,value:e[t++]});else{var i=1,o="";if("?"===e[a=t+1])throw new TypeError('Pattern cannot start with "?" at '+a);for(;a<e.length;)if("\\"!==e[a]){if(")"===e[a]){if(0==--i){a++;break}}else if("("===e[a]&&(i++,"?"!==e[a+1]))throw new TypeError("Capturing groups are not allowed at "+a);o+=e[a++]}else o+=e[a++]+e[a++];if(i)throw new TypeError("Unbalanced pattern at "+t);if(!o)throw new TypeError("Missing pattern at "+t);r.push({type:"PATTERN",index:t,value:o}),t=a}else{for(var f="",a=t+1;a<e.length;){var s=e.charCodeAt(a);if(!(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||95===s))break;f+=e[a++]}if(!f)throw new TypeError("Missing parameter name at "+t);r.push({type:"NAME",index:t,value:f}),t=a}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r}(e),i=r.prefixes,o=void 0===i?"./":i,f="[^"+n(r.delimiter||"/#?")+"]+?",a=[],s=0,u=0,p="",c=function(e){if(u<t.length&&t[u].type===e)return t[u++].value},d=function(e){var r=c(e);if(void 0!==r)return r;var n=t[u],i=n.type,o=n.index;throw new TypeError("Unexpected "+i+" at "+o+", expected "+e)},l=function(){for(var e,r="";e=c("CHAR")||c("ESCAPED_CHAR");)r+=e;return r};u<t.length;){var v=c("CHAR"),h=c("NAME"),y=c("PATTERN");if(h||y){var m=v||"";-1===o.indexOf(m)&&(p+=m,m=""),p&&(a.push(p),p=""),a.push({name:h||s++,prefix:m,suffix:"",pattern:y||f,modifier:c("MODIFIER")||""})}else{var x=v||c("ESCAPED_CHAR");if(x)p+=x;else if(p&&(a.push(p),p=""),c("OPEN")){m=l();var E=c("NAME")||"",g=c("PATTERN")||"",w=l();d("CLOSE"),a.push({name:E||(g?s++:""),pattern:E&&!g?f:g,prefix:m,suffix:w,modifier:c("MODIFIER")||""})}else d("END")}}return a}function t(e,t){return function(e,r){void 0===r&&(r={});var t=i(r),n=r.encode,o=void 0===n?function(e){return e}:n,f=r.validate,a=void 0===f||f,s=e.map((function(e){if("object"==typeof e)return new RegExp("^(?:"+e.pattern+")$",t)}));return function(r){for(var t="",n=0;n<e.length;n++){var i=e[n];if("string"!=typeof i){var f=r?r[i.name]:void 0,u="?"===i.modifier||"*"===i.modifier,p="*"===i.modifier||"+"===i.modifier;if(Array.isArray(f)){if(!p)throw new TypeError('Expected "'+i.name+'" to not repeat, but got an array');if(0===f.length){if(u)continue;throw new TypeError('Expected "'+i.name+'" to not be empty')}for(var c=0;c<f.length;c++){var d=o(f[c],i);if(a&&!s[n].test(d))throw new TypeError('Expected all "'+i.name+'" to match "'+i.pattern+'", but got "'+d+'"');t+=i.prefix+d+i.suffix}}else if("string"!=typeof f&&"number"!=typeof f){if(!u){var l=p?"an array":"a string";throw new TypeError('Expected "'+i.name+'" to be '+l)}}else{d=o(String(f),i);if(a&&!s[n].test(d))throw new TypeError('Expected "'+i.name+'" to match "'+i.pattern+'", but got "'+d+'"');t+=i.prefix+d+i.suffix}}else t+=i}return t}}(r(e,t),t)}function n(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function i(e){return e&&e.sensitive?"":"i"}function o(e,t,o){return function(e,r,t){void 0===t&&(t={});for(var o=t.strict,f=void 0!==o&&o,a=t.start,s=void 0===a||a,u=t.end,p=void 0===u||u,c=t.encode,d=void 0===c?function(e){return e}:c,l="["+n(t.endsWith||"")+"]|$",v="["+n(t.delimiter||"/#?")+"]",h=s?"^":"",y=0,m=e;y<m.length;y++){var x=m[y];if("string"==typeof x)h+=n(d(x));else{var E=n(d(x.prefix)),g=n(d(x.suffix));if(x.pattern)if(r&&r.push(x),E||g)if("+"===x.modifier||"*"===x.modifier){var w="*"===x.modifier?"?":"";h+="(?:"+E+"((?:"+x.pattern+")(?:"+g+E+"(?:"+x.pattern+"))*)"+g+")"+w}else h+="(?:"+E+"("+x.pattern+")"+g+")"+x.modifier;else h+="("+x.pattern+")"+x.modifier;else h+="(?:"+E+g+")"+x.modifier}}if(p)f||(h+=v+"?"),h+=t.endsWith?"(?="+l+")":"$";else{var b=e[e.length-1],R="string"==typeof b?v.indexOf(b[b.length-1])>-1:void 0===b;f||(h+="(?:"+v+"(?="+l+"))?"),R||(h+="(?="+v+"|"+l+")")}return new RegExp(h,i(t))}(r(e,o),t,o)}function f(e,r,t){return e instanceof RegExp?function(e,r){if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,i=t.exec(e.source);i;)r.push({name:i[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),i=t.exec(e.source);return e}(e,r):Array.isArray(e)?function(e,r,t){var n=e.map((function(e){return f(e,r,t).source}));return new RegExp("(?:"+n.join("|")+")",i(t))}(e,r,t):o(e,r,t)}const a=Symbol();function s(...e){return new Promise((r,t)=>function e(n,i){if(!n.length)return r(i);const[o,...f]=n,s="function"==typeof o?o(i):o,u=r=>e(f,r);if(null!=s){if(s===a)return;if(s.then)return s.then(u,t)}return Promise.resolve(u(s))}(e))}s.cancel=()=>a,s.compose=(...e)=>s(...e.reverse());const u=new Set,p=Symbol();function c(e,r){return e.forEach(t=>{t(r)===p&&e.delete(t)}),e}function d(e){throw new Error(e)}function l(...e){const[r,t,n,i]=[new Set,new Set,new Set,new Set(e)],o=function(e){const r=function*(){for(;;){const r=yield;yield s(r,...e)}}();return r.next(),r}(i),f=Object.create(o),a=e=>r=>e.add(r)&&f,u=e=>r=>e.delete(r)?f:d("Couldn't remove handler passed by reference");return Object.assign(f,{on:Object.freeze({value:a(r),error:a(t),end:a(n)}),off:Object.freeze({value:u(r),error:u(t),end:u(n)}),connect:a(i),push(e){const{value:n,done:i}=f.next(e);return i||n.then(e=>c(r,e),e=>c(t,e)),f},end:()=>(o.return(),c(n),[r,t,n,i].forEach(e=>e.clear()),f),fork:()=>l(...i),next(e){const r=o.next(e);return o.next(),r}})}l.install=function(e,r){return e&&"string"==typeof e||d("Please provide a name (as string) for your erre plugin"),r&&"function"==typeof r||d("Please provide a function for your erre plugin"),u.has(e)?d(`The ${e} is already part of the erre API, please provide a different name`):(l[e]=r,u.add(e)),l},l.install("cancel",s.cancel),l.install("off",()=>p);const v="undefined"!=typeof process,h=e=>e.replace(g.base,""),y=e=>r=>R(r,e)?r:l.cancel(),m=e=>{if(!g.silentErrors)throw new Error(e)},x=e=>(e=>"string"==typeof e)(e)?e:l.cancel(),E=l(x).on.error(m),g={base:"",silentErrors:!1,sensitive:!1,strict:!1,end:!0,start:!0,delimiter:"/#?",encode:void 0,endsWith:void 0,prefixes:"./"},w=e=>({...g,...e}),b=(e,r,t={})=>{const{base:n}=w(t),[,...i]=r.exec(e),o=((...e)=>v?require("url").parse(...e):new URL(...e))(e,n);return o.params=i.reduce((e,r,n)=>{const i=t.keys&&t.keys[n];return i&&(e[i.name]=r?decodeURIComponent(r):r),e},{}),o},R=(e,r)=>r.test(e),A=(e,r)=>[decodeURI,h,y(e),t=>b(t,e,r)];e.createURLStreamPipe=A,e.default=function(e,r){const t=[],n=f(e,t,r),i=l(...A(n,{...r,keys:t}));return(o=E,a=i,o.on.value(a.push),a.on.end(()=>{o.off.value(a.push)}),a).on.error(m);var o,a},e.defaults=g,e.filterStrings=x,e.match=R,e.mergeOptions=w,e.router=E,e.toPath=(e,r,n)=>t(e,w(n))(r),e.toRegexp=(e,r,t)=>f(e,r,w(t)),e.toURL=b,Object.defineProperty(e,"__esModule",{value:!0})}));