{"version":3,"file":"index.mjs","sources":["../lib/index.ts"],"sourcesContent":["/**\n * @param app app ID, e.g. \"mail\"\n * @param key name of the property\n * @param fallback optional parameter to use as default value\n * @throws if the key can't be found\n */\nexport function loadState(app: string, key: string, fallback?: T): T {\n\tconst elem = document.querySelector(`#initial-state-${app}-${key}`)\n\tif (elem === null) {\n\t\tif (fallback !== undefined) {\n\t\t\treturn fallback\n\t\t}\n\t\tthrow new Error(`Could not find initial state ${key} of ${app}`)\n\t}\n\n\ttry {\n\t\treturn JSON.parse(atob(elem.value))\n\t} catch (e) {\n\t\tthrow new Error(`Could not parse initial state ${key} of ${app}`)\n\t}\n}\n"],"names":[],"mappings":"AAMgB,SAAA,UAAa,KAAa,KAAa,UAAiB;AACvE,QAAM,OAAyB,SAAS,cAAc,kBAAkB,GAAG,IAAI,GAAG,EAAE;AACpF,MAAI,SAAS,MAAM;AAClB,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AACA,UAAM,IAAI,MAAM,gCAAgC,GAAG,OAAO,GAAG,EAAE;AAAA,EAChE;AAEI,MAAA;AACH,WAAO,KAAK,MAAM,KAAK,KAAK,KAAK,CAAC;AAAA,WAC1B,GAAG;AACX,UAAM,IAAI,MAAM,iCAAiC,GAAG,OAAO,GAAG,EAAE;AAAA,EACjE;AACD;"}