(function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l.kalemah={}))})(this,function(l){"use strict";var E=Object.defineProperty;var j=(l,i,f)=>i in l?E(l,i,{enumerable:!0,configurable:!0,writable:!0,value:f}):l[i]=f;var s=(l,i,f)=>(j(l,typeof i!="symbol"?i+"":i,f),f);const i=new Map;class f{constructor(t){s(this,"_key","");s(this,"_browser",!1);s(this,"_localizations",[]);s(this,"_default","");s(this,"_active","");var n,r,c,o;if(!t)throw new Error("Doc must be defined");if((n=t==null?void 0:t.localizations)!=null&&n.length){if((r=t.localizations)!=null&&r.find(a=>!(a!=null&&a.name)||!a.content))throw new Error("Every localization must have a name and content for each localization")}else throw new Error("Doc must have at least one localization");this._key=t.key||"default",this._browser=t.browser||!1,this._localizations=t.localizations,this._default=t.default||((o=(c=t.localizations)==null?void 0:c[0])==null?void 0:o.name),this._active=t.active||this._default,i.set(this._key,this)}}function k({docKey:e,name:t}){var c;let n=i.get(e);if(!n){console.error("doc not found");return}if(!((c=n==null?void 0:n._localizations)==null?void 0:c.find(o=>o.name===t))){console.error("please double check the name, it doesn't exist");return}n._active=t,i.set(e,n)}function z({docKey:e}){let t=i.get(e);if(!t){console.error("doc not found");return}return t._active}function v({docKey:e}){if(!i.get(e)){console.error("doc not found");return}return _({docKey:e}).content}function _({docKey:e}){let t=i.get(e);if(!t){console.error("doc not found");return}let n=t._localizations.find(r=>r.name===t._active);if(!n){console.error("active Localization not found");return}return n}function p({docKey:e,path:t}){return i.get(e)?g(v({docKey:e})||{},t)!==void 0:(console.error("doc not found"),!1)}function m({docKey:e,name:t}){let n=i.get(e);if(!n){console.error("doc not found");return}return t?n._localizations.find(r=>r.name===t):_({docKey:e})}function b({docKey:e}){let t=i.get(e);if(!t){console.error("doc not found");return}return t._localizations}function g(e,t){const n=L(t);if(!n||!(n!=null&&n.length))return;let r=e;for(const c of n)if(r&&typeof r=="object")if(Array.isArray(r)&&/^\d+$/.test(c)){const o=parseInt(c,10);if(o>=0&&oy.name===u))==null?void 0:w.content)||{},o)}function c(o){var a;return(a=m({docKey:e||"default",name:o}))==null?void 0:a.dir}return{k:n,activeName:()=>z({docKey:e||"default"}),changeLanguage:o=>k({docKey:e||"default",name:o}),exists:o=>p({docKey:e||"default",path:o}),activeContent:()=>t(),contents:()=>{var o,a;return(a=(o=i.get(e||"default"))==null?void 0:o._localizations)==null?void 0:a.map(u=>u.content)},getKey:r,getLocalization:o=>m({docKey:e||"default",name:o}),getLocalizations:o=>b({docKey:o||"default"}),dir:c}}l.Doc=f,l.kalemah=x,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});