"use strict";var A=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var L=(s,t)=>{for(var e in t)A(s,e,{get:t[e],enumerable:!0})},v=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of k(t))!I.call(s,n)&&n!==e&&A(s,n,{get:()=>t[n],enumerable:!(r=D(t,n))||r.enumerable});return s};var F=s=>v(A({},"__esModule",{value:!0}),s);var G={};L(G,{createClient:()=>Q});module.exports=F(G);var N={"Content-Type":"application/json"},W=/\{[^{}]+\}/g,S=class extends Request{constructor(t,e){super(t,e);for(let r in e)r in this||(this[r]=e[r])}};function E(s){let{baseUrl:t="",fetch:e=globalThis.fetch,querySerializer:r,bodySerializer:n,headers:o,...a}={...s};t.endsWith("/")&&(t=t.substring(0,t.length-1)),o=C(N,o);let l=[];async function u(c,i){let{fetch:h=e,headers:H,params:R={},parseAs:j="json",querySerializer:b,bodySerializer:T=n??M,...P}=i||{},x=typeof r=="function"?r:O(r);b&&(x=typeof b=="function"?b:O({...typeof r=="object"?r:{},...b}));let p={redirect:"follow",...a,...P,headers:C(o,H,R.header)};p.body&&(p.body=T(p.body)),p.body instanceof FormData&&p.headers.delete("Content-Type");let m=new S(B(c,{baseUrl:t,params:R,querySerializer:x}),p),z={baseUrl:t,fetch:h,parseAs:j,querySerializer:x,bodySerializer:T};for(let d of l)if(d&&typeof d=="object"&&typeof d.onRequest=="function"){m.schemaPath=c,m.params=R;let y=await d.onRequest(m,z);if(y){if(!(y instanceof Request))throw new Error("Middleware must return new Request() when modifying the request");m=y}}let f=await h(m);for(let d=l.length-1;d>=0;d--){let y=l[d];if(y&&typeof y=="object"&&typeof y.onResponse=="function"){let g=await y.onResponse(f,z);if(g){if(!(g instanceof Response))throw new Error("Middleware must return new Response() when modifying the response");f=g}}}if(f.status===204||f.headers.get("Content-Length")==="0")return f.ok?{data:{},response:f}:{error:{},response:f};if(f.ok)return j==="stream"?{data:f.body,response:f}:{data:await f[j](),response:f};let $=await f.text();try{$=JSON.parse($)}catch{}return{error:$,response:f}}return{async GET(c,i){return u(c,{...i,method:"GET"})},async PUT(c,i){return u(c,{...i,method:"PUT"})},async POST(c,i){return u(c,{...i,method:"POST"})},async DELETE(c,i){return u(c,{...i,method:"DELETE"})},async OPTIONS(c,i){return u(c,{...i,method:"OPTIONS"})},async HEAD(c,i){return u(c,{...i,method:"HEAD"})},async PATCH(c,i){return u(c,{...i,method:"PATCH"})},async TRACE(c,i){return u(c,{...i,method:"TRACE"})},use(...c){for(let i of c)if(i){if(typeof i!="object"||!("onRequest"in i||"onResponse"in i))throw new Error("Middleware must be an object with one of `onRequest()` or `onResponse()`");l.push(i)}},eject(...c){for(let i of c){let h=l.indexOf(i);h!==-1&&l.splice(h,1)}}}}function w(s,t,e){if(t==null)return"";if(typeof t=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${s}=${e?.allowReserved===!0?t:encodeURIComponent(t)}`}function q(s,t,e){if(!t||typeof t!="object")return"";let r=[],n={simple:",",label:".",matrix:";"}[e.style]||"&";if(e.style!=="deepObject"&&e.explode===!1){for(let l in t)r.push(l,e.allowReserved===!0?t[l]:encodeURIComponent(t[l]));let a=r.join(",");switch(e.style){case"form":return`${s}=${a}`;case"label":return`.${a}`;case"matrix":return`;${s}=${a}`;default:return a}}for(let a in t){let l=e.style==="deepObject"?`${s}[${a}]`:a;r.push(w(l,t[a],e))}let o=r.join(n);return e.style==="label"||e.style==="matrix"?`${n}${o}`:o}function U(s,t,e){if(!Array.isArray(t))return"";if(e.explode===!1){let o={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[e.style]||",",a=(e.allowReserved===!0?t:t.map(l=>encodeURIComponent(l))).join(o);switch(e.style){case"simple":return a;case"label":return`.${a}`;case"matrix":return`;${s}=${a}`;default:return`${s}=${a}`}}let r={simple:",",label:".",matrix:";"}[e.style]||"&",n=[];for(let o of t)e.style==="simple"||e.style==="label"?n.push(e.allowReserved===!0?o:encodeURIComponent(o)):n.push(w(s,o,e));return e.style==="label"||e.style==="matrix"?`${r}${n.join(r)}`:n.join(r)}function O(s){return function(e){let r=[];if(e&&typeof e=="object")for(let n in e){let o=e[n];if(o!=null){if(Array.isArray(o)){r.push(U(n,o,{style:"form",explode:!0,...s?.array,allowReserved:s?.allowReserved||!1}));continue}if(typeof o=="object"){r.push(q(n,o,{style:"deepObject",explode:!0,...s?.object,allowReserved:s?.allowReserved||!1}));continue}r.push(w(n,o,s))}}return r.join("&")}}function _(s,t){let e=s;for(let r of s.match(W)??[]){let n=r.substring(1,r.length-1),o=!1,a="simple";if(n.endsWith("*")&&(o=!0,n=n.substring(0,n.length-1)),n.startsWith(".")?(a="label",n=n.substring(1)):n.startsWith(";")&&(a="matrix",n=n.substring(1)),!t||t[n]===void 0||t[n]===null)continue;let l=t[n];if(Array.isArray(l)){e=e.replace(r,U(n,l,{style:a,explode:o}));continue}if(typeof l=="object"){e=e.replace(r,q(n,l,{style:a,explode:o}));continue}if(a==="matrix"){e=e.replace(r,`;${w(n,l)}`);continue}e=e.replace(r,a==="label"?`.${l}`:l)}return e}function M(s){return JSON.stringify(s)}function B(s,t){let e=`${t.baseUrl}${s}`;t.params?.path&&(e=_(e,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith("?")&&(r=r.substring(1)),r&&(e+=`?${r}`),e}function C(...s){let t=new Headers;for(let e of s){if(!e||typeof e!="object")continue;let r=e instanceof Headers?e.entries():Object.entries(e);for(let[n,o]of r)if(o===null)t.delete(n);else if(Array.isArray(o))for(let a of o)t.append(n,a);else o!==void 0&&t.set(n,o)}return t}function Q({token:s}){return E({baseUrl:"https://api.vultr.com/v2",headers:{Authorization:`Bearer ${s}`}})}