define(["require","exports","typescript/libraries/file-viewer/src/preview_audio_video/helper/exception"],(function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.QueryComponent=e.URI=void 0;const i=/^(?:([^:\/\\?#]+):)?(?:[\/\\]{2}([^\/\\?#]*))?([^?#]*)(?:\?([^#]*))?(?:[#](.*))?$/,s=/^[a-zA-Z][a-zA-Z0-9+.\-]*$/;class n{constructor(t={}){this.dict={},this.add(t)}static parseString(t){if(!t)return{};const e={};return t.split("&").forEach(t=>{if(""!==t){const r=t.split("="),i=n.decode(r[0]),s=n.decode(r.slice(1).join("="));if(e.hasOwnProperty(i)){const t=e[i];let r;r="string"==typeof t?[t]:void 0===t?[]:t,r.push(s),e[i]=r}else e[i]=s}}),e}add(t,e){if("string"==typeof t)e&&(Array.isArray(e)?this.dict[t]=e.map(String):this.dict[t]=String(e));else for(const e in t)if(t.hasOwnProperty(e)){const r=t[e];null!=r&&(Array.isArray(r)?this.dict[e]=r.map(String):this.dict[e]=String(r))}return this}remove(t){return delete this.dict[t],this}replace(t){return this.dict=t,this}toString(){const t=[],e=Object.keys(this.dict).sort();for(const r of e)if(this.dict.hasOwnProperty(r)){const e=this.dict[r];Array.isArray(e)?e.forEach(e=>{t.push(n.encode(r)+"="+n.encode(e))}):t.push(n.encode(r)+"="+n.encode(e))}return t.length?t.join("&"):""}static decode(t){return null==t?"":h.decode(t.replace(/\+/g,"%20"))}static encode(t){return null==t?"":h.encode(t).replace(/%20/g,"+")}}e.QueryComponent=n;class h{constructor(t={}){this.scheme="",this.authority="",this.path="",this.fragment="",this.query=new n,this.initFromObject(t)}initFromObject(t){this.setScheme(t.scheme),this.authority=t.authority||"",this.path=t.path||"",this.setQuery(t.query),this.fragment=t.fragment||""}getScheme(){return this.scheme}getAuthority(){return this.authority}getPath(){return this.path}getQuery(){return this.query.dict}getFragment(){return this.fragment}setScheme(t=""){const e=!t||Boolean(t.match(s));return r.assert(e,"Invalid scheme",{exc_extra:{scheme_param:t}}),this.scheme=t,this}setAuthority(t=""){return this.authority=t,this}setPath(t=""){return this.path=t,this}setQuery(t={}){return this.query=new n(t),this}setFragment(t=""){return this.fragment=t,this}updateQuery(t,e){return this.query.add(t,e),this}removeQuery(t){return this.query.remove(t),this}clone(){return new h(this.toObject())}toObject(){return{scheme:this.getScheme(),authority:this.getAuthority(),path:this.getPath(),query:this.getQuery(),fragment:this.getFragment()}}toString(){let t="";this.scheme&&(t+=this.scheme+":"),this.authority&&(t+="//"+h.encode(this.authority,":@[]")),this.path&&(r.assert(!this.authority||!this.path.length||"/"===this.path[0],'Path must start with a "/" if URI is not relative'),t+=h.encode(this.path,"/"));const e=this.query.toString();return e&&(t+="?"+e),this.fragment&&(t+="#"+h.encode(this.fragment,":@[]/&=+?#!")),t}static parse(t){const e=String(t).match(i)||[],[,r,s,o,c,a]=e,u=new h;return u.setScheme(r),u.setAuthority(h.decode(s)),u.setPath(h.decode(o)),u.setQuery(n.parseString(c)),u.setFragment(h.decode(a)),u}static decode(t){return t?decodeURIComponent(t):""}static encode(t,e=""){if(!t)return"";t=encodeURIComponent(t),e+="~";for(const r of e){const e=encodeURIComponent(r);t=t.replace(new RegExp(e,"g"),r)}return t}static encode_parts(t,e="/"){return t.split(e).map(t=>h.encode(t)).join(e)}}e.URI=h,h.Query=n})); //# sourceMappingURL=uri.amd.min.js-vflUMz0xz.map