"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@zero-dependency/utils"),a=(r,e)=>r;class h{#o;#e;#t;constructor({encode:e=a,decode:o=a,attributes:i={},initialValue:t}={}){if(this.#o=e,this.#e=o,this.attributes=i,t)for(const[s,n]of u.entries(t))this.has(s)||this.set(s,n)}get attributes(){return this.#t}set attributes(e){this.#t=e}get(e){const o=`; ${document.cookie}`.match(`;\\s*${e}=([^;]+)`);return o?this.#e(decodeURIComponent(o[1]),e):null}set(e,o,i){const t={path:"/",...this.#t,...i};typeof t.expires=="number"&&(t.expires=new Date(Date.now()+t.expires*864e5)),t.expires instanceof Date&&(t.expires=t.expires.toUTCString());let s=`${encodeURIComponent(e)}=${encodeURIComponent(this.#o(o,e))}`;for(const[n,c]of u.entries(t))s+=`; ${n}`,c!==!0&&(s+=`=${c}`);document.cookie=s}list(){const e=document.cookie,i=(e?e.split("; "):[]).map(t=>{const[s,n]=t.split(/=(.*)/);return[s,this.#e(decodeURIComponent(n),s)]});return Object.fromEntries(i)}remove(e,o){this.set(e,null,{...o,expires:-1})}has(e){return!!this.get(e)}}exports.Cookie=h; //# sourceMappingURL=index.cjs.map