harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
1 lines • 24.5 kB
JavaScript
;(self.webpackChunkharperdb_studio=self.webpackChunkharperdb_studio||[]).push([[881],{6304:(e,t,r)=>{r.r(t),r.d(t,{default:()=>y});var n=r(9379),o=r(9950),i=r(9708),s=r(1646),a=r(5488),c=r(3452),l=r(5077),u=r(6713),f=r(4979),p=r(4319),d=r(5911),m=r(5553),b=r(4414);const y=function(){const e=(0,u.O$)(m.A,(e=>{var t;return null===(t=e.instances.find((e=>"local"===e.compute_stack_id)))||void 0===t?void 0:t.url})),[t,r]=(0,o.useState)({}),[y,g]=(0,o.useState)({}),[h,v]=(0,p.A)({}),j=(0,l.Zp)(),O=async()=>{r({submitted:!0});const{user:t,pass:o}=y;if(t&&o){const i=await(0,d.A)({auth:{user:t,pass:o},url:e});i.error&&"catch"===i.type?r({error:"SSL ERROR. ACCEPT SELF-SIGNED CERT?",url:e}):i.error&&"Login failed"===i.message||"Login failed"===i.error?r({error:"Login failed. Using instance credentials?",url:"https://harperdb.io/docs/harperdb-studio/instances/#instance-login"}):i.error?r({error:i.message||i.error}):(v((0,n.A)((0,n.A)({},h),{},{local:{valid:!0,user:y.user,pass:y.pass,super:i.role.permission.super_user,structure:i.role.permission.structure_user}})),setTimeout(j("/o/local/i/local/browse"),0))}else r({error:"All fields are required"})},x=e=>{"Enter"===e.code&&O()};return(0,b.jsx)("div",{className:"login-form",children:t.submitted?(0,b.jsx)(f.A,{header:"Signing in",spinner:!0,relative:!0}):(0,b.jsxs)(i.A,{children:[(0,b.jsx)("h2",{className:"mb-2 instructions",children:"Please sign into Harper"}),t.error&&(0,b.jsxs)("a",{href:t.url||null,target:"_blank",rel:"noopener noreferrer",className:"my-2 text-center text-bold text-small d-block text-nowrap text-decoration-none",children:[(0,b.jsx)("span",{className:"login-nav-link error",children:t.error}),t.url&&(0,b.jsx)("i",{className:"ms-2 fa fa-lg fa-external-link-square text-danger"})]}),(0,b.jsxs)(s.A,{className:"mb-3 d-block",children:[(0,b.jsx)("span",{className:"mb-2 d-inline-block",children:"Instance user"}),(0,b.jsx)(a.A,{id:"username",autoComplete:"username",required:!0,onChange:e=>g((0,n.A)((0,n.A)({},y),{},{user:e.target.value})),type:"text",title:"instance user",placeholder:"Instance user",value:y.user||"",disabled:t.submitted,onKeyDown:x})]}),(0,b.jsxs)(s.A,{className:"mb-4 d-block",children:[(0,b.jsx)("span",{className:"mb-2 d-inline-block",children:"Password"}),(0,b.jsx)(a.A,{id:"password",name:"password",required:!0,autoComplete:"current-password",onChange:e=>g((0,n.A)((0,n.A)({},y),{},{pass:e.target.value})),className:"mb-2",type:"password",title:"instance password",placeholder:"Instance password",disabled:t.submitted,value:y.pass||"",onKeyDown:x})]}),(0,b.jsx)(c.A,{id:"signIn",className:"border-0 rounded-pill btn-gradient-blue",onClick:O,title:"Sign In My Account",block:!0,disabled:t.submitted,children:"Sign In"})]})})}},5559:(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var n=r(9379),o=r(9950),i=r(9708),s=r(1646),a=r(5488),c=r(3452),l=r(5077),u=r(6713),f=r(4283),p=r(5553),d=r(3304),m=r(1440),b=r(4979),y=r(5283),g=r(4414);const h=function(){const{search:e}=(0,l.zy)(),{user:t,token:r}=f.A.parse(e,{decode:!1}),h=(0,u.O$)(p.A,(e=>e.theme)),[v,j]=(0,o.useState)({}),[O,x]=(0,o.useState)({}),[w,k]=(0,y.A)({});return(0,o.useEffect)((()=>{t&&r&&(0,d.A)({email:t,pass:r,loggingIn:!0})}),[t,r]),(0,g.jsx)("div",{className:"login-form",children:v.processing?(0,g.jsx)(b.A,{header:"signing in",spinner:!0,relative:!0}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(i.A,{children:[(0,g.jsx)("h2",{className:"mb-2 instructions",children:"Sign in to Harper Studio"}),(0,g.jsx)("span",{className:"login-nav-link error d-inline-block",children:v.error}),(0,g.jsxs)(s.A,{className:"mb-3 d-block",children:[(0,g.jsx)("span",{className:"mb-2 d-inline-block",children:"Email"}),(0,g.jsx)(a.A,{name:"email",autoComplete:"email",required:!0,id:"email",onChange:e=>{e.currentTarget.focus(),x((0,n.A)((0,n.A)({},O),{},{email:e.target.value.trim().toLowerCase()}))},value:O.email||"",disabled:v.submitted,type:"text",title:"email",placeholder:"email address"})]}),(0,g.jsxs)(s.A,{className:"mb-4 d-block",children:[(0,g.jsx)("span",{className:"mb-2 d-inline-block",children:"Password"}),(0,g.jsx)(a.A,{id:"password",required:!0,onChange:e=>{e.currentTarget.focus(),x((0,n.A)((0,n.A)({},O),{},{pass:e.target.value}))},value:O.pass||"",disabled:v.submitted,type:"password",title:"password",name:"password",autoComplete:"current-password",placeholder:"password"})]}),(0,g.jsx)(c.A,{id:"signIn",type:"submit",className:"border-0 rounded-pill btn-gradient-blue",onClick:async()=>{j({submitted:!0});const{email:e,pass:t}=O;if((0,m.A)(e))if(t)if("akamai"===h&&-1===O.email.indexOf("harperdb.io")&&-1===O.email.indexOf("akamai.com")&&-1===O.email.indexOf("walmart.com"))j({error:"Portal access denied"});else{j({processing:!0});const r=await(0,d.A)({email:e,pass:t,loggingIn:!0});if(!r||null!==r&&void 0!==r&&r.error)j({error:["Unauthorized","User does not exist"].includes(null===r||void 0===r?void 0:r.message)?"Login Failed":(null===r||void 0===r?void 0:r.message)||"Login Failed"}),setTimeout((()=>j({})),5e3);else{k((0,n.A)((0,n.A)({},w),{},{email:e,pass:t}));const r={username:e,type:"email",company:e.split("@")[1]};Reo.identify(r)}}else j({error:"Password is required"});else j({error:"A valid email is required"})},title:"Sign In My Account",block:!0,disabled:v.submitted,children:"Sign In"})]}),(0,g.jsxs)("div",{className:"px-4 mt-3 d-flex justify-content-between",children:[(0,g.jsx)(l.k2,{to:"/sign-up",className:"login-nav-link d-inline-block",children:"Sign Up for Free"}),(0,g.jsx)(l.k2,{to:"/reset-password",className:"login-nav-link d-inline-block",children:"Reset Password"})]})]})})}},5911:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(127);const o=async e=>{let{auth:t,url:r}=e;return(0,n.A)({operation:{operation:"user_info"},auth:t,url:r,timeout:5e3})}},127:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(4038);const o=async e=>{let{operation:t,auth:r,url:o,timeout:i=0,authType:s,signal:a}=e;try{const e=new AbortController,u=setTimeout((()=>i?e.abort():null),i),f={"Content-Type":"application/json"};"token"===s?f.Authorization="Bearer ".concat(r.token):null!==r&&void 0!==r&&r.pass&&(f.Authorization="Basic ".concat(btoa("".concat(r.user,":").concat(r.pass))));const p=await(0,n.hd)(o,{signal:a||e.signal,method:"POST",body:JSON.stringify(t),headers:f,credentials:f.Authorization?"omit":"include"});clearTimeout(u);const d=await p.json();var c,l;return d.error?{error:!0,message:d.error,type:"response",status:p.status,role_errors:null===(c=d.main_permissions)||void 0===c?void 0:c.join(", "),access_errors:null===(l=d.unauthorized_access)||void 0===l?void 0:l.map((e=>{var t,r,n,o,i,s;return{schema:e.schema,table:e.table,type:null!==(t=e.required_attribute_permissions)&&void 0!==t&&t.length?"attribute":"table",entity:null!==(r=e.required_attribute_permissions)&&void 0!==r&&r.length?null===(n=e.required_attribute_permissions[0])||void 0===n?void 0:n.attribute_name:e.table,permission:null!==(o=e.required_attribute_permissions)&&void 0!==o&&o.length?null===(i=e.required_attribute_permissions[0])||void 0===i?void 0:i.required_permissions.join(", "):null===(s=e.required_table_permissions)||void 0===s?void 0:s.join(", ")}}))}:200!==p.status?{error:!0,message:"Error of type ".concat(p.status),type:"status"}:d}catch(u){return{error:!0,message:u.message,type:"catch"}}}},4319:(e,t,r)=>{r.d(t,{A:()=>n});const n=(0,r(6997).A)("instanceAuths")},1440:(e,t,r)=>{r.d(t,{A:()=>n});const n=e=>/^\S+@\S+\.\S+$/.test(String(e).toLowerCase())},9708:(e,t,r)=>{r.d(t,{A:()=>h});var n=r(9950),o=r(1942),i=r.n(o),s=r(1497);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}var c=["className","cssModule","tag","innerRef"];function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(this,arguments)}function u(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function d(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b(e);if(t){var o=b(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===a(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}(this,r)}}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}var y={children:i().node,tag:s.Wx,innerRef:i().oneOfType([i().object,i().func,i().string]),className:i().string,cssModule:i().object},g=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(a,e);var t,r,o,i=d(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=i.call(this,e)).getRef=t.getRef.bind(m(t)),t.submit=t.submit.bind(m(t)),t}return t=a,(r=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"submit",value:function(){this.ref&&this.ref.submit()}},{key:"render",value:function(){var e=this.props,t=e.className,r=e.cssModule,o=e.tag,i=void 0===o?"form":o,a=e.innerRef,f=u(e,c),p=(0,s.qO)(t,r);return n.createElement(i,l({},f,{ref:a,className:p}))}}])&&f(t.prototype,r),o&&f(t,o),Object.defineProperty(t,"prototype",{writable:!1}),a}(n.Component);g.propTypes=y;const h=g},5488:(e,t,r)=>{r.d(t,{A:()=>j});var n=r(9950),o=r(1942),i=r.n(o),s=r(8738),a=r.n(s),c=r(1497);function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}var u=["className","cssModule","type","bsSize","valid","invalid","tag","addon","plaintext","innerRef"];function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},f.apply(this,arguments)}function p(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function b(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=g(e);if(t){var o=g(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}(this,r)}}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}var h={children:i().node,type:i().string,size:i().oneOfType([i().number,i().string]),bsSize:i().string,valid:i().bool,invalid:i().bool,tag:c.Wx,innerRef:i().oneOfType([i().object,i().func,i().string]),plaintext:i().bool,addon:i().bool,className:i().string,cssModule:i().object},v=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(s,e);var t,r,o,i=b(s);function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(t=i.call(this,e)).getRef=t.getRef.bind(y(t)),t.focus=t.focus.bind(y(t)),t}return t=s,(r=[{key:"getRef",value:function(e){this.props.innerRef&&this.props.innerRef(e),this.ref=e}},{key:"focus",value:function(){this.ref&&this.ref.focus()}},{key:"render",value:function(){var e=this.props,t=e.className,r=e.cssModule,o=e.type,i=void 0===o?"text":o,s=e.bsSize,l=e.valid,d=e.invalid,m=e.tag,b=e.addon,y=e.plaintext,g=e.innerRef,h=p(e,u),v=["switch","radio","checkbox"].indexOf(i)>-1,j="select"===i,O="range"===i,x=m||(j||"textarea"===i?i:"input"),w="form-control";y?(w="".concat(w,"-plaintext"),x=m||"input"):O?w="form-range":j?w="form-select":v&&(w=b?null:"form-check-input"),h.size&&/\D/g.test(h.size)&&((0,c.mc)('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.'),s=h.size,delete h.size);var k=(0,c.qO)(a()(t,d&&"is-invalid",l&&"is-valid",!!s&&(j?"form-select-".concat(s):"form-control-".concat(s)),w),r);return("input"===x||m&&"function"===typeof m)&&(h.type="switch"===i?"checkbox":i),h.children&&!y&&"select"!==i&&"string"===typeof x&&"select"!==x&&((0,c.mc)('Input with a type of "'.concat(i,'" cannot have children. Please use "value"/"defaultValue" instead.')),delete h.children),n.createElement(x,f({},h,{ref:g,className:k,"aria-invalid":d}))}}])&&d(t.prototype,r),o&&d(t,o),Object.defineProperty(t,"prototype",{writable:!1}),s}(n.Component);v.propTypes=h;const j=v},1646:(e,t,r)=>{r.d(t,{A:()=>v});var n=r(9950),o=r(1942),i=r.n(o),s=r(8738),a=r.n(s),c=r(1497),l=["className","cssModule","hidden","widths","tag","check","size","for"];function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var d=["xs","sm","md","lg","xl","xxl"],m=i().oneOfType([i().number,i().string]),b=i().oneOfType([i().bool,i().string,i().number,i().shape({size:m,order:m,offset:m})]),y={children:i().node,hidden:i().bool,check:i().bool,size:i().string,for:i().string,tag:c.Wx,className:i().string,cssModule:i().object,xs:b,sm:b,md:b,lg:b,xl:b,xxl:b,widths:i().array},g=function(e,t,r){return!0===r||""===r?e?"col":"col-".concat(t):"auto"===r?e?"col-auto":"col-".concat(t,"-auto"):e?"col-".concat(r):"col-".concat(t,"-").concat(r)};function h(e){var t=e.className,r=e.cssModule,o=e.hidden,i=e.widths,s=void 0===i?d:i,m=e.tag,b=void 0===m?"label":m,y=e.check,h=e.size,v=e.for,j=p(e,l),O=[];s.forEach((function(t,n){var o=e[t];if(delete j[t],o||""===o){var i,s=!n;if((0,c.Gv)(o)){var l,u=s?"-":"-".concat(t,"-");i=g(s,t,o.size),O.push((0,c.qO)(a()((f(l={},i,o.size||""===o.size),f(l,"order".concat(u).concat(o.order),o.order||0===o.order),f(l,"offset".concat(u).concat(o.offset),o.offset||0===o.offset),l))),r)}else i=g(s,t,o),O.push(i)}}));var x=h||O.length,w=!(y||x),k=(0,c.qO)(a()(t,!!o&&"visually-hidden",!!y&&"form-check-label",!!h&&"col-form-label-".concat(h),O,!!x&&"col-form-label",!!w&&"form-label"),r);return n.createElement(b,u({htmlFor:v},j,{className:k}))}h.propTypes=y;const v=h},4283:(e,t,r)=>{r.d(t,{A:()=>P});var n={};r.r(n),r.d(n,{exclude:()=>R,extract:()=>x,parse:()=>w,parseUrl:()=>A,pick:()=>N,stringify:()=>k,stringifyUrl:()=>S});var o=r(9379);const i="%[a-f0-9]{2}",s=new RegExp("("+i+")|([^%]+?)","gi"),a=new RegExp("("+i+")+","gi");function c(e,t){try{return[decodeURIComponent(e.join(""))]}catch(o){}if(1===e.length)return e;t=t||1;const r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],c(r),c(n))}function l(e){try{return decodeURIComponent(e)}catch(t){let r=e.match(s)||[];for(let n=1;n<r.length;n++)r=(e=c(r,n).join("")).match(s)||[];return e}}function u(e){if("string"!==typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch(t){return function(e){const t={"%FE%FF":"\ufffd\ufffd","%FF%FE":"\ufffd\ufffd"};let r=a.exec(e);for(;r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(o){const e=l(r[0]);e!==r[0]&&(t[r[0]]=e)}r=a.exec(e)}t["%C2"]="\ufffd";const n=Object.keys(t);for(const i of n)e=e.replace(new RegExp(i,"g"),t[i]);return e}(e)}}function f(e,t){const r={};if(Array.isArray(t))for(const n of t){const t=Object.getOwnPropertyDescriptor(e,n);null!==t&&void 0!==t&&t.enumerable&&Object.defineProperty(r,n,t)}else for(const n of Reflect.ownKeys(e)){const o=Object.getOwnPropertyDescriptor(e,n);if(o.enumerable){t(n,e[n],e)&&Object.defineProperty(r,n,o)}}return r}function p(e,t){if("string"!==typeof e||"string"!==typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===e||""===t)return[];const r=e.indexOf(t);return-1===r?[]:[e.slice(0,r),e.slice(r+t.length)]}const d=e=>null===e||void 0===e,m=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,(e=>"%".concat(e.charCodeAt(0).toString(16).toUpperCase()))),b=Symbol("encodeFragmentIdentifier");function y(e){if("string"!==typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function g(e,t){return t.encode?t.strict?m(e):encodeURIComponent(e):e}function h(e,t){return t.decode?u(e):e}function v(e){return Array.isArray(e)?e.sort():"object"===typeof e?v(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function j(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function O(e,t,r){return"string"===r&&"string"===typeof e?e:"function"===typeof r&&"string"===typeof e?r(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()?"number"!==r||Number.isNaN(Number(e))||"string"!==typeof e||""===e.trim()?t.parseNumbers&&!Number.isNaN(Number(e))&&"string"===typeof e&&""!==e.trim()?Number(e):e:Number(e):"true"===e.toLowerCase()}function x(e){const t=(e=j(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function w(e,t){y((t=(0,o.A)({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null)},t)).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[])$/.exec(e),e=e.replace(/\[]$/,""),t?void 0!==n[e]?n[e]=[...n[e],r]:n[e]=[r]:n[e]=r};case"colon-list-separator":return(e,r,n)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==n[e]?n[e]=[...n[e],r]:n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const o="string"===typeof r&&r.includes(e.arrayFormatSeparator),i="string"===typeof r&&!o&&h(r,e).includes(e.arrayFormatSeparator);r=i?h(r,e):r;const s=o||i?r.split(e.arrayFormatSeparator).map((t=>h(t,e))):null===r?r:h(r,e);n[t]=s};case"bracket-separator":return(t,r,n)=>{const o=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!o)return void(n[t]=r?h(r,e):r);const i=null===r?[]:h(r,e).split(e.arrayFormatSeparator);void 0!==n[t]?n[t]=[...n[t],...i]:n[t]=i};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[...[r[e]].flat(),t]:r[e]=t}}}(t),n=Object.create(null);if("string"!==typeof e)return n;if(!(e=e.trim().replace(/^[?#&]/,"")))return n;for(const o of e.split("&")){if(""===o)continue;const e=t.decode?o.replaceAll("+"," "):o;let[i,s]=p(e,"=");void 0===i&&(i=e),s=void 0===s?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?s:h(s,t),r(h(i,t),s,n)}for(const[o,i]of Object.entries(n))if("object"===typeof i&&null!==i&&"string"!==t.types[o])for(const[e,r]of Object.entries(i)){const n=t.types[o]?t.types[o].replace("[]",""):void 0;i[e]=O(r,t,n)}else"object"===typeof i&&null!==i&&"string"===t.types[o]?n[o]=Object.values(i).join(t.arrayFormatSeparator):n[o]=O(i,t,t.types[o]);return!1===t.sort?n:(!0===t.sort?Object.keys(n).sort():Object.keys(n).sort(t.sort)).reduce(((e,t)=>{const r=n[t];return e[t]=Boolean(r)&&"object"===typeof r&&!Array.isArray(r)?v(r):r,e}),Object.create(null))}function k(e,t){if(!e)return"";y((t=(0,o.A)({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&d(e[r])||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const o=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[g(t,e),"[",o,"]"].join("")]:[...r,[g(t,e),"[",g(o,e),"]=",g(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[g(t,e),"[]"].join("")]:[...r,[g(t,e),"[]=",g(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[g(t,e),":list="].join("")]:[...r,[g(t,e),":list=",g(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(n,o)=>void 0===o||e.skipNull&&null===o||e.skipEmptyString&&""===o?n:(o=null===o?"":o,0===n.length?[[g(r,e),t,g(o,e)].join("")]:[[n,g(o,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,g(t,e)]:[...r,[g(t,e),"=",g(n,e)].join("")]}}(t),i={};for(const[o,a]of Object.entries(e))r(o)||(i[o]=a);const s=Object.keys(i);return!1!==t.sort&&s.sort(t.sort),s.map((r=>{const o=e[r];return void 0===o?"":null===o?g(r,t):Array.isArray(o)?0===o.length&&"bracket-separator"===t.arrayFormat?g(r,t)+"[]":o.reduce(n(r),[]).join("&"):g(r,t)+"="+g(o,t)})).filter((e=>e.length>0)).join("&")}function A(e,t){var r,n;t=(0,o.A)({decode:!0},t);let[i,s]=p(e,"#");return void 0===i&&(i=e),(0,o.A)({url:null!==(r=null===(n=i)||void 0===n||null===(n=n.split("?"))||void 0===n?void 0:n[0])&&void 0!==r?r:"",query:w(x(e),t)},t&&t.parseFragmentIdentifier&&s?{fragmentIdentifier:h(s,t)}:{})}function S(e,t){t=(0,o.A)({encode:!0,strict:!0,[b]:!0},t);const r=j(e.url).split("?")[0]||"",n=x(e.url);let i=k((0,o.A)((0,o.A)({},w(n,{sort:!1})),e.query),t);i&&(i="?".concat(i));let s=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(e.url);if("string"===typeof e.fragmentIdentifier){const n=new URL(r);n.hash=e.fragmentIdentifier,s=t[b]?n.hash:"#".concat(e.fragmentIdentifier)}return"".concat(r).concat(i).concat(s)}function N(e,t,r){r=(0,o.A)({parseFragmentIdentifier:!0,[b]:!1},r);const{url:n,query:i,fragmentIdentifier:s}=A(e,r);return S({url:n,query:f(i,t),fragmentIdentifier:s},r)}function R(e,t,r){return N(e,Array.isArray(t)?e=>!t.includes(e):(e,r)=>!t(e,r),r)}const P=n}}]);