log for com.standardnotes:3000323

== Installed Android Tools ==2022-01-13 02:54:14,964 DEBUG: Reading 'config.yml'2022-01-13 02:54:14,973 INFO: Using /opt/android-sdk/build-tools/29.0.3/apksigner2022-01-13 02:54:14,976 INFO: Creating log directory2022-01-13 02:54:14,976 INFO: Creating temporary directory2022-01-13 02:54:14,976 INFO: Creating output directory2022-01-13 02:54:15,015 DEBUG: Getting git vcs interface for https://github.com/standardnotes/mobile2022-01-13 02:54:15,015 DEBUG: > git --versiongit version 2.11.02022-01-13 02:54:15,220 INFO: Using git version 2.11.02022-01-13 02:54:15,221 DEBUG: Checking 3.9.62022-01-13 02:54:15,221 INFO: Building version 3.9.6 (3000323) of com.standardnotes2022-01-13 02:54:15,222 INFO: Running 'sudo' commands in /home/vagrant2022-01-13 02:54:15,222 DEBUG: > sudo DEBIAN_FRONTEND=noninteractive bash -x -c sysctl fs.inotify.max_user_watches=524288 && curl -Lo node.tar.gz https://nodejs.org/download/release/v14.18.2/node-v14.18.2-linux-x64.tar.gz && echo "83fa18a0e3642235446b66653eb27c169224ae9c1a15a32d6c3d9ddefb154ed4 node.tar.gz" | sha256sum -c - && tar xf node.tar.gz && cp -a node-v*-linux-x64/. /usr/local/ && rm -rf node-v*-linux-x64/ && npm -g install yarn+ sysctl fs.inotify.max_user_watches=524288fs.inotify.max_user_watches = 524288+ curl -Lo node.tar.gz https://nodejs.org/download/release/v14.18.2/node-v14.18.2-linux-x64.tar.gz% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 19 32.5M   19 6564k    0     0  10.2M      0  0:00:03 --:--:--  0:00:03 10.2M
100 32.5M  100 32.5M    0     0  28.8M      0  0:00:01  0:00:01 --:--:-- 28.8M+ echo '83fa18a0e3642235446b66653eb27c169224ae9c1a15a32d6c3d9ddefb154ed4 node.tar.gz'+ sha256sum -c -node.tar.gz: OK+ tar xf node.tar.gz+ cp -a node-v14.18.2-linux-x64/. /usr/local/+ rm -rf node-v14.18.2-linux-x64/+ npm -g install yarn> yarn@1.22.17 preinstall /usr/local/lib/node_modules/yarn> :; (node ./preinstall.js > /dev/null 2>&1 || true)/usr/local/bin/yarnpkg -> /usr/local/lib/node_modules/yarn/bin/yarn.js/usr/local/bin/yarn -> /usr/local/lib/node_modules/yarn/bin/yarn.js+ yarn@1.22.17added 1 package in 0.848s2022-01-13 02:54:19,262 DEBUG: > sudo passwd --lock rootpasswd: password expiry information changed.2022-01-13 02:54:19,470 DEBUG: > sudo SUDO_FORCE_REMOVE=yes dpkg --purge sudo(Reading database ... 64893 files and directories currently installed.)Removing sudo (1.8.19p1-2.1+deb9u3) ...Purging configuration files for sudo (1.8.19p1-2.1+deb9u3) ...Processing triggers for systemd (232-25+deb9u13) ...2022-01-13 02:54:25,479 INFO: Getting source for revision 3.9.62022-01-13 02:54:25,480 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:25,480 DEBUG: > git rev-parse --show-toplevel2022-01-13 02:54:25,686 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:25,687 DEBUG: > git submodule foreach --recursive git reset --hard2022-01-13 02:54:25,796 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:25,797 DEBUG: > git reset --hard2022-01-13 02:54:26,117 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:26,117 DEBUG: > git submodule foreach --recursive git clean -dffx2022-01-13 02:54:26,223 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:26,224 DEBUG: > git clean -dffx2022-01-13 02:54:26,337 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:26,337 DEBUG: > git -c core.askpass=/bin/true -c core.sshCommand=/bin/false -c url.https://.insteadOf=ssh:// -c url.https://u:p@bitbucket.org/.insteadOf=git@bitbucket.org: -c url.https://u:p@bitbucket.org.insteadOf=git://bitbucket.org -c url.https://u:p@bitbucket.org.insteadOf=https://bitbucket.org -c url.https://u:p@github.com/.insteadOf=git@github.com: -c url.https://u:p@github.com.insteadOf=git://github.com -c url.https://u:p@github.com.insteadOf=https://github.com -c url.https://u:p@gitlab.com/.insteadOf=git@gitlab.com: -c url.https://u:p@gitlab.com.insteadOf=git://gitlab.com -c url.https://u:p@gitlab.com.insteadOf=https://gitlab.com fetch origin2022-01-13 02:54:26,938 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:26,938 DEBUG: > git -c core.askpass=/bin/true -c core.sshCommand=/bin/false -c url.https://.insteadOf=ssh:// -c url.https://u:p@bitbucket.org/.insteadOf=git@bitbucket.org: -c url.https://u:p@bitbucket.org.insteadOf=git://bitbucket.org -c url.https://u:p@bitbucket.org.insteadOf=https://bitbucket.org -c url.https://u:p@github.com/.insteadOf=git@github.com: -c url.https://u:p@github.com.insteadOf=git://github.com -c url.https://u:p@github.com.insteadOf=https://github.com -c url.https://u:p@gitlab.com/.insteadOf=git@gitlab.com: -c url.https://u:p@gitlab.com.insteadOf=git://gitlab.com -c url.https://u:p@gitlab.com.insteadOf=https://gitlab.com remote prune origin2022-01-13 02:54:27,243 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:27,244 DEBUG: > git -c core.askpass=/bin/true -c core.sshCommand=/bin/false -c url.https://.insteadOf=ssh:// -c url.https://u:p@bitbucket.org/.insteadOf=git@bitbucket.org: -c url.https://u:p@bitbucket.org.insteadOf=git://bitbucket.org -c url.https://u:p@bitbucket.org.insteadOf=https://bitbucket.org -c url.https://u:p@github.com/.insteadOf=git@github.com: -c url.https://u:p@github.com.insteadOf=git://github.com -c url.https://u:p@github.com.insteadOf=https://github.com -c url.https://u:p@gitlab.com/.insteadOf=git@gitlab.com: -c url.https://u:p@gitlab.com.insteadOf=git://gitlab.com -c url.https://u:p@gitlab.com.insteadOf=https://gitlab.com fetch --prune --tags --force origin2022-01-13 02:54:27,555 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:27,556 DEBUG: > git remote set-head origin --auto2022-01-13 02:54:27,964 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:27,965 DEBUG: > git checkout -f 3.9.62022-01-13 02:54:28,171 DEBUG: Directory: build/com.standardnotes2022-01-13 02:54:28,171 DEBUG: > git clean -dffx2022-01-13 02:54:28,308 INFO: Running 'init' commands in build/com.standardnotes/android/app/2022-01-13 02:54:28,308 DEBUG: Directory: build/com.standardnotes/android/app2022-01-13 02:54:28,308 DEBUG: > bash -x -c -- cd ../.. && yarn cache clean snjs && npm_config_build_from_source=true yarn --force+ cd ../..+ yarn cache clean snjsyarn cache v1.22.17success Cleared package "snjs" from cacheDone in 0.05s.+ npm_config_build_from_source=true+ yarn --forceyarn install v1.22.17[1/4] Resolving packages...[2/4] Fetching packages...[3/4] Linking dependencies...warning " > @react-native-community/async-storage@1.12.1" has incorrect peer dependency "react@^16.8".warning " > @react-native-community/masked-view@0.1.10" has incorrect peer dependency "react@^16.0".warning "react-native > use-subscription@1.4.1" has incorrect peer dependency "react@^16.8.0".warning "react-native > react-native-codegen > jscodeshift@0.11.0" has unmet peer dependency "@babel/preset-env@^7.1.6".warning " > react-native-fs@2.16.6" has incorrect peer dependency "react-native@^0.59.5".warning " > react-native-fs@2.16.6" has unmet peer dependency "react-native-windows@^0.57.2".warning " > react-native-privacy-snapshot@1.0.0" has incorrect peer dependency "react@^16.13.1".warning " > react-native-privacy-snapshot@1.0.0" has incorrect peer dependency "react-native@^0.62.0".warning " > react-native-webview@11.0.3" has incorrect peer dependency "react-native@>=0.60 <0.64".warning " > sn-textview@1.0.1" has incorrect peer dependency "react@^16.11.0".warning " > styled-components@5.2.1" has unmet peer dependency "react-dom@>= 16.8.0".warning " > styled-components@5.2.1" has unmet peer dependency "react-is@>= 16.8.0".warning " > detox@17.8.3" has unmet peer dependency "jest-environment-node@>=25.0.0".warning " > detox@17.8.3" has unmet peer dependency "mocha@>=6.0.0".warning " > react-test-renderer@16.13.1" has incorrect peer dependency "react@^16.13.1".[4/4] Rebuilding all packages...success Saved lockfile.Done in 71.29s.2022-01-13 02:55:40,184 INFO: Applying patches2022-01-13 02:55:40,184 INFO: Applying bugsnag-3.9.4.patch2022-01-13 02:55:40,184 DEBUG: Directory: build/com.standardnotes2022-01-13 02:55:40,184 DEBUG: > patch -p1 -i /home/vagrant/metadata/com.standardnotes/bugsnag-3.9.4.patchpatching file android/app/build.gradlepatching file android/app/src/main/java/com/standardnotes/MainActivity.javapatching file android/app/src/main/java/com/standardnotes/MainApplication.javapatching file index.jspatching file src/App.tsxHunk #2 succeeded at 135 (offset 4 lines).patching file src/lib/interface.ts2022-01-13 02:55:40,469 INFO: Collecting source libraries2022-01-13 02:55:40,483 DEBUG: Removing debuggable flags from build/srclib/libsodium2022-01-13 02:55:40,491 DEBUG: Directory: build/srclib/libsodium2022-01-13 02:55:40,491 DEBUG: > bash -x -c -- ./autogen.sh+ ./autogen.shautoreconf: Entering directory `.'autoreconf: configure.ac: not using Gettextautoreconf: running: aclocal --force -I m4autoreconf: configure.ac: tracingautoreconf: configure.ac: creating directory build-auxautoreconf: running: libtoolize --copy --forcelibtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.libtoolize: copying file 'build-aux/ltmain.sh'libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.libtoolize: copying file 'm4/libtool.m4'libtoolize: copying file 'm4/ltoptions.m4'libtoolize: copying file 'm4/ltsugar.m4'libtoolize: copying file 'm4/ltversion.m4'libtoolize: copying file 'm4/lt~obsolete.m4'autoreconf: running: /usr/bin/autoconf --forceautoreconf: configure.ac: not using Autoheaderautoreconf: running: automake --add-missing --copy --force-missingconfigure.ac:75: installing 'build-aux/compile'configure.ac:9: installing 'build-aux/config.guess'configure.ac:9: installing 'build-aux/config.sub'configure.ac:10: installing 'build-aux/install-sh'configure.ac:10: installing 'build-aux/missing'src/libsodium/Makefile.am: installing 'build-aux/depcomp'parallel-tests: installing 'build-aux/test-driver'autoreconf: Leaving directory `.'Downloading config.guess and config.sub...Done.2022-01-13 02:55:50,447 INFO: Creating local.properties file at build/com.standardnotes/local.properties2022-01-13 02:55:50,448 INFO: Creating local.properties file at build/com.standardnotes/android/local.properties2022-01-13 02:55:50,449 INFO: Creating local.properties file at build/com.standardnotes/android/app/local.properties2022-01-13 02:55:50,449 INFO: Updating local.properties file at build/com.standardnotes/android/app/local.properties2022-01-13 02:55:50,450 DEBUG: Removing debuggable flags from build/com.standardnotes/android/app/2022-01-13 02:55:50,454 INFO: Removing specified files2022-01-13 02:55:50,454 INFO: Removing .gitmodules2022-01-13 02:55:50,460 INFO: Cleaned build.gradle of keysigning configs at build/com.standardnotes/android/app/build.gradle2022-01-13 02:55:50,523 INFO: Cleaned build.gradle of keysigning configs at build/com.standardnotes/node_modules/react-native-sodium/example/android/app/build.gradle2022-01-13 02:55:50,538 INFO: Cleaned build.gradle of keysigning configs at build/com.standardnotes/node_modules/react-native-search-bar/example/android/app/build.gradle2022-01-13 02:55:50,679 INFO: Cleaned build.gradle of keysigning configs at build/com.standardnotes/node_modules/react-native/template/android/app/build.gradle2022-01-13 02:55:50,730 INFO: Running 'prebuild' commands in build/com.standardnotes/android/app/2022-01-13 02:55:50,730 DEBUG: Directory: build/com.standardnotes/android/app2022-01-13 02:55:50,730 DEBUG: > bash -x -c -- wget -O /tmp/cmdline-tools.zip -t 5 "https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip" && echo "124f2d5115eee365df6cf3228ffbca6fc3911d16f8025bebd5b1c6e2fcfa7faf /tmp/cmdline-tools.zip"  | sha256sum -c - && unzip -q -o /tmp/cmdline-tools.zip -d /tmp/cmdline-tools && rm /tmp/cmdline-tools.zip && mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools/tools && mv /tmp/cmdline-tools/cmdline-tools/* ${ANDROID_SDK_ROOT}/cmdline-tools/tools || true && export PATH=${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${PATH} && yes | sdkmanager --licenses && sdkmanager 'cmake;3.10.2.4988404' > /dev/null && sed -i -e '/detox/d' -e '/DETOX_CI/d' build.gradle && echo "android { splits { abi { enable false } } }" >> build.gradle && sed -i -e "s/versionName appVersionName/versionName \"3.9.6\"/" -e "s/versionCode appVersionCode/versionCode 3000323/" build.gradle && sed -i -e "/appVersionName/d" -e "/appVersionCode/d" build.gradle && sed -i -e "/@bugsnag\/react-native/d" -e "/bugsnag-sourcemaps/d" ../../package.json+ wget -O /tmp/cmdline-tools.zip -t 5 https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip--2022-01-13 02:55:50--  https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zipResolving dl.google.com (dl.google.com)... 172.217.18.110, 2a00:1450:4001:809::200eConnecting to dl.google.com (dl.google.com)|172.217.18.110|:443... connected.HTTP request sent, awaiting response... 200 OKLength: 109673042 (105M) [application/zip]Saving to: ‘/tmp/cmdline-tools.zip’0K .......... .......... .......... .......... ..........  0% 6.47M 16s50K .......... .......... .......... .......... ..........  0% 10.6M 13s100K .......... .......... .......... .......... ..........  0% 14.3M 11s150K .......... .......... .......... .......... ..........  0% 19.9M 10s200K .......... .......... .......... .......... ..........  0% 32.6M 8s250K .......... .......... .......... .......... ..........  0% 20.4M 8s300K .......... .......... .......... .......... ..........  0% 23.8M 7s350K .......... .......... .......... .......... ..........  0% 20.1M 7s400K .......... .......... .......... .......... ..........  0% 27.1M 7s450K .......... .......... .......... .......... ..........  0% 36.2M 6s500K .......... .......... .......... .......... ..........  0% 39.9M 6s550K .......... .......... .......... .......... ..........  0% 36.5M 6s600K .......... .......... .......... .......... ..........  0% 33.9M 5s650K .......... .......... .......... .......... ..........  0% 44.8M 5s700K .......... .......... .......... .......... ..........  0% 45.1M 5s750K .......... .......... .......... .......... ..........  0% 57.5M 5s800K .......... .......... .......... .......... ..........  0% 46.5M 5s850K .......... .......... .......... .......... ..........  0% 49.1M 5s900K .......... .......... .......... .......... ..........  0% 43.5M 4s950K .......... .......... .......... .......... ..........  0% 45.0M 4s1000K .......... .......... .......... .......... ..........  0% 75.6M 4s1050K .......... .......... .......... .......... ..........  1% 98.1M 4s1100K .......... .......... .......... .......... ..........  1%  110M 4s1150K .......... .......... .......... .......... ..........  1% 88.8M 4s1200K .......... .......... .......... .......... ..........  1% 86.4M 4s1250K .......... .......... .......... .......... ..........  1%  132M 4s1300K .......... .......... .......... .......... ..........  1%  111M 3s1350K .......... .......... .......... .......... ..........  1%  120M 3s1400K .......... .......... .......... .......... ..........  1% 97.4M 3s1450K .......... .......... .......... .......... ..........  1%  123M 3s1500K .......... .......... .......... .......... ..........  1%  108M 3s1550K .......... .......... .......... .......... ..........  1%  109M 3s1600K .......... .......... .......... .......... ..........  1% 90.3M 3s1650K .......... .......... .......... .......... ..........  1%  130M 3s1700K .......... .......... .......... .......... ..........  1%  127M 3s1750K .......... .......... .......... .......... ..........  1%  134M 3s1800K .......... .......... .......... .......... ..........  1% 95.0M 3s1850K .......... .......... .......... .......... ..........  1%  144M 3s1900K .......... .......... .......... .......... ..........  1%  140M 3s1950K .......... .......... .......... .......... ..........  1%  113M 3s2000K .......... .......... .......... .......... ..........  1% 88.4M 3s2050K .......... .......... .......... .......... ..........  1% 94.3M 3s2100K .......... .......... .......... .......... ..........  2%  110M 3s2150K .......... .......... .......... .......... ..........  2%  119M 2s2200K .......... .......... .......... .......... ..........  2% 94.8M 2s2250K .......... .......... .......... .......... ..........  2% 86.1M 2s2300K .......... .......... .......... .......... ..........  2% 64.7M 2s2350K .......... .......... .......... .......... ..........  2% 81.2M 2s2400K .......... .......... .......... .......... ..........  2% 92.9M 2s2450K .......... .......... .......... .......... ..........  2% 90.4M 2s2500K .......... .......... .......... .......... ..........  2%  134M 2s2550K .......... .......... .......... .......... ..........  2% 91.1M 2s2600K .......... .......... .......... .......... ..........  2%  118M 2s2650K .......... .......... .......... .......... ..........  2%  105M 2s2700K .......... .......... .......... .......... ..........  2%  103M 2s2750K .......... .......... .......... .......... ..........  2% 86.1M 2s2800K .......... .......... .......... .......... ..........  2%  103M 2s2850K .......... .......... .......... .......... ..........  2%  137M 2s2900K .......... .......... .......... .......... ..........  2%  128M 2s2950K .......... .......... .......... .......... ..........  2% 89.3M 2s3000K .......... .......... .......... .......... ..........  2%  137M 2s3050K .......... .......... .......... .......... ..........  2% 97.6M 2s3100K .......... .......... .......... .......... ..........  2% 92.0M 2s3150K .......... .......... .......... .......... ..........  2% 91.1M 2s3200K .......... .......... .......... .......... ..........  3%  104M 2s3250K .......... .......... .......... .......... ..........  3%  110M 2s3300K .......... .......... .......... .......... ..........  3%  113M 2s3350K .......... .......... .......... .......... ..........  3%  103M 2s3400K .......... .......... .......... .......... ..........  3%  123M 2s3450K .......... .......... .......... .......... ..........  3% 99.7M 2s3500K .......... .......... .......... .......... ..........  3%  114M 2s3550K .......... .......... .......... .......... ..........  3% 77.9M 2s3600K .......... .......... .......... .......... ..........  3%  140M 2s3650K .......... .......... .......... .......... ..........  3%  122M 2s3700K .......... .......... .......... .......... ..........  3%  107M 2s3750K .......... .......... .......... .......... ..........  3% 92.9M 2s3800K .......... .......... .......... .......... ..........  3%  105M 2s3850K .......... .......... .......... .......... ..........  3%  107M 2s3900K .......... .......... .......... .......... ..........  3%  109M 2s3950K .......... .......... .......... .......... ..........  3% 71.3M 2s4000K .......... .......... .......... .......... ..........  3% 81.5M 2s4050K .......... .......... .......... .......... ..........  3%  122M 2s4100K .......... .......... .......... .......... ..........  3%  152M 2s4150K .......... .......... .......... .......... ..........  3%  122M 2s4200K .......... .......... .......... .......... ..........  3%  115M 2s4250K .......... .......... .......... .......... ..........  4% 90.6M 2s4300K .......... .......... .......... .......... ..........  4%  135M 2s4350K .......... .......... .......... .......... ..........  4%  107M 2s4400K .......... .......... .......... .......... ..........  4% 61.2M 2s4450K .......... .......... .......... .......... ..........  4% 65.8M 2s4500K .......... .......... .......... .......... ..........  4%  122M 2s4550K .......... .......... .......... .......... ..........  4%  102M 2s4600K .......... .......... .......... .......... ..........  4%  134M 2s4650K .......... .......... .......... .......... ..........  4%  125M 2s4700K .......... .......... .......... .......... ..........  4%  150M 2s4750K .......... .......... .......... .......... ..........  4% 86.6M 2s4800K .......... .......... .......... .......... ..........  4%  128M 2s4850K .......... .......... .......... .......... ..........  4%  120M 2s4900K .......... .......... .......... .......... ..........  4%  153M 2s4950K .......... .......... .......... .......... ..........  4% 95.8M 2s5000K .......... .......... .......... .......... ..........  4%  121M 2s5050K .......... .......... .......... .......... ..........  4% 94.0M 2s5100K .......... .......... .......... .......... ..........  4% 97.8M 2s5150K .......... .......... .......... .......... ..........  4% 72.7M 2s5200K .......... .......... .......... .......... ..........  4% 60.7M 2s5250K .......... .......... .......... .......... ..........  4% 40.8M 2s5300K .......... .......... .......... .......... ..........  4% 21.0M 2s5350K .......... .......... .......... .......... ..........  5% 55.2M 2s5400K .......... .......... .......... .......... ..........  5% 96.2M 2s5450K .......... .......... .......... .......... ..........  5%  104M 2s5500K .......... .......... .......... .......... ..........  5% 83.1M 2s5550K .......... .......... .......... .......... ..........  5% 96.7M 2s5600K .......... .......... .......... .......... ..........  5%  111M 2s5650K .......... .......... .......... .......... ..........  5%  104M 2s5700K .......... .......... .......... .......... ..........  5%  101M 2s5750K .......... .......... .......... .......... ..........  5%  100M 2s5800K .......... .......... .......... .......... ..........  5%  107M 2s5850K .......... .......... .......... .......... ..........  5%  102M 2s5900K .......... .......... .......... .......... ..........  5%  114M 2s5950K .......... .......... .......... .......... ..........  5% 78.4M 2s6000K .......... .......... .......... .......... ..........  5%  105M 2s6050K .......... .......... .......... .......... ..........  5% 96.7M 2s6100K .......... .......... .......... .......... ..........  5% 91.9M 2s6150K .......... .......... .......... .......... ..........  5% 70.3M 2s6200K .......... .......... .......... .......... ..........  5% 94.4M 2s6250K .......... .......... .......... .......... ..........  5% 98.9M 2s6300K .......... .......... .......... .......... ..........  5% 97.1M 2s6350K .......... .......... .......... .......... ..........  5% 75.4M 2s6400K .......... .......... .......... .......... ..........  6%  101M 2s6450K .......... .......... .......... .......... ..........  6%  101M 2s6500K .......... .......... .......... .......... ..........  6% 93.5M 1s6550K .......... .......... .......... .......... ..........  6% 84.9M 1s6600K .......... .......... .......... .......... ..........  6% 88.9M 1s6650K .......... .......... .......... .......... ..........  6% 31.9M 2s6700K .......... .......... .......... .......... ..........  6% 92.1M 1s6750K .......... .......... .......... .......... ..........  6% 79.2M 1s6800K .......... .......... .......... .......... ..........  6% 83.5M 1s6850K .......... .......... .......... .......... ..........  6% 95.7M 1s6900K .......... .......... .......... .......... ..........  6% 93.8M 1s6950K .......... .......... .......... .......... ..........  6% 73.9M 1s7000K .......... .......... .......... .......... ..........  6% 98.7M 1s7050K .......... .......... .......... .......... ..........  6%  105M 1s7100K .......... .......... .......... .......... ..........  6% 98.6M 1s7150K .......... .......... .......... .......... ..........  6% 85.5M 1s7200K .......... .......... .......... .......... ..........  6%  103M 1s7250K .......... .......... .......... .......... ..........  6%  143M 1s7300K .......... .......... .......... .......... ..........  6%  144M 1s7350K .......... .......... .......... .......... ..........  6% 92.9M 1s7400K .......... .......... .......... .......... ..........  6%  119M 1s7450K .......... .......... .......... .......... ..........  7%  115M 1s7500K .......... .......... .......... .......... ..........  7%  124M 1s7550K .......... .......... .......... .......... ..........  7%  114M 1s7600K .......... .......... .......... .......... ..........  7%  114M 1s7650K .......... .......... .......... .......... ..........  7%  133M 1s7700K .......... .......... .......... .......... ..........  7% 87.1M 1s7750K .......... .......... .......... .......... ..........  7% 89.2M 1s7800K .......... .......... .......... .......... ..........  7% 84.9M 1s7850K .......... .......... .......... .......... ..........  7% 77.3M 1s7900K .......... .......... .......... .......... ..........  7%  119M 1s7950K .......... .......... .......... .......... ..........  7% 76.0M 1s8000K .......... .......... .......... .......... ..........  7% 85.2M 1s8050K .......... .......... .......... .......... ..........  7%  105M 1s8100K .......... .......... .......... .......... ..........  7%  102M 1s8150K .......... .......... .......... .......... ..........  7% 85.7M 1s8200K .......... .......... .......... .......... ..........  7% 92.3M 1s8250K .......... .......... .......... .......... ..........  7% 92.2M 1s8300K .......... .......... .......... .......... ..........  7% 89.2M 1s8350K .......... .......... .......... .......... ..........  7% 83.7M 1s8400K .......... .......... .......... .......... ..........  7% 88.1M 1s8450K .......... .......... .......... .......... ..........  7% 89.4M 1s8500K .......... .......... .......... .......... ..........  7% 83.1M 1s8550K .......... .......... .......... .......... ..........  8% 71.0M 1s8600K .......... .......... .......... .......... ..........  8% 79.0M 1s8650K .......... .......... .......... .......... ..........  8% 82.2M 1s8700K .......... .......... .......... .......... ..........  8% 89.5M 1s8750K .......... .......... .......... .......... ..........  8% 82.8M 1s8800K .......... .......... .......... .......... ..........  8% 86.1M 1s8850K .......... .......... .......... .......... ..........  8% 82.6M 1s8900K .......... .......... .......... .......... ..........  8% 76.7M 1s8950K .......... .......... .......... .......... ..........  8% 70.7M 1s9000K .......... .......... .......... .......... ..........  8% 76.6M 1s9050K .......... .......... .......... .......... ..........  8% 81.7M 1s9100K .......... .......... .......... .......... ..........  8% 94.6M 1s9150K .......... .......... .......... .......... ..........  8% 66.4M 1s9200K .......... .......... .......... .......... ..........  8% 87.3M 1s9250K .......... .......... .......... .......... ..........  8% 76.5M 1s9300K .......... .......... .......... .......... ..........  8% 75.6M 1s9350K .......... .......... .......... .......... ..........  8% 69.6M 1s9400K .......... .......... .......... .......... ..........  8% 78.4M 1s9450K .......... .......... .......... .......... ..........  8%  105M 1s9500K .......... .......... .......... .......... ..........  8%  163M 1s9550K .......... .......... .......... .......... ..........  8% 77.6M 1s9600K .......... .......... .......... .......... ..........  9%  140M 1s9650K .......... .......... .......... .......... ..........  9% 98.6M 1s9700K .......... .......... .......... .......... ..........  9%  101M 1s9750K .......... .......... .......... .......... ..........  9% 88.7M 1s9800K .......... .......... .......... .......... ..........  9%  112M 1s9850K .......... .......... .......... .......... ..........  9%  166M 1s9900K .......... .......... .......... .......... ..........  9% 89.4M 1s9950K .......... .......... .......... .......... ..........  9% 97.7M 1s10000K .......... .......... .......... .......... ..........  9%  116M 1s10050K .......... .......... .......... .......... ..........  9% 92.2M 1s10100K .......... .......... .......... .......... ..........  9%  117M 1s10150K .......... .......... .......... .......... ..........  9% 85.5M 1s10200K .......... .......... .......... .......... ..........  9%  155M 1s10250K .......... .......... .......... .......... ..........  9% 77.8M 1s10300K .......... .......... .......... .......... ..........  9%  139M 1s10350K .......... .......... .......... .......... ..........  9% 97.4M 1s10400K .......... .......... .......... .......... ..........  9% 94.6M 1s10450K .......... .......... .......... .......... ..........  9%  144M 1s10500K .......... .......... .......... .......... ..........  9% 87.3M 1s10550K .......... .......... .......... .......... ..........  9%  132M 1s10600K .......... .......... .......... .......... ..........  9% 85.1M 1s10650K .......... .......... .......... .......... ..........  9%  142M 1s10700K .......... .......... .......... .......... .......... 10%  105M 1s10750K .......... .......... .......... .......... .......... 10% 91.3M 1s10800K .......... .......... .......... .......... .......... 10%  148M 1s10850K .......... .......... .......... .......... .......... 10% 89.7M 1s10900K .......... .......... .......... .......... .......... 10%  137M 1s10950K .......... .......... .......... .......... .......... 10% 90.2M 1s11000K .......... .......... .......... .......... .......... 10%  106M 1s11050K .......... .......... .......... .......... .......... 10%  125M 1s11100K .......... .......... .......... .......... .......... 10% 84.2M 1s11150K .......... .......... .......... .......... .......... 10%  126M 1s11200K .......... .......... .......... .......... .......... 10%  107M 1s11250K .......... .......... .......... .......... .......... 10% 93.6M 1s11300K .......... .......... .......... .......... .......... 10%  163M 1s11350K .......... .......... .......... .......... .......... 10% 82.8M 1s11400K .......... .......... .......... .......... .......... 10%  129M 1s11450K .......... .......... .......... .......... .......... 10%  166M 1s11500K .......... .......... .......... .......... .......... 10% 81.9M 1s11550K .......... .......... .......... .......... .......... 10% 86.7M 1s11600K .......... .......... .......... .......... .......... 10%  147M 1s11650K .......... .......... .......... .......... .......... 10% 81.8M 1s11700K .......... .......... .......... .......... .......... 10%  129M 1s11750K .......... .......... .......... .......... .......... 11% 95.3M 1s11800K .......... .......... .......... .......... .......... 11% 96.7M 1s11850K .......... .......... .......... .......... .......... 11%  158M 1s11900K .......... .......... .......... .......... .......... 11% 89.1M 1s11950K .......... .......... .......... .......... .......... 11% 92.1M 1s12000K .......... .......... .......... .......... .......... 11% 87.4M 1s12050K .......... .......... .......... .......... .......... 11%  116M 1s12100K .......... .......... .......... .......... .......... 11%  107M 1s12150K .......... .......... .......... .......... .......... 11%  103M 1s12200K .......... .......... .......... .......... .......... 11%  164M 1s12250K .......... .......... .......... .......... .......... 11% 91.7M 1s12300K .......... .......... .......... .......... .......... 11%  107M 1s12350K .......... .......... .......... .......... .......... 11% 81.8M 1s12400K .......... .......... .......... .......... .......... 11%  117M 1s12450K .......... .......... .......... .......... .......... 11%  147M 1s12500K .......... .......... .......... .......... .......... 11% 82.4M 1s12550K .......... .......... .......... .......... .......... 11%  115M 1s12600K .......... .......... .......... .......... .......... 11% 91.7M 1s12650K .......... .......... .......... .......... .......... 11%  108M 1s12700K .......... .......... .......... .......... .......... 11%  130M 1s12750K .......... .......... .......... .......... .......... 11% 78.8M 1s12800K .......... .......... .......... .......... .......... 11%  158M 1s12850K .......... .......... .......... .......... .......... 12%  102M 1s12900K .......... .......... .......... .......... .......... 12%  106M 1s12950K .......... .......... .......... .......... .......... 12% 90.5M 1s13000K .......... .......... .......... .......... .......... 12%  112M 1s13050K .......... .......... .......... .......... .......... 12%  163M 1s13100K .......... .......... .......... .......... .......... 12% 95.0M 1s13150K .......... .......... .......... .......... .......... 12% 98.4M 1s13200K .......... .......... .......... .......... .......... 12% 97.5M 1s13250K .......... .......... .......... .......... .......... 12%  103M 1s13300K .......... .......... .......... .......... .......... 12% 90.0M 1s13350K .......... .......... .......... .......... .......... 12% 95.3M 1s13400K .......... .......... .......... .......... .......... 12%  164M 1s13450K .......... .......... .......... .......... .......... 12% 84.6M 1s13500K .......... .......... .......... .......... .......... 12%  153M 1s13550K .......... .......... .......... .......... .......... 12% 73.7M 1s13600K .......... .......... .......... .......... .......... 12%  133M 1s13650K .......... .......... .......... .......... .......... 12%  147M 1s13700K .......... .......... .......... .......... .......... 12% 91.2M 1s13750K .......... .......... .......... .......... .......... 12%  117M 1s13800K .......... .......... .......... .......... .......... 12% 82.6M 1s13850K .......... .......... .......... .......... .......... 12%  154M 1s13900K .......... .......... .......... .......... .......... 13% 97.1M 1s13950K .......... .......... .......... .......... .......... 13%  102M 1s14000K .......... .......... .......... .......... .......... 13%  147M 1s14050K .......... .......... .......... .......... .......... 13% 89.3M 1s14100K .......... .......... .......... .......... .......... 13%  138M 1s14150K .......... .......... .......... .......... .......... 13% 96.6M 1s14200K .......... .......... .......... .......... .......... 13%  104M 1s14250K .......... .......... .......... .......... .......... 13%  130M 1s14300K .......... .......... .......... .......... .......... 13% 86.4M 1s14350K .......... .......... .......... .......... .......... 13%  122M 1s14400K .......... .......... .......... .......... .......... 13% 82.6M 1s14450K .......... .......... .......... .......... .......... 13%  140M 1s14500K .......... .......... .......... .......... .......... 13%  103M 1s14550K .......... .......... .......... .......... .......... 13%  102M 1s14600K .......... .......... .......... .......... .......... 13%  166M 1s14650K .......... .......... .......... .......... .......... 13%  124M 1s14700K .......... .......... .......... .......... .......... 13% 70.7M 1s14750K .......... .......... .......... .......... .......... 13%  115M 1s14800K .......... .......... .......... .......... .......... 13%  107M 1s14850K .......... .......... .......... .......... .......... 13%  107M 1s14900K .......... .......... .......... .......... .......... 13%  121M 1s14950K .......... .......... .......... .......... .......... 14%  129M 1s15000K .......... .......... .......... .......... .......... 14%  174M 1s15050K .......... .......... .......... .......... .......... 14%  150M 1s15100K .......... .......... .......... .......... .......... 14%  165M 1s15150K .......... .......... .......... .......... .......... 14%  147M 1s15200K .......... .......... .......... .......... .......... 14%  127M 1s15250K .......... .......... .......... .......... .......... 14%  152M 1s15300K .......... .......... .......... .......... .......... 14%  172M 1s15350K .......... .......... .......... .......... .......... 14%  125M 1s15400K .......... .......... .......... .......... .......... 14%  160M 1s15450K .......... .......... .......... .......... .......... 14%  149M 1s15500K .......... .......... .......... .......... .......... 14%  112M 1s15550K .......... .......... .......... .......... .......... 14% 86.9M 1s15600K .......... .......... .......... .......... .......... 14%  131M 1s15650K .......... .......... .......... .......... .......... 14%  167M 1s15700K .......... .......... .......... .......... .......... 14% 91.0M 1s15750K .......... .......... .......... .......... .......... 14%  126M 1s15800K .......... .......... .......... .......... .......... 14%  145M 1s15850K .......... .......... .......... .......... .......... 14%  102M 1s15900K .......... .......... .......... .......... .......... 14%  126M 1s15950K .......... .......... .......... .......... .......... 14% 90.8M 1s16000K .......... .......... .......... .......... .......... 14%  110M 1s16050K .......... .......... .......... .......... .......... 15%  176M 1s16100K .......... .......... .......... .......... .......... 15% 97.1M 1s16150K .......... .......... .......... .......... .......... 15%  125M 1s16200K .......... .......... .......... .......... .......... 15%  151M 1s16250K .......... .......... .......... .......... .......... 15%  127M 1s16300K .......... .......... .......... .......... .......... 15%  164M 1s16350K .......... .......... .......... .......... .......... 15%  134M 1s16400K .......... .......... .......... .......... .......... 15%  132M 1s16450K .......... .......... .......... .......... .......... 15%  138M 1s16500K .......... .......... .......... .......... .......... 15%  168M 1s16550K .......... .......... .......... .......... .......... 15%  162M 1s16600K .......... .......... .......... .......... .......... 15%  135M 1s16650K .......... .......... .......... .......... .......... 15%  119M 1s16700K .......... .......... .......... .......... .......... 15%  131M 1s16750K .......... .......... .......... .......... .......... 15%  116M 1s16800K .......... .......... .......... .......... .......... 15%  143M 1s16850K .......... .......... .......... .......... .......... 15%  154M 1s16900K .......... .......... .......... .......... .......... 15%  151M 1s16950K .......... .......... .......... .......... .......... 15%  120M 1s17000K .......... .......... .......... .......... .......... 15%  123M 1s17050K .......... .......... .......... .......... .......... 15%  145M 1s17100K .......... .......... .......... .......... .......... 16%  112M 1s17150K .......... .......... .......... .......... .......... 16% 89.0M 1s17200K .......... .......... .......... .......... .......... 16%  112M 1s17250K .......... .......... .......... .......... .......... 16%  108M 1s17300K .......... .......... .......... .......... .......... 16%  104M 1s17350K .......... .......... .......... .......... .......... 16%  140M 1s17400K .......... .......... .......... .......... .......... 16% 91.6M 1s17450K .......... .......... .......... .......... .......... 16%  121M 1s17500K .......... .......... .......... .......... .......... 16%  120M 1s17550K .......... .......... .......... .......... .......... 16% 71.1M 1s17600K .......... .......... .......... .......... .......... 16%  157M 1s17650K .......... .......... .......... .......... .......... 16% 89.2M 1s17700K .......... .......... .......... .......... .......... 16%  125M 1s17750K .......... .......... .......... .......... .......... 16%  135M 1s17800K .......... .......... .......... .......... .......... 16%  102M 1s17850K .......... .......... .......... .......... .......... 16%  119M 1s17900K .......... .......... .......... .......... .......... 16%  138M 1s17950K .......... .......... .......... .......... .......... 16% 84.7M 1s18000K .......... .......... .......... .......... .......... 16%  160M 1s18050K .......... .......... .......... .......... .......... 16% 98.8M 1s18100K .......... .......... .......... .......... .......... 16%  125M 1s18150K .......... .......... .......... .......... .......... 16%  121M 1s18200K .......... .......... .......... .......... .......... 17% 83.8M 1s18250K .......... .......... .......... .......... .......... 17%  133M 1s18300K .......... .......... .......... .......... .......... 17%  119M 1s18350K .......... .......... .......... .......... .......... 17% 85.2M 1s18400K .......... .......... .......... .......... .......... 17%  146M 1s18450K .......... .......... .......... .......... .......... 17%  102M 1s18500K .......... .......... .......... .......... .......... 17% 92.4M 1s18550K .......... .......... .......... .......... .......... 17%  144M 1s18600K .......... .......... .......... .......... .......... 17%  121M 1s18650K .......... .......... .......... .......... .......... 17%  100M 1s18700K .......... .......... .......... .......... .......... 17%  159M 1s18750K .......... .......... .......... .......... .......... 17% 73.2M 1s18800K .......... .......... .......... .......... .......... 17%  119M 1s18850K .......... .......... .......... .......... .......... 17%  123M 1s18900K .......... .......... .......... .......... .......... 17% 95.1M 1s18950K .......... .......... .......... .......... .......... 17%  144M 1s19000K .......... .......... .......... .......... .......... 17%  118M 1s19050K .......... .......... .......... .......... .......... 17%  128M 1s19100K .......... .......... .......... .......... .......... 17% 97.2M 1s19150K .......... .......... .......... .......... .......... 17% 89.5M 1s19200K .......... .......... .......... .......... .......... 17%  117M 1s19250K .......... .......... .......... .......... .......... 18%  113M 1s19300K .......... .......... .......... .......... .......... 18%  164M 1s19350K .......... .......... .......... .......... .......... 18% 88.6M 1s19400K .......... .......... .......... .......... .......... 18%  138M 1s19450K .......... .......... .......... .......... .......... 18%  122M 1s19500K .......... .......... .......... .......... .......... 18% 89.4M 1s19550K .......... .......... .......... .......... .......... 18%  103M 1s19600K .......... .......... .......... .......... .......... 18%  101M 1s19650K .......... .......... .......... .......... .......... 18%  149M 1s19700K .......... .......... .......... .......... .......... 18%  111M 1s19750K .......... .......... .......... .......... .......... 18% 91.0M 1s19800K .......... .......... .......... .......... .......... 18%  147M 1s19850K .......... .......... .......... .......... .......... 18%  102M 1s19900K .......... .......... .......... .......... .......... 18%  121M 1s19950K .......... .......... .......... .......... .......... 18% 95.0M 1s20000K .......... .......... .......... .......... .......... 18%  103M 1s20050K .......... .......... .......... .......... .......... 18%  133M 1s20100K .......... .......... .......... .......... .......... 18% 93.9M 1s20150K .......... .......... .......... .......... .......... 18% 89.1M 1s20200K .......... .......... .......... .......... .......... 18% 75.4M 1s20250K .......... .......... .......... .......... .......... 18%  155M 1s20300K .......... .......... .......... .......... .......... 19%  124M 1s20350K .......... .......... .......... .......... .......... 19% 83.3M 1s20400K .......... .......... .......... .......... .......... 19%  128M 1s20450K .......... .......... .......... .......... .......... 19%  113M 1s20500K .......... .......... .......... .......... .......... 19%  115M 1s20550K .......... .......... .......... .......... .......... 19%  119M 1s20600K .......... .......... .......... .......... .......... 19%  120M 1s20650K .......... .......... .......... .......... .......... 19%  111M 1s20700K .......... .......... .......... .......... .......... 19%  104M 1s20750K .......... .......... .......... .......... .......... 19% 82.9M 1s20800K .......... .......... .......... .......... .......... 19%  103M 1s20850K .......... .......... .......... .......... .......... 19% 83.5M 1s20900K .......... .......... .......... .......... .......... 19%  105M 1s20950K .......... .......... .......... .......... .......... 19% 86.3M 1s21000K .......... .......... .......... .......... .......... 19% 92.6M 1s21050K .......... .......... .......... .......... .......... 19% 85.4M 1s21100K .......... .......... .......... .......... .......... 19% 97.0M 1s21150K .......... .......... .......... .......... .......... 19% 84.2M 1s21200K .......... .......... .......... .......... .......... 19% 87.0M 1s21250K .......... .......... .......... .......... .......... 19% 94.5M 1s21300K .......... .......... .......... .......... .......... 19% 89.2M 1s21350K .......... .......... .......... .......... .......... 19% 95.4M 1s21400K .......... .......... .......... .......... .......... 20% 99.2M 1s21450K .......... .......... .......... .......... .......... 20% 85.8M 1s21500K .......... .......... .......... .......... .......... 20% 87.6M 1s21550K .......... .......... .......... .......... .......... 20% 79.4M 1s21600K .......... .......... .......... .......... .......... 20%  105M 1s21650K .......... .......... .......... .......... .......... 20% 84.7M 1s21700K .......... .......... .......... .......... .......... 20% 79.8M 1s21750K .......... .......... .......... .......... .......... 20% 91.0M 1s21800K .......... .......... .......... .......... .......... 20% 94.0M 1s21850K .......... .......... .......... .......... .......... 20%  107M 1s21900K .......... .......... .......... .......... .......... 20% 89.7M 1s21950K .......... .......... .......... .......... .......... 20% 86.6M 1s22000K .......... .......... .......... .......... .......... 20% 94.0M 1s22050K .......... .......... .......... .......... .......... 20%  109M 1s22100K .......... .......... .......... .......... .......... 20%  107M 1s22150K .......... .......... .......... .......... .......... 20% 86.3M 1s22200K .......... .......... .......... .......... .......... 20%  108M 1s22250K .......... .......... .......... .......... .......... 20% 96.6M 1s22300K .......... .......... .......... .......... .......... 20%  107M 1s22350K .......... .......... .......... .......... .......... 20% 85.8M 1s22400K .......... .......... .......... .......... .......... 20% 98.9M 1s22450K .......... .......... .......... .......... .......... 21%  111M 1s22500K .......... .......... .......... .......... .......... 21% 95.5M 1s22550K .......... .......... .......... .......... .......... 21% 82.5M 1s22600K .......... .......... .......... .......... .......... 21% 87.3M 1s22650K .......... .......... .......... .......... .......... 21% 98.2M 1s22700K .......... .......... .......... .......... .......... 21%  109M 1s22750K .......... .......... .......... .......... .......... 21% 83.6M 1s22800K .......... .......... .......... .......... .......... 21%  103M 1s22850K .......... .......... .......... .......... .......... 21%  107M 1s22900K .......... .......... .......... .......... .......... 21%  101M 1s22950K .......... .......... .......... .......... .......... 21% 97.3M 1s23000K .......... .......... .......... .......... .......... 21% 96.6M 1s23050K .......... .......... .......... .......... .......... 21% 91.5M 1s23100K .......... .......... .......... .......... .......... 21%  104M 1s23150K .......... .......... .......... .......... .......... 21% 72.2M 1s23200K .......... .......... .......... .......... .......... 21% 86.3M 1s23250K .......... .......... .......... .......... .......... 21% 98.8M 1s23300K .......... .......... .......... .......... .......... 21% 98.8M 1s23350K .......... .......... .......... .......... .......... 21% 82.7M 1s23400K .......... .......... .......... .......... .......... 21% 89.2M 1s23450K .......... .......... .......... .......... .......... 21%  112M 1s23500K .......... .......... .......... .......... .......... 21%  109M 1s23550K .......... .......... .......... .......... .......... 22% 81.7M 1s23600K .......... .......... .......... .......... .......... 22% 97.1M 1s23650K .......... .......... .......... .......... .......... 22%  105M 1s23700K .......... .......... .......... .......... .......... 22%  103M 1s23750K .......... .......... .......... .......... .......... 22% 89.7M 1s23800K .......... .......... .......... .......... .......... 22% 92.6M 1s23850K .......... .......... .......... .......... .......... 22%  100M 1s23900K .......... .......... .......... .......... .......... 22%  105M 1s23950K .......... .......... .......... .......... .......... 22% 74.0M 1s24000K .......... .......... .......... .......... .......... 22%  108M 1s24050K .......... .......... .......... .......... .......... 22% 96.1M 1s24100K .......... .......... .......... .......... .......... 22%  117M 1s24150K .......... .......... .......... .......... .......... 22% 85.0M 1s24200K .......... .......... .......... .......... .......... 22%  107M 1s24250K .......... .......... .......... .......... .......... 22% 94.0M 1s24300K .......... .......... .......... .......... .......... 22% 84.8M 1s24350K .......... .......... .......... .......... .......... 22% 96.2M 1s24400K .......... .......... .......... .......... .......... 22%  100M 1s24450K .......... .......... .......... .......... .......... 22% 94.6M 1s24500K .......... .......... .......... .......... .......... 22%  101M 1s24550K .......... .......... .......... .......... .......... 22% 83.0M 1s24600K .......... .......... .......... .......... .......... 23%  105M 1s24650K .......... .......... .......... .......... .......... 23% 84.8M 1s24700K .......... .......... .......... .......... .......... 23% 99.0M 1s24750K .......... .......... .......... .......... .......... 23% 83.8M 1s24800K .......... .......... .......... .......... .......... 23%  101M 1s24850K .......... .......... .......... .......... .......... 23%  111M 1s24900K .......... .......... .......... .......... .......... 23% 98.9M 1s24950K .......... .......... .......... .......... .......... 23% 98.5M 1s25000K .......... .......... .......... .......... .......... 23% 84.8M 1s25050K .......... .......... .......... .......... .......... 23% 89.8M 1s25100K .......... .......... .......... .......... .......... 23%  111M 1s25150K .......... .......... .......... .......... .......... 23% 70.2M 1s25200K .......... .......... .......... .......... .......... 23%  103M 1s25250K .......... .......... .......... .......... .......... 23% 88.8M 1s25300K .......... .......... .......... .......... .......... 23% 92.4M 1s25350K .......... .......... .......... .......... .......... 23% 80.1M 1s25400K .......... .......... .......... .......... .......... 23% 89.5M 1s25450K .......... .......... .......... .......... .......... 23%  121M 1s25500K .......... .......... .......... .......... .......... 23% 95.3M 1s25550K .......... .......... .......... .......... .......... 23% 80.8M 1s25600K .......... .......... .......... .......... .......... 23%  101M 1s25650K .......... .......... .......... .......... .......... 23%  105M 1s25700K .......... .......... .......... .......... .......... 24% 95.8M 1s25750K .......... .......... .......... .......... .......... 24% 77.1M 1s25800K .......... .......... .......... .......... .......... 24%  116M 1s25850K .......... .......... .......... .......... .......... 24% 99.6M 1s25900K .......... .......... .......... .......... .......... 24% 78.8M 1s25950K .......... .......... .......... .......... .......... 24% 79.9M 1s26000K .......... .......... .......... .......... .......... 24% 95.8M 1s26050K .......... .......... .......... .......... .......... 24%  113M 1s26100K .......... .......... .......... .......... .......... 24% 93.7M 1s26150K .......... .......... .......... .......... .......... 24% 90.2M 1s26200K .......... .......... .......... .......... .......... 24%  110M 1s26250K .......... .......... .......... .......... .......... 24% 93.4M 1s26300K .......... .......... .......... .......... .......... 24%  109M 1s26350K .......... .......... .......... .......... .......... 24% 75.7M 1s26400K .......... .......... .......... .......... .......... 24%  107M 1s26450K .......... .......... .......... .......... .......... 24%  102M 1s26500K .......... .......... .......... .......... .......... 24% 91.7M 1s26550K .......... .......... .......... .......... .......... 24%  107M 1s26600K .......... .......... .......... .......... .......... 24% 87.2M 1s26650K .......... .......... .......... .......... .......... 24% 89.4M 1s26700K .......... .......... .......... .......... .......... 24%  109M 1s26750K .......... .......... .......... .......... .......... 25% 72.9M 1s26800K .......... .......... .......... .......... .......... 25%  108M 1s26850K .......... .......... .......... .......... .......... 25% 99.0M 1s26900K .......... .......... .......... .......... .......... 25% 97.7M 1s26950K .......... .......... .......... .......... .......... 25%  104M 1s27000K .......... .......... .......... .......... .......... 25% 98.1M 1s27050K .......... .......... .......... .......... .......... 25% 95.7M 1s27100K .......... .......... .......... .......... .......... 25%  109M 1s27150K .......... .......... .......... .......... .......... 25% 75.8M 1s27200K .......... .......... .......... .......... .......... 25%  104M 1s27250K .......... .......... .......... .......... .......... 25% 94.4M 1s27300K .......... .......... .......... .......... .......... 25%  109M 1s27350K .......... .......... .......... .......... .......... 25% 77.3M 1s27400K .......... .......... .......... .......... .......... 25% 97.3M 1s27450K .......... .......... .......... .......... .......... 25%  110M 1s27500K .......... .......... .......... .......... .......... 25% 97.6M 1s27550K .......... .......... .......... .......... .......... 25% 91.4M 1s27600K .......... .......... .......... .......... .......... 25%  100M 1s27650K .......... .......... .......... .......... .......... 25%  103M 1s27700K .......... .......... .......... .......... .......... 25%  114M 1s27750K .......... .......... .......... .......... .......... 25% 87.2M 1s27800K .......... .......... .......... .......... .......... 26% 85.6M 1s27850K .......... .......... .......... .......... .......... 26%  108M 1s27900K .......... .......... .......... .......... .......... 26% 85.7M 1s27950K .......... .......... .......... .......... .......... 26% 84.4M 1s28000K .......... .......... .......... .......... .......... 26% 83.9M 1s28050K .......... .......... .......... .......... .......... 26%  105M 1s28100K .......... .......... .......... .......... .......... 26% 87.5M 1s28150K .......... .......... .......... .......... .......... 26% 88.0M 1s28200K .......... .......... .......... .......... .......... 26%  121M 1s28250K .......... .......... .......... .......... .......... 26% 88.3M 1s28300K .......... .......... .......... .......... .......... 26% 99.0M 1s28350K .......... .......... .......... .......... .......... 26% 91.2M 1s28400K .......... .......... .......... .......... .......... 26% 87.9M 1s28450K .......... .......... .......... .......... .......... 26% 99.0M 1s28500K .......... .......... .......... .......... .......... 26% 87.2M 1s28550K .......... .......... .......... .......... .......... 26% 92.1M 1s28600K .......... .......... .......... .......... .......... 26%  109M 1s28650K .......... .......... .......... .......... .......... 26% 99.9M 1s28700K .......... .......... .......... .......... .......... 26%  114M 1s28750K .......... .......... .......... .......... .......... 26% 79.7M 1s28800K .......... .......... .......... .......... .......... 26% 94.0M 1s28850K .......... .......... .......... .......... .......... 26%  100M 1s28900K .......... .......... .......... .......... .......... 27% 97.1M 1s28950K .......... .......... .......... .......... .......... 27%  111M 1s29000K .......... .......... .......... .......... .......... 27% 87.6M 1s29050K .......... .......... .......... .......... .......... 27% 95.1M 1s29100K .......... .......... .......... .......... .......... 27%  108M 1s29150K .......... .......... .......... .......... .......... 27% 79.5M 1s29200K .......... .......... .......... .......... .......... 27%  107M 1s29250K .......... .......... .......... .......... .......... 27% 96.5M 1s29300K .......... .......... .......... .......... .......... 27%  110M 1s29350K .......... .......... .......... .......... .......... 27% 99.5M 1s29400K .......... .......... .......... .......... .......... 27%  101M 1s29450K .......... .......... .......... .......... .......... 27% 98.5M 1s29500K .......... .......... .......... .......... .......... 27%  110M 1s29550K .......... .......... .......... .......... .......... 27% 74.1M 1s29600K .......... .......... .......... .......... .......... 27%  106M 1s29650K .......... .......... .......... .......... .......... 27% 83.4M 1s29700K .......... .......... .......... .......... .......... 27% 96.1M 1s29750K .......... .......... .......... .......... .......... 27% 93.7M 1s29800K .......... .......... .......... .......... .......... 27%  103M 1s29850K .......... .......... .......... .......... .......... 27%  108M 1s29900K .......... .......... .......... .......... .......... 27% 97.0M 1s29950K .......... .......... .......... .......... .......... 28% 90.2M 1s30000K .......... .......... .......... .......... .......... 28% 92.1M 1s30050K .......... .......... .......... .......... .......... 28% 88.3M 1s30100K .......... .......... .......... .......... .......... 28%  110M 1s30150K .......... .......... .......... .......... .......... 28% 83.1M 1s30200K .......... .......... .......... .......... .......... 28% 97.8M 1s30250K .......... .......... .......... .......... .......... 28%  103M 1s30300K .......... .......... .......... .......... .......... 28% 99.0M 1s30350K .......... .......... .......... .......... .......... 28% 78.6M 1s30400K .......... .......... .......... .......... .......... 28% 93.1M 1s30450K .......... .......... .......... .......... .......... 28%  105M 1s30500K .......... .......... .......... .......... .......... 28% 90.3M 1s30550K .......... .......... .......... .......... .......... 28% 86.8M 1s30600K .......... .......... .......... .......... .......... 28%  122M 1s30650K .......... .......... .......... .......... .......... 28% 92.6M 1s30700K .......... .......... .......... .......... .......... 28%  102M 1s30750K .......... .......... .......... .......... .......... 28% 76.1M 1s30800K .......... .......... .......... .......... .......... 28% 98.1M 1s30850K .......... .......... .......... .......... .......... 28%  119M 1s30900K .......... .......... .......... .......... .......... 28% 94.4M 1s30950K .......... .......... .......... .......... .......... 28% 78.6M 1s31000K .......... .......... .......... .......... .......... 28%  111M 1s31050K .......... .......... .......... .......... .......... 29% 90.5M 1s31100K .......... .......... .......... .......... .......... 29%  103M 1s31150K .......... .......... .......... .......... .......... 29% 76.9M 1s31200K .......... .......... .......... .......... .......... 29% 92.3M 1s31250K .......... .......... .......... .......... .......... 29%  100M 1s31300K .......... .......... .......... .......... .......... 29%  106M 1s31350K .......... .......... .......... .......... .......... 29%  106M 1s31400K .......... .......... .......... .......... .......... 29% 93.6M 1s31450K .......... .......... .......... .......... .......... 29% 92.6M 1s31500K .......... .......... .......... .......... .......... 29%  102M 1s31550K .......... .......... .......... .......... .......... 29% 71.6M 1s31600K .......... .......... .......... .......... .......... 29%  112M 1s31650K .......... .......... .......... .......... .......... 29% 99.3M 1s31700K .......... .......... .......... .......... .......... 29% 96.4M 1s31750K .......... .......... .......... .......... .......... 29%  103M 1s31800K .......... .......... .......... .......... .......... 29%  103M 1s31850K .......... .......... .......... .......... .......... 29% 88.3M 1s31900K .......... .......... .......... .......... .......... 29%  102M 1s31950K .......... .......... .......... .......... .......... 29% 87.7M 1s32000K .......... .......... .......... .......... .......... 29%  118M 1s32050K .......... .......... .......... .......... .......... 29%  108M 1s32100K .......... .......... .......... .......... .......... 30% 88.3M 1s32150K .......... .......... .......... .......... .......... 30% 78.1M 1s32200K .......... .......... .......... .......... .......... 30%  113M 1s32250K .......... .......... .......... .......... .......... 30% 89.7M 1s32300K .......... .......... .......... .......... .......... 30% 79.7M 1s32350K .......... .......... .......... .......... .......... 30% 95.9M 1s32400K .......... .......... .......... .......... .......... 30%  118M 1s32450K .......... .......... .......... .......... .......... 30%  103M 1s32500K .......... .......... .......... .......... .......... 30% 95.3M 1s32550K .......... .......... .......... .......... .......... 30% 86.9M 1s32600K .......... .......... .......... .......... .......... 30%  113M 1s32650K .......... .......... .......... .......... .......... 30% 90.2M 1s32700K .......... .......... .......... .......... .......... 30% 80.7M 1s32750K .......... .......... .......... .......... .......... 30% 62.7M 1s32800K .......... .......... .......... .......... .......... 30% 92.1M 1s32850K .......... .......... .......... .......... .......... 30% 96.4M 1s32900K .......... .......... .......... .......... .......... 30% 89.2M 1s32950K .......... .......... .......... .......... .......... 30% 84.8M 1s33000K .......... .......... .......... .......... .......... 30% 98.2M 1s33050K .......... .......... .......... .......... .......... 30%  108M 1s33100K .......... .......... .......... .......... .......... 30% 93.7M 1s33150K .......... .......... .......... .......... .......... 30% 87.6M 1s33200K .......... .......... .......... .......... .......... 31% 89.2M 1s33250K .......... .......... .......... .......... .......... 31%  102M 1s33300K .......... .......... .......... .......... .......... 31%  108M 1s33350K .......... .......... .......... .......... .......... 31% 89.0M 1s33400K .......... .......... .......... .......... .......... 31% 96.3M 1s33450K .......... .......... .......... .......... .......... 31%  105M 1s33500K .......... .......... .......... .......... .......... 31% 92.8M 1s33550K .......... .......... .......... .......... .......... 31% 74.8M 1s33600K .......... .......... .......... .......... .......... 31%  104M 1s33650K .......... .......... .......... .......... .......... 31%  104M 1s33700K .......... .......... .......... .......... .......... 31% 92.9M 1s33750K .......... .......... .......... .......... .......... 31%  102M 1s33800K .......... .......... .......... .......... .......... 31% 92.7M 1s33850K .......... .......... .......... .......... .......... 31% 90.1M 1s33900K .......... .......... .......... .......... .......... 31%  109M 1s33950K .......... .......... .......... .......... .......... 31% 87.2M 1s34000K .......... .......... .......... .......... .......... 31% 89.1M 1s34050K .......... .......... .......... .......... .......... 31%  112M 1s34100K .......... .......... .......... .......... .......... 31%  104M 1s34150K .......... .......... .......... .......... .......... 31% 99.3M 1s34200K .......... .......... .......... .......... .......... 31% 90.8M 1s34250K .......... .......... .......... .......... .......... 32%  105M 1s34300K .......... .......... .......... .......... .......... 32% 95.1M 1s34350K .......... .......... .......... .......... .......... 32% 80.7M 1s34400K .......... .......... .......... .......... .......... 32% 83.4M 1s34450K .......... .......... .......... .......... .......... 32%  102M 1s34500K .......... .......... .......... .......... .......... 32% 86.8M 1s34550K .......... .......... .......... .......... .......... 32% 87.7M 1s34600K .......... .......... .......... .......... .......... 32% 96.4M 1s34650K .......... .......... .......... .......... .......... 32% 98.5M 1s34700K .......... .......... .......... .......... .......... 32%  103M 1s34750K .......... .......... .......... .......... .......... 32% 74.9M 1s34800K .......... .......... .......... .......... .......... 32%  105M 1s34850K .......... .......... .......... .......... .......... 32%  104M 1s34900K .......... .......... .......... .......... .......... 32% 96.1M 1s34950K .......... .......... .......... .......... .......... 32%  108M 1s35000K .......... .......... .......... .......... .......... 32% 88.7M 1s35050K .......... .......... .......... .......... .......... 32%  102M 1s35100K .......... .......... .......... .......... .......... 32% 96.1M 1s35150K .......... .......... .......... .......... .......... 32% 79.4M 1s35200K .......... .......... .......... .......... .......... 32% 88.5M 1s35250K .......... .......... .......... .......... .......... 32%  123M 1s35300K .......... .......... .......... .......... .......... 33% 95.6M 1s35350K .......... .......... .......... .......... .......... 33% 97.7M 1s35400K .......... .......... .......... .......... .......... 33% 93.1M 1s35450K .......... .......... .......... .......... .......... 33% 78.7M 1s35500K .......... .......... .......... .......... .......... 33%  101M 1s35550K .......... .......... .......... .......... .......... 33% 86.4M 1s35600K .......... .......... .......... .......... .......... 33% 98.0M 1s35650K .......... .......... .......... .......... .......... 33% 99.6M 1s35700K .......... .......... .......... .......... .......... 33%  106M 1s35750K .......... .......... .......... .......... .......... 33% 83.6M 1s35800K .......... .......... .......... .......... .......... 33% 95.8M 1s35850K .......... .......... .......... .......... .......... 33%  104M 1s35900K .......... .......... .......... .......... .......... 33% 87.0M 1s35950K .......... .......... .......... .......... .......... 33% 88.5M 1s36000K .......... .......... .......... .......... .......... 33%  105M 1s36050K .......... .......... .......... .......... .......... 33%  103M 1s36100K .......... .......... .......... .......... .......... 33%  108M 1s36150K .......... .......... .......... .......... .......... 33% 86.4M 1s36200K .......... .......... .......... .......... .......... 33% 93.9M 1s36250K .......... .......... .......... .......... .......... 33%  102M 1s36300K .......... .......... .......... .......... .......... 33% 87.9M 1s36350K .......... .......... .......... .......... .......... 33% 85.9M 1s36400K .......... .......... .......... .......... .......... 34% 80.5M 1s36450K .......... .......... .......... .......... .......... 34%  107M 1s36500K .......... .......... .......... .......... .......... 34% 96.3M 1s36550K .......... .......... .......... .......... .......... 34% 76.6M 1s36600K .......... .......... .......... .......... .......... 34% 95.6M 1s36650K .......... .......... .......... .......... .......... 34%  106M 1s36700K .......... .......... .......... .......... .......... 34% 85.6M 1s36750K .......... .......... .......... .......... .......... 34% 87.0M 1s36800K .......... .......... .......... .......... .......... 34% 84.4M 1s36850K .......... .......... .......... .......... .......... 34% 97.8M 1s36900K .......... .......... .......... .......... .......... 34% 86.4M 1s36950K .......... .......... .......... .......... .......... 34% 89.3M 1s37000K .......... .......... .......... .......... .......... 34%  110M 1s37050K .......... .......... .......... .......... .......... 34% 88.2M 1s37100K .......... .......... .......... .......... .......... 34% 99.7M 1s37150K .......... .......... .......... .......... .......... 34% 78.2M 1s37200K .......... .......... .......... .......... .......... 34% 88.6M 1s37250K .......... .......... .......... .......... .......... 34%  115M 1s37300K .......... .......... .......... .......... .......... 34% 78.0M 1s37350K .......... .......... .......... .......... .......... 34% 98.0M 1s37400K .......... .......... .......... .......... .......... 34% 97.4M 1s37450K .......... .......... .......... .......... .......... 35% 98.1M 1s37500K .......... .......... .......... .......... .......... 35%  108M 1s37550K .......... .......... .......... .......... .......... 35% 73.7M 1s37600K .......... .......... .......... .......... .......... 35%  107M 1s37650K .......... .......... .......... .......... .......... 35% 81.7M 1s37700K .......... .......... .......... .......... .......... 35% 96.3M 1s37750K .......... .......... .......... .......... .......... 35% 87.7M 1s37800K .......... .......... .......... .......... .......... 35% 81.2M 1s37850K .......... .......... .......... .......... .......... 35%  122M 1s37900K .......... .......... .......... .......... .......... 35% 90.0M 1s37950K .......... .......... .......... .......... .......... 35% 73.4M 1s38000K .......... .......... .......... .......... .......... 35%  104M 1s38050K .......... .......... .......... .......... .......... 35% 70.5M 1s38100K .......... .......... .......... .......... .......... 35%  101M 1s38150K .......... .......... .......... .......... .......... 35% 84.7M 1s38200K .......... .......... .......... .......... .......... 35%  104M 1s38250K .......... .......... .......... .......... .......... 35% 81.1M 1s38300K .......... .......... .......... .......... .......... 35%  103M 1s38350K .......... .......... .......... .......... .......... 35% 76.6M 1s38400K .......... .......... .......... .......... .......... 35% 84.9M 1s38450K .......... .......... .......... .......... .......... 35% 89.1M 1s38500K .......... .......... .......... .......... .......... 35%  106M 1s38550K .......... .......... .......... .......... .......... 36% 87.5M 1s38600K .......... .......... .......... .......... .......... 36% 97.7M 1s38650K .......... .......... .......... .......... .......... 36%  123M 1s38700K .......... .......... .......... .......... .......... 36% 81.5M 1s38750K .......... .......... .......... .......... .......... 36% 64.0M 1s38800K .......... .......... .......... .......... .......... 36%  102M 1s38850K .......... .......... .......... .......... .......... 36% 89.0M 1s38900K .......... .......... .......... .......... .......... 36% 93.7M 1s38950K .......... .......... .......... .......... .......... 36% 83.7M 1s39000K .......... .......... .......... .......... .......... 36% 87.2M 1s39050K .......... .......... .......... .......... .......... 36%  108M 1s39100K .......... .......... .......... .......... .......... 36% 94.4M 1s39150K .......... .......... .......... .......... .......... 36% 71.1M 1s39200K .......... .......... .......... .......... .......... 36%  108M 1s39250K .......... .......... .......... .......... .......... 36% 84.9M 1s39300K .......... .......... .......... .......... .......... 36% 90.8M 1s39350K .......... .......... .......... .......... .......... 36% 94.6M 1s39400K .......... .......... .......... .......... .......... 36%  101M 1s39450K .......... .......... .......... .......... .......... 36% 94.1M 1s39500K .......... .......... .......... .......... .......... 36% 88.7M 1s39550K .......... .......... .......... .......... .......... 36% 71.4M 1s39600K .......... .......... .......... .......... .......... 37%  102M 1s39650K .......... .......... .......... .......... .......... 37%  102M 1s39700K .......... .......... .......... .......... .......... 37% 81.6M 1s39750K .......... .......... .......... .......... .......... 37% 90.7M 1s39800K .......... .......... .......... .......... .......... 37% 99.6M 1s39850K .......... .......... .......... .......... .......... 37% 89.0M 1s39900K .......... .......... .......... .......... .......... 37% 89.0M 1s39950K .......... .......... .......... .......... .......... 37% 76.1M 1s40000K .......... .......... .......... .......... .......... 37%  117M 1s40050K .......... .......... .......... .......... .......... 37% 92.6M 1s40100K .......... .......... .......... .......... .......... 37% 85.1M 1s40150K .......... .......... .......... .......... .......... 37% 89.0M 1s40200K .......... .......... .......... .......... .......... 37%  100M 1s40250K .......... .......... .......... .......... .......... 37% 89.2M 1s40300K .......... .......... .......... .......... .......... 37%  100M 1s40350K .......... .......... .......... .......... .......... 37% 77.5M 1s40400K .......... .......... .......... .......... .......... 37%  114M 1s40450K .......... .......... .......... .......... .......... 37% 91.4M 1s40500K .......... .......... .......... .......... .......... 37% 89.5M 1s40550K .......... .......... .......... .......... .......... 37%  113M 1s40600K .......... .......... .......... .......... .......... 37% 88.6M 1s40650K .......... .......... .......... .......... .......... 38% 91.6M 1s40700K .......... .......... .......... .......... .......... 38%  115M 1s40750K .......... .......... .......... .......... .......... 38% 68.3M 1s40800K .......... .......... .......... .......... .......... 38%  108M 1s40850K .......... .......... .......... .......... .......... 38%  103M 1s40900K .......... .......... .......... .......... .......... 38% 84.1M 1s40950K .......... .......... .......... .......... .......... 38%  101M 1s41000K .......... .......... .......... .......... .......... 38% 92.7M 1s41050K .......... .......... .......... .......... .......... 38% 91.9M 1s41100K .......... .......... .......... .......... .......... 38%  116M 1s41150K .......... .......... .......... .......... .......... 38% 71.3M 1s41200K .......... .......... .......... .......... .......... 38% 93.0M 1s41250K .......... .......... .......... .......... .......... 38%  113M 1s41300K .......... .......... .......... .......... .......... 38% 85.3M 1s41350K .......... .......... .......... .......... .......... 38% 88.8M 1s41400K .......... .......... .......... .......... .......... 38% 96.8M 1s41450K .......... .......... .......... .......... .......... 38% 80.9M 1s41500K .......... .......... .......... .......... .......... 38%  104M 1s41550K .......... .......... .......... .......... .......... 38% 76.0M 1s41600K .......... .......... .......... .......... .......... 38% 86.1M 1s41650K .......... .......... .......... .......... .......... 38%  112M 1s41700K .......... .......... .......... .......... .......... 38% 81.6M 1s41750K .......... .......... .......... .......... .......... 39% 96.4M 1s41800K .......... .......... .......... .......... .......... 39% 94.4M 1s41850K .......... .......... .......... .......... .......... 39%  100M 1s41900K .......... .......... .......... .......... .......... 39%  113M 1s41950K .......... .......... .......... .......... .......... 39% 73.8M 1s42000K .......... .......... .......... .......... .......... 39%  109M 1s42050K .......... .......... .......... .......... .......... 39%  107M 1s42100K .......... .......... .......... .......... .......... 39% 85.3M 1s42150K .......... .......... .......... .......... .......... 39% 90.3M 1s42200K .......... .......... .......... .......... .......... 39%  106M 1s42250K .......... .......... .......... .......... .......... 39% 89.5M 1s42300K .......... .......... .......... .......... .......... 39% 93.8M 1s42350K .......... .......... .......... .......... .......... 39% 76.3M 1s42400K .......... .......... .......... .......... .......... 39% 68.9M 1s42450K .......... .......... .......... .......... .......... 39% 89.1M 1s42500K .......... .......... .......... .......... .......... 39% 77.6M 1s42550K .......... .......... .......... .......... .......... 39% 90.8M 1s42600K .......... .......... .......... .......... .......... 39%  116M 1s42650K .......... .......... .......... .......... .......... 39% 85.3M 1s42700K .......... .......... .......... .......... .......... 39% 98.6M 1s42750K .......... .......... .......... .......... .......... 39% 89.0M 1s42800K .......... .......... .......... .......... .......... 40%  109M 1s42850K .......... .......... .......... .......... .......... 40%  142M 1s42900K .......... .......... .......... .......... .......... 40%  161M 1s42950K .......... .......... .......... .......... .......... 40%  143M 1s43000K .......... .......... .......... .......... .......... 40%  121M 1s43050K .......... .......... .......... .......... .......... 40%  108M 1s43100K .......... .......... .......... .......... .......... 40%  107M 1s43150K .......... .......... .......... .......... .......... 40% 72.1M 1s43200K .......... .......... .......... .......... .......... 40%  120M 1s43250K .......... .......... .......... .......... .......... 40%  110M 1s43300K .......... .......... .......... .......... .......... 40%  124M 1s43350K .......... .......... .......... .......... .......... 40%  102M 1s43400K .......... .......... .......... .......... .......... 40% 86.3M 1s43450K .......... .......... .......... .......... .......... 40% 81.2M 1s43500K .......... .......... .......... .......... .......... 40%  105M 1s43550K .......... .......... .......... .......... .......... 40% 68.9M 1s43600K .......... .......... .......... .......... .......... 40%  146M 1s43650K .......... .......... .......... .......... .......... 40%  114M 1s43700K .......... .......... .......... .......... .......... 40%  114M 1s43750K .......... .......... .......... .......... .......... 40%  126M 1s43800K .......... .......... .......... .......... .......... 40%  158M 1s43850K .......... .......... .......... .......... .......... 40%  107M 1s43900K .......... .......... .......... .......... .......... 41%  136M 1s43950K .......... .......... .......... .......... .......... 41%  113M 1s44000K .......... .......... .......... .......... .......... 41%  121M 1s44050K .......... .......... .......... .......... .......... 41%  119M 1s44100K .......... .......... .......... .......... .......... 41%  134M 1s44150K .......... .......... .......... .......... .......... 41%  135M 1s44200K .......... .......... .......... .......... .......... 41%  138M 1s44250K .......... .......... .......... .......... .......... 41%  118M 1s44300K .......... .......... .......... .......... .......... 41%  116M 1s44350K .......... .......... .......... .......... .......... 41%  106M 1s44400K .......... .......... .......... .......... .......... 41%  133M 1s44450K .......... .......... .......... .......... .......... 41%  100M 1s44500K .......... .......... .......... .......... .......... 41%  101M 1s44550K .......... .......... .......... .......... .......... 41%  109M 1s44600K .......... .......... .......... .......... .......... 41%  114M 1s44650K .......... .......... .......... .......... .......... 41%  142M 1s44700K .......... .......... .......... .......... .......... 41%  151M 1s44750K .......... .......... .......... .......... .......... 41% 86.9M 1s44800K .......... .......... .......... .......... .......... 41%  103M 1s44850K .......... .......... .......... .......... .......... 41%  104M 1s44900K .......... .......... .......... .......... .......... 41%  136M 1s44950K .......... .......... .......... .......... .......... 42%  116M 1s45000K .......... .......... .......... .......... .......... 42%  133M 1s45050K .......... .......... .......... .......... .......... 42%  132M 1s45100K .......... .......... .......... .......... .......... 42%  110M 1s45150K .......... .......... .......... .......... .......... 42%  100M 1s45200K .......... .......... .......... .......... .......... 42% 94.1M 1s45250K .......... .......... .......... .......... .......... 42%  129M 1s45300K .......... .......... .......... .......... .......... 42% 68.6M 1s45350K .......... .......... .......... .......... .......... 42%  137M 1s45400K .......... .......... .......... .......... .......... 42%  110M 1s45450K .......... .......... .......... .......... .......... 42% 98.7M 1s45500K .......... .......... .......... .......... .......... 42%  130M 1s45550K .......... .......... .......... .......... .......... 42%  112M 1s45600K .......... .......... .......... .......... .......... 42%  101M 1s45650K .......... .......... .......... .......... .......... 42%  103M 1s45700K .......... .......... .......... .......... .......... 42% 82.3M 1s45750K .......... .......... .......... .......... .......... 42% 91.3M 1s45800K .......... .......... .......... .......... .......... 42% 95.3M 1s45850K .......... .......... .......... .......... .......... 42% 93.1M 1s45900K .......... .......... .......... .......... .......... 42%  146M 1s45950K .......... .......... .......... .......... .......... 42% 81.4M 1s46000K .......... .......... .......... .......... .......... 42%  108M 1s46050K .......... .......... .......... .......... .......... 43%  124M 1s46100K .......... .......... .......... .......... .......... 43%  138M 1s46150K .......... .......... .......... .......... .......... 43%  117M 1s46200K .......... .......... .......... .......... .......... 43%  146M 1s46250K .......... .......... .......... .......... .......... 43%  129M 1s46300K .......... .......... .......... .......... .......... 43%  140M 1s46350K .......... .......... .......... .......... .......... 43%  101M 1s46400K .......... .......... .......... .......... .......... 43%  148M 1s46450K .......... .......... .......... .......... .......... 43%  150M 1s46500K .......... .......... .......... .......... .......... 43%  146M 1s46550K .......... .......... .......... .......... .......... 43%  131M 1s46600K .......... .......... .......... .......... .......... 43%  132M 1s46650K .......... .......... .......... .......... .......... 43%  138M 1s46700K .......... .......... .......... .......... .......... 43%  148M 1s46750K .......... .......... .......... .......... .......... 43%  104M 1s46800K .......... .......... .......... .......... .......... 43%  149M 1s46850K .......... .......... .......... .......... .......... 43%  123M 1s46900K .......... .......... .......... .......... .......... 43%  133M 1s46950K .......... .......... .......... .......... .......... 43%  126M 1s47000K .......... .......... .......... .......... .......... 43%  135M 1s47050K .......... .......... .......... .......... .......... 43%  149M 1s47100K .......... .......... .......... .......... .......... 44%  163M 1s47150K .......... .......... .......... .......... .......... 44%  126M 1s47200K .......... .......... .......... .......... .......... 44%  118M 1s47250K .......... .......... .......... .......... .......... 44%  133M 1s47300K .......... .......... .......... .......... .......... 44%  159M 1s47350K .......... .......... .......... .......... .......... 44%  151M 1s47400K .......... .......... .......... .......... .......... 44%  178M 1s47450K .......... .......... .......... .......... .......... 44%  141M 1s47500K .......... .......... .......... .......... .......... 44%  122M 1s47550K .......... .......... .......... .......... .......... 44%  108M 1s47600K .......... .......... .......... .......... .......... 44%  111M 1s47650K .......... .......... .......... .......... .......... 44%  125M 1s47700K .......... .......... .......... .......... .......... 44%  147M 1s47750K .......... .......... .......... .......... .......... 44%  136M 1s47800K .......... .......... .......... .......... .......... 44%  128M 1s47850K .......... .......... .......... .......... .......... 44%  145M 1s47900K .......... .......... .......... .......... .......... 44%  151M 1s47950K .......... .......... .......... .......... .......... 44%  106M 1s48000K .......... .......... .......... .......... .......... 44%  142M 1s48050K .......... .......... .......... .......... .......... 44%  139M 1s48100K .......... .......... .......... .......... .......... 44%  148M 1s48150K .......... .......... .......... .......... .......... 45%  100M 1s48200K .......... .......... .......... .......... .......... 45%  149M 1s48250K .......... .......... .......... .......... .......... 45%  123M 1s48300K .......... .......... .......... .......... .......... 45%  139M 1s48350K .......... .......... .......... .......... .......... 45%  123M 1s48400K .......... .......... .......... .......... .......... 45%  132M 1s48450K .......... .......... .......... .......... .......... 45%  150M 1s48500K .......... .......... .......... .......... .......... 45%  143M 1s48550K .......... .......... .......... .......... .......... 45%  124M 1s48600K .......... .......... .......... .......... .......... 45%  136M 1s48650K .......... .......... .......... .......... .......... 45%  145M 1s48700K .......... .......... .......... .......... .......... 45%  130M 1s48750K .......... .......... .......... .......... .......... 45%  112M 1s48800K .......... .......... .......... .......... .......... 45%  152M 1s48850K .......... .......... .......... .......... .......... 45%  149M 1s48900K .......... .......... .......... .......... .......... 45%  133M 1s48950K .......... .......... .......... .......... .......... 45%  124M 1s49000K .......... .......... .......... .......... .......... 45%  163M 1s49050K .......... .......... .......... .......... .......... 45%  137M 1s49100K .......... .......... .......... .......... .......... 45%  127M 1s49150K .......... .......... .......... .......... .......... 45% 94.3M 1s49200K .......... .......... .......... .......... .......... 45%  138M 1s49250K .......... .......... .......... .......... .......... 46%  134M 1s49300K .......... .......... .......... .......... .......... 46%  127M 1s49350K .......... .......... .......... .......... .......... 46%  106M 1s49400K .......... .......... .......... .......... .......... 46%  132M 1s49450K .......... .......... .......... .......... .......... 46%  151M 1s49500K .......... .......... .......... .......... .......... 46%  167M 1s49550K .......... .......... .......... .......... .......... 46%  100M 1s49600K .......... .......... .......... .......... .......... 46%  150M 1s49650K .......... .......... .......... .......... .......... 46%  147M 1s49700K .......... .......... .......... .......... .......... 46%  131M 1s49750K .......... .......... .......... .......... .......... 46%  117M 1s49800K .......... .......... .......... .......... .......... 46%  138M 1s49850K .......... .......... .......... .......... .......... 46%  114M 1s49900K .......... .......... .......... .......... .......... 46%  134M 1s49950K .......... .......... .......... .......... .......... 46%  111M 1s50000K .......... .......... .......... .......... .......... 46%  148M 1s50050K .......... .......... .......... .......... .......... 46%  137M 1s50100K .......... .......... .......... .......... .......... 46%  144M 1s50150K .......... .......... .......... .......... .......... 46%  137M 1s50200K .......... .......... .......... .......... .......... 46%  141M 1s50250K .......... .......... .......... .......... .......... 46%  143M 1s50300K .......... .......... .......... .......... .......... 47%  152M 1s50350K .......... .......... .......... .......... .......... 47% 98.1M 1s50400K .......... .......... .......... .......... .......... 47%  134M 1s50450K .......... .......... .......... .......... .......... 47%  154M 1s50500K .......... .......... .......... .......... .......... 47%  133M 1s50550K .......... .......... .......... .......... .......... 47%  143M 1s50600K .......... .......... .......... .......... .......... 47%  137M 1s50650K .......... .......... .......... .......... .......... 47%  151M 1s50700K .......... .......... .......... .......... .......... 47%  151M 1s50750K .......... .......... .......... .......... .......... 47%  105M 1s50800K .......... .......... .......... .......... .......... 47%  162M 1s50850K .......... .......... .......... .......... .......... 47%  135M 1s50900K .......... .......... .......... .......... .......... 47%  141M 1s50950K .......... .......... .......... .......... .......... 47%  119M 1s51000K .......... .......... .......... .......... .......... 47%  157M 1s51050K .......... .......... .......... .......... .......... 47%  167M 1s51100K .......... .......... .......... .......... .......... 47%  141M 1s51150K .......... .......... .......... .......... .......... 47%  124M 1s51200K .......... .......... .......... .......... .......... 47%  147M 1s51250K .......... .......... .......... .......... .......... 47%  125M 1s51300K .......... .......... .......... .......... .......... 47%  158M 1s51350K .......... .......... .......... .......... .......... 47%  138M 1s51400K .......... .......... .......... .......... .......... 48%  137M 1s51450K .......... .......... .......... .......... .......... 48%  161M 1s51500K .......... .......... .......... .......... .......... 48%  175M 1s51550K .......... .......... .......... .......... .......... 48%  111M 1s51600K .......... .......... .......... .......... .......... 48%  153M 1s51650K .......... .......... .......... .......... .......... 48%  148M 1s51700K .......... .......... .......... .......... .......... 48%  144M 1s51750K .......... .......... .......... .......... .......... 48%  142M 1s51800K .......... .......... .......... .......... .......... 48%  138M 1s51850K .......... .......... .......... .......... .......... 48%  159M 1s51900K .......... .......... .......... .......... .......... 48%  152M 1s51950K .......... .......... .......... .......... .......... 48% 93.8M 1s52000K .......... .......... .......... .......... .......... 48%  152M 1s52050K .......... .......... .......... .......... .......... 48%  106M 1s52100K .......... .......... .......... .......... .......... 48%  131M 1s52150K .......... .......... .......... .......... .......... 48%  117M 1s52200K .......... .......... .......... .......... .......... 48% 97.0M 1s52250K .......... .......... .......... .......... .......... 48%  151M 1s52300K .......... .......... .......... .......... .......... 48%  155M 1s52350K .......... .......... .......... .......... .......... 48%  114M 1s52400K .......... .......... .......... .......... .......... 48%  139M 1s52450K .......... .......... .......... .......... .......... 49%  123M 1s52500K .......... .......... .......... .......... .......... 49%  125M 1s52550K .......... .......... .......... .......... .......... 49%  135M 1s52600K .......... .......... .......... .......... .......... 49%  118M 1s52650K .......... .......... .......... .......... .......... 49%  149M 1s52700K .......... .......... .......... .......... .......... 49%  151M 1s52750K .......... .......... .......... .......... .......... 49% 98.0M 1s52800K .......... .......... .......... .......... .......... 49%  166M 1s52850K .......... .......... .......... .......... .......... 49%  127M 1s52900K .......... .......... .......... .......... .......... 49%  128M 1s52950K .......... .......... .......... .......... .......... 49%  130M 1s53000K .......... .......... .......... .......... .......... 49%  156M 1s53050K .......... .......... .......... .......... .......... 49%  140M 1s53100K .......... .......... .......... .......... .......... 49%  129M 1s53150K .......... .......... .......... .......... .......... 49%  123M 1s53200K .......... .......... .......... .......... .......... 49%  158M 1s53250K .......... .......... .......... .......... .......... 49%  127M 1s53300K .......... .......... .......... .......... .......... 49%  141M 1s53350K .......... .......... .......... .......... .......... 49%  114M 1s53400K .......... .......... .......... .......... .......... 49%  142M 1s53450K .......... .......... .......... .......... .......... 49%  133M 1s53500K .......... .......... .......... .......... .......... 49%  127M 1s53550K .......... .......... .......... .......... .......... 50%  116M 1s53600K .......... .......... .......... .......... .......... 50%  158M 1s53650K .......... .......... .......... .......... .......... 50%  156M 1s53700K .......... .......... .......... .......... .......... 50%  149M 1s53750K .......... .......... .......... .......... .......... 50%  125M 1s53800K .......... .......... .......... .......... .......... 50%  146M 1s53850K .......... .......... .......... .......... .......... 50%  113M 1s53900K .......... .......... .......... .......... .......... 50%  168M 1s53950K .......... .......... .......... .......... .......... 50%  110M 1s54000K .......... .......... .......... .......... .......... 50%  139M 1s54050K .......... .......... .......... .......... .......... 50%  121M 1s54100K .......... .......... .......... .......... .......... 50%  113M 1s54150K .......... .......... .......... .......... .......... 50%  145M 1s54200K .......... .......... .......... .......... .......... 50% 94.3M 1s54250K .......... .......... .......... .......... .......... 50%  122M 1s54300K .......... .......... .......... .......... .......... 50%  160M 1s54350K .......... .......... .......... .......... .......... 50%  102M 1s54400K .......... .......... .......... .......... .......... 50%  146M 1s54450K .......... .......... .......... .......... .......... 50%  142M 1s54500K .......... .......... .......... .......... .......... 50%  140M 1s54550K .......... .......... .......... .......... .......... 50%  123M 1s54600K .......... .......... .......... .......... .......... 51%  163M 1s54650K .......... .......... .......... .......... .......... 51%  133M 1s54700K .......... .......... .......... .......... .......... 51%  110M 1s54750K .......... .......... .......... .......... .......... 51%  118M 1s54800K .......... .......... .......... .......... .......... 51%  136M 1s54850K .......... .......... .......... .......... .......... 51%  127M 1s54900K .......... .......... .......... .......... .......... 51%  134M 1s54950K .......... .......... .......... .......... .......... 51%  154M 1s55000K .......... .......... .......... .......... .......... 51%  136M 1s55050K .......... .......... .......... .......... .......... 51%  175M 1s55100K .......... .......... .......... .......... .......... 51%  134M 1s55150K .......... .......... .......... .......... .......... 51%  108M 1s55200K .......... .......... .......... .......... .......... 51%  168M 1s55250K .......... .......... .......... .......... .......... 51%  133M 1s55300K .......... .......... .......... .......... .......... 51%  136M 1s55350K .......... .......... .......... .......... .......... 51%  142M 1s55400K .......... .......... .......... .......... .......... 51%  121M 1s55450K .......... .......... .......... .......... .......... 51%  155M 1s55500K .......... .......... .......... .......... .......... 51%  129M 1s55550K .......... .......... .......... .......... .......... 51%  122M 1s55600K .......... .......... .......... .......... .......... 51%  155M 1s55650K .......... .......... .......... .......... .......... 52%  149M 1s55700K .......... .......... .......... .......... .......... 52%  153M 1s55750K .......... .......... .......... .......... .......... 52%  112M 1s55800K .......... .......... .......... .......... .......... 52%  143M 1s55850K .......... .......... .......... .......... .......... 52%  145M 1s55900K .......... .......... .......... .......... .......... 52%  128M 1s55950K .......... .......... .......... .......... .......... 52%  106M 1s56000K .......... .......... .......... .......... .......... 52%  148M 1s56050K .......... .......... .......... .......... .......... 52%  156M 1s56100K .......... .......... .......... .......... .......... 52%  162M 1s56150K .......... .......... .......... .......... .......... 52%  174M 1s56200K .......... .......... .......... .......... .......... 52%  142M 1s56250K .......... .......... .......... .......... .......... 52%  138M 1s56300K .......... .......... .......... .......... .......... 52%  161M 1s56350K .......... .......... .......... .......... .......... 52%  122M 1s56400K .......... .......... .......... .......... .......... 52%  148M 1s56450K .......... .......... .......... .......... .......... 52%  160M 1s56500K .......... .......... .......... .......... .......... 52%  138M 1s56550K .......... .......... .......... .......... .......... 52%  147M 1s56600K .......... .......... .......... .......... .......... 52%  151M 1s56650K .......... .......... .......... .......... .......... 52%  144M 1s56700K .......... .......... .......... .......... .......... 52%  119M 1s56750K .......... .......... .......... .......... .......... 53%  124M 1s56800K .......... .......... .......... .......... .......... 53%  142M 1s56850K .......... .......... .......... .......... .......... 53%  127M 1s56900K .......... .......... .......... .......... .......... 53%  128M 1s56950K .......... .......... .......... .......... .......... 53%  134M 0s57000K .......... .......... .......... .......... .......... 53%  127M 0s57050K .......... .......... .......... .......... .......... 53%  134M 0s57100K .......... .......... .......... .......... .......... 53%  136M 0s57150K .......... .......... .......... .......... .......... 53%  118M 0s57200K .......... .......... .......... .......... .......... 53%  113M 0s57250K .......... .......... .......... .......... .......... 53%  133M 0s57300K .......... .......... .......... .......... .......... 53%  125M 0s57350K .......... .......... .......... .......... .......... 53%  116M 0s57400K .......... .......... .......... .......... .......... 53%  139M 0s57450K .......... .......... .......... .......... .......... 53%  141M 0s57500K .......... .......... .......... .......... .......... 53%  120M 0s57550K .......... .......... .......... .......... .......... 53%  112M 0s57600K .......... .......... .......... .......... .......... 53%  164M 0s57650K .......... .......... .......... .......... .......... 53%  125M 0s57700K .......... .......... .......... .......... .......... 53%  142M 0s57750K .......... .......... .......... .......... .......... 53%  134M 0s57800K .......... .......... .......... .......... .......... 54%  140M 0s57850K .......... .......... .......... .......... .......... 54%  101M 0s57900K .......... .......... .......... .......... .......... 54%  147M 0s57950K .......... .......... .......... .......... .......... 54%  113M 0s58000K .......... .......... .......... .......... .......... 54%  128M 0s58050K .......... .......... .......... .......... .......... 54% 64.4M 0s58100K .......... .......... .......... .......... .......... 54%  157M 0s58150K .......... .......... .......... .......... .......... 54%  126M 0s58200K .......... .......... .......... .......... .......... 54%  146M 0s58250K .......... .......... .......... .......... .......... 54%  144M 0s58300K .......... .......... .......... .......... .......... 54%  138M 0s58350K .......... .......... .......... .......... .......... 54% 99.0M 0s58400K .......... .......... .......... .......... .......... 54%  126M 0s58450K .......... .......... .......... .......... .......... 54%  186M 0s58500K .......... .......... .......... .......... .......... 54%  125M 0s58550K .......... .......... .......... .......... .......... 54% 97.6M 0s58600K .......... .......... .......... .......... .......... 54%  121M 0s58650K .......... .......... .......... .......... .......... 54%  143M 0s58700K .......... .......... .......... .......... .......... 54%  127M 0s58750K .......... .......... .......... .......... .......... 54%  110M 0s58800K .......... .......... .......... .......... .......... 54%  144M 0s58850K .......... .......... .......... .......... .......... 54%  140M 0s58900K .......... .......... .......... .......... .......... 55%  126M 0s58950K .......... .......... .......... .......... .......... 55%  140M 0s59000K .......... .......... .......... .......... .......... 55%  117M 0s59050K .......... .......... .......... .......... .......... 55%  110M 0s59100K .......... .......... .......... .......... .......... 55%  161M 0s59150K .......... .......... .......... .......... .......... 55% 99.8M 0s59200K .......... .......... .......... .......... .......... 55%  117M 0s59250K .......... .......... .......... .......... .......... 55%  104M 0s59300K .......... .......... .......... .......... .......... 55%  145M 0s59350K .......... .......... .......... .......... .......... 55%  112M 0s59400K .......... .......... .......... .......... .......... 55% 94.5M 0s59450K .......... .......... .......... .......... .......... 55%  156M 0s59500K .......... .......... .......... .......... .......... 55%  117M 0s59550K .......... .......... .......... .......... .......... 55%  143M 0s59600K .......... .......... .......... .......... .......... 55%  182M 0s59650K .......... .......... .......... .......... .......... 55%  158M 0s59700K .......... .......... .......... .......... .......... 55%  170M 0s59750K .......... .......... .......... .......... .......... 55%  150M 0s59800K .......... .......... .......... .......... .......... 55%  132M 0s59850K .......... .......... .......... .......... .......... 55%  146M 0s59900K .......... .......... .......... .......... .......... 55% 99.1M 0s59950K .......... .......... .......... .......... .......... 56% 75.1M 0s60000K .......... .......... .......... .......... .......... 56%  116M 0s60050K .......... .......... .......... .......... .......... 56%  131M 0s60100K .......... .......... .......... .......... .......... 56%  158M 0s60150K .......... .......... .......... .......... .......... 56%  122M 0s60200K .......... .......... .......... .......... .......... 56%  114M 0s60250K .......... .......... .......... .......... .......... 56%  112M 0s60300K .......... .......... .......... .......... .......... 56%  123M 0s60350K .......... .......... .......... .......... .......... 56% 96.0M 0s60400K .......... .......... .......... .......... .......... 56%  124M 0s60450K .......... .......... .......... .......... .......... 56%  132M 0s60500K .......... .......... .......... .......... .......... 56%  190M 0s60550K .......... .......... .......... .......... .......... 56%  169M 0s60600K .......... .......... .......... .......... .......... 56%  152M 0s60650K .......... .......... .......... .......... .......... 56%  170M 0s60700K .......... .......... .......... .......... .......... 56%  142M 0s60750K .......... .......... .......... .......... .......... 56% 88.1M 0s60800K .......... .......... .......... .......... .......... 56%  123M 0s60850K .......... .......... .......... .......... .......... 56% 81.2M 0s60900K .......... .......... .......... .......... .......... 56%  117M 0s60950K .......... .......... .......... .......... .......... 56% 86.5M 0s61000K .......... .......... .......... .......... .......... 57%  117M 0s61050K .......... .......... .......... .......... .......... 57%  104M 0s61100K .......... .......... .......... .......... .......... 57%  115M 0s61150K .......... .......... .......... .......... .......... 57% 96.3M 0s61200K .......... .......... .......... .......... .......... 57%  102M 0s61250K .......... .......... .......... .......... .......... 57%  116M 0s61300K .......... .......... .......... .......... .......... 57% 82.9M 0s61350K .......... .......... .......... .......... .......... 57% 94.5M 0s61400K .......... .......... .......... .......... .......... 57%  119M 0s61450K .......... .......... .......... .......... .......... 57% 76.3M 0s61500K .......... .......... .......... .......... .......... 57%  108M 0s61550K .......... .......... .......... .......... .......... 57% 72.3M 0s61600K .......... .......... .......... .......... .......... 57%  120M 0s61650K .......... .......... .......... .......... .......... 57%  121M 0s61700K .......... .......... .......... .......... .......... 57%  121M 0s61750K .......... .......... .......... .......... .......... 57%  135M 0s61800K .......... .......... .......... .......... .......... 57%  101M 0s61850K .......... .......... .......... .......... .......... 57%  119M 0s61900K .......... .......... .......... .......... .......... 57% 97.6M 0s61950K .......... .......... .......... .......... .......... 57% 89.6M 0s62000K .......... .......... .......... .......... .......... 57%  111M 0s62050K .......... .......... .......... .......... .......... 57%  115M 0s62100K .......... .......... .......... .......... .......... 58%  132M 0s62150K .......... .......... .......... .......... .......... 58%  108M 0s62200K .......... .......... .......... .......... .......... 58% 98.8M 0s62250K .......... .......... .......... .......... .......... 58%  108M 0s62300K .......... .......... .......... .......... .......... 58%  175M 0s62350K .......... .......... .......... .......... .......... 58% 89.9M 0s62400K .......... .......... .......... .......... .......... 58%  158M 0s62450K .......... .......... .......... .......... .......... 58%  107M 0s62500K .......... .......... .......... .......... .......... 58%  106M 0s62550K .......... .......... .......... .......... .......... 58%  151M 0s62600K .......... .......... .......... .......... .......... 58% 80.0M 0s62650K .......... .......... .......... .......... .......... 58%  160M 0s62700K .......... .......... .......... .......... .......... 58% 98.9M 0s62750K .......... .......... .......... .......... .......... 58% 98.8M 0s62800K .......... .......... .......... .......... .......... 58%  120M 0s62850K .......... .......... .......... .......... .......... 58%  173M 0s62900K .......... .......... .......... .......... .......... 58%  135M 0s62950K .......... .......... .......... .......... .......... 58%  111M 0s63000K .......... .......... .......... .......... .......... 58% 74.8M 0s63050K .......... .......... .......... .......... .......... 58%  129M 0s63100K .......... .......... .......... .......... .......... 58% 96.1M 0s63150K .......... .......... .......... .......... .......... 59% 71.0M 0s63200K .......... .......... .......... .......... .......... 59%  115M 0s63250K .......... .......... .......... .......... .......... 59%  129M 0s63300K .......... .......... .......... .......... .......... 59% 92.5M 0s63350K .......... .......... .......... .......... .......... 59% 76.1M 0s63400K .......... .......... .......... .......... .......... 59%  119M 0s63450K .......... .......... .......... .......... .......... 59% 69.2M 0s63500K .......... .......... .......... .......... .......... 59%  137M 0s63550K .......... .......... .......... .......... .......... 59% 93.9M 0s63600K .......... .......... .......... .......... .......... 59% 71.4M 0s63650K .......... .......... .......... .......... .......... 59%  126M 0s63700K .......... .......... .......... .......... .......... 59%  121M 0s63750K .......... .......... .......... .......... .......... 59% 73.5M 0s63800K .......... .......... .......... .......... .......... 59%  139M 0s63850K .......... .......... .......... .......... .......... 59% 92.0M 0s63900K .......... .......... .......... .......... .......... 59% 83.3M 0s63950K .......... .......... .......... .......... .......... 59%  106M 0s64000K .......... .......... .......... .......... .......... 59%  147M 0s64050K .......... .......... .......... .......... .......... 59% 68.3M 0s64100K .......... .......... .......... .......... .......... 59%  117M 0s64150K .......... .......... .......... .......... .......... 59% 98.7M 0s64200K .......... .......... .......... .......... .......... 59% 87.8M 0s64250K .......... .......... .......... .......... .......... 60%  165M 0s64300K .......... .......... .......... .......... .......... 60% 96.2M 0s64350K .......... .......... .......... .......... .......... 60% 95.7M 0s64400K .......... .......... .......... .......... .......... 60%  118M 0s64450K .......... .......... .......... .......... .......... 60% 83.1M 0s64500K .......... .......... .......... .......... .......... 60%  153M 0s64550K .......... .......... .......... .......... .......... 60% 78.0M 0s64600K .......... .......... .......... .......... .......... 60%  127M 0s64650K .......... .......... .......... .......... .......... 60%  120M 0s64700K .......... .......... .......... .......... .......... 60% 87.0M 0s64750K .......... .......... .......... .......... .......... 60% 88.8M 0s64800K .......... .......... .......... .......... .......... 60% 75.9M 0s64850K .......... .......... .......... .......... .......... 60%  132M 0s64900K .......... .......... .......... .......... .......... 60%  108M 0s64950K .......... .......... .......... .......... .......... 60% 76.8M 0s65000K .......... .......... .......... .......... .......... 60%  166M 0s65050K .......... .......... .......... .......... .......... 60% 88.8M 0s65100K .......... .......... .......... .......... .......... 60%  104M 0s65150K .......... .......... .......... .......... .......... 60% 93.8M 0s65200K .......... .......... .......... .......... .......... 60% 91.8M 0s65250K .......... .......... .......... .......... .......... 60%  137M 0s65300K .......... .......... .......... .......... .......... 61%  147M 0s65350K .......... .......... .......... .......... .......... 61% 81.1M 0s65400K .......... .......... .......... .......... .......... 61% 99.8M 0s65450K .......... .......... .......... .......... .......... 61%  103M 0s65500K .......... .......... .......... .......... .......... 61% 88.6M 0s65550K .......... .......... .......... .......... .......... 61%  116M 0s65600K .......... .......... .......... .......... .......... 61%  100M 0s65650K .......... .......... .......... .......... .......... 61% 93.1M 0s65700K .......... .......... .......... .......... .......... 61%  135M 0s65750K .......... .......... .......... .......... .......... 61% 74.1M 0s65800K .......... .......... .......... .......... .......... 61%  110M 0s65850K .......... .......... .......... .......... .......... 61% 96.8M 0s65900K .......... .......... .......... .......... .......... 61% 88.0M 0s65950K .......... .......... .......... .......... .......... 61% 92.0M 0s66000K .......... .......... .......... .......... .......... 61% 88.7M 0s66050K .......... .......... .......... .......... .......... 61%  165M 0s66100K .......... .......... .......... .......... .......... 61% 90.4M 0s66150K .......... .......... .......... .......... .......... 61%  111M 0s66200K .......... .......... .......... .......... .......... 61%  110M 0s66250K .......... .......... .......... .......... .......... 61% 87.6M 0s66300K .......... .......... .......... .......... .......... 61%  132M 0s66350K .......... .......... .......... .......... .......... 61% 72.6M 0s66400K .......... .......... .......... .......... .......... 62%  163M 0s66450K .......... .......... .......... .......... .......... 62% 94.6M 0s66500K .......... .......... .......... .......... .......... 62% 93.5M 0s66550K .......... .......... .......... .......... .......... 62%  120M 0s66600K .......... .......... .......... .......... .......... 62% 76.2M 0s66650K .......... .......... .......... .......... .......... 62%  127M 0s66700K .......... .......... .......... .......... .......... 62%  111M 0s66750K .......... .......... .......... .......... .......... 62% 91.8M 0s66800K .......... .......... .......... .......... .......... 62%  147M 0s66850K .......... .......... .......... .......... .......... 62% 87.5M 0s66900K .......... .......... .......... .......... .......... 62%  122M 0s66950K .......... .......... .......... .......... .......... 62% 78.5M 0s67000K .......... .......... .......... .......... .......... 62% 91.0M 0s67050K .......... .......... .......... .......... .......... 62%  107M 0s67100K .......... .......... .......... .......... .......... 62% 80.6M 0s67150K .......... .......... .......... .......... .......... 62%  110M 0s67200K .......... .......... .......... .......... .......... 62% 90.0M 0s67250K .......... .......... .......... .......... .......... 62% 96.1M 0s67300K .......... .......... .......... .......... .......... 62% 84.8M 0s67350K .......... .......... .......... .......... .......... 62%  106M 0s67400K .......... .......... .......... .......... .......... 62%  149M 0s67450K .......... .......... .......... .......... .......... 63% 74.5M 0s67500K .......... .......... .......... .......... .......... 63%  117M 0s67550K .......... .......... .......... .......... .......... 63% 78.8M 0s67600K .......... .......... .......... .......... .......... 63%  114M 0s67650K .......... .......... .......... .......... .......... 63%  169M 0s67700K .......... .......... .......... .......... .......... 63% 91.5M 0s67750K .......... .......... .......... .......... .......... 63% 78.5M 0s67800K .......... .......... .......... .......... .......... 63%  132M 0s67850K .......... .......... .......... .......... .......... 63% 81.0M 0s67900K .......... .......... .......... .......... .......... 63%  130M 0s67950K .......... .......... .......... .......... .......... 63% 79.7M 0s68000K .......... .......... .......... .......... .......... 63%  110M 0s68050K .......... .......... .......... .......... .......... 63%  116M 0s68100K .......... .......... .......... .......... .......... 63% 93.7M 0s68150K .......... .......... .......... .......... .......... 63%  130M 0s68200K .......... .......... .......... .......... .......... 63% 89.7M 0s68250K .......... .......... .......... .......... .......... 63%  119M 0s68300K .......... .......... .......... .......... .......... 63% 88.3M 0s68350K .......... .......... .......... .......... .......... 63% 81.8M 0s68400K .......... .......... .......... .......... .......... 63%  146M 0s68450K .......... .......... .......... .......... .......... 63% 90.2M 0s68500K .......... .......... .......... .......... .......... 64%  118M 0s68550K .......... .......... .......... .......... .......... 64% 90.1M 0s68600K .......... .......... .......... .......... .......... 64% 96.0M 0s68650K .......... .......... .......... .......... .......... 64%  165M 0s68700K .......... .......... .......... .......... .......... 64% 81.4M 0s68750K .......... .......... .......... .......... .......... 64% 95.5M 0s68800K .......... .......... .......... .......... .......... 64%  104M 0s68850K .......... .......... .......... .......... .......... 64% 87.4M 0s68900K .......... .......... .......... .......... .......... 64%  162M 0s68950K .......... .......... .......... .......... .......... 64% 87.3M 0s69000K .......... .......... .......... .......... .......... 64% 97.3M 0s69050K .......... .......... .......... .......... .......... 64% 96.4M 0s69100K .......... .......... .......... .......... .......... 64% 87.1M 0s69150K .......... .......... .......... .......... .......... 64%  113M 0s69200K .......... .......... .......... .......... .......... 64% 86.4M 0s69250K .......... .......... .......... .......... .......... 64%  145M 0s69300K .......... .......... .......... .......... .......... 64%  114M 0s69350K .......... .......... .......... .......... .......... 64% 86.4M 0s69400K .......... .......... .......... .......... .......... 64%  151M 0s69450K .......... .......... .......... .......... .......... 64% 80.3M 0s69500K .......... .......... .......... .......... .......... 64%  116M 0s69550K .......... .......... .......... .......... .......... 64% 70.8M 0s69600K .......... .......... .......... .......... .......... 65%  128M 0s69650K .......... .......... .......... .......... .......... 65%  144M 0s69700K .......... .......... .......... .......... .......... 65% 71.1M 0s69750K .......... .......... .......... .......... .......... 65%  149M 0s69800K .......... .......... .......... .......... .......... 65% 89.3M 0s69850K .......... .......... .......... .......... .......... 65%  104M 0s69900K .......... .......... .......... .......... .......... 65%  128M 0s69950K .......... .......... .......... .......... .......... 65% 70.2M 0s70000K .......... .......... .......... .......... .......... 65%  168M 0s70050K .......... .......... .......... .......... .......... 65% 95.0M 0s70100K .......... .......... .......... .......... .......... 65% 99.6M 0s70150K .......... .......... .......... .......... .......... 65%  118M 0s70200K .......... .......... .......... .......... .......... 65% 75.8M 0s70250K .......... .......... .......... .......... .......... 65%  137M 0s70300K .......... .......... .......... .......... .......... 65% 71.9M 0s70350K .......... .......... .......... .......... .......... 65%  106M 0s70400K .......... .......... .......... .......... .......... 65%  143M 0s70450K .......... .......... .......... .......... .......... 65% 74.3M 0s70500K .......... .......... .......... .......... .......... 65%  160M 0s70550K .......... .......... .......... .......... .......... 65% 83.7M 0s70600K .......... .......... .......... .......... .......... 65%  103M 0s70650K .......... .......... .......... .......... .......... 66% 84.2M 0s70700K .......... .......... .......... .......... .......... 66%  115M 0s70750K .......... .......... .......... .......... .......... 66%  108M 0s70800K .......... .......... .......... .......... .......... 66% 82.3M 0s70850K .......... .......... .......... .......... .......... 66%  134M 0s70900K .......... .......... .......... .......... .......... 66% 86.6M 0s70950K .......... .......... .......... .......... .......... 66%  101M 0s71000K .......... .......... .......... .......... .......... 66%  118M 0s71050K .......... .......... .......... .......... .......... 66% 79.7M 0s71100K .......... .......... .......... .......... .......... 66%  126M 0s71150K .......... .......... .......... .......... .......... 66% 64.3M 0s71200K .......... .......... .......... .......... .......... 66%  120M 0s71250K .......... .......... .......... .......... .......... 66%  103M 0s71300K .......... .......... .......... .......... .......... 66%  102M 0s71350K .......... .......... .......... .......... .......... 66%  148M 0s71400K .......... .......... .......... .......... .......... 66% 76.4M 0s71450K .......... .......... .......... .......... .......... 66%  135M 0s71500K .......... .......... .......... .......... .......... 66%  124M 0s71550K .......... .......... .......... .......... .......... 66% 72.1M 0s71600K .......... .......... .......... .......... .......... 66%  127M 0s71650K .......... .......... .......... .......... .......... 66% 91.4M 0s71700K .......... .......... .......... .......... .......... 66%  128M 0s71750K .......... .......... .......... .......... .......... 67% 82.2M 0s71800K .......... .......... .......... .......... .......... 67%  103M 0s71850K .......... .......... .......... .......... .......... 67%  156M 0s71900K .......... .......... .......... .......... .......... 67% 74.0M 0s71950K .......... .......... .......... .......... .......... 67% 86.8M 0s72000K .......... .......... .......... .......... .......... 67%  147M 0s72050K .......... .......... .......... .......... .......... 67% 86.0M 0s72100K .......... .......... .......... .......... .......... 67%  164M 0s72150K .......... .......... .......... .......... .......... 67% 97.9M 0s72200K .......... .......... .......... .......... .......... 67% 91.1M 0s72250K .......... .......... .......... .......... .......... 67%  164M 0s72300K .......... .......... .......... .......... .......... 67% 71.9M 0s72350K .......... .......... .......... .......... .......... 67%  106M 0s72400K .......... .......... .......... .......... .......... 67% 98.3M 0s72450K .......... .......... .......... .......... .......... 67% 92.6M 0s72500K .......... .......... .......... .......... .......... 67%  163M 0s72550K .......... .......... .......... .......... .......... 67% 81.6M 0s72600K .......... .......... .......... .......... .......... 67% 91.1M 0s72650K .......... .......... .......... .......... .......... 67%  152M 0s72700K .......... .......... .......... .......... .......... 67% 88.1M 0s72750K .......... .......... .......... .......... .......... 67% 77.1M 0s72800K .......... .......... .......... .......... .......... 68%  100M 0s72850K .......... .......... .......... .......... .......... 68% 88.8M 0s72900K .......... .......... .......... .......... .......... 68%  162M 0s72950K .......... .......... .......... .......... .......... 68% 87.6M 0s73000K .......... .......... .......... .......... .......... 68%  104M 0s73050K .......... .......... .......... .......... .......... 68%  127M 0s73100K .......... .......... .......... .......... .......... 68% 73.1M 0s73150K .......... .......... .......... .......... .......... 68%  120M 0s73200K .......... .......... .......... .......... .......... 68% 70.1M 0s73250K .......... .......... .......... .......... .......... 68%  161M 0s73300K .......... .......... .......... .......... .......... 68% 76.1M 0s73350K .......... .......... .......... .......... .......... 68%  119M 0s73400K .......... .......... .......... .......... .......... 68%  129M 0s73450K .......... .......... .......... .......... .......... 68% 84.5M 0s73500K .......... .......... .......... .......... .......... 68%  142M 0s73550K .......... .......... .......... .......... .......... 68% 67.9M 0s73600K .......... .......... .......... .......... .......... 68%  115M 0s73650K .......... .......... .......... .......... .......... 68%  140M 0s73700K .......... .......... .......... .......... .......... 68% 74.4M 0s73750K .......... .......... .......... .......... .......... 68%  143M 0s73800K .......... .......... .......... .......... .......... 68% 99.9M 0s73850K .......... .......... .......... .......... .......... 68% 97.6M 0s73900K .......... .......... .......... .......... .......... 69%  122M 0s73950K .......... .......... .......... .......... .......... 69% 61.3M 0s74000K .......... .......... .......... .......... .......... 69%  123M 0s74050K .......... .......... .......... .......... .......... 69% 92.9M 0s74100K .......... .......... .......... .......... .......... 69%  109M 0s74150K .......... .......... .......... .......... .......... 69%  106M 0s74200K .......... .......... .......... .......... .......... 69%  133M 0s74250K .......... .......... .......... .......... .......... 69%  136M 0s74300K .......... .......... .......... .......... .......... 69%  100M 0s74350K .......... .......... .......... .......... .......... 69% 68.3M 0s74400K .......... .......... .......... .......... .......... 69% 98.3M 0s74450K .......... .......... .......... .......... .......... 69%  146M 0s74500K .......... .......... .......... .......... .......... 69%  155M 0s74550K .......... .......... .......... .......... .......... 69%  131M 0s74600K .......... .......... .......... .......... .......... 69%  143M 0s74650K .......... .......... .......... .......... .......... 69%  144M 0s74700K .......... .......... .......... .......... .......... 69%  122M 0s74750K .......... .......... .......... .......... .......... 69% 99.1M 0s74800K .......... .......... .......... .......... .......... 69%  136M 0s74850K .......... .......... .......... .......... .......... 69%  162M 0s74900K .......... .......... .......... .......... .......... 69%  134M 0s74950K .......... .......... .......... .......... .......... 70%  163M 0s75000K .......... .......... .......... .......... .......... 70%  144M 0s75050K .......... .......... .......... .......... .......... 70%  129M 0s75100K .......... .......... .......... .......... .......... 70%  123M 0s75150K .......... .......... .......... .......... .......... 70% 98.3M 0s75200K .......... .......... .......... .......... .......... 70%  129M 0s75250K .......... .......... .......... .......... .......... 70% 88.6M 0s75300K .......... .......... .......... .......... .......... 70%  140M 0s75350K .......... .......... .......... .......... .......... 70% 97.2M 0s75400K .......... .......... .......... .......... .......... 70%  143M 0s75450K .......... .......... .......... .......... .......... 70%  122M 0s75500K .......... .......... .......... .......... .......... 70%  113M 0s75550K .......... .......... .......... .......... .......... 70% 86.0M 0s75600K .......... .......... .......... .......... .......... 70%  105M 0s75650K .......... .......... .......... .......... .......... 70%  127M 0s75700K .......... .......... .......... .......... .......... 70%  102M 0s75750K .......... .......... .......... .......... .......... 70% 88.2M 0s75800K .......... .......... .......... .......... .......... 70%  105M 0s75850K .......... .......... .......... .......... .......... 70% 92.1M 0s75900K .......... .......... .......... .......... .......... 70%  116M 0s75950K .......... .......... .......... .......... .......... 70% 86.5M 0s76000K .......... .......... .......... .......... .......... 71%  106M 0s76050K .......... .......... .......... .......... .......... 71% 88.5M 0s76100K .......... .......... .......... .......... .......... 71% 98.8M 0s76150K .......... .......... .......... .......... .......... 71%  104M 0s76200K .......... .......... .......... .......... .......... 71%  109M 0s76250K .......... .......... .......... .......... .......... 71%  106M 0s76300K .......... .......... .......... .......... .......... 71% 89.9M 0s76350K .......... .......... .......... .......... .......... 71% 90.5M 0s76400K .......... .......... .......... .......... .......... 71%  135M 0s76450K .......... .......... .......... .......... .......... 71% 96.9M 0s76500K .......... .......... .......... .......... .......... 71%  123M 0s76550K .......... .......... .......... .......... .......... 71%  102M 0s76600K .......... .......... .......... .......... .......... 71% 62.6M 0s76650K .......... .......... .......... .......... .......... 71%  134M 0s76700K .......... .......... .......... .......... .......... 71%  110M 0s76750K .......... .......... .......... .......... .......... 71% 82.0M 0s76800K .......... .......... .......... .......... .......... 71%  105M 0s76850K .......... .......... .......... .......... .......... 71%  102M 0s76900K .......... .......... .......... .......... .......... 71%  128M 0s76950K .......... .......... .......... .......... .......... 71% 92.5M 0s77000K .......... .......... .......... .......... .......... 71% 83.9M 0s77050K .......... .......... .......... .......... .......... 71%  129M 0s77100K .......... .......... .......... .......... .......... 72%  127M 0s77150K .......... .......... .......... .......... .......... 72% 56.5M 0s77200K .......... .......... .......... .......... .......... 72%  104M 0s77250K .......... .......... .......... .......... .......... 72%  106M 0s77300K .......... .......... .......... .......... .......... 72% 90.9M 0s77350K .......... .......... .......... .......... .......... 72% 88.6M 0s77400K .......... .......... .......... .......... .......... 72% 86.9M 0s77450K .......... .......... .......... .......... .......... 72% 96.3M 0s77500K .......... .......... .......... .......... .......... 72% 88.3M 0s77550K .......... .......... .......... .......... .......... 72% 95.3M 0s77600K .......... .......... .......... .......... .......... 72%  172M 0s77650K .......... .......... .......... .......... .......... 72% 92.4M 0s77700K .......... .......... .......... .......... .......... 72% 97.6M 0s77750K .......... .......... .......... .......... .......... 72% 71.7M 0s77800K .......... .......... .......... .......... .......... 72%  126M 0s77850K .......... .......... .......... .......... .......... 72%  109M 0s77900K .......... .......... .......... .......... .......... 72% 86.6M 0s77950K .......... .......... .......... .......... .......... 72% 92.1M 0s78000K .......... .......... .......... .......... .......... 72%  107M 0s78050K .......... .......... .......... .......... .......... 72%  106M 0s78100K .......... .......... .......... .......... .......... 72% 96.6M 0s78150K .......... .......... .......... .......... .......... 73%  104M 0s78200K .......... .......... .......... .......... .......... 73%  111M 0s78250K .......... .......... .......... .......... .......... 73%  113M 0s78300K .......... .......... .......... .......... .......... 73% 92.8M 0s78350K .......... .......... .......... .......... .......... 73% 68.9M 0s78400K .......... .......... .......... .......... .......... 73%  110M 0s78450K .......... .......... .......... .......... .......... 73%  110M 0s78500K .......... .......... .......... .......... .......... 73%  121M 0s78550K .......... .......... .......... .......... .......... 73% 95.2M 0s78600K .......... .......... .......... .......... .......... 73% 89.9M 0s78650K .......... .......... .......... .......... .......... 73% 98.1M 0s78700K .......... .......... .......... .......... .......... 73%  158M 0s78750K .......... .......... .......... .......... .......... 73%  105M 0s78800K .......... .......... .......... .......... .......... 73%  162M 0s78850K .......... .......... .......... .......... .......... 73%  167M 0s78900K .......... .......... .......... .......... .......... 73%  129M 0s78950K .......... .......... .......... .......... .......... 73%  148M 0s79000K .......... .......... .......... .......... .......... 73%  136M 0s79050K .......... .......... .......... .......... .......... 73%  138M 0s79100K .......... .......... .......... .......... .......... 73%  181M 0s79150K .......... .......... .......... .......... .......... 73%  110M 0s79200K .......... .......... .......... .......... .......... 73%  170M 0s79250K .......... .......... .......... .......... .......... 74%  136M 0s79300K .......... .......... .......... .......... .......... 74%  152M 0s79350K .......... .......... .......... .......... .......... 74%  122M 0s79400K .......... .......... .......... .......... .......... 74%  146M 0s79450K .......... .......... .......... .......... .......... 74%  134M 0s79500K .......... .......... .......... .......... .......... 74%  143M 0s79550K .......... .......... .......... .......... .......... 74%  124M 0s79600K .......... .......... .......... .......... .......... 74%  148M 0s79650K .......... .......... .......... .......... .......... 74%  157M 0s79700K .......... .......... .......... .......... .......... 74%  144M 0s79750K .......... .......... .......... .......... .......... 74%  120M 0s79800K .......... .......... .......... .......... .......... 74%  143M 0s79850K .......... .......... .......... .......... .......... 74%  154M 0s79900K .......... .......... .......... .......... .......... 74%  109M 0s79950K .......... .......... .......... .......... .......... 74%  139M 0s80000K .......... .......... .......... .......... .......... 74%  148M 0s80050K .......... .......... .......... .......... .......... 74%  143M 0s80100K .......... .......... .......... .......... .......... 74%  168M 0s80150K .......... .......... .......... .......... .......... 74%  134M 0s80200K .......... .......... .......... .......... .......... 74%  153M 0s80250K .......... .......... .......... .......... .......... 74%  150M 0s80300K .......... .......... .......... .......... .......... 75%  141M 0s80350K .......... .......... .......... .......... .......... 75%  130M 0s80400K .......... .......... .......... .......... .......... 75%  161M 0s80450K .......... .......... .......... .......... .......... 75%  136M 0s80500K .......... .......... .......... .......... .......... 75%  129M 0s80550K .......... .......... .......... .......... .......... 75%  116M 0s80600K .......... .......... .......... .......... .......... 75%  147M 0s80650K .......... .......... .......... .......... .......... 75%  176M 0s80700K .......... .......... .......... .......... .......... 75%  142M 0s80750K .......... .......... .......... .......... .......... 75% 97.4M 0s80800K .......... .......... .......... .......... .......... 75%  145M 0s80850K .......... .......... .......... .......... .......... 75%  142M 0s80900K .......... .......... .......... .......... .......... 75%  192M 0s80950K .......... .......... .......... .......... .......... 75%  145M 0s81000K .......... .......... .......... .......... .......... 75%  131M 0s81050K .......... .......... .......... .......... .......... 75%  127M 0s81100K .......... .......... .......... .......... .......... 75%  162M 0s81150K .......... .......... .......... .......... .......... 75%  128M 0s81200K .......... .......... .......... .......... .......... 75%  168M 0s81250K .......... .......... .......... .......... .......... 75%  158M 0s81300K .......... .......... .......... .......... .......... 75%  161M 0s81350K .......... .......... .......... .......... .......... 76%  119M 0s81400K .......... .......... .......... .......... .......... 76%  142M 0s81450K .......... .......... .......... .......... .......... 76%  142M 0s81500K .......... .......... .......... .......... .......... 76%  144M 0s81550K .......... .......... .......... .......... .......... 76%  119M 0s81600K .......... .......... .......... .......... .......... 76%  152M 0s81650K .......... .......... .......... .......... .......... 76%  126M 0s81700K .......... .......... .......... .......... .......... 76%  153M 0s81750K .......... .......... .......... .......... .......... 76%  132M 0s81800K .......... .......... .......... .......... .......... 76%  130M 0s81850K .......... .......... .......... .......... .......... 76%  150M 0s81900K .......... .......... .......... .......... .......... 76%  143M 0s81950K .......... .......... .......... .......... .......... 76%  123M 0s82000K .......... .......... .......... .......... .......... 76%  155M 0s82050K .......... .......... .......... .......... .......... 76%  122M 0s82100K .......... .......... .......... .......... .......... 76%  148M 0s82150K .......... .......... .......... .......... .......... 76% 51.7M 0s82200K .......... .......... .......... .......... .......... 76%  126M 0s82250K .......... .......... .......... .......... .......... 76%  158M 0s82300K .......... .......... .......... .......... .......... 76%  145M 0s82350K .......... .......... .......... .......... .......... 76%  116M 0s82400K .......... .......... .......... .......... .......... 76%  132M 0s82450K .......... .......... .......... .......... .......... 77%  168M 0s82500K .......... .......... .......... .......... .......... 77%  133M 0s82550K .......... .......... .......... .......... .......... 77%  163M 0s82600K .......... .......... .......... .......... .......... 77%  173M 0s82650K .......... .......... .......... .......... .......... 77%  116M 0s82700K .......... .......... .......... .......... .......... 77%  155M 0s82750K .......... .......... .......... .......... .......... 77%  115M 0s82800K .......... .......... .......... .......... .......... 77%  127M 0s82850K .......... .......... .......... .......... .......... 77%  132M 0s82900K .......... .......... .......... .......... .......... 77%  183M 0s82950K .......... .......... .......... .......... .......... 77%  121M 0s83000K .......... .......... .......... .......... .......... 77%  134M 0s83050K .......... .......... .......... .......... .......... 77%  136M 0s83100K .......... .......... .......... .......... .......... 77%  144M 0s83150K .......... .......... .......... .......... .......... 77%  124M 0s83200K .......... .......... .......... .......... .......... 77%  133M 0s83250K .......... .......... .......... .......... .......... 77%  162M 0s83300K .......... .......... .......... .......... .......... 77%  150M 0s83350K .......... .......... .......... .......... .......... 77%  116M 0s83400K .......... .......... .......... .......... .......... 77%  109M 0s83450K .......... .......... .......... .......... .......... 77%  184M 0s83500K .......... .......... .......... .......... .......... 78%  163M 0s83550K .......... .......... .......... .......... .......... 78% 96.9M 0s83600K .......... .......... .......... .......... .......... 78%  115M 0s83650K .......... .......... .......... .......... .......... 78%  143M 0s83700K .......... .......... .......... .......... .......... 78%  129M 0s83750K .......... .......... .......... .......... .......... 78%  143M 0s83800K .......... .......... .......... .......... .......... 78%  130M 0s83850K .......... .......... .......... .......... .......... 78%  126M 0s83900K .......... .......... .......... .......... .......... 78%  135M 0s83950K .......... .......... .......... .......... .......... 78%  130M 0s84000K .......... .......... .......... .......... .......... 78%  126M 0s84050K .......... .......... .......... .......... .......... 78%  175M 0s84100K .......... .......... .......... .......... .......... 78%  142M 0s84150K .......... .......... .......... .......... .......... 78%  127M 0s84200K .......... .......... .......... .......... .......... 78%  149M 0s84250K .......... .......... .......... .......... .......... 78%  151M 0s84300K .......... .......... .......... .......... .......... 78%  123M 0s84350K .......... .......... .......... .......... .......... 78%  133M 0s84400K .......... .......... .......... .......... .......... 78%  135M 0s84450K .......... .......... .......... .......... .......... 78%  121M 0s84500K .......... .......... .......... .......... .......... 78%  150M 0s84550K .......... .......... .......... .......... .......... 78%  127M 0s84600K .......... .......... .......... .......... .......... 79%  149M 0s84650K .......... .......... .......... .......... .......... 79%  152M 0s84700K .......... .......... .......... .......... .......... 79%  142M 0s84750K .......... .......... .......... .......... .......... 79%  133M 0s84800K .......... .......... .......... .......... .......... 79%  116M 0s84850K .......... .......... .......... .......... .......... 79%  158M 0s84900K .......... .......... .......... .......... .......... 79%  154M 0s84950K .......... .......... .......... .......... .......... 79%  130M 0s85000K .......... .......... .......... .......... .......... 79%  160M 0s85050K .......... .......... .......... .......... .......... 79%  165M 0s85100K .......... .......... .......... .......... .......... 79%  174M 0s85150K .......... .......... .......... .......... .......... 79%  118M 0s85200K .......... .......... .......... .......... .......... 79%  151M 0s85250K .......... .......... .......... .......... .......... 79%  156M 0s85300K .......... .......... .......... .......... .......... 79%  162M 0s85350K .......... .......... .......... .......... .......... 79%  157M 0s85400K .......... .......... .......... .......... .......... 79%  155M 0s85450K .......... .......... .......... .......... .......... 79%  135M 0s85500K .......... .......... .......... .......... .......... 79%  138M 0s85550K .......... .......... .......... .......... .......... 79%  106M 0s85600K .......... .......... .......... .......... .......... 79%  178M 0s85650K .......... .......... .......... .......... .......... 80%  123M 0s85700K .......... .......... .......... .......... .......... 80%  129M 0s85750K .......... .......... .......... .......... .......... 80%  125M 0s85800K .......... .......... .......... .......... .......... 80%  149M 0s85850K .......... .......... .......... .......... .......... 80%  155M 0s85900K .......... .......... .......... .......... .......... 80%  126M 0s85950K .......... .......... .......... .......... .......... 80%  108M 0s86000K .......... .......... .......... .......... .......... 80%  116M 0s86050K .......... .......... .......... .......... .......... 80%  127M 0s86100K .......... .......... .......... .......... .......... 80%  156M 0s86150K .......... .......... .......... .......... .......... 80%  134M 0s86200K .......... .......... .......... .......... .......... 80%  133M 0s86250K .......... .......... .......... .......... .......... 80%  128M 0s86300K .......... .......... .......... .......... .......... 80%  133M 0s86350K .......... .......... .......... .......... .......... 80%  120M 0s86400K .......... .......... .......... .......... .......... 80%  110M 0s86450K .......... .......... .......... .......... .......... 80%  144M 0s86500K .......... .......... .......... .......... .......... 80%  134M 0s86550K .......... .......... .......... .......... .......... 80%  127M 0s86600K .......... .......... .......... .......... .......... 80%  133M 0s86650K .......... .......... .......... .......... .......... 80%  181M 0s86700K .......... .......... .......... .......... .......... 80%  164M 0s86750K .......... .......... .......... .......... .......... 81% 94.9M 0s86800K .......... .......... .......... .......... .......... 81%  164M 0s86850K .......... .......... .......... .......... .......... 81%  149M 0s86900K .......... .......... .......... .......... .......... 81%  129M 0s86950K .......... .......... .......... .......... .......... 81%  117M 0s87000K .......... .......... .......... .......... .......... 81%  162M 0s87050K .......... .......... .......... .......... .......... 81%  141M 0s87100K .......... .......... .......... .......... .......... 81%  139M 0s87150K .......... .......... .......... .......... .......... 81%  118M 0s87200K .......... .......... .......... .......... .......... 81%  110M 0s87250K .......... .......... .......... .......... .......... 81%  138M 0s87300K .......... .......... .......... .......... .......... 81%  148M 0s87350K .......... .......... .......... .......... .......... 81%  131M 0s87400K .......... .......... .......... .......... .......... 81%  143M 0s87450K .......... .......... .......... .......... .......... 81%  179M 0s87500K .......... .......... .......... .......... .......... 81%  136M 0s87550K .......... .......... .......... .......... .......... 81%  102M 0s87600K .......... .......... .......... .......... .......... 81%  149M 0s87650K .......... .......... .......... .......... .......... 81%  147M 0s87700K .......... .......... .......... .......... .......... 81%  144M 0s87750K .......... .......... .......... .......... .......... 81%  118M 0s87800K .......... .......... .......... .......... .......... 82%  163M 0s87850K .......... .......... .......... .......... .......... 82%  131M 0s87900K .......... .......... .......... .......... .......... 82%  139M 0s87950K .......... .......... .......... .......... .......... 82%  103M 0s88000K .......... .......... .......... .......... .......... 82%  184M 0s88050K .......... .......... .......... .......... .......... 82%  134M 0s88100K .......... .......... .......... .......... .......... 82%  183M 0s88150K .......... .......... .......... .......... .......... 82%  137M 0s88200K .......... .......... .......... .......... .......... 82%  124M 0s88250K .......... .......... .......... .......... .......... 82%  151M 0s88300K .......... .......... .......... .......... .......... 82%  183M 0s88350K .......... .......... .......... .......... .......... 82%  141M 0s88400K .......... .......... .......... .......... .......... 82%  199M 0s88450K .......... .......... .......... .......... .......... 82%  133M 0s88500K .......... .......... .......... .......... .......... 82%  178M 0s88550K .......... .......... .......... .......... .......... 82%  156M 0s88600K .......... .......... .......... .......... .......... 82%  146M 0s88650K .......... .......... .......... .......... .......... 82%  139M 0s88700K .......... .......... .......... .......... .......... 82%  150M 0s88750K .......... .......... .......... .......... .......... 82%  134M 0s88800K .......... .......... .......... .......... .......... 82%  145M 0s88850K .......... .......... .......... .......... .......... 83%  148M 0s88900K .......... .......... .......... .......... .......... 83%  185M 0s88950K .......... .......... .......... .......... .......... 83%  153M 0s89000K .......... .......... .......... .......... .......... 83%  144M 0s89050K .......... .......... .......... .......... .......... 83%  133M 0s89100K .......... .......... .......... .......... .......... 83%  165M 0s89150K .......... .......... .......... .......... .......... 83%  106M 0s89200K .......... .......... .......... .......... .......... 83%  125M 0s89250K .......... .......... .......... .......... .......... 83%  137M 0s89300K .......... .......... .......... .......... .......... 83%  170M 0s89350K .......... .......... .......... .......... .......... 83%  155M 0s89400K .......... .......... .......... .......... .......... 83%  145M 0s89450K .......... .......... .......... .......... .......... 83%  121M 0s89500K .......... .......... .......... .......... .......... 83%  156M 0s89550K .......... .......... .......... .......... .......... 83%  107M 0s89600K .......... .......... .......... .......... .......... 83%  138M 0s89650K .......... .......... .......... .......... .......... 83%  167M 0s89700K .......... .......... .......... .......... .......... 83%  175M 0s89750K .......... .......... .......... .......... .......... 83%  123M 0s89800K .......... .......... .......... .......... .......... 83%  157M 0s89850K .......... .......... .......... .......... .......... 83%  129M 0s89900K .......... .......... .......... .......... .......... 83%  127M 0s89950K .......... .......... .......... .......... .......... 84%  119M 0s90000K .......... .......... .......... .......... .......... 84%  137M 0s90050K .......... .......... .......... .......... .......... 84%  131M 0s90100K .......... .......... .......... .......... .......... 84%  176M 0s90150K .......... .......... .......... .......... .......... 84%  127M 0s90200K .......... .......... .......... .......... .......... 84%  123M 0s90250K .......... .......... .......... .......... .......... 84%  138M 0s90300K .......... .......... .......... .......... .......... 84%  163M 0s90350K .......... .......... .......... .......... .......... 84%  134M 0s90400K .......... .......... .......... .......... .......... 84%  132M 0s90450K .......... .......... .......... .......... .......... 84%  138M 0s90500K .......... .......... .......... .......... .......... 84%  148M 0s90550K .......... .......... .......... .......... .......... 84%  127M 0s90600K .......... .......... .......... .......... .......... 84%  139M 0s90650K .......... .......... .......... .......... .......... 84%  121M 0s90700K .......... .......... .......... .......... .......... 84%  135M 0s90750K .......... .......... .......... .......... .......... 84%  111M 0s90800K .......... .......... .......... .......... .......... 84%  184M 0s90850K .......... .......... .......... .......... .......... 84%  139M 0s90900K .......... .......... .......... .......... .......... 84%  132M 0s90950K .......... .......... .......... .......... .......... 84%  115M 0s91000K .......... .......... .......... .......... .......... 85%  135M 0s91050K .......... .......... .......... .......... .......... 85%  148M 0s91100K .......... .......... .......... .......... .......... 85%  131M 0s91150K .......... .......... .......... .......... .......... 85%  118M 0s91200K .......... .......... .......... .......... .......... 85%  172M 0s91250K .......... .......... .......... .......... .......... 85%  144M 0s91300K .......... .......... .......... .......... .......... 85%  176M 0s91350K .......... .......... .......... .......... .......... 85%  127M 0s91400K .......... .......... .......... .......... .......... 85%  156M 0s91450K .......... .......... .......... .......... .......... 85%  145M 0s91500K .......... .......... .......... .......... .......... 85%  111M 0s91550K .......... .......... .......... .......... .......... 85%  132M 0s91600K .......... .......... .......... .......... .......... 85%  152M 0s91650K .......... .......... .......... .......... .......... 85%  149M 0s91700K .......... .......... .......... .......... .......... 85%  139M 0s91750K .......... .......... .......... .......... .......... 85%  132M 0s91800K .......... .......... .......... .......... .......... 85%  167M 0s91850K .......... .......... .......... .......... .......... 85%  148M 0s91900K .......... .......... .......... .......... .......... 85%  165M 0s91950K .......... .......... .......... .......... .......... 85%  130M 0s92000K .......... .......... .......... .......... .......... 85%  153M 0s92050K .......... .......... .......... .......... .......... 85%  145M 0s92100K .......... .......... .......... .......... .......... 86%  157M 0s92150K .......... .......... .......... .......... .......... 86%  166M 0s92200K .......... .......... .......... .......... .......... 86%  141M 0s92250K .......... .......... .......... .......... .......... 86%  180M 0s92300K .......... .......... .......... .......... .......... 86%  126M 0s92350K .......... .......... .......... .......... .......... 86%  118M 0s92400K .......... .......... .......... .......... .......... 86%  130M 0s92450K .......... .......... .......... .......... .......... 86%  145M 0s92500K .......... .......... .......... .......... .......... 86%  129M 0s92550K .......... .......... .......... .......... .......... 86%  133M 0s92600K .......... .......... .......... .......... .......... 86%  131M 0s92650K .......... .......... .......... .......... .......... 86%  128M 0s92700K .......... .......... .......... .......... .......... 86%  154M 0s92750K .......... .......... .......... .......... .......... 86%  107M 0s92800K .......... .......... .......... .......... .......... 86%  141M 0s92850K .......... .......... .......... .......... .......... 86%  106M 0s92900K .......... .......... .......... .......... .......... 86%  103M 0s92950K .......... .......... .......... .......... .......... 86%  112M 0s93000K .......... .......... .......... .......... .......... 86%  104M 0s93050K .......... .......... .......... .......... .......... 86%  106M 0s93100K .......... .......... .......... .......... .......... 86%  118M 0s93150K .......... .......... .......... .......... .......... 87% 82.5M 0s93200K .......... .......... .......... .......... .......... 87%  118M 0s93250K .......... .......... .......... .......... .......... 87% 91.9M 0s93300K .......... .......... .......... .......... .......... 87% 98.8M 0s93350K .......... .......... .......... .......... .......... 87% 99.7M 0s93400K .......... .......... .......... .......... .......... 87%  121M 0s93450K .......... .......... .......... .......... .......... 87%  104M 0s93500K .......... .......... .......... .......... .......... 87%  108M 0s93550K .......... .......... .......... .......... .......... 87% 67.6M 0s93600K .......... .......... .......... .......... .......... 87%  110M 0s93650K .......... .......... .......... .......... .......... 87% 87.8M 0s93700K .......... .......... .......... .......... .......... 87%  117M 0s93750K .......... .......... .......... .......... .......... 87% 88.4M 0s93800K .......... .......... .......... .......... .......... 87% 90.0M 0s93850K .......... .......... .......... .......... .......... 87% 83.6M 0s93900K .......... .......... .......... .......... .......... 87% 82.3M 0s93950K .......... .......... .......... .......... .......... 87% 67.2M 0s94000K .......... .......... .......... .......... .......... 87% 99.7M 0s94050K .......... .......... .......... .......... .......... 87%  108M 0s94100K .......... .......... .......... .......... .......... 87%  103M 0s94150K .......... .......... .......... .......... .......... 87% 81.8M 0s94200K .......... .......... .......... .......... .......... 87%  103M 0s94250K .......... .......... .......... .......... .......... 88%  112M 0s94300K .......... .......... .......... .......... .......... 88% 84.5M 0s94350K .......... .......... .......... .......... .......... 88% 90.0M 0s94400K .......... .......... .......... .......... .......... 88%  102M 0s94450K .......... .......... .......... .......... .......... 88% 94.8M 0s94500K .......... .......... .......... .......... .......... 88% 90.1M 0s94550K .......... .......... .......... .......... .......... 88% 88.1M 0s94600K .......... .......... .......... .......... .......... 88% 85.2M 0s94650K .......... .......... .......... .......... .......... 88% 84.6M 0s94700K .......... .......... .......... .......... .......... 88% 94.1M 0s94750K .......... .......... .......... .......... .......... 88% 69.2M 0s94800K .......... .......... .......... .......... .......... 88% 73.2M 0s94850K .......... .......... .......... .......... .......... 88% 95.2M 0s94900K .......... .......... .......... .......... .......... 88% 93.0M 0s94950K .......... .......... .......... .......... .......... 88% 91.2M 0s95000K .......... .......... .......... .......... .......... 88% 85.5M 0s95050K .......... .......... .......... .......... .......... 88% 82.1M 0s95100K .......... .......... .......... .......... .......... 88% 86.6M 0s95150K .......... .......... .......... .......... .......... 88%  103M 0s95200K .......... .......... .......... .......... .......... 88%  109M 0s95250K .......... .......... .......... .......... .......... 88% 97.0M 0s95300K .......... .......... .......... .......... .......... 89% 96.7M 0s95350K .......... .......... .......... .......... .......... 89% 88.7M 0s95400K .......... .......... .......... .......... .......... 89% 76.1M 0s95450K .......... .......... .......... .......... .......... 89%  102M 0s95500K .......... .......... .......... .......... .......... 89% 93.4M 0s95550K .......... .......... .......... .......... .......... 89% 93.6M 0s95600K .......... .......... .......... .......... .......... 89%  110M 0s95650K .......... .......... .......... .......... .......... 89%  110M 0s95700K .......... .......... .......... .......... .......... 89% 92.2M 0s95750K .......... .......... .......... .......... .......... 89%  111M 0s95800K .......... .......... .......... .......... .......... 89% 83.9M 0s95850K .......... .......... .......... .......... .......... 89% 84.5M 0s95900K .......... .......... .......... .......... .......... 89% 83.7M 0s95950K .......... .......... .......... .......... .......... 89% 82.0M 0s96000K .......... .......... .......... .......... .......... 89%  102M 0s96050K .......... .......... .......... .......... .......... 89%  118M 0s96100K .......... .......... .......... .......... .......... 89% 99.7M 0s96150K .......... .......... .......... .......... .......... 89% 85.1M 0s96200K .......... .......... .......... .......... .......... 89% 87.1M 0s96250K .......... .......... .......... .......... .......... 89% 87.8M 0s96300K .......... .......... .......... .......... .......... 89% 77.6M 0s96350K .......... .......... .......... .......... .......... 90% 84.6M 0s96400K .......... .......... .......... .......... .......... 90%  106M 0s96450K .......... .......... .......... .......... .......... 90% 85.2M 0s96500K .......... .......... .......... .......... .......... 90% 84.2M 0s96550K .......... .......... .......... .......... .......... 90% 87.7M 0s96600K .......... .......... .......... .......... .......... 90% 82.6M 0s96650K .......... .......... .......... .......... .......... 90%  111M 0s96700K .......... .......... .......... .......... .......... 90%  114M 0s96750K .......... .......... .......... .......... .......... 90% 98.8M 0s96800K .......... .......... .......... .......... .......... 90%  112M 0s96850K .......... .......... .......... .......... .......... 90% 98.0M 0s96900K .......... .......... .......... .......... .......... 90%  102M 0s96950K .......... .......... .......... .......... .......... 90%  126M 0s97000K .......... .......... .......... .......... .......... 90%  143M 0s97050K .......... .......... .......... .......... .......... 90%  123M 0s97100K .......... .......... .......... .......... .......... 90%  123M 0s97150K .......... .......... .......... .......... .......... 90%  107M 0s97200K .......... .......... .......... .......... .......... 90%  167M 0s97250K .......... .......... .......... .......... .......... 90%  141M 0s97300K .......... .......... .......... .......... .......... 90%  132M 0s97350K .......... .......... .......... .......... .......... 90%  142M 0s97400K .......... .......... .......... .......... .......... 90%  152M 0s97450K .......... .......... .......... .......... .......... 91%  129M 0s97500K .......... .......... .......... .......... .......... 91%  148M 0s97550K .......... .......... .......... .......... .......... 91%  116M 0s97600K .......... .......... .......... .......... .......... 91%  150M 0s97650K .......... .......... .......... .......... .......... 91%  143M 0s97700K .......... .......... .......... .......... .......... 91%  129M 0s97750K .......... .......... .......... .......... .......... 91%  117M 0s97800K .......... .......... .......... .......... .......... 91%  148M 0s97850K .......... .......... .......... .......... .......... 91%  161M 0s97900K .......... .......... .......... .......... .......... 91%  120M 0s97950K .......... .......... .......... .......... .......... 91%  125M 0s98000K .......... .......... .......... .......... .......... 91%  134M 0s98050K .......... .......... .......... .......... .......... 91%  139M 0s98100K .......... .......... .......... .......... .......... 91%  136M 0s98150K .......... .......... .......... .......... .......... 91%  127M 0s98200K .......... .......... .......... .......... .......... 91%  137M 0s98250K .......... .......... .......... .......... .......... 91% 92.4M 0s98300K .......... .......... .......... .......... .......... 91% 88.5M 0s98350K .......... .......... .......... .......... .......... 91% 67.5M 0s98400K .......... .......... .......... .......... .......... 91% 99.0M 0s98450K .......... .......... .......... .......... .......... 91%  133M 0s98500K .......... .......... .......... .......... .......... 92% 77.5M 0s98550K .......... .......... .......... .......... .......... 92%  123M 0s98600K .......... .......... .......... .......... .......... 92% 99.3M 0s98650K .......... .......... .......... .......... .......... 92% 98.2M 0s98700K .......... .......... .......... .......... .......... 92%  164M 0s98750K .......... .......... .......... .......... .......... 92% 77.4M 0s98800K .......... .......... .......... .......... .......... 92%  120M 0s98850K .......... .......... .......... .......... .......... 92% 99.4M 0s98900K .......... .......... .......... .......... .......... 92% 95.2M 0s98950K .......... .......... .......... .......... .......... 92%  149M 0s99000K .......... .......... .......... .......... .......... 92% 90.4M 0s99050K .......... .......... .......... .......... .......... 92%  101M 0s99100K .......... .......... .......... .......... .......... 92%  134M 0s99150K .......... .......... .......... .......... .......... 92% 74.9M 0s99200K .......... .......... .......... .......... .......... 92%  159M 0s99250K .......... .......... .......... .......... .......... 92% 96.9M 0s99300K .......... .......... .......... .......... .......... 92% 83.2M 0s99350K .......... .......... .......... .......... .......... 92%  123M 0s99400K .......... .......... .......... .......... .......... 92% 90.7M 0s99450K .......... .......... .......... .......... .......... 92%  154M 0s99500K .......... .......... .......... .......... .......... 92% 95.5M 0s99550K .......... .......... .......... .......... .......... 92% 82.7M 0s99600K .......... .......... .......... .......... .......... 93%  136M 0s99650K .......... .......... .......... .......... .......... 93% 82.9M 0s99700K .......... .......... .......... .......... .......... 93%  109M 0s99750K .......... .......... .......... .......... .......... 93% 93.3M 0s99800K .......... .......... .......... .......... .......... 93% 79.0M 0s99850K .......... .......... .......... .......... .......... 93%  103M 0s99900K .......... .......... .......... .......... .......... 93% 87.6M 0s99950K .......... .......... .......... .......... .......... 93% 95.5M 0s100000K .......... .......... .......... .......... .......... 93% 96.3M 0s100050K .......... .......... .......... .......... .......... 93%  102M 0s100100K .......... .......... .......... .......... .......... 93%  133M 0s100150K .......... .......... .......... .......... .......... 93% 73.1M 0s100200K .......... .......... .......... .......... .......... 93%  162M 0s100250K .......... .......... .......... .......... .......... 93% 95.4M 0s100300K .......... .......... .......... .......... .......... 93%  104M 0s100350K .......... .......... .......... .......... .......... 93%  122M 0s100400K .......... .......... .......... .......... .......... 93% 79.3M 0s100450K .......... .......... .......... .......... .......... 93%  159M 0s100500K .......... .......... .......... .......... .......... 93%  107M 0s100550K .......... .......... .......... .......... .......... 93% 82.3M 0s100600K .......... .......... .......... .......... .......... 93%  164M 0s100650K .......... .......... .......... .......... .......... 94% 79.9M 0s100700K .......... .......... .......... .......... .......... 94%  123M 0s100750K .......... .......... .......... .......... .......... 94%  122M 0s100800K .......... .......... .......... .......... .......... 94% 79.3M 0s100850K .......... .......... .......... .......... .......... 94%  148M 0s100900K .......... .......... .......... .......... .......... 94% 95.7M 0s100950K .......... .......... .......... .......... .......... 94% 86.9M 0s101000K .......... .......... .......... .......... .......... 94%  120M 0s101050K .......... .......... .......... .......... .......... 94% 77.7M 0s101100K .......... .......... .......... .......... .......... 94%  146M 0s101150K .......... .......... .......... .......... .......... 94% 69.1M 0s101200K .......... .......... .......... .......... .......... 94%  117M 0s101250K .......... .......... .......... .......... .......... 94%  108M 0s101300K .......... .......... .......... .......... .......... 94% 82.6M 0s101350K .......... .......... .......... .......... .......... 94%  130M 0s101400K .......... .......... .......... .......... .......... 94% 83.1M 0s101450K .......... .......... .......... .......... .......... 94%  132M 0s101500K .......... .......... .......... .......... .......... 94%  131M 0s101550K .......... .......... .......... .......... .......... 94% 70.0M 0s101600K .......... .......... .......... .......... .......... 94%  138M 0s101650K .......... .......... .......... .......... .......... 94% 92.4M 0s101700K .......... .......... .......... .......... .......... 95%  117M 0s101750K .......... .......... .......... .......... .......... 95% 86.8M 0s101800K .......... .......... .......... .......... .......... 95% 91.0M 0s101850K .......... .......... .......... .......... .......... 95%  134M 0s101900K .......... .......... .......... .......... .......... 95% 82.9M 0s101950K .......... .......... .......... .......... .......... 95%  133M 0s102000K .......... .......... .......... .......... .......... 95% 91.3M 0s102050K .......... .......... .......... .......... .......... 95% 96.0M 0s102100K .......... .......... .......... .......... .......... 95%  145M 0s102150K .......... .......... .......... .......... .......... 95% 70.4M 0s102200K .......... .......... .......... .......... .......... 95%  128M 0s102250K .......... .......... .......... .......... .......... 95% 87.0M 0s102300K .......... .......... .......... .......... .......... 95%  109M 0s102350K .......... .......... .......... .......... .......... 95% 95.9M 0s102400K .......... .......... .......... .......... .......... 95% 94.4M 0s102450K .......... .......... .......... .......... .......... 95%  158M 0s102500K .......... .......... .......... .......... .......... 95% 84.2M 0s102550K .......... .......... .......... .......... .......... 95%  116M 0s102600K .......... .......... .......... .......... .......... 95% 99.5M 0s102650K .......... .......... .......... .......... .......... 95%  103M 0s102700K .......... .......... .......... .......... .......... 95%  163M 0s102750K .......... .......... .......... .......... .......... 95% 70.6M 0s102800K .......... .......... .......... .......... .......... 96%  122M 0s102850K .......... .......... .......... .......... .......... 96%  146M 0s102900K .......... .......... .......... .......... .......... 96% 93.5M 0s102950K .......... .......... .......... .......... .......... 96% 92.9M 0s103000K .......... .......... .......... .......... .......... 96% 89.0M 0s103050K .......... .......... .......... .......... .......... 96% 94.5M 0s103100K .......... .......... .......... .......... .......... 96%  110M 0s103150K .......... .......... .......... .......... .......... 96% 80.4M 0s103200K .......... .......... .......... .......... .......... 96%  137M 0s103250K .......... .......... .......... .......... .......... 96% 76.2M 0s103300K .......... .......... .......... .......... .......... 96%  156M 0s103350K .......... .......... .......... .......... .......... 96% 96.6M 0s103400K .......... .......... .......... .......... .......... 96% 87.6M 0s103450K .......... .......... .......... .......... .......... 96%  148M 0s103500K .......... .......... .......... .......... .......... 96%  133M 0s103550K .......... .......... .......... .......... .......... 96% 68.5M 0s103600K .......... .......... .......... .......... .......... 96%  138M 0s103650K .......... .......... .......... .......... .......... 96% 79.3M 0s103700K .......... .......... .......... .......... .......... 96%  164M 0s103750K .......... .......... .......... .......... .......... 96%  105M 0s103800K .......... .......... .......... .......... .......... 96% 96.3M 0s103850K .......... .......... .......... .......... .......... 97%  137M 0s103900K .......... .......... .......... .......... .......... 97% 84.0M 0s103950K .......... .......... .......... .......... .......... 97%  136M 0s104000K .......... .......... .......... .......... .......... 97% 94.4M 0s104050K .......... .......... .......... .......... .......... 97%  106M 0s104100K .......... .......... .......... .......... .......... 97%  150M 0s104150K .......... .......... .......... .......... .......... 97% 79.4M 0s104200K .......... .......... .......... .......... .......... 97%  134M 0s104250K .......... .......... .......... .......... .......... 97%  138M 0s104300K .......... .......... .......... .......... .......... 97% 79.5M 0s104350K .......... .......... .......... .......... .......... 97%  105M 0s104400K .......... .......... .......... .......... .......... 97% 94.5M 0s104450K .......... .......... .......... .......... .......... 97% 89.9M 0s104500K .......... .......... .......... .......... .......... 97%  110M 0s104550K .......... .......... .......... .......... .......... 97%  121M 0s104600K .......... .......... .......... .......... .......... 97%  148M 0s104650K .......... .......... .......... .......... .......... 97%  130M 0s104700K .......... .......... .......... .......... .......... 97%  147M 0s104750K .......... .......... .......... .......... .......... 97%  124M 0s104800K .......... .......... .......... .......... .......... 97%  148M 0s104850K .......... .......... .......... .......... .......... 97%  150M 0s104900K .......... .......... .......... .......... .......... 97%  133M 0s104950K .......... .......... .......... .......... .......... 98%  124M 0s105000K .......... .......... .......... .......... .......... 98%  126M 0s105050K .......... .......... .......... .......... .......... 98%  172M 0s105100K .......... .......... .......... .......... .......... 98%  175M 0s105150K .......... .......... .......... .......... .......... 98%  138M 0s105200K .......... .......... .......... .......... .......... 98%  144M 0s105250K .......... .......... .......... .......... .......... 98%  107M 0s105300K .......... .......... .......... .......... .......... 98%  113M 0s105350K .......... .......... .......... .......... .......... 98%  105M 0s105400K .......... .......... .......... .......... .......... 98%  111M 0s105450K .......... .......... .......... .......... .......... 98%  104M 0s105500K .......... .......... .......... .......... .......... 98% 92.6M 0s105550K .......... .......... .......... .......... .......... 98%  102M 0s105600K .......... .......... .......... .......... .......... 98%  110M 0s105650K .......... .......... .......... .......... .......... 98%  111M 0s105700K .......... .......... .......... .......... .......... 98%  111M 0s105750K .......... .......... .......... .......... .......... 98%  103M 0s105800K .......... .......... .......... .......... .......... 98%  114M 0s105850K .......... .......... .......... .......... .......... 98%  103M 0s105900K .......... .......... .......... .......... .......... 98%  107M 0s105950K .......... .......... .......... .......... .......... 98% 91.2M 0s106000K .......... .......... .......... .......... .......... 99%  109M 0s106050K .......... .......... .......... .......... .......... 99%  113M 0s106100K .......... .......... .......... .......... .......... 99%  107M 0s106150K .......... .......... .......... .......... .......... 99%  107M 0s106200K .......... .......... .......... .......... .......... 99% 92.1M 0s106250K .......... .......... .......... .......... .......... 99%  109M 0s106300K .......... .......... .......... .......... .......... 99%  141M 0s106350K .......... .......... .......... .......... .......... 99%  135M 0s106400K .......... .......... .......... .......... .......... 99%  159M 0s106450K .......... .......... .......... .......... .......... 99%  164M 0s106500K .......... .......... .......... .......... .......... 99%  164M 0s106550K .......... .......... .......... .......... .......... 99%  149M 0s106600K .......... .......... .......... .......... .......... 99%  163M 0s106650K .......... .......... .......... .......... .......... 99%  141M 0s106700K .......... .......... .......... .......... .......... 99%  164M 0s106750K .......... .......... .......... .......... .......... 99%  134M 0s106800K .......... .......... .......... .......... .......... 99%  148M 0s106850K .......... .......... .......... .......... .......... 99%  164M 0s106900K .......... .......... .......... .......... .......... 99%  166M 0s106950K .......... .......... .......... .......... .......... 99%  151M 0s107000K .......... .......... .......... .......... .......... 99%  165M 0s107050K .......... .......... .......... .......... .......... 99%  156M 0s107100K ..                                                    100% 4921G=1.0s2022-01-13 02:55:51 (104 MB/s) - ‘/tmp/cmdline-tools.zip’ saved [109673042/109673042]+ echo '124f2d5115eee365df6cf3228ffbca6fc3911d16f8025bebd5b1c6e2fcfa7faf /tmp/cmdline-tools.zip'+ sha256sum -c -/tmp/cmdline-tools.zip: OK+ unzip -q -o /tmp/cmdline-tools.zip -d /tmp/cmdline-tools+ rm /tmp/cmdline-tools.zip+ mkdir -p /opt/android-sdk/cmdline-tools/tools+ mv /tmp/cmdline-tools/cmdline-tools/bin /tmp/cmdline-tools/cmdline-tools/lib /tmp/cmdline-tools/cmdline-tools/NOTICE.txt /tmp/cmdline-tools/cmdline-tools/source.properties /opt/android-sdk/cmdline-tools/tools+ export PATH=/opt/android-sdk/cmdline-tools/tools/bin:/opt/android-sdk/ndk/21.4.7075529:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:/opt/gradle/bin+ PATH=/opt/android-sdk/cmdline-tools/tools/bin:/opt/android-sdk/ndk/21.4.7075529:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/android-sdk/tools:/opt/android-sdk/platform-tools:/opt/gradle/bin+ yes+ sdkmanager --licensesLoading local repository...                                                     
[=========                              ] 25% Loading local repository...       
[=========                              ] 25% Fetch remote repository...        
[==========                             ] 26% Fetch remote repository...        
[============                           ] 32% Fetch remote repository...        
[=============                          ] 33% Fetch remote repository...        
[=============                          ] 35% Fetch remote repository...        
[==============                         ] 36% Fetch remote repository...        
[==============                         ] 38% Fetch remote repository...        
[===============                        ] 39% Fetch remote repository...        
[================                       ] 41% Fetch remote repository...        
[================                       ] 42% Fetch remote repository...        
[=================                      ] 44% Fetch remote repository...        
[==================                     ] 45% Fetch remote repository...        
[==================                     ] 47% Fetch remote repository...        
[===================                    ] 48% Fetch remote repository...        
[===================                    ] 50% Fetch remote repository...        
[====================                   ] 51% Fetch remote repository...        
[=====================                  ] 53% Fetch remote repository...        
[=====================                  ] 54% Fetch remote repository...        
[======================                 ] 56% Fetch remote repository...        
[======================                 ] 57% Fetch remote repository...        
[=======================                ] 59% Fetch remote repository...        
[========================               ] 60% Fetch remote repository...        
[========================               ] 62% Fetch remote repository...        
[=========================              ] 63% Fetch remote repository...        
[=========================              ] 65% Fetch remote repository...        
[==========================             ] 66% Fetch remote repository...        
[===========================            ] 68% Fetch remote repository...        
[===========================            ] 69% Fetch remote repository...        
[============================           ] 71% Fetch remote repository...        
[============================           ] 72% Fetch remote repository...        
[=============================          ] 74% Fetch remote repository...        
[=============================          ] 75% Fetch remote repository...        
[=============================          ] 75% Computing updates...              
[=======================================] 100% Computing updates...             
4 of 6 SDK package licenses not accepted.Review licenses that have not been accepted (y/N)?1/4: License android-googletv-license:---------------------------------------Terms and ConditionsThis is the Google TV Add-on for the Android Software Development Kit License Agreement.1. Introduction1.1 The Google TV Add-on for the Android Software Development Kit (referred to in this License Agreement as the "Google TV Add-on" and specifically including the Android system files, packaged APIs, and Google APIs add-ons) is licensed to you subject to the terms of this License Agreement. This License Agreement forms a legally binding contract between you and Google in relation to your use of the Google TV Add-on.1.2 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.2. Accepting this License Agreement2.1 In order to use the Google TV Add-on, you must first agree to this License Agreement. You may not use the Google TV Add-on if you do not accept this License Agreement.2.2 You can accept this License Agreement by:(A) clicking to accept or agree to this License Agreement, where this option is made available to you; or(B) by actually using the Google TV Add-on. In this case, you agree that use of the Google TV Add-on constitutes acceptance of the License Agreement from that point onwards.2.3 You may not use the Google TV Add-on and may not accept the Licensing Agreement if you are a person barred from receiving the Google TV Add-on under the laws of the United States or other countries including the country in which you are resident or from which you use the Google TV Add-on.2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to this License Agreement. If you do not have the requisite authority, you may not accept the Licensing Agreement or use the Google TV Add-on on behalf of your employer or other entity.3. Google TV Add-on License from Google3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, royalty-free, non- assignable and non-exclusive license to use the Google TV Add-on solely to develop applications to run on the Google TV platform.3.2 You agree that Google or third parties own all legal right, title and interest in and to the Google TV Add-on, including any Intellectual Property Rights that subsist in the Google TV Add-on. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.3.3 Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Google TV Add-on or any part of the Google TV Add-on. Except to the extent required by applicable third party licenses, you may not load any part of the Google TV Add-on onto a mobile handset, television, or any other hardware device except a personal computer, combine any part of the Google TV Add-on with other software, or distribute any software or device incorporating a part of the Google TV Add-on.3.4 Use, reproduction and distribution of components of the Google TV Add-on licensed under an open source software license are governed solely by the terms of that open source software license and not this License Agreement.3.5 You agree that the form and nature of the Google TV Add-on that Google provides may change without prior notice to you and that future versions of the Google TV Add-on may be incompatible with applications developed on previous versions of the Google TV Add-on. You agree that Google may stop (permanently or temporarily) providing the Google TV Add-on (or any features within the Google TV Add-on) to you or to users generally at Google's sole discretion, without prior notice to you.3.6 Nothing in this License Agreement gives you a right to use any of Google's or it’s licensors’ trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.3.7 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Google TV Add-on.4. Use of the Google TV Add-on by You4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under this License Agreement in or to any software applications that you develop using the Google TV Add-on, including any intellectual property rights that subsist in those applications.4.2 You agree to use the Google TV Add-on and write applications only for purposes that are permitted by (a) this License Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).4.3 You agree that if you use the Google TV Add-on to develop applications for general public users, you will protect the privacy and legal rights of those users. If the users provide you with user names, passwords, or other login information or personal information, your must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If the user provides your application with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, the user has given you explicit permission to do so.4.4 You agree that you will not engage in any activity with the Google TV Add-on, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any third party including, but not limited to, Google, Multichannel Video Program Distributors or any mobile communications carrier.4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through the Google TV platform and/or applications for the Google TV platform, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under this License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.5. Your Developer Credentials5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.6. Privacy and Information6.1 In order to continually innovate and improve the Google TV Add-on, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the Google TV Add-on are being used and how they are being used. Before any of this information is collected, the Google TV Add-on will notify you and seek your consent. If you withhold consent, the information will not be collected.6.2 The data collected is examined in the aggregate to improve the Google TV Add-on and is maintained in accordance with Google's Privacy Policy.7. Third Party Applications for the Google TV Platform7.1 If you use the Google TV Add-on to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party. In that case, this License Agreement does not affect your legal relationship with these third parties.8. Using Google TV APIs8.1 If you use any Google TV API to retrieve data from Google, you acknowledge that the data (“Google TV API Content”) may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service. Some portions of the Google TV API Content are licensed to Google by third parties, including but not limited to Tribune Media Services8.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.8.3 Except as explicitly permitted in Section 3 (Google TV Add-on License from Google), you must:(a) not modify nor format the Google TV API Content except to the extent reasonably and technically necessary to optimize the display such Google TV API Content in your application;(b) not edit the Google TV API Content in a manner that renders the Google TV API Content inaccurate of alters its inherent meaning (provided that displaying excerpts will not violate the foregoing); or(c) not create any commercial audience measurement tool or service using the Google TV API Content9. Terminating this License Agreement9.1 This License Agreement will continue to apply until terminated by either you or Google as set out below.9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the Google TV Add-on and any relevant developer credentials.9.3 Google may at any time, terminate this License Agreement with you if:(A) you have breached any provision of this License Agreement; or(B) Google is required to do so by law; or(C) the partner with whom Google offered certain parts of Google TV Add-on (such as APIs) to you has terminated its relationship with Google or ceased to offer certain parts of the Google TV Add-on to you; or(D) Google decides to no longer providing the Google TV Add-on or certain parts of the Google TV Add-on to users in the country in which you are resident or from which you use the service, or the provision of the Google TV Add-on or certain Google TV Add-on services to you by Google is, in Google's sole discretion, no longer commercially viable.9.4 When this License Agreement comes to an end, all of the legal rights, obligations and liabilities that you and Google have benefited from, been subject to (or which have accrued over time whilst this License Agreement has been in force) or which are expressed to continue indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall continue to apply to such rights, obligations and liabilities indefinitely.10. DISCLAIMER OF WARRANTIES10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE GOOGLE TV ADD-ON IS AT YOUR SOLE RISK AND THAT THE GOOGLE TV ADD-ON IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.10.2 YOUR USE OF THE GOOGLE TV ADD-ON AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE GOOGLE TV ADD-ON IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.11. LIMITATION OF LIABILITY11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.12. Indemnification12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the Google TV Add-on, (b) any application you develop on the Google TV Add-on that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with this License Agreement.13. Changes to the License Agreement13.1 Google may make changes to the License Agreement as it distributes new versions of the Google TV Add-on.14. General Legal Terms14.1 This License Agreement constitute the whole legal agreement between you and Google and govern your use of the Google TV Add-on (excluding any services which Google may provide to you under a separate written agreement), and completely replace any prior agreements between you and Google in relation to the Google TV Add-on.14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in this License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of this License Agreement is invalid, then that provision will be removed from this License Agreement without affecting the rest of this License Agreement. The remaining provisions of this License Agreement will continue to be valid and enforceable.14.4 You acknowledge and agree that Google’s API data licensors and each member of the group of companies of which Google is the parent shall be third party beneficiaries to this License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to this License Agreement.14.5 EXPORT RESTRICTIONS. THE GOOGLE TV ADD-ON IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE GOOGLE TV ADD-ON. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.14.6 The rights granted in this License Agreement may not be assigned or transferred by either you or Google without the prior written approval of the other party. Neither you nor Google shall be permitted to delegate their responsibilities or obligations under this License Agreement without the prior written approval of the other party.14.7 This License Agreement, and your relationship with Google under this License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from this License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.August 15, 2011---------------------------------------Accept? (y/N):2/4: License android-sdk-arm-dbt-license:---------------------------------------Terms and ConditionsThis is the Android Software Development Kit License Agreement1. Introduction1.1 The Android Software Development Kit (referred to in the License Agreement as the "SDK" and specifically including the Android system files, packaged APIs, and Google APIs add-ons) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the SDK.1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.1.3 A "compatible implementation" means any Android device that (i) complies with the Android Compatibility Definition document, which can be found at the Android compatibility website (http://source.android.com/compatibility) and which may be updated from time to time; and (ii) successfully passes the Android Compatibility Test Suite (CTS).1.4 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.2. Accepting the License Agreement2.1 In order to use the SDK, you must first agree to the License Agreement. You may not use the SDK if you do not accept the License Agreement.2.2 By clicking to accept, you hereby agree to the terms of the License Agreement.2.3 You may not use the SDK and may not accept the License Agreement if you are a person barred from receiving the SDK under the laws of the United States or other countries, including the country in which you are resident or from which you use the SDK.2.4 If you are agreeing to be bound by the License Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the SDK on behalf of your employer or other entity.3. SDK License from Google3.1 Subject to the terms of the License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable, non-exclusive, and non-sublicensable license to use the SDK solely to develop applications for compatible implementations of Android.3.2 You may not use this SDK to develop applications for other platforms (including non-compatible implementations of Android) or to develop another SDK. You are of course free to develop applications for other platforms, including non-compatible implementations of Android, provided that this SDK is not used for that purpose.3.3 You agree that Google or third parties own all legal right, title and interest in and to the SDK, including any Intellectual Property Rights that subsist in the SDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.3.4 You may not use the SDK for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the SDK or any part of the SDK.3.5 Use, reproduction and distribution of components of the SDK licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement.3.6 You agree that the form and nature of the SDK that Google provides may change without prior notice to you and that future versions of the SDK may be incompatible with applications developed on previous versions of the SDK. You agree that Google may stop (permanently or temporarily) providing the SDK (or any features within the SDK) to you or to users generally at Google's sole discretion, without prior notice to you.3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the SDK.4. Use of the SDK by You4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the SDK, including any intellectual property rights that subsist in those applications.4.2 You agree to use the SDK and write applications only for purposes that are permitted by (a) the License Agreement and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).4.3 You agree that if you use the SDK to develop applications for general public users, you will protect the privacy and legal rights of those users. If the users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If the user provides your application with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, the user has given you permission to do so.4.4 You agree that you will not engage in any activity with the SDK, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any third party including, but not limited to, Google or any mobile communications carrier.4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.4.7 This software enables the execution of intellectual property owned by Arm Limited. You agree that your use of the software, that allows execution of ARM Instruction Set Architecture (“ISA”) compliant executables for application development and debug only on x86 desktop, laptop, customer on-premise servers, and customer-procured cloud-based environments.5. Your Developer Credentials5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.6. Privacy and Information6.1 In order to continually innovate and improve the SDK, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the SDK are being used and how they are being used. Before any of this information is collected, the SDK will notify you and seek your consent. If you withhold consent, the information will not be collected.6.2 The data collected is examined in the aggregate to improve the SDK and is maintained in accordance with Google's Privacy Policy.7. Third Party Applications7.1 If you use the SDK to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party. In that case, the License Agreement does not affect your legal relationship with these third parties.8. Using Android APIs8.1 Google Data APIs8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so. If you use the Android Recognition Service API, documented at the following URL: https://developer.android.com/reference/android/speech/RecognitionService, as updated from time to time, you acknowledge that the use of the API is subject to the Data Processing Addendum for Products where Google is a Data Processor, which is located at the following URL: https://privacy.google.com/businesses/gdprprocessorterms/, as updated from time to time. By clicking to accept, you hereby agree to the terms of the Data Processing Addendum for Products where Google is a Data Processor.9. Terminating the License Agreement9.1 The License Agreement will continue to apply until terminated by either you or Google as set out below.9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the SDK and any relevant developer credentials.9.3 Google may at any time, terminate the License Agreement with you if: (A) you have breached any provision of the License Agreement; or (B) Google is required to do so by law; or (C) the partner with whom Google offered certain parts of SDK (such as APIs) to you has terminated its relationship with Google or ceased to offer certain parts of the SDK to you; or (D) Google decides to no longer provide the SDK or certain parts of the SDK to users in the country in which you are resident or from which you use the service, or the provision of the SDK or certain SDK services to you by Google is, in Google's sole discretion, no longer commercially viable.9.4 When the License Agreement comes to an end, all of the legal rights, obligations and liabilities that you and Google have benefited from, been subject to (or which have accrued over time whilst the License Agreement has been in force) or which are expressed to continue indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall continue to apply to such rights, obligations and liabilities indefinitely.10. DISCLAIMER OF WARRANTIES10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE RISK AND THAT THE SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.10.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.11. LIMITATION OF LIABILITY11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.12. Indemnification12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the SDK, (b) any application you develop on the SDK that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with the License Agreement.13. Changes to the License Agreement13.1 Google may make changes to the License Agreement as it distributes new versions of the SDK. When these changes are made, Google will make a new version of the License Agreement available on the website where the SDK is made available.14. General Legal Terms14.1 The License Agreement constitutes the whole legal agreement between you and Google and governs your use of the SDK (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the SDK.14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.14.5 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.14.6 The rights granted in the License Agreement may not be assigned or transferred by either you or Google without the prior written approval of the other party. Neither you nor Google shall be permitted to delegate their responsibilities or obligations under the License Agreement without the prior written approval of the other party.14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.January 16, 2019---------------------------------------Accept? (y/N):3/4: License google-gdk-license:---------------------------------------This is a Developer Preview of the GDK that is subject to change.Terms and ConditionsThis is the Glass Development Kit License Agreement.1. Introduction1.1 The Glass Development Kit (referred to in this License Agreement as the "GDK" and specifically including the Android system files, packaged APIs, and GDK library files, if and when they are made available) is licensed to you subject to the terms of this License Agreement. This License Agreement forms a legally binding contract between you and Google in relation to your use of the GDK.1.2 "Glass" means Glass devices and the Glass software stack for use on Glass devices.1.3 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.1.4 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.2. Accepting this License Agreement2.1 In order to use the GDK, you must first agree to this License Agreement. You may not use the GDK if you do not accept this License Agreement.2.2 By clicking to accept, you hereby agree to the terms of this License Agreement.2.3 You may not use the GDK and may not accept the License Agreement if you are a person barred from receiving the GDK under the laws of the United States or other countries including the country in which you are resident or from which you use the GDK.2.4 If you are agreeing to be bound by this License Agreement on behalf of your employer or other entity, you represent and warrant that you have full legal authority to bind your employer or such entity to this License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the GDK on behalf of your employer or other entity.3. GDK License from Google3.1 Subject to the terms of this License Agreement, Google grants you a limited, worldwide, royalty-free, non-assignable and non-exclusive license to use the GDK solely to develop applications to run on the Glass platform for Glass devices.3.2 You agree that Google or third parties own all legal right, title and interest in and to the GDK, including any Intellectual Property Rights that subsist in the GDK. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.3.3 You may not use the GDK for any purpose not expressly permitted by this License Agreement. Except to the extent required by applicable third party licenses, you may not: (a) copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the GDK or any part of the GDK; or (b) load any part of the GDK onto a mobile handset or wearable computing device or any other hardware device except a Glass device personal computer, combine any part of the GDK with other software, or distribute any software or device incorporating a part of the GDK.3.4 You agree that you will not take any actions that may cause or result in the fragmentation of Glass, including but not limited to distributing, participating in the creation of, or promoting in any way a software development kit derived from the GDK.3.5 Use, reproduction and distribution of components of the GDK licensed under an open source software license are governed solely by the terms of that open source software license and not this License Agreement.3.6 You agree that the form and nature of the GDK that Google provides may change without prior notice to you and that future versions of the GDK may be incompatible with applications developed on previous versions of the GDK. You agree that Google may stop (permanently or temporarily) providing the GDK (or any features within the GDK) to you or to users generally at Google's sole discretion, without prior notice to you.3.7 Nothing in this License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the GDK.3.9 Your use of any Android system files, packaged APIs, or other components of the GDK which are part of the Android Software Development Kit is subject to the terms of the Android Software Development Kit License Agreement located at http://developer.android.com/sdk/terms.html. These terms are hereby incorporated by reference into this License Agreement.4. Use of the GDK by You4.1 Google agrees that it obtains no right, title or interest from you (or your licensors) under this License Agreement in or to any software applications that you develop using the GDK, including any intellectual property rights that subsist in those applications.4.2 You agree to use the GDK and write applications only for purposes that are permitted by (a) this License Agreement, (b) the Glass Platform Developer Policies (located at https://developers.google.com/glass/policies, and hereby incorporated into this License Agreement by reference), and (c) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).4.3 You agree that if you use the GDK to develop applications for general public users, you will protect the privacy and legal rights of those users. If the users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If the user provides your application with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, the user has given you permission to do so.4.4 You agree that you will not engage in any activity with the GDK, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of any third party including, but not limited to, Google.4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Glass and/or applications for Glass, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under this License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.4.7 The GDK is in development, and your testing and feedback are an important part of the development process. By using the GDK, you acknowledge that implementation of some features are still under development and that you should not rely on the GDK, Glass devices, Glass system software, Google Mirror API, or Glass services having the full functionality of a stable release.5. Your Developer Credentials5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.6. Privacy and Information6.1 In order to continually innovate and improve the GDK, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the GDK are being used and how they are being used. Before any of this information is collected, the GDK will notify you and seek your consent. If you withhold consent, the information will not be collected.6.2 The data collected is examined in the aggregate to improve the GDK and is maintained in accordance with Google's Privacy Policy.7. Third Party Applications7.1 If you use the GDK to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party. In that case, this License Agreement does not affect your legal relationship with these third parties.8. Using Google APIs8.1 Google APIs8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.9. Terminating this License Agreement9.1 This License Agreement will continue to apply until terminated by either you or Google as set out below.9.2 If you want to terminate this License Agreement, you may do so by ceasing your use of the GDK and any relevant developer credentials.9.3 Google may at any time, terminate this License Agreement with you if: (A) you have breached any provision of this License Agreement; or (B) Google is required to do so by law; or (C) the partner with whom Google offered certain parts of GDK (such as APIs) to you has terminated its relationship with Google or ceased to offer certain parts of the GDK to you; or (D) Google decides to no longer provide the GDK or certain parts of the GDK to users in the country in which you are resident or from which you use the service, or the provision of the GDK or certain GDK services to you by Google is, in Google's sole discretion, no longer commercially viable.9.4 When this License Agreement comes to an end, all of the legal rights, obligations and liabilities that you and Google have benefited from, been subject to (or which have accrued over time whilst this License Agreement has been in force) or which are expressed to continue indefinitely, shall be unaffected by this cessation, and the provisions of paragraph 14.7 shall continue to apply to such rights, obligations and liabilities indefinitely.10. DISCLAIMER OF WARRANTIES10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE GDK IS AT YOUR SOLE RISK AND THAT THE GDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.10.2 YOUR USE OF THE GDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE GDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE.10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.11. LIMITATION OF LIABILITY11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.12. Indemnification12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys fees) arising out of or accruing from (a) your use of the GDK, (b) any application you develop on the GDK that infringes any copyright, trademark, trade secret, trade dress, patent or other intellectual property right of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you with this License Agreement.13. Changes to the License Agreement13.1 Google may make changes to the License Agreement as it distributes new versions of the GDK. When these changes are made, Google will make a new version of the License Agreement available on the website where the GDK is made available.14. General Legal Terms14.1 This License Agreement constitutes the whole legal agreement between you and Google and governs your use of the GDK (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the GDK.14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in this License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of this License Agreement is invalid, then that provision will be removed from this License Agreement without affecting the rest of this License Agreement. The remaining provisions of this License Agreement will continue to be valid and enforceable.14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to this License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of this License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to this License Agreement.14.5 EXPORT RESTRICTIONS. THE GDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE GDK. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.14.6 The rights granted in this License Agreement may not be assigned or transferred by either you or Google without the prior written approval of the other party. Neither you nor Google shall be permitted to delegate their responsibilities or obligations under this License Agreement without the prior written approval of the other party.14.7 This License Agreement, and your relationship with Google under this License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from this License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.November 19, 2013---------------------------------------Accept? (y/N):4/4: License mips-android-sysimage-license:---------------------------------------MIPS Technologies, Inc. (“MIPS”) Internal Evaluation License Agreement for MIPS Android™ System Images for Android Software Development Kit (SDK): This Internal Evaluation License Agreement (this "Agreement") is entered into by and between MIPS and you (as an individual developer or a legal entity -- identified below as “Recipient”). MIPS shall make the Evaluation Software available to Recipient as described in accordance with the terms and conditions set forth below.By clicking on the “Accept” button, downloading, installing, or otherwise using the Evaluation Materials (defined below), you agree to be bound by the terms of this Agreement effective as of the date you click “Accept” (the “Effective Date”), and if doing so on behalf of an entity, you represent that you are authorized to bind the entity to the terms and conditions of this Agreement. If you do not agree to be bound by the terms and conditions of this Agreement, do not download, install, or use the Evaluation Materials.1. DEFINITIONS. These terms shall have the following meanings:1.1 “MIPS” shall mean MIPS Technologies, Inc., a Delaware corporation having a principal place of business at: 955 East Arques Ave., Sunnyvale, CA 940851.2 “Evaluation Software” shall mean MIPS Android™ emulator system images for Android Software Development Kit (SDK), as made available to Recipient.1.3 “Evaluation Materials" means, collectively, the Evaluation Software (in source and/or object code form) and documentation (including, without limitation, any design documents, specifications, reference manuals, and other related materials) related to the Evaluation Software as made available to Recipient.1.4 “Open Source Software” means any software that requires (as a condition of use, modification and/or distribution of such software) that such software or other software incorporated into, derived from or distributed with such software (a) be disclosed or distributed in source code form; or (b) be licensed by the user to third parties for the purpose of making and/or distributing derivative works; or (c) be redistributable at no charge. Open Source Software includes, without limitation, software licensed or distributed under any of the following licenses or distribution models, or licenses or distribution models substantially similar to any of the following: (a) GNU’s General Public License (GPL) or Lesser/Library GPL (LGPL), (b) the Artistic License (e.g., PERL), (c) the Mozilla Public License, (d) the Netscape Public License, (e) the Sun Community Source License (SCSL), (f) the Sun Industry Source License (SISL), (g) the Apache Software license and (h) the Common Public License (CPL).1.5 “Pre-Release Materials” means “alpha” or “beta” designated pre-release features, which may not be fully functional, which MIPS may substantially modify in producing any production version of the Evaluation Materials, and/or which is still under development by MIPS and/or MIPS’ suppliers.2. PURPOSE. MIPS desires to make the Evaluation Materials available to Recipient solely for Recipient's internal evaluation of the Evaluation Software to evaluate the desirability of cooperating with MIPS in developing products that are compatible with the Evaluation Software and/or to advise MIPS as to possible modifications to the Evaluation Software. Recipient may not disclose, distribute, modify (except to facilitate the above-mentioned internal evaluation), or make commercial use of the Evaluation Materials or any modifications of the Evaluation Materials.THE EVALUATION MATERIALS ARE PROVIDED FOR EVALUATION PURPOSES ONLY AND MAY NOT BE MODIFIED (EXCEPT TO FACILITATE THE INTERNAL EVALUATION) OR DISTRIBUTED BY RECIPIENT OR INCORPORATED INTO RECIPIENT’S PRODUCTS OR SOFTWARE. PLEASE CONTACT A MIPS SALES REPRESENTATIVE TO LEARN ABOUT THE AVAILABILITY AND COST OF A COMMERCIAL VERSION OF THE EVALUATION SOFTWARE.3. TITLE. Title to the Evaluation Materials remains with MIPS or its suppliers. Recipient shall not mortgage, pledge or encumber the Evaluation Materials in any way. Recipient shall return all Evaluation Materials, keeping no copies, upon termination or expiration of this Agreement.4. LICENSE. MIPS grants Recipient a royalty-free, personal, nontransferable, nonexclusive license under its copyrights to use the Evaluation Software only for the purposes described in paragraph 2 above and only for a period beginning on the Effective Date and extending to the first anniversary of the Effective Date (the “Evaluation Period”). Unless otherwise communicated in writing by MIPS to Recipient, to the extent the Evaluation Software is provided in more than one delivery or release (each, a “Release”) the license grant in this Section 4 and the Evaluation Period shall apply to each Release, in which case the Evaluation Period shall begin on the date that the Release is made generally available and continue to the first anniversary of such date. Recipient may not make modifications to the Evaluation Software. Recipient shall not disassemble, reverse-engineer, or decompile any software that is not provided to Recipient in source code form.EXCEPT AS PROVIDED HEREIN, NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY OTHER MIPS INTELLECTUAL PROPERTY RIGHTS IS GRANTED TO THE RECIPIENT. OTHER THAN AS EXPLICITLY SET FORTH IN PARAGRAPH 2 ABOVE, NO RIGHT TO COPY, TO REPRODUCE, TO MODIFY, OR TO CREATE DERIVATIVE WORKS OF, THE EVALUATION MATERIALS IS GRANTED HEREIN.5. NO OBLIGATION. Recipient shall have no duty to purchase or license any product from MIPS. MIPS and its suppliers shall have no obligation to provide support for, or develop a non-evaluation version of, the Evaluation Software or to license any version of it.6. MODIFICATIONS. This Agreement does not obligate Recipient to provide MIPS with comments or suggestions regarding Evaluation Materials. However, should Recipient provide MIPS with comments or suggestions for the modification, correction, improvement or enhancement of (a) the Evaluation Materials or (b) MIPS products or processes which may embody the Evaluation Materials, then Recipient agrees to grant and hereby grants to MIPS a non-exclusive, irrevocable, worldwide, fully paid-up, royalty-free license, with the right to sublicense MIPS’ licensees and customers, under Recipient’s Intellectual property rights, to use and disclose such comments and suggestions in any manner MIPS chooses and to display, perform, copy, make, have made, use, sell, offer to sell, import, and otherwise dispose of MIPS’ and its sublicensee’s products embodying such comments and suggestions in any manner and via any media MIPS chooses, without reference to the source.7. WARRANTY DISCLAIMER. MIPS AND ITS SUPPLIERS MAKE NO WARRANTIES WITH RESPECT TO EVALUATION MATERIALS, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY IMPLIED WARRANTY OF NONINFRINGEMENT WITH RESPECT TO THIRD PARTY INTELLECTUAL PROPERTY. RECIPIENT ACKNOWLEDGES AND AGREES THAT THE EVALUATION MATERIALS ARE PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND.8. LIMITATION OF LIABILITY. MIPS AND ITS SUPPLIERS SHALL NOT BE LIABLE FOR ANY PROPERTY DAMAGE, PERSONAL INJURY, LOSS OF PROFITS, INTERRUPTION OF BUSINESS OR FOR ANY DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, HOWEVER CAUSED OR ALLEGED, WHETHER FOR BREACH OF WARRANTY, CONTRACT, STRICT LIABILITY OR OTHERWISE, INCLUDING WITHOUT LIMITATION, UNDER TORT OR OTHER LEGAL THEORY. MIPS AND ITS SUPPLIERS DISCLAIM ANY AND ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY INTELLECTUAL PROPERTY RIGHTS OF ANY KIND RELATING TO THE EVALUATION MATERIALS.9. EXPIRATION. MIPS may terminate this Agreement immediately after a breach by Recipient or otherwise at MIPS’ reasonable discretion and upon five (5) business days’ notice to Recipient.10. GENERAL.10.1 Controlling Law. This Agreement shall be governed by California law excluding its choice of law rules. With the exception of MIPS’ rights to enforce its intellectual property rights and any confidentiality obligations under this Agreement or any licenses distributed with the Evaluation Materials, all disputes and any claims arising under or relating to this Agreement shall be subject to the exclusive jurisdiction and venue of the state and federal courts located in Santa Clara County, California. Each party hereby agrees to jurisdiction and venue in the courts set forth in the preceding sentence. The parties agree that the United Nations Convention on Contracts for the International Sale of Goods is specifically excluded from application to this Agreement. The parties consent to the personal jurisdiction of the above courts.10.2 Remedies. Recipient acknowledges and agrees that any breach of confidentiality obligations under this Agreement or any licenses distributed with the Evaluation Materials, as well as any disclosure, commercialization, or public use of the Evaluation Materials, would cause irreparable injury to MIPS, and therefore Recipient agrees to consent to, and hereby consents to, the grant of an injunction by any court of competent jurisdiction in the event of an actual or threatened breach.10.3 Assignment. Recipient may not delegate, assign or transfer this Agreement, the license granted or any of Recipient’s rights, obligations, or duties hereunder, expressly, by implication, by operation of law, by way of merger (regardless of whether Recipient is the surviving entity) or acquisition, or otherwise and any attempt to do so, without MIPS’ express prior written consent, shall be ineffective, null and void. MIPS may freely assign this Agreement, and its rights and obligations hereunder, in its sole discretion.10.4 Entire Agreement. This Agreement constitutes the entire agreement between Recipient and MIPS and supersedes in their entirety any and all oral or written agreements previously existing between Recipient and MIPS with respect to the subject matter hereof. This Agreement may only be amended or supplemented by a writing that refers explicitly to this Agreement and that is signed or otherwise accepted by duly authorized representatives of Recipient and MIPS.10.5 Severability. In the event that any provision of this Agreement is finally adjudicated to be unenforceable or invalid under any applicable law, such unenforceability or invalidity shall not render this Agreement unenforceable or invalid as a whole, and, in such event, such unenforceable or invalid provision shall be interpreted so as to best accomplish the objectives of such provision within the limits of applicable law or applicable court decisions.10.6 Export Regulations / Export Control. Recipient shall not export, either directly or indirectly, any product, service or technical data or system incorporating the Evaluation Materials without first obtaining any required license or other necessary approval from the U.S. Department of Commerce or any other governing agency or department of the United States Government. In the event any product is exported from the United States or re-exported from a foreign destination by Recipient, Recipient shall ensure that the distribution and export/re-export or import of the product is in compliance with all applicable laws, regulations, orders, or other restrictions of the U.S. Export Administration Regulations and the appropriate foreign government. Recipient agrees that neither it nor any of its subsidiaries will export/re-export any technical data, process, product, or service, directly or indirectly, to any country for which the United States government or any agency thereof or the foreign government from where it is shipping requires an export license, or other governmental approval, without first obtaining such license or approval. Recipient also agrees to implement measures to ensure that foreign national employees are authorized to receive any information controlled by U.S. export control laws. An export is "deemed" to take place when information is released to a foreign national wherever located.10.7 Special Terms for Pre-Release Materials. If so indicated in the description of the Evaluation Software, the Evaluation Software may contain Pre-Release Materials. Recipient hereby understands, acknowledges and agrees that: (i) Pre-Release Materials may not be fully tested and may contain bugs or errors; (ii) Pre-Release materials are not suitable for commercial release in their current state; (iii) regulatory approvals for Pre-Release Materials (such as UL or FCC) have not been obtained, and Pre-Release Materials may therefore not be certified for use in certain countries or environments or may not be suitable for certain applications and (iv) MIPS can provide no assurance that it will ever produce or make generally available a production version of the Pre-Release Materials . MIPS is not under any obligation to develop and/or release or offer for sale or license a final product based upon the Pre-Release Materials and may unilaterally elect to abandon the Pre-Release Materials or any such development platform at any time and without any obligation or liability whatsoever to Recipient or any other person.ANY PRE-RELEASE MATERIALS ARE NON-QUALIFIED AND, AS SUCH, ARE PROVIDED “AS IS” AND “AS AVAILABLE”, POSSIBLY WITH FAULTS, AND WITHOUT REPRESENTATION OR WARRANTY OF ANY KIND.10.8 Open Source Software. In the event Open Source software is included with Evaluation Software, such Open Source software is licensed pursuant to the applicable Open Source software license agreement identified in the Open Source software comments in the applicable source code file(s) and/or file header as indicated in the Evaluation Software. Additional detail may be available (where applicable) in the accompanying on-line documentation. With respect to the Open Source software, nothing in this Agreement limits any rights under, or grants rights that supersede, the terms of any applicable Open Source software license agreement.---------------------------------------Accept? (y/N): All SDK package licenses accepted+ sdkmanager 'cmake;3.10.2.4988404'+ sed -i -e /detox/d -e /DETOX_CI/d build.gradle+ echo 'android { splits { abi { enable false } } }'+ sed -i -e 's/versionName appVersionName/versionName "3.9.6"/' -e 's/versionCode appVersionCode/versionCode 3000323/' build.gradle+ sed -i -e /appVersionName/d -e /appVersionCode/d build.gradle+ sed -i -e '/@bugsnag\/react-native/d' -e /bugsnag-sourcemaps/d ../../package.json2022-01-13 02:56:19,447 INFO: Cleaning Gradle project...2022-01-13 02:56:19,448 DEBUG: Directory: build/com.standardnotes/android/app2022-01-13 02:56:19,448 DEBUG: > /home/vagrant/fdroidserver/gradlew-fdroid cleanFound 5.4.1 via distributionUrlDownloading missing gradle version 5.4.1cachedir /home/vagrant/.cache/fdroidserver/home/vagrant/.cache/fdroidserver/gradle-5.4.1-bin.zip: OKRunning /opt/gradle/versions/5.4.1/bin/gradle cleanWelcome to Gradle 5.4.1!Here are the highlights of this release:- Run builds with JDK12- New API for Incremental Tasks- Updates to native projects, including Swift 5 supportFor more details see https://docs.gradle.org/5.4.1/release-notes.htmlTo honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.4.1/userguide/gradle_daemon.html.Daemon will be stopped at the end of the build stopping after processing> Configure project :react-native-reanimatedMapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01File /home/vagrant/.android/repositories.cfg could not be loaded.Checking the license for package Android SDK Build-Tools 30.0.2 in /opt/android-sdk/licensesLicense for package Android SDK Build-Tools 30.0.2 accepted.Preparing "Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)"."Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" ready.Installing Android SDK Build-Tools 30.0.2 in /opt/android-sdk/build-tools/30.0.2"Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" complete."Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" finished.Checking the license for package Android SDK Platform 30 in /opt/android-sdk/licensesLicense for package Android SDK Platform 30 accepted.Preparing "Install Android SDK Platform 30 (revision: 3)"."Install Android SDK Platform 30 (revision: 3)" ready.Installing Android SDK Platform 30 in /opt/android-sdk/platforms/android-30"Install Android SDK Platform 30 (revision: 3)" complete."Install Android SDK Platform 30 (revision: 3)" finished.Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01> Task :app:clean UP-TO-DATEBUILD SUCCESSFUL in 42s1 actionable task: 1 up-to-date2022-01-13 02:57:07,041 INFO: Scanning source for common problems...2022-01-13 02:57:07,051 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at android/build.gradle2022-01-13 02:57:07,051 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at android/build.gradle2022-01-13 02:57:07,051 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/detox/Detox-android' at android/build.gradle2022-01-13 02:57:07,052 INFO: Removing gradle-wrapper.jar at android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:07,056 INFO: Removing gradle-wrapper.jar at android/app/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:07,304 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86_64/.ninja_deps2022-01-13 02:57:07,305 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86_64/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,305 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86_64/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,306 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86_64/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,307 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/armeabi-v7a/.ninja_deps2022-01-13 02:57:07,307 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/armeabi-v7a/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,308 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/armeabi-v7a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,308 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/armeabi-v7a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,309 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86/.ninja_deps2022-01-13 02:57:07,310 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,310 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,310 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/x86/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,311 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/arm64-v8a/.ninja_deps2022-01-13 02:57:07,312 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/arm64-v8a/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,313 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/arm64-v8a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,313 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/debug/arm64-v8a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,314 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/x86_64/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,314 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/x86_64/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,315 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/x86_64/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,316 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/armeabi-v7a/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,316 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/armeabi-v7a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,316 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/armeabi-v7a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,318 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/x86/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,318 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/x86/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,318 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/x86/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,319 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/arm64-v8a/CMakeFiles/feature_tests.bin2022-01-13 02:57:07,320 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/arm64-v8a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_CXX.bin2022-01-13 02:57:07,320 INFO: Ignoring binary at node_modules/react-native-sodium/android/.cxx/cmake/release/arm64-v8a/CMakeFiles/3.6.0-rc2/CMakeDetermineCompilerABI_C.bin2022-01-13 02:57:07,323 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-sodium/example/android/build.gradle2022-01-13 02:57:07,323 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native-sodium/example/android/build.gradle2022-01-13 02:57:07,324 INFO: Removing gradle-wrapper.jar at node_modules/react-native-sodium/example/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:07,332 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/watchos-simulators/lib/libsodium.a2022-01-13 02:57:07,335 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/ios-simulators/lib/libsodium.a2022-01-13 02:57:07,338 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/catalyst/lib/libsodium.a2022-01-13 02:57:07,341 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/ios/lib/libsodium.a2022-01-13 02:57:07,345 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/watchos/lib/libsodium.a2022-01-13 02:57:07,348 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/tvos-simulators/lib/libsodium.a2022-01-13 02:57:07,351 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/macos/lib/libsodium.a2022-01-13 02:57:07,355 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/tvos/lib/libsodium.a2022-01-13 02:57:07,355 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/ios-arm64_x86_64-maccatalyst/libsodium.a2022-01-13 02:57:07,358 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/tvos-arm64/libsodium.a2022-01-13 02:57:07,362 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/ios-arm64_i386_x86_64-simulator/libsodium.a2022-01-13 02:57:07,365 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/ios-arm64_armv7_armv7s/libsodium.a2022-01-13 02:57:07,368 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/watchos-arm64_32_armv7k/libsodium.a2022-01-13 02:57:07,371 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/tvos-arm64_x86_64-simulator/libsodium.a2022-01-13 02:57:07,374 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/watchos-arm64_i386_x86_64-simulator/libsodium.a2022-01-13 02:57:07,377 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-apple/Clibsodium.xcframework/macos-arm64_x86_64/libsodium.a2022-01-13 02:57:07,383 INFO: Ignoring shared library at node_modules/react-native-sodium/libsodium/libsodium-android-westmere/lib/libsodium.so2022-01-13 02:57:07,384 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-android-westmere/lib/libsodium.a2022-01-13 02:57:07,387 INFO: Ignoring shared library at node_modules/react-native-sodium/libsodium/libsodium-android-armv7-a/lib/libsodium.so2022-01-13 02:57:07,387 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-android-armv7-a/lib/libsodium.a2022-01-13 02:57:07,390 INFO: Ignoring shared library at node_modules/react-native-sodium/libsodium/libsodium-android-i686/lib/libsodium.so2022-01-13 02:57:07,391 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-android-i686/lib/libsodium.a2022-01-13 02:57:07,394 INFO: Ignoring shared library at node_modules/react-native-sodium/libsodium/libsodium-android-armv8-a/lib/libsodium.so2022-01-13 02:57:07,394 INFO: Ignoring static library at node_modules/react-native-sodium/libsodium/libsodium-android-armv8-a/lib/libsodium.a2022-01-13 02:57:07,398 INFO: Removing Java JAR file at node_modules/jetifier/lib/annotations-13.0.jar2022-01-13 02:57:07,398 INFO: Removing Java JAR file at node_modules/jetifier/lib/asm-tree-6.0.jar2022-01-13 02:57:07,398 INFO: Removing Java JAR file at node_modules/jetifier/lib/gson-2.8.0.jar2022-01-13 02:57:07,399 INFO: Removing Java JAR file at node_modules/jetifier/lib/jetifier-core-1.0.0-beta09.jar2022-01-13 02:57:07,399 INFO: Removing Java JAR file at node_modules/jetifier/lib/jdom2-2.0.6.jar2022-01-13 02:57:07,400 INFO: Removing Java JAR file at node_modules/jetifier/lib/jetifier-standalone.jar2022-01-13 02:57:07,400 INFO: Removing Java JAR file at node_modules/jetifier/lib/asm-commons-6.0.jar2022-01-13 02:57:07,400 INFO: Removing Java JAR file at node_modules/jetifier/lib/jetifier-processor-1.0.0-beta09.jar2022-01-13 02:57:07,401 INFO: Removing Java JAR file at node_modules/jetifier/lib/kotlin-stdlib-1.3.60.jar2022-01-13 02:57:07,401 INFO: Removing Java JAR file at node_modules/jetifier/lib/kotlin-stdlib-common-1.3.60.jar2022-01-13 02:57:07,401 INFO: Removing Java JAR file at node_modules/jetifier/lib/asm-util-6.0.jar2022-01-13 02:57:07,402 INFO: Removing Java JAR file at node_modules/jetifier/lib/asm-6.0.jar2022-01-13 02:57:07,402 INFO: Removing Java JAR file at node_modules/jetifier/lib/commons-cli-1.3.1.jar2022-01-13 02:57:07,491 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/sn-textview/android/build.gradle2022-01-13 02:57:07,491 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/sn-textview/android/build.gradle2022-01-13 02:57:07,497 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-search-bar/example/android/build.gradle2022-01-13 02:57:07,497 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native-search-bar/example/android/build.gradle2022-01-13 02:57:07,498 INFO: Removing gradle-wrapper.jar at node_modules/react-native-search-bar/example/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:07,530 INFO: Removing binary at node_modules/node-notifier/vendor/notifu/notifu64.exe2022-01-13 02:57:07,530 INFO: Removing binary at node_modules/node-notifier/vendor/notifu/notifu.exe2022-01-13 02:57:07,531 INFO: Removing binary at node_modules/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier2022-01-13 02:57:07,532 INFO: Removing binary at node_modules/node-notifier/vendor/snoreToast/snoretoast-x64.exe2022-01-13 02:57:07,532 INFO: Removing binary at node_modules/node-notifier/vendor/snoreToast/snoretoast-x86.exe2022-01-13 02:57:07,621 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/standard-notes-rn/android/build.gradle2022-01-13 02:57:07,627 INFO: Ignoring unknown maven repo 'defaultDir.toString()' at node_modules/react-native-webview/android/build.gradle2022-01-13 02:57:07,627 INFO: Ignoring unknown maven repo 'androidPrebuiltBinaryDir.toString()' at node_modules/react-native-webview/android/build.gradle2022-01-13 02:57:07,627 INFO: Ignoring unknown maven repo 'androidSourcesDir.toString()' at node_modules/react-native-webview/android/build.gradle2022-01-13 02:57:07,811 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-safe-area-context/android/build.gradle2022-01-13 02:57:07,914 WARNING: Found executable binary, possibly code at node_modules/bplist-parser/test/utf16_chinese.plist2022-01-13 02:57:07,975 INFO: Ignoring unknown maven repo '$projectDir/../node_modules/react-native/android' at node_modules/react-native-screens/android/build.gradle2022-01-13 02:57:08,098 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-keychain/android/build.gradle2022-01-13 02:57:08,098 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native-keychain/android/build.gradle2022-01-13 02:57:08,122 INFO: Removing Java JAR file at node_modules/detox/Detox-android/com/wix/detox/17.8.3/detox-17.8.3-sources.jar2022-01-13 02:57:08,123 INFO: Removing Java JAR file at node_modules/detox/Detox-android/com/wix/detox/17.8.3/detox-17.8.3-javadoc.jar2022-01-13 02:57:08,124 INFO: Removing Android AAR library at node_modules/detox/Detox-android/com/wix/detox/17.8.3/detox-17.8.3.aar2022-01-13 02:57:08,125 INFO: Ignoring unknown maven repo '$projectDir/../../node_modules/react-native/android' at node_modules/detox/android/build.gradle2022-01-13 02:57:08,125 INFO: Removing gradle-wrapper.jar at node_modules/detox/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:08,131 INFO: Ignoring unknown maven repo '$libOutputDir' at node_modules/detox/android/detox/detox-publishing.gradle2022-01-13 02:57:08,157 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-fingerprint-scanner/examples/android/build.gradle2022-01-13 02:57:08,157 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native-fingerprint-scanner/examples/android/build.gradle2022-01-13 02:57:08,158 INFO: Removing gradle-wrapper.jar at node_modules/react-native-fingerprint-scanner/examples/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:08,211 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-reanimated/android/build.gradle2022-01-13 02:57:08,211 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native-reanimated/android/build.gradle2022-01-13 02:57:08,230 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-aes-crypto/android/build.gradle2022-01-13 02:57:08,231 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native-aes-crypto/android/build.gradle2022-01-13 02:57:08,233 INFO: Removing gradle-wrapper.jar at node_modules/react-native-default-preference/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:08,707 INFO: Ignoring Java JAR file at node_modules/react-native/android/com/facebook/react/react-native/0.64.1/react-native-0.64.1-javadoc.jar2022-01-13 02:57:08,708 INFO: Ignoring Android AAR library at node_modules/react-native/android/com/facebook/react/react-native/0.64.1/react-native-0.64.1.aar2022-01-13 02:57:08,708 INFO: Ignoring Java JAR file at node_modules/react-native/android/com/facebook/react/react-native/0.64.1/react-native-0.64.1-sources.jar2022-01-13 02:57:08,711 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native/template/android/build.gradle2022-01-13 02:57:08,711 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/jsc-android/dist' at node_modules/react-native/template/android/build.gradle2022-01-13 02:57:08,712 INFO: Removing gradle-wrapper.jar at node_modules/react-native/template/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:08,839 INFO: Ignoring Java JAR file at node_modules/react-native/ReactAndroid/src/main/third-party/java/buck-android-support/buck-android-support.jar2022-01-13 02:57:08,882 INFO: Ignoring Android AAR library at node_modules/jsc-android/dist/org/webkit/android-jsc/r245459/android-jsc-r245459.aar2022-01-13 02:57:08,883 INFO: Ignoring Android AAR library at node_modules/jsc-android/dist/org/webkit/android-jsc-cppruntime/r245459/android-jsc-cppruntime-r245459.aar2022-01-13 02:57:08,883 INFO: Ignoring Android AAR library at node_modules/jsc-android/dist/org/webkit/android-jsc-intl/r245459/android-jsc-intl-r245459.aar2022-01-13 02:57:08,890 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/@react-native-community/async-storage/android/build.gradle2022-01-13 02:57:08,912 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/@react-native-community/masked-view/android/build.gradle2022-01-13 02:57:08,935 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/@react-native-community/netinfo/android/build.gradle2022-01-13 02:57:08,935 INFO: Removing gradle-wrapper.jar at node_modules/@react-native-community/netinfo/android/gradle/wrapper/gradle-wrapper.jar2022-01-13 02:57:08,964 INFO: Ignoring unknown maven repo '$rootDir/../node_modules/react-native/android' at node_modules/react-native-vector-icons/android/build.gradle2022-01-13 02:57:08,986 INFO: Removing unknown maven repo '$rootDir/../node_modules/@bugsnag/react-native/android' at node_modules/@bugsnag/react-native/bugsnag-react-native.gradle2022-01-13 02:57:08,998 INFO: Removing unknown maven repo 'facebookRepo' at node_modules/@bugsnag/react-native/android/build.gradle2022-01-13 02:57:08,998 INFO: Removing unknown maven repo 'bugsnagRepo' at node_modules/@bugsnag/react-native/android/build.gradle2022-01-13 02:57:08,999 INFO: Removing Android AAR library at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-android-core/5.5.0-react-native/bugsnag-android-core-5.5.0-react-native.aar2022-01-13 02:57:09,000 INFO: Removing Java JAR file at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-android-core/5.5.0-react-native/bugsnag-android-core-5.5.0-react-native-sources.jar2022-01-13 02:57:09,000 INFO: Removing Android AAR library at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-android-ndk/5.5.0-react-native/bugsnag-android-ndk-5.5.0-react-native.aar2022-01-13 02:57:09,000 INFO: Removing Java JAR file at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-android-ndk/5.5.0-react-native/bugsnag-android-ndk-5.5.0-react-native-sources.jar2022-01-13 02:57:09,002 INFO: Removing Android AAR library at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-android/5.5.0-react-native/bugsnag-android-5.5.0-react-native.aar2022-01-13 02:57:09,002 INFO: Removing Java JAR file at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-android/5.5.0-react-native/bugsnag-android-5.5.0-react-native-sources.jar2022-01-13 02:57:09,003 INFO: Removing Android AAR library at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-plugin-android-anr/5.5.0-react-native/bugsnag-plugin-android-anr-5.5.0-react-native.aar2022-01-13 02:57:09,003 INFO: Removing Java JAR file at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-plugin-android-anr/5.5.0-react-native/bugsnag-plugin-android-anr-5.5.0-react-native-sources.jar2022-01-13 02:57:09,004 INFO: Removing Android AAR library at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-plugin-android-ndk/5.5.0-react-native/bugsnag-plugin-android-ndk-5.5.0-react-native.aar2022-01-13 02:57:09,004 INFO: Removing Java JAR file at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-plugin-android-ndk/5.5.0-react-native/bugsnag-plugin-android-ndk-5.5.0-react-native-sources.jar2022-01-13 02:57:09,005 INFO: Removing Android AAR library at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-plugin-react-native/5.5.0-react-native/bugsnag-plugin-react-native-5.5.0-react-native.aar2022-01-13 02:57:09,005 INFO: Removing Java JAR file at node_modules/@bugsnag/react-native/android/com/bugsnag/bugsnag-plugin-react-native/5.5.0-react-native/bugsnag-plugin-react-native-5.5.0-react-native-sources.jar2022-01-13 02:57:09,278 INFO: Ignoring binary at node_modules/hermes-engine/linux64-bin/hermesc2022-01-13 02:57:09,279 INFO: Ignoring binary at node_modules/hermes-engine/osx-bin/hermesc2022-01-13 02:57:09,279 INFO: Ignoring binary at node_modules/hermes-engine/win64-bin/hermesc.exe2022-01-13 02:57:09,279 INFO: Ignoring Android AAR library at node_modules/hermes-engine/android/hermes-debug.aar2022-01-13 02:57:09,280 INFO: Ignoring Android AAR library at node_modules/hermes-engine/android/hermes-release.aar2022-01-13 02:57:09,280 INFO: Ignoring Android AAR library at node_modules/hermes-engine/android/hermes-cppruntime-release.aar2022-01-13 02:57:09,280 INFO: Ignoring Android AAR library at node_modules/hermes-engine/android/hermes-cppruntime-debug.aar2022-01-13 02:57:09,295 INFO: Creating source tarball...2022-01-13 02:57:46,307 INFO: Running 'build' commands in build/com.standardnotes/android/app/2022-01-13 02:57:46,307 DEBUG: Directory: build/com.standardnotes/android/app2022-01-13 02:57:46,307 DEBUG: > bash -x -c lib="$PWD/../../node_modules/react-native-sodium/libsodium" && target_sdk_version=`sed -n -E 's/.*targetSdkVersion = ([0-9]{1,2}).*/\1/p' ../build.gradle` && pushd /home/vagrant/build/srclib/libsodium && ./dist-build/android-armv7-a.sh && ./dist-build/android-armv8-a.sh && ./dist-build/android-x86.sh && ./dist-build/android-x86_64.sh && popd+ lib=/home/vagrant/build/com.standardnotes/android/app/../../node_modules/react-native-sodium/libsodium++ sed -n -E 's/.*targetSdkVersion = ([0-9]{1,2}).*/\1/p' ../build.gradle+ target_sdk_version=30+ pushd /home/vagrant/build/srclib/libsodium~/build/srclib/libsodium ~/build/com.standardnotes/android/app+ ./dist-build/android-armv7-a.shWarnings related to headers being present but not usable are due to functionsthat didn't exist in the specified minimum API version level.They can be safely ignored.Building for platform [android-16]WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that performthe same task. For example, instead of:$ python $NDK/build/tools/make_standalone_toolchain.py \--arch arm --api 16 --install-dir toolchain$ toolchain/bin/clang++ src.cppInstead use:$ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi16-clang++ src.cppchecking build system type... x86_64-pc-linux-gnux32checking host system type... arm-unknown-linux-androideabichecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for arm-linux-androideabi-strip... arm-linux-androideabi-stripchecking for a thread-safe mkdir -p... /bin/mkdir -pchecking for gawk... nochecking for mawk... mawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether UID '1000' is supported by ustar format... yeschecking whether GID '1000' is supported by ustar format... yeschecking how to create a ustar tar archive... gnutarchecking whether make supports nested variables... (cached) yeschecking whether to enable maintainer-specific portions of Makefiles... nochecking for style of include used by make... GNUchecking for arm-linux-androideabi-gcc... arm-linux-androideabi-clangchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... yeschecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether arm-linux-androideabi-clang accepts -g... yeschecking for arm-linux-androideabi-clang option to accept ISO C89... none neededchecking whether arm-linux-androideabi-clang understands -c and -o together... yeschecking dependency style of arm-linux-androideabi-clang... gcc3checking for a sed that does not truncate output... /bin/sedchecking how to run the C preprocessor... arm-linux-androideabi-clang -Echecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking whether arm-linux-androideabi-clang is Clang... yeschecking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... nochecking for joinable pthread attribute... PTHREAD_CREATE_JOINABLEchecking whether more special flags are required for pthreads... nochecking for PTHREAD_PRIO_INHERIT... yeschecking for arm-linux-androideabi-clang option to accept ISO C99... none neededchecking dependency style of arm-linux-androideabi-clang... gcc3checking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking minix/config.h usability... nochecking minix/config.h presence... nochecking for minix/config.h... nochecking whether it is safe to define __EXTENSIONS__... yeschecking for variable-length arrays... yeschecking for __wasi__ defined... nochecking for _FORTIFY_SOURCE defined... nochecking whether C compiler accepts -D_FORTIFY_SOURCE=2... yeschecking whether C compiler accepts -fvisibility=hidden... yeschecking whether C compiler accepts -fPIC... yeschecking whether C compiler accepts -fPIE... yeschecking whether the linker accepts -pie... yeschecking whether C compiler accepts -fno-strict-aliasing... yeschecking whether C compiler accepts -fno-strict-overflow... yeschecking whether C compiler accepts -fstack-protector... yeschecking whether the linker accepts -fstack-protector... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wall... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra... yeschecking for clang... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl... yeschecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl -Wwrite-strings... yeschecking whether the linker accepts -Wl,-z,relro... yeschecking whether the linker accepts -Wl,-z,now... yeschecking whether the linker accepts -Wl,-z,noexecstack... yeschecking whether segmentation violations can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, segmentation violations cannot be caught using signal handlers. This is expected if you enabled a tool such as Address Sanitizer (-fsanitize=address), but be aware that using Address Sanitizer may also significantly reduce performance.checking whether SIGABRT can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, SIGABRT cannot be caught using signal handlers.checking for thread local storage (TLS) class... _Thread_localthread local storage is supportedchecking whether C compiler accepts -ftls-model=local-dynamic... yeschecking how to print strings... printfchecking for a sed that does not truncate output... (cached) /bin/sedchecking for fgrep... /bin/grep -Fchecking for ld used by arm-linux-androideabi-clang... /home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/arm-linux-androideabi/bin/ldchecking if the linker (/home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/arm-linux-androideabi/bin/ld) is GNU ld... yeschecking for BSD- or MS-compatible name lister (nm)... /home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/bin/arm-linux-androideabi-nm -Bchecking the name lister (/home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/bin/arm-linux-androideabi-nm -B) interface... BSD nmchecking whether ln -s works... yeschecking the maximum length of command line arguments... 1572864checking how to convert x86_64-pc-linux-gnux32 file names to arm-unknown-linux-androideabi format... func_convert_file_noopchecking how to convert x86_64-pc-linux-gnux32 file names to toolchain format... func_convert_file_noopchecking for /home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/arm-linux-androideabi/bin/ld option to reload object files... -rchecking for arm-linux-androideabi-objdump... arm-linux-androideabi-objdumpchecking how to recognize dependent libraries... pass_allchecking for arm-linux-androideabi-dlltool... nochecking for dlltool... nochecking how to associate runtime and link libraries... printf %s\nchecking for arm-linux-androideabi-ar... arm-linux-androideabi-archecking for archiver @FILE support... @checking for arm-linux-androideabi-strip... (cached) arm-linux-androideabi-stripchecking for arm-linux-androideabi-ranlib... arm-linux-androideabi-ranlibchecking command to parse /home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/bin/arm-linux-androideabi-nm -B output from arm-linux-androideabi-clang object... okchecking for sysroot... /home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/sysrootchecking for a working dd... /bin/ddchecking how to truncate binary pipes... /bin/dd bs=4096 count=1checking for arm-linux-androideabi-mt... nochecking for mt... mtconfigure: WARNING: using cross tools not prefixed with host tripletchecking if mt is a manifest tool... nochecking for dlfcn.h... yeschecking for objdir... .libschecking if arm-linux-androideabi-clang supports -fno-rtti -fno-exceptions... yeschecking for arm-linux-androideabi-clang option to produce PIC... -fPIC -DPICchecking if arm-linux-androideabi-clang PIC flag -fPIC -DPIC works... yeschecking if arm-linux-androideabi-clang static flag -static works... nochecking if arm-linux-androideabi-clang supports -c -o file.o... yeschecking if arm-linux-androideabi-clang supports -c -o file.o... (cached) yeschecking whether the arm-linux-androideabi-clang linker (/home/vagrant/build/srclib/libsodium/android-toolchain-armv7-a/arm-linux-androideabi/bin/ld) supports shared libraries... yeschecking whether -lc should be explicitly linked in... nochecking dynamic linker characteristics... Android linkerchecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... yeschecking for arm-linux-androideabi-ar... (cached) arm-linux-androideabi-archecking whether C compiler accepts -mmmx... yeschecking for MMX instructions set... nochecking whether C compiler accepts -msse2... yeschecking for SSE2 instructions set... nochecking whether C compiler accepts -msse3... yeschecking for SSE3 instructions set... nochecking whether C compiler accepts -mssse3... yeschecking for SSSE3 instructions set... nochecking whether C compiler accepts -msse4.1... yeschecking for SSE4.1 instructions set... nochecking whether C compiler accepts -mavx... yeschecking for AVX instructions set... nochecking whether C compiler accepts -mavx2... yeschecking for AVX2 instructions set... nochecking whether C compiler accepts -mavx512f... yeschecking for AVX512F instructions set... nochecking whether C compiler accepts -Os -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -marm -march=armv7-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -ftls-model=local-dynamic -mavx512f -mno-avx512f... yeschecking whether C compiler accepts -maes... yeschecking whether C compiler accepts -mpclmul... yeschecking for AESNI instructions set and PCLMULQDQ... nochecking whether C compiler accepts -mrdrnd... yeschecking for RDRAND... nochecking sys/mman.h usability... yeschecking sys/mman.h presence... yeschecking for sys/mman.h... yeschecking sys/random.h usability... yeschecking sys/random.h presence... yeschecking for sys/random.h... yeschecking intrin.h usability... nochecking intrin.h presence... nochecking for intrin.h... nochecking if _xgetbv() is available... nochecking for inline... inlinechecking whether byte ordering is bigendian... nochecking whether __STDC_LIMIT_MACROS is required... nochecking whether we can use inline asm code... yesnochecking whether we can use x86_64 asm code... nochecking whether we can assemble AVX opcodes... nochecking for 128-bit arithmetic... nochecking for cpuid instruction... nochecking if the .private_extern asm directive is supported... nochecking if the .hidden asm directive is supported... yeschecking if weak symbols are supported... yeschecking if data alignment is required... nochecking if atomic operations are supported... yeschecking for size_t... yeschecking for working alloca.h... yeschecking for alloca... yeschecking for arc4random... yeschecking for arc4random_buf... yeschecking for mmap... yeschecking for mlock... yeschecking for madvise... yeschecking for mprotect... yeschecking for getrandom with a standard API... nochecking for getentropy with a standard API... nochecking for posix_memalign... nochecking for getpid... yeschecking for nanosleep... yeschecking for memset_s... nochecking for explicit_bzero... nochecking for explicit_memset... nochecking if gcc/ld supports -Wl,--output-def... nochecking that generated files are newer than configure... doneconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating builds/Makefileconfig.status: creating contrib/Makefileconfig.status: creating dist-build/Makefileconfig.status: creating libsodium.pcconfig.status: creating libsodium-uninstalled.pcconfig.status: creating msvc-scripts/Makefileconfig.status: creating src/Makefileconfig.status: creating src/libsodium/Makefileconfig.status: creating src/libsodium/include/Makefileconfig.status: creating src/libsodium/include/sodium/version.hconfig.status: creating test/default/Makefileconfig.status: creating test/Makefileconfig.status: executing depfiles commandsconfig.status: executing libtool commandsMaking clean in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making clean in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making clean in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making clean in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making clean in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making clean in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making clean in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'rm -rf .libs _libsrm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'test -z "" || rm -ftest -z "libsodium.la" || rm -f libsodium.larm -f ./so_locationsrm -rf .libs _libsrm -rf crypto_aead/aes256gcm/aesni/.libs crypto_aead/aes256gcm/aesni/_libsrm -rf crypto_aead/chacha20poly1305/sodium/.libs crypto_aead/chacha20poly1305/sodium/_libsrm -rf crypto_aead/xchacha20poly1305/sodium/.libs crypto_aead/xchacha20poly1305/sodium/_libsrm -rf crypto_auth/.libs crypto_auth/_libsrm -rf crypto_auth/hmacsha256/.libs crypto_auth/hmacsha256/_libsrm -rf crypto_auth/hmacsha512/.libs crypto_auth/hmacsha512/_libsrm -rf crypto_auth/hmacsha512256/.libs crypto_auth/hmacsha512256/_libsrm -rf crypto_box/.libs crypto_box/_libsrm -rf crypto_box/curve25519xchacha20poly1305/.libs crypto_box/curve25519xchacha20poly1305/_libsrm -rf crypto_box/curve25519xsalsa20poly1305/.libs crypto_box/curve25519xsalsa20poly1305/_libsrm -rf crypto_core/ed25519/.libs crypto_core/ed25519/_libsrm -rf crypto_core/ed25519/ref10/.libs crypto_core/ed25519/ref10/_libsrm -rf crypto_core/hchacha20/.libs crypto_core/hchacha20/_libsrm -rf crypto_core/hsalsa20/.libs crypto_core/hsalsa20/_libsrm -rf crypto_core/hsalsa20/ref2/.libs crypto_core/hsalsa20/ref2/_libsrm -rf crypto_core/salsa/ref/.libs crypto_core/salsa/ref/_libsrm -rf crypto_generichash/.libs crypto_generichash/_libsrm -rf crypto_generichash/blake2b/.libs crypto_generichash/blake2b/_libsrm -rf crypto_generichash/blake2b/ref/.libs crypto_generichash/blake2b/ref/_libsrm -rf crypto_hash/.libs crypto_hash/_libsrm -rf crypto_hash/sha256/.libs crypto_hash/sha256/_libsrm -rf crypto_hash/sha256/cp/.libs crypto_hash/sha256/cp/_libsrm -rf crypto_hash/sha512/.libs crypto_hash/sha512/_libsrm -rf crypto_hash/sha512/cp/.libs crypto_hash/sha512/cp/_libsrm -rf crypto_kdf/.libs crypto_kdf/_libsrm -rf crypto_kdf/blake2b/.libs crypto_kdf/blake2b/_libsrm -rf crypto_kx/.libs crypto_kx/_libsrm -rf crypto_onetimeauth/.libs crypto_onetimeauth/_libsrm -rf crypto_onetimeauth/poly1305/.libs crypto_onetimeauth/poly1305/_libsrm -rf crypto_onetimeauth/poly1305/donna/.libs crypto_onetimeauth/poly1305/donna/_libsrm -rf crypto_onetimeauth/poly1305/sse2/.libs crypto_onetimeauth/poly1305/sse2/_libsrm -rf crypto_pwhash/.libs crypto_pwhash/_libsrm -rf crypto_pwhash/argon2/.libs crypto_pwhash/argon2/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/.libs crypto_pwhash/scryptsalsa208sha256/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/nosse/.libs crypto_pwhash/scryptsalsa208sha256/nosse/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/sse/.libs crypto_pwhash/scryptsalsa208sha256/sse/_libsrm -rf crypto_scalarmult/.libs crypto_scalarmult/_libsrm -rf crypto_scalarmult/curve25519/.libs crypto_scalarmult/curve25519/_libsrm -rf crypto_scalarmult/curve25519/ref10/.libs crypto_scalarmult/curve25519/ref10/_libsrm -rf crypto_scalarmult/curve25519/sandy2x/.libs crypto_scalarmult/curve25519/sandy2x/_libsrm -rf crypto_scalarmult/ed25519/ref10/.libs crypto_scalarmult/ed25519/ref10/_libsrm -rf crypto_scalarmult/ristretto255/ref10/.libs crypto_scalarmult/ristretto255/ref10/_libsrm -rf crypto_secretbox/.libs crypto_secretbox/_libsrm -rf crypto_secretbox/xchacha20poly1305/.libs crypto_secretbox/xchacha20poly1305/_libsrm -rf crypto_secretbox/xsalsa20poly1305/.libs crypto_secretbox/xsalsa20poly1305/_libsrm -rf crypto_secretstream/xchacha20poly1305/.libs crypto_secretstream/xchacha20poly1305/_libsrm -rf crypto_shorthash/.libs crypto_shorthash/_libsrm -rf crypto_shorthash/siphash24/.libs crypto_shorthash/siphash24/_libsrm -rf crypto_shorthash/siphash24/ref/.libs crypto_shorthash/siphash24/ref/_libsrm -rf crypto_sign/.libs crypto_sign/_libsrm -rf crypto_sign/ed25519/.libs crypto_sign/ed25519/_libsrm -rf crypto_sign/ed25519/ref10/.libs crypto_sign/ed25519/ref10/_libsrm -rf crypto_stream/.libs crypto_stream/_libsrm -rf crypto_stream/chacha20/.libs crypto_stream/chacha20/_libsrm -rf crypto_stream/chacha20/dolbeau/.libs crypto_stream/chacha20/dolbeau/_libsrm -rf crypto_stream/chacha20/ref/.libs crypto_stream/chacha20/ref/_libsrm -rf crypto_stream/salsa20/.libs crypto_stream/salsa20/_libsrm -rf crypto_stream/salsa20/ref/.libs crypto_stream/salsa20/ref/_libsrm -rf crypto_stream/salsa20/xmm6/.libs crypto_stream/salsa20/xmm6/_libsrm -rf crypto_stream/salsa20/xmm6int/.libs crypto_stream/salsa20/xmm6int/_libsrm -rf crypto_stream/salsa2012/.libs crypto_stream/salsa2012/_libsrm -rf crypto_stream/salsa2012/ref/.libs crypto_stream/salsa2012/ref/_libsrm -rf crypto_stream/salsa208/.libs crypto_stream/salsa208/_libsrm -rf crypto_stream/salsa208/ref/.libs crypto_stream/salsa208/ref/_libsrm -rf crypto_stream/xchacha20/.libs crypto_stream/xchacha20/_libsrm -rf crypto_stream/xsalsa20/.libs crypto_stream/xsalsa20/_libsrm -rf crypto_verify/sodium/.libs crypto_verify/sodium/_libsrm -rf randombytes/.libs randombytes/_libsrm -rf randombytes/internal/.libs randombytes/internal/_libsrm -rf randombytes/sysrandom/.libs randombytes/sysrandom/_libsrm -rf sodium/.libs sodium/_libstest -z "libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.la" || rm -f libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.larm -f ./so_locationsrm -f *.orm -f crypto_aead/aes256gcm/aesni/*.orm -f crypto_aead/aes256gcm/aesni/*.lorm -f crypto_aead/chacha20poly1305/sodium/*.orm -f crypto_aead/chacha20poly1305/sodium/*.lorm -f crypto_aead/xchacha20poly1305/sodium/*.orm -f crypto_aead/xchacha20poly1305/sodium/*.lorm -f crypto_auth/*.orm -f crypto_auth/*.lorm -f crypto_auth/hmacsha256/*.orm -f crypto_auth/hmacsha256/*.lorm -f crypto_auth/hmacsha512/*.orm -f crypto_auth/hmacsha512/*.lorm -f crypto_auth/hmacsha512256/*.orm -f crypto_auth/hmacsha512256/*.lorm -f crypto_box/*.orm -f crypto_box/*.lorm -f crypto_box/curve25519xchacha20poly1305/*.orm -f crypto_box/curve25519xchacha20poly1305/*.lorm -f crypto_box/curve25519xsalsa20poly1305/*.orm -f crypto_box/curve25519xsalsa20poly1305/*.lorm -f crypto_core/ed25519/*.orm -f crypto_core/ed25519/*.lorm -f crypto_core/ed25519/ref10/*.orm -f crypto_core/ed25519/ref10/*.lorm -f crypto_core/hchacha20/*.orm -f crypto_core/hchacha20/*.lorm -f crypto_core/hsalsa20/*.orm -f crypto_core/hsalsa20/*.lorm -f crypto_core/hsalsa20/ref2/*.orm -f crypto_core/hsalsa20/ref2/*.lorm -f crypto_core/salsa/ref/*.orm -f crypto_core/salsa/ref/*.lorm -f crypto_generichash/*.orm -f crypto_generichash/*.lorm -f crypto_generichash/blake2b/*.orm -f crypto_generichash/blake2b/*.lorm -f crypto_generichash/blake2b/ref/*.orm -f crypto_generichash/blake2b/ref/*.lorm -f crypto_hash/*.orm -f crypto_hash/*.lorm -f crypto_hash/sha256/*.orm -f crypto_hash/sha256/*.lorm -f crypto_hash/sha256/cp/*.orm -f crypto_hash/sha256/cp/*.lorm -f crypto_hash/sha512/*.orm -f crypto_hash/sha512/*.lorm -f crypto_hash/sha512/cp/*.orm -f crypto_hash/sha512/cp/*.lorm -f crypto_kdf/*.orm -f crypto_kdf/*.lorm -f crypto_kdf/blake2b/*.orm -f crypto_kdf/blake2b/*.lorm -f crypto_kx/*.orm -f crypto_kx/*.lorm -f crypto_onetimeauth/*.orm -f crypto_onetimeauth/*.lorm -f crypto_onetimeauth/poly1305/*.orm -f crypto_onetimeauth/poly1305/*.lorm -f crypto_onetimeauth/poly1305/donna/*.orm -f crypto_onetimeauth/poly1305/donna/*.lorm -f crypto_onetimeauth/poly1305/sse2/*.orm -f crypto_onetimeauth/poly1305/sse2/*.lorm -f crypto_pwhash/*.orm -f crypto_pwhash/*.lorm -f crypto_pwhash/argon2/*.orm -f crypto_pwhash/argon2/*.lorm -f crypto_pwhash/scryptsalsa208sha256/*.orm -f crypto_pwhash/scryptsalsa208sha256/*.lorm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.orm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.lorm -f crypto_pwhash/scryptsalsa208sha256/sse/*.orm -f crypto_pwhash/scryptsalsa208sha256/sse/*.lorm -f crypto_scalarmult/*.orm -f crypto_scalarmult/*.lorm -f crypto_scalarmult/curve25519/*.orm -f crypto_scalarmult/curve25519/*.lorm -f crypto_scalarmult/curve25519/ref10/*.orm -f crypto_scalarmult/curve25519/ref10/*.lorm -f crypto_scalarmult/curve25519/sandy2x/*.orm -f crypto_scalarmult/curve25519/sandy2x/*.lorm -f crypto_scalarmult/ed25519/ref10/*.orm -f crypto_scalarmult/ed25519/ref10/*.lorm -f crypto_scalarmult/ristretto255/ref10/*.orm -f crypto_scalarmult/ristretto255/ref10/*.lorm -f crypto_secretbox/*.orm -f crypto_secretbox/*.lorm -f crypto_secretbox/xchacha20poly1305/*.orm -f crypto_secretbox/xchacha20poly1305/*.lorm -f crypto_secretbox/xsalsa20poly1305/*.orm -f crypto_secretbox/xsalsa20poly1305/*.lorm -f crypto_secretstream/xchacha20poly1305/*.orm -f crypto_secretstream/xchacha20poly1305/*.lorm -f crypto_shorthash/*.orm -f crypto_shorthash/*.lorm -f crypto_shorthash/siphash24/*.orm -f crypto_shorthash/siphash24/*.lorm -f crypto_shorthash/siphash24/ref/*.orm -f crypto_shorthash/siphash24/ref/*.lorm -f crypto_sign/*.orm -f crypto_sign/*.lorm -f crypto_sign/ed25519/*.orm -f crypto_sign/ed25519/*.lorm -f crypto_sign/ed25519/ref10/*.orm -f crypto_sign/ed25519/ref10/*.lorm -f crypto_stream/*.orm -f crypto_stream/*.lorm -f crypto_stream/chacha20/*.orm -f crypto_stream/chacha20/*.lorm -f crypto_stream/chacha20/dolbeau/*.orm -f crypto_stream/chacha20/dolbeau/*.lorm -f crypto_stream/chacha20/ref/*.orm -f crypto_stream/chacha20/ref/*.lorm -f crypto_stream/salsa20/*.orm -f crypto_stream/salsa20/*.lorm -f crypto_stream/salsa20/ref/*.orm -f crypto_stream/salsa20/ref/*.lorm -f crypto_stream/salsa20/xmm6/*.orm -f crypto_stream/salsa20/xmm6/*.lorm -f crypto_stream/salsa20/xmm6int/*.orm -f crypto_stream/salsa20/xmm6int/*.lorm -f crypto_stream/salsa2012/*.orm -f crypto_stream/salsa2012/*.lorm -f crypto_stream/salsa2012/ref/*.orm -f crypto_stream/salsa2012/ref/*.lorm -f crypto_stream/salsa208/*.orm -f crypto_stream/salsa208/*.lorm -f crypto_stream/salsa208/ref/*.orm -f crypto_stream/salsa208/ref/*.lorm -f crypto_stream/xchacha20/*.orm -f crypto_stream/xchacha20/*.lorm -f crypto_stream/xsalsa20/*.orm -f crypto_stream/xsalsa20/*.lorm -f crypto_verify/sodium/*.orm -f crypto_verify/sodium/*.lorm -f randombytes/*.orm -f randombytes/*.lorm -f randombytes/internal/*.orm -f randombytes/internal/*.lorm -f randombytes/sysrandom/*.orm -f randombytes/sysrandom/*.lorm -f sodium/*.orm -f sodium/*.lorm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making clean in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making clean in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'rm -f aead_aes256gcm aead_aes256gcm2 aead_chacha20poly1305 aead_chacha20poly13052 aead_xchacha20poly1305 auth auth2 auth3 auth5 auth6 auth7 box box2 box7 box8 box_easy box_easy2 box_seal box_seed chacha20 codecs core1 core2 core3 core4 core5 core6 ed25519_convert generichash generichash2 generichash3 hash hash3 kdf keygen kx metamorphic misuse onetimeauth onetimeauth2 onetimeauth7 pwhash_argon2i pwhash_argon2id randombytes scalarmult scalarmult2 scalarmult5 scalarmult6 scalarmult7 scalarmult8 secretbox secretbox2 secretbox7 secretbox8 secretbox_easy secretbox_easy2 secretstream shorthash sign sodium_core sodium_utils sodium_version stream stream2 stream3 stream4 verify1 sodium_utils2 sodium_utils3rm -rf .libs _libsrm -f *.otest -z "aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.log" || rm -f aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.logtest -z "aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trs" || rm -f aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trstest -z "test-suite.log" || rm -f test-suite.logrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'Making install in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making install in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making install in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making install in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making install in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making install in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making install in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/sodium'/usr/bin/install -c -m 644  sodium/version.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/sodium'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/sodium'/usr/bin/install -c -m 644  sodium/core.h sodium/crypto_aead_aes256gcm.h sodium/crypto_aead_chacha20poly1305.h sodium/crypto_aead_xchacha20poly1305.h sodium/crypto_auth.h sodium/crypto_auth_hmacsha256.h sodium/crypto_auth_hmacsha512.h sodium/crypto_auth_hmacsha512256.h sodium/crypto_box.h sodium/crypto_box_curve25519xchacha20poly1305.h sodium/crypto_box_curve25519xsalsa20poly1305.h sodium/crypto_core_ed25519.h sodium/crypto_core_ristretto255.h sodium/crypto_core_hchacha20.h sodium/crypto_core_hsalsa20.h sodium/crypto_core_salsa20.h sodium/crypto_core_salsa2012.h sodium/crypto_core_salsa208.h sodium/crypto_generichash.h sodium/crypto_generichash_blake2b.h sodium/crypto_hash.h sodium/crypto_hash_sha256.h sodium/crypto_hash_sha512.h sodium/crypto_kdf.h sodium/crypto_kdf_blake2b.h sodium/crypto_kx.h sodium/crypto_onetimeauth.h sodium/crypto_onetimeauth_poly1305.h sodium/crypto_pwhash.h sodium/crypto_pwhash_argon2i.h sodium/crypto_pwhash_argon2id.h sodium/crypto_pwhash_scryptsalsa208sha256.h sodium/crypto_scalarmult.h sodium/crypto_scalarmult_curve25519.h sodium/crypto_scalarmult_ed25519.h sodium/crypto_scalarmult_ristretto255.h sodium/crypto_secretbox.h sodium/crypto_secretbox_xchacha20poly1305.h sodium/crypto_secretbox_xsalsa20poly1305.h sodium/crypto_secretstream_xchacha20poly1305.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/sodium'/usr/bin/install -c -m 644  sodium.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/.'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/sodium'/usr/bin/install -c -m 644  sodium/crypto_shorthash.h sodium/crypto_shorthash_siphash24.h sodium/crypto_sign.h sodium/crypto_sign_ed25519.h sodium/crypto_sign_edwards25519sha512batch.h sodium/crypto_stream.h sodium/crypto_stream_chacha20.h sodium/crypto_stream_salsa20.h sodium/crypto_stream_salsa2012.h sodium/crypto_stream_salsa208.h sodium/crypto_stream_xchacha20.h sodium/crypto_stream_xsalsa20.h sodium/crypto_verify_16.h sodium/crypto_verify_32.h sodium/crypto_verify_64.h sodium/export.h sodium/randombytes.h sodium/randombytes_internal_random.h sodium/randombytes_sysrandom.h sodium/runtime.h sodium/utils.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/include/sodium'make[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'CC       crypto_generichash/blake2b/ref/libssse3_la-blake2b-compress-ssse3.loCC       crypto_pwhash/argon2/libssse3_la-argon2-fill-block-ssse3.loCC       crypto_generichash/blake2b/ref/libsse41_la-blake2b-compress-sse41.loCC       crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.loCC       crypto_pwhash/argon2/libavx2_la-argon2-fill-block-avx2.loCC       crypto_stream/salsa20/xmm6int/libavx2_la-salsa20_xmm6int-avx2.loCC       crypto_pwhash/argon2/libavx512f_la-argon2-fill-block-avx512f.loCC       crypto_aead/chacha20poly1305/sodium/libsodium_la-aead_chacha20poly1305.loCC       crypto_aead/xchacha20poly1305/sodium/libsodium_la-aead_xchacha20poly1305.loCC       crypto_auth/libsodium_la-crypto_auth.loCC       crypto_auth/hmacsha256/libsodium_la-auth_hmacsha256.loCC       crypto_auth/hmacsha512/libsodium_la-auth_hmacsha512.loCC       crypto_auth/hmacsha512256/libsodium_la-auth_hmacsha512256.loCC       crypto_box/libsodium_la-crypto_box.loCC       crypto_box/libsodium_la-crypto_box_easy.loCC       crypto_box/libsodium_la-crypto_box_seal.loCC       crypto_box/curve25519xsalsa20poly1305/libsodium_la-box_curve25519xsalsa20poly1305.loCC       crypto_core/ed25519/ref10/libsodium_la-ed25519_ref10.loCC       crypto_core/hchacha20/libsodium_la-core_hchacha20.loCC       crypto_core/hsalsa20/ref2/libsodium_la-core_hsalsa20_ref2.loCC       crypto_core/hsalsa20/libsodium_la-core_hsalsa20.loCC       crypto_core/salsa/ref/libsodium_la-core_salsa_ref.loCC       crypto_generichash/libsodium_la-crypto_generichash.loCC       crypto_generichash/blake2b/libsodium_la-generichash_blake2.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-compress-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-generichash_blake2b.loCC       crypto_hash/libsodium_la-crypto_hash.loCC       crypto_hash/sha256/libsodium_la-hash_sha256.loCC       crypto_hash/sha256/cp/libsodium_la-hash_sha256_cp.loCC       crypto_hash/sha512/libsodium_la-hash_sha512.loCC       crypto_hash/sha512/cp/libsodium_la-hash_sha512_cp.loCC       crypto_kdf/blake2b/libsodium_la-kdf_blake2b.loCC       crypto_kdf/libsodium_la-crypto_kdf.loCC       crypto_kx/libsodium_la-crypto_kx.loCC       crypto_onetimeauth/libsodium_la-crypto_onetimeauth.loCC       crypto_onetimeauth/poly1305/libsodium_la-onetimeauth_poly1305.loCC       crypto_onetimeauth/poly1305/donna/libsodium_la-poly1305_donna.loCC       crypto_pwhash/argon2/libsodium_la-argon2-core.loCC       crypto_pwhash/argon2/libsodium_la-argon2-encoding.loCC       crypto_pwhash/argon2/libsodium_la-argon2-fill-block-ref.loCC       crypto_pwhash/argon2/libsodium_la-argon2.loCC       crypto_pwhash/argon2/libsodium_la-blake2b-long.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2i.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2id.loCC       crypto_pwhash/libsodium_la-crypto_pwhash.loCC       crypto_scalarmult/libsodium_la-crypto_scalarmult.loCC       crypto_scalarmult/curve25519/ref10/libsodium_la-x25519_ref10.loCC       crypto_scalarmult/curve25519/libsodium_la-scalarmult_curve25519.loCC       crypto_secretbox/libsodium_la-crypto_secretbox.loCC       crypto_secretbox/libsodium_la-crypto_secretbox_easy.loCC       crypto_secretbox/xsalsa20poly1305/libsodium_la-secretbox_xsalsa20poly1305.loCC       crypto_secretstream/xchacha20poly1305/libsodium_la-secretstream_xchacha20poly1305.loCC       crypto_shorthash/libsodium_la-crypto_shorthash.loCC       crypto_shorthash/siphash24/libsodium_la-shorthash_siphash24.loCC       crypto_shorthash/siphash24/ref/libsodium_la-shorthash_siphash24_ref.loCC       crypto_sign/libsodium_la-crypto_sign.loCC       crypto_sign/ed25519/libsodium_la-sign_ed25519.loCC       crypto_sign/ed25519/ref10/libsodium_la-keypair.loCC       crypto_sign/ed25519/ref10/libsodium_la-open.loCC       crypto_sign/ed25519/ref10/libsodium_la-sign.loCC       crypto_stream/chacha20/libsodium_la-stream_chacha20.loCC       crypto_stream/chacha20/ref/libsodium_la-chacha20_ref.loCC       crypto_stream/libsodium_la-crypto_stream.loCC       crypto_stream/salsa20/libsodium_la-stream_salsa20.loCC       crypto_stream/xsalsa20/libsodium_la-stream_xsalsa20.loCC       crypto_verify/sodium/libsodium_la-verify.loCC       randombytes/libsodium_la-randombytes.loCC       sodium/libsodium_la-codecs.loCC       sodium/libsodium_la-core.loCC       sodium/libsodium_la-runtime.loCC       sodium/libsodium_la-utils.loCC       sodium/libsodium_la-version.loCC       crypto_stream/salsa20/ref/libsodium_la-salsa20_ref.loCC       randombytes/sysrandom/libsodium_la-randombytes_sysrandom.loCC       crypto_aead/aes256gcm/aesni/libaesni_la-aead_aes256gcm_aesni.loCC       crypto_onetimeauth/poly1305/sse2/libsse2_la-poly1305_sse2.loCC       crypto_stream/salsa20/xmm6int/libsse2_la-salsa20_xmm6int-sse2.loCC       crypto_stream/chacha20/dolbeau/libssse3_la-chacha20_dolbeau-ssse3.loCCLD     libsse41.laCC       crypto_stream/chacha20/dolbeau/libavx2_la-chacha20_dolbeau-avx2.loCCLD     libavx512f.laCC       randombytes/internal/librdrand_la-randombytes_internal_random.loCCLD     libaesni.laCCLD     libsse2.laCCLD     libssse3.laCCLD     libavx2.laCCLD     librdrand.laCCLD     libsodium.lamake[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[4]: Nothing to be done for 'install-data-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib'/bin/bash ../../libtool   --mode=install /usr/bin/install -c   libsodium.la '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib'libtool: install: /usr/bin/install -c .libs/libsodium.so /home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/libsodium.solibtool: install: /usr/bin/install -c .libs/libsodium.lai /home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/libsodium.lalibtool: install: /usr/bin/install -c .libs/libsodium.a /home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/libsodium.alibtool: install: chmod 644 /home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/libsodium.alibtool: install: arm-linux-androideabi-ranlib /home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/libsodium.amake[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making install in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making install in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/pkgconfig'/usr/bin/install -c -m 644 libsodium.pc '/home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a/lib/pkgconfig'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'libsodium has been installed into /home/vagrant/build/srclib/libsodium/libsodium-android-armv7-a+ ./dist-build/android-armv8-a.shWarnings related to headers being present but not usable are due to functionsthat didn't exist in the specified minimum API version level.They can be safely ignored.Building for platform [android-21]WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that performthe same task. For example, instead of:$ python $NDK/build/tools/make_standalone_toolchain.py \--arch arm64 --api 21 --install-dir toolchain$ toolchain/bin/clang++ src.cppInstead use:$ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ src.cppchecking build system type... x86_64-pc-linux-gnuchecking host system type... aarch64-unknown-linux-androidchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for aarch64-linux-android-strip... aarch64-linux-android-stripchecking for a thread-safe mkdir -p... /bin/mkdir -pchecking for gawk... nochecking for mawk... mawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether UID '1000' is supported by ustar format... yeschecking whether GID '1000' is supported by ustar format... yeschecking how to create a ustar tar archive... gnutarchecking whether make supports nested variables... (cached) yeschecking whether to enable maintainer-specific portions of Makefiles... nochecking for style of include used by make... GNUchecking for aarch64-linux-android-gcc... aarch64-linux-android-clangchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... yeschecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether aarch64-linux-android-clang accepts -g... yeschecking for aarch64-linux-android-clang option to accept ISO C89... none neededchecking whether aarch64-linux-android-clang understands -c and -o together... yeschecking dependency style of aarch64-linux-android-clang... gcc3checking for a sed that does not truncate output... /bin/sedchecking how to run the C preprocessor... aarch64-linux-android-clang -Echecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking whether aarch64-linux-android-clang is Clang... yeschecking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... nochecking for joinable pthread attribute... PTHREAD_CREATE_JOINABLEchecking whether more special flags are required for pthreads... nochecking for PTHREAD_PRIO_INHERIT... yeschecking for aarch64-linux-android-clang option to accept ISO C99... none neededchecking dependency style of aarch64-linux-android-clang... gcc3checking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking minix/config.h usability... nochecking minix/config.h presence... nochecking for minix/config.h... nochecking whether it is safe to define __EXTENSIONS__... yeschecking for variable-length arrays... yeschecking for __wasi__ defined... nochecking for _FORTIFY_SOURCE defined... nochecking whether C compiler accepts -D_FORTIFY_SOURCE=2... yeschecking whether C compiler accepts -fvisibility=hidden... yeschecking whether C compiler accepts -fPIC... yeschecking whether C compiler accepts -fPIE... yeschecking whether the linker accepts -pie... yeschecking whether C compiler accepts -fno-strict-aliasing... yeschecking whether C compiler accepts -fno-strict-overflow... yeschecking whether C compiler accepts -fstack-protector... yeschecking whether the linker accepts -fstack-protector... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wall... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra... yeschecking for clang... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl... yeschecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl -Wwrite-strings... yeschecking whether the linker accepts -Wl,-z,relro... yeschecking whether the linker accepts -Wl,-z,now... yeschecking whether the linker accepts -Wl,-z,noexecstack... yeschecking whether segmentation violations can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, segmentation violations cannot be caught using signal handlers. This is expected if you enabled a tool such as Address Sanitizer (-fsanitize=address), but be aware that using Address Sanitizer may also significantly reduce performance.checking whether SIGABRT can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, SIGABRT cannot be caught using signal handlers.checking for thread local storage (TLS) class... _Thread_localthread local storage is supportedchecking whether C compiler accepts -ftls-model=local-dynamic... yeschecking how to print strings... printfchecking for a sed that does not truncate output... (cached) /bin/sedchecking for fgrep... /bin/grep -Fchecking for ld used by aarch64-linux-android-clang... /home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/aarch64-linux-android/bin/ldchecking if the linker (/home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/aarch64-linux-android/bin/ld) is GNU ld... yeschecking for BSD- or MS-compatible name lister (nm)... /home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/bin/aarch64-linux-android-nm -Bchecking the name lister (/home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/bin/aarch64-linux-android-nm -B) interface... BSD nmchecking whether ln -s works... yeschecking the maximum length of command line arguments... 1572864checking how to convert x86_64-pc-linux-gnu file names to aarch64-unknown-linux-android format... func_convert_file_noopchecking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noopchecking for /home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/aarch64-linux-android/bin/ld option to reload object files... -rchecking for aarch64-linux-android-objdump... aarch64-linux-android-objdumpchecking how to recognize dependent libraries... pass_allchecking for aarch64-linux-android-dlltool... nochecking for dlltool... nochecking how to associate runtime and link libraries... printf %s\nchecking for aarch64-linux-android-ar... aarch64-linux-android-archecking for archiver @FILE support... @checking for aarch64-linux-android-strip... (cached) aarch64-linux-android-stripchecking for aarch64-linux-android-ranlib... aarch64-linux-android-ranlibchecking command to parse /home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/bin/aarch64-linux-android-nm -B output from aarch64-linux-android-clang object... okchecking for sysroot... /home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/sysrootchecking for a working dd... /bin/ddchecking how to truncate binary pipes... /bin/dd bs=4096 count=1checking for aarch64-linux-android-mt... nochecking for mt... mtconfigure: WARNING: using cross tools not prefixed with host tripletchecking if mt is a manifest tool... nochecking for dlfcn.h... yeschecking for objdir... .libschecking if aarch64-linux-android-clang supports -fno-rtti -fno-exceptions... yeschecking for aarch64-linux-android-clang option to produce PIC... -fPIC -DPICchecking if aarch64-linux-android-clang PIC flag -fPIC -DPIC works... yeschecking if aarch64-linux-android-clang static flag -static works... nochecking if aarch64-linux-android-clang supports -c -o file.o... yeschecking if aarch64-linux-android-clang supports -c -o file.o... (cached) yeschecking whether the aarch64-linux-android-clang linker (/home/vagrant/build/srclib/libsodium/android-toolchain-armv8-a/aarch64-linux-android/bin/ld) supports shared libraries... yeschecking whether -lc should be explicitly linked in... nochecking dynamic linker characteristics... Android linkerchecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... yeschecking for aarch64-linux-android-ar... (cached) aarch64-linux-android-archecking whether C compiler accepts -mmmx... yeschecking for MMX instructions set... nochecking whether C compiler accepts -msse2... yeschecking for SSE2 instructions set... nochecking whether C compiler accepts -msse3... yeschecking for SSE3 instructions set... nochecking whether C compiler accepts -mssse3... yeschecking for SSSE3 instructions set... nochecking whether C compiler accepts -msse4.1... yeschecking for SSE4.1 instructions set... nochecking whether C compiler accepts -mavx... yeschecking for AVX instructions set... nochecking whether C compiler accepts -mavx2... yeschecking for AVX2 instructions set... nochecking whether C compiler accepts -mavx512f... yeschecking for AVX512F instructions set... nochecking whether C compiler accepts -Os -march=armv8-a -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -ftls-model=local-dynamic -mavx512f -mno-avx512f... yeschecking whether C compiler accepts -maes... yeschecking whether C compiler accepts -mpclmul... yeschecking for AESNI instructions set and PCLMULQDQ... nochecking whether C compiler accepts -mrdrnd... yeschecking for RDRAND... nochecking sys/mman.h usability... yeschecking sys/mman.h presence... yeschecking for sys/mman.h... yeschecking sys/random.h usability... yeschecking sys/random.h presence... yeschecking for sys/random.h... yeschecking intrin.h usability... nochecking intrin.h presence... nochecking for intrin.h... nochecking if _xgetbv() is available... nochecking for inline... inlinechecking whether byte ordering is bigendian... nochecking whether __STDC_LIMIT_MACROS is required... nochecking whether we can use inline asm code... yesnochecking whether we can use x86_64 asm code... nochecking whether we can assemble AVX opcodes... nochecking for 128-bit arithmetic... yeschecking for cpuid instruction... nochecking if the .private_extern asm directive is supported... nochecking if the .hidden asm directive is supported... yeschecking if weak symbols are supported... yeschecking if data alignment is required... yeschecking if atomic operations are supported... yeschecking for size_t... yeschecking for working alloca.h... yeschecking for alloca... yeschecking for arc4random... yeschecking for arc4random_buf... yeschecking for mmap... yeschecking for mlock... yeschecking for madvise... yeschecking for mprotect... yeschecking for getrandom with a standard API... nochecking for getentropy with a standard API... nochecking for posix_memalign... yeschecking for getpid... yeschecking for nanosleep... yeschecking for memset_s... nochecking for explicit_bzero... nochecking for explicit_memset... nochecking if gcc/ld supports -Wl,--output-def... nochecking that generated files are newer than configure... doneconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating builds/Makefileconfig.status: creating contrib/Makefileconfig.status: creating dist-build/Makefileconfig.status: creating libsodium.pcconfig.status: creating libsodium-uninstalled.pcconfig.status: creating msvc-scripts/Makefileconfig.status: creating src/Makefileconfig.status: creating src/libsodium/Makefileconfig.status: creating src/libsodium/include/Makefileconfig.status: creating src/libsodium/include/sodium/version.hconfig.status: creating test/default/Makefileconfig.status: creating test/Makefileconfig.status: executing depfiles commandsconfig.status: executing libtool commandsMaking clean in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making clean in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making clean in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making clean in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making clean in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making clean in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making clean in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'rm -rf .libs _libsrm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'test -z "" || rm -ftest -z "libsodium.la" || rm -f libsodium.larm -f ./so_locationsrm -rf .libs _libsrm -rf crypto_aead/aes256gcm/aesni/.libs crypto_aead/aes256gcm/aesni/_libsrm -rf crypto_aead/chacha20poly1305/sodium/.libs crypto_aead/chacha20poly1305/sodium/_libsrm -rf crypto_aead/xchacha20poly1305/sodium/.libs crypto_aead/xchacha20poly1305/sodium/_libsrm -rf crypto_auth/.libs crypto_auth/_libsrm -rf crypto_auth/hmacsha256/.libs crypto_auth/hmacsha256/_libsrm -rf crypto_auth/hmacsha512/.libs crypto_auth/hmacsha512/_libsrm -rf crypto_auth/hmacsha512256/.libs crypto_auth/hmacsha512256/_libsrm -rf crypto_box/.libs crypto_box/_libsrm -rf crypto_box/curve25519xchacha20poly1305/.libs crypto_box/curve25519xchacha20poly1305/_libsrm -rf crypto_box/curve25519xsalsa20poly1305/.libs crypto_box/curve25519xsalsa20poly1305/_libsrm -rf crypto_core/ed25519/.libs crypto_core/ed25519/_libsrm -rf crypto_core/ed25519/ref10/.libs crypto_core/ed25519/ref10/_libsrm -rf crypto_core/hchacha20/.libs crypto_core/hchacha20/_libsrm -rf crypto_core/hsalsa20/.libs crypto_core/hsalsa20/_libsrm -rf crypto_core/hsalsa20/ref2/.libs crypto_core/hsalsa20/ref2/_libsrm -rf crypto_core/salsa/ref/.libs crypto_core/salsa/ref/_libsrm -rf crypto_generichash/.libs crypto_generichash/_libsrm -rf crypto_generichash/blake2b/.libs crypto_generichash/blake2b/_libsrm -rf crypto_generichash/blake2b/ref/.libs crypto_generichash/blake2b/ref/_libsrm -rf crypto_hash/.libs crypto_hash/_libsrm -rf crypto_hash/sha256/.libs crypto_hash/sha256/_libsrm -rf crypto_hash/sha256/cp/.libs crypto_hash/sha256/cp/_libsrm -rf crypto_hash/sha512/.libs crypto_hash/sha512/_libsrm -rf crypto_hash/sha512/cp/.libs crypto_hash/sha512/cp/_libsrm -rf crypto_kdf/.libs crypto_kdf/_libsrm -rf crypto_kdf/blake2b/.libs crypto_kdf/blake2b/_libsrm -rf crypto_kx/.libs crypto_kx/_libsrm -rf crypto_onetimeauth/.libs crypto_onetimeauth/_libsrm -rf crypto_onetimeauth/poly1305/.libs crypto_onetimeauth/poly1305/_libsrm -rf crypto_onetimeauth/poly1305/donna/.libs crypto_onetimeauth/poly1305/donna/_libsrm -rf crypto_onetimeauth/poly1305/sse2/.libs crypto_onetimeauth/poly1305/sse2/_libsrm -rf crypto_pwhash/.libs crypto_pwhash/_libsrm -rf crypto_pwhash/argon2/.libs crypto_pwhash/argon2/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/.libs crypto_pwhash/scryptsalsa208sha256/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/nosse/.libs crypto_pwhash/scryptsalsa208sha256/nosse/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/sse/.libs crypto_pwhash/scryptsalsa208sha256/sse/_libsrm -rf crypto_scalarmult/.libs crypto_scalarmult/_libsrm -rf crypto_scalarmult/curve25519/.libs crypto_scalarmult/curve25519/_libsrm -rf crypto_scalarmult/curve25519/ref10/.libs crypto_scalarmult/curve25519/ref10/_libsrm -rf crypto_scalarmult/curve25519/sandy2x/.libs crypto_scalarmult/curve25519/sandy2x/_libsrm -rf crypto_scalarmult/ed25519/ref10/.libs crypto_scalarmult/ed25519/ref10/_libsrm -rf crypto_scalarmult/ristretto255/ref10/.libs crypto_scalarmult/ristretto255/ref10/_libsrm -rf crypto_secretbox/.libs crypto_secretbox/_libsrm -rf crypto_secretbox/xchacha20poly1305/.libs crypto_secretbox/xchacha20poly1305/_libsrm -rf crypto_secretbox/xsalsa20poly1305/.libs crypto_secretbox/xsalsa20poly1305/_libsrm -rf crypto_secretstream/xchacha20poly1305/.libs crypto_secretstream/xchacha20poly1305/_libsrm -rf crypto_shorthash/.libs crypto_shorthash/_libsrm -rf crypto_shorthash/siphash24/.libs crypto_shorthash/siphash24/_libsrm -rf crypto_shorthash/siphash24/ref/.libs crypto_shorthash/siphash24/ref/_libsrm -rf crypto_sign/.libs crypto_sign/_libsrm -rf crypto_sign/ed25519/.libs crypto_sign/ed25519/_libsrm -rf crypto_sign/ed25519/ref10/.libs crypto_sign/ed25519/ref10/_libsrm -rf crypto_stream/.libs crypto_stream/_libsrm -rf crypto_stream/chacha20/.libs crypto_stream/chacha20/_libsrm -rf crypto_stream/chacha20/dolbeau/.libs crypto_stream/chacha20/dolbeau/_libsrm -rf crypto_stream/chacha20/ref/.libs crypto_stream/chacha20/ref/_libsrm -rf crypto_stream/salsa20/.libs crypto_stream/salsa20/_libsrm -rf crypto_stream/salsa20/ref/.libs crypto_stream/salsa20/ref/_libsrm -rf crypto_stream/salsa20/xmm6/.libs crypto_stream/salsa20/xmm6/_libsrm -rf crypto_stream/salsa20/xmm6int/.libs crypto_stream/salsa20/xmm6int/_libsrm -rf crypto_stream/salsa2012/.libs crypto_stream/salsa2012/_libsrm -rf crypto_stream/salsa2012/ref/.libs crypto_stream/salsa2012/ref/_libsrm -rf crypto_stream/salsa208/.libs crypto_stream/salsa208/_libsrm -rf crypto_stream/salsa208/ref/.libs crypto_stream/salsa208/ref/_libsrm -rf crypto_stream/xchacha20/.libs crypto_stream/xchacha20/_libsrm -rf crypto_stream/xsalsa20/.libs crypto_stream/xsalsa20/_libsrm -rf crypto_verify/sodium/.libs crypto_verify/sodium/_libsrm -rf randombytes/.libs randombytes/_libsrm -rf randombytes/internal/.libs randombytes/internal/_libsrm -rf randombytes/sysrandom/.libs randombytes/sysrandom/_libsrm -rf sodium/.libs sodium/_libstest -z "libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.la" || rm -f libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.larm -f ./so_locationsrm -f *.orm -f crypto_aead/aes256gcm/aesni/*.orm -f crypto_aead/aes256gcm/aesni/*.lorm -f crypto_aead/chacha20poly1305/sodium/*.orm -f crypto_aead/chacha20poly1305/sodium/*.lorm -f crypto_aead/xchacha20poly1305/sodium/*.orm -f crypto_aead/xchacha20poly1305/sodium/*.lorm -f crypto_auth/*.orm -f crypto_auth/*.lorm -f crypto_auth/hmacsha256/*.orm -f crypto_auth/hmacsha256/*.lorm -f crypto_auth/hmacsha512/*.orm -f crypto_auth/hmacsha512/*.lorm -f crypto_auth/hmacsha512256/*.orm -f crypto_auth/hmacsha512256/*.lorm -f crypto_box/*.orm -f crypto_box/*.lorm -f crypto_box/curve25519xchacha20poly1305/*.orm -f crypto_box/curve25519xchacha20poly1305/*.lorm -f crypto_box/curve25519xsalsa20poly1305/*.orm -f crypto_box/curve25519xsalsa20poly1305/*.lorm -f crypto_core/ed25519/*.orm -f crypto_core/ed25519/*.lorm -f crypto_core/ed25519/ref10/*.orm -f crypto_core/ed25519/ref10/*.lorm -f crypto_core/hchacha20/*.orm -f crypto_core/hchacha20/*.lorm -f crypto_core/hsalsa20/*.orm -f crypto_core/hsalsa20/*.lorm -f crypto_core/hsalsa20/ref2/*.orm -f crypto_core/hsalsa20/ref2/*.lorm -f crypto_core/salsa/ref/*.orm -f crypto_core/salsa/ref/*.lorm -f crypto_generichash/*.orm -f crypto_generichash/*.lorm -f crypto_generichash/blake2b/*.orm -f crypto_generichash/blake2b/*.lorm -f crypto_generichash/blake2b/ref/*.orm -f crypto_generichash/blake2b/ref/*.lorm -f crypto_hash/*.orm -f crypto_hash/*.lorm -f crypto_hash/sha256/*.orm -f crypto_hash/sha256/*.lorm -f crypto_hash/sha256/cp/*.orm -f crypto_hash/sha256/cp/*.lorm -f crypto_hash/sha512/*.orm -f crypto_hash/sha512/*.lorm -f crypto_hash/sha512/cp/*.orm -f crypto_hash/sha512/cp/*.lorm -f crypto_kdf/*.orm -f crypto_kdf/*.lorm -f crypto_kdf/blake2b/*.orm -f crypto_kdf/blake2b/*.lorm -f crypto_kx/*.orm -f crypto_kx/*.lorm -f crypto_onetimeauth/*.orm -f crypto_onetimeauth/*.lorm -f crypto_onetimeauth/poly1305/*.orm -f crypto_onetimeauth/poly1305/*.lorm -f crypto_onetimeauth/poly1305/donna/*.orm -f crypto_onetimeauth/poly1305/donna/*.lorm -f crypto_onetimeauth/poly1305/sse2/*.orm -f crypto_onetimeauth/poly1305/sse2/*.lorm -f crypto_pwhash/*.orm -f crypto_pwhash/*.lorm -f crypto_pwhash/argon2/*.orm -f crypto_pwhash/argon2/*.lorm -f crypto_pwhash/scryptsalsa208sha256/*.orm -f crypto_pwhash/scryptsalsa208sha256/*.lorm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.orm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.lorm -f crypto_pwhash/scryptsalsa208sha256/sse/*.orm -f crypto_pwhash/scryptsalsa208sha256/sse/*.lorm -f crypto_scalarmult/*.orm -f crypto_scalarmult/*.lorm -f crypto_scalarmult/curve25519/*.orm -f crypto_scalarmult/curve25519/*.lorm -f crypto_scalarmult/curve25519/ref10/*.orm -f crypto_scalarmult/curve25519/ref10/*.lorm -f crypto_scalarmult/curve25519/sandy2x/*.orm -f crypto_scalarmult/curve25519/sandy2x/*.lorm -f crypto_scalarmult/ed25519/ref10/*.orm -f crypto_scalarmult/ed25519/ref10/*.lorm -f crypto_scalarmult/ristretto255/ref10/*.orm -f crypto_scalarmult/ristretto255/ref10/*.lorm -f crypto_secretbox/*.orm -f crypto_secretbox/*.lorm -f crypto_secretbox/xchacha20poly1305/*.orm -f crypto_secretbox/xchacha20poly1305/*.lorm -f crypto_secretbox/xsalsa20poly1305/*.orm -f crypto_secretbox/xsalsa20poly1305/*.lorm -f crypto_secretstream/xchacha20poly1305/*.orm -f crypto_secretstream/xchacha20poly1305/*.lorm -f crypto_shorthash/*.orm -f crypto_shorthash/*.lorm -f crypto_shorthash/siphash24/*.orm -f crypto_shorthash/siphash24/*.lorm -f crypto_shorthash/siphash24/ref/*.orm -f crypto_shorthash/siphash24/ref/*.lorm -f crypto_sign/*.orm -f crypto_sign/*.lorm -f crypto_sign/ed25519/*.orm -f crypto_sign/ed25519/*.lorm -f crypto_sign/ed25519/ref10/*.orm -f crypto_sign/ed25519/ref10/*.lorm -f crypto_stream/*.orm -f crypto_stream/*.lorm -f crypto_stream/chacha20/*.orm -f crypto_stream/chacha20/*.lorm -f crypto_stream/chacha20/dolbeau/*.orm -f crypto_stream/chacha20/dolbeau/*.lorm -f crypto_stream/chacha20/ref/*.orm -f crypto_stream/chacha20/ref/*.lorm -f crypto_stream/salsa20/*.orm -f crypto_stream/salsa20/*.lorm -f crypto_stream/salsa20/ref/*.orm -f crypto_stream/salsa20/ref/*.lorm -f crypto_stream/salsa20/xmm6/*.orm -f crypto_stream/salsa20/xmm6/*.lorm -f crypto_stream/salsa20/xmm6int/*.orm -f crypto_stream/salsa20/xmm6int/*.lorm -f crypto_stream/salsa2012/*.orm -f crypto_stream/salsa2012/*.lorm -f crypto_stream/salsa2012/ref/*.orm -f crypto_stream/salsa2012/ref/*.lorm -f crypto_stream/salsa208/*.orm -f crypto_stream/salsa208/*.lorm -f crypto_stream/salsa208/ref/*.orm -f crypto_stream/salsa208/ref/*.lorm -f crypto_stream/xchacha20/*.orm -f crypto_stream/xchacha20/*.lorm -f crypto_stream/xsalsa20/*.orm -f crypto_stream/xsalsa20/*.lorm -f crypto_verify/sodium/*.orm -f crypto_verify/sodium/*.lorm -f randombytes/*.orm -f randombytes/*.lorm -f randombytes/internal/*.orm -f randombytes/internal/*.lorm -f randombytes/sysrandom/*.orm -f randombytes/sysrandom/*.lorm -f sodium/*.orm -f sodium/*.lorm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making clean in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making clean in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'rm -f aead_aes256gcm aead_aes256gcm2 aead_chacha20poly1305 aead_chacha20poly13052 aead_xchacha20poly1305 auth auth2 auth3 auth5 auth6 auth7 box box2 box7 box8 box_easy box_easy2 box_seal box_seed chacha20 codecs core1 core2 core3 core4 core5 core6 ed25519_convert generichash generichash2 generichash3 hash hash3 kdf keygen kx metamorphic misuse onetimeauth onetimeauth2 onetimeauth7 pwhash_argon2i pwhash_argon2id randombytes scalarmult scalarmult2 scalarmult5 scalarmult6 scalarmult7 scalarmult8 secretbox secretbox2 secretbox7 secretbox8 secretbox_easy secretbox_easy2 secretstream shorthash sign sodium_core sodium_utils sodium_version stream stream2 stream3 stream4 verify1 sodium_utils2 sodium_utils3rm -rf .libs _libsrm -f *.otest -z "aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.log" || rm -f aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.logtest -z "aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trs" || rm -f aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trstest -z "test-suite.log" || rm -f test-suite.logrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'Making install in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making install in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making install in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making install in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making install in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making install in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making install in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/sodium'/usr/bin/install -c -m 644  sodium/version.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/sodium'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/sodium'/usr/bin/install -c -m 644  sodium/core.h sodium/crypto_aead_aes256gcm.h sodium/crypto_aead_chacha20poly1305.h sodium/crypto_aead_xchacha20poly1305.h sodium/crypto_auth.h sodium/crypto_auth_hmacsha256.h sodium/crypto_auth_hmacsha512.h sodium/crypto_auth_hmacsha512256.h sodium/crypto_box.h sodium/crypto_box_curve25519xchacha20poly1305.h sodium/crypto_box_curve25519xsalsa20poly1305.h sodium/crypto_core_ed25519.h sodium/crypto_core_ristretto255.h sodium/crypto_core_hchacha20.h sodium/crypto_core_hsalsa20.h sodium/crypto_core_salsa20.h sodium/crypto_core_salsa2012.h sodium/crypto_core_salsa208.h sodium/crypto_generichash.h sodium/crypto_generichash_blake2b.h sodium/crypto_hash.h sodium/crypto_hash_sha256.h sodium/crypto_hash_sha512.h sodium/crypto_kdf.h sodium/crypto_kdf_blake2b.h sodium/crypto_kx.h sodium/crypto_onetimeauth.h sodium/crypto_onetimeauth_poly1305.h sodium/crypto_pwhash.h sodium/crypto_pwhash_argon2i.h sodium/crypto_pwhash_argon2id.h sodium/crypto_pwhash_scryptsalsa208sha256.h sodium/crypto_scalarmult.h sodium/crypto_scalarmult_curve25519.h sodium/crypto_scalarmult_ed25519.h sodium/crypto_scalarmult_ristretto255.h sodium/crypto_secretbox.h sodium/crypto_secretbox_xchacha20poly1305.h sodium/crypto_secretbox_xsalsa20poly1305.h sodium/crypto_secretstream_xchacha20poly1305.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/sodium'/usr/bin/install -c -m 644  sodium.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/.'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/sodium'/usr/bin/install -c -m 644  sodium/crypto_shorthash.h sodium/crypto_shorthash_siphash24.h sodium/crypto_sign.h sodium/crypto_sign_ed25519.h sodium/crypto_sign_edwards25519sha512batch.h sodium/crypto_stream.h sodium/crypto_stream_chacha20.h sodium/crypto_stream_salsa20.h sodium/crypto_stream_salsa2012.h sodium/crypto_stream_salsa208.h sodium/crypto_stream_xchacha20.h sodium/crypto_stream_xsalsa20.h sodium/crypto_verify_16.h sodium/crypto_verify_32.h sodium/crypto_verify_64.h sodium/export.h sodium/randombytes.h sodium/randombytes_internal_random.h sodium/randombytes_sysrandom.h sodium/runtime.h sodium/utils.h '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/include/sodium'make[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'CC       crypto_aead/chacha20poly1305/sodium/libsodium_la-aead_chacha20poly1305.loCC       crypto_aead/xchacha20poly1305/sodium/libsodium_la-aead_xchacha20poly1305.loCC       crypto_auth/libsodium_la-crypto_auth.loCC       crypto_auth/hmacsha256/libsodium_la-auth_hmacsha256.loCC       crypto_auth/hmacsha512256/libsodium_la-auth_hmacsha512256.loCC       crypto_auth/hmacsha512/libsodium_la-auth_hmacsha512.loCC       crypto_box/libsodium_la-crypto_box.loCC       crypto_box/libsodium_la-crypto_box_easy.loCC       crypto_box/libsodium_la-crypto_box_seal.loCC       crypto_box/curve25519xsalsa20poly1305/libsodium_la-box_curve25519xsalsa20poly1305.loCC       crypto_core/ed25519/ref10/libsodium_la-ed25519_ref10.loCC       crypto_core/hchacha20/libsodium_la-core_hchacha20.loCC       crypto_core/hsalsa20/ref2/libsodium_la-core_hsalsa20_ref2.loCC       crypto_core/hsalsa20/libsodium_la-core_hsalsa20.loCC       crypto_core/salsa/ref/libsodium_la-core_salsa_ref.loCC       crypto_generichash/libsodium_la-crypto_generichash.loCC       crypto_generichash/blake2b/libsodium_la-generichash_blake2.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-compress-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-generichash_blake2b.loCC       crypto_hash/libsodium_la-crypto_hash.loCC       crypto_hash/sha256/libsodium_la-hash_sha256.loCC       crypto_hash/sha256/cp/libsodium_la-hash_sha256_cp.loCC       crypto_hash/sha512/libsodium_la-hash_sha512.loCC       crypto_hash/sha512/cp/libsodium_la-hash_sha512_cp.loCC       crypto_kdf/blake2b/libsodium_la-kdf_blake2b.loCC       crypto_kdf/libsodium_la-crypto_kdf.loCC       crypto_kx/libsodium_la-crypto_kx.loCC       crypto_onetimeauth/libsodium_la-crypto_onetimeauth.loCC       crypto_onetimeauth/poly1305/libsodium_la-onetimeauth_poly1305.loCC       crypto_onetimeauth/poly1305/donna/libsodium_la-poly1305_donna.loCC       crypto_pwhash/argon2/libsodium_la-argon2-core.loCC       crypto_pwhash/argon2/libsodium_la-argon2-encoding.loCC       crypto_pwhash/argon2/libsodium_la-argon2-fill-block-ref.loCC       crypto_pwhash/argon2/libsodium_la-argon2.loCC       crypto_pwhash/argon2/libsodium_la-blake2b-long.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2i.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2id.loCC       crypto_pwhash/libsodium_la-crypto_pwhash.loCC       crypto_scalarmult/libsodium_la-crypto_scalarmult.loCC       crypto_scalarmult/curve25519/ref10/libsodium_la-x25519_ref10.loCC       crypto_scalarmult/curve25519/libsodium_la-scalarmult_curve25519.loCC       crypto_secretbox/libsodium_la-crypto_secretbox.loCC       crypto_secretbox/libsodium_la-crypto_secretbox_easy.loCC       crypto_secretbox/xsalsa20poly1305/libsodium_la-secretbox_xsalsa20poly1305.loCC       crypto_secretstream/xchacha20poly1305/libsodium_la-secretstream_xchacha20poly1305.loCC       crypto_shorthash/libsodium_la-crypto_shorthash.loCC       crypto_shorthash/siphash24/libsodium_la-shorthash_siphash24.loCC       crypto_shorthash/siphash24/ref/libsodium_la-shorthash_siphash24_ref.loCC       crypto_sign/libsodium_la-crypto_sign.loCC       crypto_sign/ed25519/libsodium_la-sign_ed25519.loCC       crypto_sign/ed25519/ref10/libsodium_la-keypair.loCC       crypto_sign/ed25519/ref10/libsodium_la-open.loCC       crypto_sign/ed25519/ref10/libsodium_la-sign.loCC       crypto_stream/chacha20/libsodium_la-stream_chacha20.loCC       crypto_stream/chacha20/ref/libsodium_la-chacha20_ref.loCC       crypto_stream/libsodium_la-crypto_stream.loCC       crypto_stream/salsa20/libsodium_la-stream_salsa20.loCC       crypto_stream/xsalsa20/libsodium_la-stream_xsalsa20.loCC       crypto_verify/sodium/libsodium_la-verify.loCC       randombytes/libsodium_la-randombytes.loCC       sodium/libsodium_la-codecs.loCC       sodium/libsodium_la-core.loCC       sodium/libsodium_la-runtime.loCC       sodium/libsodium_la-utils.loCC       sodium/libsodium_la-version.loCC       crypto_stream/salsa20/ref/libsodium_la-salsa20_ref.loCC       randombytes/sysrandom/libsodium_la-randombytes_sysrandom.loCC       crypto_aead/aes256gcm/aesni/libaesni_la-aead_aes256gcm_aesni.loCC       crypto_onetimeauth/poly1305/sse2/libsse2_la-poly1305_sse2.loCC       crypto_stream/salsa20/xmm6int/libsse2_la-salsa20_xmm6int-sse2.loCC       crypto_generichash/blake2b/ref/libssse3_la-blake2b-compress-ssse3.loCC       crypto_pwhash/argon2/libssse3_la-argon2-fill-block-ssse3.loCC       crypto_stream/chacha20/dolbeau/libssse3_la-chacha20_dolbeau-ssse3.loCC       crypto_generichash/blake2b/ref/libsse41_la-blake2b-compress-sse41.loCC       crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.loCC       crypto_pwhash/argon2/libavx2_la-argon2-fill-block-avx2.loCC       crypto_stream/chacha20/dolbeau/libavx2_la-chacha20_dolbeau-avx2.loCC       crypto_stream/salsa20/xmm6int/libavx2_la-salsa20_xmm6int-avx2.loCC       crypto_pwhash/argon2/libavx512f_la-argon2-fill-block-avx512f.loCC       randombytes/internal/librdrand_la-randombytes_internal_random.loCCLD     libaesni.laCCLD     libsse2.laCCLD     libssse3.laCCLD     libsse41.laCCLD     libavx2.laCCLD     libavx512f.laCCLD     librdrand.laCCLD     libsodium.lamake[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[4]: Nothing to be done for 'install-data-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib'/bin/bash ../../libtool   --mode=install /usr/bin/install -c   libsodium.la '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib'libtool: install: /usr/bin/install -c .libs/libsodium.so /home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/libsodium.solibtool: install: /usr/bin/install -c .libs/libsodium.lai /home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/libsodium.lalibtool: install: /usr/bin/install -c .libs/libsodium.a /home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/libsodium.alibtool: install: chmod 644 /home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/libsodium.alibtool: install: aarch64-linux-android-ranlib /home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/libsodium.amake[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making install in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making install in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/pkgconfig'/usr/bin/install -c -m 644 libsodium.pc '/home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a/lib/pkgconfig'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'libsodium has been installed into /home/vagrant/build/srclib/libsodium/libsodium-android-armv8-a+ ./dist-build/android-x86.shWarnings related to headers being present but not usable are due to functionsthat didn't exist in the specified minimum API version level.They can be safely ignored.Building for platform [android-16]WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that performthe same task. For example, instead of:$ python $NDK/build/tools/make_standalone_toolchain.py \--arch x86 --api 16 --install-dir toolchain$ toolchain/bin/clang++ src.cppInstead use:$ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android16-clang++ src.cppchecking build system type... x86_64-pc-linux-gnux32checking host system type... i686-pc-linux-androidchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for i686-linux-android-strip... i686-linux-android-stripchecking for a thread-safe mkdir -p... /bin/mkdir -pchecking for gawk... nochecking for mawk... mawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether UID '1000' is supported by ustar format... yeschecking whether GID '1000' is supported by ustar format... yeschecking how to create a ustar tar archive... gnutarchecking whether make supports nested variables... (cached) yeschecking whether to enable maintainer-specific portions of Makefiles... nochecking for style of include used by make... GNUchecking for i686-linux-android-gcc... i686-linux-android-clangchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... yeschecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether i686-linux-android-clang accepts -g... yeschecking for i686-linux-android-clang option to accept ISO C89... none neededchecking whether i686-linux-android-clang understands -c and -o together... yeschecking dependency style of i686-linux-android-clang... gcc3checking for a sed that does not truncate output... /bin/sedchecking how to run the C preprocessor... i686-linux-android-clang -Echecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking whether i686-linux-android-clang is Clang... yeschecking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... nochecking for joinable pthread attribute... PTHREAD_CREATE_JOINABLEchecking whether more special flags are required for pthreads... nochecking for PTHREAD_PRIO_INHERIT... yeschecking for i686-linux-android-clang option to accept ISO C99... none neededchecking dependency style of i686-linux-android-clang... gcc3checking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking minix/config.h usability... nochecking minix/config.h presence... nochecking for minix/config.h... nochecking whether it is safe to define __EXTENSIONS__... yeschecking for variable-length arrays... yeschecking for __wasi__ defined... nochecking for _FORTIFY_SOURCE defined... nochecking whether C compiler accepts -D_FORTIFY_SOURCE=2... yeschecking whether C compiler accepts -fvisibility=hidden... yeschecking whether C compiler accepts -fPIC... yeschecking whether C compiler accepts -fPIE... yeschecking whether the linker accepts -pie... yeschecking whether C compiler accepts -fno-strict-aliasing... yeschecking whether C compiler accepts -fno-strict-overflow... yeschecking whether C compiler accepts -fstack-protector... yeschecking whether the linker accepts -fstack-protector... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wall... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra... yeschecking for clang... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl... yeschecking whether C compiler accepts -Os -march=i686 -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl -Wwrite-strings... yeschecking whether the linker accepts -Wl,-z,relro... yeschecking whether the linker accepts -Wl,-z,now... yeschecking whether the linker accepts -Wl,-z,noexecstack... yeschecking whether segmentation violations can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, segmentation violations cannot be caught using signal handlers. This is expected if you enabled a tool such as Address Sanitizer (-fsanitize=address), but be aware that using Address Sanitizer may also significantly reduce performance.checking whether SIGABRT can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, SIGABRT cannot be caught using signal handlers.checking for thread local storage (TLS) class... _Thread_localthread local storage is supportedchecking whether C compiler accepts -ftls-model=local-dynamic... yeschecking how to print strings... printfchecking for a sed that does not truncate output... (cached) /bin/sedchecking for fgrep... /bin/grep -Fchecking for ld used by i686-linux-android-clang... /home/vagrant/build/srclib/libsodium/android-toolchain-i686/i686-linux-android/bin/ldchecking if the linker (/home/vagrant/build/srclib/libsodium/android-toolchain-i686/i686-linux-android/bin/ld) is GNU ld... yeschecking for BSD- or MS-compatible name lister (nm)... /home/vagrant/build/srclib/libsodium/android-toolchain-i686/bin/i686-linux-android-nm -Bchecking the name lister (/home/vagrant/build/srclib/libsodium/android-toolchain-i686/bin/i686-linux-android-nm -B) interface... BSD nmchecking whether ln -s works... yeschecking the maximum length of command line arguments... 1572864checking how to convert x86_64-pc-linux-gnux32 file names to i686-pc-linux-android format... func_convert_file_noopchecking how to convert x86_64-pc-linux-gnux32 file names to toolchain format... func_convert_file_noopchecking for /home/vagrant/build/srclib/libsodium/android-toolchain-i686/i686-linux-android/bin/ld option to reload object files... -rchecking for i686-linux-android-objdump... i686-linux-android-objdumpchecking how to recognize dependent libraries... pass_allchecking for i686-linux-android-dlltool... nochecking for dlltool... nochecking how to associate runtime and link libraries... printf %s\nchecking for i686-linux-android-ar... i686-linux-android-archecking for archiver @FILE support... @checking for i686-linux-android-strip... (cached) i686-linux-android-stripchecking for i686-linux-android-ranlib... i686-linux-android-ranlibchecking command to parse /home/vagrant/build/srclib/libsodium/android-toolchain-i686/bin/i686-linux-android-nm -B output from i686-linux-android-clang object... okchecking for sysroot... /home/vagrant/build/srclib/libsodium/android-toolchain-i686/sysrootchecking for a working dd... /bin/ddchecking how to truncate binary pipes... /bin/dd bs=4096 count=1checking for i686-linux-android-mt... nochecking for mt... mtconfigure: WARNING: using cross tools not prefixed with host tripletchecking if mt is a manifest tool... nochecking for dlfcn.h... yeschecking for objdir... .libschecking if i686-linux-android-clang supports -fno-rtti -fno-exceptions... yeschecking for i686-linux-android-clang option to produce PIC... -fPIC -DPICchecking if i686-linux-android-clang PIC flag -fPIC -DPIC works... yeschecking if i686-linux-android-clang static flag -static works... nochecking if i686-linux-android-clang supports -c -o file.o... yeschecking if i686-linux-android-clang supports -c -o file.o... (cached) yeschecking whether the i686-linux-android-clang linker (/home/vagrant/build/srclib/libsodium/android-toolchain-i686/i686-linux-android/bin/ld) supports shared libraries... yeschecking whether -lc should be explicitly linked in... nochecking dynamic linker characteristics... Android linkerchecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... yeschecking for i686-linux-android-ar... (cached) i686-linux-android-archecking whether C compiler accepts -mmmx... yeschecking for MMX instructions set... yeschecking whether C compiler accepts -mmmx... (cached) yeschecking whether C compiler accepts -msse2... yeschecking for SSE2 instructions set... yeschecking whether C compiler accepts -msse2... (cached) yeschecking whether C compiler accepts -msse3... yeschecking for SSE3 instructions set... yeschecking whether C compiler accepts -msse3... (cached) yeschecking whether C compiler accepts -mssse3... yeschecking for SSSE3 instructions set... yeschecking whether C compiler accepts -mssse3... (cached) yeschecking whether C compiler accepts -msse4.1... yeschecking for SSE4.1 instructions set... yeschecking whether C compiler accepts -msse4.1... (cached) yeschecking whether C compiler accepts -mavx... yeschecking for AVX instructions set... yeschecking whether C compiler accepts -mavx... (cached) yeschecking whether C compiler accepts -mavx2... yeschecking for AVX2 instructions set... yeschecking whether C compiler accepts -mavx2... (cached) yeschecking if _mm256_broadcastsi128_si256 is correctly defined... yeschecking whether C compiler accepts -mavx512f... yeschecking for AVX512F instructions set... yeschecking whether C compiler accepts -mavx512f... (cached) yeschecking whether C compiler accepts -maes... yeschecking whether C compiler accepts -mpclmul... yeschecking for AESNI instructions set and PCLMULQDQ... yeschecking whether C compiler accepts -maes... (cached) yeschecking whether C compiler accepts -mpclmul... (cached) yeschecking whether C compiler accepts -mrdrnd... yeschecking for RDRAND... yeschecking whether C compiler accepts -mrdrnd... (cached) yeschecking sys/mman.h usability... yeschecking sys/mman.h presence... yeschecking for sys/mman.h... yeschecking sys/random.h usability... yeschecking sys/random.h presence... yeschecking for sys/random.h... yeschecking intrin.h usability... nochecking intrin.h presence... nochecking for intrin.h... nochecking if _xgetbv() is available... nochecking for inline... inlinechecking whether byte ordering is bigendian... (cached) nochecking whether __STDC_LIMIT_MACROS is required... nochecking whether we can use inline asm code... yesnochecking whether we can use x86_64 asm code... nochecking whether we can assemble AVX opcodes... nochecking for 128-bit arithmetic... nochecking for cpuid instruction... yeschecking if the .private_extern asm directive is supported... nochecking if the .hidden asm directive is supported... yeschecking if weak symbols are supported... yeschecking if data alignment is required... nochecking if atomic operations are supported... yeschecking for size_t... yeschecking for working alloca.h... yeschecking for alloca... yeschecking for arc4random... yeschecking for arc4random_buf... yeschecking for mmap... yeschecking for mlock... yeschecking for madvise... yeschecking for mprotect... yeschecking for getrandom with a standard API... nochecking for getentropy with a standard API... nochecking for posix_memalign... nochecking for getpid... yeschecking for nanosleep... yeschecking for memset_s... nochecking for explicit_bzero... nochecking for explicit_memset... nochecking if gcc/ld supports -Wl,--output-def... nochecking that generated files are newer than configure... doneconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating builds/Makefileconfig.status: creating contrib/Makefileconfig.status: creating dist-build/Makefileconfig.status: creating libsodium.pcconfig.status: creating libsodium-uninstalled.pcconfig.status: creating msvc-scripts/Makefileconfig.status: creating src/Makefileconfig.status: creating src/libsodium/Makefileconfig.status: creating src/libsodium/include/Makefileconfig.status: creating src/libsodium/include/sodium/version.hconfig.status: creating test/default/Makefileconfig.status: creating test/Makefileconfig.status: executing depfiles commandsconfig.status: executing libtool commandsMaking clean in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making clean in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making clean in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making clean in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making clean in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making clean in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making clean in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'rm -rf .libs _libsrm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'test -z "" || rm -ftest -z "libsodium.la" || rm -f libsodium.larm -f ./so_locationsrm -rf .libs _libsrm -rf crypto_aead/aes256gcm/aesni/.libs crypto_aead/aes256gcm/aesni/_libsrm -rf crypto_aead/chacha20poly1305/sodium/.libs crypto_aead/chacha20poly1305/sodium/_libsrm -rf crypto_aead/xchacha20poly1305/sodium/.libs crypto_aead/xchacha20poly1305/sodium/_libsrm -rf crypto_auth/.libs crypto_auth/_libsrm -rf crypto_auth/hmacsha256/.libs crypto_auth/hmacsha256/_libsrm -rf crypto_auth/hmacsha512/.libs crypto_auth/hmacsha512/_libsrm -rf crypto_auth/hmacsha512256/.libs crypto_auth/hmacsha512256/_libsrm -rf crypto_box/.libs crypto_box/_libsrm -rf crypto_box/curve25519xchacha20poly1305/.libs crypto_box/curve25519xchacha20poly1305/_libsrm -rf crypto_box/curve25519xsalsa20poly1305/.libs crypto_box/curve25519xsalsa20poly1305/_libsrm -rf crypto_core/ed25519/.libs crypto_core/ed25519/_libsrm -rf crypto_core/ed25519/ref10/.libs crypto_core/ed25519/ref10/_libsrm -rf crypto_core/hchacha20/.libs crypto_core/hchacha20/_libsrm -rf crypto_core/hsalsa20/.libs crypto_core/hsalsa20/_libsrm -rf crypto_core/hsalsa20/ref2/.libs crypto_core/hsalsa20/ref2/_libsrm -rf crypto_core/salsa/ref/.libs crypto_core/salsa/ref/_libsrm -rf crypto_generichash/.libs crypto_generichash/_libsrm -rf crypto_generichash/blake2b/.libs crypto_generichash/blake2b/_libsrm -rf crypto_generichash/blake2b/ref/.libs crypto_generichash/blake2b/ref/_libsrm -rf crypto_hash/.libs crypto_hash/_libsrm -rf crypto_hash/sha256/.libs crypto_hash/sha256/_libsrm -rf crypto_hash/sha256/cp/.libs crypto_hash/sha256/cp/_libsrm -rf crypto_hash/sha512/.libs crypto_hash/sha512/_libsrm -rf crypto_hash/sha512/cp/.libs crypto_hash/sha512/cp/_libsrm -rf crypto_kdf/.libs crypto_kdf/_libsrm -rf crypto_kdf/blake2b/.libs crypto_kdf/blake2b/_libsrm -rf crypto_kx/.libs crypto_kx/_libsrm -rf crypto_onetimeauth/.libs crypto_onetimeauth/_libsrm -rf crypto_onetimeauth/poly1305/.libs crypto_onetimeauth/poly1305/_libsrm -rf crypto_onetimeauth/poly1305/donna/.libs crypto_onetimeauth/poly1305/donna/_libsrm -rf crypto_onetimeauth/poly1305/sse2/.libs crypto_onetimeauth/poly1305/sse2/_libsrm -rf crypto_pwhash/.libs crypto_pwhash/_libsrm -rf crypto_pwhash/argon2/.libs crypto_pwhash/argon2/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/.libs crypto_pwhash/scryptsalsa208sha256/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/nosse/.libs crypto_pwhash/scryptsalsa208sha256/nosse/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/sse/.libs crypto_pwhash/scryptsalsa208sha256/sse/_libsrm -rf crypto_scalarmult/.libs crypto_scalarmult/_libsrm -rf crypto_scalarmult/curve25519/.libs crypto_scalarmult/curve25519/_libsrm -rf crypto_scalarmult/curve25519/ref10/.libs crypto_scalarmult/curve25519/ref10/_libsrm -rf crypto_scalarmult/curve25519/sandy2x/.libs crypto_scalarmult/curve25519/sandy2x/_libsrm -rf crypto_scalarmult/ed25519/ref10/.libs crypto_scalarmult/ed25519/ref10/_libsrm -rf crypto_scalarmult/ristretto255/ref10/.libs crypto_scalarmult/ristretto255/ref10/_libsrm -rf crypto_secretbox/.libs crypto_secretbox/_libsrm -rf crypto_secretbox/xchacha20poly1305/.libs crypto_secretbox/xchacha20poly1305/_libsrm -rf crypto_secretbox/xsalsa20poly1305/.libs crypto_secretbox/xsalsa20poly1305/_libsrm -rf crypto_secretstream/xchacha20poly1305/.libs crypto_secretstream/xchacha20poly1305/_libsrm -rf crypto_shorthash/.libs crypto_shorthash/_libsrm -rf crypto_shorthash/siphash24/.libs crypto_shorthash/siphash24/_libsrm -rf crypto_shorthash/siphash24/ref/.libs crypto_shorthash/siphash24/ref/_libsrm -rf crypto_sign/.libs crypto_sign/_libsrm -rf crypto_sign/ed25519/.libs crypto_sign/ed25519/_libsrm -rf crypto_sign/ed25519/ref10/.libs crypto_sign/ed25519/ref10/_libsrm -rf crypto_stream/.libs crypto_stream/_libsrm -rf crypto_stream/chacha20/.libs crypto_stream/chacha20/_libsrm -rf crypto_stream/chacha20/dolbeau/.libs crypto_stream/chacha20/dolbeau/_libsrm -rf crypto_stream/chacha20/ref/.libs crypto_stream/chacha20/ref/_libsrm -rf crypto_stream/salsa20/.libs crypto_stream/salsa20/_libsrm -rf crypto_stream/salsa20/ref/.libs crypto_stream/salsa20/ref/_libsrm -rf crypto_stream/salsa20/xmm6/.libs crypto_stream/salsa20/xmm6/_libsrm -rf crypto_stream/salsa20/xmm6int/.libs crypto_stream/salsa20/xmm6int/_libsrm -rf crypto_stream/salsa2012/.libs crypto_stream/salsa2012/_libsrm -rf crypto_stream/salsa2012/ref/.libs crypto_stream/salsa2012/ref/_libsrm -rf crypto_stream/salsa208/.libs crypto_stream/salsa208/_libsrm -rf crypto_stream/salsa208/ref/.libs crypto_stream/salsa208/ref/_libsrm -rf crypto_stream/xchacha20/.libs crypto_stream/xchacha20/_libsrm -rf crypto_stream/xsalsa20/.libs crypto_stream/xsalsa20/_libsrm -rf crypto_verify/sodium/.libs crypto_verify/sodium/_libsrm -rf randombytes/.libs randombytes/_libsrm -rf randombytes/internal/.libs randombytes/internal/_libsrm -rf randombytes/sysrandom/.libs randombytes/sysrandom/_libsrm -rf sodium/.libs sodium/_libstest -z "libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.la" || rm -f libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.larm -f ./so_locationsrm -f *.orm -f crypto_aead/aes256gcm/aesni/*.orm -f crypto_aead/aes256gcm/aesni/*.lorm -f crypto_aead/chacha20poly1305/sodium/*.orm -f crypto_aead/chacha20poly1305/sodium/*.lorm -f crypto_aead/xchacha20poly1305/sodium/*.orm -f crypto_aead/xchacha20poly1305/sodium/*.lorm -f crypto_auth/*.orm -f crypto_auth/*.lorm -f crypto_auth/hmacsha256/*.orm -f crypto_auth/hmacsha256/*.lorm -f crypto_auth/hmacsha512/*.orm -f crypto_auth/hmacsha512/*.lorm -f crypto_auth/hmacsha512256/*.orm -f crypto_auth/hmacsha512256/*.lorm -f crypto_box/*.orm -f crypto_box/*.lorm -f crypto_box/curve25519xchacha20poly1305/*.orm -f crypto_box/curve25519xchacha20poly1305/*.lorm -f crypto_box/curve25519xsalsa20poly1305/*.orm -f crypto_box/curve25519xsalsa20poly1305/*.lorm -f crypto_core/ed25519/*.orm -f crypto_core/ed25519/*.lorm -f crypto_core/ed25519/ref10/*.orm -f crypto_core/ed25519/ref10/*.lorm -f crypto_core/hchacha20/*.orm -f crypto_core/hchacha20/*.lorm -f crypto_core/hsalsa20/*.orm -f crypto_core/hsalsa20/*.lorm -f crypto_core/hsalsa20/ref2/*.orm -f crypto_core/hsalsa20/ref2/*.lorm -f crypto_core/salsa/ref/*.orm -f crypto_core/salsa/ref/*.lorm -f crypto_generichash/*.orm -f crypto_generichash/*.lorm -f crypto_generichash/blake2b/*.orm -f crypto_generichash/blake2b/*.lorm -f crypto_generichash/blake2b/ref/*.orm -f crypto_generichash/blake2b/ref/*.lorm -f crypto_hash/*.orm -f crypto_hash/*.lorm -f crypto_hash/sha256/*.orm -f crypto_hash/sha256/*.lorm -f crypto_hash/sha256/cp/*.orm -f crypto_hash/sha256/cp/*.lorm -f crypto_hash/sha512/*.orm -f crypto_hash/sha512/*.lorm -f crypto_hash/sha512/cp/*.orm -f crypto_hash/sha512/cp/*.lorm -f crypto_kdf/*.orm -f crypto_kdf/*.lorm -f crypto_kdf/blake2b/*.orm -f crypto_kdf/blake2b/*.lorm -f crypto_kx/*.orm -f crypto_kx/*.lorm -f crypto_onetimeauth/*.orm -f crypto_onetimeauth/*.lorm -f crypto_onetimeauth/poly1305/*.orm -f crypto_onetimeauth/poly1305/*.lorm -f crypto_onetimeauth/poly1305/donna/*.orm -f crypto_onetimeauth/poly1305/donna/*.lorm -f crypto_onetimeauth/poly1305/sse2/*.orm -f crypto_onetimeauth/poly1305/sse2/*.lorm -f crypto_pwhash/*.orm -f crypto_pwhash/*.lorm -f crypto_pwhash/argon2/*.orm -f crypto_pwhash/argon2/*.lorm -f crypto_pwhash/scryptsalsa208sha256/*.orm -f crypto_pwhash/scryptsalsa208sha256/*.lorm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.orm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.lorm -f crypto_pwhash/scryptsalsa208sha256/sse/*.orm -f crypto_pwhash/scryptsalsa208sha256/sse/*.lorm -f crypto_scalarmult/*.orm -f crypto_scalarmult/*.lorm -f crypto_scalarmult/curve25519/*.orm -f crypto_scalarmult/curve25519/*.lorm -f crypto_scalarmult/curve25519/ref10/*.orm -f crypto_scalarmult/curve25519/ref10/*.lorm -f crypto_scalarmult/curve25519/sandy2x/*.orm -f crypto_scalarmult/curve25519/sandy2x/*.lorm -f crypto_scalarmult/ed25519/ref10/*.orm -f crypto_scalarmult/ed25519/ref10/*.lorm -f crypto_scalarmult/ristretto255/ref10/*.orm -f crypto_scalarmult/ristretto255/ref10/*.lorm -f crypto_secretbox/*.orm -f crypto_secretbox/*.lorm -f crypto_secretbox/xchacha20poly1305/*.orm -f crypto_secretbox/xchacha20poly1305/*.lorm -f crypto_secretbox/xsalsa20poly1305/*.orm -f crypto_secretbox/xsalsa20poly1305/*.lorm -f crypto_secretstream/xchacha20poly1305/*.orm -f crypto_secretstream/xchacha20poly1305/*.lorm -f crypto_shorthash/*.orm -f crypto_shorthash/*.lorm -f crypto_shorthash/siphash24/*.orm -f crypto_shorthash/siphash24/*.lorm -f crypto_shorthash/siphash24/ref/*.orm -f crypto_shorthash/siphash24/ref/*.lorm -f crypto_sign/*.orm -f crypto_sign/*.lorm -f crypto_sign/ed25519/*.orm -f crypto_sign/ed25519/*.lorm -f crypto_sign/ed25519/ref10/*.orm -f crypto_sign/ed25519/ref10/*.lorm -f crypto_stream/*.orm -f crypto_stream/*.lorm -f crypto_stream/chacha20/*.orm -f crypto_stream/chacha20/*.lorm -f crypto_stream/chacha20/dolbeau/*.orm -f crypto_stream/chacha20/dolbeau/*.lorm -f crypto_stream/chacha20/ref/*.orm -f crypto_stream/chacha20/ref/*.lorm -f crypto_stream/salsa20/*.orm -f crypto_stream/salsa20/*.lorm -f crypto_stream/salsa20/ref/*.orm -f crypto_stream/salsa20/ref/*.lorm -f crypto_stream/salsa20/xmm6/*.orm -f crypto_stream/salsa20/xmm6/*.lorm -f crypto_stream/salsa20/xmm6int/*.orm -f crypto_stream/salsa20/xmm6int/*.lorm -f crypto_stream/salsa2012/*.orm -f crypto_stream/salsa2012/*.lorm -f crypto_stream/salsa2012/ref/*.orm -f crypto_stream/salsa2012/ref/*.lorm -f crypto_stream/salsa208/*.orm -f crypto_stream/salsa208/*.lorm -f crypto_stream/salsa208/ref/*.orm -f crypto_stream/salsa208/ref/*.lorm -f crypto_stream/xchacha20/*.orm -f crypto_stream/xchacha20/*.lorm -f crypto_stream/xsalsa20/*.orm -f crypto_stream/xsalsa20/*.lorm -f crypto_verify/sodium/*.orm -f crypto_verify/sodium/*.lorm -f randombytes/*.orm -f randombytes/*.lorm -f randombytes/internal/*.orm -f randombytes/internal/*.lorm -f randombytes/sysrandom/*.orm -f randombytes/sysrandom/*.lorm -f sodium/*.orm -f sodium/*.lorm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making clean in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making clean in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'rm -f aead_aes256gcm aead_aes256gcm2 aead_chacha20poly1305 aead_chacha20poly13052 aead_xchacha20poly1305 auth auth2 auth3 auth5 auth6 auth7 box box2 box7 box8 box_easy box_easy2 box_seal box_seed chacha20 codecs core1 core2 core3 core4 core5 core6 ed25519_convert generichash generichash2 generichash3 hash hash3 kdf keygen kx metamorphic misuse onetimeauth onetimeauth2 onetimeauth7 pwhash_argon2i pwhash_argon2id randombytes scalarmult scalarmult2 scalarmult5 scalarmult6 scalarmult7 scalarmult8 secretbox secretbox2 secretbox7 secretbox8 secretbox_easy secretbox_easy2 secretstream shorthash sign sodium_core sodium_utils sodium_version stream stream2 stream3 stream4 verify1 sodium_utils2 sodium_utils3rm -rf .libs _libsrm -f *.otest -z "aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.log" || rm -f aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.logtest -z "aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trs" || rm -f aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trstest -z "test-suite.log" || rm -f test-suite.logrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'Making install in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making install in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making install in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making install in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making install in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making install in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making install in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/sodium'/usr/bin/install -c -m 644  sodium/version.h '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/sodium'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/sodium'/usr/bin/install -c -m 644  sodium/core.h sodium/crypto_aead_aes256gcm.h sodium/crypto_aead_chacha20poly1305.h sodium/crypto_aead_xchacha20poly1305.h sodium/crypto_auth.h sodium/crypto_auth_hmacsha256.h sodium/crypto_auth_hmacsha512.h sodium/crypto_auth_hmacsha512256.h sodium/crypto_box.h sodium/crypto_box_curve25519xchacha20poly1305.h sodium/crypto_box_curve25519xsalsa20poly1305.h sodium/crypto_core_ed25519.h sodium/crypto_core_ristretto255.h sodium/crypto_core_hchacha20.h sodium/crypto_core_hsalsa20.h sodium/crypto_core_salsa20.h sodium/crypto_core_salsa2012.h sodium/crypto_core_salsa208.h sodium/crypto_generichash.h sodium/crypto_generichash_blake2b.h sodium/crypto_hash.h sodium/crypto_hash_sha256.h sodium/crypto_hash_sha512.h sodium/crypto_kdf.h sodium/crypto_kdf_blake2b.h sodium/crypto_kx.h sodium/crypto_onetimeauth.h sodium/crypto_onetimeauth_poly1305.h sodium/crypto_pwhash.h sodium/crypto_pwhash_argon2i.h sodium/crypto_pwhash_argon2id.h sodium/crypto_pwhash_scryptsalsa208sha256.h sodium/crypto_scalarmult.h sodium/crypto_scalarmult_curve25519.h sodium/crypto_scalarmult_ed25519.h sodium/crypto_scalarmult_ristretto255.h sodium/crypto_secretbox.h sodium/crypto_secretbox_xchacha20poly1305.h sodium/crypto_secretbox_xsalsa20poly1305.h sodium/crypto_secretstream_xchacha20poly1305.h '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/sodium'/usr/bin/install -c -m 644  sodium.h '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/.'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/sodium'/usr/bin/install -c -m 644  sodium/crypto_shorthash.h sodium/crypto_shorthash_siphash24.h sodium/crypto_sign.h sodium/crypto_sign_ed25519.h sodium/crypto_sign_edwards25519sha512batch.h sodium/crypto_stream.h sodium/crypto_stream_chacha20.h sodium/crypto_stream_salsa20.h sodium/crypto_stream_salsa2012.h sodium/crypto_stream_salsa208.h sodium/crypto_stream_xchacha20.h sodium/crypto_stream_xsalsa20.h sodium/crypto_verify_16.h sodium/crypto_verify_32.h sodium/crypto_verify_64.h sodium/export.h sodium/randombytes.h sodium/randombytes_internal_random.h sodium/randombytes_sysrandom.h sodium/runtime.h sodium/utils.h '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/include/sodium'make[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'CC       crypto_aead/chacha20poly1305/sodium/libsodium_la-aead_chacha20poly1305.loCC       crypto_aead/xchacha20poly1305/sodium/libsodium_la-aead_xchacha20poly1305.loCC       crypto_auth/libsodium_la-crypto_auth.loCC       crypto_auth/hmacsha256/libsodium_la-auth_hmacsha256.loCC       crypto_auth/hmacsha512/libsodium_la-auth_hmacsha512.loCC       crypto_auth/hmacsha512256/libsodium_la-auth_hmacsha512256.loCC       crypto_box/libsodium_la-crypto_box.loCC       crypto_box/libsodium_la-crypto_box_easy.loCC       crypto_box/libsodium_la-crypto_box_seal.loCC       crypto_box/curve25519xsalsa20poly1305/libsodium_la-box_curve25519xsalsa20poly1305.loCC       crypto_core/ed25519/ref10/libsodium_la-ed25519_ref10.loCC       crypto_core/hchacha20/libsodium_la-core_hchacha20.loCC       crypto_core/hsalsa20/ref2/libsodium_la-core_hsalsa20_ref2.loCC       crypto_core/hsalsa20/libsodium_la-core_hsalsa20.loCC       crypto_core/salsa/ref/libsodium_la-core_salsa_ref.loCC       crypto_generichash/libsodium_la-crypto_generichash.loCC       crypto_generichash/blake2b/libsodium_la-generichash_blake2.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-compress-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-generichash_blake2b.loCC       crypto_hash/libsodium_la-crypto_hash.loCC       crypto_hash/sha256/libsodium_la-hash_sha256.loCC       crypto_hash/sha256/cp/libsodium_la-hash_sha256_cp.loCC       crypto_hash/sha512/libsodium_la-hash_sha512.loCC       crypto_hash/sha512/cp/libsodium_la-hash_sha512_cp.loCC       crypto_kdf/blake2b/libsodium_la-kdf_blake2b.loCC       crypto_kdf/libsodium_la-crypto_kdf.loCC       crypto_kx/libsodium_la-crypto_kx.loCC       crypto_onetimeauth/libsodium_la-crypto_onetimeauth.loCC       crypto_onetimeauth/poly1305/libsodium_la-onetimeauth_poly1305.loCC       crypto_onetimeauth/poly1305/donna/libsodium_la-poly1305_donna.loCC       crypto_pwhash/argon2/libsodium_la-argon2-core.loCC       crypto_pwhash/argon2/libsodium_la-argon2-encoding.loCC       crypto_pwhash/argon2/libsodium_la-argon2-fill-block-ref.loCC       crypto_pwhash/argon2/libsodium_la-argon2.loCC       crypto_pwhash/argon2/libsodium_la-blake2b-long.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2i.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2id.loCC       crypto_pwhash/libsodium_la-crypto_pwhash.loCC       crypto_scalarmult/libsodium_la-crypto_scalarmult.loCC       crypto_scalarmult/curve25519/ref10/libsodium_la-x25519_ref10.loCC       crypto_scalarmult/curve25519/libsodium_la-scalarmult_curve25519.loCC       crypto_secretbox/libsodium_la-crypto_secretbox.loCC       crypto_secretbox/libsodium_la-crypto_secretbox_easy.loCC       crypto_secretbox/xsalsa20poly1305/libsodium_la-secretbox_xsalsa20poly1305.loCC       crypto_secretstream/xchacha20poly1305/libsodium_la-secretstream_xchacha20poly1305.loCC       crypto_shorthash/libsodium_la-crypto_shorthash.loCC       crypto_shorthash/siphash24/libsodium_la-shorthash_siphash24.loCC       crypto_shorthash/siphash24/ref/libsodium_la-shorthash_siphash24_ref.loCC       crypto_sign/libsodium_la-crypto_sign.loCC       crypto_sign/ed25519/libsodium_la-sign_ed25519.loCC       crypto_sign/ed25519/ref10/libsodium_la-keypair.loCC       crypto_sign/ed25519/ref10/libsodium_la-open.loCC       crypto_sign/ed25519/ref10/libsodium_la-sign.loCC       crypto_stream/chacha20/libsodium_la-stream_chacha20.loCC       crypto_stream/chacha20/ref/libsodium_la-chacha20_ref.loCC       crypto_stream/libsodium_la-crypto_stream.loCC       crypto_stream/salsa20/libsodium_la-stream_salsa20.loCC       crypto_stream/xsalsa20/libsodium_la-stream_xsalsa20.loCC       crypto_verify/sodium/libsodium_la-verify.loCC       randombytes/libsodium_la-randombytes.loCC       sodium/libsodium_la-codecs.loCC       sodium/libsodium_la-core.loCC       sodium/libsodium_la-runtime.loCC       sodium/libsodium_la-utils.loCC       sodium/libsodium_la-version.loCC       crypto_stream/salsa20/ref/libsodium_la-salsa20_ref.loCC       randombytes/sysrandom/libsodium_la-randombytes_sysrandom.loCC       crypto_aead/aes256gcm/aesni/libaesni_la-aead_aes256gcm_aesni.loCC       crypto_onetimeauth/poly1305/sse2/libsse2_la-poly1305_sse2.loCC       crypto_stream/salsa20/xmm6int/libsse2_la-salsa20_xmm6int-sse2.loCC       crypto_generichash/blake2b/ref/libssse3_la-blake2b-compress-ssse3.loCC       crypto_pwhash/argon2/libssse3_la-argon2-fill-block-ssse3.loCC       crypto_stream/chacha20/dolbeau/libssse3_la-chacha20_dolbeau-ssse3.loCC       crypto_generichash/blake2b/ref/libsse41_la-blake2b-compress-sse41.loCC       crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.loCC       crypto_pwhash/argon2/libavx2_la-argon2-fill-block-avx2.loCC       crypto_stream/chacha20/dolbeau/libavx2_la-chacha20_dolbeau-avx2.loCC       crypto_stream/salsa20/xmm6int/libavx2_la-salsa20_xmm6int-avx2.loCC       crypto_pwhash/argon2/libavx512f_la-argon2-fill-block-avx512f.loCC       randombytes/internal/librdrand_la-randombytes_internal_random.loCCLD     libaesni.laCCLD     libsse2.laCCLD     libssse3.laCCLD     libsse41.laCCLD     libavx2.laCCLD     libavx512f.laCCLD     librdrand.laCCLD     libsodium.lamake[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[4]: Nothing to be done for 'install-data-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib'/bin/bash ../../libtool   --mode=install /usr/bin/install -c   libsodium.la '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib'libtool: install: /usr/bin/install -c .libs/libsodium.so /home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/libsodium.solibtool: install: /usr/bin/install -c .libs/libsodium.lai /home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/libsodium.lalibtool: install: /usr/bin/install -c .libs/libsodium.a /home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/libsodium.alibtool: install: chmod 644 /home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/libsodium.alibtool: install: i686-linux-android-ranlib /home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/libsodium.amake[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making install in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making install in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/pkgconfig'/usr/bin/install -c -m 644 libsodium.pc '/home/vagrant/build/srclib/libsodium/libsodium-android-i686/lib/pkgconfig'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'libsodium has been installed into /home/vagrant/build/srclib/libsodium/libsodium-android-i686+ ./dist-build/android-x86_64.shWarnings related to headers being present but not usable are due to functionsthat didn't exist in the specified minimum API version level.They can be safely ignored.Building for platform [android-21]WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that performthe same task. For example, instead of:$ python $NDK/build/tools/make_standalone_toolchain.py \--arch x86_64 --api 21 --install-dir toolchain$ toolchain/bin/clang++ src.cppInstead use:$ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++ src.cppchecking build system type... x86_64-pc-linux-gnuchecking host system type... x86_64-pc-linux-androidchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for x86_64-linux-android-strip... x86_64-linux-android-stripchecking for a thread-safe mkdir -p... /bin/mkdir -pchecking for gawk... nochecking for mawk... mawkchecking whether make sets $(MAKE)... yeschecking whether make supports nested variables... yeschecking whether UID '1000' is supported by ustar format... yeschecking whether GID '1000' is supported by ustar format... yeschecking how to create a ustar tar archive... gnutarchecking whether make supports nested variables... (cached) yeschecking whether to enable maintainer-specific portions of Makefiles... nochecking for style of include used by make... GNUchecking for x86_64-linux-android-gcc... x86_64-linux-android-clangchecking whether the C compiler works... yeschecking for C compiler default output file name... a.outchecking for suffix of executables...checking whether we are cross compiling... yeschecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether x86_64-linux-android-clang accepts -g... yeschecking for x86_64-linux-android-clang option to accept ISO C89... none neededchecking whether x86_64-linux-android-clang understands -c and -o together... yeschecking dependency style of x86_64-linux-android-clang... gcc3checking for a sed that does not truncate output... /bin/sedchecking how to run the C preprocessor... x86_64-linux-android-clang -Echecking for grep that handles long lines and -e... /bin/grepchecking for egrep... /bin/grep -Echecking whether x86_64-linux-android-clang is Clang... yeschecking whether Clang needs flag to prevent "argument unused" warning when linking with -pthread... nochecking for joinable pthread attribute... PTHREAD_CREATE_JOINABLEchecking whether more special flags are required for pthreads... nochecking for PTHREAD_PRIO_INHERIT... yeschecking for x86_64-linux-android-clang option to accept ISO C99... none neededchecking dependency style of x86_64-linux-android-clang... gcc3checking for ANSI C header files... yeschecking for sys/types.h... yeschecking for sys/stat.h... yeschecking for stdlib.h... yeschecking for string.h... yeschecking for memory.h... yeschecking for strings.h... yeschecking for inttypes.h... yeschecking for stdint.h... yeschecking for unistd.h... yeschecking minix/config.h usability... nochecking minix/config.h presence... nochecking for minix/config.h... nochecking whether it is safe to define __EXTENSIONS__... yeschecking for variable-length arrays... yeschecking for __wasi__ defined... nochecking for _FORTIFY_SOURCE defined... nochecking whether C compiler accepts -D_FORTIFY_SOURCE=2... yeschecking whether C compiler accepts -fvisibility=hidden... yeschecking whether C compiler accepts -fPIC... yeschecking whether C compiler accepts -fPIE... yeschecking whether the linker accepts -pie... yeschecking whether C compiler accepts -fno-strict-aliasing... yeschecking whether C compiler accepts -fno-strict-overflow... yeschecking whether C compiler accepts -fstack-protector... yeschecking whether the linker accepts -fstack-protector... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wall... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra... yeschecking for clang... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl... yeschecking whether C compiler accepts -Os -march=westmere -pthread -fvisibility=hidden -fPIC -fPIE -fno-strict-aliasing -fno-strict-overflow -fstack-protector -Wextra -Wno-unknown-warning-option -Wbad-function-cast -Wcast-qual -Wdiv-by-zero -Wduplicated-branches -Wduplicated-cond -Wfloat-equal -Wformat=2 -Wlogical-op -Wmaybe-uninitialized -Wmisleading-indentation -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-type-limits -Wno-unknown-pragmas -Wnormalized=id -Wnull-dereference -Wold-style-declaration -Wpointer-arith -Wredundant-decls -Wrestrict -Wshorten-64-to-32 -Wsometimes-uninitialized -Wstrict-prototypes -Wswitch-enum -Wvariable-decl -Wwrite-strings... yeschecking whether the linker accepts -Wl,-z,relro... yeschecking whether the linker accepts -Wl,-z,now... yeschecking whether the linker accepts -Wl,-z,noexecstack... yeschecking whether segmentation violations can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, segmentation violations cannot be caught using signal handlers. This is expected if you enabled a tool such as Address Sanitizer (-fsanitize=address), but be aware that using Address Sanitizer may also significantly reduce performance.checking whether SIGABRT can be caught when using the C compiler... unknownconfigure: WARNING: On this platform, SIGABRT cannot be caught using signal handlers.checking for thread local storage (TLS) class... _Thread_localthread local storage is supportedchecking whether C compiler accepts -ftls-model=local-dynamic... yeschecking how to print strings... printfchecking for a sed that does not truncate output... (cached) /bin/sedchecking for fgrep... /bin/grep -Fchecking for ld used by x86_64-linux-android-clang... /home/vagrant/build/srclib/libsodium/android-toolchain-westmere/x86_64-linux-android/bin/ldchecking if the linker (/home/vagrant/build/srclib/libsodium/android-toolchain-westmere/x86_64-linux-android/bin/ld) is GNU ld... yeschecking for BSD- or MS-compatible name lister (nm)... /home/vagrant/build/srclib/libsodium/android-toolchain-westmere/bin/x86_64-linux-android-nm -Bchecking the name lister (/home/vagrant/build/srclib/libsodium/android-toolchain-westmere/bin/x86_64-linux-android-nm -B) interface... BSD nmchecking whether ln -s works... yeschecking the maximum length of command line arguments... 1572864checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-android format... func_convert_file_noopchecking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noopchecking for /home/vagrant/build/srclib/libsodium/android-toolchain-westmere/x86_64-linux-android/bin/ld option to reload object files... -rchecking for x86_64-linux-android-objdump... x86_64-linux-android-objdumpchecking how to recognize dependent libraries... pass_allchecking for x86_64-linux-android-dlltool... nochecking for dlltool... nochecking how to associate runtime and link libraries... printf %s\nchecking for x86_64-linux-android-ar... x86_64-linux-android-archecking for archiver @FILE support... @checking for x86_64-linux-android-strip... (cached) x86_64-linux-android-stripchecking for x86_64-linux-android-ranlib... x86_64-linux-android-ranlibchecking command to parse /home/vagrant/build/srclib/libsodium/android-toolchain-westmere/bin/x86_64-linux-android-nm -B output from x86_64-linux-android-clang object... okchecking for sysroot... /home/vagrant/build/srclib/libsodium/android-toolchain-westmere/sysrootchecking for a working dd... /bin/ddchecking how to truncate binary pipes... /bin/dd bs=4096 count=1checking for x86_64-linux-android-mt... nochecking for mt... mtconfigure: WARNING: using cross tools not prefixed with host tripletchecking if mt is a manifest tool... nochecking for dlfcn.h... yeschecking for objdir... .libschecking if x86_64-linux-android-clang supports -fno-rtti -fno-exceptions... yeschecking for x86_64-linux-android-clang option to produce PIC... -fPIC -DPICchecking if x86_64-linux-android-clang PIC flag -fPIC -DPIC works... yeschecking if x86_64-linux-android-clang static flag -static works... nochecking if x86_64-linux-android-clang supports -c -o file.o... yeschecking if x86_64-linux-android-clang supports -c -o file.o... (cached) yeschecking whether the x86_64-linux-android-clang linker (/home/vagrant/build/srclib/libsodium/android-toolchain-westmere/x86_64-linux-android/bin/ld -m elf_x86_64) supports shared libraries... yeschecking whether -lc should be explicitly linked in... nochecking dynamic linker characteristics... Android linkerchecking how to hardcode library paths into programs... immediatechecking whether stripping libraries is possible... yeschecking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... yeschecking for x86_64-linux-android-ar... (cached) x86_64-linux-android-archecking whether C compiler accepts -mmmx... yeschecking for MMX instructions set... yeschecking whether C compiler accepts -mmmx... (cached) yeschecking whether C compiler accepts -msse2... yeschecking for SSE2 instructions set... yeschecking whether C compiler accepts -msse2... (cached) yeschecking whether C compiler accepts -msse3... yeschecking for SSE3 instructions set... yeschecking whether C compiler accepts -msse3... (cached) yeschecking whether C compiler accepts -mssse3... yeschecking for SSSE3 instructions set... yeschecking whether C compiler accepts -mssse3... (cached) yeschecking whether C compiler accepts -msse4.1... yeschecking for SSE4.1 instructions set... yeschecking whether C compiler accepts -msse4.1... (cached) yeschecking whether C compiler accepts -mavx... yeschecking for AVX instructions set... yeschecking whether C compiler accepts -mavx... (cached) yeschecking whether C compiler accepts -mavx2... yeschecking for AVX2 instructions set... yeschecking whether C compiler accepts -mavx2... (cached) yeschecking if _mm256_broadcastsi128_si256 is correctly defined... yeschecking whether C compiler accepts -mavx512f... yeschecking for AVX512F instructions set... yeschecking whether C compiler accepts -mavx512f... (cached) yeschecking whether C compiler accepts -maes... yeschecking whether C compiler accepts -mpclmul... yeschecking for AESNI instructions set and PCLMULQDQ... yeschecking whether C compiler accepts -maes... (cached) yeschecking whether C compiler accepts -mpclmul... (cached) yeschecking whether C compiler accepts -mrdrnd... yeschecking for RDRAND... yeschecking whether C compiler accepts -mrdrnd... (cached) yeschecking sys/mman.h usability... yeschecking sys/mman.h presence... yeschecking for sys/mman.h... yeschecking sys/random.h usability... yeschecking sys/random.h presence... yeschecking for sys/random.h... yeschecking intrin.h usability... nochecking intrin.h presence... nochecking for intrin.h... nochecking if _xgetbv() is available... nochecking for inline... inlinechecking whether byte ordering is bigendian... (cached) nochecking whether __STDC_LIMIT_MACROS is required... nochecking whether we can use inline asm code... yesnochecking whether we can use x86_64 asm code... yeschecking whether we can assemble AVX opcodes... yeschecking for 128-bit arithmetic... yeschecking for cpuid instruction... yeschecking if the .private_extern asm directive is supported... nochecking if the .hidden asm directive is supported... yeschecking if weak symbols are supported... yeschecking if data alignment is required... nochecking if atomic operations are supported... yeschecking for size_t... yeschecking for working alloca.h... yeschecking for alloca... yeschecking for arc4random... yeschecking for arc4random_buf... yeschecking for mmap... yeschecking for mlock... yeschecking for madvise... yeschecking for mprotect... yeschecking for getrandom with a standard API... nochecking for getentropy with a standard API... nochecking for posix_memalign... yeschecking for getpid... yeschecking for nanosleep... yeschecking for memset_s... nochecking for explicit_bzero... nochecking for explicit_memset... nochecking if gcc/ld supports -Wl,--output-def... nochecking that generated files are newer than configure... doneconfigure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating builds/Makefileconfig.status: creating contrib/Makefileconfig.status: creating dist-build/Makefileconfig.status: creating libsodium.pcconfig.status: creating libsodium-uninstalled.pcconfig.status: creating msvc-scripts/Makefileconfig.status: creating src/Makefileconfig.status: creating src/libsodium/Makefileconfig.status: creating src/libsodium/include/Makefileconfig.status: creating src/libsodium/include/sodium/version.hconfig.status: creating test/default/Makefileconfig.status: creating test/Makefileconfig.status: executing depfiles commandsconfig.status: executing libtool commandsMaking clean in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making clean in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making clean in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making clean in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making clean in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making clean in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making clean in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'rm -rf .libs _libsrm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'test -z "" || rm -ftest -z "libsodium.la" || rm -f libsodium.larm -f ./so_locationsrm -rf .libs _libsrm -rf crypto_aead/aes256gcm/aesni/.libs crypto_aead/aes256gcm/aesni/_libsrm -rf crypto_aead/chacha20poly1305/sodium/.libs crypto_aead/chacha20poly1305/sodium/_libsrm -rf crypto_aead/xchacha20poly1305/sodium/.libs crypto_aead/xchacha20poly1305/sodium/_libsrm -rf crypto_auth/.libs crypto_auth/_libsrm -rf crypto_auth/hmacsha256/.libs crypto_auth/hmacsha256/_libsrm -rf crypto_auth/hmacsha512/.libs crypto_auth/hmacsha512/_libsrm -rf crypto_auth/hmacsha512256/.libs crypto_auth/hmacsha512256/_libsrm -rf crypto_box/.libs crypto_box/_libsrm -rf crypto_box/curve25519xchacha20poly1305/.libs crypto_box/curve25519xchacha20poly1305/_libsrm -rf crypto_box/curve25519xsalsa20poly1305/.libs crypto_box/curve25519xsalsa20poly1305/_libsrm -rf crypto_core/ed25519/.libs crypto_core/ed25519/_libsrm -rf crypto_core/ed25519/ref10/.libs crypto_core/ed25519/ref10/_libsrm -rf crypto_core/hchacha20/.libs crypto_core/hchacha20/_libsrm -rf crypto_core/hsalsa20/.libs crypto_core/hsalsa20/_libsrm -rf crypto_core/hsalsa20/ref2/.libs crypto_core/hsalsa20/ref2/_libsrm -rf crypto_core/salsa/ref/.libs crypto_core/salsa/ref/_libsrm -rf crypto_generichash/.libs crypto_generichash/_libsrm -rf crypto_generichash/blake2b/.libs crypto_generichash/blake2b/_libsrm -rf crypto_generichash/blake2b/ref/.libs crypto_generichash/blake2b/ref/_libsrm -rf crypto_hash/.libs crypto_hash/_libsrm -rf crypto_hash/sha256/.libs crypto_hash/sha256/_libsrm -rf crypto_hash/sha256/cp/.libs crypto_hash/sha256/cp/_libsrm -rf crypto_hash/sha512/.libs crypto_hash/sha512/_libsrm -rf crypto_hash/sha512/cp/.libs crypto_hash/sha512/cp/_libsrm -rf crypto_kdf/.libs crypto_kdf/_libsrm -rf crypto_kdf/blake2b/.libs crypto_kdf/blake2b/_libsrm -rf crypto_kx/.libs crypto_kx/_libsrm -rf crypto_onetimeauth/.libs crypto_onetimeauth/_libsrm -rf crypto_onetimeauth/poly1305/.libs crypto_onetimeauth/poly1305/_libsrm -rf crypto_onetimeauth/poly1305/donna/.libs crypto_onetimeauth/poly1305/donna/_libsrm -rf crypto_onetimeauth/poly1305/sse2/.libs crypto_onetimeauth/poly1305/sse2/_libsrm -rf crypto_pwhash/.libs crypto_pwhash/_libsrm -rf crypto_pwhash/argon2/.libs crypto_pwhash/argon2/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/.libs crypto_pwhash/scryptsalsa208sha256/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/nosse/.libs crypto_pwhash/scryptsalsa208sha256/nosse/_libsrm -rf crypto_pwhash/scryptsalsa208sha256/sse/.libs crypto_pwhash/scryptsalsa208sha256/sse/_libsrm -rf crypto_scalarmult/.libs crypto_scalarmult/_libsrm -rf crypto_scalarmult/curve25519/.libs crypto_scalarmult/curve25519/_libsrm -rf crypto_scalarmult/curve25519/ref10/.libs crypto_scalarmult/curve25519/ref10/_libsrm -rf crypto_scalarmult/curve25519/sandy2x/.libs crypto_scalarmult/curve25519/sandy2x/_libsrm -rf crypto_scalarmult/ed25519/ref10/.libs crypto_scalarmult/ed25519/ref10/_libsrm -rf crypto_scalarmult/ristretto255/ref10/.libs crypto_scalarmult/ristretto255/ref10/_libsrm -rf crypto_secretbox/.libs crypto_secretbox/_libsrm -rf crypto_secretbox/xchacha20poly1305/.libs crypto_secretbox/xchacha20poly1305/_libsrm -rf crypto_secretbox/xsalsa20poly1305/.libs crypto_secretbox/xsalsa20poly1305/_libsrm -rf crypto_secretstream/xchacha20poly1305/.libs crypto_secretstream/xchacha20poly1305/_libsrm -rf crypto_shorthash/.libs crypto_shorthash/_libsrm -rf crypto_shorthash/siphash24/.libs crypto_shorthash/siphash24/_libsrm -rf crypto_shorthash/siphash24/ref/.libs crypto_shorthash/siphash24/ref/_libsrm -rf crypto_sign/.libs crypto_sign/_libsrm -rf crypto_sign/ed25519/.libs crypto_sign/ed25519/_libsrm -rf crypto_sign/ed25519/ref10/.libs crypto_sign/ed25519/ref10/_libsrm -rf crypto_stream/.libs crypto_stream/_libsrm -rf crypto_stream/chacha20/.libs crypto_stream/chacha20/_libsrm -rf crypto_stream/chacha20/dolbeau/.libs crypto_stream/chacha20/dolbeau/_libsrm -rf crypto_stream/chacha20/ref/.libs crypto_stream/chacha20/ref/_libsrm -rf crypto_stream/salsa20/.libs crypto_stream/salsa20/_libsrm -rf crypto_stream/salsa20/ref/.libs crypto_stream/salsa20/ref/_libsrm -rf crypto_stream/salsa20/xmm6/.libs crypto_stream/salsa20/xmm6/_libsrm -rf crypto_stream/salsa20/xmm6int/.libs crypto_stream/salsa20/xmm6int/_libsrm -rf crypto_stream/salsa2012/.libs crypto_stream/salsa2012/_libsrm -rf crypto_stream/salsa2012/ref/.libs crypto_stream/salsa2012/ref/_libsrm -rf crypto_stream/salsa208/.libs crypto_stream/salsa208/_libsrm -rf crypto_stream/salsa208/ref/.libs crypto_stream/salsa208/ref/_libsrm -rf crypto_stream/xchacha20/.libs crypto_stream/xchacha20/_libsrm -rf crypto_stream/xsalsa20/.libs crypto_stream/xsalsa20/_libsrm -rf crypto_verify/sodium/.libs crypto_verify/sodium/_libsrm -rf randombytes/.libs randombytes/_libsrm -rf randombytes/internal/.libs randombytes/internal/_libsrm -rf randombytes/sysrandom/.libs randombytes/sysrandom/_libsrm -rf sodium/.libs sodium/_libstest -z "libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.la" || rm -f libaesni.la libsse2.la libssse3.la libsse41.la libavx2.la libavx512f.la librdrand.larm -f ./so_locationsrm -f *.orm -f crypto_aead/aes256gcm/aesni/*.orm -f crypto_aead/aes256gcm/aesni/*.lorm -f crypto_aead/chacha20poly1305/sodium/*.orm -f crypto_aead/chacha20poly1305/sodium/*.lorm -f crypto_aead/xchacha20poly1305/sodium/*.orm -f crypto_aead/xchacha20poly1305/sodium/*.lorm -f crypto_auth/*.orm -f crypto_auth/*.lorm -f crypto_auth/hmacsha256/*.orm -f crypto_auth/hmacsha256/*.lorm -f crypto_auth/hmacsha512/*.orm -f crypto_auth/hmacsha512/*.lorm -f crypto_auth/hmacsha512256/*.orm -f crypto_auth/hmacsha512256/*.lorm -f crypto_box/*.orm -f crypto_box/*.lorm -f crypto_box/curve25519xchacha20poly1305/*.orm -f crypto_box/curve25519xchacha20poly1305/*.lorm -f crypto_box/curve25519xsalsa20poly1305/*.orm -f crypto_box/curve25519xsalsa20poly1305/*.lorm -f crypto_core/ed25519/*.orm -f crypto_core/ed25519/*.lorm -f crypto_core/ed25519/ref10/*.orm -f crypto_core/ed25519/ref10/*.lorm -f crypto_core/hchacha20/*.orm -f crypto_core/hchacha20/*.lorm -f crypto_core/hsalsa20/*.orm -f crypto_core/hsalsa20/*.lorm -f crypto_core/hsalsa20/ref2/*.orm -f crypto_core/hsalsa20/ref2/*.lorm -f crypto_core/salsa/ref/*.orm -f crypto_core/salsa/ref/*.lorm -f crypto_generichash/*.orm -f crypto_generichash/*.lorm -f crypto_generichash/blake2b/*.orm -f crypto_generichash/blake2b/*.lorm -f crypto_generichash/blake2b/ref/*.orm -f crypto_generichash/blake2b/ref/*.lorm -f crypto_hash/*.orm -f crypto_hash/*.lorm -f crypto_hash/sha256/*.orm -f crypto_hash/sha256/*.lorm -f crypto_hash/sha256/cp/*.orm -f crypto_hash/sha256/cp/*.lorm -f crypto_hash/sha512/*.orm -f crypto_hash/sha512/*.lorm -f crypto_hash/sha512/cp/*.orm -f crypto_hash/sha512/cp/*.lorm -f crypto_kdf/*.orm -f crypto_kdf/*.lorm -f crypto_kdf/blake2b/*.orm -f crypto_kdf/blake2b/*.lorm -f crypto_kx/*.orm -f crypto_kx/*.lorm -f crypto_onetimeauth/*.orm -f crypto_onetimeauth/*.lorm -f crypto_onetimeauth/poly1305/*.orm -f crypto_onetimeauth/poly1305/*.lorm -f crypto_onetimeauth/poly1305/donna/*.orm -f crypto_onetimeauth/poly1305/donna/*.lorm -f crypto_onetimeauth/poly1305/sse2/*.orm -f crypto_onetimeauth/poly1305/sse2/*.lorm -f crypto_pwhash/*.orm -f crypto_pwhash/*.lorm -f crypto_pwhash/argon2/*.orm -f crypto_pwhash/argon2/*.lorm -f crypto_pwhash/scryptsalsa208sha256/*.orm -f crypto_pwhash/scryptsalsa208sha256/*.lorm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.orm -f crypto_pwhash/scryptsalsa208sha256/nosse/*.lorm -f crypto_pwhash/scryptsalsa208sha256/sse/*.orm -f crypto_pwhash/scryptsalsa208sha256/sse/*.lorm -f crypto_scalarmult/*.orm -f crypto_scalarmult/*.lorm -f crypto_scalarmult/curve25519/*.orm -f crypto_scalarmult/curve25519/*.lorm -f crypto_scalarmult/curve25519/ref10/*.orm -f crypto_scalarmult/curve25519/ref10/*.lorm -f crypto_scalarmult/curve25519/sandy2x/*.orm -f crypto_scalarmult/curve25519/sandy2x/*.lorm -f crypto_scalarmult/ed25519/ref10/*.orm -f crypto_scalarmult/ed25519/ref10/*.lorm -f crypto_scalarmult/ristretto255/ref10/*.orm -f crypto_scalarmult/ristretto255/ref10/*.lorm -f crypto_secretbox/*.orm -f crypto_secretbox/*.lorm -f crypto_secretbox/xchacha20poly1305/*.orm -f crypto_secretbox/xchacha20poly1305/*.lorm -f crypto_secretbox/xsalsa20poly1305/*.orm -f crypto_secretbox/xsalsa20poly1305/*.lorm -f crypto_secretstream/xchacha20poly1305/*.orm -f crypto_secretstream/xchacha20poly1305/*.lorm -f crypto_shorthash/*.orm -f crypto_shorthash/*.lorm -f crypto_shorthash/siphash24/*.orm -f crypto_shorthash/siphash24/*.lorm -f crypto_shorthash/siphash24/ref/*.orm -f crypto_shorthash/siphash24/ref/*.lorm -f crypto_sign/*.orm -f crypto_sign/*.lorm -f crypto_sign/ed25519/*.orm -f crypto_sign/ed25519/*.lorm -f crypto_sign/ed25519/ref10/*.orm -f crypto_sign/ed25519/ref10/*.lorm -f crypto_stream/*.orm -f crypto_stream/*.lorm -f crypto_stream/chacha20/*.orm -f crypto_stream/chacha20/*.lorm -f crypto_stream/chacha20/dolbeau/*.orm -f crypto_stream/chacha20/dolbeau/*.lorm -f crypto_stream/chacha20/ref/*.orm -f crypto_stream/chacha20/ref/*.lorm -f crypto_stream/salsa20/*.orm -f crypto_stream/salsa20/*.lorm -f crypto_stream/salsa20/ref/*.orm -f crypto_stream/salsa20/ref/*.lorm -f crypto_stream/salsa20/xmm6/*.orm -f crypto_stream/salsa20/xmm6/*.lorm -f crypto_stream/salsa20/xmm6int/*.orm -f crypto_stream/salsa20/xmm6int/*.lorm -f crypto_stream/salsa2012/*.orm -f crypto_stream/salsa2012/*.lorm -f crypto_stream/salsa2012/ref/*.orm -f crypto_stream/salsa2012/ref/*.lorm -f crypto_stream/salsa208/*.orm -f crypto_stream/salsa208/*.lorm -f crypto_stream/salsa208/ref/*.orm -f crypto_stream/salsa208/ref/*.lorm -f crypto_stream/xchacha20/*.orm -f crypto_stream/xchacha20/*.lorm -f crypto_stream/xsalsa20/*.orm -f crypto_stream/xsalsa20/*.lorm -f crypto_verify/sodium/*.orm -f crypto_verify/sodium/*.lorm -f randombytes/*.orm -f randombytes/*.lorm -f randombytes/internal/*.orm -f randombytes/internal/*.lorm -f randombytes/sysrandom/*.orm -f randombytes/sysrandom/*.lorm -f sodium/*.orm -f sodium/*.lorm -f *.lomake[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making clean in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making clean in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'rm -f aead_aes256gcm aead_aes256gcm2 aead_chacha20poly1305 aead_chacha20poly13052 aead_xchacha20poly1305 auth auth2 auth3 auth5 auth6 auth7 box box2 box7 box8 box_easy box_easy2 box_seal box_seed chacha20 codecs core1 core2 core3 core4 core5 core6 ed25519_convert generichash generichash2 generichash3 hash hash3 kdf keygen kx metamorphic misuse onetimeauth onetimeauth2 onetimeauth7 pwhash_argon2i pwhash_argon2id randombytes scalarmult scalarmult2 scalarmult5 scalarmult6 scalarmult7 scalarmult8 secretbox secretbox2 secretbox7 secretbox8 secretbox_easy secretbox_easy2 secretstream shorthash sign sodium_core sodium_utils sodium_version stream stream2 stream3 stream4 verify1 sodium_utils2 sodium_utils3rm -rf .libs _libsrm -f *.otest -z "aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.log" || rm -f aead_aes256gcm.log aead_aes256gcm2.log aead_chacha20poly1305.log aead_chacha20poly13052.log aead_xchacha20poly1305.log auth.log auth2.log auth3.log auth5.log auth6.log auth7.log box.log box2.log box7.log box8.log box_easy.log box_easy2.log box_seal.log box_seed.log chacha20.log codecs.log core1.log core2.log core3.log core4.log core5.log core6.log ed25519_convert.log generichash.log generichash2.log generichash3.log hash.log hash3.log kdf.log keygen.log kx.log metamorphic.log misuse.log onetimeauth.log onetimeauth2.log onetimeauth7.log pwhash_argon2i.log pwhash_argon2id.log randombytes.log scalarmult.log scalarmult2.log scalarmult5.log scalarmult6.log scalarmult7.log scalarmult8.log secretbox.log secretbox2.log secretbox7.log secretbox8.log secretbox_easy.log secretbox_easy2.log secretstream.log shorthash.log sign.log sodium_core.log sodium_utils.log sodium_version.log stream.log stream2.log stream3.log stream4.log verify1.log sodium_utils2.log sodium_utils3.logtest -z "aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trs" || rm -f aead_aes256gcm.trs aead_aes256gcm2.trs aead_chacha20poly1305.trs aead_chacha20poly13052.trs aead_xchacha20poly1305.trs auth.trs auth2.trs auth3.trs auth5.trs auth6.trs auth7.trs box.trs box2.trs box7.trs box8.trs box_easy.trs box_easy2.trs box_seal.trs box_seed.trs chacha20.trs codecs.trs core1.trs core2.trs core3.trs core4.trs core5.trs core6.trs ed25519_convert.trs generichash.trs generichash2.trs generichash3.trs hash.trs hash3.trs kdf.trs keygen.trs kx.trs metamorphic.trs misuse.trs onetimeauth.trs onetimeauth2.trs onetimeauth7.trs pwhash_argon2i.trs pwhash_argon2id.trs randombytes.trs scalarmult.trs scalarmult2.trs scalarmult5.trs scalarmult6.trs scalarmult7.trs scalarmult8.trs secretbox.trs secretbox2.trs secretbox7.trs secretbox8.trs secretbox_easy.trs secretbox_easy2.trs secretstream.trs shorthash.trs sign.trs sodium_core.trs sodium_utils.trs sodium_version.trs stream.trs stream2.trs stream3.trs stream4.trs verify1.trs sodium_utils2.trs sodium_utils3.trstest -z "test-suite.log" || rm -f test-suite.logrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'rm -rf .libs _libsrm -f *.lomake[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'rm -rf .libs _libsrm -f *.lomake[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'Making install in buildsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/builds'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/builds'Making install in contribmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/contrib'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/contrib'Making install in dist-buildmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/dist-build'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/dist-build'Making install in msvc-scriptsmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[2]: Nothing to be done for 'install-exec-am'.make[2]: Nothing to be done for 'install-data-am'.make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/msvc-scripts'Making install in srcmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/src'Making install in libsodiummake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'Making install in includemake[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[4]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/sodium'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/sodium'/usr/bin/install -c -m 644  sodium/version.h '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/sodium'/usr/bin/install -c -m 644  sodium/core.h sodium/crypto_aead_aes256gcm.h sodium/crypto_aead_chacha20poly1305.h sodium/crypto_aead_xchacha20poly1305.h sodium/crypto_auth.h sodium/crypto_auth_hmacsha256.h sodium/crypto_auth_hmacsha512.h sodium/crypto_auth_hmacsha512256.h sodium/crypto_box.h sodium/crypto_box_curve25519xchacha20poly1305.h sodium/crypto_box_curve25519xsalsa20poly1305.h sodium/crypto_core_ed25519.h sodium/crypto_core_ristretto255.h sodium/crypto_core_hchacha20.h sodium/crypto_core_hsalsa20.h sodium/crypto_core_salsa20.h sodium/crypto_core_salsa2012.h sodium/crypto_core_salsa208.h sodium/crypto_generichash.h sodium/crypto_generichash_blake2b.h sodium/crypto_hash.h sodium/crypto_hash_sha256.h sodium/crypto_hash_sha512.h sodium/crypto_kdf.h sodium/crypto_kdf_blake2b.h sodium/crypto_kx.h sodium/crypto_onetimeauth.h sodium/crypto_onetimeauth_poly1305.h sodium/crypto_pwhash.h sodium/crypto_pwhash_argon2i.h sodium/crypto_pwhash_argon2id.h sodium/crypto_pwhash_scryptsalsa208sha256.h sodium/crypto_scalarmult.h sodium/crypto_scalarmult_curve25519.h sodium/crypto_scalarmult_ed25519.h sodium/crypto_scalarmult_ristretto255.h sodium/crypto_secretbox.h sodium/crypto_secretbox_xchacha20poly1305.h sodium/crypto_secretbox_xsalsa20poly1305.h sodium/crypto_secretstream_xchacha20poly1305.h '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/sodium'/usr/bin/install -c -m 644  sodium.h '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/.'/bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/sodium'/usr/bin/install -c -m 644  sodium/crypto_shorthash.h sodium/crypto_shorthash_siphash24.h sodium/crypto_sign.h sodium/crypto_sign_ed25519.h sodium/crypto_sign_edwards25519sha512batch.h sodium/crypto_stream.h sodium/crypto_stream_chacha20.h sodium/crypto_stream_salsa20.h sodium/crypto_stream_salsa2012.h sodium/crypto_stream_salsa208.h sodium/crypto_stream_xchacha20.h sodium/crypto_stream_xsalsa20.h sodium/crypto_verify_16.h sodium/crypto_verify_32.h sodium/crypto_verify_64.h sodium/export.h sodium/randombytes.h sodium/randombytes_internal_random.h sodium/randombytes_sysrandom.h sodium/runtime.h sodium/utils.h '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/include/sodium'make[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium/include'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'CC       crypto_aead/chacha20poly1305/sodium/libsodium_la-aead_chacha20poly1305.loCC       crypto_aead/xchacha20poly1305/sodium/libsodium_la-aead_xchacha20poly1305.loCC       crypto_auth/libsodium_la-crypto_auth.loCC       crypto_auth/hmacsha256/libsodium_la-auth_hmacsha256.loCC       crypto_auth/hmacsha512/libsodium_la-auth_hmacsha512.loCC       crypto_auth/hmacsha512256/libsodium_la-auth_hmacsha512256.loCC       crypto_box/libsodium_la-crypto_box.loCC       crypto_box/libsodium_la-crypto_box_easy.loCC       crypto_box/libsodium_la-crypto_box_seal.loCC       crypto_box/curve25519xsalsa20poly1305/libsodium_la-box_curve25519xsalsa20poly1305.loCC       crypto_core/ed25519/ref10/libsodium_la-ed25519_ref10.loCC       crypto_core/hchacha20/libsodium_la-core_hchacha20.loCC       crypto_core/hsalsa20/ref2/libsodium_la-core_hsalsa20_ref2.loCC       crypto_core/hsalsa20/libsodium_la-core_hsalsa20.loCC       crypto_core/salsa/ref/libsodium_la-core_salsa_ref.loCC       crypto_generichash/libsodium_la-crypto_generichash.loCC       crypto_generichash/blake2b/libsodium_la-generichash_blake2.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-compress-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-blake2b-ref.loCC       crypto_generichash/blake2b/ref/libsodium_la-generichash_blake2b.loCC       crypto_hash/libsodium_la-crypto_hash.loCC       crypto_hash/sha256/libsodium_la-hash_sha256.loCC       crypto_hash/sha256/cp/libsodium_la-hash_sha256_cp.loCC       crypto_hash/sha512/libsodium_la-hash_sha512.loCC       crypto_hash/sha512/cp/libsodium_la-hash_sha512_cp.loCC       crypto_kdf/blake2b/libsodium_la-kdf_blake2b.loCC       crypto_kdf/libsodium_la-crypto_kdf.loCC       crypto_kx/libsodium_la-crypto_kx.loCC       crypto_onetimeauth/libsodium_la-crypto_onetimeauth.loCC       crypto_onetimeauth/poly1305/libsodium_la-onetimeauth_poly1305.loCC       crypto_onetimeauth/poly1305/donna/libsodium_la-poly1305_donna.loCC       crypto_pwhash/argon2/libsodium_la-argon2-core.loCC       crypto_pwhash/argon2/libsodium_la-argon2-encoding.loCC       crypto_pwhash/argon2/libsodium_la-argon2-fill-block-ref.loCC       crypto_pwhash/argon2/libsodium_la-argon2.loCC       crypto_pwhash/argon2/libsodium_la-blake2b-long.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2i.loCC       crypto_pwhash/argon2/libsodium_la-pwhash_argon2id.loCC       crypto_pwhash/libsodium_la-crypto_pwhash.loCC       crypto_scalarmult/libsodium_la-crypto_scalarmult.loCC       crypto_scalarmult/curve25519/ref10/libsodium_la-x25519_ref10.loCC       crypto_scalarmult/curve25519/libsodium_la-scalarmult_curve25519.loCC       crypto_secretbox/libsodium_la-crypto_secretbox.loCC       crypto_secretbox/libsodium_la-crypto_secretbox_easy.loCC       crypto_secretbox/xsalsa20poly1305/libsodium_la-secretbox_xsalsa20poly1305.loCC       crypto_secretstream/xchacha20poly1305/libsodium_la-secretstream_xchacha20poly1305.loCC       crypto_shorthash/libsodium_la-crypto_shorthash.loCC       crypto_shorthash/siphash24/libsodium_la-shorthash_siphash24.loCC       crypto_shorthash/siphash24/ref/libsodium_la-shorthash_siphash24_ref.loCC       crypto_sign/libsodium_la-crypto_sign.loCC       crypto_sign/ed25519/libsodium_la-sign_ed25519.loCC       crypto_sign/ed25519/ref10/libsodium_la-keypair.loCC       crypto_sign/ed25519/ref10/libsodium_la-open.loCC       crypto_sign/ed25519/ref10/libsodium_la-sign.loCC       crypto_stream/chacha20/libsodium_la-stream_chacha20.loCC       crypto_stream/chacha20/ref/libsodium_la-chacha20_ref.loCC       crypto_stream/libsodium_la-crypto_stream.loCC       crypto_stream/salsa20/libsodium_la-stream_salsa20.loCC       crypto_stream/xsalsa20/libsodium_la-stream_xsalsa20.loCC       crypto_verify/sodium/libsodium_la-verify.loCC       randombytes/libsodium_la-randombytes.loCC       sodium/libsodium_la-codecs.loCC       sodium/libsodium_la-core.loCC       sodium/libsodium_la-utils.loCC       sodium/libsodium_la-runtime.loCC       sodium/libsodium_la-version.loCC       randombytes/sysrandom/libsodium_la-randombytes_sysrandom.loCC       crypto_aead/aes256gcm/aesni/libaesni_la-aead_aes256gcm_aesni.loCC       crypto_onetimeauth/poly1305/sse2/libsse2_la-poly1305_sse2.loCC       crypto_generichash/blake2b/ref/libssse3_la-blake2b-compress-ssse3.loCC       crypto_pwhash/argon2/libssse3_la-argon2-fill-block-ssse3.loCC       crypto_stream/chacha20/dolbeau/libssse3_la-chacha20_dolbeau-ssse3.loCC       crypto_generichash/blake2b/ref/libsse41_la-blake2b-compress-sse41.loCC       crypto_generichash/blake2b/ref/libavx2_la-blake2b-compress-avx2.loCC       crypto_pwhash/argon2/libavx2_la-argon2-fill-block-avx2.loCC       crypto_stream/chacha20/dolbeau/libavx2_la-chacha20_dolbeau-avx2.loCC       crypto_stream/salsa20/xmm6int/libavx2_la-salsa20_xmm6int-avx2.loCC       crypto_pwhash/argon2/libavx512f_la-argon2-fill-block-avx512f.loCC       randombytes/internal/librdrand_la-randombytes_internal_random.loCPPAS    crypto_stream/salsa20/xmm6/libsodium_la-salsa20_xmm6-asm.loCC       crypto_stream/salsa20/xmm6/libsodium_la-salsa20_xmm6.loCC       crypto_scalarmult/curve25519/sandy2x/libsodium_la-curve25519_sandy2x.loCC       crypto_scalarmult/curve25519/sandy2x/libsodium_la-fe51_invert.loCC       crypto_scalarmult/curve25519/sandy2x/libsodium_la-fe_frombytes_sandy2x.loCPPAS    crypto_scalarmult/curve25519/sandy2x/libsodium_la-sandy2x.loCCLD     libaesni.laCCLD     libsse2.laCCLD     libssse3.laCCLD     libsse41.laCCLD     libavx2.laCCLD     libavx512f.laCCLD     librdrand.laCCLD     libsodium.lamake[4]: Entering directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[4]: Nothing to be done for 'install-data-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib'/bin/bash ../../libtool   --mode=install /usr/bin/install -c   libsodium.la '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib'libtool: install: /usr/bin/install -c .libs/libsodium.so /home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/libsodium.solibtool: install: /usr/bin/install -c .libs/libsodium.lai /home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/libsodium.lalibtool: install: /usr/bin/install -c .libs/libsodium.a /home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/libsodium.alibtool: install: chmod 644 /home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/libsodium.alibtool: install: x86_64-linux-android-ranlib /home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/libsodium.amake[4]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/src'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/src'Making install in testmake[1]: Entering directory '/home/vagrant/build/srclib/libsodium/test'Making install in defaultmake[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test/default'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test/default'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Entering directory '/home/vagrant/build/srclib/libsodium/test'make[3]: Nothing to be done for 'install-exec-am'.make[3]: Nothing to be done for 'install-data-am'.make[3]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium/test'make[1]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Entering directory '/home/vagrant/build/srclib/libsodium'make[2]: Nothing to be done for 'install-exec-am'./bin/mkdir -p '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/pkgconfig'/usr/bin/install -c -m 644 libsodium.pc '/home/vagrant/build/srclib/libsodium/libsodium-android-westmere/lib/pkgconfig'make[2]: Leaving directory '/home/vagrant/build/srclib/libsodium'make[1]: Leaving directory '/home/vagrant/build/srclib/libsodium'libsodium has been installed into /home/vagrant/build/srclib/libsodium/libsodium-android-westmere+ popd~/build/com.standardnotes/android/app2022-01-13 03:00:36,937 INFO: Building Gradle project...2022-01-13 03:00:36,937 DEBUG: Directory: build/com.standardnotes/android/app2022-01-13 03:00:36,937 DEBUG: > /home/vagrant/fdroidserver/gradlew-fdroid assembleProdReleaseFound 5.4.1 via distributionUrlRunning /opt/gradle/versions/5.4.1/bin/gradle assembleProdReleaseTo honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.4.1/userguide/gradle_daemon.html.Daemon will be stopped at the end of the build stopping after processingSupport for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01Checking the license for package CMake 3.6.4111459 in /opt/android-sdk/licensesLicense for package CMake 3.6.4111459 accepted.Preparing "Install CMake 3.6.4111459 (revision: 3.6.4111459)"."Install CMake 3.6.4111459 (revision: 3.6.4111459)" ready.Installing CMake 3.6.4111459 in /opt/android-sdk/cmake/3.6.4111459"Install CMake 3.6.4111459 (revision: 3.6.4111459)" complete."Install CMake 3.6.4111459 (revision: 3.6.4111459)" finished.Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01> Task :app:generatePackageList> Task :app:preBuild> Task :app:preProdReleaseBuild> Task :react-native-aes-crypto:preBuild UP-TO-DATE> Task :react-native-aes-crypto:preReleaseBuild UP-TO-DATE> Task :react-native-community_async-storage:preBuild UP-TO-DATE> Task :react-native-community_async-storage:preReleaseBuild UP-TO-DATE> Task :react-native-community_masked-view:preBuild UP-TO-DATE> Task :react-native-community_masked-view:preReleaseBuild UP-TO-DATE> Task :react-native-community_netinfo:preBuild UP-TO-DATE> Task :react-native-community_netinfo:preReleaseBuild UP-TO-DATE> Task :react-native-default-preference:preBuild UP-TO-DATE> Task :react-native-default-preference:preReleaseBuild UP-TO-DATE> Task :react-native-community_async-storage:compileReleaseAidl NO-SOURCE> Task :react-native-aes-crypto:compileReleaseAidl NO-SOURCE> Task :react-native-community_masked-view:compileReleaseAidl NO-SOURCE> Task :react-native-community_netinfo:compileReleaseAidl NO-SOURCE> Task :react-native-default-preference:compileReleaseAidl NO-SOURCE> Task :react-native-document-picker:preBuild UP-TO-DATE> Task :react-native-document-picker:preReleaseBuild UP-TO-DATE> Task :react-native-document-picker:compileReleaseAidl NO-SOURCE> Task :react-native-file-viewer:preBuild UP-TO-DATE> Task :react-native-file-viewer:preReleaseBuild UP-TO-DATE> Task :react-native-file-viewer:compileReleaseAidl NO-SOURCE> Task :react-native-fingerprint-scanner:preBuild UP-TO-DATE> Task :react-native-fingerprint-scanner:preReleaseBuild UP-TO-DATE> Task :react-native-flag-secure-android:preBuild UP-TO-DATE> Task :react-native-flag-secure-android:preReleaseBuild UP-TO-DATE> Task :react-native-flag-secure-android:compileReleaseAidl NO-SOURCE> Task :react-native-fs:preBuild UP-TO-DATE> Task :react-native-fs:preReleaseBuild UP-TO-DATE> Task :react-native-fs:compileReleaseAidl NO-SOURCE> Task :react-native-gesture-handler:preBuild UP-TO-DATE> Task :react-native-gesture-handler:preReleaseBuild UP-TO-DATE> Task :react-native-gesture-handler:compileReleaseAidl NO-SOURCE> Task :react-native-keychain:preBuild UP-TO-DATE> Task :react-native-keychain:preReleaseBuild UP-TO-DATE> Task :react-native-keychain:compileReleaseAidl NO-SOURCE> Task :react-native-fingerprint-scanner:compileReleaseAidl NO-SOURCE> Task :react-native-mail:preBuild UP-TO-DATE> Task :react-native-mail:preReleaseBuild UP-TO-DATE> Task :react-native-mail:compileReleaseAidl NO-SOURCE> Task :react-native-reanimated:preBuild UP-TO-DATE> Task :react-native-reanimated:preReleaseBuild UP-TO-DATE> Task :react-native-safe-area-context:preBuild UP-TO-DATE> Task :react-native-safe-area-context:preReleaseBuild UP-TO-DATE> Task :react-native-safe-area-context:compileReleaseAidl NO-SOURCE> Task :react-native-screens:preBuild UP-TO-DATE> Task :react-native-screens:preReleaseBuild UP-TO-DATE> Task :react-native-screens:compileReleaseAidl NO-SOURCE> Task :react-native-search-bar:preBuild UP-TO-DATE> Task :react-native-search-bar:preReleaseBuild UP-TO-DATE> Task :react-native-search-bar:compileReleaseAidl NO-SOURCE> Task :react-native-reanimated:compileReleaseAidl NO-SOURCE> Task :react-native-sodium:preBuild UP-TO-DATE> Task :react-native-sodium:preReleaseBuild UP-TO-DATE> Task :react-native-sodium:compileReleaseAidl NO-SOURCE> Task :react-native-vector-icons:preBuild UP-TO-DATE> Task :react-native-vector-icons:preReleaseBuild UP-TO-DATE> Task :react-native-version-info:preBuild UP-TO-DATE> Task :react-native-version-info:preReleaseBuild UP-TO-DATE> Task :react-native-version-info:compileReleaseAidl NO-SOURCE> Task :react-native-vector-icons:compileReleaseAidl NO-SOURCE> Task :react-native-webview:preBuild UP-TO-DATE> Task :react-native-webview:preReleaseBuild UP-TO-DATE> Task :sn-textview:preBuild UP-TO-DATE> Task :react-native-webview:compileReleaseAidl NO-SOURCE> Task :sn-textview:preReleaseBuild UP-TO-DATE> Task :sn-textview:compileReleaseAidl NO-SOURCE> Task :standard-notes-rn:preBuild UP-TO-DATE> Task :standard-notes-rn:preReleaseBuild UP-TO-DATE> Task :standard-notes-rn:compileReleaseAidl NO-SOURCE> Task :app:compileProdReleaseAidl NO-SOURCE> Task :react-native-aes-crypto:packageReleaseRenderscript NO-SOURCE> Task :react-native-community_async-storage:packageReleaseRenderscript NO-SOURCE> Task :react-native-community_masked-view:packageReleaseRenderscript NO-SOURCE> Task :react-native-community_netinfo:packageReleaseRenderscript NO-SOURCE> Task :react-native-default-preference:packageReleaseRenderscript NO-SOURCE> Task :react-native-document-picker:packageReleaseRenderscript NO-SOURCE> Task :react-native-file-viewer:packageReleaseRenderscript NO-SOURCE> Task :react-native-fingerprint-scanner:packageReleaseRenderscript NO-SOURCE> Task :react-native-flag-secure-android:packageReleaseRenderscript NO-SOURCE> Task :react-native-fs:packageReleaseRenderscript NO-SOURCE> Task :react-native-gesture-handler:packageReleaseRenderscript NO-SOURCE> Task :react-native-keychain:packageReleaseRenderscript NO-SOURCE> Task :react-native-mail:packageReleaseRenderscript NO-SOURCE> Task :react-native-reanimated:packageReleaseRenderscript NO-SOURCE> Task :react-native-safe-area-context:packageReleaseRenderscript NO-SOURCE> Task :react-native-screens:packageReleaseRenderscript NO-SOURCE> Task :react-native-search-bar:packageReleaseRenderscript NO-SOURCE> Task :react-native-sodium:packageReleaseRenderscript NO-SOURCE> Task :react-native-vector-icons:packageReleaseRenderscript NO-SOURCE> Task :react-native-version-info:packageReleaseRenderscript NO-SOURCE> Task :react-native-webview:packageReleaseRenderscript NO-SOURCE> Task :sn-textview:packageReleaseRenderscript NO-SOURCE> Task :standard-notes-rn:packageReleaseRenderscript NO-SOURCE> Task :app:compileProdReleaseRenderscript NO-SOURCE> Task :app:checkProdReleaseManifest> Task :app:generateProdReleaseBuildConfig> Task :react-native-aes-crypto:checkReleaseManifest> Task :react-native-aes-crypto:compileReleaseRenderscript NO-SOURCE> Task :react-native-aes-crypto:generateReleaseBuildConfig> Task :react-native-aes-crypto:generateReleaseResValues> Task :react-native-aes-crypto:generateReleaseResources> Task :react-native-aes-crypto:packageReleaseResources> Task :react-native-aes-crypto:parseReleaseLibraryResources> Task :react-native-aes-crypto:processReleaseManifest> Task :react-native-aes-crypto:javaPreCompileRelease> Task :react-native-community_async-storage:checkReleaseManifest> Task :react-native-community_async-storage:compileReleaseRenderscript NO-SOURCE> Task :react-native-community_async-storage:generateReleaseBuildConfig> Task :react-native-community_async-storage:generateReleaseResValues> Task :react-native-community_async-storage:generateReleaseResources> Task :react-native-community_async-storage:packageReleaseResources> Task :react-native-community_async-storage:parseReleaseLibraryResources> Task :react-native-community_async-storage:processReleaseManifest> Task :react-native-community_async-storage:javaPreCompileRelease> Task :react-native-community_masked-view:checkReleaseManifest> Task :react-native-community_masked-view:compileReleaseRenderscript NO-SOURCE> Task :react-native-community_masked-view:generateReleaseBuildConfig> Task :react-native-community_masked-view:generateReleaseResValues> Task :react-native-community_masked-view:generateReleaseResources> Task :react-native-community_masked-view:packageReleaseResources> Task :react-native-community_masked-view:parseReleaseLibraryResources> Task :react-native-community_netinfo:compileReleaseRenderscript NO-SOURCE> Task :react-native-community_netinfo:checkReleaseManifest> Task :react-native-community_netinfo:generateReleaseBuildConfig> Task :react-native-community_masked-view:javaPreCompileRelease> Task :react-native-community_netinfo:generateReleaseResValues> Task :react-native-community_netinfo:generateReleaseResources> Task :react-native-community_netinfo:packageReleaseResources> Task :react-native-community_masked-view:processReleaseManifest> Task :react-native-community_netinfo:processReleaseManifest> Task :react-native-aes-crypto:generateReleaseRFile> Task :react-native-aes-crypto:compileReleaseJavaWithJavac> Task :react-native-community_netinfo:javaPreCompileRelease> Task :react-native-community_async-storage:generateReleaseRFile> Task :react-native-community_async-storage:compileReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-community_netinfo:parseReleaseLibraryResources> Task :react-native-community_async-storage:bundleLibCompileRelease> Task :react-native-community_masked-view:generateReleaseRFile> Task :react-native-community_masked-view:compileReleaseJavaWithJavac> Task :react-native-community_netinfo:generateReleaseRFile> Task :react-native-community_netinfo:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-community_netinfo:bundleLibCompileRelease> Task :react-native-default-preference:compileReleaseRenderscript NO-SOURCE> Task :react-native-default-preference:checkReleaseManifest> Task :react-native-default-preference:generateReleaseBuildConfig> Task :react-native-default-preference:generateReleaseResValues> Task :react-native-default-preference:generateReleaseResources> Task :react-native-aes-crypto:bundleLibCompileRelease> Task :react-native-default-preference:packageReleaseResources> Task :react-native-community_masked-view:bundleLibCompileRelease> Task :react-native-default-preference:processReleaseManifest> Task :react-native-default-preference:parseReleaseLibraryResources> Task :react-native-default-preference:javaPreCompileRelease> Task :react-native-document-picker:compileReleaseRenderscript NO-SOURCE> Task :react-native-document-picker:checkReleaseManifest> Task :react-native-document-picker:generateReleaseBuildConfig> Task :react-native-document-picker:generateReleaseResValues> Task :react-native-document-picker:generateReleaseResources> Task :react-native-document-picker:packageReleaseResources> Task :react-native-document-picker:parseReleaseLibraryResources> Task :react-native-file-viewer:compileReleaseRenderscript NO-SOURCE> Task :react-native-file-viewer:checkReleaseManifest> Task :react-native-file-viewer:generateReleaseBuildConfig> Task :react-native-document-picker:processReleaseManifest> Task :react-native-default-preference:generateReleaseRFile> Task :react-native-default-preference:compileReleaseJavaWithJavac> Task :react-native-document-picker:generateReleaseRFile> Task :react-native-default-preference:bundleLibCompileRelease> Task :react-native-file-viewer:generateReleaseResValues> Task :react-native-file-viewer:generateReleaseResources> Task :react-native-file-viewer:packageReleaseResources> Task :react-native-file-viewer:parseReleaseLibraryResources> Task :react-native-file-viewer:javaPreCompileRelease> Task :react-native-document-picker:javaPreCompileRelease> Task :react-native-document-picker:compileReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/node_modules/react-native-document-picker/android/src/main/java/io/github/elyx0/reactnativedocumentpicker/DocumentPickerModule.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-document-picker:bundleLibCompileRelease> Task :react-native-file-viewer:processReleaseManifest> Task :react-native-fingerprint-scanner:checkReleaseManifest> Task :react-native-fingerprint-scanner:compileReleaseRenderscript NO-SOURCE> Task :react-native-fingerprint-scanner:generateReleaseBuildConfig> Task :react-native-fingerprint-scanner:generateReleaseResValues> Task :react-native-fingerprint-scanner:generateReleaseResources> Task :react-native-fingerprint-scanner:packageReleaseResources> Task :react-native-fingerprint-scanner:processReleaseManifest> Task :react-native-file-viewer:generateReleaseRFile> Task :react-native-file-viewer:compileReleaseJavaWithJavac> Task :react-native-file-viewer:bundleLibCompileRelease> Task :react-native-fingerprint-scanner:parseReleaseLibraryResources> Task :react-native-fingerprint-scanner:javaPreCompileRelease> Task :react-native-flag-secure-android:checkReleaseManifest> Task :react-native-flag-secure-android:compileReleaseRenderscript NO-SOURCE> Task :react-native-flag-secure-android:generateReleaseBuildConfig> Task :react-native-flag-secure-android:generateReleaseResValues> Task :react-native-flag-secure-android:generateReleaseResources> Task :react-native-flag-secure-android:packageReleaseResources> Task :react-native-flag-secure-android:parseReleaseLibraryResources> Task :react-native-flag-secure-android:processReleaseManifest> Task :react-native-flag-secure-android:javaPreCompileRelease> Task :react-native-fs:compileReleaseRenderscript NO-SOURCE> Task :react-native-fs:checkReleaseManifest> Task :react-native-fs:generateReleaseBuildConfig> Task :react-native-fingerprint-scanner:generateReleaseRFile> Task :react-native-fingerprint-scanner:compileReleaseJavaWithJavac> Task :react-native-flag-secure-android:generateReleaseRFile> Task :react-native-flag-secure-android:compileReleaseJavaWithJavac> Task :react-native-fingerprint-scanner:bundleLibCompileRelease> Task :react-native-fs:generateReleaseResValues> Task :react-native-fs:generateReleaseResources> Task :react-native-fs:packageReleaseResources> Task :react-native-fs:parseReleaseLibraryResources> Task :react-native-flag-secure-android:bundleLibCompileRelease> Task :react-native-gesture-handler:checkReleaseManifest> Task :react-native-gesture-handler:compileReleaseRenderscript NO-SOURCE> Task :react-native-gesture-handler:generateReleaseBuildConfig> Task :react-native-fs:processReleaseManifest> Task :react-native-fs:javaPreCompileRelease> Task :react-native-gesture-handler:generateReleaseResValues> Task :react-native-gesture-handler:generateReleaseResources> Task :react-native-gesture-handler:packageReleaseResources> Task :react-native-gesture-handler:parseReleaseLibraryResources> Task :react-native-gesture-handler:processReleaseManifest> Task :react-native-keychain:compileReleaseRenderscript NO-SOURCE> Task :react-native-keychain:checkReleaseManifest> Task :react-native-keychain:generateReleaseBuildConfig> Task :react-native-fs:generateReleaseRFile> Task :react-native-fs:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-gesture-handler:generateReleaseRFile> Task :react-native-gesture-handler:javaPreCompileRelease> Task :react-native-gesture-handler:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: Some input files use unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.> Task :react-native-fs:bundleLibCompileRelease> Task :react-native-keychain:generateReleaseResValues> Task :react-native-keychain:generateReleaseResources> Task :react-native-keychain:packageReleaseResources> Task :react-native-keychain:parseReleaseLibraryResources> Task :react-native-keychain:javaPreCompileRelease> Task :react-native-keychain:processReleaseManifest> Task :react-native-gesture-handler:bundleLibCompileRelease> Task :react-native-mail:checkReleaseManifest> Task :react-native-mail:compileReleaseRenderscript NO-SOURCE> Task :react-native-mail:generateReleaseBuildConfig> Task :react-native-mail:generateReleaseResValues> Task :react-native-mail:generateReleaseResources> Task :react-native-mail:packageReleaseResources> Task :react-native-mail:parseReleaseLibraryResources> Task :react-native-keychain:generateReleaseRFile> Task :react-native-keychain:compileReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/DeviceAvailability.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-keychain:bundleLibCompileRelease> Task :react-native-mail:processReleaseManifest> Task :react-native-mail:javaPreCompileRelease> Task :react-native-reanimated:checkReleaseManifest> Task :react-native-reanimated:generateReleaseBuildConfig> Task :react-native-reanimated:compileReleaseRenderscript NO-SOURCE> Task :react-native-reanimated:generateReleaseResValues> Task :react-native-reanimated:generateReleaseResources> Task :react-native-reanimated:packageReleaseResources> Task :react-native-reanimated:parseReleaseLibraryResources> Task :react-native-reanimated:processReleaseManifest> Task :react-native-mail:generateReleaseRFile> Task :react-native-mail:compileReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/node_modules/react-native-mail/android/src/main/java/com/chirag/RNMail/RNMailModule.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-mail:bundleLibCompileRelease> Task :react-native-safe-area-context:compileReleaseRenderscript NO-SOURCE> Task :react-native-safe-area-context:checkReleaseManifest> Task :react-native-safe-area-context:generateReleaseBuildConfig> Task :react-native-reanimated:generateReleaseRFile> Task :react-native-safe-area-context:generateReleaseResValues> Task :react-native-safe-area-context:generateReleaseResources> Task :react-native-safe-area-context:packageReleaseResources> Task :react-native-reanimated:javaPreCompileRelease> Task :react-native-reanimated:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: /home/vagrant/build/com.standardnotes/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.> Task :react-native-safe-area-context:parseReleaseLibraryResources> Task :react-native-reanimated:bundleLibCompileRelease> Task :react-native-safe-area-context:javaPreCompileRelease> Task :react-native-safe-area-context:processReleaseManifest> Task :react-native-screens:checkReleaseManifest> Task :react-native-screens:compileReleaseRenderscript NO-SOURCE> Task :react-native-screens:generateReleaseBuildConfig> Task :react-native-safe-area-context:generateReleaseRFile> Task :react-native-safe-area-context:compileReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/node_modules/react-native-safe-area-context/android/src/main/java/com/th3rdwave/safeareacontext/SafeAreaUtils.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-safe-area-context:bundleLibCompileRelease> Task :react-native-screens:generateReleaseResValues> Task :react-native-screens:generateReleaseResources> Task :react-native-screens:packageReleaseResources> Task :react-native-screens:parseReleaseLibraryResources> Task :react-native-search-bar:compileReleaseRenderscript NO-SOURCE> Task :react-native-screens:processReleaseManifest> Task :react-native-search-bar:checkReleaseManifest> Task :react-native-search-bar:generateReleaseBuildConfig> Task :react-native-screens:javaPreCompileRelease> Task :react-native-search-bar:generateReleaseResValues> Task :react-native-search-bar:generateReleaseResources> Task :react-native-search-bar:packageReleaseResources> Task :react-native-search-bar:parseReleaseLibraryResources> Task :react-native-search-bar:javaPreCompileRelease> Task :react-native-search-bar:processReleaseManifest> Task :react-native-sodium:compileReleaseRenderscript NO-SOURCE> Task :react-native-sodium:checkReleaseManifest> Task :react-native-sodium:generateReleaseBuildConfig> Task :react-native-sodium:generateReleaseResValues> Task :react-native-sodium:generateReleaseResources> Task :react-native-sodium:packageReleaseResources> Task :react-native-sodium:parseReleaseLibraryResources> Task :react-native-sodium:processReleaseManifest> Task :react-native-screens:generateReleaseRFile> Task :react-native-screens:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: Some input files use unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.> Task :react-native-sodium:javaPreCompileRelease> Task :react-native-search-bar:generateReleaseRFile> Task :react-native-search-bar:compileReleaseJavaWithJavac> Task :react-native-screens:bundleLibCompileRelease> Task :react-native-vector-icons:compileReleaseRenderscript NO-SOURCE> Task :react-native-vector-icons:checkReleaseManifest> Task :react-native-vector-icons:generateReleaseBuildConfig> Task :react-native-sodium:generateReleaseRFile> Task :react-native-sodium:compileReleaseJavaWithJavac> Task :react-native-search-bar:bundleLibCompileRelease> Task :react-native-sodium:bundleLibCompileRelease> Task :react-native-vector-icons:generateReleaseResValues> Task :react-native-vector-icons:generateReleaseResources> Task :react-native-vector-icons:packageReleaseResources> Task :react-native-vector-icons:parseReleaseLibraryResources> Task :react-native-vector-icons:javaPreCompileRelease> Task :react-native-vector-icons:processReleaseManifest> Task :react-native-version-info:compileReleaseRenderscript NO-SOURCE> Task :react-native-version-info:checkReleaseManifest> Task :react-native-version-info:generateReleaseBuildConfig> Task :react-native-version-info:generateReleaseResValues> Task :react-native-version-info:generateReleaseResources> Task :react-native-version-info:packageReleaseResources> Task :react-native-version-info:parseReleaseLibraryResources> Task :react-native-version-info:processReleaseManifest> Task :react-native-version-info:javaPreCompileRelease> Task :react-native-webview:checkReleaseManifest> Task :react-native-webview:compileReleaseRenderscript NO-SOURCE> Task :react-native-webview:generateReleaseBuildConfig> Task :react-native-webview:generateReleaseResValues> Task :react-native-webview:generateReleaseResources> Task :react-native-vector-icons:generateReleaseRFile> Task :react-native-vector-icons:compileReleaseJavaWithJavac> Task :react-native-webview:packageReleaseResources> Task :react-native-vector-icons:bundleLibCompileRelease> Task :react-native-version-info:generateReleaseRFile> Task :react-native-version-info:compileReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/node_modules/react-native-version-info/android/src/main/java/cx/evermeet/versioninfo/RNVersionInfoModule.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :react-native-webview:processReleaseManifest> Task :sn-textview:compileReleaseRenderscript NO-SOURCE> Task :sn-textview:checkReleaseManifest> Task :sn-textview:generateReleaseBuildConfig> Task :sn-textview:generateReleaseResValues> Task :sn-textview:generateReleaseResources> Task :sn-textview:packageReleaseResources> Task :sn-textview:parseReleaseLibraryResources> Task :sn-textview:processReleaseManifest> Task :react-native-webview:parseReleaseLibraryResources> Task :react-native-version-info:bundleLibCompileRelease> Task :sn-textview:javaPreCompileRelease> Task :standard-notes-rn:checkReleaseManifest> Task :standard-notes-rn:compileReleaseRenderscript NO-SOURCE> Task :standard-notes-rn:generateReleaseBuildConfig> Task :standard-notes-rn:generateReleaseResValues> Task :standard-notes-rn:generateReleaseResources> Task :standard-notes-rn:packageReleaseResources> Task :standard-notes-rn:processReleaseManifest> Task :standard-notes-rn:javaPreCompileRelease> Task :sn-textview:generateReleaseRFile> Task :sn-textview:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: /home/vagrant/build/com.standardnotes/node_modules/sn-textview/android/src/main/java/com/standardnotes/sntextview/TextViewManager.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.> Task :sn-textview:bundleLibCompileRelease> Task :standard-notes-rn:parseReleaseLibraryResources> Task :react-native-webview:generateReleaseRFile> Task :react-native-webview:compileReleaseKotlin> Task :standard-notes-rn:generateReleaseRFile> Task :standard-notes-rn:compileReleaseJavaWithJavac> Task :react-native-webview:javaPreCompileRelease> Task :react-native-webview:compileReleaseJavaWithJavacNote: Some input files use or override a deprecated API.Note: Recompile with -Xlint:deprecation for details.Note: /home/vagrant/build/com.standardnotes/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.> Task :standard-notes-rn:bundleLibCompileRelease> Task :react-native-webview:bundleLibCompileRelease> Task :app:javaPreCompileProdRelease> Task :app:mergeProdReleaseShaders> Task :app:compileProdReleaseShaders> Task :app:generateProdReleaseAssets> Task :react-native-aes-crypto:mergeReleaseShaders> Task :react-native-aes-crypto:compileReleaseShaders> Task :react-native-aes-crypto:generateReleaseAssets> Task :react-native-aes-crypto:packageReleaseAssets> Task :react-native-community_async-storage:mergeReleaseShaders> Task :react-native-community_async-storage:compileReleaseShaders> Task :react-native-community_async-storage:generateReleaseAssets> Task :react-native-community_async-storage:packageReleaseAssets> Task :react-native-community_masked-view:mergeReleaseShaders> Task :react-native-community_masked-view:compileReleaseShaders> Task :react-native-community_masked-view:generateReleaseAssets> Task :react-native-community_masked-view:packageReleaseAssets> Task :react-native-community_netinfo:mergeReleaseShaders> Task :react-native-community_netinfo:compileReleaseShaders> Task :react-native-community_netinfo:generateReleaseAssets> Task :react-native-community_netinfo:packageReleaseAssets> Task :react-native-default-preference:mergeReleaseShaders> Task :react-native-default-preference:compileReleaseShaders> Task :react-native-default-preference:generateReleaseAssets> Task :react-native-default-preference:packageReleaseAssets> Task :react-native-document-picker:mergeReleaseShaders> Task :react-native-document-picker:compileReleaseShaders> Task :react-native-document-picker:generateReleaseAssets> Task :react-native-document-picker:packageReleaseAssets> Task :react-native-file-viewer:mergeReleaseShaders> Task :react-native-file-viewer:compileReleaseShaders> Task :react-native-file-viewer:generateReleaseAssets> Task :react-native-file-viewer:packageReleaseAssets> Task :react-native-fingerprint-scanner:mergeReleaseShaders> Task :react-native-fingerprint-scanner:compileReleaseShaders> Task :react-native-fingerprint-scanner:generateReleaseAssets> Task :react-native-fingerprint-scanner:packageReleaseAssets> Task :react-native-flag-secure-android:mergeReleaseShaders> Task :react-native-flag-secure-android:compileReleaseShaders> Task :react-native-flag-secure-android:generateReleaseAssets> Task :react-native-flag-secure-android:packageReleaseAssets> Task :react-native-fs:mergeReleaseShaders> Task :react-native-fs:compileReleaseShaders> Task :react-native-fs:generateReleaseAssets> Task :react-native-fs:packageReleaseAssets> Task :react-native-gesture-handler:mergeReleaseShaders> Task :react-native-gesture-handler:compileReleaseShaders> Task :react-native-gesture-handler:generateReleaseAssets> Task :react-native-gesture-handler:packageReleaseAssets> Task :react-native-keychain:mergeReleaseShaders> Task :react-native-keychain:compileReleaseShaders> Task :react-native-keychain:generateReleaseAssets> Task :react-native-keychain:packageReleaseAssets> Task :react-native-mail:mergeReleaseShaders> Task :react-native-mail:compileReleaseShaders> Task :react-native-mail:generateReleaseAssets> Task :react-native-mail:packageReleaseAssets> Task :react-native-reanimated:mergeReleaseShaders> Task :react-native-reanimated:compileReleaseShaders> Task :react-native-reanimated:generateReleaseAssets> Task :react-native-reanimated:packageReleaseAssets> Task :react-native-safe-area-context:mergeReleaseShaders> Task :react-native-safe-area-context:compileReleaseShaders> Task :react-native-safe-area-context:generateReleaseAssets> Task :react-native-safe-area-context:packageReleaseAssets> Task :react-native-screens:mergeReleaseShaders> Task :react-native-screens:compileReleaseShaders> Task :react-native-screens:generateReleaseAssets> Task :react-native-screens:packageReleaseAssets> Task :react-native-search-bar:mergeReleaseShaders> Task :react-native-search-bar:compileReleaseShaders> Task :react-native-search-bar:generateReleaseAssets> Task :react-native-search-bar:packageReleaseAssets> Task :react-native-sodium:mergeReleaseShaders> Task :react-native-sodium:compileReleaseShaders> Task :react-native-sodium:generateReleaseAssets> Task :react-native-sodium:packageReleaseAssets> Task :react-native-vector-icons:mergeReleaseShaders> Task :react-native-vector-icons:compileReleaseShaders> Task :react-native-vector-icons:generateReleaseAssets> Task :react-native-vector-icons:packageReleaseAssets> Task :react-native-version-info:mergeReleaseShaders> Task :react-native-version-info:compileReleaseShaders> Task :react-native-version-info:generateReleaseAssets> Task :react-native-version-info:packageReleaseAssets> Task :react-native-webview:mergeReleaseShaders> Task :react-native-webview:compileReleaseShaders> Task :react-native-webview:generateReleaseAssets> Task :react-native-webview:packageReleaseAssets> Task :sn-textview:mergeReleaseShaders> Task :sn-textview:compileReleaseShaders> Task :sn-textview:generateReleaseAssets> Task :sn-textview:packageReleaseAssets> Task :standard-notes-rn:mergeReleaseShaders> Task :standard-notes-rn:compileReleaseShaders> Task :standard-notes-rn:generateReleaseAssets> Task :standard-notes-rn:packageReleaseAssets> Task :app:mergeProdReleaseAssets> Task :app:bundleProdReleaseJsAndAssetswarning: the transform cache was reset.Welcome to Metro!Fast - Scalable - Integratedinfo Writing bundle output to:, /home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundleinfo Writing sourcemap output to:, /home/vagrant/build/com.standardnotes/android/app/build/intermediates/sourcemaps/react/prod/release/index.android.bundle.packager.mapinfo Done writing bundle outputinfo Done writing sourcemap outputinfo Copying 15 asset filesinfo Done copying assets/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:26:144: warning: the variable "Promise" was not declared in function "isBoldTextEnabled"__d(function(g,r,i,a,m,e,d){'use strict';var n=r(d[0]),t=n(r(d[1])),s=n(r(d[2])),o=n(r(d[3])),c=new Map,u={isBoldTextEnabled:function(){return Promise.resolve(!1)},isGrayscaleEnabled:function(){return Promise.resolve(!1)},isInvertColorsEnabled:function(){return Promise.resolve(!1)},isReduceMotionEnabled:function(){return new Promise(function(n,t){o.default?o.default.isReduceMotionEnabled(n):t(!1)})},isReduceTransparencyEnabled:function(){return Promise.resolve(!1)},isScreenReaderEnabled:function(){return new Promise(function(n,t){o.default?o.default.isTouchExplorationEnabled(n):t(!1)})},get fetch(){return console.warn('AccessibilityInfo.fetch is deprecated, call AccessibilityInfo.isScreenReaderEnabled instead'),this.isScreenReaderEnabled},addEventListener:function(n,s){var o;'change'===n||'screenReaderChanged'===n?o=t.default.addListener("touchExplorationDidChange",s):'reduceMotionChanged'===n&&(o=t.default.addListener("reduceMotionDidChange",s)),c.set(s,o)},removeEventListener:function(n,t){var s=c.get(t);s&&(s.remove(),c.delete(t))},setAccessibilityFocus:function(n){s.default.sendAccessibilityEvent(n,s.default.getConstants().AccessibilityEventTypes.typeViewFocused)},announceForAccessibility:function(n){o.default&&o.default.announceForAccessibility(n)}};m.exports=u},20,[2,21,29,55]);^~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:48:2647: warning: the variable "DebuggerInternal" was not declared in function "value 30#"__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),l=r(d[1]),u=r(d[2]),s=r(d[3]),n=r(d[4]),h=(r(d[5]),r(d[6])),o=r(d[7]).default,c=(r(d[8]),(function(){function c(){l(this,c),this._lazyCallableModules={},this._queue=[[],[],[],0],this._successCallbacks=new Map,this._failureCallbacks=new Map,this._callID=0,this._lastFlush=0,this._eventLoopStartTime=Date.now(),this._immediatesCallback=null,this.callFunctionReturnFlushedQueue=this.callFunctionReturnFlushedQueue.bind(this),this.flushedQueue=this.flushedQueue.bind(this),this.invokeCallbackAndReturnFlushedQueue=this.invokeCallbackAndReturnFlushedQueue.bind(this)}return u(c,[{key:"callFunctionReturnFlushedQueue",value:function(t,l,u){var s=this;return this.__guard(function(){s.__callFunction(t,l,u)}),this.flushedQueue()}},{key:"invokeCallbackAndReturnFlushedQueue",value:function(t,l){var u=this;return this.__guard(function(){u.__invokeCallback(t,l)}),this.flushedQueue()}},{key:"flushedQueue",value:function(){var t=this;this.__guard(function(){t.__callImmediates()});var l=this._queue;return this._queue=[[],[],[],this._callID],l[0].length?l:null}},{key:"getEventLoopRunningTime",value:function(){return Date.now()-this._eventLoopStartTime}},{key:"registerCallableModule",value:function(t,l){this._lazyCallableModules[t]=function(){return l}}},{key:"registerLazyCallableModule",value:function(t,l){var u,s=l;this._lazyCallableModules[t]=function(){return s&&(u=s(),s=null),u}}},{key:"getCallableModule",value:function(t){var l=this._lazyCallableModules[t];return l?l():null}},{key:"callNativeSyncHook",value:function(t,l,u,s,n){return this.processCallbacks(t,l,u,s,n),g.nativeCallSyncHook(t,l,u)}},{key:"processCallbacks",value:function(t,l,u,s,n){(s||n)&&(s&&u.push(this._callID<<1),n&&u.push(this._callID<<1|1),this._successCallbacks.set(this._callID,n),this._failureCallbacks.set(this._callID,s)),this._callID++}},{key:"enqueueNativeCall",value:function(t,l,u,s,h){this.processCallbacks(t,l,u,s,h),this._queue[0].push(t),this._queue[1].push(l),this._queue[2].push(u);var o=Date.now();if(g.nativeFlushQueueImmediate&&o-this._lastFlush>=5){var c=this._queue;this._queue=[[],[],[],this._callID],this._lastFlush=o,g.nativeFlushQueueImmediate(c)}n.counterEvent('pending_js_to_native_queue',this._queue[0].length),this.__spy&&this.__spy({type:1,module:t+'',method:l,args:u})}},{key:"createDebugLookup",value:function(t,l,u){}},{key:"setImmediatesCallback",value:function(t){this._immediatesCallback=t}},{key:"__guard",value:function(t){if(this.__shouldPauseOnThrow())t();else try{t()}catch(t){s.reportFatalError(t)}}},{key:"__shouldPauseOnThrow",value:function(){return'undefined'!=typeof DebuggerInternal&&!0===DebuggerInternal.shouldPauseOnThrow}},{key:"__callImmediates",value:function(){n.beginEvent('JSTimers.callImmediates()'),null!=this._immediatesCallback&&this._immediatesCallback(),n.endEvent()}},{key:"__callFunction",value:function(t,l,u){this._lastFlush=Date.now(),this._eventLoopStartTime=this._lastFlush,this.__spy?n.beginEvent(t+"."+l+"("+o(u)+")"):n.beginEvent(t+"."+l+"(...)"),this.__spy&&this.__spy({type:0,module:t,method:l,args:u});var s=this.getCallableModule(t);h(!!s,"Module "+t+" is not a registered callable module (calling "+l+"). A frequent cause of the error is that the application entry file path is incorrect. \n      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native."),h(!!s[l],"Method "+l+" does not exist on module "+t),s[l].apply(s,u),n.endEvent()}},{key:"__invokeCallback",value:function(l,u){this._lastFlush=Date.now(),this._eventLoopStartTime=this._lastFlush;var s=l>>>1,n=1&l?this._successCallbacks.get(s):this._failureCallbacks.get(s);n&&(this._successCallbacks.delete(s),this._failureCallbacks.delete(s),n.apply(void 0,t(u)))}}],[{key:"spy",value:function(t){c.prototype.__spy=!0===t?function(t){console.log((0===t.type?'N->JS':'JS->N')+" : "+(null!=t.module?t.module+'.':'')+t.method+"("+JSON.stringify(t.args)+")")}:!1===t?null:t}}]),c})());m.exports=c},42,[43,7,8,47,48,49,18,50,19]);^~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:94:63741: warning: the variable "setTimeout" was not declared in function "Bl"__d(function(e,n,t,r,l,a,i){"use strict";var u=n(i[0]);n(i[1]);var o=n(i[2]),s=n(i[3]),c=n(i[4]);function f(e,n,t,r,l,a,i,u,o){var s=Array.prototype.slice.call(arguments,3);try{n.apply(t,s)}catch(e){this.onError(e)}}var d=!1,p=null,h=!1,g=null,m={onError:function(e){d=!0,p=e}};function v(e,n,t,r,l,a,i,u,o){d=!1,p=null,f.apply(m,arguments)}function y(e,n,t,r,l,a,i,u,o){if(v.apply(this,arguments),d){if(!d)throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");var s=p;d=!1,p=null,h||(h=!0,g=s)}}var b=null,S=null,w=null;function k(e,n,t){var r=e.type||"unknown-event";e.currentTarget=w(t),y(r,n,void 0,e),e.currentTarget=null}function E(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))throw Error("executeDirectDispatch(...): Invalid `event`.");return e.currentTarget=n?w(t):null,n=n?n(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,n}function T(){return!0}function x(){return!1}function _(e,n,t,r){for(var l in this.dispatchConfig=e,this._targetInst=n,this.nativeEvent=t,this._dispatchInstances=this._dispatchListeners=null,e=this.constructor.Interface)e.hasOwnProperty(l)&&((n=e[l])?this[l]=n(t):"target"===l?this.target=r:this[l]=t[l]);return this.isDefaultPrevented=(null!=t.defaultPrevented?t.defaultPrevented:!1===t.returnValue)?T:x,this.isPropagationStopped=x,this}function R(e,n,t,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,n,t,r),l}return new this(e,n,t,r)}function P(e){if(!(e instanceof this))throw Error("Trying to release an event instance into a pool of a different type.");e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function C(e){e.getPooled=R,e.eventPool=[],e.release=P}u(_.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=T)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=T)},persist:function(){this.isPersistent=T},isPersistent:x,destructor:function(){var e,n=this.constructor.Interface;for(e in n)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=x,this._dispatchInstances=this._dispatchListeners=null}}),_.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},_.extend=function(e){function n(){}function t(){return r.apply(this,arguments)}var r=this;n.prototype=r.prototype;var l=new n;return u(l,t.prototype),t.prototype=l,t.prototype.constructor=t,t.Interface=u({},r.Interface,e),t.extend=r.extend,C(t),t},C(_);var N=_.extend({touchHistory:function(){return null}});function z(e){return"topTouchStart"===e}function I(e){return"topTouchMove"===e}var L=["topTouchStart"],U=["topTouchMove"],M=["topTouchCancel","topTouchEnd"],A=[],D={touchBank:A,numberActiveTouches:0,indexOfSingleActiveTouch:-1,mostRecentTimeStamp:0};function Q(e){return e.timeStamp||e.timestamp}function B(e){if(null==(e=e.identifier))throw Error("Touch object is missing identifier.");return e}function F(e){var n=B(e),t=A[n];t?(t.touchActive=!0,t.startPageX=e.pageX,t.startPageY=e.pageY,t.startTimeStamp=Q(e),t.currentPageX=e.pageX,t.currentPageY=e.pageY,t.currentTimeStamp=Q(e),t.previousPageX=e.pageX,t.previousPageY=e.pageY,t.previousTimeStamp=Q(e)):(t={touchActive:!0,startPageX:e.pageX,startPageY:e.pageY,startTimeStamp:Q(e),currentPageX:e.pageX,currentPageY:e.pageY,currentTimeStamp:Q(e),previousPageX:e.pageX,previousPageY:e.pageY,previousTimeStamp:Q(e)},A[n]=t),D.mostRecentTimeStamp=Q(e)}function j(e){var n=A[B(e)];n&&(n.touchActive=!0,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}function O(e){var n=A[B(e)];n&&(n.touchActive=!1,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}var H={recordTouchTrack:function(e,n){if(I(e))n.changedTouches.forEach(j);else if(z(e))n.changedTouches.forEach(F),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches&&(D.indexOfSingleActiveTouch=n.touches[0].identifier);else if(("topTouchEnd"===e||"topTouchCancel"===e)&&(n.changedTouches.forEach(O),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches))for(e=0;e<A.length;e++)if(null!=(n=A[e])&&n.touchActive){D.indexOfSingleActiveTouch=e;break}},touchHistory:D};function V(e,n){if(null==n)throw Error("accumulate(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?e.concat(n):Array.isArray(n)?[e].concat(n):[e,n]}function W(e,n){if(null==n)throw Error("accumulateInto(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?Array.isArray(n)?(e.push.apply(e,n),e):(e.push(n),e):Array.isArray(n)?[e].concat(n):[e,n]}function Y(e,n,t){Array.isArray(e)?e.forEach(n,t):e&&n.call(t,e)}var q=null,X=0;function $(e,n){var t=q;q=e,null!==le.GlobalResponderHandler&&le.GlobalResponderHandler.onChange(t,e,n)}var G={startShouldSetResponder:{phasedRegistrationNames:{bubbled:"onStartShouldSetResponder",captured:"onStartShouldSetResponderCapture"},dependencies:L},scrollShouldSetResponder:{phasedRegistrationNames:{bubbled:"onScrollShouldSetResponder",captured:"onScrollShouldSetResponderCapture"},dependencies:["topScroll"]},selectionChangeShouldSetResponder:{phasedRegistrationNames:{bubbled:"onSelectionChangeShouldSetResponder",captured:"onSelectionChangeShouldSetResponderCapture"},dependencies:["topSelectionChange"]},moveShouldSetResponder:{phasedRegistrationNames:{bubbled:"onMoveShouldSetResponder",captured:"onMoveShouldSetResponderCapture"},dependencies:U},responderStart:{registrationName:"onResponderStart",dependencies:L},responderMove:{registrationName:"onResponderMove",dependencies:U},responderEnd:{registrationName:"onResponderEnd",dependencies:M},responderRelease:{registrationName:"onResponderRelease",dependencies:M},responderTerminationRequest:{registrationName:"onResponderTerminationRequest",dependencies:[]},responderGrant:{registrationName:"onResponderGrant",dependencies:[]},responderReject:{registrationName:"onResponderReject",dependencies:[]},responderTerminate:{registrationName:"onResponderTerminate",dependencies:[]}};function K(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function J(e,n,t){for(var r=[];e;)r.push(e),e=K(e);for(e=r.length;0<e--;)n(r[e],"captured",t);for(e=0;e<r.length;e++)n(r[e],"bubbled",t)}function Z(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}function ee(e,n,t){(n=Z(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function ne(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=Z(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}function te(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var n=e._targetInst;J(n=n?K(n):null,ee,e)}}function re(e){e&&e.dispatchConfig.phasedRegistrationNames&&J(e._targetInst,ee,e)}var le={_getResponder:function(){return q},eventTypes:G,extractEvents:function(e,n,t,r){if(z(e))X+=1;else if("topTouchEnd"===e||"topTouchCancel"===e){if(!(0<=X))return null;--X}if(H.recordTouchTrack(e,t),n&&("topScroll"===e&&!t.responderIgnoreScroll||0<X&&"topSelectionChange"===e||z(e)||I(e))){var l=z(e)?G.startShouldSetResponder:I(e)?G.moveShouldSetResponder:"topSelectionChange"===e?G.selectionChangeShouldSetResponder:G.scrollShouldSetResponder;if(q)e:{for(var a=q,i=0,u=a;u;u=K(u))i++;u=0;for(var o=n;o;o=K(o))u++;for(;0<i-u;)a=K(a),i--;for(;0<u-i;)n=K(n),u--;for(;i--;){if(a===n||a===n.alternate)break e;a=K(a),n=K(n)}a=null}else a=n;a=(n=a)===q,(l=N.getPooled(l,n,t,r)).touchHistory=H.touchHistory,Y(l,a?te:re);e:{if(a=l._dispatchListeners,n=l._dispatchInstances,Array.isArray(a)){for(i=0;i<a.length&&!l.isPropagationStopped();i++)if(a[i](l,n[i])){a=n[i];break e}}else if(a&&a(l,n)){a=n;break e}a=null}if(l._dispatchInstances=null,l._dispatchListeners=null,l.isPersistent()||l.constructor.release(l),a&&a!==q)if((l=N.getPooled(G.responderGrant,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),n=!0===E(l),q)if((i=N.getPooled(G.responderTerminationRequest,q,t,r)).touchHistory=H.touchHistory,Y(i,ne),u=!i._dispatchListeners||E(i),i.isPersistent()||i.constructor.release(i),u){(i=N.getPooled(G.responderTerminate,q,t,r)).touchHistory=H.touchHistory,Y(i,ne);var s=V(s,[l,i]);$(a,n)}else(l=N.getPooled(G.responderReject,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l);else s=V(s,l),$(a,n);else s=null}else s=null;if(l=q&&z(e),a=q&&I(e),n=q&&("topTouchEnd"===e||"topTouchCancel"===e),(l=l?G.responderStart:a?G.responderMove:n?G.responderEnd:null)&&((l=N.getPooled(l,q,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l)),l=q&&"topTouchCancel"===e,e=q&&!l&&("topTouchEnd"===e||"topTouchCancel"===e))e:{if((e=t.touches)&&0!==e.length)for(a=0;a<e.length;a++)if(null!==(n=e[a].target)&&void 0!==n&&0!==n){i=S(n);n:{for(n=q;i;){if(n===i||n===i.alternate){n=!0;break n}i=K(i)}n=!1}if(n){e=!1;break e}}e=!0}return(e=l?G.responderTerminate:e?G.responderRelease:null)&&((t=N.getPooled(e,q,t,r)).touchHistory=H.touchHistory,Y(t,ne),s=V(s,t),$(null)),s},GlobalResponderHandler:null,injection:{injectGlobalResponderHandler:function(e){le.GlobalResponderHandler=e}}},ae=null,ie={};function ue(){if(ae)for(var e in ie){var n=ie[e],t=ae.indexOf(e);if(!(-1<t))throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `"+e+"`.");if(!se[t]){if(!n.extractEvents)throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `"+e+"` does not.");for(var r in se[t]=n,t=n.eventTypes){var l=void 0,a=t[r],i=r;if(ce.hasOwnProperty(i))throw Error("EventPluginRegistry: More than one plugin attempted to publish the same event name, `"+i+"`.");ce[i]=a;var u=a.phasedRegistrationNames;if(u){for(l in u)u.hasOwnProperty(l)&&oe(u[l],n);l=!0}else a.registrationName?(oe(a.registrationName,n),l=!0):l=!1;if(!l)throw Error("EventPluginRegistry: Failed to publish event `"+r+"` for plugin `"+e+"`.")}}}}function oe(e,n){if(fe[e])throw Error("EventPluginRegistry: More than one plugin attempted to publish the same registration name, `"+e+"`.");fe[e]=n}var se=[],ce={},fe={};function de(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}var pe=o.ReactNativeViewConfigRegistry.customBubblingEventTypes,he=o.ReactNativeViewConfigRegistry.customDirectEventTypes;function ge(e,n,t){(n=de(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function me(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var n=e._targetInst,t=[];n;){t.push(n);do{n=n.return}while(n&&5!==n.tag);n=n||null}for(n=t.length;0<n--;)ge(t[n],"captured",e);for(n=0;n<t.length;n++)ge(t[n],"bubbled",e)}}function ve(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=de(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}if(ae)throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.");ae=Array.prototype.slice.call(["ResponderEventPlugin","ReactNativeBridgeEventPlugin"]),ue();var ye,be={ResponderEventPlugin:le,ReactNativeBridgeEventPlugin:{eventTypes:{},extractEvents:function(e,n,t,r){if(null==n)return null;var l=pe[e],a=he[e];if(!l&&!a)throw Error('Unsupported top level event type "'+e+'" dispatched');if(e=_.getPooled(l||a,n,t,r),l)Y(e,me);else{if(!a)return null;Y(e,ve)}return e}}},Se=!1;for(ye in be)if(be.hasOwnProperty(ye)){var we=be[ye];if(!ie.hasOwnProperty(ye)||ie[ye]!==we){if(ie[ye])throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `"+ye+"`.");ie[ye]=we,Se=!0}}Se&&ue();var ke=new Map,Ee=new Map;function Te(e){return ke.get(e)||null}function xe(e,n){return e(n)}var _e=!1;function Re(e,n){if(_e)return e(n);_e=!0;try{return xe(e,n)}finally{_e=!1}}var Pe=null;function Ce(e){if(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))for(var r=0;r<n.length&&!e.isPropagationStopped();r++)k(e,n[r],t[r]);else n&&k(e,n,t);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}var Ne={};function ze(e,n,t){var r=t||Ne,l=Te(e),a=null;null!=l&&(a=l.stateNode),Re(function(){for(var e=a,t=null,i=se,u=0;u<i.length;u++){var o=i[u];o&&(o=o.extractEvents(n,l,r,e))&&(t=W(t,o))}if(null!==(e=t)&&(Pe=W(Pe,e)),e=Pe,Pe=null,e){if(Y(e,Ce),Pe)throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.");if(h)throw e=g,h=!1,g=null,e}})}o.RCTEventEmitter.register({receiveEvent:function(e,n,t){ze(e,n,t)},receiveTouches:function(e,n,t){if("topTouchEnd"===e||"topTouchCancel"===e){for(var r=[],l=0;l<t.length;l++){var a=t[l];r.push(n[a]),n[a]=null}for(l=t=0;l<n.length;l++)null!==(a=n[l])&&(n[t++]=a);n.length=t}else for(r=[],l=0;l<t.length;l++)r.push(n[t[l]]);for(t=0;t<r.length;t++){(l=r[t]).changedTouches=r,l.touches=n,a=null;var i=l.target;null===i||void 0===i||1>i||(a=i),ze(a,e,l)}}}),b=function(e){return Ee.get(e._nativeTag)||null},S=Te,w=function(e){var n=(e=e.stateNode)._nativeTag;if(void 0===n&&(n=(e=e.canonical)._nativeTag),!n)throw Error("All native instances should have a tag.");return e},le.injection.injectGlobalResponderHandler({onChange:function(e,n,t){null!==n?o.UIManager.setJSResponder(n.stateNode._nativeTag,t):o.UIManager.clearJSResponder()}});var Ie=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Le=60103,Ue=60106,Me=60107,Ae=60108,De=60114,Qe=60109,Be=60110,Fe=60112,je=60113,Oe=60120,He=60115,Ve=60116,We=60121,Ye=60129,qe=60130,Xe=60131;if("function"==typeof Symbol&&Symbol.for){var $e=Symbol.for;Le=$e("react.element"),Ue=$e("react.portal"),Me=$e("react.fragment"),Ae=$e("react.strict_mode"),De=$e("react.profiler"),Qe=$e("react.provider"),Be=$e("react.context"),Fe=$e("react.forward_ref"),je=$e("react.suspense"),Oe=$e("react.suspense_list"),He=$e("react.memo"),Ve=$e("react.lazy"),We=$e("react.block"),$e("react.scope"),Ye=$e("react.debug_trace_mode"),qe=$e("react.offscreen"),Xe=$e("react.legacy_hidden")}var Ge="function"==typeof Symbol&&Symbol.iterator;function Ke(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=Ge&&e[Ge]||e["@@iterator"])?e:null}function Je(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case Me:return"Fragment";case Ue:return"Portal";case De:return"Profiler";case Ae:return"StrictMode";case je:return"Suspense";case Oe:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case Be:return(e.displayName||"Context")+".Consumer";case Qe:return(e._context.displayName||"Context")+".Provider";case Fe:var n=e.render;return n=n.displayName||n.name||"",e.displayName||(""!==n?"ForwardRef("+n+")":"ForwardRef");case He:return Je(e.type);case We:return Je(e._render);case Ve:n=e._payload,e=e._init;try{return Je(e(n))}catch(e){}}return null}function Ze(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do{0!=(1026&(n=e).flags)&&(t=n.return),e=n.return}while(e)}return 3===n.tag?t:null}function en(e){if(Ze(e)!==e)throw Error("Unable to find node on an unmounted component.")}function nn(e){var n=e.alternate;if(!n){if(null===(n=Ze(e)))throw Error("Unable to find node on an unmounted component.");return n!==e?null:e}for(var t=e,r=n;;){var l=t.return;if(null===l)break;var a=l.alternate;if(null===a){if(null!==(r=l.return)){t=r;continue}break}if(l.child===a.child){for(a=l.child;a;){if(a===t)return en(l),e;if(a===r)return en(l),n;a=a.sibling}throw Error("Unable to find node on an unmounted component.")}if(t.return!==r.return)t=l,r=a;else{for(var i=!1,u=l.child;u;){if(u===t){i=!0,t=l,r=a;break}if(u===r){i=!0,r=l,t=a;break}u=u.sibling}if(!i){for(u=a.child;u;){if(u===t){i=!0,t=a,r=l;break}if(u===r){i=!0,r=a,t=l;break}u=u.sibling}if(!i)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(t.alternate!==r)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(3!==t.tag)throw Error("Unable to find node on an unmounted component.");return t.stateNode.current===t?e:n}function tn(e){if(!(e=nn(e)))return null;for(var n=e;;){if(5===n.tag||6===n.tag)return n;if(n.child)n.child.return=n,n=n.child;else{if(n===e)break;for(;!n.sibling;){if(!n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}}return null}function rn(e,n){for(var t=e.alternate;null!==n;){if(n===e||n===t)return!0;n=n.return}return!1}var ln={},an=null,un=0,on={unsafelyIgnoreFunctions:!0};function sn(e,n){return"object"!=typeof n||null===n||o.deepDiffer(e,n,on)}function cn(e,n,t){if(Array.isArray(n))for(var r=n.length;r--&&0<un;)cn(e,n[r],t);else if(n&&0<un)for(r in an)if(an[r]){var l=n[r];if(void 0!==l){var a=t[r];a&&("function"==typeof l&&(l=!0),void 0===l&&(l=null),"object"!=typeof a?e[r]=l:"function"!=typeof a.diff&&"function"!=typeof a.process||(l="function"==typeof a.process?a.process(l):l,e[r]=l),an[r]=!1,un--)}}}function fn(e,n,t,r){if(!e&&n===t)return e;if(!n||!t)return t?dn(e,t,r):n?pn(e,n,r):e;if(!Array.isArray(n)&&!Array.isArray(t))return hn(e,n,t,r);if(Array.isArray(n)&&Array.isArray(t)){var l,a=n.length<t.length?n.length:t.length;for(l=0;l<a;l++)e=fn(e,n[l],t[l],r);for(;l<n.length;l++)e=pn(e,n[l],r);for(;l<t.length;l++)e=dn(e,t[l],r);return e}return Array.isArray(n)?hn(e,o.flattenStyle(n),t,r):hn(e,n,o.flattenStyle(t),r)}function dn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,ln,n,t);for(var r=0;r<n.length;r++)e=dn(e,n[r],t);return e}function pn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,n,ln,t);for(var r=0;r<n.length;r++)e=pn(e,n[r],t);return e}function hn(e,n,t,r){var l,a;for(a in t)if(l=r[a]){var i=n[a],u=t[a];"function"==typeof u&&(u=!0,"function"==typeof i&&(i=!0)),void 0===u&&(u=null,void 0===i&&(i=null)),an&&(an[a]=!1),e&&void 0!==e[a]?"object"!=typeof l?e[a]=u:"function"!=typeof l.diff&&"function"!=typeof l.process||(l="function"==typeof l.process?l.process(u):u,e[a]=l):i!==u&&("object"!=typeof l?sn(i,u)&&((e||(e={}))[a]=u):"function"==typeof l.diff||"function"==typeof l.process?(void 0===i||("function"==typeof l.diff?l.diff(i,u):sn(i,u)))&&(l="function"==typeof l.process?l.process(u):u,(e||(e={}))[a]=l):(an=null,un=0,e=fn(e,i,u,l),0<un&&e&&(cn(e,u,l),an=null)))}for(var o in n)void 0===t[o]&&(!(l=r[o])||e&&void 0!==e[o]||void 0!==(i=n[o])&&("object"!=typeof l||"function"==typeof l.diff||"function"==typeof l.process?((e||(e={}))[o]=null,an||(an={}),an[o]||(an[o]=!0,un++)):e=pn(e,i,l)));return e}function gn(e,n){return function(){if(n&&("boolean"!=typeof e.__isMounted||e.__isMounted))return n.apply(e,arguments)}}var mn=(function(){function e(e,n){this._nativeTag=e,this._children=[],this.viewConfig=n}var n=e.prototype;return n.blur=function(){o.TextInputState.blurTextInput(this)},n.focus=function(){o.TextInputState.focusTextInput(this)},n.measure=function(e){o.UIManager.measure(this._nativeTag,gn(this,e))},n.measureInWindow=function(e){o.UIManager.measureInWindow(this._nativeTag,gn(this,e))},n.measureLayout=function(e,n,t){if("number"==typeof e)var r=e;else e._nativeTag&&(r=e._nativeTag);null!=r&&o.UIManager.measureLayout(this._nativeTag,r,gn(this,t),gn(this,n))},n.setNativeProps=function(e){null!=(e=hn(null,ln,e,this.viewConfig.validAttributes))&&o.UIManager.updateView(this._nativeTag,this.viewConfig.uiViewClassName,e)},e})();function vn(){throw Error("The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.")}var yn=o.ReactNativeViewConfigRegistry.get,bn={},Sn=3;function wn(){var e=Sn;return 1==e%10&&(e+=2),Sn=e+2,e}function kn(e){if("number"==typeof e)ke.delete(e),Ee.delete(e);else{var n=e._nativeTag;ke.delete(n),Ee.delete(n),e._children.forEach(kn)}}function En(e){if(0===e._children.length)return!1;var n=e._children.map(function(e){return"number"==typeof e?e:e._nativeTag});return o.UIManager.setChildren(e._nativeTag,n),!1}var Tn=setTimeout,xn=clearTimeout;function _n(e,n,t){return n="",t&&(n=" (created by "+t+")"),"\n    in "+(e||"Unknown")+n}function Rn(e,n){return e?_n(e.displayName||e.name||null,n,null):""}var Pn=[],Cn=-1;function Nn(e){return{current:e}}function zn(e){0>Cn||(e.current=Pn[Cn],Pn[Cn]=null,Cn--)}function In(e,n){Pn[++Cn]=e.current,e.current=n}var Ln={},Un=Nn(Ln),Mn=Nn(!1),An=Ln;function Dn(e,n){var t=e.type.contextTypes;if(!t)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===n)return r.__reactInternalMemoizedMaskedChildContext;var l,a={};for(l in t)a[l]=n[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function Qn(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Bn(){zn(Mn),zn(Un)}function Fn(e,n,t){if(Un.current!==Ln)throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");In(Un,n),In(Mn,t)}function jn(e,n,t){var r=e.stateNode;if(e=n.childContextTypes,"function"!=typeof r.getChildContext)return t;for(var l in r=r.getChildContext())if(!(l in e))throw Error((Je(n)||"Unknown")+'.getChildContext(): key "'+l+'" is not defined in childContextTypes.');return u({},t,r)}function On(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,An=Un.current,In(Un,e),In(Mn,Mn.current),!0}function Hn(e,n,t){var r=e.stateNode;if(!r)throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");t?(e=jn(e,n,An),r.__reactInternalMemoizedMergedChildContext=e,zn(Mn),zn(Un),In(Un,e)):zn(Mn),In(Mn,t)}var Vn=null,Wn=null;(0,c.unstable_now)();var Yn=8;function qn(e){if(0!=(1&e))return Yn=15,1;if(0!=(2&e))return Yn=14,2;if(0!=(4&e))return Yn=13,4;var n=24&e;return 0!==n?(Yn=12,n):0!=(32&e)?(Yn=11,32):0!==(n=192&e)?(Yn=10,n):0!=(256&e)?(Yn=9,256):0!==(n=3584&e)?(Yn=8,n):0!=(4096&e)?(Yn=7,4096):0!==(n=4186112&e)?(Yn=6,n):0!==(n=62914560&e)?(Yn=5,n):67108864&e?(Yn=4,67108864):0!=(134217728&e)?(Yn=3,134217728):0!==(n=805306368&e)?(Yn=2,n):0!=(1073741824&e)?(Yn=1,1073741824):(Yn=8,e)}function Xn(e){switch(e){case 99:return 15;case 98:return 10;case 97:case 96:return 8;case 95:return 2;default:return 0}}function $n(e){switch(e){case 15:case 14:return 99;case 13:case 12:case 11:case 10:return 98;case 9:case 8:case 7:case 6:case 4:case 5:return 97;case 3:case 2:case 1:return 95;case 0:return 90;default:throw Error("Invalid update priority: "+e+". This is a bug in React.")}}function Gn(e,n){var t=e.pendingLanes;if(0===t)return Yn=0;var r=0,l=0,a=e.expiredLanes,i=e.suspendedLanes,u=e.pingedLanes;if(0!==a)r=a,l=Yn=15;else if(0!==(a=134217727&t)){var o=a&~i;0!==o?(r=qn(o),l=Yn):0!==(u&=a)&&(r=qn(u),l=Yn)}else 0!==(a=t&~i)?(r=qn(a),l=Yn):0!==u&&(r=qn(u),l=Yn);if(0===r)return 0;if(r=t&((0>(r=31-tt(r))?0:1<<r)<<1)-1,0!==n&&n!==r&&0==(n&i)){if(qn(n),l<=Yn)return n;Yn=l}if(0!==(n=e.entangledLanes))for(e=e.entanglements,n&=r;0<n;)l=1<<(t=31-tt(n)),r|=e[t],n&=~l;return r}function Kn(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function Jn(e,n){switch(e){case 15:return 1;case 14:return 2;case 12:return 0===(e=Zn(24&~n))?Jn(10,n):e;case 10:return 0===(e=Zn(192&~n))?Jn(8,n):e;case 8:return 0===(e=Zn(3584&~n))&&(0===(e=Zn(4186112&~n))&&(e=512)),e;case 2:return 0===(n=Zn(805306368&~n))&&(n=268435456),n}throw Error("Invalid update priority: "+e+". This is a bug in React.")}function Zn(e){return e&-e}function et(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function nt(e,n,t){e.pendingLanes|=n;var r=n-1;e.suspendedLanes&=r,e.pingedLanes&=r,(e=e.eventTimes)[n=31-tt(n)]=t}var tt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-(rt(e)/lt|0)|0},rt=Math.log,lt=Math.LN2;var at=c.unstable_runWithPriority,it=c.unstable_scheduleCallback,ut=c.unstable_cancelCallback,ot=c.unstable_shouldYield,st=c.unstable_requestPaint,ct=c.unstable_now,ft=c.unstable_getCurrentPriorityLevel,dt=c.unstable_ImmediatePriority,pt=c.unstable_UserBlockingPriority,ht=c.unstable_NormalPriority,gt=c.unstable_LowPriority,mt=c.unstable_IdlePriority,vt={},yt=void 0!==st?st:function(){},bt=null,St=null,wt=!1,kt=ct(),Et=1e4>kt?ct:function(){return ct()-kt};function Tt(){switch(ft()){case dt:return 99;case pt:return 98;case ht:return 97;case gt:return 96;case mt:return 95;default:throw Error("Unknown priority level.")}}function xt(e){switch(e){case 99:return dt;case 98:return pt;case 97:return ht;case 96:return gt;case 95:return mt;default:throw Error("Unknown priority level.")}}function _t(e,n){return e=xt(e),at(e,n)}function Rt(e,n,t){return e=xt(e),it(e,n,t)}function Pt(){if(null!==St){var e=St;St=null,ut(e)}Ct()}function Ct(){if(!wt&&null!==bt){wt=!0;var e=0;try{var n=bt;_t(99,function(){for(;e<n.length;e++){var t=n[e];do{t=t(!0)}while(null!==t)}}),bt=null}catch(n){throw null!==bt&&(bt=bt.slice(e+1)),it(dt,Pt),n}finally{wt=!1}}}var Nt=Ie.ReactCurrentBatchConfig;var zt="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},It=Object.prototype.hasOwnProperty;function Lt(e,n){if(zt(e,n))return!0;if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(r=0;r<t.length;r++)if(!It.call(n,t[r])||!zt(e[t[r]],n[t[r]]))return!1;return!0}function Ut(e){switch(e.tag){case 5:return _n(e.type,null,null);case 16:return _n("Lazy",null,null);case 13:return _n("Suspense",null,null);case 19:return _n("SuspenseList",null,null);case 0:case 2:case 15:return Rn(e.type,null);case 11:return Rn(e.type.render,null);case 22:return Rn(e.type._render,null);case 1:return e=Rn(e.type,null);default:return""}}function Mt(e){try{var n="";do{n+=Ut(e),e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function At(e,n){if(e&&e.defaultProps){for(var t in n=u({},n),e=e.defaultProps)void 0===n[t]&&(n[t]=e[t]);return n}return n}var Dt=Nn(null),Qt=null,Bt=null,Ft=null;function jt(){Ft=Bt=Qt=null}function Ot(e){var n=Dt.current;zn(Dt),e.type._context._currentValue=n}function Ht(e,n){for(;null!==e;){var t=e.alternate;if((e.childLanes&n)===n){if(null===t||(t.childLanes&n)===n)break;t.childLanes|=n}else e.childLanes|=n,null!==t&&(t.childLanes|=n);e=e.return}}function Vt(e,n){Qt=e,Ft=Bt=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!=(e.lanes&n)&&(fl=!0),e.firstContext=null)}function Wt(e,n){if(Ft!==e&&!1!==n&&0!==n)if("number"==typeof n&&1073741823!==n||(Ft=e,n=1073741823),n={context:e,observedBits:n,next:null},null===Bt){if(null===Qt)throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");Bt=n,Qt.dependencies={lanes:0,firstContext:n,responders:null}}else Bt=Bt.next=n;return e._currentValue}var Yt=!1;function qt(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null},effects:null}}function Xt(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gt(e,n){if(null!==(e=e.updateQueue)){var t=(e=e.shared).pending;null===t?n.next=n:(n.next=t.next,t.next=n),e.pending=n}}function Kt(e,n){var t=e.updateQueue,r=e.alternate;if(null!==r&&t===(r=r.updateQueue)){var l=null,a=null;if(null!==(t=t.firstBaseUpdate)){do{var i={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};null===a?l=a=i:a=a.next=i,t=t.next}while(null!==t);null===a?l=a=n:a=a.next=n}else l=a=n;return t={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:a,shared:r.shared,effects:r.effects},void(e.updateQueue=t)}null===(e=t.lastBaseUpdate)?t.firstBaseUpdate=n:e.next=n,t.lastBaseUpdate=n}function Jt(e,n,t,r){var l=e.updateQueue;Yt=!1;var a=l.firstBaseUpdate,i=l.lastBaseUpdate,o=l.shared.pending;if(null!==o){l.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?a=c:i.next=c,i=s;var f=e.alternate;if(null!==f){var d=(f=f.updateQueue).lastBaseUpdate;d!==i&&(null===d?f.firstBaseUpdate=c:d.next=c,f.lastBaseUpdate=s)}}if(null!==a){for(d=l.baseState,i=0,f=c=s=null;;){o=a.lane;var p=a.eventTime;if((r&o)===o){null!==f&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var h=e,g=a;switch(o=n,p=t,g.tag){case 1:if("function"==typeof(h=g.payload)){d=h.call(p,d,o);break e}d=h;break e;case 3:h.flags=-8193&h.flags|64;case 0:if(null===(o="function"==typeof(h=g.payload)?h.call(p,d,o):h)||void 0===o)break e;d=u({},d,o);break e;case 2:Yt=!0}}null!==a.callback&&(e.flags|=32,null===(o=l.effects)?l.effects=[a]:o.push(a))}else p={eventTime:p,lane:o,tag:a.tag,payload:a.payload,callback:a.callback,next:null},null===f?(c=f=p,s=d):f=f.next=p,i|=o;if(null===(a=a.next)){if(null===(o=l.shared.pending))break;a=o.next,o.next=null,l.lastBaseUpdate=o,l.shared.pending=null}}null===f&&(s=d),l.baseState=s,l.firstBaseUpdate=c,l.lastBaseUpdate=f,va|=i,e.lanes=i,e.memoizedState=d}}function Zt(e,n,t){if(e=n.effects,n.effects=null,null!==e)for(n=0;n<e.length;n++){var r=e[n],l=r.callback;if(null!==l){if(r.callback=null,"function"!=typeof l)throw Error("Invalid argument passed as callback. Expected a function. Instead received: "+l);l.call(t)}}}var er=(new s.Component).refs;function nr(e,n,t,r){t=null===(t=t(r,n=e.memoizedState))||void 0===t?n:u({},n,t),e.memoizedState=t,0===e.lanes&&(e.updateQueue.baseState=t)}var tr={isMounted:function(e){return!!(e=e._reactInternals)&&Ze(e)===e},enqueueSetState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.tag=1,a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=Fa(),r=ja(e),l=$t(t,r);l.tag=2,void 0!==n&&null!==n&&(l.callback=n),Gt(e,l),Oa(e,r,t)}};function rr(e,n,t,r,l,a,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,a,i):!n.prototype||!n.prototype.isPureReactComponent||(!Lt(t,r)||!Lt(l,a))}function lr(e,n,t){var r=!1,l=Ln,a=n.contextType;return"object"==typeof a&&null!==a?a=Wt(a):(l=Qn(n)?An:Un.current,a=(r=null!==(r=n.contextTypes)&&void 0!==r)?Dn(e,l):Ln),n=new n(t,a),e.memoizedState=null!==n.state&&void 0!==n.state?n.state:null,n.updater=tr,e.stateNode=n,n._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=a),n}function ar(e,n,t,r){e=n.state,"function"==typeof n.componentWillReceiveProps&&n.componentWillReceiveProps(t,r),"function"==typeof n.UNSAFE_componentWillReceiveProps&&n.UNSAFE_componentWillReceiveProps(t,r),n.state!==e&&tr.enqueueReplaceState(n,n.state,null)}function ir(e,n,t,r){var l=e.stateNode;l.props=t,l.state=e.memoizedState,l.refs=er,qt(e);var a=n.contextType;"object"==typeof a&&null!==a?l.context=Wt(a):(a=Qn(n)?An:Un.current,l.context=Dn(e,a)),Jt(e,t,l,r),l.state=e.memoizedState,"function"==typeof(a=n.getDerivedStateFromProps)&&(nr(e,n,a,t),l.state=e.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof l.getSnapshotBeforeUpdate||"function"!=typeof l.UNSAFE_componentWillMount&&"function"!=typeof l.componentWillMount||(n=l.state,"function"==typeof l.componentWillMount&&l.componentWillMount(),"function"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),n!==l.state&&tr.enqueueReplaceState(l,l.state,null),Jt(e,t,l,r),l.state=e.memoizedState),"function"==typeof l.componentDidMount&&(e.flags|=4)}var ur=Array.isArray;function or(e,n,t){if(null!==(e=t.ref)&&"function"!=typeof e&&"object"!=typeof e){if(t._owner){if(t=t._owner){if(1!==t.tag)throw Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");var r=t.stateNode}if(!r)throw Error("Missing owner for string ref "+e+". This error is likely caused by a bug in React. Please file an issue.");var l=""+e;return null!==n&&null!==n.ref&&"function"==typeof n.ref&&n.ref._stringRef===l?n.ref:((n=function(e){var n=r.refs;n===er&&(n=r.refs={}),null===e?delete n[l]:n[l]=e})._stringRef=l,n)}if("string"!=typeof e)throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");if(!t._owner)throw Error("Element ref was specified as a string ("+e+") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information.")}return e}function sr(e,n){if("textarea"!==e.type)throw Error("Objects are not valid as a React child (found: "+("[object Object]"===Object.prototype.toString.call(n)?"object with keys {"+Object.keys(n).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.")}function cr(e){function n(n,t){if(e){var r=n.lastEffect;null!==r?(r.nextEffect=t,n.lastEffect=t):n.firstEffect=n.lastEffect=t,t.nextEffect=null,t.flags=8}}function t(t,r){if(!e)return null;for(;null!==r;)n(t,r),r=r.sibling;return null}function r(e,n){for(e=new Map;null!==n;)null!==n.key?e.set(n.key,n):e.set(n.index,n),n=n.sibling;return e}function l(e,n){return(e=bi(e,n)).index=0,e.sibling=null,e}function a(n,t,r){return n.index=r,e?null!==(r=n.alternate)?(r=r.index)<t?(n.flags=2,t):r:(n.flags=2,t):t}function i(n){return e&&null===n.alternate&&(n.flags=2),n}function u(e,n,t,r){return null===n||6!==n.tag?((n=Ei(t,e.mode,r)).return=e,n):((n=l(n,t)).return=e,n)}function o(e,n,t,r){return null!==n&&n.elementType===t.type?((r=l(n,t.props)).ref=or(e,n,t),r.return=e,r):((r=Si(t.type,t.key,t.props,null,e.mode,r)).ref=or(e,n,t),r.return=e,r)}function s(e,n,t,r){return null===n||4!==n.tag||n.stateNode.containerInfo!==t.containerInfo||n.stateNode.implementation!==t.implementation?((n=Ti(t,e.mode,r)).return=e,n):((n=l(n,t.children||[])).return=e,n)}function c(e,n,t,r,a){return null===n||7!==n.tag?((n=wi(t,e.mode,r,a)).return=e,n):((n=l(n,t)).return=e,n)}function f(e,n,t){if("string"==typeof n||"number"==typeof n)return(n=Ei(""+n,e.mode,t)).return=e,n;if("object"==typeof n&&null!==n){switch(n.$$typeof){case Le:return(t=Si(n.type,n.key,n.props,null,e.mode,t)).ref=or(e,null,n),t.return=e,t;case Ue:return(n=Ti(n,e.mode,t)).return=e,n}if(ur(n)||Ke(n))return(n=wi(n,e.mode,t,null)).return=e,n;sr(e,n)}return null}function d(e,n,t,r){var l=null!==n?n.key:null;if("string"==typeof t||"number"==typeof t)return null!==l?null:u(e,n,""+t,r);if("object"==typeof t&&null!==t){switch(t.$$typeof){case Le:return t.key===l?t.type===Me?c(e,n,t.props.children,r,l):o(e,n,t,r):null;case Ue:return t.key===l?s(e,n,t,r):null}if(ur(t)||Ke(t))return null!==l?null:c(e,n,t,r,null);sr(e,t)}return null}function p(e,n,t,r,l){if("string"==typeof r||"number"==typeof r)return u(n,e=e.get(t)||null,""+r,l);if("object"==typeof r&&null!==r){switch(r.$$typeof){case Le:return e=e.get(null===r.key?t:r.key)||null,r.type===Me?c(n,e,r.props.children,l,r.key):o(n,e,r,l);case Ue:return s(n,e=e.get(null===r.key?t:r.key)||null,r,l)}if(ur(r)||Ke(r))return c(n,e=e.get(t)||null,r,l,null);sr(n,r)}return null}function h(l,i,u,o){for(var s=null,c=null,h=i,g=i=0,m=null;null!==h&&g<u.length;g++){h.index>g?(m=h,h=null):m=h.sibling;var v=d(l,h,u[g],o);if(null===v){null===h&&(h=m);break}e&&h&&null===v.alternate&&n(l,h),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v,h=m}if(g===u.length)return t(l,h),s;if(null===h){for(;g<u.length;g++)null!==(h=f(l,u[g],o))&&(i=a(h,i,g),null===c?s=h:c.sibling=h,c=h);return s}for(h=r(l,h);g<u.length;g++)null!==(m=p(h,l,g,u[g],o))&&(e&&null!==m.alternate&&h.delete(null===m.key?g:m.key),i=a(m,i,g),null===c?s=m:c.sibling=m,c=m);return e&&h.forEach(function(e){return n(l,e)}),s}function g(l,i,u,o){var s=Ke(u);if("function"!=typeof s)throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");if(null==(u=s.call(u)))throw Error("An iterable object provided no iterator.");for(var c=s=null,h=i,g=i=0,m=null,v=u.next();null!==h&&!v.done;g++,v=u.next()){h.index>g?(m=h,h=null):m=h.sibling;var y=d(l,h,v.value,o);if(null===y){null===h&&(h=m);break}e&&h&&null===y.alternate&&n(l,h),i=a(y,i,g),null===c?s=y:c.sibling=y,c=y,h=m}if(v.done)return t(l,h),s;if(null===h){for(;!v.done;g++,v=u.next())null!==(v=f(l,v.value,o))&&(i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return s}for(h=r(l,h);!v.done;g++,v=u.next())null!==(v=p(h,l,g,v.value,o))&&(e&&null!==v.alternate&&h.delete(null===v.key?g:v.key),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return e&&h.forEach(function(e){return n(l,e)}),s}return function(e,r,a,u){var o="object"==typeof a&&null!==a&&a.type===Me&&null===a.key;o&&(a=a.props.children);var s="object"==typeof a&&null!==a;if(s)switch(a.$$typeof){case Le:e:{for(s=a.key,o=r;null!==o;){if(o.key===s){switch(o.tag){case 7:if(a.type===Me){t(e,o.sibling),(r=l(o,a.props.children)).return=e,e=r;break e}break;default:if(o.elementType===a.type){t(e,o.sibling),(r=l(o,a.props)).ref=or(e,o,a),r.return=e,e=r;break e}}t(e,o);break}n(e,o),o=o.sibling}a.type===Me?((r=wi(a.props.children,e.mode,u,a.key)).return=e,e=r):((u=Si(a.type,a.key,a.props,null,e.mode,u)).ref=or(e,r,a),u.return=e,e=u)}return i(e);case Ue:e:{for(o=a.key;null!==r;){if(r.key===o){if(4===r.tag&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){t(e,r.sibling),(r=l(r,a.children||[])).return=e,e=r;break e}t(e,r);break}n(e,r),r=r.sibling}(r=Ti(a,e.mode,u)).return=e,e=r}return i(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==r&&6===r.tag?(t(e,r.sibling),(r=l(r,a)).return=e,e=r):(t(e,r),(r=Ei(a,e.mode,u)).return=e,e=r),i(e);if(ur(a))return h(e,r,a,u);if(Ke(a))return g(e,r,a,u);if(s&&sr(e,a),void 0===a&&!o)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error((Je(e.type)||"Component")+"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.")}return t(e,r)}}var fr=cr(!0),dr=cr(!1),pr={},hr=Nn(pr),gr=Nn(pr),mr=Nn(pr);function vr(e){if(e===pr)throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");return e}function yr(e,n){In(mr,n),In(gr,e),In(hr,pr),zn(hr),In(hr,{isInAParentText:!1})}function br(){zn(hr),zn(gr),zn(mr)}function Sr(e){vr(mr.current);var n=vr(hr.current),t=e.type;t="AndroidTextInput"===t||"RCTMultilineTextInputView"===t||"RCTSinglelineTextInputView"===t||"RCTText"===t||"RCTVirtualText"===t,n!==(t=n.isInAParentText!==t?{isInAParentText:t}:n)&&(In(gr,e),In(hr,t))}function wr(e){gr.current===e&&(zn(hr),zn(gr))}var kr=Nn(0);function Er(e){for(var n=e;null!==n;){if(13===n.tag){var t=n.memoizedState;if(null!==t&&(null===t.dehydrated||vn()||vn()))return n}else if(19===n.tag&&void 0!==n.memoizedProps.revealOrder){if(0!=(64&n.flags))return n}else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===e)break;for(;null===n.sibling;){if(null===n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Tr=[];function xr(){for(var e=0;e<Tr.length;e++)Tr[e]._workInProgressVersionPrimary=null;Tr.length=0}var _r=Ie.ReactCurrentDispatcher,Rr=Ie.ReactCurrentBatchConfig,Pr=0,Cr=null,Nr=null,zr=null,Ir=!1,Lr=!1;function Ur(){throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.")}function Mr(e,n){if(null===n)return!1;for(var t=0;t<n.length&&t<e.length;t++)if(!zt(e[t],n[t]))return!1;return!0}function Ar(e,n,t,r,l,a){if(Pr=a,Cr=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,_r.current=null===e||null===e.memoizedState?ul:ol,e=t(r,l),Lr){a=0;do{if(Lr=!1,!(25>a))throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");a+=1,zr=Nr=null,n.updateQueue=null,_r.current=sl,e=t(r,l)}while(Lr)}if(_r.current=il,n=null!==Nr&&null!==Nr.next,Pr=0,zr=Nr=Cr=null,Ir=!1,n)throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");return e}function Dr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===zr?Cr.memoizedState=zr=e:zr=zr.next=e,zr}function Qr(){if(null===Nr){var e=Cr.alternate;e=null!==e?e.memoizedState:null}else e=Nr.next;var n=null===zr?Cr.memoizedState:zr.next;if(null!==n)zr=n,Nr=e;else{if(null===e)throw Error("Rendered more hooks than during the previous render.");e={memoizedState:(Nr=e).memoizedState,baseState:Nr.baseState,baseQueue:Nr.baseQueue,queue:Nr.queue,next:null},null===zr?Cr.memoizedState=zr=e:zr=zr.next=e}return zr}function Br(e,n){return"function"==typeof n?n(e):n}function Fr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=Nr,l=r.baseQueue,a=t.pending;if(null!==a){if(null!==l){var i=l.next;l.next=a.next,a.next=i}r.baseQueue=l=a,t.pending=null}if(null!==l){l=l.next,r=r.baseState;var u=i=a=null,o=l;do{var s=o.lane;if((Pr&s)===s)null!==u&&(u=u.next={lane:0,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null}),r=o.eagerReducer===e?o.eagerState:e(r,o.action);else{var c={lane:s,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null};null===u?(i=u=c,a=r):u=u.next=c,Cr.lanes|=s,va|=s}o=o.next}while(null!==o&&o!==l);null===u?a=r:u.next=i,zt(r,n.memoizedState)||(fl=!0),n.memoizedState=r,n.baseState=a,n.baseQueue=u,t.lastRenderedState=r}return[n.memoizedState,t.dispatch]}function jr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=t.dispatch,l=t.pending,a=n.memoizedState;if(null!==l){t.pending=null;var i=l=l.next;do{a=e(a,i.action),i=i.next}while(i!==l);zt(a,n.memoizedState)||(fl=!0),n.memoizedState=a,null===n.baseQueue&&(n.baseState=a),t.lastRenderedState=a}return[a,r]}function Or(e,n,t){var r=n._getVersion;r=r(n._source);var l=n._workInProgressVersionPrimary;if(null!==l?e=l===r:(e=e.mutableReadLanes,(e=(Pr&e)===e)&&(n._workInProgressVersionPrimary=r,Tr.push(n))),e)return t(n._source);throw Tr.push(n),Error("Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.")}function Hr(e,n,t,r){var l=sa;if(null===l)throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");var a=n._getVersion,i=a(n._source),u=_r.current,o=u.useState(function(){return Or(l,n,t)}),s=o[1],c=o[0];o=zr;var f=e.memoizedState,d=f.refs,p=d.getSnapshot,h=f.source;f=f.subscribe;var g=Cr;return e.memoizedState={refs:d,source:n,subscribe:r},u.useEffect(function(){d.getSnapshot=t,d.setSnapshot=s;var e=a(n._source);if(!zt(i,e)){e=t(n._source),zt(c,e)||(s(e),e=ja(g),l.mutableReadLanes|=e&l.pendingLanes),e=l.mutableReadLanes,l.entangledLanes|=e;for(var r=l.entanglements,u=e;0<u;){var o=31-tt(u),f=1<<o;r[o]|=e,u&=~f}}},[t,n,r]),u.useEffect(function(){return r(n._source,function(){var e=d.getSnapshot,t=d.setSnapshot;try{t(e(n._source));var r=ja(g);l.mutableReadLanes|=r&l.pendingLanes}catch(e){t(function(){throw e})}})},[n,r]),zt(p,t)&&zt(h,n)&&zt(f,r)||((e={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:c}).dispatch=s=al.bind(null,Cr,e),o.queue=e,o.baseQueue=null,c=Or(l,n,t),o.memoizedState=o.baseState=c),c}function Vr(e,n,t){return Hr(Qr(),e,n,t)}function Wr(e){var n=Dr();return"function"==typeof e&&(e=e()),n.memoizedState=n.baseState=e,e=(e=n.queue={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:e}).dispatch=al.bind(null,Cr,e),[n.memoizedState,e]}function Yr(e,n,t,r){return e={tag:e,create:n,destroy:t,deps:r,next:null},null===(n=Cr.updateQueue)?(n={lastEffect:null},Cr.updateQueue=n,n.lastEffect=e.next=e):null===(t=n.lastEffect)?n.lastEffect=e.next=e:(r=t.next,t.next=e,e.next=r,n.lastEffect=e),e}function qr(){return Qr().memoizedState}function Xr(e,n,t,r){var l=Dr();Cr.flags|=e,l.memoizedState=Yr(1|n,t,void 0,void 0===r?null:r)}function $r(e,n,t,r){var l=Qr();r=void 0===r?null:r;var a=void 0;if(null!==Nr){var i=Nr.memoizedState;if(a=i.destroy,null!==r&&Mr(r,i.deps))return void Yr(n,t,a,r)}Cr.flags|=e,l.memoizedState=Yr(1|n,t,a,r)}function Gr(e,n){return Xr(516,4,e,n)}function Kr(e,n){return $r(516,4,e,n)}function Jr(e,n){return $r(4,2,e,n)}function Zr(e,n){return"function"==typeof n?(e=e(),n(e),function(){n(null)}):null!==n&&void 0!==n?(e=e(),n.current=e,function(){n.current=null}):void 0}function el(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,$r(4,2,Zr.bind(null,n,e),t)}function nl(){}function tl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(t.memoizedState=[e,n],e)}function rl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(e=e(),t.memoizedState=[e,n],e)}function ll(e,n){var t=Tt();_t(98>t?98:t,function(){e(!0)}),_t(97<t?97:t,function(){var t=Rr.transition;Rr.transition=1;try{e(!1),n()}finally{Rr.transition=t}})}function al(e,n,t){var r=Fa(),l=ja(e),a={lane:l,action:t,eagerReducer:null,eagerState:null,next:null},i=n.pending;if(null===i?a.next=a:(a.next=i.next,i.next=a),n.pending=a,i=e.alternate,e===Cr||null!==i&&i===Cr)Lr=Ir=!0;else{if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=n.lastRenderedReducer))try{var u=n.lastRenderedState,o=i(u,t);if(a.eagerReducer=i,a.eagerState=o,zt(o,u))return}catch(e){}Oa(e,l,r)}}var il={readContext:Wt,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useMutableSource:Ur,useOpaqueIdentifier:Ur,unstable_isNewReconciler:!1},ul={readContext:Wt,useCallback:function(e,n){return Dr().memoizedState=[e,void 0===n?null:n],e},useContext:Wt,useEffect:Gr,useImperativeHandle:function(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,Xr(4,2,Zr.bind(null,n,e),t)},useLayoutEffect:function(e,n){return Xr(4,2,e,n)},useMemo:function(e,n){var t=Dr();return n=void 0===n?null:n,e=e(),t.memoizedState=[e,n],e},useReducer:function(e,n,t){var r=Dr();return n=void 0!==t?t(n):n,r.memoizedState=r.baseState=n,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:n}).dispatch=al.bind(null,Cr,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Dr().memoizedState=e},useState:Wr,useDebugValue:nl,useDeferredValue:function(e){var n=Wr(e),t=n[0],r=n[1];return Gr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Wr(!1),n=e[0];return e=ll.bind(null,e[1]),Dr().memoizedState=e,[e,n]},useMutableSource:function(e,n,t){var r=Dr();return r.memoizedState={refs:{getSnapshot:n,setSnapshot:null},source:e,subscribe:t},Hr(r,e,n,t)},useOpaqueIdentifier:function(){throw Error("Not yet implemented")},unstable_isNewReconciler:!1},ol={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:Fr,useRef:qr,useState:function(){return Fr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=Fr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Fr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return Fr(Br)[0]},unstable_isNewReconciler:!1},sl={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:jr,useRef:qr,useState:function(){return jr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=jr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=jr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return jr(Br)[0]},unstable_isNewReconciler:!1},cl=Ie.ReactCurrentOwner,fl=!1;function dl(e,n,t,r){n.child=null===e?dr(n,null,t,r):fr(n,e.child,t,r)}function pl(e,n,t,r,l){t=t.render;var a=n.ref;return Vt(n,l),r=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,r,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function hl(e,n,t,r,l,a){if(null===e){var i=t.type;return"function"!=typeof i||vi(i)||void 0!==i.defaultProps||null!==t.compare||void 0!==t.defaultProps?((e=Si(t.type,null,r,n,n.mode,a)).ref=n.ref,e.return=n,n.child=e):(n.tag=15,n.type=i,gl(e,n,i,r,l,a))}return i=e.child,0==(l&a)&&(l=i.memoizedProps,(t=null!==(t=t.compare)?t:Lt)(l,r)&&e.ref===n.ref)?Ul(e,n,a):(n.flags|=1,(e=bi(i,r)).ref=n.ref,e.return=n,n.child=e)}function gl(e,n,t,r,l,a){if(null!==e&&Lt(e.memoizedProps,r)&&e.ref===n.ref){if(fl=!1,0==(a&l))return n.lanes=e.lanes,Ul(e,n,a);0!=(32768&e.flags)&&(fl=!0)}return yl(e,n,t,r,a)}function ml(e,n,t){var r=n.pendingProps,l=r.children,a=null!==e?e.memoizedState:null;if("hidden"===r.mode||"unstable-defer-without-hiding"===r.mode)if(0==(4&n.mode))n.memoizedState={baseLanes:0},Xa(n,t);else{if(0==(1073741824&t))return e=null!==a?a.baseLanes|t:t,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e},Xa(n,e),null;n.memoizedState={baseLanes:0},Xa(n,null!==a?a.baseLanes:t)}else null!==a?(r=a.baseLanes|t,n.memoizedState=null):r=t,Xa(n,r);return dl(e,n,l,t),n.child}function vl(e,n){var t=n.ref;(null===e&&null!==t||null!==e&&e.ref!==t)&&(n.flags|=128)}function yl(e,n,t,r,l){var a=Qn(t)?An:Un.current;return a=Dn(n,a),Vt(n,l),t=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,t,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function bl(e,n,t,r,l){if(Qn(t)){var a=!0;On(n)}else a=!1;if(Vt(n,l),null===n.stateNode)null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),lr(n,t,r),ir(n,t,r,l),r=!0;else if(null===e){var i=n.stateNode,u=n.memoizedProps;i.props=u;var o=i.context,s=t.contextType;"object"==typeof s&&null!==s?s=Wt(s):s=Dn(n,s=Qn(t)?An:Un.current);var c=t.getDerivedStateFromProps,f="function"==typeof c||"function"==typeof i.getSnapshotBeforeUpdate;f||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==r||o!==s)&&ar(n,i,r,s),Yt=!1;var d=n.memoizedState;i.state=d,Jt(n,r,i,l),o=n.memoizedState,u!==r||d!==o||Mn.current||Yt?("function"==typeof c&&(nr(n,t,c,r),o=n.memoizedState),(u=Yt||rr(n,t,u,r,d,o,s))?(f||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(n.flags|=4)):("function"==typeof i.componentDidMount&&(n.flags|=4),n.memoizedProps=r,n.memoizedState=o),i.props=r,i.state=o,i.context=s,r=u):("function"==typeof i.componentDidMount&&(n.flags|=4),r=!1)}else{i=n.stateNode,Xt(e,n),u=n.memoizedProps,s=n.type===n.elementType?u:At(n.type,u),i.props=s,f=n.pendingProps,d=i.context,"object"==typeof(o=t.contextType)&&null!==o?o=Wt(o):o=Dn(n,o=Qn(t)?An:Un.current);var p=t.getDerivedStateFromProps;(c="function"==typeof p||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==f||d!==o)&&ar(n,i,r,o),Yt=!1,d=n.memoizedState,i.state=d,Jt(n,r,i,l);var h=n.memoizedState;u!==f||d!==h||Mn.current||Yt?("function"==typeof p&&(nr(n,t,p,r),h=n.memoizedState),(s=Yt||rr(n,t,s,r,d,h,o))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,o),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,o)),"function"==typeof i.componentDidUpdate&&(n.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(n.flags|=256)):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),n.memoizedProps=r,n.memoizedState=h),i.props=r,i.state=h,i.context=o,r=s):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),r=!1)}return Sl(e,n,t,r,a,l)}function Sl(e,n,t,r,l,a){vl(e,n);var i=0!=(64&n.flags);if(!r&&!i)return l&&Hn(n,t,!1),Ul(e,n,a);r=n.stateNode,cl.current=n;var u=i&&"function"!=typeof t.getDerivedStateFromError?null:r.render();return n.flags|=1,null!==e&&i?(n.child=fr(n,e.child,null,a),n.child=fr(n,null,u,a)):dl(e,n,u,a),n.memoizedState=r.state,l&&Hn(n,t,!0),n.child}function wl(e){var n=e.stateNode;n.pendingContext?Fn(0,n.pendingContext,n.pendingContext!==n.context):n.context&&Fn(0,n.context,!1),yr(e,n.containerInfo)}var kl,El,Tl,xl,_l={dehydrated:null,retryLane:0};function Rl(e,n,t){var r,l=n.pendingProps,a=kr.current,i=!1;return(r=0!=(64&n.flags))||(r=(null===e||null!==e.memoizedState)&&0!=(2&a)),r?(i=!0,n.flags&=-65):null!==e&&null===e.memoizedState||void 0===l.fallback||!0===l.unstable_avoidThisFallback||(a|=1),In(kr,1&a),null===e?(e=l.children,a=l.fallback,i?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,e):"number"==typeof l.unstable_expectedLoadTime?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,n.lanes=33554432,e):((t=ki({mode:"visible",children:e},n.mode,t,null)).return=n,n.child=t)):(e.memoizedState,i?(l=Nl(e,n,l.children,l.fallback,t),i=n.child,a=e.child.memoizedState,i.memoizedState=null===a?{baseLanes:t}:{baseLanes:a.baseLanes|t},i.childLanes=e.childLanes&~t,n.memoizedState=_l,l):(t=Cl(e,n,l.children,t),n.memoizedState=null,t))}function Pl(e,n,t,r){var l=e.mode,a=e.child;return n={mode:"hidden",children:n},0==(2&l)&&null!==a?(a.childLanes=0,a.pendingProps=n):a=ki(n,l,0,null),t=wi(t,l,r,null),a.return=e,t.return=e,a.sibling=t,e.child=a,t}function Cl(e,n,t,r){var l=e.child;return e=l.sibling,t=bi(l,{mode:"visible",children:t}),0==(2&n.mode)&&(t.lanes=r),t.return=n,t.sibling=null,null!==e&&(e.nextEffect=null,e.flags=8,n.firstEffect=n.lastEffect=e),n.child=t}function Nl(e,n,t,r,l){var a=n.mode,i=e.child;e=i.sibling;var u={mode:"hidden",children:t};return 0==(2&a)&&n.child!==i?((t=n.child).childLanes=0,t.pendingProps=u,null!==(i=t.lastEffect)?(n.firstEffect=t.firstEffect,n.lastEffect=i,i.nextEffect=null):n.firstEffect=n.lastEffect=null):t=bi(i,u),null!==e?r=bi(e,r):(r=wi(r,a,l,null)).flags|=2,r.return=n,t.return=n,t.sibling=r,n.child=t,r}function zl(e,n){e.lanes|=n;var t=e.alternate;null!==t&&(t.lanes|=n),Ht(e.return,n)}function Il(e,n,t,r,l,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:l,lastEffect:a}:(i.isBackwards=n,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=t,i.tailMode=l,i.lastEffect=a)}function Ll(e,n,t){var r=n.pendingProps,l=r.revealOrder,a=r.tail;if(dl(e,n,r.children,t),0!=(2&(r=kr.current)))r=1&r|2,n.flags|=64;else{if(null!==e&&0!=(64&e.flags))e:for(e=n.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zl(e,t);else if(19===e.tag)zl(e,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(In(kr,r),0==(2&n.mode))n.memoizedState=null;else switch(l){case"forwards":for(t=n.child,l=null;null!==t;)null!==(e=t.alternate)&&null===Er(e)&&(l=t),t=t.sibling;null===(t=l)?(l=n.child,n.child=null):(l=t.sibling,t.sibling=null),Il(n,!1,l,t,a,n.lastEffect);break;case"backwards":for(t=null,l=n.child,n.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Er(e)){n.child=l;break}e=l.sibling,l.sibling=t,t=l,l=e}Il(n,!0,t,null,a,n.lastEffect);break;case"together":Il(n,!1,null,null,void 0,n.lastEffect);break;default:n.memoizedState=null}return n.child}function Ul(e,n,t){if(null!==e&&(n.dependencies=e.dependencies),va|=n.lanes,0!=(t&n.childLanes)){if(null!==e&&n.child!==e.child)throw Error("Resuming work not yet implemented.");if(null!==n.child){for(t=bi(e=n.child,e.pendingProps),n.child=t,t.return=n;null!==e.sibling;)e=e.sibling,(t=t.sibling=bi(e,e.pendingProps)).return=n;t.sibling=null}return n.child}return null}function Ml(e,n){switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;null!==n;)null!==n.alternate&&(t=n),n=n.sibling;null===t?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?n||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Al(e,n,t){var r=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return Qn(n.type)&&Bn(),null;case 3:return br(),zn(Mn),zn(Un),xr(),(r=n.stateNode).pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||r.hydrate||(n.flags|=256),El(n),null;case 5:wr(n);var l=vr(mr.current);if(t=n.type,null!==e&&null!=n.stateNode)Tl(e,n,t,r,l),e.ref!==n.ref&&(n.flags|=128);else{if(!r){if(null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return null}vr(hr.current),e=wn(),t=yn(t);var a=hn(null,ln,r,t.validAttributes);o.UIManager.createView(e,t.uiViewClassName,l,a),l=new mn(e,t,n),ke.set(e,n),Ee.set(e,r),kl(l,n,!1,!1),n.stateNode=l,En(l)&&(n.flags|=4),null!==n.ref&&(n.flags|=128)}return null;case 6:if(e&&null!=n.stateNode)xl(e,n,e.memoizedProps,r);else{if("string"!=typeof r&&null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");if(e=vr(mr.current),!vr(hr.current).isInAParentText)throw Error("Text strings must be rendered within a <Text> component.");l=wn(),o.UIManager.createView(l,"RCTRawText",e,{text:r}),ke.set(l,n),n.stateNode=l}return null;case 13:return zn(kr),r=n.memoizedState,0!=(64&n.flags)?(n.lanes=t,n):(r=null!==r,l=!1,null!==e&&(l=null!==e.memoizedState),r&&!l&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&kr.current)?0===ha&&(ha=3):(0!==ha&&3!==ha||(ha=4),null===sa||0==(134217727&va)&&0==(134217727&ya)||Ya(sa,fa))),(r||l)&&(n.flags|=4),null);case 4:return br(),El(n),null;case 10:return Ot(n),null;case 17:return Qn(n.type)&&Bn(),null;case 19:if(zn(kr),null===(r=n.memoizedState))return null;if(l=0!=(64&n.flags),null===(a=r.rendering))if(l)Ml(r,!1);else{if(0!==ha||null!==e&&0!=(64&e.flags))for(e=n.child;null!==e;){if(null!==(a=Er(e))){for(n.flags|=64,Ml(r,!1),null!==(e=a.updateQueue)&&(n.updateQueue=e,n.flags|=4),null===r.lastEffect&&(n.firstEffect=null),n.lastEffect=r.lastEffect,e=t,r=n.child;null!==r;)t=e,(l=r).flags&=2,l.nextEffect=null,l.firstEffect=null,l.lastEffect=null,null===(a=l.alternate)?(l.childLanes=0,l.lanes=t,l.child=null,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=a.childLanes,l.lanes=a.lanes,l.child=a.child,l.memoizedProps=a.memoizedProps,l.memoizedState=a.memoizedState,l.updateQueue=a.updateQueue,l.type=a.type,t=a.dependencies,l.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return In(kr,1&kr.current|2),n.child}e=e.sibling}null!==r.tail&&Et()>ka&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432)}else{if(!l)if(null!==(e=Er(a))){if(n.flags|=64,l=!0,null!==(e=e.updateQueue)&&(n.updateQueue=e,n.flags|=4),Ml(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate)return null!==(n=n.lastEffect=r.lastEffect)&&(n.nextEffect=null),null}else 2*Et()-r.renderingStartTime>ka&&1073741824!==t&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432);r.isBackwards?(a.sibling=n.child,n.child=a):(null!==(e=r.last)?e.sibling=a:n.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.lastEffect=n.lastEffect,r.renderingStartTime=Et(),e.sibling=null,n=kr.current,In(kr,l?1&n|2:1&n),e):null;case 23:case 24:return $a(),null!==e&&null!==e.memoizedState!=(null!==n.memoizedState)&&"unstable-defer-without-hiding"!==r.mode&&(n.flags|=4),null}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function Dl(e){switch(e.tag){case 1:Qn(e.type)&&Bn();var n=e.flags;return 8192&n?(e.flags=-8193&n|64,e):null;case 3:if(br(),zn(Mn),zn(Un),xr(),0!=(64&(n=e.flags)))throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");return e.flags=-8193&n|64,e;case 5:return wr(e),null;case 13:return zn(kr),8192&(n=e.flags)?(e.flags=-8193&n|64,e):null;case 19:return zn(kr),null;case 4:return br(),null;case 10:return Ot(e),null;case 23:case 24:return $a(),null;default:return null}}function Ql(e,n){return{value:e,source:n,stack:Mt(n)}}if(kl=function(e,n){for(var t=n.child;null!==t;){if(5===t.tag||6===t.tag)e._children.push(t.stateNode);else if(4!==t.tag&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===n)break;for(;null===t.sibling;){if(null===t.return||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}},El=function(){},Tl=function(e,n,t,r){e.memoizedProps!==r&&(vr(hr.current),n.updateQueue=bn)&&(n.flags|=4)},xl=function(e,n,t,r){t!==r&&(n.flags|=4)},"function"!=typeof o.ReactFiberErrorDialog.showErrorDialog)throw Error("Expected ReactFiberErrorDialog.showErrorDialog to be a function.");function Bl(e,n){try{!1!==o.ReactFiberErrorDialog.showErrorDialog({componentStack:null!==n.stack?n.stack:"",error:n.value,errorBoundary:null!==e&&1===e.tag?e.stateNode:null})&&console.error(n.value)}catch(e){setTimeout(function(){throw e})}}var Fl="function"==typeof WeakMap?WeakMap:Map;function jl(e,n,t){(t=$t(-1,t)).tag=3,t.payload={element:null};var r=n.value;return t.callback=function(){Ta||(Ta=!0,xa=r),Bl(e,n)},t}function Ol(e,n,t){(t=$t(-1,t)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var l=n.value;t.payload=function(){return Bl(e,n),r(l)}}var a=e.stateNode;return null!==a&&"function"==typeof a.componentDidCatch&&(t.callback=function(){"function"!=typeof r&&(null===_a?_a=new Set([this]):_a.add(this),Bl(e,n));var t=n.stack;this.componentDidCatch(n.value,{componentStack:null!==t?t:""})}),t}var Hl="function"==typeof WeakSet?WeakSet:Set;function Vl(e){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){di(e,n)}else n.current=null}function Wl(e,n){switch(n.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&n.flags&&null!==e){var t=e.memoizedProps,r=e.memoizedState;n=(e=n.stateNode).getSnapshotBeforeUpdate(n.elementType===n.type?t:At(n.type,t),r),e.__reactInternalSnapshotBeforeUpdate=n}return;case 3:return;case 5:case 6:case 4:case 17:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function Yl(e,n,t){switch(t.tag){case 0:case 11:case 15:case 22:if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{if(3==(3&e.tag)){var r=e.create;e.destroy=r()}e=e.next}while(e!==n)}if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{var l=e;r=l.next,0!=(4&(l=l.tag))&&0!=(1&l)&&(si(t,e),oi(t,e)),e=r}while(e!==n)}return;case 1:return e=t.stateNode,4&t.flags&&(null===n?e.componentDidMount():(r=t.elementType===t.type?n.memoizedProps:At(t.type,n.memoizedProps),e.componentDidUpdate(r,n.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),void(null!==(n=t.updateQueue)&&Zt(t,n,e));case 3:if(null!==(n=t.updateQueue)){if(e=null,null!==t.child)switch(t.child.tag){case 5:e=t.child.stateNode;break;case 1:e=t.child.stateNode}Zt(t,n,e)}return;case 5:case 6:case 4:case 12:case 13:return;case 19:case 17:case 20:case 21:case 23:case 24:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ql(e,n){for(var t=e;;){if(5===t.tag){var r=t.stateNode;if(n){var l=r.viewConfig,a=hn(null,ln,{style:{display:"none"}},l.validAttributes);o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}else{r=t.stateNode,a=t.memoizedProps,l=r.viewConfig,a=hn(null,u({},a,{style:[a.style,{display:"none"}]}),a,l.validAttributes),o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}}else{if(6===t.tag)throw Error("Not yet implemented.");if((23!==t.tag&&24!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}function Xl(e,n){if(Wn&&"function"==typeof Wn.onCommitFiberUnmount)try{Wn.onCommitFiberUnmount(Vn,n)}catch(e){}switch(n.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=n.updateQueue)&&null!==(e=e.lastEffect)){var t=e=e.next;do{var r=t,l=r.destroy;if(r=r.tag,void 0!==l)if(0!=(4&r))si(n,t);else{r=n;try{l()}catch(e){di(r,e)}}t=t.next}while(t!==e)}break;case 1:if(Vl(n),"function"==typeof(e=n.stateNode).componentWillUnmount)try{e.props=n.memoizedProps,e.state=n.memoizedState,e.componentWillUnmount()}catch(e){di(n,e)}break;case 5:Vl(n);break;case 4:ea(e,n)}}function $l(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}function Gl(e){return 5===e.tag||3===e.tag||4===e.tag}function Kl(e){e:{for(var n=e.return;null!==n;){if(Gl(n))break e;n=n.return}throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.")}var t=n;switch(n=t.stateNode,t.tag){case 5:var r=!1;break;case 3:case 4:n=n.containerInfo,r=!0;break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}16&t.flags&&(t.flags&=-17);e:n:for(t=e;;){for(;null===t.sibling;){if(null===t.return||Gl(t.return)){t=null;break e}t=t.return}for(t.sibling.return=t.return,t=t.sibling;5!==t.tag&&6!==t.tag&&18!==t.tag;){if(2&t.flags)continue n;if(null===t.child||4===t.tag)continue n;t.child.return=t,t=t.child}if(!(2&t.flags)){t=t.stateNode;break e}}r?Jl(e,t,n):Zl(e,t,n)}function Jl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)if(e=l?e.stateNode:e.stateNode.instance,n){if("number"==typeof t)throw Error("Container does not support insertBefore operation")}else o.UIManager.setChildren(t,["number"==typeof e?e:e._nativeTag]);else if(4!==r&&null!==(e=e.child))for(Jl(e,n,t),e=e.sibling;null!==e;)Jl(e,n,t),e=e.sibling}function Zl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,n?0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[l],[n],[],[],[])):(n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[],[],["number"==typeof e?e:e._nativeTag],[n],[])):(n="number"==typeof e?e:e._nativeTag,0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),r.push(e),o.UIManager.manageChildren(t._nativeTag,[l],[r.length-1],[],[],[])):(r.push(e),o.UIManager.manageChildren(t._nativeTag,[],[],[n],[r.length-1],[])));else if(4!==r&&null!==(e=e.child))for(Zl(e,n,t),e=e.sibling;null!==e;)Zl(e,n,t),e=e.sibling}function ea(e,n){for(var t,r,l=n,a=!1;;){if(!a){a=l.return;e:for(;;){if(null===a)throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");switch(t=a.stateNode,a.tag){case 5:r=!1;break e;case 3:case 4:t=t.containerInfo,r=!0;break e}a=a.return}a=!0}if(5===l.tag||6===l.tag){e:for(var i=e,u=l,s=u;;)if(Xl(i,s),null!==s.child&&4!==s.tag)s.child.return=s,s=s.child;else{if(s===u)break e;for(;null===s.sibling;){if(null===s.return||s.return===u)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}r?(i=t,kn(l.stateNode),o.UIManager.manageChildren(i,[],[],[],[],[0])):(i=t,kn(s=l.stateNode),s=(u=i._children).indexOf(s),u.splice(s,1),o.UIManager.manageChildren(i._nativeTag,[],[],[],[],[s]))}else if(4===l.tag){if(null!==l.child){t=l.stateNode.containerInfo,r=!0,l.child.return=l,l=l.child;continue}}else if(Xl(e,l),null!==l.child){l.child.return=l,l=l.child;continue}if(l===n)break;for(;null===l.sibling;){if(null===l.return||l.return===n)return;4===(l=l.return).tag&&(a=!1)}l.sibling.return=l.return,l=l.sibling}}function na(e,n){switch(n.tag){case 0:case 11:case 14:case 15:case 22:var t=n.updateQueue;if(null!==(t=null!==t?t.lastEffect:null)){var r=t=t.next;do{3==(3&r.tag)&&(n=r.destroy,r.destroy=void 0,void 0!==n&&n()),r=r.next}while(r!==t)}return;case 1:return;case 5:if(null!=(t=n.stateNode)){r=n.memoizedProps,e=null!==e?e.memoizedProps:r;var l=n.updateQueue;n.updateQueue=null,null!==l&&(n=t.viewConfig,Ee.set(t._nativeTag,r),null!=(r=hn(null,e,r,n.validAttributes))&&o.UIManager.updateView(t._nativeTag,n.uiViewClassName,r))}return;case 6:if(null===n.stateNode)throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");return void o.UIManager.updateView(n.stateNode,"RCTRawText",{text:n.memoizedProps});case 3:case 12:return;case 13:return null!==n.memoizedState&&(wa=Et(),ql(n.child,!0)),void ta(n);case 19:return void ta(n);case 17:return;case 23:case 24:return void ql(n,null!==n.memoizedState)}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ta(e){var n=e.updateQueue;if(null!==n){e.updateQueue=null;var t=e.stateNode;null===t&&(t=e.stateNode=new Hl),n.forEach(function(n){var r=hi.bind(null,e,n);t.has(n)||(t.add(n),n.then(r,r))})}}function ra(e,n){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(n=n.memoizedState)&&null===n.dehydrated)}var la,aa=Math.ceil,ia=Ie.ReactCurrentDispatcher,ua=Ie.ReactCurrentOwner,oa=0,sa=null,ca=null,fa=0,da=0,pa=Nn(0),ha=0,ga=null,ma=0,va=0,ya=0,ba=0,Sa=null,wa=0,ka=1/0,Ea=null,Ta=!1,xa=null,_a=null,Ra=!1,Pa=null,Ca=90,Na=[],za=[],Ia=null,La=0,Ua=null,Ma=-1,Aa=0,Da=0,Qa=null,Ba=!1;function Fa(){return 0!=(48&oa)?Et():-1!==Ma?Ma:Ma=Et()}function ja(e){if(0==(2&(e=e.mode)))return 1;if(0==(4&e))return 99===Tt()?1:2;if(0===Aa&&(Aa=ma),0!==Nt.transition){0!==Da&&(Da=null!==Sa?Sa.pendingLanes:0),e=Aa;var n=4186112&~Da;return 0===(n&=-n)&&(0===(n=(e=4186112&~e)&-e)&&(n=8192)),n}return e=Tt(),0!=(4&oa)&&98===e?e=Jn(12,Aa):e=Jn(e=Xn(e),Aa),e}function Oa(e,n,t){if(50<La)throw La=0,Ua=null,Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");if(null===(e=Ha(e,n)))return null;nt(e,n,t),e===sa&&(ya|=n,4===ha&&Ya(e,fa));var r=Tt();1===n?0!=(8&oa)&&0==(48&oa)?qa(e):(Va(e,t),0===oa&&(ka=Et()+500,Pt())):(0==(4&oa)||98!==r&&99!==r||(null===Ia?Ia=new Set([e]):Ia.add(e)),Va(e,t)),Sa=e}function Ha(e,n){e.lanes|=n;var t=e.alternate;for(null!==t&&(t.lanes|=n),t=e,e=e.return;null!==e;)e.childLanes|=n,null!==(t=e.alternate)&&(t.childLanes|=n),t=e,e=e.return;return 3===t.tag?t.stateNode:null}function Va(e,n){for(var t=e.callbackNode,r=e.suspendedLanes,l=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var u=31-tt(i),o=1<<u,s=a[u];if(-1===s){if(0==(o&r)||0!=(o&l)){s=n,qn(o);var c=Yn;a[u]=10<=c?s+250:6<=c?s+5e3:-1}}else s<=n&&(e.expiredLanes|=o);i&=~o}if(r=Gn(e,e===sa?fa:0),n=Yn,0===r)null!==t&&(t!==vt&&ut(t),e.callbackNode=null,e.callbackPriority=0);else{if(null!==t){if(e.callbackPriority===n)return;t!==vt&&ut(t)}15===n?(t=qa.bind(null,e),null===bt?(bt=[t],St=it(dt,Ct)):bt.push(t),t=vt):14===n?t=Rt(99,qa.bind(null,e)):t=Rt(t=$n(n),Wa.bind(null,e)),e.callbackPriority=n,e.callbackNode=t}}function Wa(e){if(Ma=-1,Da=Aa=0,0!=(48&oa))throw Error("Should not already be working.");var n=e.callbackNode;if(ui()&&e.callbackNode!==n)return null;var t=Gn(e,e===sa?fa:0);if(0===t)return null;var r=t,l=oa;oa|=16;var a=Ja();for(sa===e&&fa===r||(ka=Et()+500,Ga(e,r));;)try{ni();break}catch(n){Ka(e,n)}if(jt(),ia.current=a,oa=l,null!==ca?r=0:(sa=null,fa=0,r=ha),0!=(ma&ya))Ga(e,0);else if(0!==r){if(2===r&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(t=Kn(e))&&(r=Za(e,t))),1===r)throw n=ga,Ga(e,0),Ya(e,t),Va(e,Et()),n;switch(e.finishedWork=e.current.alternate,e.finishedLanes=t,r){case 0:case 1:throw Error("Root did not complete. This is a bug in React.");case 2:li(e);break;case 3:if(Ya(e,t),(62914560&t)===t&&10<(r=wa+500-Et())){if(0!==Gn(e,0))break;if(((l=e.suspendedLanes)&t)!==t){Fa(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=Tn(li.bind(null,e),r);break}li(e);break;case 4:if(Ya(e,t),(4186112&t)===t)break;for(r=e.eventTimes,l=-1;0<t;){var i=31-tt(t);a=1<<i,(i=r[i])>l&&(l=i),t&=~a}if(t=l,10<(t=(120>(t=Et()-t)?120:480>t?480:1080>t?1080:1920>t?1920:3e3>t?3e3:4320>t?4320:1960*aa(t/1960))-t)){e.timeoutHandle=Tn(li.bind(null,e),t);break}li(e);break;case 5:li(e);break;default:throw Error("Unknown root exit status.")}}return Va(e,Et()),e.callbackNode===n?Wa.bind(null,e):null}function Ya(e,n){for(n&=~ba,n&=~ya,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var t=31-tt(n),r=1<<t;e[t]=-1,n&=~r}}function qa(e){if(0!=(48&oa))throw Error("Should not already be working.");if(ui(),e===sa&&0!=(e.expiredLanes&fa)){var n=fa,t=Za(e,n);0!=(ma&ya)&&(t=Za(e,n=Gn(e,n)))}else t=Za(e,n=Gn(e,0));if(0!==e.tag&&2===t&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(n=Kn(e))&&(t=Za(e,n))),1===t)throw t=ga,Ga(e,0),Ya(e,n),Va(e,Et()),t;return e.finishedWork=e.current.alternate,e.finishedLanes=n,li(e),Va(e,Et()),null}function Xa(e,n){In(pa,da),da|=n,ma|=n}function $a(){da=pa.current,zn(pa)}function Ga(e,n){e.finishedWork=null,e.finishedLanes=0;var t=e.timeoutHandle;if(-1!==t&&(e.timeoutHandle=-1,xn(t)),null!==ca)for(t=ca.return;null!==t;){var r=t;switch(r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&Bn();break;case 3:br(),zn(Mn),zn(Un),xr();break;case 5:wr(r);break;case 4:br();break;case 13:case 19:zn(kr);break;case 10:Ot(r);break;case 23:case 24:$a()}t=t.return}sa=e,ca=bi(e.current,null),fa=da=ma=n,ha=0,ga=null,ba=ya=va=0}function Ka(e,n){for(;;){var t=ca;try{if(jt(),_r.current=il,Ir){for(var r=Cr.memoizedState;null!==r;){var l=r.queue;null!==l&&(l.pending=null),r=r.next}Ir=!1}if(Pr=0,zr=Nr=Cr=null,Lr=!1,ua.current=null,null===t||null===t.return){ha=1,ga=n,ca=null;break}e:{var a=e,i=t.return,u=t,o=n;if(n=fa,u.flags|=4096,u.firstEffect=u.lastEffect=null,null!==o&&"object"==typeof o&&"function"==typeof o.then){var s=o;if(0==(2&u.mode)){var c=u.alternate;c?(u.updateQueue=c.updateQueue,u.memoizedState=c.memoizedState,u.lanes=c.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=0!=(1&kr.current),d=i;do{var p;if(p=13===d.tag){var h=d.memoizedState;if(null!==h)p=null!==h.dehydrated;else{var g=d.memoizedProps;p=void 0!==g.fallback&&(!0!==g.unstable_avoidThisFallback||!f)}}if(p){var m=d.updateQueue;if(null===m){var v=new Set;v.add(s),d.updateQueue=v}else m.add(s);if(0==(2&d.mode)){if(d.flags|=64,u.flags|=32768,u.flags&=-5029,1===u.tag)if(null===u.alternate)u.tag=17;else{var y=$t(-1,1);y.tag=2,Gt(u,y)}u.lanes|=1;break e}o=void 0,u=n;var b=a.pingCache;if(null===b?(b=a.pingCache=new Fl,o=new Set,b.set(s,o)):void 0===(o=b.get(s))&&(o=new Set,b.set(s,o)),!o.has(u)){o.add(u);var S=pi.bind(null,a,s,u);s.then(S,S)}d.flags|=8192,d.lanes=n;break e}d=d.return}while(null!==d);o=Error((Je(u.type)||"A React component")+" suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.")}5!==ha&&(ha=2),o=Ql(o,u),d=i;do{switch(d.tag){case 3:a=o,d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,jl(d,a,n));break e;case 1:a=o;var w=d.type,k=d.stateNode;if(0==(64&d.flags)&&("function"==typeof w.getDerivedStateFromError||null!==k&&"function"==typeof k.componentDidCatch&&(null===_a||!_a.has(k)))){d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,Ol(d,a,n));break e}}d=d.return}while(null!==d)}ri(t)}catch(e){n=e,ca===t&&null!==t&&(ca=t=t.return);continue}break}}function Ja(){var e=ia.current;return ia.current=il,null===e?il:e}function Za(e,n){var t=oa;oa|=16;var r=Ja();for(sa===e&&fa===n||Ga(e,n);;)try{ei();break}catch(n){Ka(e,n)}if(jt(),oa=t,ia.current=r,null!==ca)throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");return sa=null,fa=0,ha}function ei(){for(;null!==ca;)ti(ca)}function ni(){for(;null!==ca&&!ot();)ti(ca)}function ti(e){var n=la(e.alternate,e,da);e.memoizedProps=e.pendingProps,null===n?ri(e):ca=n,ua.current=null}function ri(e){var n=e;do{var t=n.alternate;if(e=n.return,0==(4096&n.flags)){if(null!==(t=Al(t,n,da)))return void(ca=t);if(24!==(t=n).tag&&23!==t.tag||null===t.memoizedState||0!=(1073741824&da)||0==(4&t.mode)){for(var r=0,l=t.child;null!==l;)r|=l.lanes|l.childLanes,l=l.sibling;t.childLanes=r}null!==e&&0==(4096&e.flags)&&(null===e.firstEffect&&(e.firstEffect=n.firstEffect),null!==n.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=n.firstEffect),e.lastEffect=n.lastEffect),1<n.flags&&(null!==e.lastEffect?e.lastEffect.nextEffect=n:e.firstEffect=n,e.lastEffect=n))}else{if(null!==(t=Dl(n)))return t.flags&=4095,void(ca=t);null!==e&&(e.firstEffect=e.lastEffect=null,e.flags|=4096)}if(null!==(n=n.sibling))return void(ca=n);ca=n=e}while(null!==n);0===ha&&(ha=5)}function li(e){var n=Tt();return _t(99,ai.bind(null,e,n)),null}function ai(e,n){do{ui()}while(null!==Pa);if(0!=(48&oa))throw Error("Should not already be working.");var t=e.finishedWork;if(null===t)return null;if(e.finishedWork=null,e.finishedLanes=0,t===e.current)throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");e.callbackNode=null;var r=t.lanes|t.childLanes,l=r,a=e.pendingLanes&~l;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=l,e.mutableReadLanes&=l,e.entangledLanes&=l,l=e.entanglements;for(var i=e.eventTimes,u=e.expirationTimes;0<a;){var o=31-tt(a),s=1<<o;l[o]=0,i[o]=-1,u[o]=-1,a&=~s}if(null!==Ia&&0==(24&r)&&Ia.has(e)&&Ia.delete(e),e===sa&&(ca=sa=null,fa=0),1<t.flags?null!==t.lastEffect?(t.lastEffect.nextEffect=t,r=t.firstEffect):r=t:r=t.firstEffect,null!==r){l=oa,oa|=32,Qa=ua.current=null,Ba=!1,Ea=r;do{try{ii()}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Qa=null,Ea=r;do{try{for(i=e;null!==Ea;){var c=Ea.flags;if(128&c){var f=Ea.alternate;if(null!==f){var d=f.ref;null!==d&&("function"==typeof d?d(null):d.current=null)}}switch(1038&c){case 2:Kl(Ea),Ea.flags&=-3;break;case 6:Kl(Ea),Ea.flags&=-3,na(Ea.alternate,Ea);break;case 1024:Ea.flags&=-1025;break;case 1028:Ea.flags&=-1025,na(Ea.alternate,Ea);break;case 4:na(Ea.alternate,Ea);break;case 8:ea(i,u=Ea);var p=u.alternate;$l(u),null!==p&&$l(p)}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);e.current=t,Ea=r;do{try{for(c=e;null!==Ea;){var h=Ea.flags;if(36&h&&Yl(c,Ea.alternate,Ea),128&h){f=void 0;var g=Ea.ref;if(null!==g){var m=Ea.stateNode;switch(Ea.tag){case 5:f=m;break;default:f=m}"function"==typeof g?g(f):g.current=f}}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Ea=null,yt(),oa=l}else e.current=t;if(Ra)Ra=!1,Pa=e,Ca=n;else for(Ea=r;null!==Ea;)n=Ea.nextEffect,Ea.nextEffect=null,8&Ea.flags&&((h=Ea).sibling=null,h.stateNode=null),Ea=n;if(0===(r=e.pendingLanes)&&(_a=null),1===r?e===Ua?La++:(La=0,Ua=e):La=0,t=t.stateNode,Wn&&"function"==typeof Wn.onCommitFiberRoot)try{Wn.onCommitFiberRoot(Vn,t,void 0,64==(64&t.current.flags))}catch(e){}if(Va(e,Et()),Ta)throw Ta=!1,e=xa,xa=null,e;return 0!=(8&oa)?null:(Pt(),null)}function ii(){for(;null!==Ea;){var e=Ea.alternate;Ba||null===Qa||(0!=(8&Ea.flags)?rn(Ea,Qa)&&(Ba=!0):13===Ea.tag&&ra(e,Ea)&&rn(Ea,Qa)&&(Ba=!0));var n=Ea.flags;0!=(256&n)&&Wl(e,Ea),0==(512&n)||Ra||(Ra=!0,Rt(97,function(){return ui(),null})),Ea=Ea.nextEffect}}function ui(){if(90!==Ca){var e=97<Ca?97:Ca;return Ca=90,_t(e,ci)}return!1}function oi(e,n){Na.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function si(e,n){za.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function ci(){if(null===Pa)return!1;var e=Pa;if(Pa=null,0!=(48&oa))throw Error("Cannot flush passive effects while already rendering.");var n=oa;oa|=32;var t=za;za=[];for(var r=0;r<t.length;r+=2){var l=t[r],a=t[r+1],i=l.destroy;if(l.destroy=void 0,"function"==typeof i)try{i()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(t=Na,Na=[],r=0;r<t.length;r+=2){l=t[r],a=t[r+1];try{var u=l.create;l.destroy=u()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(u=e.current.firstEffect;null!==u;)e=u.nextEffect,u.nextEffect=null,8&u.flags&&(u.sibling=null,u.stateNode=null),u=e;return oa=n,Pt(),!0}function fi(e,n,t){Gt(e,n=jl(e,n=Ql(t,n),1)),n=Fa(),null!==(e=Ha(e,1))&&(nt(e,1,n),Va(e,n))}function di(e,n){if(3===e.tag)fi(e,e,n);else for(var t=e.return;null!==t;){if(3===t.tag){fi(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r))){var l=Ol(t,e=Ql(n,e),1);if(Gt(t,l),l=Fa(),null!==(t=Ha(t,1)))nt(t,1,l),Va(t,l);else if("function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r)))try{r.componentDidCatch(n,e)}catch(e){}break}}t=t.return}}function pi(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),n=Fa(),e.pingedLanes|=e.suspendedLanes&t,sa===e&&(fa&t)===t&&(4===ha||3===ha&&(62914560&fa)===fa&&500>Et()-wa?Ga(e,0):ba|=t),Va(e,n)}function hi(e,n){var t=e.stateNode;null!==t&&t.delete(n),0===(n=0)&&(0==(2&(n=e.mode))?n=1:0==(4&n)?n=99===Tt()?1:2:(0===Aa&&(Aa=ma),0===(n=Zn(62914560&~Aa))&&(n=4194304))),t=Fa(),null!==(e=Ha(e,n))&&(nt(e,n,t),Va(e,t))}function gi(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.flags=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childLanes=this.lanes=0,this.alternate=null}function mi(e,n,t,r){return new gi(e,n,t,r)}function vi(e){return!(!(e=e.prototype)||!e.isReactComponent)}function yi(e){if("function"==typeof e)return vi(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===Fe)return 11;if(e===He)return 14}return 2}function bi(e,n){var t=e.alternate;return null===t?((t=mi(e.tag,n,e.key,e.mode)).elementType=e.elementType,t.type=e.type,t.stateNode=e.stateNode,t.alternate=e,e.alternate=t):(t.pendingProps=n,t.type=e.type,t.flags=0,t.nextEffect=null,t.firstEffect=null,t.lastEffect=null),t.childLanes=e.childLanes,t.lanes=e.lanes,t.child=e.child,t.memoizedProps=e.memoizedProps,t.memoizedState=e.memoizedState,t.updateQueue=e.updateQueue,n=e.dependencies,t.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},t.sibling=e.sibling,t.index=e.index,t.ref=e.ref,t}function Si(e,n,t,r,l,a){var i=2;if(r=e,"function"==typeof e)vi(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case Me:return wi(t.children,l,a,n);case Ye:i=8,l|=16;break;case Ae:i=8,l|=1;break;case De:return(e=mi(12,t,n,8|l)).elementType=De,e.type=De,e.lanes=a,e;case je:return(e=mi(13,t,n,l)).type=je,e.elementType=je,e.lanes=a,e;case Oe:return(e=mi(19,t,n,l)).elementType=Oe,e.lanes=a,e;case qe:return ki(t,l,a,n);case Xe:return(e=mi(24,t,n,l)).elementType=Xe,e.lanes=a,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case Qe:i=10;break e;case Be:i=9;break e;case Fe:i=11;break e;case He:i=14;break e;case Ve:i=16,r=null;break e;case We:i=22;break e}throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+(null==e?e:typeof e)+".")}return(n=mi(i,t,n,l)).elementType=e,n.type=r,n.lanes=a,n}function wi(e,n,t,r){return(e=mi(7,e,r,n)).lanes=t,e}function ki(e,n,t,r){return(e=mi(23,e,r,n)).elementType=qe,e.lanes=t,e}function Ei(e,n,t){return(e=mi(6,e,null,n)).lanes=t,e}function Ti(e,n,t){return(n=mi(4,null!==e.children?e.children:[],e.key,n)).lanes=t,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function xi(e,n,t){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=t,this.callbackNode=null,this.callbackPriority=0,this.eventTimes=et(0),this.expirationTimes=et(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0)}function _i(e,n,t){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:Ue,key:null==r?null:""+r,children:e,containerInfo:n,implementation:t}}function Ri(e){var n=e._reactInternals;if(void 0===n){if("function"==typeof e.render)throw Error("Unable to find node on an unmounted component.");throw Error("Argument appears to not be a ReactComponent. Keys: "+Object.keys(e))}return null===(e=tn(n))?null:e.stateNode}function Pi(e,n,t,r){var l=n.current,a=Fa(),i=ja(l);e:if(t){t=t._reactInternals;n:{if(Ze(t)!==t||1!==t.tag)throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");var u=t;do{switch(u.tag){case 3:u=u.stateNode.context;break n;case 1:if(Qn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break n}}u=u.return}while(null!==u);throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.")}if(1===t.tag){var o=t.type;if(Qn(o)){t=jn(t,o,u);break e}}t=u}else t=Ln;return null===n.context?n.context=t:n.pendingContext=t,(n=$t(a,i)).payload={element:e},null!==(r=void 0===r?null:r)&&(n.callback=r),Gt(l,n),Oa(l,i,a),i}function Ci(e){return null==e?null:"number"==typeof e?e:e._nativeTag?e._nativeTag:e.canonical&&e.canonical._nativeTag?e.canonical._nativeTag:null==(e=Ri(e))?e:e.canonical?e.canonical._nativeTag:e._nativeTag}function Ni(e){var n=zi.get(e);n&&Pi(null,n,null,function(){zi.delete(e)})}la=function(e,n,t){var r=n.lanes;if(null!==e)if(e.memoizedProps!==n.pendingProps||Mn.current)fl=!0;else{if(0==(t&r)){switch(fl=!1,n.tag){case 3:wl(n);break;case 5:Sr(n);break;case 1:Qn(n.type)&&On(n);break;case 4:yr(n,n.stateNode.containerInfo);break;case 10:r=n.memoizedProps.value;var l=n.type._context;In(Dt,l._currentValue),l._currentValue=r;break;case 13:if(null!==n.memoizedState)return 0!=(t&n.child.childLanes)?Rl(e,n,t):(In(kr,1&kr.current),null!==(n=Ul(e,n,t))?n.sibling:null);In(kr,1&kr.current);break;case 19:if(r=0!=(t&n.childLanes),0!=(64&e.flags)){if(r)return Ll(e,n,t);n.flags|=64}if(null!==(l=n.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),In(kr,kr.current),r)break;return null;case 23:case 24:return n.lanes=0,ml(e,n,t)}return Ul(e,n,t)}fl=0!=(32768&e.flags)}else fl=!1;switch(n.lanes=0,n.tag){case 2:if(r=n.type,null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=Dn(n,Un.current),Vt(n,t),l=Ar(null,n,r,e,l,t),n.flags|=1,"object"==typeof l&&null!==l&&"function"==typeof l.render&&void 0===l.$$typeof){if(n.tag=1,n.memoizedState=null,n.updateQueue=null,Qn(r)){var a=!0;On(n)}else a=!1;n.memoizedState=null!==l.state&&void 0!==l.state?l.state:null,qt(n);var i=r.getDerivedStateFromProps;"function"==typeof i&&nr(n,r,i,e),l.updater=tr,n.stateNode=l,l._reactInternals=n,ir(n,r,e,t),n=Sl(null,n,r,!0,a,t)}else n.tag=0,dl(null,n,l,t),n=n.child;return n;case 16:l=n.elementType;e:{switch(null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=(a=l._init)(l._payload),n.type=l,a=n.tag=yi(l),e=At(l,e),a){case 0:n=yl(null,n,l,e,t);break e;case 1:n=bl(null,n,l,e,t);break e;case 11:n=pl(null,n,l,e,t);break e;case 14:n=hl(null,n,l,At(l.type,e),r,t);break e}throw Error("Element type is invalid. Received a promise that resolves to: "+l+". Lazy element type must resolve to a class or function.")}return n;case 0:return r=n.type,l=n.pendingProps,yl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 1:return r=n.type,l=n.pendingProps,bl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 3:if(wl(n),r=n.updateQueue,null===e||null===r)throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");return r=n.pendingProps,l=null!==(l=n.memoizedState)?l.element:null,Xt(e,n),Jt(n,r,null,t),(r=n.memoizedState.element)===l?n=Ul(e,n,t):(dl(e,n,r,t),n=n.child),n;case 5:return Sr(n),r=n.pendingProps.children,vl(e,n),dl(e,n,r,t),n.child;case 6:return null;case 13:return Rl(e,n,t);case 4:return yr(n,n.stateNode.containerInfo),r=n.pendingProps,null===e?n.child=fr(n,null,r,t):dl(e,n,r,t),n.child;case 11:return r=n.type,l=n.pendingProps,pl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 7:return dl(e,n,n.pendingProps,t),n.child;case 8:case 12:return dl(e,n,n.pendingProps.children,t),n.child;case 10:e:{r=n.type._context,l=n.pendingProps,i=n.memoizedProps,a=l.value;var u=n.type._context;if(In(Dt,u._currentValue),u._currentValue=a,null!==i)if(u=i.value,0===(a=zt(u,a)?0:0|("function"==typeof r._calculateChangedBits?r._calculateChangedBits(u,a):1073741823))){if(i.children===l.children&&!Mn.current){n=Ul(e,n,t);break e}}else for(null!==(u=n.child)&&(u.return=n);null!==u;){var o=u.dependencies;if(null!==o){i=u.child;for(var s=o.firstContext;null!==s;){if(s.context===r&&0!=(s.observedBits&a)){1===u.tag&&((s=$t(-1,t&-t)).tag=2,Gt(u,s)),u.lanes|=t,null!==(s=u.alternate)&&(s.lanes|=t),Ht(u.return,t),o.lanes|=t;break}s=s.next}}else i=10===u.tag&&u.type===n.type?null:u.child;if(null!==i)i.return=u;else for(i=u;null!==i;){if(i===n){i=null;break}if(null!==(u=i.sibling)){u.return=i.return,i=u;break}i=i.return}u=i}dl(e,n,l.children,t),n=n.child}return n;case 9:return l=n.type,r=(a=n.pendingProps).children,Vt(n,t),r=r(l=Wt(l,a.unstable_observedBits)),n.flags|=1,dl(e,n,r,t),n.child;case 14:return a=At(l=n.type,n.pendingProps),hl(e,n,l,a=At(l.type,a),r,t);case 15:return gl(e,n,n.type,n.pendingProps,r,t);case 17:return r=n.type,l=n.pendingProps,l=n.elementType===r?l:At(r,l),null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),n.tag=1,Qn(r)?(e=!0,On(n)):e=!1,Vt(n,t),lr(n,r,l),ir(n,r,l,t),Sl(null,n,r,!0,e,t);case 19:return Ll(e,n,t);case 23:case 24:return ml(e,n,t)}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")},xe=function(e,n){var t=oa;oa|=1;try{return e(n)}finally{0===(oa=t)&&(ka=Et()+500,Pt())}};var zi=new Map,Ii={findFiberByHostInstance:Te,bundleType:0,version:"17.0.1-4e5d7faf5",rendererPackageName:"react-native-renderer",rendererConfig:{getInspectorDataForViewTag:function(){throw Error("getInspectorDataForViewTag() is not available in production")},getInspectorDataForViewAtPoint:function(){throw Error("getInspectorDataForViewAtPoint() is not available in production.")}.bind(null,Ci)}},Li={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ie.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=tn(e))?null:e.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Ui=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ui.isDisabled&&Ui.supportsFiber)try{Vn=Ui.inject(Li),Wn=Ui}catch(e){}}a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED={computeComponentStackForErrorReporting:function(e){return(e=Te(e))?Mt(e):""}},a.createPortal=function(e,n){return _i(e,n,null,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},a.dispatchCommand=function(e,n,t){null!=e._nativeTag&&(e._internalInstanceHandle?nativeFabricUIManager.dispatchCommand(e._internalInstanceHandle.stateNode.node,n,t):o.UIManager.dispatchViewManagerCommand(e._nativeTag,n,t))},a.findHostInstance_DEPRECATED=function(e){return null==e?null:e._nativeTag?e:e.canonical&&e.canonical._nativeTag?e.canonical:null==(e=Ri(e))?e:e.canonical?e.canonical:e},a.findNodeHandle=Ci,a.render=function(e,n,t){var r=zi.get(n);if(!r){r=new xi(n,0,!1);var l=mi(3,null,null,0);r.current=l,l.stateNode=r,qt(l),zi.set(n,r)}Pi(e,r,null,t);e:if(e=r.current,e.child)switch(e.child.tag){case 5:e=e.child.stateNode;break e;default:e=e.child.stateNode}else e=null;return e},a.unmountComponentAtNode=Ni,a.unmountComponentAtNodeAndRemoveContainer=function(e){Ni(e),o.UIManager.removeRootView(e)},a.unstable_batchedUpdates=Re},88,[6,89,160,14,184]);^~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:94:21265: warning: the variable "clearTimeout" was not declared in anonymous function " 246#"__d(function(e,n,t,r,l,a,i){"use strict";var u=n(i[0]);n(i[1]);var o=n(i[2]),s=n(i[3]),c=n(i[4]);function f(e,n,t,r,l,a,i,u,o){var s=Array.prototype.slice.call(arguments,3);try{n.apply(t,s)}catch(e){this.onError(e)}}var d=!1,p=null,h=!1,g=null,m={onError:function(e){d=!0,p=e}};function v(e,n,t,r,l,a,i,u,o){d=!1,p=null,f.apply(m,arguments)}function y(e,n,t,r,l,a,i,u,o){if(v.apply(this,arguments),d){if(!d)throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");var s=p;d=!1,p=null,h||(h=!0,g=s)}}var b=null,S=null,w=null;function k(e,n,t){var r=e.type||"unknown-event";e.currentTarget=w(t),y(r,n,void 0,e),e.currentTarget=null}function E(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))throw Error("executeDirectDispatch(...): Invalid `event`.");return e.currentTarget=n?w(t):null,n=n?n(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,n}function T(){return!0}function x(){return!1}function _(e,n,t,r){for(var l in this.dispatchConfig=e,this._targetInst=n,this.nativeEvent=t,this._dispatchInstances=this._dispatchListeners=null,e=this.constructor.Interface)e.hasOwnProperty(l)&&((n=e[l])?this[l]=n(t):"target"===l?this.target=r:this[l]=t[l]);return this.isDefaultPrevented=(null!=t.defaultPrevented?t.defaultPrevented:!1===t.returnValue)?T:x,this.isPropagationStopped=x,this}function R(e,n,t,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,n,t,r),l}return new this(e,n,t,r)}function P(e){if(!(e instanceof this))throw Error("Trying to release an event instance into a pool of a different type.");e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function C(e){e.getPooled=R,e.eventPool=[],e.release=P}u(_.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=T)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=T)},persist:function(){this.isPersistent=T},isPersistent:x,destructor:function(){var e,n=this.constructor.Interface;for(e in n)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=x,this._dispatchInstances=this._dispatchListeners=null}}),_.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},_.extend=function(e){function n(){}function t(){return r.apply(this,arguments)}var r=this;n.prototype=r.prototype;var l=new n;return u(l,t.prototype),t.prototype=l,t.prototype.constructor=t,t.Interface=u({},r.Interface,e),t.extend=r.extend,C(t),t},C(_);var N=_.extend({touchHistory:function(){return null}});function z(e){return"topTouchStart"===e}function I(e){return"topTouchMove"===e}var L=["topTouchStart"],U=["topTouchMove"],M=["topTouchCancel","topTouchEnd"],A=[],D={touchBank:A,numberActiveTouches:0,indexOfSingleActiveTouch:-1,mostRecentTimeStamp:0};function Q(e){return e.timeStamp||e.timestamp}function B(e){if(null==(e=e.identifier))throw Error("Touch object is missing identifier.");return e}function F(e){var n=B(e),t=A[n];t?(t.touchActive=!0,t.startPageX=e.pageX,t.startPageY=e.pageY,t.startTimeStamp=Q(e),t.currentPageX=e.pageX,t.currentPageY=e.pageY,t.currentTimeStamp=Q(e),t.previousPageX=e.pageX,t.previousPageY=e.pageY,t.previousTimeStamp=Q(e)):(t={touchActive:!0,startPageX:e.pageX,startPageY:e.pageY,startTimeStamp:Q(e),currentPageX:e.pageX,currentPageY:e.pageY,currentTimeStamp:Q(e),previousPageX:e.pageX,previousPageY:e.pageY,previousTimeStamp:Q(e)},A[n]=t),D.mostRecentTimeStamp=Q(e)}function j(e){var n=A[B(e)];n&&(n.touchActive=!0,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}function O(e){var n=A[B(e)];n&&(n.touchActive=!1,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}var H={recordTouchTrack:function(e,n){if(I(e))n.changedTouches.forEach(j);else if(z(e))n.changedTouches.forEach(F),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches&&(D.indexOfSingleActiveTouch=n.touches[0].identifier);else if(("topTouchEnd"===e||"topTouchCancel"===e)&&(n.changedTouches.forEach(O),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches))for(e=0;e<A.length;e++)if(null!=(n=A[e])&&n.touchActive){D.indexOfSingleActiveTouch=e;break}},touchHistory:D};function V(e,n){if(null==n)throw Error("accumulate(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?e.concat(n):Array.isArray(n)?[e].concat(n):[e,n]}function W(e,n){if(null==n)throw Error("accumulateInto(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?Array.isArray(n)?(e.push.apply(e,n),e):(e.push(n),e):Array.isArray(n)?[e].concat(n):[e,n]}function Y(e,n,t){Array.isArray(e)?e.forEach(n,t):e&&n.call(t,e)}var q=null,X=0;function $(e,n){var t=q;q=e,null!==le.GlobalResponderHandler&&le.GlobalResponderHandler.onChange(t,e,n)}var G={startShouldSetResponder:{phasedRegistrationNames:{bubbled:"onStartShouldSetResponder",captured:"onStartShouldSetResponderCapture"},dependencies:L},scrollShouldSetResponder:{phasedRegistrationNames:{bubbled:"onScrollShouldSetResponder",captured:"onScrollShouldSetResponderCapture"},dependencies:["topScroll"]},selectionChangeShouldSetResponder:{phasedRegistrationNames:{bubbled:"onSelectionChangeShouldSetResponder",captured:"onSelectionChangeShouldSetResponderCapture"},dependencies:["topSelectionChange"]},moveShouldSetResponder:{phasedRegistrationNames:{bubbled:"onMoveShouldSetResponder",captured:"onMoveShouldSetResponderCapture"},dependencies:U},responderStart:{registrationName:"onResponderStart",dependencies:L},responderMove:{registrationName:"onResponderMove",dependencies:U},responderEnd:{registrationName:"onResponderEnd",dependencies:M},responderRelease:{registrationName:"onResponderRelease",dependencies:M},responderTerminationRequest:{registrationName:"onResponderTerminationRequest",dependencies:[]},responderGrant:{registrationName:"onResponderGrant",dependencies:[]},responderReject:{registrationName:"onResponderReject",dependencies:[]},responderTerminate:{registrationName:"onResponderTerminate",dependencies:[]}};function K(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function J(e,n,t){for(var r=[];e;)r.push(e),e=K(e);for(e=r.length;0<e--;)n(r[e],"captured",t);for(e=0;e<r.length;e++)n(r[e],"bubbled",t)}function Z(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}function ee(e,n,t){(n=Z(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function ne(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=Z(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}function te(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var n=e._targetInst;J(n=n?K(n):null,ee,e)}}function re(e){e&&e.dispatchConfig.phasedRegistrationNames&&J(e._targetInst,ee,e)}var le={_getResponder:function(){return q},eventTypes:G,extractEvents:function(e,n,t,r){if(z(e))X+=1;else if("topTouchEnd"===e||"topTouchCancel"===e){if(!(0<=X))return null;--X}if(H.recordTouchTrack(e,t),n&&("topScroll"===e&&!t.responderIgnoreScroll||0<X&&"topSelectionChange"===e||z(e)||I(e))){var l=z(e)?G.startShouldSetResponder:I(e)?G.moveShouldSetResponder:"topSelectionChange"===e?G.selectionChangeShouldSetResponder:G.scrollShouldSetResponder;if(q)e:{for(var a=q,i=0,u=a;u;u=K(u))i++;u=0;for(var o=n;o;o=K(o))u++;for(;0<i-u;)a=K(a),i--;for(;0<u-i;)n=K(n),u--;for(;i--;){if(a===n||a===n.alternate)break e;a=K(a),n=K(n)}a=null}else a=n;a=(n=a)===q,(l=N.getPooled(l,n,t,r)).touchHistory=H.touchHistory,Y(l,a?te:re);e:{if(a=l._dispatchListeners,n=l._dispatchInstances,Array.isArray(a)){for(i=0;i<a.length&&!l.isPropagationStopped();i++)if(a[i](l,n[i])){a=n[i];break e}}else if(a&&a(l,n)){a=n;break e}a=null}if(l._dispatchInstances=null,l._dispatchListeners=null,l.isPersistent()||l.constructor.release(l),a&&a!==q)if((l=N.getPooled(G.responderGrant,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),n=!0===E(l),q)if((i=N.getPooled(G.responderTerminationRequest,q,t,r)).touchHistory=H.touchHistory,Y(i,ne),u=!i._dispatchListeners||E(i),i.isPersistent()||i.constructor.release(i),u){(i=N.getPooled(G.responderTerminate,q,t,r)).touchHistory=H.touchHistory,Y(i,ne);var s=V(s,[l,i]);$(a,n)}else(l=N.getPooled(G.responderReject,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l);else s=V(s,l),$(a,n);else s=null}else s=null;if(l=q&&z(e),a=q&&I(e),n=q&&("topTouchEnd"===e||"topTouchCancel"===e),(l=l?G.responderStart:a?G.responderMove:n?G.responderEnd:null)&&((l=N.getPooled(l,q,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l)),l=q&&"topTouchCancel"===e,e=q&&!l&&("topTouchEnd"===e||"topTouchCancel"===e))e:{if((e=t.touches)&&0!==e.length)for(a=0;a<e.length;a++)if(null!==(n=e[a].target)&&void 0!==n&&0!==n){i=S(n);n:{for(n=q;i;){if(n===i||n===i.alternate){n=!0;break n}i=K(i)}n=!1}if(n){e=!1;break e}}e=!0}return(e=l?G.responderTerminate:e?G.responderRelease:null)&&((t=N.getPooled(e,q,t,r)).touchHistory=H.touchHistory,Y(t,ne),s=V(s,t),$(null)),s},GlobalResponderHandler:null,injection:{injectGlobalResponderHandler:function(e){le.GlobalResponderHandler=e}}},ae=null,ie={};function ue(){if(ae)for(var e in ie){var n=ie[e],t=ae.indexOf(e);if(!(-1<t))throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `"+e+"`.");if(!se[t]){if(!n.extractEvents)throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `"+e+"` does not.");for(var r in se[t]=n,t=n.eventTypes){var l=void 0,a=t[r],i=r;if(ce.hasOwnProperty(i))throw Error("EventPluginRegistry: More than one plugin attempted to publish the same event name, `"+i+"`.");ce[i]=a;var u=a.phasedRegistrationNames;if(u){for(l in u)u.hasOwnProperty(l)&&oe(u[l],n);l=!0}else a.registrationName?(oe(a.registrationName,n),l=!0):l=!1;if(!l)throw Error("EventPluginRegistry: Failed to publish event `"+r+"` for plugin `"+e+"`.")}}}}function oe(e,n){if(fe[e])throw Error("EventPluginRegistry: More than one plugin attempted to publish the same registration name, `"+e+"`.");fe[e]=n}var se=[],ce={},fe={};function de(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}var pe=o.ReactNativeViewConfigRegistry.customBubblingEventTypes,he=o.ReactNativeViewConfigRegistry.customDirectEventTypes;function ge(e,n,t){(n=de(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function me(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var n=e._targetInst,t=[];n;){t.push(n);do{n=n.return}while(n&&5!==n.tag);n=n||null}for(n=t.length;0<n--;)ge(t[n],"captured",e);for(n=0;n<t.length;n++)ge(t[n],"bubbled",e)}}function ve(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=de(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}if(ae)throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.");ae=Array.prototype.slice.call(["ResponderEventPlugin","ReactNativeBridgeEventPlugin"]),ue();var ye,be={ResponderEventPlugin:le,ReactNativeBridgeEventPlugin:{eventTypes:{},extractEvents:function(e,n,t,r){if(null==n)return null;var l=pe[e],a=he[e];if(!l&&!a)throw Error('Unsupported top level event type "'+e+'" dispatched');if(e=_.getPooled(l||a,n,t,r),l)Y(e,me);else{if(!a)return null;Y(e,ve)}return e}}},Se=!1;for(ye in be)if(be.hasOwnProperty(ye)){var we=be[ye];if(!ie.hasOwnProperty(ye)||ie[ye]!==we){if(ie[ye])throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `"+ye+"`.");ie[ye]=we,Se=!0}}Se&&ue();var ke=new Map,Ee=new Map;function Te(e){return ke.get(e)||null}function xe(e,n){return e(n)}var _e=!1;function Re(e,n){if(_e)return e(n);_e=!0;try{return xe(e,n)}finally{_e=!1}}var Pe=null;function Ce(e){if(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))for(var r=0;r<n.length&&!e.isPropagationStopped();r++)k(e,n[r],t[r]);else n&&k(e,n,t);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}var Ne={};function ze(e,n,t){var r=t||Ne,l=Te(e),a=null;null!=l&&(a=l.stateNode),Re(function(){for(var e=a,t=null,i=se,u=0;u<i.length;u++){var o=i[u];o&&(o=o.extractEvents(n,l,r,e))&&(t=W(t,o))}if(null!==(e=t)&&(Pe=W(Pe,e)),e=Pe,Pe=null,e){if(Y(e,Ce),Pe)throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.");if(h)throw e=g,h=!1,g=null,e}})}o.RCTEventEmitter.register({receiveEvent:function(e,n,t){ze(e,n,t)},receiveTouches:function(e,n,t){if("topTouchEnd"===e||"topTouchCancel"===e){for(var r=[],l=0;l<t.length;l++){var a=t[l];r.push(n[a]),n[a]=null}for(l=t=0;l<n.length;l++)null!==(a=n[l])&&(n[t++]=a);n.length=t}else for(r=[],l=0;l<t.length;l++)r.push(n[t[l]]);for(t=0;t<r.length;t++){(l=r[t]).changedTouches=r,l.touches=n,a=null;var i=l.target;null===i||void 0===i||1>i||(a=i),ze(a,e,l)}}}),b=function(e){return Ee.get(e._nativeTag)||null},S=Te,w=function(e){var n=(e=e.stateNode)._nativeTag;if(void 0===n&&(n=(e=e.canonical)._nativeTag),!n)throw Error("All native instances should have a tag.");return e},le.injection.injectGlobalResponderHandler({onChange:function(e,n,t){null!==n?o.UIManager.setJSResponder(n.stateNode._nativeTag,t):o.UIManager.clearJSResponder()}});var Ie=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Le=60103,Ue=60106,Me=60107,Ae=60108,De=60114,Qe=60109,Be=60110,Fe=60112,je=60113,Oe=60120,He=60115,Ve=60116,We=60121,Ye=60129,qe=60130,Xe=60131;if("function"==typeof Symbol&&Symbol.for){var $e=Symbol.for;Le=$e("react.element"),Ue=$e("react.portal"),Me=$e("react.fragment"),Ae=$e("react.strict_mode"),De=$e("react.profiler"),Qe=$e("react.provider"),Be=$e("react.context"),Fe=$e("react.forward_ref"),je=$e("react.suspense"),Oe=$e("react.suspense_list"),He=$e("react.memo"),Ve=$e("react.lazy"),We=$e("react.block"),$e("react.scope"),Ye=$e("react.debug_trace_mode"),qe=$e("react.offscreen"),Xe=$e("react.legacy_hidden")}var Ge="function"==typeof Symbol&&Symbol.iterator;function Ke(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=Ge&&e[Ge]||e["@@iterator"])?e:null}function Je(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case Me:return"Fragment";case Ue:return"Portal";case De:return"Profiler";case Ae:return"StrictMode";case je:return"Suspense";case Oe:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case Be:return(e.displayName||"Context")+".Consumer";case Qe:return(e._context.displayName||"Context")+".Provider";case Fe:var n=e.render;return n=n.displayName||n.name||"",e.displayName||(""!==n?"ForwardRef("+n+")":"ForwardRef");case He:return Je(e.type);case We:return Je(e._render);case Ve:n=e._payload,e=e._init;try{return Je(e(n))}catch(e){}}return null}function Ze(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do{0!=(1026&(n=e).flags)&&(t=n.return),e=n.return}while(e)}return 3===n.tag?t:null}function en(e){if(Ze(e)!==e)throw Error("Unable to find node on an unmounted component.")}function nn(e){var n=e.alternate;if(!n){if(null===(n=Ze(e)))throw Error("Unable to find node on an unmounted component.");return n!==e?null:e}for(var t=e,r=n;;){var l=t.return;if(null===l)break;var a=l.alternate;if(null===a){if(null!==(r=l.return)){t=r;continue}break}if(l.child===a.child){for(a=l.child;a;){if(a===t)return en(l),e;if(a===r)return en(l),n;a=a.sibling}throw Error("Unable to find node on an unmounted component.")}if(t.return!==r.return)t=l,r=a;else{for(var i=!1,u=l.child;u;){if(u===t){i=!0,t=l,r=a;break}if(u===r){i=!0,r=l,t=a;break}u=u.sibling}if(!i){for(u=a.child;u;){if(u===t){i=!0,t=a,r=l;break}if(u===r){i=!0,r=a,t=l;break}u=u.sibling}if(!i)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(t.alternate!==r)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(3!==t.tag)throw Error("Unable to find node on an unmounted component.");return t.stateNode.current===t?e:n}function tn(e){if(!(e=nn(e)))return null;for(var n=e;;){if(5===n.tag||6===n.tag)return n;if(n.child)n.child.return=n,n=n.child;else{if(n===e)break;for(;!n.sibling;){if(!n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}}return null}function rn(e,n){for(var t=e.alternate;null!==n;){if(n===e||n===t)return!0;n=n.return}return!1}var ln={},an=null,un=0,on={unsafelyIgnoreFunctions:!0};function sn(e,n){return"object"!=typeof n||null===n||o.deepDiffer(e,n,on)}function cn(e,n,t){if(Array.isArray(n))for(var r=n.length;r--&&0<un;)cn(e,n[r],t);else if(n&&0<un)for(r in an)if(an[r]){var l=n[r];if(void 0!==l){var a=t[r];a&&("function"==typeof l&&(l=!0),void 0===l&&(l=null),"object"!=typeof a?e[r]=l:"function"!=typeof a.diff&&"function"!=typeof a.process||(l="function"==typeof a.process?a.process(l):l,e[r]=l),an[r]=!1,un--)}}}function fn(e,n,t,r){if(!e&&n===t)return e;if(!n||!t)return t?dn(e,t,r):n?pn(e,n,r):e;if(!Array.isArray(n)&&!Array.isArray(t))return hn(e,n,t,r);if(Array.isArray(n)&&Array.isArray(t)){var l,a=n.length<t.length?n.length:t.length;for(l=0;l<a;l++)e=fn(e,n[l],t[l],r);for(;l<n.length;l++)e=pn(e,n[l],r);for(;l<t.length;l++)e=dn(e,t[l],r);return e}return Array.isArray(n)?hn(e,o.flattenStyle(n),t,r):hn(e,n,o.flattenStyle(t),r)}function dn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,ln,n,t);for(var r=0;r<n.length;r++)e=dn(e,n[r],t);return e}function pn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,n,ln,t);for(var r=0;r<n.length;r++)e=pn(e,n[r],t);return e}function hn(e,n,t,r){var l,a;for(a in t)if(l=r[a]){var i=n[a],u=t[a];"function"==typeof u&&(u=!0,"function"==typeof i&&(i=!0)),void 0===u&&(u=null,void 0===i&&(i=null)),an&&(an[a]=!1),e&&void 0!==e[a]?"object"!=typeof l?e[a]=u:"function"!=typeof l.diff&&"function"!=typeof l.process||(l="function"==typeof l.process?l.process(u):u,e[a]=l):i!==u&&("object"!=typeof l?sn(i,u)&&((e||(e={}))[a]=u):"function"==typeof l.diff||"function"==typeof l.process?(void 0===i||("function"==typeof l.diff?l.diff(i,u):sn(i,u)))&&(l="function"==typeof l.process?l.process(u):u,(e||(e={}))[a]=l):(an=null,un=0,e=fn(e,i,u,l),0<un&&e&&(cn(e,u,l),an=null)))}for(var o in n)void 0===t[o]&&(!(l=r[o])||e&&void 0!==e[o]||void 0!==(i=n[o])&&("object"!=typeof l||"function"==typeof l.diff||"function"==typeof l.process?((e||(e={}))[o]=null,an||(an={}),an[o]||(an[o]=!0,un++)):e=pn(e,i,l)));return e}function gn(e,n){return function(){if(n&&("boolean"!=typeof e.__isMounted||e.__isMounted))return n.apply(e,arguments)}}var mn=(function(){function e(e,n){this._nativeTag=e,this._children=[],this.viewConfig=n}var n=e.prototype;return n.blur=function(){o.TextInputState.blurTextInput(this)},n.focus=function(){o.TextInputState.focusTextInput(this)},n.measure=function(e){o.UIManager.measure(this._nativeTag,gn(this,e))},n.measureInWindow=function(e){o.UIManager.measureInWindow(this._nativeTag,gn(this,e))},n.measureLayout=function(e,n,t){if("number"==typeof e)var r=e;else e._nativeTag&&(r=e._nativeTag);null!=r&&o.UIManager.measureLayout(this._nativeTag,r,gn(this,t),gn(this,n))},n.setNativeProps=function(e){null!=(e=hn(null,ln,e,this.viewConfig.validAttributes))&&o.UIManager.updateView(this._nativeTag,this.viewConfig.uiViewClassName,e)},e})();function vn(){throw Error("The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.")}var yn=o.ReactNativeViewConfigRegistry.get,bn={},Sn=3;function wn(){var e=Sn;return 1==e%10&&(e+=2),Sn=e+2,e}function kn(e){if("number"==typeof e)ke.delete(e),Ee.delete(e);else{var n=e._nativeTag;ke.delete(n),Ee.delete(n),e._children.forEach(kn)}}function En(e){if(0===e._children.length)return!1;var n=e._children.map(function(e){return"number"==typeof e?e:e._nativeTag});return o.UIManager.setChildren(e._nativeTag,n),!1}var Tn=setTimeout,xn=clearTimeout;function _n(e,n,t){return n="",t&&(n=" (created by "+t+")"),"\n    in "+(e||"Unknown")+n}function Rn(e,n){return e?_n(e.displayName||e.name||null,n,null):""}var Pn=[],Cn=-1;function Nn(e){return{current:e}}function zn(e){0>Cn||(e.current=Pn[Cn],Pn[Cn]=null,Cn--)}function In(e,n){Pn[++Cn]=e.current,e.current=n}var Ln={},Un=Nn(Ln),Mn=Nn(!1),An=Ln;function Dn(e,n){var t=e.type.contextTypes;if(!t)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===n)return r.__reactInternalMemoizedMaskedChildContext;var l,a={};for(l in t)a[l]=n[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function Qn(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Bn(){zn(Mn),zn(Un)}function Fn(e,n,t){if(Un.current!==Ln)throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");In(Un,n),In(Mn,t)}function jn(e,n,t){var r=e.stateNode;if(e=n.childContextTypes,"function"!=typeof r.getChildContext)return t;for(var l in r=r.getChildContext())if(!(l in e))throw Error((Je(n)||"Unknown")+'.getChildContext(): key "'+l+'" is not defined in childContextTypes.');return u({},t,r)}function On(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,An=Un.current,In(Un,e),In(Mn,Mn.current),!0}function Hn(e,n,t){var r=e.stateNode;if(!r)throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");t?(e=jn(e,n,An),r.__reactInternalMemoizedMergedChildContext=e,zn(Mn),zn(Un),In(Un,e)):zn(Mn),In(Mn,t)}var Vn=null,Wn=null;(0,c.unstable_now)();var Yn=8;function qn(e){if(0!=(1&e))return Yn=15,1;if(0!=(2&e))return Yn=14,2;if(0!=(4&e))return Yn=13,4;var n=24&e;return 0!==n?(Yn=12,n):0!=(32&e)?(Yn=11,32):0!==(n=192&e)?(Yn=10,n):0!=(256&e)?(Yn=9,256):0!==(n=3584&e)?(Yn=8,n):0!=(4096&e)?(Yn=7,4096):0!==(n=4186112&e)?(Yn=6,n):0!==(n=62914560&e)?(Yn=5,n):67108864&e?(Yn=4,67108864):0!=(134217728&e)?(Yn=3,134217728):0!==(n=805306368&e)?(Yn=2,n):0!=(1073741824&e)?(Yn=1,1073741824):(Yn=8,e)}function Xn(e){switch(e){case 99:return 15;case 98:return 10;case 97:case 96:return 8;case 95:return 2;default:return 0}}function $n(e){switch(e){case 15:case 14:return 99;case 13:case 12:case 11:case 10:return 98;case 9:case 8:case 7:case 6:case 4:case 5:return 97;case 3:case 2:case 1:return 95;case 0:return 90;default:throw Error("Invalid update priority: "+e+". This is a bug in React.")}}function Gn(e,n){var t=e.pendingLanes;if(0===t)return Yn=0;var r=0,l=0,a=e.expiredLanes,i=e.suspendedLanes,u=e.pingedLanes;if(0!==a)r=a,l=Yn=15;else if(0!==(a=134217727&t)){var o=a&~i;0!==o?(r=qn(o),l=Yn):0!==(u&=a)&&(r=qn(u),l=Yn)}else 0!==(a=t&~i)?(r=qn(a),l=Yn):0!==u&&(r=qn(u),l=Yn);if(0===r)return 0;if(r=t&((0>(r=31-tt(r))?0:1<<r)<<1)-1,0!==n&&n!==r&&0==(n&i)){if(qn(n),l<=Yn)return n;Yn=l}if(0!==(n=e.entangledLanes))for(e=e.entanglements,n&=r;0<n;)l=1<<(t=31-tt(n)),r|=e[t],n&=~l;return r}function Kn(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function Jn(e,n){switch(e){case 15:return 1;case 14:return 2;case 12:return 0===(e=Zn(24&~n))?Jn(10,n):e;case 10:return 0===(e=Zn(192&~n))?Jn(8,n):e;case 8:return 0===(e=Zn(3584&~n))&&(0===(e=Zn(4186112&~n))&&(e=512)),e;case 2:return 0===(n=Zn(805306368&~n))&&(n=268435456),n}throw Error("Invalid update priority: "+e+". This is a bug in React.")}function Zn(e){return e&-e}function et(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function nt(e,n,t){e.pendingLanes|=n;var r=n-1;e.suspendedLanes&=r,e.pingedLanes&=r,(e=e.eventTimes)[n=31-tt(n)]=t}var tt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-(rt(e)/lt|0)|0},rt=Math.log,lt=Math.LN2;var at=c.unstable_runWithPriority,it=c.unstable_scheduleCallback,ut=c.unstable_cancelCallback,ot=c.unstable_shouldYield,st=c.unstable_requestPaint,ct=c.unstable_now,ft=c.unstable_getCurrentPriorityLevel,dt=c.unstable_ImmediatePriority,pt=c.unstable_UserBlockingPriority,ht=c.unstable_NormalPriority,gt=c.unstable_LowPriority,mt=c.unstable_IdlePriority,vt={},yt=void 0!==st?st:function(){},bt=null,St=null,wt=!1,kt=ct(),Et=1e4>kt?ct:function(){return ct()-kt};function Tt(){switch(ft()){case dt:return 99;case pt:return 98;case ht:return 97;case gt:return 96;case mt:return 95;default:throw Error("Unknown priority level.")}}function xt(e){switch(e){case 99:return dt;case 98:return pt;case 97:return ht;case 96:return gt;case 95:return mt;default:throw Error("Unknown priority level.")}}function _t(e,n){return e=xt(e),at(e,n)}function Rt(e,n,t){return e=xt(e),it(e,n,t)}function Pt(){if(null!==St){var e=St;St=null,ut(e)}Ct()}function Ct(){if(!wt&&null!==bt){wt=!0;var e=0;try{var n=bt;_t(99,function(){for(;e<n.length;e++){var t=n[e];do{t=t(!0)}while(null!==t)}}),bt=null}catch(n){throw null!==bt&&(bt=bt.slice(e+1)),it(dt,Pt),n}finally{wt=!1}}}var Nt=Ie.ReactCurrentBatchConfig;var zt="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},It=Object.prototype.hasOwnProperty;function Lt(e,n){if(zt(e,n))return!0;if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(r=0;r<t.length;r++)if(!It.call(n,t[r])||!zt(e[t[r]],n[t[r]]))return!1;return!0}function Ut(e){switch(e.tag){case 5:return _n(e.type,null,null);case 16:return _n("Lazy",null,null);case 13:return _n("Suspense",null,null);case 19:return _n("SuspenseList",null,null);case 0:case 2:case 15:return Rn(e.type,null);case 11:return Rn(e.type.render,null);case 22:return Rn(e.type._render,null);case 1:return e=Rn(e.type,null);default:return""}}function Mt(e){try{var n="";do{n+=Ut(e),e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function At(e,n){if(e&&e.defaultProps){for(var t in n=u({},n),e=e.defaultProps)void 0===n[t]&&(n[t]=e[t]);return n}return n}var Dt=Nn(null),Qt=null,Bt=null,Ft=null;function jt(){Ft=Bt=Qt=null}function Ot(e){var n=Dt.current;zn(Dt),e.type._context._currentValue=n}function Ht(e,n){for(;null!==e;){var t=e.alternate;if((e.childLanes&n)===n){if(null===t||(t.childLanes&n)===n)break;t.childLanes|=n}else e.childLanes|=n,null!==t&&(t.childLanes|=n);e=e.return}}function Vt(e,n){Qt=e,Ft=Bt=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!=(e.lanes&n)&&(fl=!0),e.firstContext=null)}function Wt(e,n){if(Ft!==e&&!1!==n&&0!==n)if("number"==typeof n&&1073741823!==n||(Ft=e,n=1073741823),n={context:e,observedBits:n,next:null},null===Bt){if(null===Qt)throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");Bt=n,Qt.dependencies={lanes:0,firstContext:n,responders:null}}else Bt=Bt.next=n;return e._currentValue}var Yt=!1;function qt(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null},effects:null}}function Xt(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gt(e,n){if(null!==(e=e.updateQueue)){var t=(e=e.shared).pending;null===t?n.next=n:(n.next=t.next,t.next=n),e.pending=n}}function Kt(e,n){var t=e.updateQueue,r=e.alternate;if(null!==r&&t===(r=r.updateQueue)){var l=null,a=null;if(null!==(t=t.firstBaseUpdate)){do{var i={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};null===a?l=a=i:a=a.next=i,t=t.next}while(null!==t);null===a?l=a=n:a=a.next=n}else l=a=n;return t={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:a,shared:r.shared,effects:r.effects},void(e.updateQueue=t)}null===(e=t.lastBaseUpdate)?t.firstBaseUpdate=n:e.next=n,t.lastBaseUpdate=n}function Jt(e,n,t,r){var l=e.updateQueue;Yt=!1;var a=l.firstBaseUpdate,i=l.lastBaseUpdate,o=l.shared.pending;if(null!==o){l.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?a=c:i.next=c,i=s;var f=e.alternate;if(null!==f){var d=(f=f.updateQueue).lastBaseUpdate;d!==i&&(null===d?f.firstBaseUpdate=c:d.next=c,f.lastBaseUpdate=s)}}if(null!==a){for(d=l.baseState,i=0,f=c=s=null;;){o=a.lane;var p=a.eventTime;if((r&o)===o){null!==f&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var h=e,g=a;switch(o=n,p=t,g.tag){case 1:if("function"==typeof(h=g.payload)){d=h.call(p,d,o);break e}d=h;break e;case 3:h.flags=-8193&h.flags|64;case 0:if(null===(o="function"==typeof(h=g.payload)?h.call(p,d,o):h)||void 0===o)break e;d=u({},d,o);break e;case 2:Yt=!0}}null!==a.callback&&(e.flags|=32,null===(o=l.effects)?l.effects=[a]:o.push(a))}else p={eventTime:p,lane:o,tag:a.tag,payload:a.payload,callback:a.callback,next:null},null===f?(c=f=p,s=d):f=f.next=p,i|=o;if(null===(a=a.next)){if(null===(o=l.shared.pending))break;a=o.next,o.next=null,l.lastBaseUpdate=o,l.shared.pending=null}}null===f&&(s=d),l.baseState=s,l.firstBaseUpdate=c,l.lastBaseUpdate=f,va|=i,e.lanes=i,e.memoizedState=d}}function Zt(e,n,t){if(e=n.effects,n.effects=null,null!==e)for(n=0;n<e.length;n++){var r=e[n],l=r.callback;if(null!==l){if(r.callback=null,"function"!=typeof l)throw Error("Invalid argument passed as callback. Expected a function. Instead received: "+l);l.call(t)}}}var er=(new s.Component).refs;function nr(e,n,t,r){t=null===(t=t(r,n=e.memoizedState))||void 0===t?n:u({},n,t),e.memoizedState=t,0===e.lanes&&(e.updateQueue.baseState=t)}var tr={isMounted:function(e){return!!(e=e._reactInternals)&&Ze(e)===e},enqueueSetState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.tag=1,a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=Fa(),r=ja(e),l=$t(t,r);l.tag=2,void 0!==n&&null!==n&&(l.callback=n),Gt(e,l),Oa(e,r,t)}};function rr(e,n,t,r,l,a,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,a,i):!n.prototype||!n.prototype.isPureReactComponent||(!Lt(t,r)||!Lt(l,a))}function lr(e,n,t){var r=!1,l=Ln,a=n.contextType;return"object"==typeof a&&null!==a?a=Wt(a):(l=Qn(n)?An:Un.current,a=(r=null!==(r=n.contextTypes)&&void 0!==r)?Dn(e,l):Ln),n=new n(t,a),e.memoizedState=null!==n.state&&void 0!==n.state?n.state:null,n.updater=tr,e.stateNode=n,n._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=a),n}function ar(e,n,t,r){e=n.state,"function"==typeof n.componentWillReceiveProps&&n.componentWillReceiveProps(t,r),"function"==typeof n.UNSAFE_componentWillReceiveProps&&n.UNSAFE_componentWillReceiveProps(t,r),n.state!==e&&tr.enqueueReplaceState(n,n.state,null)}function ir(e,n,t,r){var l=e.stateNode;l.props=t,l.state=e.memoizedState,l.refs=er,qt(e);var a=n.contextType;"object"==typeof a&&null!==a?l.context=Wt(a):(a=Qn(n)?An:Un.current,l.context=Dn(e,a)),Jt(e,t,l,r),l.state=e.memoizedState,"function"==typeof(a=n.getDerivedStateFromProps)&&(nr(e,n,a,t),l.state=e.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof l.getSnapshotBeforeUpdate||"function"!=typeof l.UNSAFE_componentWillMount&&"function"!=typeof l.componentWillMount||(n=l.state,"function"==typeof l.componentWillMount&&l.componentWillMount(),"function"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),n!==l.state&&tr.enqueueReplaceState(l,l.state,null),Jt(e,t,l,r),l.state=e.memoizedState),"function"==typeof l.componentDidMount&&(e.flags|=4)}var ur=Array.isArray;function or(e,n,t){if(null!==(e=t.ref)&&"function"!=typeof e&&"object"!=typeof e){if(t._owner){if(t=t._owner){if(1!==t.tag)throw Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");var r=t.stateNode}if(!r)throw Error("Missing owner for string ref "+e+". This error is likely caused by a bug in React. Please file an issue.");var l=""+e;return null!==n&&null!==n.ref&&"function"==typeof n.ref&&n.ref._stringRef===l?n.ref:((n=function(e){var n=r.refs;n===er&&(n=r.refs={}),null===e?delete n[l]:n[l]=e})._stringRef=l,n)}if("string"!=typeof e)throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");if(!t._owner)throw Error("Element ref was specified as a string ("+e+") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information.")}return e}function sr(e,n){if("textarea"!==e.type)throw Error("Objects are not valid as a React child (found: "+("[object Object]"===Object.prototype.toString.call(n)?"object with keys {"+Object.keys(n).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.")}function cr(e){function n(n,t){if(e){var r=n.lastEffect;null!==r?(r.nextEffect=t,n.lastEffect=t):n.firstEffect=n.lastEffect=t,t.nextEffect=null,t.flags=8}}function t(t,r){if(!e)return null;for(;null!==r;)n(t,r),r=r.sibling;return null}function r(e,n){for(e=new Map;null!==n;)null!==n.key?e.set(n.key,n):e.set(n.index,n),n=n.sibling;return e}function l(e,n){return(e=bi(e,n)).index=0,e.sibling=null,e}function a(n,t,r){return n.index=r,e?null!==(r=n.alternate)?(r=r.index)<t?(n.flags=2,t):r:(n.flags=2,t):t}function i(n){return e&&null===n.alternate&&(n.flags=2),n}function u(e,n,t,r){return null===n||6!==n.tag?((n=Ei(t,e.mode,r)).return=e,n):((n=l(n,t)).return=e,n)}function o(e,n,t,r){return null!==n&&n.elementType===t.type?((r=l(n,t.props)).ref=or(e,n,t),r.return=e,r):((r=Si(t.type,t.key,t.props,null,e.mode,r)).ref=or(e,n,t),r.return=e,r)}function s(e,n,t,r){return null===n||4!==n.tag||n.stateNode.containerInfo!==t.containerInfo||n.stateNode.implementation!==t.implementation?((n=Ti(t,e.mode,r)).return=e,n):((n=l(n,t.children||[])).return=e,n)}function c(e,n,t,r,a){return null===n||7!==n.tag?((n=wi(t,e.mode,r,a)).return=e,n):((n=l(n,t)).return=e,n)}function f(e,n,t){if("string"==typeof n||"number"==typeof n)return(n=Ei(""+n,e.mode,t)).return=e,n;if("object"==typeof n&&null!==n){switch(n.$$typeof){case Le:return(t=Si(n.type,n.key,n.props,null,e.mode,t)).ref=or(e,null,n),t.return=e,t;case Ue:return(n=Ti(n,e.mode,t)).return=e,n}if(ur(n)||Ke(n))return(n=wi(n,e.mode,t,null)).return=e,n;sr(e,n)}return null}function d(e,n,t,r){var l=null!==n?n.key:null;if("string"==typeof t||"number"==typeof t)return null!==l?null:u(e,n,""+t,r);if("object"==typeof t&&null!==t){switch(t.$$typeof){case Le:return t.key===l?t.type===Me?c(e,n,t.props.children,r,l):o(e,n,t,r):null;case Ue:return t.key===l?s(e,n,t,r):null}if(ur(t)||Ke(t))return null!==l?null:c(e,n,t,r,null);sr(e,t)}return null}function p(e,n,t,r,l){if("string"==typeof r||"number"==typeof r)return u(n,e=e.get(t)||null,""+r,l);if("object"==typeof r&&null!==r){switch(r.$$typeof){case Le:return e=e.get(null===r.key?t:r.key)||null,r.type===Me?c(n,e,r.props.children,l,r.key):o(n,e,r,l);case Ue:return s(n,e=e.get(null===r.key?t:r.key)||null,r,l)}if(ur(r)||Ke(r))return c(n,e=e.get(t)||null,r,l,null);sr(n,r)}return null}function h(l,i,u,o){for(var s=null,c=null,h=i,g=i=0,m=null;null!==h&&g<u.length;g++){h.index>g?(m=h,h=null):m=h.sibling;var v=d(l,h,u[g],o);if(null===v){null===h&&(h=m);break}e&&h&&null===v.alternate&&n(l,h),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v,h=m}if(g===u.length)return t(l,h),s;if(null===h){for(;g<u.length;g++)null!==(h=f(l,u[g],o))&&(i=a(h,i,g),null===c?s=h:c.sibling=h,c=h);return s}for(h=r(l,h);g<u.length;g++)null!==(m=p(h,l,g,u[g],o))&&(e&&null!==m.alternate&&h.delete(null===m.key?g:m.key),i=a(m,i,g),null===c?s=m:c.sibling=m,c=m);return e&&h.forEach(function(e){return n(l,e)}),s}function g(l,i,u,o){var s=Ke(u);if("function"!=typeof s)throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");if(null==(u=s.call(u)))throw Error("An iterable object provided no iterator.");for(var c=s=null,h=i,g=i=0,m=null,v=u.next();null!==h&&!v.done;g++,v=u.next()){h.index>g?(m=h,h=null):m=h.sibling;var y=d(l,h,v.value,o);if(null===y){null===h&&(h=m);break}e&&h&&null===y.alternate&&n(l,h),i=a(y,i,g),null===c?s=y:c.sibling=y,c=y,h=m}if(v.done)return t(l,h),s;if(null===h){for(;!v.done;g++,v=u.next())null!==(v=f(l,v.value,o))&&(i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return s}for(h=r(l,h);!v.done;g++,v=u.next())null!==(v=p(h,l,g,v.value,o))&&(e&&null!==v.alternate&&h.delete(null===v.key?g:v.key),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return e&&h.forEach(function(e){return n(l,e)}),s}return function(e,r,a,u){var o="object"==typeof a&&null!==a&&a.type===Me&&null===a.key;o&&(a=a.props.children);var s="object"==typeof a&&null!==a;if(s)switch(a.$$typeof){case Le:e:{for(s=a.key,o=r;null!==o;){if(o.key===s){switch(o.tag){case 7:if(a.type===Me){t(e,o.sibling),(r=l(o,a.props.children)).return=e,e=r;break e}break;default:if(o.elementType===a.type){t(e,o.sibling),(r=l(o,a.props)).ref=or(e,o,a),r.return=e,e=r;break e}}t(e,o);break}n(e,o),o=o.sibling}a.type===Me?((r=wi(a.props.children,e.mode,u,a.key)).return=e,e=r):((u=Si(a.type,a.key,a.props,null,e.mode,u)).ref=or(e,r,a),u.return=e,e=u)}return i(e);case Ue:e:{for(o=a.key;null!==r;){if(r.key===o){if(4===r.tag&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){t(e,r.sibling),(r=l(r,a.children||[])).return=e,e=r;break e}t(e,r);break}n(e,r),r=r.sibling}(r=Ti(a,e.mode,u)).return=e,e=r}return i(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==r&&6===r.tag?(t(e,r.sibling),(r=l(r,a)).return=e,e=r):(t(e,r),(r=Ei(a,e.mode,u)).return=e,e=r),i(e);if(ur(a))return h(e,r,a,u);if(Ke(a))return g(e,r,a,u);if(s&&sr(e,a),void 0===a&&!o)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error((Je(e.type)||"Component")+"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.")}return t(e,r)}}var fr=cr(!0),dr=cr(!1),pr={},hr=Nn(pr),gr=Nn(pr),mr=Nn(pr);function vr(e){if(e===pr)throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");return e}function yr(e,n){In(mr,n),In(gr,e),In(hr,pr),zn(hr),In(hr,{isInAParentText:!1})}function br(){zn(hr),zn(gr),zn(mr)}function Sr(e){vr(mr.current);var n=vr(hr.current),t=e.type;t="AndroidTextInput"===t||"RCTMultilineTextInputView"===t||"RCTSinglelineTextInputView"===t||"RCTText"===t||"RCTVirtualText"===t,n!==(t=n.isInAParentText!==t?{isInAParentText:t}:n)&&(In(gr,e),In(hr,t))}function wr(e){gr.current===e&&(zn(hr),zn(gr))}var kr=Nn(0);function Er(e){for(var n=e;null!==n;){if(13===n.tag){var t=n.memoizedState;if(null!==t&&(null===t.dehydrated||vn()||vn()))return n}else if(19===n.tag&&void 0!==n.memoizedProps.revealOrder){if(0!=(64&n.flags))return n}else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===e)break;for(;null===n.sibling;){if(null===n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Tr=[];function xr(){for(var e=0;e<Tr.length;e++)Tr[e]._workInProgressVersionPrimary=null;Tr.length=0}var _r=Ie.ReactCurrentDispatcher,Rr=Ie.ReactCurrentBatchConfig,Pr=0,Cr=null,Nr=null,zr=null,Ir=!1,Lr=!1;function Ur(){throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.")}function Mr(e,n){if(null===n)return!1;for(var t=0;t<n.length&&t<e.length;t++)if(!zt(e[t],n[t]))return!1;return!0}function Ar(e,n,t,r,l,a){if(Pr=a,Cr=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,_r.current=null===e||null===e.memoizedState?ul:ol,e=t(r,l),Lr){a=0;do{if(Lr=!1,!(25>a))throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");a+=1,zr=Nr=null,n.updateQueue=null,_r.current=sl,e=t(r,l)}while(Lr)}if(_r.current=il,n=null!==Nr&&null!==Nr.next,Pr=0,zr=Nr=Cr=null,Ir=!1,n)throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");return e}function Dr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===zr?Cr.memoizedState=zr=e:zr=zr.next=e,zr}function Qr(){if(null===Nr){var e=Cr.alternate;e=null!==e?e.memoizedState:null}else e=Nr.next;var n=null===zr?Cr.memoizedState:zr.next;if(null!==n)zr=n,Nr=e;else{if(null===e)throw Error("Rendered more hooks than during the previous render.");e={memoizedState:(Nr=e).memoizedState,baseState:Nr.baseState,baseQueue:Nr.baseQueue,queue:Nr.queue,next:null},null===zr?Cr.memoizedState=zr=e:zr=zr.next=e}return zr}function Br(e,n){return"function"==typeof n?n(e):n}function Fr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=Nr,l=r.baseQueue,a=t.pending;if(null!==a){if(null!==l){var i=l.next;l.next=a.next,a.next=i}r.baseQueue=l=a,t.pending=null}if(null!==l){l=l.next,r=r.baseState;var u=i=a=null,o=l;do{var s=o.lane;if((Pr&s)===s)null!==u&&(u=u.next={lane:0,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null}),r=o.eagerReducer===e?o.eagerState:e(r,o.action);else{var c={lane:s,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null};null===u?(i=u=c,a=r):u=u.next=c,Cr.lanes|=s,va|=s}o=o.next}while(null!==o&&o!==l);null===u?a=r:u.next=i,zt(r,n.memoizedState)||(fl=!0),n.memoizedState=r,n.baseState=a,n.baseQueue=u,t.lastRenderedState=r}return[n.memoizedState,t.dispatch]}function jr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=t.dispatch,l=t.pending,a=n.memoizedState;if(null!==l){t.pending=null;var i=l=l.next;do{a=e(a,i.action),i=i.next}while(i!==l);zt(a,n.memoizedState)||(fl=!0),n.memoizedState=a,null===n.baseQueue&&(n.baseState=a),t.lastRenderedState=a}return[a,r]}function Or(e,n,t){var r=n._getVersion;r=r(n._source);var l=n._workInProgressVersionPrimary;if(null!==l?e=l===r:(e=e.mutableReadLanes,(e=(Pr&e)===e)&&(n._workInProgressVersionPrimary=r,Tr.push(n))),e)return t(n._source);throw Tr.push(n),Error("Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.")}function Hr(e,n,t,r){var l=sa;if(null===l)throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");var a=n._getVersion,i=a(n._source),u=_r.current,o=u.useState(function(){return Or(l,n,t)}),s=o[1],c=o[0];o=zr;var f=e.memoizedState,d=f.refs,p=d.getSnapshot,h=f.source;f=f.subscribe;var g=Cr;return e.memoizedState={refs:d,source:n,subscribe:r},u.useEffect(function(){d.getSnapshot=t,d.setSnapshot=s;var e=a(n._source);if(!zt(i,e)){e=t(n._source),zt(c,e)||(s(e),e=ja(g),l.mutableReadLanes|=e&l.pendingLanes),e=l.mutableReadLanes,l.entangledLanes|=e;for(var r=l.entanglements,u=e;0<u;){var o=31-tt(u),f=1<<o;r[o]|=e,u&=~f}}},[t,n,r]),u.useEffect(function(){return r(n._source,function(){var e=d.getSnapshot,t=d.setSnapshot;try{t(e(n._source));var r=ja(g);l.mutableReadLanes|=r&l.pendingLanes}catch(e){t(function(){throw e})}})},[n,r]),zt(p,t)&&zt(h,n)&&zt(f,r)||((e={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:c}).dispatch=s=al.bind(null,Cr,e),o.queue=e,o.baseQueue=null,c=Or(l,n,t),o.memoizedState=o.baseState=c),c}function Vr(e,n,t){return Hr(Qr(),e,n,t)}function Wr(e){var n=Dr();return"function"==typeof e&&(e=e()),n.memoizedState=n.baseState=e,e=(e=n.queue={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:e}).dispatch=al.bind(null,Cr,e),[n.memoizedState,e]}function Yr(e,n,t,r){return e={tag:e,create:n,destroy:t,deps:r,next:null},null===(n=Cr.updateQueue)?(n={lastEffect:null},Cr.updateQueue=n,n.lastEffect=e.next=e):null===(t=n.lastEffect)?n.lastEffect=e.next=e:(r=t.next,t.next=e,e.next=r,n.lastEffect=e),e}function qr(){return Qr().memoizedState}function Xr(e,n,t,r){var l=Dr();Cr.flags|=e,l.memoizedState=Yr(1|n,t,void 0,void 0===r?null:r)}function $r(e,n,t,r){var l=Qr();r=void 0===r?null:r;var a=void 0;if(null!==Nr){var i=Nr.memoizedState;if(a=i.destroy,null!==r&&Mr(r,i.deps))return void Yr(n,t,a,r)}Cr.flags|=e,l.memoizedState=Yr(1|n,t,a,r)}function Gr(e,n){return Xr(516,4,e,n)}function Kr(e,n){return $r(516,4,e,n)}function Jr(e,n){return $r(4,2,e,n)}function Zr(e,n){return"function"==typeof n?(e=e(),n(e),function(){n(null)}):null!==n&&void 0!==n?(e=e(),n.current=e,function(){n.current=null}):void 0}function el(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,$r(4,2,Zr.bind(null,n,e),t)}function nl(){}function tl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(t.memoizedState=[e,n],e)}function rl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(e=e(),t.memoizedState=[e,n],e)}function ll(e,n){var t=Tt();_t(98>t?98:t,function(){e(!0)}),_t(97<t?97:t,function(){var t=Rr.transition;Rr.transition=1;try{e(!1),n()}finally{Rr.transition=t}})}function al(e,n,t){var r=Fa(),l=ja(e),a={lane:l,action:t,eagerReducer:null,eagerState:null,next:null},i=n.pending;if(null===i?a.next=a:(a.next=i.next,i.next=a),n.pending=a,i=e.alternate,e===Cr||null!==i&&i===Cr)Lr=Ir=!0;else{if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=n.lastRenderedReducer))try{var u=n.lastRenderedState,o=i(u,t);if(a.eagerReducer=i,a.eagerState=o,zt(o,u))return}catch(e){}Oa(e,l,r)}}var il={readContext:Wt,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useMutableSource:Ur,useOpaqueIdentifier:Ur,unstable_isNewReconciler:!1},ul={readContext:Wt,useCallback:function(e,n){return Dr().memoizedState=[e,void 0===n?null:n],e},useContext:Wt,useEffect:Gr,useImperativeHandle:function(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,Xr(4,2,Zr.bind(null,n,e),t)},useLayoutEffect:function(e,n){return Xr(4,2,e,n)},useMemo:function(e,n){var t=Dr();return n=void 0===n?null:n,e=e(),t.memoizedState=[e,n],e},useReducer:function(e,n,t){var r=Dr();return n=void 0!==t?t(n):n,r.memoizedState=r.baseState=n,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:n}).dispatch=al.bind(null,Cr,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Dr().memoizedState=e},useState:Wr,useDebugValue:nl,useDeferredValue:function(e){var n=Wr(e),t=n[0],r=n[1];return Gr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Wr(!1),n=e[0];return e=ll.bind(null,e[1]),Dr().memoizedState=e,[e,n]},useMutableSource:function(e,n,t){var r=Dr();return r.memoizedState={refs:{getSnapshot:n,setSnapshot:null},source:e,subscribe:t},Hr(r,e,n,t)},useOpaqueIdentifier:function(){throw Error("Not yet implemented")},unstable_isNewReconciler:!1},ol={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:Fr,useRef:qr,useState:function(){return Fr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=Fr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Fr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return Fr(Br)[0]},unstable_isNewReconciler:!1},sl={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:jr,useRef:qr,useState:function(){return jr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=jr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=jr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return jr(Br)[0]},unstable_isNewReconciler:!1},cl=Ie.ReactCurrentOwner,fl=!1;function dl(e,n,t,r){n.child=null===e?dr(n,null,t,r):fr(n,e.child,t,r)}function pl(e,n,t,r,l){t=t.render;var a=n.ref;return Vt(n,l),r=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,r,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function hl(e,n,t,r,l,a){if(null===e){var i=t.type;return"function"!=typeof i||vi(i)||void 0!==i.defaultProps||null!==t.compare||void 0!==t.defaultProps?((e=Si(t.type,null,r,n,n.mode,a)).ref=n.ref,e.return=n,n.child=e):(n.tag=15,n.type=i,gl(e,n,i,r,l,a))}return i=e.child,0==(l&a)&&(l=i.memoizedProps,(t=null!==(t=t.compare)?t:Lt)(l,r)&&e.ref===n.ref)?Ul(e,n,a):(n.flags|=1,(e=bi(i,r)).ref=n.ref,e.return=n,n.child=e)}function gl(e,n,t,r,l,a){if(null!==e&&Lt(e.memoizedProps,r)&&e.ref===n.ref){if(fl=!1,0==(a&l))return n.lanes=e.lanes,Ul(e,n,a);0!=(32768&e.flags)&&(fl=!0)}return yl(e,n,t,r,a)}function ml(e,n,t){var r=n.pendingProps,l=r.children,a=null!==e?e.memoizedState:null;if("hidden"===r.mode||"unstable-defer-without-hiding"===r.mode)if(0==(4&n.mode))n.memoizedState={baseLanes:0},Xa(n,t);else{if(0==(1073741824&t))return e=null!==a?a.baseLanes|t:t,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e},Xa(n,e),null;n.memoizedState={baseLanes:0},Xa(n,null!==a?a.baseLanes:t)}else null!==a?(r=a.baseLanes|t,n.memoizedState=null):r=t,Xa(n,r);return dl(e,n,l,t),n.child}function vl(e,n){var t=n.ref;(null===e&&null!==t||null!==e&&e.ref!==t)&&(n.flags|=128)}function yl(e,n,t,r,l){var a=Qn(t)?An:Un.current;return a=Dn(n,a),Vt(n,l),t=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,t,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function bl(e,n,t,r,l){if(Qn(t)){var a=!0;On(n)}else a=!1;if(Vt(n,l),null===n.stateNode)null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),lr(n,t,r),ir(n,t,r,l),r=!0;else if(null===e){var i=n.stateNode,u=n.memoizedProps;i.props=u;var o=i.context,s=t.contextType;"object"==typeof s&&null!==s?s=Wt(s):s=Dn(n,s=Qn(t)?An:Un.current);var c=t.getDerivedStateFromProps,f="function"==typeof c||"function"==typeof i.getSnapshotBeforeUpdate;f||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==r||o!==s)&&ar(n,i,r,s),Yt=!1;var d=n.memoizedState;i.state=d,Jt(n,r,i,l),o=n.memoizedState,u!==r||d!==o||Mn.current||Yt?("function"==typeof c&&(nr(n,t,c,r),o=n.memoizedState),(u=Yt||rr(n,t,u,r,d,o,s))?(f||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(n.flags|=4)):("function"==typeof i.componentDidMount&&(n.flags|=4),n.memoizedProps=r,n.memoizedState=o),i.props=r,i.state=o,i.context=s,r=u):("function"==typeof i.componentDidMount&&(n.flags|=4),r=!1)}else{i=n.stateNode,Xt(e,n),u=n.memoizedProps,s=n.type===n.elementType?u:At(n.type,u),i.props=s,f=n.pendingProps,d=i.context,"object"==typeof(o=t.contextType)&&null!==o?o=Wt(o):o=Dn(n,o=Qn(t)?An:Un.current);var p=t.getDerivedStateFromProps;(c="function"==typeof p||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==f||d!==o)&&ar(n,i,r,o),Yt=!1,d=n.memoizedState,i.state=d,Jt(n,r,i,l);var h=n.memoizedState;u!==f||d!==h||Mn.current||Yt?("function"==typeof p&&(nr(n,t,p,r),h=n.memoizedState),(s=Yt||rr(n,t,s,r,d,h,o))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,o),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,o)),"function"==typeof i.componentDidUpdate&&(n.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(n.flags|=256)):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),n.memoizedProps=r,n.memoizedState=h),i.props=r,i.state=h,i.context=o,r=s):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),r=!1)}return Sl(e,n,t,r,a,l)}function Sl(e,n,t,r,l,a){vl(e,n);var i=0!=(64&n.flags);if(!r&&!i)return l&&Hn(n,t,!1),Ul(e,n,a);r=n.stateNode,cl.current=n;var u=i&&"function"!=typeof t.getDerivedStateFromError?null:r.render();return n.flags|=1,null!==e&&i?(n.child=fr(n,e.child,null,a),n.child=fr(n,null,u,a)):dl(e,n,u,a),n.memoizedState=r.state,l&&Hn(n,t,!0),n.child}function wl(e){var n=e.stateNode;n.pendingContext?Fn(0,n.pendingContext,n.pendingContext!==n.context):n.context&&Fn(0,n.context,!1),yr(e,n.containerInfo)}var kl,El,Tl,xl,_l={dehydrated:null,retryLane:0};function Rl(e,n,t){var r,l=n.pendingProps,a=kr.current,i=!1;return(r=0!=(64&n.flags))||(r=(null===e||null!==e.memoizedState)&&0!=(2&a)),r?(i=!0,n.flags&=-65):null!==e&&null===e.memoizedState||void 0===l.fallback||!0===l.unstable_avoidThisFallback||(a|=1),In(kr,1&a),null===e?(e=l.children,a=l.fallback,i?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,e):"number"==typeof l.unstable_expectedLoadTime?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,n.lanes=33554432,e):((t=ki({mode:"visible",children:e},n.mode,t,null)).return=n,n.child=t)):(e.memoizedState,i?(l=Nl(e,n,l.children,l.fallback,t),i=n.child,a=e.child.memoizedState,i.memoizedState=null===a?{baseLanes:t}:{baseLanes:a.baseLanes|t},i.childLanes=e.childLanes&~t,n.memoizedState=_l,l):(t=Cl(e,n,l.children,t),n.memoizedState=null,t))}function Pl(e,n,t,r){var l=e.mode,a=e.child;return n={mode:"hidden",children:n},0==(2&l)&&null!==a?(a.childLanes=0,a.pendingProps=n):a=ki(n,l,0,null),t=wi(t,l,r,null),a.return=e,t.return=e,a.sibling=t,e.child=a,t}function Cl(e,n,t,r){var l=e.child;return e=l.sibling,t=bi(l,{mode:"visible",children:t}),0==(2&n.mode)&&(t.lanes=r),t.return=n,t.sibling=null,null!==e&&(e.nextEffect=null,e.flags=8,n.firstEffect=n.lastEffect=e),n.child=t}function Nl(e,n,t,r,l){var a=n.mode,i=e.child;e=i.sibling;var u={mode:"hidden",children:t};return 0==(2&a)&&n.child!==i?((t=n.child).childLanes=0,t.pendingProps=u,null!==(i=t.lastEffect)?(n.firstEffect=t.firstEffect,n.lastEffect=i,i.nextEffect=null):n.firstEffect=n.lastEffect=null):t=bi(i,u),null!==e?r=bi(e,r):(r=wi(r,a,l,null)).flags|=2,r.return=n,t.return=n,t.sibling=r,n.child=t,r}function zl(e,n){e.lanes|=n;var t=e.alternate;null!==t&&(t.lanes|=n),Ht(e.return,n)}function Il(e,n,t,r,l,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:l,lastEffect:a}:(i.isBackwards=n,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=t,i.tailMode=l,i.lastEffect=a)}function Ll(e,n,t){var r=n.pendingProps,l=r.revealOrder,a=r.tail;if(dl(e,n,r.children,t),0!=(2&(r=kr.current)))r=1&r|2,n.flags|=64;else{if(null!==e&&0!=(64&e.flags))e:for(e=n.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zl(e,t);else if(19===e.tag)zl(e,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(In(kr,r),0==(2&n.mode))n.memoizedState=null;else switch(l){case"forwards":for(t=n.child,l=null;null!==t;)null!==(e=t.alternate)&&null===Er(e)&&(l=t),t=t.sibling;null===(t=l)?(l=n.child,n.child=null):(l=t.sibling,t.sibling=null),Il(n,!1,l,t,a,n.lastEffect);break;case"backwards":for(t=null,l=n.child,n.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Er(e)){n.child=l;break}e=l.sibling,l.sibling=t,t=l,l=e}Il(n,!0,t,null,a,n.lastEffect);break;case"together":Il(n,!1,null,null,void 0,n.lastEffect);break;default:n.memoizedState=null}return n.child}function Ul(e,n,t){if(null!==e&&(n.dependencies=e.dependencies),va|=n.lanes,0!=(t&n.childLanes)){if(null!==e&&n.child!==e.child)throw Error("Resuming work not yet implemented.");if(null!==n.child){for(t=bi(e=n.child,e.pendingProps),n.child=t,t.return=n;null!==e.sibling;)e=e.sibling,(t=t.sibling=bi(e,e.pendingProps)).return=n;t.sibling=null}return n.child}return null}function Ml(e,n){switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;null!==n;)null!==n.alternate&&(t=n),n=n.sibling;null===t?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?n||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Al(e,n,t){var r=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return Qn(n.type)&&Bn(),null;case 3:return br(),zn(Mn),zn(Un),xr(),(r=n.stateNode).pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||r.hydrate||(n.flags|=256),El(n),null;case 5:wr(n);var l=vr(mr.current);if(t=n.type,null!==e&&null!=n.stateNode)Tl(e,n,t,r,l),e.ref!==n.ref&&(n.flags|=128);else{if(!r){if(null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return null}vr(hr.current),e=wn(),t=yn(t);var a=hn(null,ln,r,t.validAttributes);o.UIManager.createView(e,t.uiViewClassName,l,a),l=new mn(e,t,n),ke.set(e,n),Ee.set(e,r),kl(l,n,!1,!1),n.stateNode=l,En(l)&&(n.flags|=4),null!==n.ref&&(n.flags|=128)}return null;case 6:if(e&&null!=n.stateNode)xl(e,n,e.memoizedProps,r);else{if("string"!=typeof r&&null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");if(e=vr(mr.current),!vr(hr.current).isInAParentText)throw Error("Text strings must be rendered within a <Text> component.");l=wn(),o.UIManager.createView(l,"RCTRawText",e,{text:r}),ke.set(l,n),n.stateNode=l}return null;case 13:return zn(kr),r=n.memoizedState,0!=(64&n.flags)?(n.lanes=t,n):(r=null!==r,l=!1,null!==e&&(l=null!==e.memoizedState),r&&!l&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&kr.current)?0===ha&&(ha=3):(0!==ha&&3!==ha||(ha=4),null===sa||0==(134217727&va)&&0==(134217727&ya)||Ya(sa,fa))),(r||l)&&(n.flags|=4),null);case 4:return br(),El(n),null;case 10:return Ot(n),null;case 17:return Qn(n.type)&&Bn(),null;case 19:if(zn(kr),null===(r=n.memoizedState))return null;if(l=0!=(64&n.flags),null===(a=r.rendering))if(l)Ml(r,!1);else{if(0!==ha||null!==e&&0!=(64&e.flags))for(e=n.child;null!==e;){if(null!==(a=Er(e))){for(n.flags|=64,Ml(r,!1),null!==(e=a.updateQueue)&&(n.updateQueue=e,n.flags|=4),null===r.lastEffect&&(n.firstEffect=null),n.lastEffect=r.lastEffect,e=t,r=n.child;null!==r;)t=e,(l=r).flags&=2,l.nextEffect=null,l.firstEffect=null,l.lastEffect=null,null===(a=l.alternate)?(l.childLanes=0,l.lanes=t,l.child=null,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=a.childLanes,l.lanes=a.lanes,l.child=a.child,l.memoizedProps=a.memoizedProps,l.memoizedState=a.memoizedState,l.updateQueue=a.updateQueue,l.type=a.type,t=a.dependencies,l.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return In(kr,1&kr.current|2),n.child}e=e.sibling}null!==r.tail&&Et()>ka&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432)}else{if(!l)if(null!==(e=Er(a))){if(n.flags|=64,l=!0,null!==(e=e.updateQueue)&&(n.updateQueue=e,n.flags|=4),Ml(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate)return null!==(n=n.lastEffect=r.lastEffect)&&(n.nextEffect=null),null}else 2*Et()-r.renderingStartTime>ka&&1073741824!==t&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432);r.isBackwards?(a.sibling=n.child,n.child=a):(null!==(e=r.last)?e.sibling=a:n.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.lastEffect=n.lastEffect,r.renderingStartTime=Et(),e.sibling=null,n=kr.current,In(kr,l?1&n|2:1&n),e):null;case 23:case 24:return $a(),null!==e&&null!==e.memoizedState!=(null!==n.memoizedState)&&"unstable-defer-without-hiding"!==r.mode&&(n.flags|=4),null}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function Dl(e){switch(e.tag){case 1:Qn(e.type)&&Bn();var n=e.flags;return 8192&n?(e.flags=-8193&n|64,e):null;case 3:if(br(),zn(Mn),zn(Un),xr(),0!=(64&(n=e.flags)))throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");return e.flags=-8193&n|64,e;case 5:return wr(e),null;case 13:return zn(kr),8192&(n=e.flags)?(e.flags=-8193&n|64,e):null;case 19:return zn(kr),null;case 4:return br(),null;case 10:return Ot(e),null;case 23:case 24:return $a(),null;default:return null}}function Ql(e,n){return{value:e,source:n,stack:Mt(n)}}if(kl=function(e,n){for(var t=n.child;null!==t;){if(5===t.tag||6===t.tag)e._children.push(t.stateNode);else if(4!==t.tag&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===n)break;for(;null===t.sibling;){if(null===t.return||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}},El=function(){},Tl=function(e,n,t,r){e.memoizedProps!==r&&(vr(hr.current),n.updateQueue=bn)&&(n.flags|=4)},xl=function(e,n,t,r){t!==r&&(n.flags|=4)},"function"!=typeof o.ReactFiberErrorDialog.showErrorDialog)throw Error("Expected ReactFiberErrorDialog.showErrorDialog to be a function.");function Bl(e,n){try{!1!==o.ReactFiberErrorDialog.showErrorDialog({componentStack:null!==n.stack?n.stack:"",error:n.value,errorBoundary:null!==e&&1===e.tag?e.stateNode:null})&&console.error(n.value)}catch(e){setTimeout(function(){throw e})}}var Fl="function"==typeof WeakMap?WeakMap:Map;function jl(e,n,t){(t=$t(-1,t)).tag=3,t.payload={element:null};var r=n.value;return t.callback=function(){Ta||(Ta=!0,xa=r),Bl(e,n)},t}function Ol(e,n,t){(t=$t(-1,t)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var l=n.value;t.payload=function(){return Bl(e,n),r(l)}}var a=e.stateNode;return null!==a&&"function"==typeof a.componentDidCatch&&(t.callback=function(){"function"!=typeof r&&(null===_a?_a=new Set([this]):_a.add(this),Bl(e,n));var t=n.stack;this.componentDidCatch(n.value,{componentStack:null!==t?t:""})}),t}var Hl="function"==typeof WeakSet?WeakSet:Set;function Vl(e){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){di(e,n)}else n.current=null}function Wl(e,n){switch(n.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&n.flags&&null!==e){var t=e.memoizedProps,r=e.memoizedState;n=(e=n.stateNode).getSnapshotBeforeUpdate(n.elementType===n.type?t:At(n.type,t),r),e.__reactInternalSnapshotBeforeUpdate=n}return;case 3:return;case 5:case 6:case 4:case 17:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function Yl(e,n,t){switch(t.tag){case 0:case 11:case 15:case 22:if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{if(3==(3&e.tag)){var r=e.create;e.destroy=r()}e=e.next}while(e!==n)}if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{var l=e;r=l.next,0!=(4&(l=l.tag))&&0!=(1&l)&&(si(t,e),oi(t,e)),e=r}while(e!==n)}return;case 1:return e=t.stateNode,4&t.flags&&(null===n?e.componentDidMount():(r=t.elementType===t.type?n.memoizedProps:At(t.type,n.memoizedProps),e.componentDidUpdate(r,n.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),void(null!==(n=t.updateQueue)&&Zt(t,n,e));case 3:if(null!==(n=t.updateQueue)){if(e=null,null!==t.child)switch(t.child.tag){case 5:e=t.child.stateNode;break;case 1:e=t.child.stateNode}Zt(t,n,e)}return;case 5:case 6:case 4:case 12:case 13:return;case 19:case 17:case 20:case 21:case 23:case 24:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ql(e,n){for(var t=e;;){if(5===t.tag){var r=t.stateNode;if(n){var l=r.viewConfig,a=hn(null,ln,{style:{display:"none"}},l.validAttributes);o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}else{r=t.stateNode,a=t.memoizedProps,l=r.viewConfig,a=hn(null,u({},a,{style:[a.style,{display:"none"}]}),a,l.validAttributes),o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}}else{if(6===t.tag)throw Error("Not yet implemented.");if((23!==t.tag&&24!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}function Xl(e,n){if(Wn&&"function"==typeof Wn.onCommitFiberUnmount)try{Wn.onCommitFiberUnmount(Vn,n)}catch(e){}switch(n.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=n.updateQueue)&&null!==(e=e.lastEffect)){var t=e=e.next;do{var r=t,l=r.destroy;if(r=r.tag,void 0!==l)if(0!=(4&r))si(n,t);else{r=n;try{l()}catch(e){di(r,e)}}t=t.next}while(t!==e)}break;case 1:if(Vl(n),"function"==typeof(e=n.stateNode).componentWillUnmount)try{e.props=n.memoizedProps,e.state=n.memoizedState,e.componentWillUnmount()}catch(e){di(n,e)}break;case 5:Vl(n);break;case 4:ea(e,n)}}function $l(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}function Gl(e){return 5===e.tag||3===e.tag||4===e.tag}function Kl(e){e:{for(var n=e.return;null!==n;){if(Gl(n))break e;n=n.return}throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.")}var t=n;switch(n=t.stateNode,t.tag){case 5:var r=!1;break;case 3:case 4:n=n.containerInfo,r=!0;break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}16&t.flags&&(t.flags&=-17);e:n:for(t=e;;){for(;null===t.sibling;){if(null===t.return||Gl(t.return)){t=null;break e}t=t.return}for(t.sibling.return=t.return,t=t.sibling;5!==t.tag&&6!==t.tag&&18!==t.tag;){if(2&t.flags)continue n;if(null===t.child||4===t.tag)continue n;t.child.return=t,t=t.child}if(!(2&t.flags)){t=t.stateNode;break e}}r?Jl(e,t,n):Zl(e,t,n)}function Jl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)if(e=l?e.stateNode:e.stateNode.instance,n){if("number"==typeof t)throw Error("Container does not support insertBefore operation")}else o.UIManager.setChildren(t,["number"==typeof e?e:e._nativeTag]);else if(4!==r&&null!==(e=e.child))for(Jl(e,n,t),e=e.sibling;null!==e;)Jl(e,n,t),e=e.sibling}function Zl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,n?0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[l],[n],[],[],[])):(n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[],[],["number"==typeof e?e:e._nativeTag],[n],[])):(n="number"==typeof e?e:e._nativeTag,0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),r.push(e),o.UIManager.manageChildren(t._nativeTag,[l],[r.length-1],[],[],[])):(r.push(e),o.UIManager.manageChildren(t._nativeTag,[],[],[n],[r.length-1],[])));else if(4!==r&&null!==(e=e.child))for(Zl(e,n,t),e=e.sibling;null!==e;)Zl(e,n,t),e=e.sibling}function ea(e,n){for(var t,r,l=n,a=!1;;){if(!a){a=l.return;e:for(;;){if(null===a)throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");switch(t=a.stateNode,a.tag){case 5:r=!1;break e;case 3:case 4:t=t.containerInfo,r=!0;break e}a=a.return}a=!0}if(5===l.tag||6===l.tag){e:for(var i=e,u=l,s=u;;)if(Xl(i,s),null!==s.child&&4!==s.tag)s.child.return=s,s=s.child;else{if(s===u)break e;for(;null===s.sibling;){if(null===s.return||s.return===u)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}r?(i=t,kn(l.stateNode),o.UIManager.manageChildren(i,[],[],[],[],[0])):(i=t,kn(s=l.stateNode),s=(u=i._children).indexOf(s),u.splice(s,1),o.UIManager.manageChildren(i._nativeTag,[],[],[],[],[s]))}else if(4===l.tag){if(null!==l.child){t=l.stateNode.containerInfo,r=!0,l.child.return=l,l=l.child;continue}}else if(Xl(e,l),null!==l.child){l.child.return=l,l=l.child;continue}if(l===n)break;for(;null===l.sibling;){if(null===l.return||l.return===n)return;4===(l=l.return).tag&&(a=!1)}l.sibling.return=l.return,l=l.sibling}}function na(e,n){switch(n.tag){case 0:case 11:case 14:case 15:case 22:var t=n.updateQueue;if(null!==(t=null!==t?t.lastEffect:null)){var r=t=t.next;do{3==(3&r.tag)&&(n=r.destroy,r.destroy=void 0,void 0!==n&&n()),r=r.next}while(r!==t)}return;case 1:return;case 5:if(null!=(t=n.stateNode)){r=n.memoizedProps,e=null!==e?e.memoizedProps:r;var l=n.updateQueue;n.updateQueue=null,null!==l&&(n=t.viewConfig,Ee.set(t._nativeTag,r),null!=(r=hn(null,e,r,n.validAttributes))&&o.UIManager.updateView(t._nativeTag,n.uiViewClassName,r))}return;case 6:if(null===n.stateNode)throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");return void o.UIManager.updateView(n.stateNode,"RCTRawText",{text:n.memoizedProps});case 3:case 12:return;case 13:return null!==n.memoizedState&&(wa=Et(),ql(n.child,!0)),void ta(n);case 19:return void ta(n);case 17:return;case 23:case 24:return void ql(n,null!==n.memoizedState)}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ta(e){var n=e.updateQueue;if(null!==n){e.updateQueue=null;var t=e.stateNode;null===t&&(t=e.stateNode=new Hl),n.forEach(function(n){var r=hi.bind(null,e,n);t.has(n)||(t.add(n),n.then(r,r))})}}function ra(e,n){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(n=n.memoizedState)&&null===n.dehydrated)}var la,aa=Math.ceil,ia=Ie.ReactCurrentDispatcher,ua=Ie.ReactCurrentOwner,oa=0,sa=null,ca=null,fa=0,da=0,pa=Nn(0),ha=0,ga=null,ma=0,va=0,ya=0,ba=0,Sa=null,wa=0,ka=1/0,Ea=null,Ta=!1,xa=null,_a=null,Ra=!1,Pa=null,Ca=90,Na=[],za=[],Ia=null,La=0,Ua=null,Ma=-1,Aa=0,Da=0,Qa=null,Ba=!1;function Fa(){return 0!=(48&oa)?Et():-1!==Ma?Ma:Ma=Et()}function ja(e){if(0==(2&(e=e.mode)))return 1;if(0==(4&e))return 99===Tt()?1:2;if(0===Aa&&(Aa=ma),0!==Nt.transition){0!==Da&&(Da=null!==Sa?Sa.pendingLanes:0),e=Aa;var n=4186112&~Da;return 0===(n&=-n)&&(0===(n=(e=4186112&~e)&-e)&&(n=8192)),n}return e=Tt(),0!=(4&oa)&&98===e?e=Jn(12,Aa):e=Jn(e=Xn(e),Aa),e}function Oa(e,n,t){if(50<La)throw La=0,Ua=null,Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");if(null===(e=Ha(e,n)))return null;nt(e,n,t),e===sa&&(ya|=n,4===ha&&Ya(e,fa));var r=Tt();1===n?0!=(8&oa)&&0==(48&oa)?qa(e):(Va(e,t),0===oa&&(ka=Et()+500,Pt())):(0==(4&oa)||98!==r&&99!==r||(null===Ia?Ia=new Set([e]):Ia.add(e)),Va(e,t)),Sa=e}function Ha(e,n){e.lanes|=n;var t=e.alternate;for(null!==t&&(t.lanes|=n),t=e,e=e.return;null!==e;)e.childLanes|=n,null!==(t=e.alternate)&&(t.childLanes|=n),t=e,e=e.return;return 3===t.tag?t.stateNode:null}function Va(e,n){for(var t=e.callbackNode,r=e.suspendedLanes,l=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var u=31-tt(i),o=1<<u,s=a[u];if(-1===s){if(0==(o&r)||0!=(o&l)){s=n,qn(o);var c=Yn;a[u]=10<=c?s+250:6<=c?s+5e3:-1}}else s<=n&&(e.expiredLanes|=o);i&=~o}if(r=Gn(e,e===sa?fa:0),n=Yn,0===r)null!==t&&(t!==vt&&ut(t),e.callbackNode=null,e.callbackPriority=0);else{if(null!==t){if(e.callbackPriority===n)return;t!==vt&&ut(t)}15===n?(t=qa.bind(null,e),null===bt?(bt=[t],St=it(dt,Ct)):bt.push(t),t=vt):14===n?t=Rt(99,qa.bind(null,e)):t=Rt(t=$n(n),Wa.bind(null,e)),e.callbackPriority=n,e.callbackNode=t}}function Wa(e){if(Ma=-1,Da=Aa=0,0!=(48&oa))throw Error("Should not already be working.");var n=e.callbackNode;if(ui()&&e.callbackNode!==n)return null;var t=Gn(e,e===sa?fa:0);if(0===t)return null;var r=t,l=oa;oa|=16;var a=Ja();for(sa===e&&fa===r||(ka=Et()+500,Ga(e,r));;)try{ni();break}catch(n){Ka(e,n)}if(jt(),ia.current=a,oa=l,null!==ca?r=0:(sa=null,fa=0,r=ha),0!=(ma&ya))Ga(e,0);else if(0!==r){if(2===r&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(t=Kn(e))&&(r=Za(e,t))),1===r)throw n=ga,Ga(e,0),Ya(e,t),Va(e,Et()),n;switch(e.finishedWork=e.current.alternate,e.finishedLanes=t,r){case 0:case 1:throw Error("Root did not complete. This is a bug in React.");case 2:li(e);break;case 3:if(Ya(e,t),(62914560&t)===t&&10<(r=wa+500-Et())){if(0!==Gn(e,0))break;if(((l=e.suspendedLanes)&t)!==t){Fa(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=Tn(li.bind(null,e),r);break}li(e);break;case 4:if(Ya(e,t),(4186112&t)===t)break;for(r=e.eventTimes,l=-1;0<t;){var i=31-tt(t);a=1<<i,(i=r[i])>l&&(l=i),t&=~a}if(t=l,10<(t=(120>(t=Et()-t)?120:480>t?480:1080>t?1080:1920>t?1920:3e3>t?3e3:4320>t?4320:1960*aa(t/1960))-t)){e.timeoutHandle=Tn(li.bind(null,e),t);break}li(e);break;case 5:li(e);break;default:throw Error("Unknown root exit status.")}}return Va(e,Et()),e.callbackNode===n?Wa.bind(null,e):null}function Ya(e,n){for(n&=~ba,n&=~ya,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var t=31-tt(n),r=1<<t;e[t]=-1,n&=~r}}function qa(e){if(0!=(48&oa))throw Error("Should not already be working.");if(ui(),e===sa&&0!=(e.expiredLanes&fa)){var n=fa,t=Za(e,n);0!=(ma&ya)&&(t=Za(e,n=Gn(e,n)))}else t=Za(e,n=Gn(e,0));if(0!==e.tag&&2===t&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(n=Kn(e))&&(t=Za(e,n))),1===t)throw t=ga,Ga(e,0),Ya(e,n),Va(e,Et()),t;return e.finishedWork=e.current.alternate,e.finishedLanes=n,li(e),Va(e,Et()),null}function Xa(e,n){In(pa,da),da|=n,ma|=n}function $a(){da=pa.current,zn(pa)}function Ga(e,n){e.finishedWork=null,e.finishedLanes=0;var t=e.timeoutHandle;if(-1!==t&&(e.timeoutHandle=-1,xn(t)),null!==ca)for(t=ca.return;null!==t;){var r=t;switch(r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&Bn();break;case 3:br(),zn(Mn),zn(Un),xr();break;case 5:wr(r);break;case 4:br();break;case 13:case 19:zn(kr);break;case 10:Ot(r);break;case 23:case 24:$a()}t=t.return}sa=e,ca=bi(e.current,null),fa=da=ma=n,ha=0,ga=null,ba=ya=va=0}function Ka(e,n){for(;;){var t=ca;try{if(jt(),_r.current=il,Ir){for(var r=Cr.memoizedState;null!==r;){var l=r.queue;null!==l&&(l.pending=null),r=r.next}Ir=!1}if(Pr=0,zr=Nr=Cr=null,Lr=!1,ua.current=null,null===t||null===t.return){ha=1,ga=n,ca=null;break}e:{var a=e,i=t.return,u=t,o=n;if(n=fa,u.flags|=4096,u.firstEffect=u.lastEffect=null,null!==o&&"object"==typeof o&&"function"==typeof o.then){var s=o;if(0==(2&u.mode)){var c=u.alternate;c?(u.updateQueue=c.updateQueue,u.memoizedState=c.memoizedState,u.lanes=c.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=0!=(1&kr.current),d=i;do{var p;if(p=13===d.tag){var h=d.memoizedState;if(null!==h)p=null!==h.dehydrated;else{var g=d.memoizedProps;p=void 0!==g.fallback&&(!0!==g.unstable_avoidThisFallback||!f)}}if(p){var m=d.updateQueue;if(null===m){var v=new Set;v.add(s),d.updateQueue=v}else m.add(s);if(0==(2&d.mode)){if(d.flags|=64,u.flags|=32768,u.flags&=-5029,1===u.tag)if(null===u.alternate)u.tag=17;else{var y=$t(-1,1);y.tag=2,Gt(u,y)}u.lanes|=1;break e}o=void 0,u=n;var b=a.pingCache;if(null===b?(b=a.pingCache=new Fl,o=new Set,b.set(s,o)):void 0===(o=b.get(s))&&(o=new Set,b.set(s,o)),!o.has(u)){o.add(u);var S=pi.bind(null,a,s,u);s.then(S,S)}d.flags|=8192,d.lanes=n;break e}d=d.return}while(null!==d);o=Error((Je(u.type)||"A React component")+" suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.")}5!==ha&&(ha=2),o=Ql(o,u),d=i;do{switch(d.tag){case 3:a=o,d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,jl(d,a,n));break e;case 1:a=o;var w=d.type,k=d.stateNode;if(0==(64&d.flags)&&("function"==typeof w.getDerivedStateFromError||null!==k&&"function"==typeof k.componentDidCatch&&(null===_a||!_a.has(k)))){d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,Ol(d,a,n));break e}}d=d.return}while(null!==d)}ri(t)}catch(e){n=e,ca===t&&null!==t&&(ca=t=t.return);continue}break}}function Ja(){var e=ia.current;return ia.current=il,null===e?il:e}function Za(e,n){var t=oa;oa|=16;var r=Ja();for(sa===e&&fa===n||Ga(e,n);;)try{ei();break}catch(n){Ka(e,n)}if(jt(),oa=t,ia.current=r,null!==ca)throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");return sa=null,fa=0,ha}function ei(){for(;null!==ca;)ti(ca)}function ni(){for(;null!==ca&&!ot();)ti(ca)}function ti(e){var n=la(e.alternate,e,da);e.memoizedProps=e.pendingProps,null===n?ri(e):ca=n,ua.current=null}function ri(e){var n=e;do{var t=n.alternate;if(e=n.return,0==(4096&n.flags)){if(null!==(t=Al(t,n,da)))return void(ca=t);if(24!==(t=n).tag&&23!==t.tag||null===t.memoizedState||0!=(1073741824&da)||0==(4&t.mode)){for(var r=0,l=t.child;null!==l;)r|=l.lanes|l.childLanes,l=l.sibling;t.childLanes=r}null!==e&&0==(4096&e.flags)&&(null===e.firstEffect&&(e.firstEffect=n.firstEffect),null!==n.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=n.firstEffect),e.lastEffect=n.lastEffect),1<n.flags&&(null!==e.lastEffect?e.lastEffect.nextEffect=n:e.firstEffect=n,e.lastEffect=n))}else{if(null!==(t=Dl(n)))return t.flags&=4095,void(ca=t);null!==e&&(e.firstEffect=e.lastEffect=null,e.flags|=4096)}if(null!==(n=n.sibling))return void(ca=n);ca=n=e}while(null!==n);0===ha&&(ha=5)}function li(e){var n=Tt();return _t(99,ai.bind(null,e,n)),null}function ai(e,n){do{ui()}while(null!==Pa);if(0!=(48&oa))throw Error("Should not already be working.");var t=e.finishedWork;if(null===t)return null;if(e.finishedWork=null,e.finishedLanes=0,t===e.current)throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");e.callbackNode=null;var r=t.lanes|t.childLanes,l=r,a=e.pendingLanes&~l;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=l,e.mutableReadLanes&=l,e.entangledLanes&=l,l=e.entanglements;for(var i=e.eventTimes,u=e.expirationTimes;0<a;){var o=31-tt(a),s=1<<o;l[o]=0,i[o]=-1,u[o]=-1,a&=~s}if(null!==Ia&&0==(24&r)&&Ia.has(e)&&Ia.delete(e),e===sa&&(ca=sa=null,fa=0),1<t.flags?null!==t.lastEffect?(t.lastEffect.nextEffect=t,r=t.firstEffect):r=t:r=t.firstEffect,null!==r){l=oa,oa|=32,Qa=ua.current=null,Ba=!1,Ea=r;do{try{ii()}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Qa=null,Ea=r;do{try{for(i=e;null!==Ea;){var c=Ea.flags;if(128&c){var f=Ea.alternate;if(null!==f){var d=f.ref;null!==d&&("function"==typeof d?d(null):d.current=null)}}switch(1038&c){case 2:Kl(Ea),Ea.flags&=-3;break;case 6:Kl(Ea),Ea.flags&=-3,na(Ea.alternate,Ea);break;case 1024:Ea.flags&=-1025;break;case 1028:Ea.flags&=-1025,na(Ea.alternate,Ea);break;case 4:na(Ea.alternate,Ea);break;case 8:ea(i,u=Ea);var p=u.alternate;$l(u),null!==p&&$l(p)}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);e.current=t,Ea=r;do{try{for(c=e;null!==Ea;){var h=Ea.flags;if(36&h&&Yl(c,Ea.alternate,Ea),128&h){f=void 0;var g=Ea.ref;if(null!==g){var m=Ea.stateNode;switch(Ea.tag){case 5:f=m;break;default:f=m}"function"==typeof g?g(f):g.current=f}}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Ea=null,yt(),oa=l}else e.current=t;if(Ra)Ra=!1,Pa=e,Ca=n;else for(Ea=r;null!==Ea;)n=Ea.nextEffect,Ea.nextEffect=null,8&Ea.flags&&((h=Ea).sibling=null,h.stateNode=null),Ea=n;if(0===(r=e.pendingLanes)&&(_a=null),1===r?e===Ua?La++:(La=0,Ua=e):La=0,t=t.stateNode,Wn&&"function"==typeof Wn.onCommitFiberRoot)try{Wn.onCommitFiberRoot(Vn,t,void 0,64==(64&t.current.flags))}catch(e){}if(Va(e,Et()),Ta)throw Ta=!1,e=xa,xa=null,e;return 0!=(8&oa)?null:(Pt(),null)}function ii(){for(;null!==Ea;){var e=Ea.alternate;Ba||null===Qa||(0!=(8&Ea.flags)?rn(Ea,Qa)&&(Ba=!0):13===Ea.tag&&ra(e,Ea)&&rn(Ea,Qa)&&(Ba=!0));var n=Ea.flags;0!=(256&n)&&Wl(e,Ea),0==(512&n)||Ra||(Ra=!0,Rt(97,function(){return ui(),null})),Ea=Ea.nextEffect}}function ui(){if(90!==Ca){var e=97<Ca?97:Ca;return Ca=90,_t(e,ci)}return!1}function oi(e,n){Na.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function si(e,n){za.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function ci(){if(null===Pa)return!1;var e=Pa;if(Pa=null,0!=(48&oa))throw Error("Cannot flush passive effects while already rendering.");var n=oa;oa|=32;var t=za;za=[];for(var r=0;r<t.length;r+=2){var l=t[r],a=t[r+1],i=l.destroy;if(l.destroy=void 0,"function"==typeof i)try{i()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(t=Na,Na=[],r=0;r<t.length;r+=2){l=t[r],a=t[r+1];try{var u=l.create;l.destroy=u()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(u=e.current.firstEffect;null!==u;)e=u.nextEffect,u.nextEffect=null,8&u.flags&&(u.sibling=null,u.stateNode=null),u=e;return oa=n,Pt(),!0}function fi(e,n,t){Gt(e,n=jl(e,n=Ql(t,n),1)),n=Fa(),null!==(e=Ha(e,1))&&(nt(e,1,n),Va(e,n))}function di(e,n){if(3===e.tag)fi(e,e,n);else for(var t=e.return;null!==t;){if(3===t.tag){fi(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r))){var l=Ol(t,e=Ql(n,e),1);if(Gt(t,l),l=Fa(),null!==(t=Ha(t,1)))nt(t,1,l),Va(t,l);else if("function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r)))try{r.componentDidCatch(n,e)}catch(e){}break}}t=t.return}}function pi(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),n=Fa(),e.pingedLanes|=e.suspendedLanes&t,sa===e&&(fa&t)===t&&(4===ha||3===ha&&(62914560&fa)===fa&&500>Et()-wa?Ga(e,0):ba|=t),Va(e,n)}function hi(e,n){var t=e.stateNode;null!==t&&t.delete(n),0===(n=0)&&(0==(2&(n=e.mode))?n=1:0==(4&n)?n=99===Tt()?1:2:(0===Aa&&(Aa=ma),0===(n=Zn(62914560&~Aa))&&(n=4194304))),t=Fa(),null!==(e=Ha(e,n))&&(nt(e,n,t),Va(e,t))}function gi(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.flags=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childLanes=this.lanes=0,this.alternate=null}function mi(e,n,t,r){return new gi(e,n,t,r)}function vi(e){return!(!(e=e.prototype)||!e.isReactComponent)}function yi(e){if("function"==typeof e)return vi(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===Fe)return 11;if(e===He)return 14}return 2}function bi(e,n){var t=e.alternate;return null===t?((t=mi(e.tag,n,e.key,e.mode)).elementType=e.elementType,t.type=e.type,t.stateNode=e.stateNode,t.alternate=e,e.alternate=t):(t.pendingProps=n,t.type=e.type,t.flags=0,t.nextEffect=null,t.firstEffect=null,t.lastEffect=null),t.childLanes=e.childLanes,t.lanes=e.lanes,t.child=e.child,t.memoizedProps=e.memoizedProps,t.memoizedState=e.memoizedState,t.updateQueue=e.updateQueue,n=e.dependencies,t.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},t.sibling=e.sibling,t.index=e.index,t.ref=e.ref,t}function Si(e,n,t,r,l,a){var i=2;if(r=e,"function"==typeof e)vi(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case Me:return wi(t.children,l,a,n);case Ye:i=8,l|=16;break;case Ae:i=8,l|=1;break;case De:return(e=mi(12,t,n,8|l)).elementType=De,e.type=De,e.lanes=a,e;case je:return(e=mi(13,t,n,l)).type=je,e.elementType=je,e.lanes=a,e;case Oe:return(e=mi(19,t,n,l)).elementType=Oe,e.lanes=a,e;case qe:return ki(t,l,a,n);case Xe:return(e=mi(24,t,n,l)).elementType=Xe,e.lanes=a,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case Qe:i=10;break e;case Be:i=9;break e;case Fe:i=11;break e;case He:i=14;break e;case Ve:i=16,r=null;break e;case We:i=22;break e}throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+(null==e?e:typeof e)+".")}return(n=mi(i,t,n,l)).elementType=e,n.type=r,n.lanes=a,n}function wi(e,n,t,r){return(e=mi(7,e,r,n)).lanes=t,e}function ki(e,n,t,r){return(e=mi(23,e,r,n)).elementType=qe,e.lanes=t,e}function Ei(e,n,t){return(e=mi(6,e,null,n)).lanes=t,e}function Ti(e,n,t){return(n=mi(4,null!==e.children?e.children:[],e.key,n)).lanes=t,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function xi(e,n,t){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=t,this.callbackNode=null,this.callbackPriority=0,this.eventTimes=et(0),this.expirationTimes=et(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0)}function _i(e,n,t){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:Ue,key:null==r?null:""+r,children:e,containerInfo:n,implementation:t}}function Ri(e){var n=e._reactInternals;if(void 0===n){if("function"==typeof e.render)throw Error("Unable to find node on an unmounted component.");throw Error("Argument appears to not be a ReactComponent. Keys: "+Object.keys(e))}return null===(e=tn(n))?null:e.stateNode}function Pi(e,n,t,r){var l=n.current,a=Fa(),i=ja(l);e:if(t){t=t._reactInternals;n:{if(Ze(t)!==t||1!==t.tag)throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");var u=t;do{switch(u.tag){case 3:u=u.stateNode.context;break n;case 1:if(Qn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break n}}u=u.return}while(null!==u);throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.")}if(1===t.tag){var o=t.type;if(Qn(o)){t=jn(t,o,u);break e}}t=u}else t=Ln;return null===n.context?n.context=t:n.pendingContext=t,(n=$t(a,i)).payload={element:e},null!==(r=void 0===r?null:r)&&(n.callback=r),Gt(l,n),Oa(l,i,a),i}function Ci(e){return null==e?null:"number"==typeof e?e:e._nativeTag?e._nativeTag:e.canonical&&e.canonical._nativeTag?e.canonical._nativeTag:null==(e=Ri(e))?e:e.canonical?e.canonical._nativeTag:e._nativeTag}function Ni(e){var n=zi.get(e);n&&Pi(null,n,null,function(){zi.delete(e)})}la=function(e,n,t){var r=n.lanes;if(null!==e)if(e.memoizedProps!==n.pendingProps||Mn.current)fl=!0;else{if(0==(t&r)){switch(fl=!1,n.tag){case 3:wl(n);break;case 5:Sr(n);break;case 1:Qn(n.type)&&On(n);break;case 4:yr(n,n.stateNode.containerInfo);break;case 10:r=n.memoizedProps.value;var l=n.type._context;In(Dt,l._currentValue),l._currentValue=r;break;case 13:if(null!==n.memoizedState)return 0!=(t&n.child.childLanes)?Rl(e,n,t):(In(kr,1&kr.current),null!==(n=Ul(e,n,t))?n.sibling:null);In(kr,1&kr.current);break;case 19:if(r=0!=(t&n.childLanes),0!=(64&e.flags)){if(r)return Ll(e,n,t);n.flags|=64}if(null!==(l=n.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),In(kr,kr.current),r)break;return null;case 23:case 24:return n.lanes=0,ml(e,n,t)}return Ul(e,n,t)}fl=0!=(32768&e.flags)}else fl=!1;switch(n.lanes=0,n.tag){case 2:if(r=n.type,null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=Dn(n,Un.current),Vt(n,t),l=Ar(null,n,r,e,l,t),n.flags|=1,"object"==typeof l&&null!==l&&"function"==typeof l.render&&void 0===l.$$typeof){if(n.tag=1,n.memoizedState=null,n.updateQueue=null,Qn(r)){var a=!0;On(n)}else a=!1;n.memoizedState=null!==l.state&&void 0!==l.state?l.state:null,qt(n);var i=r.getDerivedStateFromProps;"function"==typeof i&&nr(n,r,i,e),l.updater=tr,n.stateNode=l,l._reactInternals=n,ir(n,r,e,t),n=Sl(null,n,r,!0,a,t)}else n.tag=0,dl(null,n,l,t),n=n.child;return n;case 16:l=n.elementType;e:{switch(null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=(a=l._init)(l._payload),n.type=l,a=n.tag=yi(l),e=At(l,e),a){case 0:n=yl(null,n,l,e,t);break e;case 1:n=bl(null,n,l,e,t);break e;case 11:n=pl(null,n,l,e,t);break e;case 14:n=hl(null,n,l,At(l.type,e),r,t);break e}throw Error("Element type is invalid. Received a promise that resolves to: "+l+". Lazy element type must resolve to a class or function.")}return n;case 0:return r=n.type,l=n.pendingProps,yl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 1:return r=n.type,l=n.pendingProps,bl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 3:if(wl(n),r=n.updateQueue,null===e||null===r)throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");return r=n.pendingProps,l=null!==(l=n.memoizedState)?l.element:null,Xt(e,n),Jt(n,r,null,t),(r=n.memoizedState.element)===l?n=Ul(e,n,t):(dl(e,n,r,t),n=n.child),n;case 5:return Sr(n),r=n.pendingProps.children,vl(e,n),dl(e,n,r,t),n.child;case 6:return null;case 13:return Rl(e,n,t);case 4:return yr(n,n.stateNode.containerInfo),r=n.pendingProps,null===e?n.child=fr(n,null,r,t):dl(e,n,r,t),n.child;case 11:return r=n.type,l=n.pendingProps,pl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 7:return dl(e,n,n.pendingProps,t),n.child;case 8:case 12:return dl(e,n,n.pendingProps.children,t),n.child;case 10:e:{r=n.type._context,l=n.pendingProps,i=n.memoizedProps,a=l.value;var u=n.type._context;if(In(Dt,u._currentValue),u._currentValue=a,null!==i)if(u=i.value,0===(a=zt(u,a)?0:0|("function"==typeof r._calculateChangedBits?r._calculateChangedBits(u,a):1073741823))){if(i.children===l.children&&!Mn.current){n=Ul(e,n,t);break e}}else for(null!==(u=n.child)&&(u.return=n);null!==u;){var o=u.dependencies;if(null!==o){i=u.child;for(var s=o.firstContext;null!==s;){if(s.context===r&&0!=(s.observedBits&a)){1===u.tag&&((s=$t(-1,t&-t)).tag=2,Gt(u,s)),u.lanes|=t,null!==(s=u.alternate)&&(s.lanes|=t),Ht(u.return,t),o.lanes|=t;break}s=s.next}}else i=10===u.tag&&u.type===n.type?null:u.child;if(null!==i)i.return=u;else for(i=u;null!==i;){if(i===n){i=null;break}if(null!==(u=i.sibling)){u.return=i.return,i=u;break}i=i.return}u=i}dl(e,n,l.children,t),n=n.child}return n;case 9:return l=n.type,r=(a=n.pendingProps).children,Vt(n,t),r=r(l=Wt(l,a.unstable_observedBits)),n.flags|=1,dl(e,n,r,t),n.child;case 14:return a=At(l=n.type,n.pendingProps),hl(e,n,l,a=At(l.type,a),r,t);case 15:return gl(e,n,n.type,n.pendingProps,r,t);case 17:return r=n.type,l=n.pendingProps,l=n.elementType===r?l:At(r,l),null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),n.tag=1,Qn(r)?(e=!0,On(n)):e=!1,Vt(n,t),lr(n,r,l),ir(n,r,l,t),Sl(null,n,r,!0,e,t);case 19:return Ll(e,n,t);case 23:case 24:return ml(e,n,t)}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")},xe=function(e,n){var t=oa;oa|=1;try{return e(n)}finally{0===(oa=t)&&(ka=Et()+500,Pt())}};var zi=new Map,Ii={findFiberByHostInstance:Te,bundleType:0,version:"17.0.1-4e5d7faf5",rendererPackageName:"react-native-renderer",rendererConfig:{getInspectorDataForViewTag:function(){throw Error("getInspectorDataForViewTag() is not available in production")},getInspectorDataForViewAtPoint:function(){throw Error("getInspectorDataForViewAtPoint() is not available in production.")}.bind(null,Ci)}},Li={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ie.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=tn(e))?null:e.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Ui=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ui.isDisabled&&Ui.supportsFiber)try{Vn=Ui.inject(Li),Wn=Ui}catch(e){}}a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED={computeComponentStackForErrorReporting:function(e){return(e=Te(e))?Mt(e):""}},a.createPortal=function(e,n){return _i(e,n,null,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},a.dispatchCommand=function(e,n,t){null!=e._nativeTag&&(e._internalInstanceHandle?nativeFabricUIManager.dispatchCommand(e._internalInstanceHandle.stateNode.node,n,t):o.UIManager.dispatchViewManagerCommand(e._nativeTag,n,t))},a.findHostInstance_DEPRECATED=function(e){return null==e?null:e._nativeTag?e:e.canonical&&e.canonical._nativeTag?e.canonical:null==(e=Ri(e))?e:e.canonical?e.canonical:e},a.findNodeHandle=Ci,a.render=function(e,n,t){var r=zi.get(n);if(!r){r=new xi(n,0,!1);var l=mi(3,null,null,0);r.current=l,l.stateNode=r,qt(l),zi.set(n,r)}Pi(e,r,null,t);e:if(e=r.current,e.child)switch(e.child.tag){case 5:e=e.child.stateNode;break e;default:e=e.child.stateNode}else e=null;return e},a.unmountComponentAtNode=Ni,a.unmountComponentAtNodeAndRemoveContainer=function(e){Ni(e),o.UIManager.removeRootView(e)},a.unstable_batchedUpdates=Re},88,[6,89,160,14,184]);^~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:94:93824: warning: the variable "__REACT_DEVTOOLS_GLOBAL_HOOK__" was not declared in anonymous function " 246#"__d(function(e,n,t,r,l,a,i){"use strict";var u=n(i[0]);n(i[1]);var o=n(i[2]),s=n(i[3]),c=n(i[4]);function f(e,n,t,r,l,a,i,u,o){var s=Array.prototype.slice.call(arguments,3);try{n.apply(t,s)}catch(e){this.onError(e)}}var d=!1,p=null,h=!1,g=null,m={onError:function(e){d=!0,p=e}};function v(e,n,t,r,l,a,i,u,o){d=!1,p=null,f.apply(m,arguments)}function y(e,n,t,r,l,a,i,u,o){if(v.apply(this,arguments),d){if(!d)throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");var s=p;d=!1,p=null,h||(h=!0,g=s)}}var b=null,S=null,w=null;function k(e,n,t){var r=e.type||"unknown-event";e.currentTarget=w(t),y(r,n,void 0,e),e.currentTarget=null}function E(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))throw Error("executeDirectDispatch(...): Invalid `event`.");return e.currentTarget=n?w(t):null,n=n?n(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,n}function T(){return!0}function x(){return!1}function _(e,n,t,r){for(var l in this.dispatchConfig=e,this._targetInst=n,this.nativeEvent=t,this._dispatchInstances=this._dispatchListeners=null,e=this.constructor.Interface)e.hasOwnProperty(l)&&((n=e[l])?this[l]=n(t):"target"===l?this.target=r:this[l]=t[l]);return this.isDefaultPrevented=(null!=t.defaultPrevented?t.defaultPrevented:!1===t.returnValue)?T:x,this.isPropagationStopped=x,this}function R(e,n,t,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,n,t,r),l}return new this(e,n,t,r)}function P(e){if(!(e instanceof this))throw Error("Trying to release an event instance into a pool of a different type.");e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function C(e){e.getPooled=R,e.eventPool=[],e.release=P}u(_.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=T)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=T)},persist:function(){this.isPersistent=T},isPersistent:x,destructor:function(){var e,n=this.constructor.Interface;for(e in n)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=x,this._dispatchInstances=this._dispatchListeners=null}}),_.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},_.extend=function(e){function n(){}function t(){return r.apply(this,arguments)}var r=this;n.prototype=r.prototype;var l=new n;return u(l,t.prototype),t.prototype=l,t.prototype.constructor=t,t.Interface=u({},r.Interface,e),t.extend=r.extend,C(t),t},C(_);var N=_.extend({touchHistory:function(){return null}});function z(e){return"topTouchStart"===e}function I(e){return"topTouchMove"===e}var L=["topTouchStart"],U=["topTouchMove"],M=["topTouchCancel","topTouchEnd"],A=[],D={touchBank:A,numberActiveTouches:0,indexOfSingleActiveTouch:-1,mostRecentTimeStamp:0};function Q(e){return e.timeStamp||e.timestamp}function B(e){if(null==(e=e.identifier))throw Error("Touch object is missing identifier.");return e}function F(e){var n=B(e),t=A[n];t?(t.touchActive=!0,t.startPageX=e.pageX,t.startPageY=e.pageY,t.startTimeStamp=Q(e),t.currentPageX=e.pageX,t.currentPageY=e.pageY,t.currentTimeStamp=Q(e),t.previousPageX=e.pageX,t.previousPageY=e.pageY,t.previousTimeStamp=Q(e)):(t={touchActive:!0,startPageX:e.pageX,startPageY:e.pageY,startTimeStamp:Q(e),currentPageX:e.pageX,currentPageY:e.pageY,currentTimeStamp:Q(e),previousPageX:e.pageX,previousPageY:e.pageY,previousTimeStamp:Q(e)},A[n]=t),D.mostRecentTimeStamp=Q(e)}function j(e){var n=A[B(e)];n&&(n.touchActive=!0,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}function O(e){var n=A[B(e)];n&&(n.touchActive=!1,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}var H={recordTouchTrack:function(e,n){if(I(e))n.changedTouches.forEach(j);else if(z(e))n.changedTouches.forEach(F),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches&&(D.indexOfSingleActiveTouch=n.touches[0].identifier);else if(("topTouchEnd"===e||"topTouchCancel"===e)&&(n.changedTouches.forEach(O),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches))for(e=0;e<A.length;e++)if(null!=(n=A[e])&&n.touchActive){D.indexOfSingleActiveTouch=e;break}},touchHistory:D};function V(e,n){if(null==n)throw Error("accumulate(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?e.concat(n):Array.isArray(n)?[e].concat(n):[e,n]}function W(e,n){if(null==n)throw Error("accumulateInto(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?Array.isArray(n)?(e.push.apply(e,n),e):(e.push(n),e):Array.isArray(n)?[e].concat(n):[e,n]}function Y(e,n,t){Array.isArray(e)?e.forEach(n,t):e&&n.call(t,e)}var q=null,X=0;function $(e,n){var t=q;q=e,null!==le.GlobalResponderHandler&&le.GlobalResponderHandler.onChange(t,e,n)}var G={startShouldSetResponder:{phasedRegistrationNames:{bubbled:"onStartShouldSetResponder",captured:"onStartShouldSetResponderCapture"},dependencies:L},scrollShouldSetResponder:{phasedRegistrationNames:{bubbled:"onScrollShouldSetResponder",captured:"onScrollShouldSetResponderCapture"},dependencies:["topScroll"]},selectionChangeShouldSetResponder:{phasedRegistrationNames:{bubbled:"onSelectionChangeShouldSetResponder",captured:"onSelectionChangeShouldSetResponderCapture"},dependencies:["topSelectionChange"]},moveShouldSetResponder:{phasedRegistrationNames:{bubbled:"onMoveShouldSetResponder",captured:"onMoveShouldSetResponderCapture"},dependencies:U},responderStart:{registrationName:"onResponderStart",dependencies:L},responderMove:{registrationName:"onResponderMove",dependencies:U},responderEnd:{registrationName:"onResponderEnd",dependencies:M},responderRelease:{registrationName:"onResponderRelease",dependencies:M},responderTerminationRequest:{registrationName:"onResponderTerminationRequest",dependencies:[]},responderGrant:{registrationName:"onResponderGrant",dependencies:[]},responderReject:{registrationName:"onResponderReject",dependencies:[]},responderTerminate:{registrationName:"onResponderTerminate",dependencies:[]}};function K(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function J(e,n,t){for(var r=[];e;)r.push(e),e=K(e);for(e=r.length;0<e--;)n(r[e],"captured",t);for(e=0;e<r.length;e++)n(r[e],"bubbled",t)}function Z(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}function ee(e,n,t){(n=Z(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function ne(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=Z(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}function te(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var n=e._targetInst;J(n=n?K(n):null,ee,e)}}function re(e){e&&e.dispatchConfig.phasedRegistrationNames&&J(e._targetInst,ee,e)}var le={_getResponder:function(){return q},eventTypes:G,extractEvents:function(e,n,t,r){if(z(e))X+=1;else if("topTouchEnd"===e||"topTouchCancel"===e){if(!(0<=X))return null;--X}if(H.recordTouchTrack(e,t),n&&("topScroll"===e&&!t.responderIgnoreScroll||0<X&&"topSelectionChange"===e||z(e)||I(e))){var l=z(e)?G.startShouldSetResponder:I(e)?G.moveShouldSetResponder:"topSelectionChange"===e?G.selectionChangeShouldSetResponder:G.scrollShouldSetResponder;if(q)e:{for(var a=q,i=0,u=a;u;u=K(u))i++;u=0;for(var o=n;o;o=K(o))u++;for(;0<i-u;)a=K(a),i--;for(;0<u-i;)n=K(n),u--;for(;i--;){if(a===n||a===n.alternate)break e;a=K(a),n=K(n)}a=null}else a=n;a=(n=a)===q,(l=N.getPooled(l,n,t,r)).touchHistory=H.touchHistory,Y(l,a?te:re);e:{if(a=l._dispatchListeners,n=l._dispatchInstances,Array.isArray(a)){for(i=0;i<a.length&&!l.isPropagationStopped();i++)if(a[i](l,n[i])){a=n[i];break e}}else if(a&&a(l,n)){a=n;break e}a=null}if(l._dispatchInstances=null,l._dispatchListeners=null,l.isPersistent()||l.constructor.release(l),a&&a!==q)if((l=N.getPooled(G.responderGrant,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),n=!0===E(l),q)if((i=N.getPooled(G.responderTerminationRequest,q,t,r)).touchHistory=H.touchHistory,Y(i,ne),u=!i._dispatchListeners||E(i),i.isPersistent()||i.constructor.release(i),u){(i=N.getPooled(G.responderTerminate,q,t,r)).touchHistory=H.touchHistory,Y(i,ne);var s=V(s,[l,i]);$(a,n)}else(l=N.getPooled(G.responderReject,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l);else s=V(s,l),$(a,n);else s=null}else s=null;if(l=q&&z(e),a=q&&I(e),n=q&&("topTouchEnd"===e||"topTouchCancel"===e),(l=l?G.responderStart:a?G.responderMove:n?G.responderEnd:null)&&((l=N.getPooled(l,q,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l)),l=q&&"topTouchCancel"===e,e=q&&!l&&("topTouchEnd"===e||"topTouchCancel"===e))e:{if((e=t.touches)&&0!==e.length)for(a=0;a<e.length;a++)if(null!==(n=e[a].target)&&void 0!==n&&0!==n){i=S(n);n:{for(n=q;i;){if(n===i||n===i.alternate){n=!0;break n}i=K(i)}n=!1}if(n){e=!1;break e}}e=!0}return(e=l?G.responderTerminate:e?G.responderRelease:null)&&((t=N.getPooled(e,q,t,r)).touchHistory=H.touchHistory,Y(t,ne),s=V(s,t),$(null)),s},GlobalResponderHandler:null,injection:{injectGlobalResponderHandler:function(e){le.GlobalResponderHandler=e}}},ae=null,ie={};function ue(){if(ae)for(var e in ie){var n=ie[e],t=ae.indexOf(e);if(!(-1<t))throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `"+e+"`.");if(!se[t]){if(!n.extractEvents)throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `"+e+"` does not.");for(var r in se[t]=n,t=n.eventTypes){var l=void 0,a=t[r],i=r;if(ce.hasOwnProperty(i))throw Error("EventPluginRegistry: More than one plugin attempted to publish the same event name, `"+i+"`.");ce[i]=a;var u=a.phasedRegistrationNames;if(u){for(l in u)u.hasOwnProperty(l)&&oe(u[l],n);l=!0}else a.registrationName?(oe(a.registrationName,n),l=!0):l=!1;if(!l)throw Error("EventPluginRegistry: Failed to publish event `"+r+"` for plugin `"+e+"`.")}}}}function oe(e,n){if(fe[e])throw Error("EventPluginRegistry: More than one plugin attempted to publish the same registration name, `"+e+"`.");fe[e]=n}var se=[],ce={},fe={};function de(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}var pe=o.ReactNativeViewConfigRegistry.customBubblingEventTypes,he=o.ReactNativeViewConfigRegistry.customDirectEventTypes;function ge(e,n,t){(n=de(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function me(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var n=e._targetInst,t=[];n;){t.push(n);do{n=n.return}while(n&&5!==n.tag);n=n||null}for(n=t.length;0<n--;)ge(t[n],"captured",e);for(n=0;n<t.length;n++)ge(t[n],"bubbled",e)}}function ve(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=de(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}if(ae)throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.");ae=Array.prototype.slice.call(["ResponderEventPlugin","ReactNativeBridgeEventPlugin"]),ue();var ye,be={ResponderEventPlugin:le,ReactNativeBridgeEventPlugin:{eventTypes:{},extractEvents:function(e,n,t,r){if(null==n)return null;var l=pe[e],a=he[e];if(!l&&!a)throw Error('Unsupported top level event type "'+e+'" dispatched');if(e=_.getPooled(l||a,n,t,r),l)Y(e,me);else{if(!a)return null;Y(e,ve)}return e}}},Se=!1;for(ye in be)if(be.hasOwnProperty(ye)){var we=be[ye];if(!ie.hasOwnProperty(ye)||ie[ye]!==we){if(ie[ye])throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `"+ye+"`.");ie[ye]=we,Se=!0}}Se&&ue();var ke=new Map,Ee=new Map;function Te(e){return ke.get(e)||null}function xe(e,n){return e(n)}var _e=!1;function Re(e,n){if(_e)return e(n);_e=!0;try{return xe(e,n)}finally{_e=!1}}var Pe=null;function Ce(e){if(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))for(var r=0;r<n.length&&!e.isPropagationStopped();r++)k(e,n[r],t[r]);else n&&k(e,n,t);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}var Ne={};function ze(e,n,t){var r=t||Ne,l=Te(e),a=null;null!=l&&(a=l.stateNode),Re(function(){for(var e=a,t=null,i=se,u=0;u<i.length;u++){var o=i[u];o&&(o=o.extractEvents(n,l,r,e))&&(t=W(t,o))}if(null!==(e=t)&&(Pe=W(Pe,e)),e=Pe,Pe=null,e){if(Y(e,Ce),Pe)throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.");if(h)throw e=g,h=!1,g=null,e}})}o.RCTEventEmitter.register({receiveEvent:function(e,n,t){ze(e,n,t)},receiveTouches:function(e,n,t){if("topTouchEnd"===e||"topTouchCancel"===e){for(var r=[],l=0;l<t.length;l++){var a=t[l];r.push(n[a]),n[a]=null}for(l=t=0;l<n.length;l++)null!==(a=n[l])&&(n[t++]=a);n.length=t}else for(r=[],l=0;l<t.length;l++)r.push(n[t[l]]);for(t=0;t<r.length;t++){(l=r[t]).changedTouches=r,l.touches=n,a=null;var i=l.target;null===i||void 0===i||1>i||(a=i),ze(a,e,l)}}}),b=function(e){return Ee.get(e._nativeTag)||null},S=Te,w=function(e){var n=(e=e.stateNode)._nativeTag;if(void 0===n&&(n=(e=e.canonical)._nativeTag),!n)throw Error("All native instances should have a tag.");return e},le.injection.injectGlobalResponderHandler({onChange:function(e,n,t){null!==n?o.UIManager.setJSResponder(n.stateNode._nativeTag,t):o.UIManager.clearJSResponder()}});var Ie=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Le=60103,Ue=60106,Me=60107,Ae=60108,De=60114,Qe=60109,Be=60110,Fe=60112,je=60113,Oe=60120,He=60115,Ve=60116,We=60121,Ye=60129,qe=60130,Xe=60131;if("function"==typeof Symbol&&Symbol.for){var $e=Symbol.for;Le=$e("react.element"),Ue=$e("react.portal"),Me=$e("react.fragment"),Ae=$e("react.strict_mode"),De=$e("react.profiler"),Qe=$e("react.provider"),Be=$e("react.context"),Fe=$e("react.forward_ref"),je=$e("react.suspense"),Oe=$e("react.suspense_list"),He=$e("react.memo"),Ve=$e("react.lazy"),We=$e("react.block"),$e("react.scope"),Ye=$e("react.debug_trace_mode"),qe=$e("react.offscreen"),Xe=$e("react.legacy_hidden")}var Ge="function"==typeof Symbol&&Symbol.iterator;function Ke(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=Ge&&e[Ge]||e["@@iterator"])?e:null}function Je(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case Me:return"Fragment";case Ue:return"Portal";case De:return"Profiler";case Ae:return"StrictMode";case je:return"Suspense";case Oe:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case Be:return(e.displayName||"Context")+".Consumer";case Qe:return(e._context.displayName||"Context")+".Provider";case Fe:var n=e.render;return n=n.displayName||n.name||"",e.displayName||(""!==n?"ForwardRef("+n+")":"ForwardRef");case He:return Je(e.type);case We:return Je(e._render);case Ve:n=e._payload,e=e._init;try{return Je(e(n))}catch(e){}}return null}function Ze(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do{0!=(1026&(n=e).flags)&&(t=n.return),e=n.return}while(e)}return 3===n.tag?t:null}function en(e){if(Ze(e)!==e)throw Error("Unable to find node on an unmounted component.")}function nn(e){var n=e.alternate;if(!n){if(null===(n=Ze(e)))throw Error("Unable to find node on an unmounted component.");return n!==e?null:e}for(var t=e,r=n;;){var l=t.return;if(null===l)break;var a=l.alternate;if(null===a){if(null!==(r=l.return)){t=r;continue}break}if(l.child===a.child){for(a=l.child;a;){if(a===t)return en(l),e;if(a===r)return en(l),n;a=a.sibling}throw Error("Unable to find node on an unmounted component.")}if(t.return!==r.return)t=l,r=a;else{for(var i=!1,u=l.child;u;){if(u===t){i=!0,t=l,r=a;break}if(u===r){i=!0,r=l,t=a;break}u=u.sibling}if(!i){for(u=a.child;u;){if(u===t){i=!0,t=a,r=l;break}if(u===r){i=!0,r=a,t=l;break}u=u.sibling}if(!i)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(t.alternate!==r)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(3!==t.tag)throw Error("Unable to find node on an unmounted component.");return t.stateNode.current===t?e:n}function tn(e){if(!(e=nn(e)))return null;for(var n=e;;){if(5===n.tag||6===n.tag)return n;if(n.child)n.child.return=n,n=n.child;else{if(n===e)break;for(;!n.sibling;){if(!n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}}return null}function rn(e,n){for(var t=e.alternate;null!==n;){if(n===e||n===t)return!0;n=n.return}return!1}var ln={},an=null,un=0,on={unsafelyIgnoreFunctions:!0};function sn(e,n){return"object"!=typeof n||null===n||o.deepDiffer(e,n,on)}function cn(e,n,t){if(Array.isArray(n))for(var r=n.length;r--&&0<un;)cn(e,n[r],t);else if(n&&0<un)for(r in an)if(an[r]){var l=n[r];if(void 0!==l){var a=t[r];a&&("function"==typeof l&&(l=!0),void 0===l&&(l=null),"object"!=typeof a?e[r]=l:"function"!=typeof a.diff&&"function"!=typeof a.process||(l="function"==typeof a.process?a.process(l):l,e[r]=l),an[r]=!1,un--)}}}function fn(e,n,t,r){if(!e&&n===t)return e;if(!n||!t)return t?dn(e,t,r):n?pn(e,n,r):e;if(!Array.isArray(n)&&!Array.isArray(t))return hn(e,n,t,r);if(Array.isArray(n)&&Array.isArray(t)){var l,a=n.length<t.length?n.length:t.length;for(l=0;l<a;l++)e=fn(e,n[l],t[l],r);for(;l<n.length;l++)e=pn(e,n[l],r);for(;l<t.length;l++)e=dn(e,t[l],r);return e}return Array.isArray(n)?hn(e,o.flattenStyle(n),t,r):hn(e,n,o.flattenStyle(t),r)}function dn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,ln,n,t);for(var r=0;r<n.length;r++)e=dn(e,n[r],t);return e}function pn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,n,ln,t);for(var r=0;r<n.length;r++)e=pn(e,n[r],t);return e}function hn(e,n,t,r){var l,a;for(a in t)if(l=r[a]){var i=n[a],u=t[a];"function"==typeof u&&(u=!0,"function"==typeof i&&(i=!0)),void 0===u&&(u=null,void 0===i&&(i=null)),an&&(an[a]=!1),e&&void 0!==e[a]?"object"!=typeof l?e[a]=u:"function"!=typeof l.diff&&"function"!=typeof l.process||(l="function"==typeof l.process?l.process(u):u,e[a]=l):i!==u&&("object"!=typeof l?sn(i,u)&&((e||(e={}))[a]=u):"function"==typeof l.diff||"function"==typeof l.process?(void 0===i||("function"==typeof l.diff?l.diff(i,u):sn(i,u)))&&(l="function"==typeof l.process?l.process(u):u,(e||(e={}))[a]=l):(an=null,un=0,e=fn(e,i,u,l),0<un&&e&&(cn(e,u,l),an=null)))}for(var o in n)void 0===t[o]&&(!(l=r[o])||e&&void 0!==e[o]||void 0!==(i=n[o])&&("object"!=typeof l||"function"==typeof l.diff||"function"==typeof l.process?((e||(e={}))[o]=null,an||(an={}),an[o]||(an[o]=!0,un++)):e=pn(e,i,l)));return e}function gn(e,n){return function(){if(n&&("boolean"!=typeof e.__isMounted||e.__isMounted))return n.apply(e,arguments)}}var mn=(function(){function e(e,n){this._nativeTag=e,this._children=[],this.viewConfig=n}var n=e.prototype;return n.blur=function(){o.TextInputState.blurTextInput(this)},n.focus=function(){o.TextInputState.focusTextInput(this)},n.measure=function(e){o.UIManager.measure(this._nativeTag,gn(this,e))},n.measureInWindow=function(e){o.UIManager.measureInWindow(this._nativeTag,gn(this,e))},n.measureLayout=function(e,n,t){if("number"==typeof e)var r=e;else e._nativeTag&&(r=e._nativeTag);null!=r&&o.UIManager.measureLayout(this._nativeTag,r,gn(this,t),gn(this,n))},n.setNativeProps=function(e){null!=(e=hn(null,ln,e,this.viewConfig.validAttributes))&&o.UIManager.updateView(this._nativeTag,this.viewConfig.uiViewClassName,e)},e})();function vn(){throw Error("The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.")}var yn=o.ReactNativeViewConfigRegistry.get,bn={},Sn=3;function wn(){var e=Sn;return 1==e%10&&(e+=2),Sn=e+2,e}function kn(e){if("number"==typeof e)ke.delete(e),Ee.delete(e);else{var n=e._nativeTag;ke.delete(n),Ee.delete(n),e._children.forEach(kn)}}function En(e){if(0===e._children.length)return!1;var n=e._children.map(function(e){return"number"==typeof e?e:e._nativeTag});return o.UIManager.setChildren(e._nativeTag,n),!1}var Tn=setTimeout,xn=clearTimeout;function _n(e,n,t){return n="",t&&(n=" (created by "+t+")"),"\n    in "+(e||"Unknown")+n}function Rn(e,n){return e?_n(e.displayName||e.name||null,n,null):""}var Pn=[],Cn=-1;function Nn(e){return{current:e}}function zn(e){0>Cn||(e.current=Pn[Cn],Pn[Cn]=null,Cn--)}function In(e,n){Pn[++Cn]=e.current,e.current=n}var Ln={},Un=Nn(Ln),Mn=Nn(!1),An=Ln;function Dn(e,n){var t=e.type.contextTypes;if(!t)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===n)return r.__reactInternalMemoizedMaskedChildContext;var l,a={};for(l in t)a[l]=n[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function Qn(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Bn(){zn(Mn),zn(Un)}function Fn(e,n,t){if(Un.current!==Ln)throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");In(Un,n),In(Mn,t)}function jn(e,n,t){var r=e.stateNode;if(e=n.childContextTypes,"function"!=typeof r.getChildContext)return t;for(var l in r=r.getChildContext())if(!(l in e))throw Error((Je(n)||"Unknown")+'.getChildContext(): key "'+l+'" is not defined in childContextTypes.');return u({},t,r)}function On(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,An=Un.current,In(Un,e),In(Mn,Mn.current),!0}function Hn(e,n,t){var r=e.stateNode;if(!r)throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");t?(e=jn(e,n,An),r.__reactInternalMemoizedMergedChildContext=e,zn(Mn),zn(Un),In(Un,e)):zn(Mn),In(Mn,t)}var Vn=null,Wn=null;(0,c.unstable_now)();var Yn=8;function qn(e){if(0!=(1&e))return Yn=15,1;if(0!=(2&e))return Yn=14,2;if(0!=(4&e))return Yn=13,4;var n=24&e;return 0!==n?(Yn=12,n):0!=(32&e)?(Yn=11,32):0!==(n=192&e)?(Yn=10,n):0!=(256&e)?(Yn=9,256):0!==(n=3584&e)?(Yn=8,n):0!=(4096&e)?(Yn=7,4096):0!==(n=4186112&e)?(Yn=6,n):0!==(n=62914560&e)?(Yn=5,n):67108864&e?(Yn=4,67108864):0!=(134217728&e)?(Yn=3,134217728):0!==(n=805306368&e)?(Yn=2,n):0!=(1073741824&e)?(Yn=1,1073741824):(Yn=8,e)}function Xn(e){switch(e){case 99:return 15;case 98:return 10;case 97:case 96:return 8;case 95:return 2;default:return 0}}function $n(e){switch(e){case 15:case 14:return 99;case 13:case 12:case 11:case 10:return 98;case 9:case 8:case 7:case 6:case 4:case 5:return 97;case 3:case 2:case 1:return 95;case 0:return 90;default:throw Error("Invalid update priority: "+e+". This is a bug in React.")}}function Gn(e,n){var t=e.pendingLanes;if(0===t)return Yn=0;var r=0,l=0,a=e.expiredLanes,i=e.suspendedLanes,u=e.pingedLanes;if(0!==a)r=a,l=Yn=15;else if(0!==(a=134217727&t)){var o=a&~i;0!==o?(r=qn(o),l=Yn):0!==(u&=a)&&(r=qn(u),l=Yn)}else 0!==(a=t&~i)?(r=qn(a),l=Yn):0!==u&&(r=qn(u),l=Yn);if(0===r)return 0;if(r=t&((0>(r=31-tt(r))?0:1<<r)<<1)-1,0!==n&&n!==r&&0==(n&i)){if(qn(n),l<=Yn)return n;Yn=l}if(0!==(n=e.entangledLanes))for(e=e.entanglements,n&=r;0<n;)l=1<<(t=31-tt(n)),r|=e[t],n&=~l;return r}function Kn(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function Jn(e,n){switch(e){case 15:return 1;case 14:return 2;case 12:return 0===(e=Zn(24&~n))?Jn(10,n):e;case 10:return 0===(e=Zn(192&~n))?Jn(8,n):e;case 8:return 0===(e=Zn(3584&~n))&&(0===(e=Zn(4186112&~n))&&(e=512)),e;case 2:return 0===(n=Zn(805306368&~n))&&(n=268435456),n}throw Error("Invalid update priority: "+e+". This is a bug in React.")}function Zn(e){return e&-e}function et(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function nt(e,n,t){e.pendingLanes|=n;var r=n-1;e.suspendedLanes&=r,e.pingedLanes&=r,(e=e.eventTimes)[n=31-tt(n)]=t}var tt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-(rt(e)/lt|0)|0},rt=Math.log,lt=Math.LN2;var at=c.unstable_runWithPriority,it=c.unstable_scheduleCallback,ut=c.unstable_cancelCallback,ot=c.unstable_shouldYield,st=c.unstable_requestPaint,ct=c.unstable_now,ft=c.unstable_getCurrentPriorityLevel,dt=c.unstable_ImmediatePriority,pt=c.unstable_UserBlockingPriority,ht=c.unstable_NormalPriority,gt=c.unstable_LowPriority,mt=c.unstable_IdlePriority,vt={},yt=void 0!==st?st:function(){},bt=null,St=null,wt=!1,kt=ct(),Et=1e4>kt?ct:function(){return ct()-kt};function Tt(){switch(ft()){case dt:return 99;case pt:return 98;case ht:return 97;case gt:return 96;case mt:return 95;default:throw Error("Unknown priority level.")}}function xt(e){switch(e){case 99:return dt;case 98:return pt;case 97:return ht;case 96:return gt;case 95:return mt;default:throw Error("Unknown priority level.")}}function _t(e,n){return e=xt(e),at(e,n)}function Rt(e,n,t){return e=xt(e),it(e,n,t)}function Pt(){if(null!==St){var e=St;St=null,ut(e)}Ct()}function Ct(){if(!wt&&null!==bt){wt=!0;var e=0;try{var n=bt;_t(99,function(){for(;e<n.length;e++){var t=n[e];do{t=t(!0)}while(null!==t)}}),bt=null}catch(n){throw null!==bt&&(bt=bt.slice(e+1)),it(dt,Pt),n}finally{wt=!1}}}var Nt=Ie.ReactCurrentBatchConfig;var zt="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},It=Object.prototype.hasOwnProperty;function Lt(e,n){if(zt(e,n))return!0;if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(r=0;r<t.length;r++)if(!It.call(n,t[r])||!zt(e[t[r]],n[t[r]]))return!1;return!0}function Ut(e){switch(e.tag){case 5:return _n(e.type,null,null);case 16:return _n("Lazy",null,null);case 13:return _n("Suspense",null,null);case 19:return _n("SuspenseList",null,null);case 0:case 2:case 15:return Rn(e.type,null);case 11:return Rn(e.type.render,null);case 22:return Rn(e.type._render,null);case 1:return e=Rn(e.type,null);default:return""}}function Mt(e){try{var n="";do{n+=Ut(e),e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function At(e,n){if(e&&e.defaultProps){for(var t in n=u({},n),e=e.defaultProps)void 0===n[t]&&(n[t]=e[t]);return n}return n}var Dt=Nn(null),Qt=null,Bt=null,Ft=null;function jt(){Ft=Bt=Qt=null}function Ot(e){var n=Dt.current;zn(Dt),e.type._context._currentValue=n}function Ht(e,n){for(;null!==e;){var t=e.alternate;if((e.childLanes&n)===n){if(null===t||(t.childLanes&n)===n)break;t.childLanes|=n}else e.childLanes|=n,null!==t&&(t.childLanes|=n);e=e.return}}function Vt(e,n){Qt=e,Ft=Bt=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!=(e.lanes&n)&&(fl=!0),e.firstContext=null)}function Wt(e,n){if(Ft!==e&&!1!==n&&0!==n)if("number"==typeof n&&1073741823!==n||(Ft=e,n=1073741823),n={context:e,observedBits:n,next:null},null===Bt){if(null===Qt)throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");Bt=n,Qt.dependencies={lanes:0,firstContext:n,responders:null}}else Bt=Bt.next=n;return e._currentValue}var Yt=!1;function qt(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null},effects:null}}function Xt(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gt(e,n){if(null!==(e=e.updateQueue)){var t=(e=e.shared).pending;null===t?n.next=n:(n.next=t.next,t.next=n),e.pending=n}}function Kt(e,n){var t=e.updateQueue,r=e.alternate;if(null!==r&&t===(r=r.updateQueue)){var l=null,a=null;if(null!==(t=t.firstBaseUpdate)){do{var i={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};null===a?l=a=i:a=a.next=i,t=t.next}while(null!==t);null===a?l=a=n:a=a.next=n}else l=a=n;return t={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:a,shared:r.shared,effects:r.effects},void(e.updateQueue=t)}null===(e=t.lastBaseUpdate)?t.firstBaseUpdate=n:e.next=n,t.lastBaseUpdate=n}function Jt(e,n,t,r){var l=e.updateQueue;Yt=!1;var a=l.firstBaseUpdate,i=l.lastBaseUpdate,o=l.shared.pending;if(null!==o){l.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?a=c:i.next=c,i=s;var f=e.alternate;if(null!==f){var d=(f=f.updateQueue).lastBaseUpdate;d!==i&&(null===d?f.firstBaseUpdate=c:d.next=c,f.lastBaseUpdate=s)}}if(null!==a){for(d=l.baseState,i=0,f=c=s=null;;){o=a.lane;var p=a.eventTime;if((r&o)===o){null!==f&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var h=e,g=a;switch(o=n,p=t,g.tag){case 1:if("function"==typeof(h=g.payload)){d=h.call(p,d,o);break e}d=h;break e;case 3:h.flags=-8193&h.flags|64;case 0:if(null===(o="function"==typeof(h=g.payload)?h.call(p,d,o):h)||void 0===o)break e;d=u({},d,o);break e;case 2:Yt=!0}}null!==a.callback&&(e.flags|=32,null===(o=l.effects)?l.effects=[a]:o.push(a))}else p={eventTime:p,lane:o,tag:a.tag,payload:a.payload,callback:a.callback,next:null},null===f?(c=f=p,s=d):f=f.next=p,i|=o;if(null===(a=a.next)){if(null===(o=l.shared.pending))break;a=o.next,o.next=null,l.lastBaseUpdate=o,l.shared.pending=null}}null===f&&(s=d),l.baseState=s,l.firstBaseUpdate=c,l.lastBaseUpdate=f,va|=i,e.lanes=i,e.memoizedState=d}}function Zt(e,n,t){if(e=n.effects,n.effects=null,null!==e)for(n=0;n<e.length;n++){var r=e[n],l=r.callback;if(null!==l){if(r.callback=null,"function"!=typeof l)throw Error("Invalid argument passed as callback. Expected a function. Instead received: "+l);l.call(t)}}}var er=(new s.Component).refs;function nr(e,n,t,r){t=null===(t=t(r,n=e.memoizedState))||void 0===t?n:u({},n,t),e.memoizedState=t,0===e.lanes&&(e.updateQueue.baseState=t)}var tr={isMounted:function(e){return!!(e=e._reactInternals)&&Ze(e)===e},enqueueSetState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.tag=1,a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=Fa(),r=ja(e),l=$t(t,r);l.tag=2,void 0!==n&&null!==n&&(l.callback=n),Gt(e,l),Oa(e,r,t)}};function rr(e,n,t,r,l,a,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,a,i):!n.prototype||!n.prototype.isPureReactComponent||(!Lt(t,r)||!Lt(l,a))}function lr(e,n,t){var r=!1,l=Ln,a=n.contextType;return"object"==typeof a&&null!==a?a=Wt(a):(l=Qn(n)?An:Un.current,a=(r=null!==(r=n.contextTypes)&&void 0!==r)?Dn(e,l):Ln),n=new n(t,a),e.memoizedState=null!==n.state&&void 0!==n.state?n.state:null,n.updater=tr,e.stateNode=n,n._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=a),n}function ar(e,n,t,r){e=n.state,"function"==typeof n.componentWillReceiveProps&&n.componentWillReceiveProps(t,r),"function"==typeof n.UNSAFE_componentWillReceiveProps&&n.UNSAFE_componentWillReceiveProps(t,r),n.state!==e&&tr.enqueueReplaceState(n,n.state,null)}function ir(e,n,t,r){var l=e.stateNode;l.props=t,l.state=e.memoizedState,l.refs=er,qt(e);var a=n.contextType;"object"==typeof a&&null!==a?l.context=Wt(a):(a=Qn(n)?An:Un.current,l.context=Dn(e,a)),Jt(e,t,l,r),l.state=e.memoizedState,"function"==typeof(a=n.getDerivedStateFromProps)&&(nr(e,n,a,t),l.state=e.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof l.getSnapshotBeforeUpdate||"function"!=typeof l.UNSAFE_componentWillMount&&"function"!=typeof l.componentWillMount||(n=l.state,"function"==typeof l.componentWillMount&&l.componentWillMount(),"function"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),n!==l.state&&tr.enqueueReplaceState(l,l.state,null),Jt(e,t,l,r),l.state=e.memoizedState),"function"==typeof l.componentDidMount&&(e.flags|=4)}var ur=Array.isArray;function or(e,n,t){if(null!==(e=t.ref)&&"function"!=typeof e&&"object"!=typeof e){if(t._owner){if(t=t._owner){if(1!==t.tag)throw Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");var r=t.stateNode}if(!r)throw Error("Missing owner for string ref "+e+". This error is likely caused by a bug in React. Please file an issue.");var l=""+e;return null!==n&&null!==n.ref&&"function"==typeof n.ref&&n.ref._stringRef===l?n.ref:((n=function(e){var n=r.refs;n===er&&(n=r.refs={}),null===e?delete n[l]:n[l]=e})._stringRef=l,n)}if("string"!=typeof e)throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");if(!t._owner)throw Error("Element ref was specified as a string ("+e+") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information.")}return e}function sr(e,n){if("textarea"!==e.type)throw Error("Objects are not valid as a React child (found: "+("[object Object]"===Object.prototype.toString.call(n)?"object with keys {"+Object.keys(n).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.")}function cr(e){function n(n,t){if(e){var r=n.lastEffect;null!==r?(r.nextEffect=t,n.lastEffect=t):n.firstEffect=n.lastEffect=t,t.nextEffect=null,t.flags=8}}function t(t,r){if(!e)return null;for(;null!==r;)n(t,r),r=r.sibling;return null}function r(e,n){for(e=new Map;null!==n;)null!==n.key?e.set(n.key,n):e.set(n.index,n),n=n.sibling;return e}function l(e,n){return(e=bi(e,n)).index=0,e.sibling=null,e}function a(n,t,r){return n.index=r,e?null!==(r=n.alternate)?(r=r.index)<t?(n.flags=2,t):r:(n.flags=2,t):t}function i(n){return e&&null===n.alternate&&(n.flags=2),n}function u(e,n,t,r){return null===n||6!==n.tag?((n=Ei(t,e.mode,r)).return=e,n):((n=l(n,t)).return=e,n)}function o(e,n,t,r){return null!==n&&n.elementType===t.type?((r=l(n,t.props)).ref=or(e,n,t),r.return=e,r):((r=Si(t.type,t.key,t.props,null,e.mode,r)).ref=or(e,n,t),r.return=e,r)}function s(e,n,t,r){return null===n||4!==n.tag||n.stateNode.containerInfo!==t.containerInfo||n.stateNode.implementation!==t.implementation?((n=Ti(t,e.mode,r)).return=e,n):((n=l(n,t.children||[])).return=e,n)}function c(e,n,t,r,a){return null===n||7!==n.tag?((n=wi(t,e.mode,r,a)).return=e,n):((n=l(n,t)).return=e,n)}function f(e,n,t){if("string"==typeof n||"number"==typeof n)return(n=Ei(""+n,e.mode,t)).return=e,n;if("object"==typeof n&&null!==n){switch(n.$$typeof){case Le:return(t=Si(n.type,n.key,n.props,null,e.mode,t)).ref=or(e,null,n),t.return=e,t;case Ue:return(n=Ti(n,e.mode,t)).return=e,n}if(ur(n)||Ke(n))return(n=wi(n,e.mode,t,null)).return=e,n;sr(e,n)}return null}function d(e,n,t,r){var l=null!==n?n.key:null;if("string"==typeof t||"number"==typeof t)return null!==l?null:u(e,n,""+t,r);if("object"==typeof t&&null!==t){switch(t.$$typeof){case Le:return t.key===l?t.type===Me?c(e,n,t.props.children,r,l):o(e,n,t,r):null;case Ue:return t.key===l?s(e,n,t,r):null}if(ur(t)||Ke(t))return null!==l?null:c(e,n,t,r,null);sr(e,t)}return null}function p(e,n,t,r,l){if("string"==typeof r||"number"==typeof r)return u(n,e=e.get(t)||null,""+r,l);if("object"==typeof r&&null!==r){switch(r.$$typeof){case Le:return e=e.get(null===r.key?t:r.key)||null,r.type===Me?c(n,e,r.props.children,l,r.key):o(n,e,r,l);case Ue:return s(n,e=e.get(null===r.key?t:r.key)||null,r,l)}if(ur(r)||Ke(r))return c(n,e=e.get(t)||null,r,l,null);sr(n,r)}return null}function h(l,i,u,o){for(var s=null,c=null,h=i,g=i=0,m=null;null!==h&&g<u.length;g++){h.index>g?(m=h,h=null):m=h.sibling;var v=d(l,h,u[g],o);if(null===v){null===h&&(h=m);break}e&&h&&null===v.alternate&&n(l,h),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v,h=m}if(g===u.length)return t(l,h),s;if(null===h){for(;g<u.length;g++)null!==(h=f(l,u[g],o))&&(i=a(h,i,g),null===c?s=h:c.sibling=h,c=h);return s}for(h=r(l,h);g<u.length;g++)null!==(m=p(h,l,g,u[g],o))&&(e&&null!==m.alternate&&h.delete(null===m.key?g:m.key),i=a(m,i,g),null===c?s=m:c.sibling=m,c=m);return e&&h.forEach(function(e){return n(l,e)}),s}function g(l,i,u,o){var s=Ke(u);if("function"!=typeof s)throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");if(null==(u=s.call(u)))throw Error("An iterable object provided no iterator.");for(var c=s=null,h=i,g=i=0,m=null,v=u.next();null!==h&&!v.done;g++,v=u.next()){h.index>g?(m=h,h=null):m=h.sibling;var y=d(l,h,v.value,o);if(null===y){null===h&&(h=m);break}e&&h&&null===y.alternate&&n(l,h),i=a(y,i,g),null===c?s=y:c.sibling=y,c=y,h=m}if(v.done)return t(l,h),s;if(null===h){for(;!v.done;g++,v=u.next())null!==(v=f(l,v.value,o))&&(i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return s}for(h=r(l,h);!v.done;g++,v=u.next())null!==(v=p(h,l,g,v.value,o))&&(e&&null!==v.alternate&&h.delete(null===v.key?g:v.key),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return e&&h.forEach(function(e){return n(l,e)}),s}return function(e,r,a,u){var o="object"==typeof a&&null!==a&&a.type===Me&&null===a.key;o&&(a=a.props.children);var s="object"==typeof a&&null!==a;if(s)switch(a.$$typeof){case Le:e:{for(s=a.key,o=r;null!==o;){if(o.key===s){switch(o.tag){case 7:if(a.type===Me){t(e,o.sibling),(r=l(o,a.props.children)).return=e,e=r;break e}break;default:if(o.elementType===a.type){t(e,o.sibling),(r=l(o,a.props)).ref=or(e,o,a),r.return=e,e=r;break e}}t(e,o);break}n(e,o),o=o.sibling}a.type===Me?((r=wi(a.props.children,e.mode,u,a.key)).return=e,e=r):((u=Si(a.type,a.key,a.props,null,e.mode,u)).ref=or(e,r,a),u.return=e,e=u)}return i(e);case Ue:e:{for(o=a.key;null!==r;){if(r.key===o){if(4===r.tag&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){t(e,r.sibling),(r=l(r,a.children||[])).return=e,e=r;break e}t(e,r);break}n(e,r),r=r.sibling}(r=Ti(a,e.mode,u)).return=e,e=r}return i(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==r&&6===r.tag?(t(e,r.sibling),(r=l(r,a)).return=e,e=r):(t(e,r),(r=Ei(a,e.mode,u)).return=e,e=r),i(e);if(ur(a))return h(e,r,a,u);if(Ke(a))return g(e,r,a,u);if(s&&sr(e,a),void 0===a&&!o)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error((Je(e.type)||"Component")+"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.")}return t(e,r)}}var fr=cr(!0),dr=cr(!1),pr={},hr=Nn(pr),gr=Nn(pr),mr=Nn(pr);function vr(e){if(e===pr)throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");return e}function yr(e,n){In(mr,n),In(gr,e),In(hr,pr),zn(hr),In(hr,{isInAParentText:!1})}function br(){zn(hr),zn(gr),zn(mr)}function Sr(e){vr(mr.current);var n=vr(hr.current),t=e.type;t="AndroidTextInput"===t||"RCTMultilineTextInputView"===t||"RCTSinglelineTextInputView"===t||"RCTText"===t||"RCTVirtualText"===t,n!==(t=n.isInAParentText!==t?{isInAParentText:t}:n)&&(In(gr,e),In(hr,t))}function wr(e){gr.current===e&&(zn(hr),zn(gr))}var kr=Nn(0);function Er(e){for(var n=e;null!==n;){if(13===n.tag){var t=n.memoizedState;if(null!==t&&(null===t.dehydrated||vn()||vn()))return n}else if(19===n.tag&&void 0!==n.memoizedProps.revealOrder){if(0!=(64&n.flags))return n}else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===e)break;for(;null===n.sibling;){if(null===n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Tr=[];function xr(){for(var e=0;e<Tr.length;e++)Tr[e]._workInProgressVersionPrimary=null;Tr.length=0}var _r=Ie.ReactCurrentDispatcher,Rr=Ie.ReactCurrentBatchConfig,Pr=0,Cr=null,Nr=null,zr=null,Ir=!1,Lr=!1;function Ur(){throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.")}function Mr(e,n){if(null===n)return!1;for(var t=0;t<n.length&&t<e.length;t++)if(!zt(e[t],n[t]))return!1;return!0}function Ar(e,n,t,r,l,a){if(Pr=a,Cr=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,_r.current=null===e||null===e.memoizedState?ul:ol,e=t(r,l),Lr){a=0;do{if(Lr=!1,!(25>a))throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");a+=1,zr=Nr=null,n.updateQueue=null,_r.current=sl,e=t(r,l)}while(Lr)}if(_r.current=il,n=null!==Nr&&null!==Nr.next,Pr=0,zr=Nr=Cr=null,Ir=!1,n)throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");return e}function Dr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===zr?Cr.memoizedState=zr=e:zr=zr.next=e,zr}function Qr(){if(null===Nr){var e=Cr.alternate;e=null!==e?e.memoizedState:null}else e=Nr.next;var n=null===zr?Cr.memoizedState:zr.next;if(null!==n)zr=n,Nr=e;else{if(null===e)throw Error("Rendered more hooks than during the previous render.");e={memoizedState:(Nr=e).memoizedState,baseState:Nr.baseState,baseQueue:Nr.baseQueue,queue:Nr.queue,next:null},null===zr?Cr.memoizedState=zr=e:zr=zr.next=e}return zr}function Br(e,n){return"function"==typeof n?n(e):n}function Fr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=Nr,l=r.baseQueue,a=t.pending;if(null!==a){if(null!==l){var i=l.next;l.next=a.next,a.next=i}r.baseQueue=l=a,t.pending=null}if(null!==l){l=l.next,r=r.baseState;var u=i=a=null,o=l;do{var s=o.lane;if((Pr&s)===s)null!==u&&(u=u.next={lane:0,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null}),r=o.eagerReducer===e?o.eagerState:e(r,o.action);else{var c={lane:s,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null};null===u?(i=u=c,a=r):u=u.next=c,Cr.lanes|=s,va|=s}o=o.next}while(null!==o&&o!==l);null===u?a=r:u.next=i,zt(r,n.memoizedState)||(fl=!0),n.memoizedState=r,n.baseState=a,n.baseQueue=u,t.lastRenderedState=r}return[n.memoizedState,t.dispatch]}function jr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=t.dispatch,l=t.pending,a=n.memoizedState;if(null!==l){t.pending=null;var i=l=l.next;do{a=e(a,i.action),i=i.next}while(i!==l);zt(a,n.memoizedState)||(fl=!0),n.memoizedState=a,null===n.baseQueue&&(n.baseState=a),t.lastRenderedState=a}return[a,r]}function Or(e,n,t){var r=n._getVersion;r=r(n._source);var l=n._workInProgressVersionPrimary;if(null!==l?e=l===r:(e=e.mutableReadLanes,(e=(Pr&e)===e)&&(n._workInProgressVersionPrimary=r,Tr.push(n))),e)return t(n._source);throw Tr.push(n),Error("Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.")}function Hr(e,n,t,r){var l=sa;if(null===l)throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");var a=n._getVersion,i=a(n._source),u=_r.current,o=u.useState(function(){return Or(l,n,t)}),s=o[1],c=o[0];o=zr;var f=e.memoizedState,d=f.refs,p=d.getSnapshot,h=f.source;f=f.subscribe;var g=Cr;return e.memoizedState={refs:d,source:n,subscribe:r},u.useEffect(function(){d.getSnapshot=t,d.setSnapshot=s;var e=a(n._source);if(!zt(i,e)){e=t(n._source),zt(c,e)||(s(e),e=ja(g),l.mutableReadLanes|=e&l.pendingLanes),e=l.mutableReadLanes,l.entangledLanes|=e;for(var r=l.entanglements,u=e;0<u;){var o=31-tt(u),f=1<<o;r[o]|=e,u&=~f}}},[t,n,r]),u.useEffect(function(){return r(n._source,function(){var e=d.getSnapshot,t=d.setSnapshot;try{t(e(n._source));var r=ja(g);l.mutableReadLanes|=r&l.pendingLanes}catch(e){t(function(){throw e})}})},[n,r]),zt(p,t)&&zt(h,n)&&zt(f,r)||((e={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:c}).dispatch=s=al.bind(null,Cr,e),o.queue=e,o.baseQueue=null,c=Or(l,n,t),o.memoizedState=o.baseState=c),c}function Vr(e,n,t){return Hr(Qr(),e,n,t)}function Wr(e){var n=Dr();return"function"==typeof e&&(e=e()),n.memoizedState=n.baseState=e,e=(e=n.queue={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:e}).dispatch=al.bind(null,Cr,e),[n.memoizedState,e]}function Yr(e,n,t,r){return e={tag:e,create:n,destroy:t,deps:r,next:null},null===(n=Cr.updateQueue)?(n={lastEffect:null},Cr.updateQueue=n,n.lastEffect=e.next=e):null===(t=n.lastEffect)?n.lastEffect=e.next=e:(r=t.next,t.next=e,e.next=r,n.lastEffect=e),e}function qr(){return Qr().memoizedState}function Xr(e,n,t,r){var l=Dr();Cr.flags|=e,l.memoizedState=Yr(1|n,t,void 0,void 0===r?null:r)}function $r(e,n,t,r){var l=Qr();r=void 0===r?null:r;var a=void 0;if(null!==Nr){var i=Nr.memoizedState;if(a=i.destroy,null!==r&&Mr(r,i.deps))return void Yr(n,t,a,r)}Cr.flags|=e,l.memoizedState=Yr(1|n,t,a,r)}function Gr(e,n){return Xr(516,4,e,n)}function Kr(e,n){return $r(516,4,e,n)}function Jr(e,n){return $r(4,2,e,n)}function Zr(e,n){return"function"==typeof n?(e=e(),n(e),function(){n(null)}):null!==n&&void 0!==n?(e=e(),n.current=e,function(){n.current=null}):void 0}function el(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,$r(4,2,Zr.bind(null,n,e),t)}function nl(){}function tl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(t.memoizedState=[e,n],e)}function rl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(e=e(),t.memoizedState=[e,n],e)}function ll(e,n){var t=Tt();_t(98>t?98:t,function(){e(!0)}),_t(97<t?97:t,function(){var t=Rr.transition;Rr.transition=1;try{e(!1),n()}finally{Rr.transition=t}})}function al(e,n,t){var r=Fa(),l=ja(e),a={lane:l,action:t,eagerReducer:null,eagerState:null,next:null},i=n.pending;if(null===i?a.next=a:(a.next=i.next,i.next=a),n.pending=a,i=e.alternate,e===Cr||null!==i&&i===Cr)Lr=Ir=!0;else{if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=n.lastRenderedReducer))try{var u=n.lastRenderedState,o=i(u,t);if(a.eagerReducer=i,a.eagerState=o,zt(o,u))return}catch(e){}Oa(e,l,r)}}var il={readContext:Wt,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useMutableSource:Ur,useOpaqueIdentifier:Ur,unstable_isNewReconciler:!1},ul={readContext:Wt,useCallback:function(e,n){return Dr().memoizedState=[e,void 0===n?null:n],e},useContext:Wt,useEffect:Gr,useImperativeHandle:function(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,Xr(4,2,Zr.bind(null,n,e),t)},useLayoutEffect:function(e,n){return Xr(4,2,e,n)},useMemo:function(e,n){var t=Dr();return n=void 0===n?null:n,e=e(),t.memoizedState=[e,n],e},useReducer:function(e,n,t){var r=Dr();return n=void 0!==t?t(n):n,r.memoizedState=r.baseState=n,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:n}).dispatch=al.bind(null,Cr,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Dr().memoizedState=e},useState:Wr,useDebugValue:nl,useDeferredValue:function(e){var n=Wr(e),t=n[0],r=n[1];return Gr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Wr(!1),n=e[0];return e=ll.bind(null,e[1]),Dr().memoizedState=e,[e,n]},useMutableSource:function(e,n,t){var r=Dr();return r.memoizedState={refs:{getSnapshot:n,setSnapshot:null},source:e,subscribe:t},Hr(r,e,n,t)},useOpaqueIdentifier:function(){throw Error("Not yet implemented")},unstable_isNewReconciler:!1},ol={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:Fr,useRef:qr,useState:function(){return Fr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=Fr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Fr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return Fr(Br)[0]},unstable_isNewReconciler:!1},sl={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:jr,useRef:qr,useState:function(){return jr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=jr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=jr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return jr(Br)[0]},unstable_isNewReconciler:!1},cl=Ie.ReactCurrentOwner,fl=!1;function dl(e,n,t,r){n.child=null===e?dr(n,null,t,r):fr(n,e.child,t,r)}function pl(e,n,t,r,l){t=t.render;var a=n.ref;return Vt(n,l),r=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,r,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function hl(e,n,t,r,l,a){if(null===e){var i=t.type;return"function"!=typeof i||vi(i)||void 0!==i.defaultProps||null!==t.compare||void 0!==t.defaultProps?((e=Si(t.type,null,r,n,n.mode,a)).ref=n.ref,e.return=n,n.child=e):(n.tag=15,n.type=i,gl(e,n,i,r,l,a))}return i=e.child,0==(l&a)&&(l=i.memoizedProps,(t=null!==(t=t.compare)?t:Lt)(l,r)&&e.ref===n.ref)?Ul(e,n,a):(n.flags|=1,(e=bi(i,r)).ref=n.ref,e.return=n,n.child=e)}function gl(e,n,t,r,l,a){if(null!==e&&Lt(e.memoizedProps,r)&&e.ref===n.ref){if(fl=!1,0==(a&l))return n.lanes=e.lanes,Ul(e,n,a);0!=(32768&e.flags)&&(fl=!0)}return yl(e,n,t,r,a)}function ml(e,n,t){var r=n.pendingProps,l=r.children,a=null!==e?e.memoizedState:null;if("hidden"===r.mode||"unstable-defer-without-hiding"===r.mode)if(0==(4&n.mode))n.memoizedState={baseLanes:0},Xa(n,t);else{if(0==(1073741824&t))return e=null!==a?a.baseLanes|t:t,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e},Xa(n,e),null;n.memoizedState={baseLanes:0},Xa(n,null!==a?a.baseLanes:t)}else null!==a?(r=a.baseLanes|t,n.memoizedState=null):r=t,Xa(n,r);return dl(e,n,l,t),n.child}function vl(e,n){var t=n.ref;(null===e&&null!==t||null!==e&&e.ref!==t)&&(n.flags|=128)}function yl(e,n,t,r,l){var a=Qn(t)?An:Un.current;return a=Dn(n,a),Vt(n,l),t=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,t,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function bl(e,n,t,r,l){if(Qn(t)){var a=!0;On(n)}else a=!1;if(Vt(n,l),null===n.stateNode)null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),lr(n,t,r),ir(n,t,r,l),r=!0;else if(null===e){var i=n.stateNode,u=n.memoizedProps;i.props=u;var o=i.context,s=t.contextType;"object"==typeof s&&null!==s?s=Wt(s):s=Dn(n,s=Qn(t)?An:Un.current);var c=t.getDerivedStateFromProps,f="function"==typeof c||"function"==typeof i.getSnapshotBeforeUpdate;f||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==r||o!==s)&&ar(n,i,r,s),Yt=!1;var d=n.memoizedState;i.state=d,Jt(n,r,i,l),o=n.memoizedState,u!==r||d!==o||Mn.current||Yt?("function"==typeof c&&(nr(n,t,c,r),o=n.memoizedState),(u=Yt||rr(n,t,u,r,d,o,s))?(f||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(n.flags|=4)):("function"==typeof i.componentDidMount&&(n.flags|=4),n.memoizedProps=r,n.memoizedState=o),i.props=r,i.state=o,i.context=s,r=u):("function"==typeof i.componentDidMount&&(n.flags|=4),r=!1)}else{i=n.stateNode,Xt(e,n),u=n.memoizedProps,s=n.type===n.elementType?u:At(n.type,u),i.props=s,f=n.pendingProps,d=i.context,"object"==typeof(o=t.contextType)&&null!==o?o=Wt(o):o=Dn(n,o=Qn(t)?An:Un.current);var p=t.getDerivedStateFromProps;(c="function"==typeof p||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==f||d!==o)&&ar(n,i,r,o),Yt=!1,d=n.memoizedState,i.state=d,Jt(n,r,i,l);var h=n.memoizedState;u!==f||d!==h||Mn.current||Yt?("function"==typeof p&&(nr(n,t,p,r),h=n.memoizedState),(s=Yt||rr(n,t,s,r,d,h,o))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,o),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,o)),"function"==typeof i.componentDidUpdate&&(n.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(n.flags|=256)):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),n.memoizedProps=r,n.memoizedState=h),i.props=r,i.state=h,i.context=o,r=s):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),r=!1)}return Sl(e,n,t,r,a,l)}function Sl(e,n,t,r,l,a){vl(e,n);var i=0!=(64&n.flags);if(!r&&!i)return l&&Hn(n,t,!1),Ul(e,n,a);r=n.stateNode,cl.current=n;var u=i&&"function"!=typeof t.getDerivedStateFromError?null:r.render();return n.flags|=1,null!==e&&i?(n.child=fr(n,e.child,null,a),n.child=fr(n,null,u,a)):dl(e,n,u,a),n.memoizedState=r.state,l&&Hn(n,t,!0),n.child}function wl(e){var n=e.stateNode;n.pendingContext?Fn(0,n.pendingContext,n.pendingContext!==n.context):n.context&&Fn(0,n.context,!1),yr(e,n.containerInfo)}var kl,El,Tl,xl,_l={dehydrated:null,retryLane:0};function Rl(e,n,t){var r,l=n.pendingProps,a=kr.current,i=!1;return(r=0!=(64&n.flags))||(r=(null===e||null!==e.memoizedState)&&0!=(2&a)),r?(i=!0,n.flags&=-65):null!==e&&null===e.memoizedState||void 0===l.fallback||!0===l.unstable_avoidThisFallback||(a|=1),In(kr,1&a),null===e?(e=l.children,a=l.fallback,i?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,e):"number"==typeof l.unstable_expectedLoadTime?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,n.lanes=33554432,e):((t=ki({mode:"visible",children:e},n.mode,t,null)).return=n,n.child=t)):(e.memoizedState,i?(l=Nl(e,n,l.children,l.fallback,t),i=n.child,a=e.child.memoizedState,i.memoizedState=null===a?{baseLanes:t}:{baseLanes:a.baseLanes|t},i.childLanes=e.childLanes&~t,n.memoizedState=_l,l):(t=Cl(e,n,l.children,t),n.memoizedState=null,t))}function Pl(e,n,t,r){var l=e.mode,a=e.child;return n={mode:"hidden",children:n},0==(2&l)&&null!==a?(a.childLanes=0,a.pendingProps=n):a=ki(n,l,0,null),t=wi(t,l,r,null),a.return=e,t.return=e,a.sibling=t,e.child=a,t}function Cl(e,n,t,r){var l=e.child;return e=l.sibling,t=bi(l,{mode:"visible",children:t}),0==(2&n.mode)&&(t.lanes=r),t.return=n,t.sibling=null,null!==e&&(e.nextEffect=null,e.flags=8,n.firstEffect=n.lastEffect=e),n.child=t}function Nl(e,n,t,r,l){var a=n.mode,i=e.child;e=i.sibling;var u={mode:"hidden",children:t};return 0==(2&a)&&n.child!==i?((t=n.child).childLanes=0,t.pendingProps=u,null!==(i=t.lastEffect)?(n.firstEffect=t.firstEffect,n.lastEffect=i,i.nextEffect=null):n.firstEffect=n.lastEffect=null):t=bi(i,u),null!==e?r=bi(e,r):(r=wi(r,a,l,null)).flags|=2,r.return=n,t.return=n,t.sibling=r,n.child=t,r}function zl(e,n){e.lanes|=n;var t=e.alternate;null!==t&&(t.lanes|=n),Ht(e.return,n)}function Il(e,n,t,r,l,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:l,lastEffect:a}:(i.isBackwards=n,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=t,i.tailMode=l,i.lastEffect=a)}function Ll(e,n,t){var r=n.pendingProps,l=r.revealOrder,a=r.tail;if(dl(e,n,r.children,t),0!=(2&(r=kr.current)))r=1&r|2,n.flags|=64;else{if(null!==e&&0!=(64&e.flags))e:for(e=n.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zl(e,t);else if(19===e.tag)zl(e,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(In(kr,r),0==(2&n.mode))n.memoizedState=null;else switch(l){case"forwards":for(t=n.child,l=null;null!==t;)null!==(e=t.alternate)&&null===Er(e)&&(l=t),t=t.sibling;null===(t=l)?(l=n.child,n.child=null):(l=t.sibling,t.sibling=null),Il(n,!1,l,t,a,n.lastEffect);break;case"backwards":for(t=null,l=n.child,n.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Er(e)){n.child=l;break}e=l.sibling,l.sibling=t,t=l,l=e}Il(n,!0,t,null,a,n.lastEffect);break;case"together":Il(n,!1,null,null,void 0,n.lastEffect);break;default:n.memoizedState=null}return n.child}function Ul(e,n,t){if(null!==e&&(n.dependencies=e.dependencies),va|=n.lanes,0!=(t&n.childLanes)){if(null!==e&&n.child!==e.child)throw Error("Resuming work not yet implemented.");if(null!==n.child){for(t=bi(e=n.child,e.pendingProps),n.child=t,t.return=n;null!==e.sibling;)e=e.sibling,(t=t.sibling=bi(e,e.pendingProps)).return=n;t.sibling=null}return n.child}return null}function Ml(e,n){switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;null!==n;)null!==n.alternate&&(t=n),n=n.sibling;null===t?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?n||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Al(e,n,t){var r=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return Qn(n.type)&&Bn(),null;case 3:return br(),zn(Mn),zn(Un),xr(),(r=n.stateNode).pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||r.hydrate||(n.flags|=256),El(n),null;case 5:wr(n);var l=vr(mr.current);if(t=n.type,null!==e&&null!=n.stateNode)Tl(e,n,t,r,l),e.ref!==n.ref&&(n.flags|=128);else{if(!r){if(null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return null}vr(hr.current),e=wn(),t=yn(t);var a=hn(null,ln,r,t.validAttributes);o.UIManager.createView(e,t.uiViewClassName,l,a),l=new mn(e,t,n),ke.set(e,n),Ee.set(e,r),kl(l,n,!1,!1),n.stateNode=l,En(l)&&(n.flags|=4),null!==n.ref&&(n.flags|=128)}return null;case 6:if(e&&null!=n.stateNode)xl(e,n,e.memoizedProps,r);else{if("string"!=typeof r&&null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");if(e=vr(mr.current),!vr(hr.current).isInAParentText)throw Error("Text strings must be rendered within a <Text> component.");l=wn(),o.UIManager.createView(l,"RCTRawText",e,{text:r}),ke.set(l,n),n.stateNode=l}return null;case 13:return zn(kr),r=n.memoizedState,0!=(64&n.flags)?(n.lanes=t,n):(r=null!==r,l=!1,null!==e&&(l=null!==e.memoizedState),r&&!l&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&kr.current)?0===ha&&(ha=3):(0!==ha&&3!==ha||(ha=4),null===sa||0==(134217727&va)&&0==(134217727&ya)||Ya(sa,fa))),(r||l)&&(n.flags|=4),null);case 4:return br(),El(n),null;case 10:return Ot(n),null;case 17:return Qn(n.type)&&Bn(),null;case 19:if(zn(kr),null===(r=n.memoizedState))return null;if(l=0!=(64&n.flags),null===(a=r.rendering))if(l)Ml(r,!1);else{if(0!==ha||null!==e&&0!=(64&e.flags))for(e=n.child;null!==e;){if(null!==(a=Er(e))){for(n.flags|=64,Ml(r,!1),null!==(e=a.updateQueue)&&(n.updateQueue=e,n.flags|=4),null===r.lastEffect&&(n.firstEffect=null),n.lastEffect=r.lastEffect,e=t,r=n.child;null!==r;)t=e,(l=r).flags&=2,l.nextEffect=null,l.firstEffect=null,l.lastEffect=null,null===(a=l.alternate)?(l.childLanes=0,l.lanes=t,l.child=null,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=a.childLanes,l.lanes=a.lanes,l.child=a.child,l.memoizedProps=a.memoizedProps,l.memoizedState=a.memoizedState,l.updateQueue=a.updateQueue,l.type=a.type,t=a.dependencies,l.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return In(kr,1&kr.current|2),n.child}e=e.sibling}null!==r.tail&&Et()>ka&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432)}else{if(!l)if(null!==(e=Er(a))){if(n.flags|=64,l=!0,null!==(e=e.updateQueue)&&(n.updateQueue=e,n.flags|=4),Ml(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate)return null!==(n=n.lastEffect=r.lastEffect)&&(n.nextEffect=null),null}else 2*Et()-r.renderingStartTime>ka&&1073741824!==t&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432);r.isBackwards?(a.sibling=n.child,n.child=a):(null!==(e=r.last)?e.sibling=a:n.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.lastEffect=n.lastEffect,r.renderingStartTime=Et(),e.sibling=null,n=kr.current,In(kr,l?1&n|2:1&n),e):null;case 23:case 24:return $a(),null!==e&&null!==e.memoizedState!=(null!==n.memoizedState)&&"unstable-defer-without-hiding"!==r.mode&&(n.flags|=4),null}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function Dl(e){switch(e.tag){case 1:Qn(e.type)&&Bn();var n=e.flags;return 8192&n?(e.flags=-8193&n|64,e):null;case 3:if(br(),zn(Mn),zn(Un),xr(),0!=(64&(n=e.flags)))throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");return e.flags=-8193&n|64,e;case 5:return wr(e),null;case 13:return zn(kr),8192&(n=e.flags)?(e.flags=-8193&n|64,e):null;case 19:return zn(kr),null;case 4:return br(),null;case 10:return Ot(e),null;case 23:case 24:return $a(),null;default:return null}}function Ql(e,n){return{value:e,source:n,stack:Mt(n)}}if(kl=function(e,n){for(var t=n.child;null!==t;){if(5===t.tag||6===t.tag)e._children.push(t.stateNode);else if(4!==t.tag&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===n)break;for(;null===t.sibling;){if(null===t.return||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}},El=function(){},Tl=function(e,n,t,r){e.memoizedProps!==r&&(vr(hr.current),n.updateQueue=bn)&&(n.flags|=4)},xl=function(e,n,t,r){t!==r&&(n.flags|=4)},"function"!=typeof o.ReactFiberErrorDialog.showErrorDialog)throw Error("Expected ReactFiberErrorDialog.showErrorDialog to be a function.");function Bl(e,n){try{!1!==o.ReactFiberErrorDialog.showErrorDialog({componentStack:null!==n.stack?n.stack:"",error:n.value,errorBoundary:null!==e&&1===e.tag?e.stateNode:null})&&console.error(n.value)}catch(e){setTimeout(function(){throw e})}}var Fl="function"==typeof WeakMap?WeakMap:Map;function jl(e,n,t){(t=$t(-1,t)).tag=3,t.payload={element:null};var r=n.value;return t.callback=function(){Ta||(Ta=!0,xa=r),Bl(e,n)},t}function Ol(e,n,t){(t=$t(-1,t)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var l=n.value;t.payload=function(){return Bl(e,n),r(l)}}var a=e.stateNode;return null!==a&&"function"==typeof a.componentDidCatch&&(t.callback=function(){"function"!=typeof r&&(null===_a?_a=new Set([this]):_a.add(this),Bl(e,n));var t=n.stack;this.componentDidCatch(n.value,{componentStack:null!==t?t:""})}),t}var Hl="function"==typeof WeakSet?WeakSet:Set;function Vl(e){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){di(e,n)}else n.current=null}function Wl(e,n){switch(n.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&n.flags&&null!==e){var t=e.memoizedProps,r=e.memoizedState;n=(e=n.stateNode).getSnapshotBeforeUpdate(n.elementType===n.type?t:At(n.type,t),r),e.__reactInternalSnapshotBeforeUpdate=n}return;case 3:return;case 5:case 6:case 4:case 17:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function Yl(e,n,t){switch(t.tag){case 0:case 11:case 15:case 22:if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{if(3==(3&e.tag)){var r=e.create;e.destroy=r()}e=e.next}while(e!==n)}if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{var l=e;r=l.next,0!=(4&(l=l.tag))&&0!=(1&l)&&(si(t,e),oi(t,e)),e=r}while(e!==n)}return;case 1:return e=t.stateNode,4&t.flags&&(null===n?e.componentDidMount():(r=t.elementType===t.type?n.memoizedProps:At(t.type,n.memoizedProps),e.componentDidUpdate(r,n.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),void(null!==(n=t.updateQueue)&&Zt(t,n,e));case 3:if(null!==(n=t.updateQueue)){if(e=null,null!==t.child)switch(t.child.tag){case 5:e=t.child.stateNode;break;case 1:e=t.child.stateNode}Zt(t,n,e)}return;case 5:case 6:case 4:case 12:case 13:return;case 19:case 17:case 20:case 21:case 23:case 24:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ql(e,n){for(var t=e;;){if(5===t.tag){var r=t.stateNode;if(n){var l=r.viewConfig,a=hn(null,ln,{style:{display:"none"}},l.validAttributes);o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}else{r=t.stateNode,a=t.memoizedProps,l=r.viewConfig,a=hn(null,u({},a,{style:[a.style,{display:"none"}]}),a,l.validAttributes),o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}}else{if(6===t.tag)throw Error("Not yet implemented.");if((23!==t.tag&&24!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}function Xl(e,n){if(Wn&&"function"==typeof Wn.onCommitFiberUnmount)try{Wn.onCommitFiberUnmount(Vn,n)}catch(e){}switch(n.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=n.updateQueue)&&null!==(e=e.lastEffect)){var t=e=e.next;do{var r=t,l=r.destroy;if(r=r.tag,void 0!==l)if(0!=(4&r))si(n,t);else{r=n;try{l()}catch(e){di(r,e)}}t=t.next}while(t!==e)}break;case 1:if(Vl(n),"function"==typeof(e=n.stateNode).componentWillUnmount)try{e.props=n.memoizedProps,e.state=n.memoizedState,e.componentWillUnmount()}catch(e){di(n,e)}break;case 5:Vl(n);break;case 4:ea(e,n)}}function $l(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}function Gl(e){return 5===e.tag||3===e.tag||4===e.tag}function Kl(e){e:{for(var n=e.return;null!==n;){if(Gl(n))break e;n=n.return}throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.")}var t=n;switch(n=t.stateNode,t.tag){case 5:var r=!1;break;case 3:case 4:n=n.containerInfo,r=!0;break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}16&t.flags&&(t.flags&=-17);e:n:for(t=e;;){for(;null===t.sibling;){if(null===t.return||Gl(t.return)){t=null;break e}t=t.return}for(t.sibling.return=t.return,t=t.sibling;5!==t.tag&&6!==t.tag&&18!==t.tag;){if(2&t.flags)continue n;if(null===t.child||4===t.tag)continue n;t.child.return=t,t=t.child}if(!(2&t.flags)){t=t.stateNode;break e}}r?Jl(e,t,n):Zl(e,t,n)}function Jl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)if(e=l?e.stateNode:e.stateNode.instance,n){if("number"==typeof t)throw Error("Container does not support insertBefore operation")}else o.UIManager.setChildren(t,["number"==typeof e?e:e._nativeTag]);else if(4!==r&&null!==(e=e.child))for(Jl(e,n,t),e=e.sibling;null!==e;)Jl(e,n,t),e=e.sibling}function Zl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,n?0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[l],[n],[],[],[])):(n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[],[],["number"==typeof e?e:e._nativeTag],[n],[])):(n="number"==typeof e?e:e._nativeTag,0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),r.push(e),o.UIManager.manageChildren(t._nativeTag,[l],[r.length-1],[],[],[])):(r.push(e),o.UIManager.manageChildren(t._nativeTag,[],[],[n],[r.length-1],[])));else if(4!==r&&null!==(e=e.child))for(Zl(e,n,t),e=e.sibling;null!==e;)Zl(e,n,t),e=e.sibling}function ea(e,n){for(var t,r,l=n,a=!1;;){if(!a){a=l.return;e:for(;;){if(null===a)throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");switch(t=a.stateNode,a.tag){case 5:r=!1;break e;case 3:case 4:t=t.containerInfo,r=!0;break e}a=a.return}a=!0}if(5===l.tag||6===l.tag){e:for(var i=e,u=l,s=u;;)if(Xl(i,s),null!==s.child&&4!==s.tag)s.child.return=s,s=s.child;else{if(s===u)break e;for(;null===s.sibling;){if(null===s.return||s.return===u)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}r?(i=t,kn(l.stateNode),o.UIManager.manageChildren(i,[],[],[],[],[0])):(i=t,kn(s=l.stateNode),s=(u=i._children).indexOf(s),u.splice(s,1),o.UIManager.manageChildren(i._nativeTag,[],[],[],[],[s]))}else if(4===l.tag){if(null!==l.child){t=l.stateNode.containerInfo,r=!0,l.child.return=l,l=l.child;continue}}else if(Xl(e,l),null!==l.child){l.child.return=l,l=l.child;continue}if(l===n)break;for(;null===l.sibling;){if(null===l.return||l.return===n)return;4===(l=l.return).tag&&(a=!1)}l.sibling.return=l.return,l=l.sibling}}function na(e,n){switch(n.tag){case 0:case 11:case 14:case 15:case 22:var t=n.updateQueue;if(null!==(t=null!==t?t.lastEffect:null)){var r=t=t.next;do{3==(3&r.tag)&&(n=r.destroy,r.destroy=void 0,void 0!==n&&n()),r=r.next}while(r!==t)}return;case 1:return;case 5:if(null!=(t=n.stateNode)){r=n.memoizedProps,e=null!==e?e.memoizedProps:r;var l=n.updateQueue;n.updateQueue=null,null!==l&&(n=t.viewConfig,Ee.set(t._nativeTag,r),null!=(r=hn(null,e,r,n.validAttributes))&&o.UIManager.updateView(t._nativeTag,n.uiViewClassName,r))}return;case 6:if(null===n.stateNode)throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");return void o.UIManager.updateView(n.stateNode,"RCTRawText",{text:n.memoizedProps});case 3:case 12:return;case 13:return null!==n.memoizedState&&(wa=Et(),ql(n.child,!0)),void ta(n);case 19:return void ta(n);case 17:return;case 23:case 24:return void ql(n,null!==n.memoizedState)}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ta(e){var n=e.updateQueue;if(null!==n){e.updateQueue=null;var t=e.stateNode;null===t&&(t=e.stateNode=new Hl),n.forEach(function(n){var r=hi.bind(null,e,n);t.has(n)||(t.add(n),n.then(r,r))})}}function ra(e,n){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(n=n.memoizedState)&&null===n.dehydrated)}var la,aa=Math.ceil,ia=Ie.ReactCurrentDispatcher,ua=Ie.ReactCurrentOwner,oa=0,sa=null,ca=null,fa=0,da=0,pa=Nn(0),ha=0,ga=null,ma=0,va=0,ya=0,ba=0,Sa=null,wa=0,ka=1/0,Ea=null,Ta=!1,xa=null,_a=null,Ra=!1,Pa=null,Ca=90,Na=[],za=[],Ia=null,La=0,Ua=null,Ma=-1,Aa=0,Da=0,Qa=null,Ba=!1;function Fa(){return 0!=(48&oa)?Et():-1!==Ma?Ma:Ma=Et()}function ja(e){if(0==(2&(e=e.mode)))return 1;if(0==(4&e))return 99===Tt()?1:2;if(0===Aa&&(Aa=ma),0!==Nt.transition){0!==Da&&(Da=null!==Sa?Sa.pendingLanes:0),e=Aa;var n=4186112&~Da;return 0===(n&=-n)&&(0===(n=(e=4186112&~e)&-e)&&(n=8192)),n}return e=Tt(),0!=(4&oa)&&98===e?e=Jn(12,Aa):e=Jn(e=Xn(e),Aa),e}function Oa(e,n,t){if(50<La)throw La=0,Ua=null,Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");if(null===(e=Ha(e,n)))return null;nt(e,n,t),e===sa&&(ya|=n,4===ha&&Ya(e,fa));var r=Tt();1===n?0!=(8&oa)&&0==(48&oa)?qa(e):(Va(e,t),0===oa&&(ka=Et()+500,Pt())):(0==(4&oa)||98!==r&&99!==r||(null===Ia?Ia=new Set([e]):Ia.add(e)),Va(e,t)),Sa=e}function Ha(e,n){e.lanes|=n;var t=e.alternate;for(null!==t&&(t.lanes|=n),t=e,e=e.return;null!==e;)e.childLanes|=n,null!==(t=e.alternate)&&(t.childLanes|=n),t=e,e=e.return;return 3===t.tag?t.stateNode:null}function Va(e,n){for(var t=e.callbackNode,r=e.suspendedLanes,l=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var u=31-tt(i),o=1<<u,s=a[u];if(-1===s){if(0==(o&r)||0!=(o&l)){s=n,qn(o);var c=Yn;a[u]=10<=c?s+250:6<=c?s+5e3:-1}}else s<=n&&(e.expiredLanes|=o);i&=~o}if(r=Gn(e,e===sa?fa:0),n=Yn,0===r)null!==t&&(t!==vt&&ut(t),e.callbackNode=null,e.callbackPriority=0);else{if(null!==t){if(e.callbackPriority===n)return;t!==vt&&ut(t)}15===n?(t=qa.bind(null,e),null===bt?(bt=[t],St=it(dt,Ct)):bt.push(t),t=vt):14===n?t=Rt(99,qa.bind(null,e)):t=Rt(t=$n(n),Wa.bind(null,e)),e.callbackPriority=n,e.callbackNode=t}}function Wa(e){if(Ma=-1,Da=Aa=0,0!=(48&oa))throw Error("Should not already be working.");var n=e.callbackNode;if(ui()&&e.callbackNode!==n)return null;var t=Gn(e,e===sa?fa:0);if(0===t)return null;var r=t,l=oa;oa|=16;var a=Ja();for(sa===e&&fa===r||(ka=Et()+500,Ga(e,r));;)try{ni();break}catch(n){Ka(e,n)}if(jt(),ia.current=a,oa=l,null!==ca?r=0:(sa=null,fa=0,r=ha),0!=(ma&ya))Ga(e,0);else if(0!==r){if(2===r&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(t=Kn(e))&&(r=Za(e,t))),1===r)throw n=ga,Ga(e,0),Ya(e,t),Va(e,Et()),n;switch(e.finishedWork=e.current.alternate,e.finishedLanes=t,r){case 0:case 1:throw Error("Root did not complete. This is a bug in React.");case 2:li(e);break;case 3:if(Ya(e,t),(62914560&t)===t&&10<(r=wa+500-Et())){if(0!==Gn(e,0))break;if(((l=e.suspendedLanes)&t)!==t){Fa(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=Tn(li.bind(null,e),r);break}li(e);break;case 4:if(Ya(e,t),(4186112&t)===t)break;for(r=e.eventTimes,l=-1;0<t;){var i=31-tt(t);a=1<<i,(i=r[i])>l&&(l=i),t&=~a}if(t=l,10<(t=(120>(t=Et()-t)?120:480>t?480:1080>t?1080:1920>t?1920:3e3>t?3e3:4320>t?4320:1960*aa(t/1960))-t)){e.timeoutHandle=Tn(li.bind(null,e),t);break}li(e);break;case 5:li(e);break;default:throw Error("Unknown root exit status.")}}return Va(e,Et()),e.callbackNode===n?Wa.bind(null,e):null}function Ya(e,n){for(n&=~ba,n&=~ya,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var t=31-tt(n),r=1<<t;e[t]=-1,n&=~r}}function qa(e){if(0!=(48&oa))throw Error("Should not already be working.");if(ui(),e===sa&&0!=(e.expiredLanes&fa)){var n=fa,t=Za(e,n);0!=(ma&ya)&&(t=Za(e,n=Gn(e,n)))}else t=Za(e,n=Gn(e,0));if(0!==e.tag&&2===t&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(n=Kn(e))&&(t=Za(e,n))),1===t)throw t=ga,Ga(e,0),Ya(e,n),Va(e,Et()),t;return e.finishedWork=e.current.alternate,e.finishedLanes=n,li(e),Va(e,Et()),null}function Xa(e,n){In(pa,da),da|=n,ma|=n}function $a(){da=pa.current,zn(pa)}function Ga(e,n){e.finishedWork=null,e.finishedLanes=0;var t=e.timeoutHandle;if(-1!==t&&(e.timeoutHandle=-1,xn(t)),null!==ca)for(t=ca.return;null!==t;){var r=t;switch(r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&Bn();break;case 3:br(),zn(Mn),zn(Un),xr();break;case 5:wr(r);break;case 4:br();break;case 13:case 19:zn(kr);break;case 10:Ot(r);break;case 23:case 24:$a()}t=t.return}sa=e,ca=bi(e.current,null),fa=da=ma=n,ha=0,ga=null,ba=ya=va=0}function Ka(e,n){for(;;){var t=ca;try{if(jt(),_r.current=il,Ir){for(var r=Cr.memoizedState;null!==r;){var l=r.queue;null!==l&&(l.pending=null),r=r.next}Ir=!1}if(Pr=0,zr=Nr=Cr=null,Lr=!1,ua.current=null,null===t||null===t.return){ha=1,ga=n,ca=null;break}e:{var a=e,i=t.return,u=t,o=n;if(n=fa,u.flags|=4096,u.firstEffect=u.lastEffect=null,null!==o&&"object"==typeof o&&"function"==typeof o.then){var s=o;if(0==(2&u.mode)){var c=u.alternate;c?(u.updateQueue=c.updateQueue,u.memoizedState=c.memoizedState,u.lanes=c.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=0!=(1&kr.current),d=i;do{var p;if(p=13===d.tag){var h=d.memoizedState;if(null!==h)p=null!==h.dehydrated;else{var g=d.memoizedProps;p=void 0!==g.fallback&&(!0!==g.unstable_avoidThisFallback||!f)}}if(p){var m=d.updateQueue;if(null===m){var v=new Set;v.add(s),d.updateQueue=v}else m.add(s);if(0==(2&d.mode)){if(d.flags|=64,u.flags|=32768,u.flags&=-5029,1===u.tag)if(null===u.alternate)u.tag=17;else{var y=$t(-1,1);y.tag=2,Gt(u,y)}u.lanes|=1;break e}o=void 0,u=n;var b=a.pingCache;if(null===b?(b=a.pingCache=new Fl,o=new Set,b.set(s,o)):void 0===(o=b.get(s))&&(o=new Set,b.set(s,o)),!o.has(u)){o.add(u);var S=pi.bind(null,a,s,u);s.then(S,S)}d.flags|=8192,d.lanes=n;break e}d=d.return}while(null!==d);o=Error((Je(u.type)||"A React component")+" suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.")}5!==ha&&(ha=2),o=Ql(o,u),d=i;do{switch(d.tag){case 3:a=o,d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,jl(d,a,n));break e;case 1:a=o;var w=d.type,k=d.stateNode;if(0==(64&d.flags)&&("function"==typeof w.getDerivedStateFromError||null!==k&&"function"==typeof k.componentDidCatch&&(null===_a||!_a.has(k)))){d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,Ol(d,a,n));break e}}d=d.return}while(null!==d)}ri(t)}catch(e){n=e,ca===t&&null!==t&&(ca=t=t.return);continue}break}}function Ja(){var e=ia.current;return ia.current=il,null===e?il:e}function Za(e,n){var t=oa;oa|=16;var r=Ja();for(sa===e&&fa===n||Ga(e,n);;)try{ei();break}catch(n){Ka(e,n)}if(jt(),oa=t,ia.current=r,null!==ca)throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");return sa=null,fa=0,ha}function ei(){for(;null!==ca;)ti(ca)}function ni(){for(;null!==ca&&!ot();)ti(ca)}function ti(e){var n=la(e.alternate,e,da);e.memoizedProps=e.pendingProps,null===n?ri(e):ca=n,ua.current=null}function ri(e){var n=e;do{var t=n.alternate;if(e=n.return,0==(4096&n.flags)){if(null!==(t=Al(t,n,da)))return void(ca=t);if(24!==(t=n).tag&&23!==t.tag||null===t.memoizedState||0!=(1073741824&da)||0==(4&t.mode)){for(var r=0,l=t.child;null!==l;)r|=l.lanes|l.childLanes,l=l.sibling;t.childLanes=r}null!==e&&0==(4096&e.flags)&&(null===e.firstEffect&&(e.firstEffect=n.firstEffect),null!==n.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=n.firstEffect),e.lastEffect=n.lastEffect),1<n.flags&&(null!==e.lastEffect?e.lastEffect.nextEffect=n:e.firstEffect=n,e.lastEffect=n))}else{if(null!==(t=Dl(n)))return t.flags&=4095,void(ca=t);null!==e&&(e.firstEffect=e.lastEffect=null,e.flags|=4096)}if(null!==(n=n.sibling))return void(ca=n);ca=n=e}while(null!==n);0===ha&&(ha=5)}function li(e){var n=Tt();return _t(99,ai.bind(null,e,n)),null}function ai(e,n){do{ui()}while(null!==Pa);if(0!=(48&oa))throw Error("Should not already be working.");var t=e.finishedWork;if(null===t)return null;if(e.finishedWork=null,e.finishedLanes=0,t===e.current)throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");e.callbackNode=null;var r=t.lanes|t.childLanes,l=r,a=e.pendingLanes&~l;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=l,e.mutableReadLanes&=l,e.entangledLanes&=l,l=e.entanglements;for(var i=e.eventTimes,u=e.expirationTimes;0<a;){var o=31-tt(a),s=1<<o;l[o]=0,i[o]=-1,u[o]=-1,a&=~s}if(null!==Ia&&0==(24&r)&&Ia.has(e)&&Ia.delete(e),e===sa&&(ca=sa=null,fa=0),1<t.flags?null!==t.lastEffect?(t.lastEffect.nextEffect=t,r=t.firstEffect):r=t:r=t.firstEffect,null!==r){l=oa,oa|=32,Qa=ua.current=null,Ba=!1,Ea=r;do{try{ii()}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Qa=null,Ea=r;do{try{for(i=e;null!==Ea;){var c=Ea.flags;if(128&c){var f=Ea.alternate;if(null!==f){var d=f.ref;null!==d&&("function"==typeof d?d(null):d.current=null)}}switch(1038&c){case 2:Kl(Ea),Ea.flags&=-3;break;case 6:Kl(Ea),Ea.flags&=-3,na(Ea.alternate,Ea);break;case 1024:Ea.flags&=-1025;break;case 1028:Ea.flags&=-1025,na(Ea.alternate,Ea);break;case 4:na(Ea.alternate,Ea);break;case 8:ea(i,u=Ea);var p=u.alternate;$l(u),null!==p&&$l(p)}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);e.current=t,Ea=r;do{try{for(c=e;null!==Ea;){var h=Ea.flags;if(36&h&&Yl(c,Ea.alternate,Ea),128&h){f=void 0;var g=Ea.ref;if(null!==g){var m=Ea.stateNode;switch(Ea.tag){case 5:f=m;break;default:f=m}"function"==typeof g?g(f):g.current=f}}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Ea=null,yt(),oa=l}else e.current=t;if(Ra)Ra=!1,Pa=e,Ca=n;else for(Ea=r;null!==Ea;)n=Ea.nextEffect,Ea.nextEffect=null,8&Ea.flags&&((h=Ea).sibling=null,h.stateNode=null),Ea=n;if(0===(r=e.pendingLanes)&&(_a=null),1===r?e===Ua?La++:(La=0,Ua=e):La=0,t=t.stateNode,Wn&&"function"==typeof Wn.onCommitFiberRoot)try{Wn.onCommitFiberRoot(Vn,t,void 0,64==(64&t.current.flags))}catch(e){}if(Va(e,Et()),Ta)throw Ta=!1,e=xa,xa=null,e;return 0!=(8&oa)?null:(Pt(),null)}function ii(){for(;null!==Ea;){var e=Ea.alternate;Ba||null===Qa||(0!=(8&Ea.flags)?rn(Ea,Qa)&&(Ba=!0):13===Ea.tag&&ra(e,Ea)&&rn(Ea,Qa)&&(Ba=!0));var n=Ea.flags;0!=(256&n)&&Wl(e,Ea),0==(512&n)||Ra||(Ra=!0,Rt(97,function(){return ui(),null})),Ea=Ea.nextEffect}}function ui(){if(90!==Ca){var e=97<Ca?97:Ca;return Ca=90,_t(e,ci)}return!1}function oi(e,n){Na.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function si(e,n){za.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function ci(){if(null===Pa)return!1;var e=Pa;if(Pa=null,0!=(48&oa))throw Error("Cannot flush passive effects while already rendering.");var n=oa;oa|=32;var t=za;za=[];for(var r=0;r<t.length;r+=2){var l=t[r],a=t[r+1],i=l.destroy;if(l.destroy=void 0,"function"==typeof i)try{i()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(t=Na,Na=[],r=0;r<t.length;r+=2){l=t[r],a=t[r+1];try{var u=l.create;l.destroy=u()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(u=e.current.firstEffect;null!==u;)e=u.nextEffect,u.nextEffect=null,8&u.flags&&(u.sibling=null,u.stateNode=null),u=e;return oa=n,Pt(),!0}function fi(e,n,t){Gt(e,n=jl(e,n=Ql(t,n),1)),n=Fa(),null!==(e=Ha(e,1))&&(nt(e,1,n),Va(e,n))}function di(e,n){if(3===e.tag)fi(e,e,n);else for(var t=e.return;null!==t;){if(3===t.tag){fi(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r))){var l=Ol(t,e=Ql(n,e),1);if(Gt(t,l),l=Fa(),null!==(t=Ha(t,1)))nt(t,1,l),Va(t,l);else if("function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r)))try{r.componentDidCatch(n,e)}catch(e){}break}}t=t.return}}function pi(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),n=Fa(),e.pingedLanes|=e.suspendedLanes&t,sa===e&&(fa&t)===t&&(4===ha||3===ha&&(62914560&fa)===fa&&500>Et()-wa?Ga(e,0):ba|=t),Va(e,n)}function hi(e,n){var t=e.stateNode;null!==t&&t.delete(n),0===(n=0)&&(0==(2&(n=e.mode))?n=1:0==(4&n)?n=99===Tt()?1:2:(0===Aa&&(Aa=ma),0===(n=Zn(62914560&~Aa))&&(n=4194304))),t=Fa(),null!==(e=Ha(e,n))&&(nt(e,n,t),Va(e,t))}function gi(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.flags=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childLanes=this.lanes=0,this.alternate=null}function mi(e,n,t,r){return new gi(e,n,t,r)}function vi(e){return!(!(e=e.prototype)||!e.isReactComponent)}function yi(e){if("function"==typeof e)return vi(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===Fe)return 11;if(e===He)return 14}return 2}function bi(e,n){var t=e.alternate;return null===t?((t=mi(e.tag,n,e.key,e.mode)).elementType=e.elementType,t.type=e.type,t.stateNode=e.stateNode,t.alternate=e,e.alternate=t):(t.pendingProps=n,t.type=e.type,t.flags=0,t.nextEffect=null,t.firstEffect=null,t.lastEffect=null),t.childLanes=e.childLanes,t.lanes=e.lanes,t.child=e.child,t.memoizedProps=e.memoizedProps,t.memoizedState=e.memoizedState,t.updateQueue=e.updateQueue,n=e.dependencies,t.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},t.sibling=e.sibling,t.index=e.index,t.ref=e.ref,t}function Si(e,n,t,r,l,a){var i=2;if(r=e,"function"==typeof e)vi(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case Me:return wi(t.children,l,a,n);case Ye:i=8,l|=16;break;case Ae:i=8,l|=1;break;case De:return(e=mi(12,t,n,8|l)).elementType=De,e.type=De,e.lanes=a,e;case je:return(e=mi(13,t,n,l)).type=je,e.elementType=je,e.lanes=a,e;case Oe:return(e=mi(19,t,n,l)).elementType=Oe,e.lanes=a,e;case qe:return ki(t,l,a,n);case Xe:return(e=mi(24,t,n,l)).elementType=Xe,e.lanes=a,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case Qe:i=10;break e;case Be:i=9;break e;case Fe:i=11;break e;case He:i=14;break e;case Ve:i=16,r=null;break e;case We:i=22;break e}throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+(null==e?e:typeof e)+".")}return(n=mi(i,t,n,l)).elementType=e,n.type=r,n.lanes=a,n}function wi(e,n,t,r){return(e=mi(7,e,r,n)).lanes=t,e}function ki(e,n,t,r){return(e=mi(23,e,r,n)).elementType=qe,e.lanes=t,e}function Ei(e,n,t){return(e=mi(6,e,null,n)).lanes=t,e}function Ti(e,n,t){return(n=mi(4,null!==e.children?e.children:[],e.key,n)).lanes=t,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function xi(e,n,t){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=t,this.callbackNode=null,this.callbackPriority=0,this.eventTimes=et(0),this.expirationTimes=et(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0)}function _i(e,n,t){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:Ue,key:null==r?null:""+r,children:e,containerInfo:n,implementation:t}}function Ri(e){var n=e._reactInternals;if(void 0===n){if("function"==typeof e.render)throw Error("Unable to find node on an unmounted component.");throw Error("Argument appears to not be a ReactComponent. Keys: "+Object.keys(e))}return null===(e=tn(n))?null:e.stateNode}function Pi(e,n,t,r){var l=n.current,a=Fa(),i=ja(l);e:if(t){t=t._reactInternals;n:{if(Ze(t)!==t||1!==t.tag)throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");var u=t;do{switch(u.tag){case 3:u=u.stateNode.context;break n;case 1:if(Qn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break n}}u=u.return}while(null!==u);throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.")}if(1===t.tag){var o=t.type;if(Qn(o)){t=jn(t,o,u);break e}}t=u}else t=Ln;return null===n.context?n.context=t:n.pendingContext=t,(n=$t(a,i)).payload={element:e},null!==(r=void 0===r?null:r)&&(n.callback=r),Gt(l,n),Oa(l,i,a),i}function Ci(e){return null==e?null:"number"==typeof e?e:e._nativeTag?e._nativeTag:e.canonical&&e.canonical._nativeTag?e.canonical._nativeTag:null==(e=Ri(e))?e:e.canonical?e.canonical._nativeTag:e._nativeTag}function Ni(e){var n=zi.get(e);n&&Pi(null,n,null,function(){zi.delete(e)})}la=function(e,n,t){var r=n.lanes;if(null!==e)if(e.memoizedProps!==n.pendingProps||Mn.current)fl=!0;else{if(0==(t&r)){switch(fl=!1,n.tag){case 3:wl(n);break;case 5:Sr(n);break;case 1:Qn(n.type)&&On(n);break;case 4:yr(n,n.stateNode.containerInfo);break;case 10:r=n.memoizedProps.value;var l=n.type._context;In(Dt,l._currentValue),l._currentValue=r;break;case 13:if(null!==n.memoizedState)return 0!=(t&n.child.childLanes)?Rl(e,n,t):(In(kr,1&kr.current),null!==(n=Ul(e,n,t))?n.sibling:null);In(kr,1&kr.current);break;case 19:if(r=0!=(t&n.childLanes),0!=(64&e.flags)){if(r)return Ll(e,n,t);n.flags|=64}if(null!==(l=n.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),In(kr,kr.current),r)break;return null;case 23:case 24:return n.lanes=0,ml(e,n,t)}return Ul(e,n,t)}fl=0!=(32768&e.flags)}else fl=!1;switch(n.lanes=0,n.tag){case 2:if(r=n.type,null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=Dn(n,Un.current),Vt(n,t),l=Ar(null,n,r,e,l,t),n.flags|=1,"object"==typeof l&&null!==l&&"function"==typeof l.render&&void 0===l.$$typeof){if(n.tag=1,n.memoizedState=null,n.updateQueue=null,Qn(r)){var a=!0;On(n)}else a=!1;n.memoizedState=null!==l.state&&void 0!==l.state?l.state:null,qt(n);var i=r.getDerivedStateFromProps;"function"==typeof i&&nr(n,r,i,e),l.updater=tr,n.stateNode=l,l._reactInternals=n,ir(n,r,e,t),n=Sl(null,n,r,!0,a,t)}else n.tag=0,dl(null,n,l,t),n=n.child;return n;case 16:l=n.elementType;e:{switch(null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=(a=l._init)(l._payload),n.type=l,a=n.tag=yi(l),e=At(l,e),a){case 0:n=yl(null,n,l,e,t);break e;case 1:n=bl(null,n,l,e,t);break e;case 11:n=pl(null,n,l,e,t);break e;case 14:n=hl(null,n,l,At(l.type,e),r,t);break e}throw Error("Element type is invalid. Received a promise that resolves to: "+l+". Lazy element type must resolve to a class or function.")}return n;case 0:return r=n.type,l=n.pendingProps,yl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 1:return r=n.type,l=n.pendingProps,bl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 3:if(wl(n),r=n.updateQueue,null===e||null===r)throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");return r=n.pendingProps,l=null!==(l=n.memoizedState)?l.element:null,Xt(e,n),Jt(n,r,null,t),(r=n.memoizedState.element)===l?n=Ul(e,n,t):(dl(e,n,r,t),n=n.child),n;case 5:return Sr(n),r=n.pendingProps.children,vl(e,n),dl(e,n,r,t),n.child;case 6:return null;case 13:return Rl(e,n,t);case 4:return yr(n,n.stateNode.containerInfo),r=n.pendingProps,null===e?n.child=fr(n,null,r,t):dl(e,n,r,t),n.child;case 11:return r=n.type,l=n.pendingProps,pl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 7:return dl(e,n,n.pendingProps,t),n.child;case 8:case 12:return dl(e,n,n.pendingProps.children,t),n.child;case 10:e:{r=n.type._context,l=n.pendingProps,i=n.memoizedProps,a=l.value;var u=n.type._context;if(In(Dt,u._currentValue),u._currentValue=a,null!==i)if(u=i.value,0===(a=zt(u,a)?0:0|("function"==typeof r._calculateChangedBits?r._calculateChangedBits(u,a):1073741823))){if(i.children===l.children&&!Mn.current){n=Ul(e,n,t);break e}}else for(null!==(u=n.child)&&(u.return=n);null!==u;){var o=u.dependencies;if(null!==o){i=u.child;for(var s=o.firstContext;null!==s;){if(s.context===r&&0!=(s.observedBits&a)){1===u.tag&&((s=$t(-1,t&-t)).tag=2,Gt(u,s)),u.lanes|=t,null!==(s=u.alternate)&&(s.lanes|=t),Ht(u.return,t),o.lanes|=t;break}s=s.next}}else i=10===u.tag&&u.type===n.type?null:u.child;if(null!==i)i.return=u;else for(i=u;null!==i;){if(i===n){i=null;break}if(null!==(u=i.sibling)){u.return=i.return,i=u;break}i=i.return}u=i}dl(e,n,l.children,t),n=n.child}return n;case 9:return l=n.type,r=(a=n.pendingProps).children,Vt(n,t),r=r(l=Wt(l,a.unstable_observedBits)),n.flags|=1,dl(e,n,r,t),n.child;case 14:return a=At(l=n.type,n.pendingProps),hl(e,n,l,a=At(l.type,a),r,t);case 15:return gl(e,n,n.type,n.pendingProps,r,t);case 17:return r=n.type,l=n.pendingProps,l=n.elementType===r?l:At(r,l),null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),n.tag=1,Qn(r)?(e=!0,On(n)):e=!1,Vt(n,t),lr(n,r,l),ir(n,r,l,t),Sl(null,n,r,!0,e,t);case 19:return Ll(e,n,t);case 23:case 24:return ml(e,n,t)}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")},xe=function(e,n){var t=oa;oa|=1;try{return e(n)}finally{0===(oa=t)&&(ka=Et()+500,Pt())}};var zi=new Map,Ii={findFiberByHostInstance:Te,bundleType:0,version:"17.0.1-4e5d7faf5",rendererPackageName:"react-native-renderer",rendererConfig:{getInspectorDataForViewTag:function(){throw Error("getInspectorDataForViewTag() is not available in production")},getInspectorDataForViewAtPoint:function(){throw Error("getInspectorDataForViewAtPoint() is not available in production.")}.bind(null,Ci)}},Li={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ie.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=tn(e))?null:e.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Ui=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ui.isDisabled&&Ui.supportsFiber)try{Vn=Ui.inject(Li),Wn=Ui}catch(e){}}a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED={computeComponentStackForErrorReporting:function(e){return(e=Te(e))?Mt(e):""}},a.createPortal=function(e,n){return _i(e,n,null,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},a.dispatchCommand=function(e,n,t){null!=e._nativeTag&&(e._internalInstanceHandle?nativeFabricUIManager.dispatchCommand(e._internalInstanceHandle.stateNode.node,n,t):o.UIManager.dispatchViewManagerCommand(e._nativeTag,n,t))},a.findHostInstance_DEPRECATED=function(e){return null==e?null:e._nativeTag?e:e.canonical&&e.canonical._nativeTag?e.canonical:null==(e=Ri(e))?e:e.canonical?e.canonical:e},a.findNodeHandle=Ci,a.render=function(e,n,t){var r=zi.get(n);if(!r){r=new xi(n,0,!1);var l=mi(3,null,null,0);r.current=l,l.stateNode=r,qt(l),zi.set(n,r)}Pi(e,r,null,t);e:if(e=r.current,e.child)switch(e.child.tag){case 5:e=e.child.stateNode;break e;default:e=e.child.stateNode}else e=null;return e},a.unmountComponentAtNode=Ni,a.unmountComponentAtNodeAndRemoveContainer=function(e){Ni(e),o.UIManager.removeRootView(e)},a.unstable_batchedUpdates=Re},88,[6,89,160,14,184]);^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:94:94291: warning: the variable "nativeFabricUIManager" was not declared in anonymous function " 290#"__d(function(e,n,t,r,l,a,i){"use strict";var u=n(i[0]);n(i[1]);var o=n(i[2]),s=n(i[3]),c=n(i[4]);function f(e,n,t,r,l,a,i,u,o){var s=Array.prototype.slice.call(arguments,3);try{n.apply(t,s)}catch(e){this.onError(e)}}var d=!1,p=null,h=!1,g=null,m={onError:function(e){d=!0,p=e}};function v(e,n,t,r,l,a,i,u,o){d=!1,p=null,f.apply(m,arguments)}function y(e,n,t,r,l,a,i,u,o){if(v.apply(this,arguments),d){if(!d)throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");var s=p;d=!1,p=null,h||(h=!0,g=s)}}var b=null,S=null,w=null;function k(e,n,t){var r=e.type||"unknown-event";e.currentTarget=w(t),y(r,n,void 0,e),e.currentTarget=null}function E(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))throw Error("executeDirectDispatch(...): Invalid `event`.");return e.currentTarget=n?w(t):null,n=n?n(e):null,e.currentTarget=null,e._dispatchListeners=null,e._dispatchInstances=null,n}function T(){return!0}function x(){return!1}function _(e,n,t,r){for(var l in this.dispatchConfig=e,this._targetInst=n,this.nativeEvent=t,this._dispatchInstances=this._dispatchListeners=null,e=this.constructor.Interface)e.hasOwnProperty(l)&&((n=e[l])?this[l]=n(t):"target"===l?this.target=r:this[l]=t[l]);return this.isDefaultPrevented=(null!=t.defaultPrevented?t.defaultPrevented:!1===t.returnValue)?T:x,this.isPropagationStopped=x,this}function R(e,n,t,r){if(this.eventPool.length){var l=this.eventPool.pop();return this.call(l,e,n,t,r),l}return new this(e,n,t,r)}function P(e){if(!(e instanceof this))throw Error("Trying to release an event instance into a pool of a different type.");e.destructor(),10>this.eventPool.length&&this.eventPool.push(e)}function C(e){e.getPooled=R,e.eventPool=[],e.release=P}u(_.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=T)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=T)},persist:function(){this.isPersistent=T},isPersistent:x,destructor:function(){var e,n=this.constructor.Interface;for(e in n)this[e]=null;this.nativeEvent=this._targetInst=this.dispatchConfig=null,this.isPropagationStopped=this.isDefaultPrevented=x,this._dispatchInstances=this._dispatchListeners=null}}),_.Interface={type:null,target:null,currentTarget:function(){return null},eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null},_.extend=function(e){function n(){}function t(){return r.apply(this,arguments)}var r=this;n.prototype=r.prototype;var l=new n;return u(l,t.prototype),t.prototype=l,t.prototype.constructor=t,t.Interface=u({},r.Interface,e),t.extend=r.extend,C(t),t},C(_);var N=_.extend({touchHistory:function(){return null}});function z(e){return"topTouchStart"===e}function I(e){return"topTouchMove"===e}var L=["topTouchStart"],U=["topTouchMove"],M=["topTouchCancel","topTouchEnd"],A=[],D={touchBank:A,numberActiveTouches:0,indexOfSingleActiveTouch:-1,mostRecentTimeStamp:0};function Q(e){return e.timeStamp||e.timestamp}function B(e){if(null==(e=e.identifier))throw Error("Touch object is missing identifier.");return e}function F(e){var n=B(e),t=A[n];t?(t.touchActive=!0,t.startPageX=e.pageX,t.startPageY=e.pageY,t.startTimeStamp=Q(e),t.currentPageX=e.pageX,t.currentPageY=e.pageY,t.currentTimeStamp=Q(e),t.previousPageX=e.pageX,t.previousPageY=e.pageY,t.previousTimeStamp=Q(e)):(t={touchActive:!0,startPageX:e.pageX,startPageY:e.pageY,startTimeStamp:Q(e),currentPageX:e.pageX,currentPageY:e.pageY,currentTimeStamp:Q(e),previousPageX:e.pageX,previousPageY:e.pageY,previousTimeStamp:Q(e)},A[n]=t),D.mostRecentTimeStamp=Q(e)}function j(e){var n=A[B(e)];n&&(n.touchActive=!0,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}function O(e){var n=A[B(e)];n&&(n.touchActive=!1,n.previousPageX=n.currentPageX,n.previousPageY=n.currentPageY,n.previousTimeStamp=n.currentTimeStamp,n.currentPageX=e.pageX,n.currentPageY=e.pageY,n.currentTimeStamp=Q(e),D.mostRecentTimeStamp=Q(e))}var H={recordTouchTrack:function(e,n){if(I(e))n.changedTouches.forEach(j);else if(z(e))n.changedTouches.forEach(F),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches&&(D.indexOfSingleActiveTouch=n.touches[0].identifier);else if(("topTouchEnd"===e||"topTouchCancel"===e)&&(n.changedTouches.forEach(O),D.numberActiveTouches=n.touches.length,1===D.numberActiveTouches))for(e=0;e<A.length;e++)if(null!=(n=A[e])&&n.touchActive){D.indexOfSingleActiveTouch=e;break}},touchHistory:D};function V(e,n){if(null==n)throw Error("accumulate(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?e.concat(n):Array.isArray(n)?[e].concat(n):[e,n]}function W(e,n){if(null==n)throw Error("accumulateInto(...): Accumulated items must not be null or undefined.");return null==e?n:Array.isArray(e)?Array.isArray(n)?(e.push.apply(e,n),e):(e.push(n),e):Array.isArray(n)?[e].concat(n):[e,n]}function Y(e,n,t){Array.isArray(e)?e.forEach(n,t):e&&n.call(t,e)}var q=null,X=0;function $(e,n){var t=q;q=e,null!==le.GlobalResponderHandler&&le.GlobalResponderHandler.onChange(t,e,n)}var G={startShouldSetResponder:{phasedRegistrationNames:{bubbled:"onStartShouldSetResponder",captured:"onStartShouldSetResponderCapture"},dependencies:L},scrollShouldSetResponder:{phasedRegistrationNames:{bubbled:"onScrollShouldSetResponder",captured:"onScrollShouldSetResponderCapture"},dependencies:["topScroll"]},selectionChangeShouldSetResponder:{phasedRegistrationNames:{bubbled:"onSelectionChangeShouldSetResponder",captured:"onSelectionChangeShouldSetResponderCapture"},dependencies:["topSelectionChange"]},moveShouldSetResponder:{phasedRegistrationNames:{bubbled:"onMoveShouldSetResponder",captured:"onMoveShouldSetResponderCapture"},dependencies:U},responderStart:{registrationName:"onResponderStart",dependencies:L},responderMove:{registrationName:"onResponderMove",dependencies:U},responderEnd:{registrationName:"onResponderEnd",dependencies:M},responderRelease:{registrationName:"onResponderRelease",dependencies:M},responderTerminationRequest:{registrationName:"onResponderTerminationRequest",dependencies:[]},responderGrant:{registrationName:"onResponderGrant",dependencies:[]},responderReject:{registrationName:"onResponderReject",dependencies:[]},responderTerminate:{registrationName:"onResponderTerminate",dependencies:[]}};function K(e){do{e=e.return}while(e&&5!==e.tag);return e||null}function J(e,n,t){for(var r=[];e;)r.push(e),e=K(e);for(e=r.length;0<e--;)n(r[e],"captured",t);for(e=0;e<r.length;e++)n(r[e],"bubbled",t)}function Z(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}function ee(e,n,t){(n=Z(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function ne(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=Z(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}function te(e){if(e&&e.dispatchConfig.phasedRegistrationNames){var n=e._targetInst;J(n=n?K(n):null,ee,e)}}function re(e){e&&e.dispatchConfig.phasedRegistrationNames&&J(e._targetInst,ee,e)}var le={_getResponder:function(){return q},eventTypes:G,extractEvents:function(e,n,t,r){if(z(e))X+=1;else if("topTouchEnd"===e||"topTouchCancel"===e){if(!(0<=X))return null;--X}if(H.recordTouchTrack(e,t),n&&("topScroll"===e&&!t.responderIgnoreScroll||0<X&&"topSelectionChange"===e||z(e)||I(e))){var l=z(e)?G.startShouldSetResponder:I(e)?G.moveShouldSetResponder:"topSelectionChange"===e?G.selectionChangeShouldSetResponder:G.scrollShouldSetResponder;if(q)e:{for(var a=q,i=0,u=a;u;u=K(u))i++;u=0;for(var o=n;o;o=K(o))u++;for(;0<i-u;)a=K(a),i--;for(;0<u-i;)n=K(n),u--;for(;i--;){if(a===n||a===n.alternate)break e;a=K(a),n=K(n)}a=null}else a=n;a=(n=a)===q,(l=N.getPooled(l,n,t,r)).touchHistory=H.touchHistory,Y(l,a?te:re);e:{if(a=l._dispatchListeners,n=l._dispatchInstances,Array.isArray(a)){for(i=0;i<a.length&&!l.isPropagationStopped();i++)if(a[i](l,n[i])){a=n[i];break e}}else if(a&&a(l,n)){a=n;break e}a=null}if(l._dispatchInstances=null,l._dispatchListeners=null,l.isPersistent()||l.constructor.release(l),a&&a!==q)if((l=N.getPooled(G.responderGrant,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),n=!0===E(l),q)if((i=N.getPooled(G.responderTerminationRequest,q,t,r)).touchHistory=H.touchHistory,Y(i,ne),u=!i._dispatchListeners||E(i),i.isPersistent()||i.constructor.release(i),u){(i=N.getPooled(G.responderTerminate,q,t,r)).touchHistory=H.touchHistory,Y(i,ne);var s=V(s,[l,i]);$(a,n)}else(l=N.getPooled(G.responderReject,a,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l);else s=V(s,l),$(a,n);else s=null}else s=null;if(l=q&&z(e),a=q&&I(e),n=q&&("topTouchEnd"===e||"topTouchCancel"===e),(l=l?G.responderStart:a?G.responderMove:n?G.responderEnd:null)&&((l=N.getPooled(l,q,t,r)).touchHistory=H.touchHistory,Y(l,ne),s=V(s,l)),l=q&&"topTouchCancel"===e,e=q&&!l&&("topTouchEnd"===e||"topTouchCancel"===e))e:{if((e=t.touches)&&0!==e.length)for(a=0;a<e.length;a++)if(null!==(n=e[a].target)&&void 0!==n&&0!==n){i=S(n);n:{for(n=q;i;){if(n===i||n===i.alternate){n=!0;break n}i=K(i)}n=!1}if(n){e=!1;break e}}e=!0}return(e=l?G.responderTerminate:e?G.responderRelease:null)&&((t=N.getPooled(e,q,t,r)).touchHistory=H.touchHistory,Y(t,ne),s=V(s,t),$(null)),s},GlobalResponderHandler:null,injection:{injectGlobalResponderHandler:function(e){le.GlobalResponderHandler=e}}},ae=null,ie={};function ue(){if(ae)for(var e in ie){var n=ie[e],t=ae.indexOf(e);if(!(-1<t))throw Error("EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `"+e+"`.");if(!se[t]){if(!n.extractEvents)throw Error("EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `"+e+"` does not.");for(var r in se[t]=n,t=n.eventTypes){var l=void 0,a=t[r],i=r;if(ce.hasOwnProperty(i))throw Error("EventPluginRegistry: More than one plugin attempted to publish the same event name, `"+i+"`.");ce[i]=a;var u=a.phasedRegistrationNames;if(u){for(l in u)u.hasOwnProperty(l)&&oe(u[l],n);l=!0}else a.registrationName?(oe(a.registrationName,n),l=!0):l=!1;if(!l)throw Error("EventPluginRegistry: Failed to publish event `"+r+"` for plugin `"+e+"`.")}}}}function oe(e,n){if(fe[e])throw Error("EventPluginRegistry: More than one plugin attempted to publish the same registration name, `"+e+"`.");fe[e]=n}var se=[],ce={},fe={};function de(e,n){if(null===(e=e.stateNode))return null;if(null===(e=b(e)))return null;if((e=e[n])&&"function"!=typeof e)throw Error("Expected `"+n+"` listener to be a function, instead got a value of `"+typeof e+"` type.");return e}var pe=o.ReactNativeViewConfigRegistry.customBubblingEventTypes,he=o.ReactNativeViewConfigRegistry.customDirectEventTypes;function ge(e,n,t){(n=de(e,t.dispatchConfig.phasedRegistrationNames[n]))&&(t._dispatchListeners=W(t._dispatchListeners,n),t._dispatchInstances=W(t._dispatchInstances,e))}function me(e){if(e&&e.dispatchConfig.phasedRegistrationNames){for(var n=e._targetInst,t=[];n;){t.push(n);do{n=n.return}while(n&&5!==n.tag);n=n||null}for(n=t.length;0<n--;)ge(t[n],"captured",e);for(n=0;n<t.length;n++)ge(t[n],"bubbled",e)}}function ve(e){if(e&&e.dispatchConfig.registrationName){var n=e._targetInst;if(n&&e&&e.dispatchConfig.registrationName){var t=de(n,e.dispatchConfig.registrationName);t&&(e._dispatchListeners=W(e._dispatchListeners,t),e._dispatchInstances=W(e._dispatchInstances,n))}}}if(ae)throw Error("EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.");ae=Array.prototype.slice.call(["ResponderEventPlugin","ReactNativeBridgeEventPlugin"]),ue();var ye,be={ResponderEventPlugin:le,ReactNativeBridgeEventPlugin:{eventTypes:{},extractEvents:function(e,n,t,r){if(null==n)return null;var l=pe[e],a=he[e];if(!l&&!a)throw Error('Unsupported top level event type "'+e+'" dispatched');if(e=_.getPooled(l||a,n,t,r),l)Y(e,me);else{if(!a)return null;Y(e,ve)}return e}}},Se=!1;for(ye in be)if(be.hasOwnProperty(ye)){var we=be[ye];if(!ie.hasOwnProperty(ye)||ie[ye]!==we){if(ie[ye])throw Error("EventPluginRegistry: Cannot inject two different event plugins using the same name, `"+ye+"`.");ie[ye]=we,Se=!0}}Se&&ue();var ke=new Map,Ee=new Map;function Te(e){return ke.get(e)||null}function xe(e,n){return e(n)}var _e=!1;function Re(e,n){if(_e)return e(n);_e=!0;try{return xe(e,n)}finally{_e=!1}}var Pe=null;function Ce(e){if(e){var n=e._dispatchListeners,t=e._dispatchInstances;if(Array.isArray(n))for(var r=0;r<n.length&&!e.isPropagationStopped();r++)k(e,n[r],t[r]);else n&&k(e,n,t);e._dispatchListeners=null,e._dispatchInstances=null,e.isPersistent()||e.constructor.release(e)}}var Ne={};function ze(e,n,t){var r=t||Ne,l=Te(e),a=null;null!=l&&(a=l.stateNode),Re(function(){for(var e=a,t=null,i=se,u=0;u<i.length;u++){var o=i[u];o&&(o=o.extractEvents(n,l,r,e))&&(t=W(t,o))}if(null!==(e=t)&&(Pe=W(Pe,e)),e=Pe,Pe=null,e){if(Y(e,Ce),Pe)throw Error("processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented.");if(h)throw e=g,h=!1,g=null,e}})}o.RCTEventEmitter.register({receiveEvent:function(e,n,t){ze(e,n,t)},receiveTouches:function(e,n,t){if("topTouchEnd"===e||"topTouchCancel"===e){for(var r=[],l=0;l<t.length;l++){var a=t[l];r.push(n[a]),n[a]=null}for(l=t=0;l<n.length;l++)null!==(a=n[l])&&(n[t++]=a);n.length=t}else for(r=[],l=0;l<t.length;l++)r.push(n[t[l]]);for(t=0;t<r.length;t++){(l=r[t]).changedTouches=r,l.touches=n,a=null;var i=l.target;null===i||void 0===i||1>i||(a=i),ze(a,e,l)}}}),b=function(e){return Ee.get(e._nativeTag)||null},S=Te,w=function(e){var n=(e=e.stateNode)._nativeTag;if(void 0===n&&(n=(e=e.canonical)._nativeTag),!n)throw Error("All native instances should have a tag.");return e},le.injection.injectGlobalResponderHandler({onChange:function(e,n,t){null!==n?o.UIManager.setJSResponder(n.stateNode._nativeTag,t):o.UIManager.clearJSResponder()}});var Ie=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Le=60103,Ue=60106,Me=60107,Ae=60108,De=60114,Qe=60109,Be=60110,Fe=60112,je=60113,Oe=60120,He=60115,Ve=60116,We=60121,Ye=60129,qe=60130,Xe=60131;if("function"==typeof Symbol&&Symbol.for){var $e=Symbol.for;Le=$e("react.element"),Ue=$e("react.portal"),Me=$e("react.fragment"),Ae=$e("react.strict_mode"),De=$e("react.profiler"),Qe=$e("react.provider"),Be=$e("react.context"),Fe=$e("react.forward_ref"),je=$e("react.suspense"),Oe=$e("react.suspense_list"),He=$e("react.memo"),Ve=$e("react.lazy"),We=$e("react.block"),$e("react.scope"),Ye=$e("react.debug_trace_mode"),qe=$e("react.offscreen"),Xe=$e("react.legacy_hidden")}var Ge="function"==typeof Symbol&&Symbol.iterator;function Ke(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=Ge&&e[Ge]||e["@@iterator"])?e:null}function Je(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case Me:return"Fragment";case Ue:return"Portal";case De:return"Profiler";case Ae:return"StrictMode";case je:return"Suspense";case Oe:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case Be:return(e.displayName||"Context")+".Consumer";case Qe:return(e._context.displayName||"Context")+".Provider";case Fe:var n=e.render;return n=n.displayName||n.name||"",e.displayName||(""!==n?"ForwardRef("+n+")":"ForwardRef");case He:return Je(e.type);case We:return Je(e._render);case Ve:n=e._payload,e=e._init;try{return Je(e(n))}catch(e){}}return null}function Ze(e){var n=e,t=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do{0!=(1026&(n=e).flags)&&(t=n.return),e=n.return}while(e)}return 3===n.tag?t:null}function en(e){if(Ze(e)!==e)throw Error("Unable to find node on an unmounted component.")}function nn(e){var n=e.alternate;if(!n){if(null===(n=Ze(e)))throw Error("Unable to find node on an unmounted component.");return n!==e?null:e}for(var t=e,r=n;;){var l=t.return;if(null===l)break;var a=l.alternate;if(null===a){if(null!==(r=l.return)){t=r;continue}break}if(l.child===a.child){for(a=l.child;a;){if(a===t)return en(l),e;if(a===r)return en(l),n;a=a.sibling}throw Error("Unable to find node on an unmounted component.")}if(t.return!==r.return)t=l,r=a;else{for(var i=!1,u=l.child;u;){if(u===t){i=!0,t=l,r=a;break}if(u===r){i=!0,r=l,t=a;break}u=u.sibling}if(!i){for(u=a.child;u;){if(u===t){i=!0,t=a,r=l;break}if(u===r){i=!0,r=a,t=l;break}u=u.sibling}if(!i)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(t.alternate!==r)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(3!==t.tag)throw Error("Unable to find node on an unmounted component.");return t.stateNode.current===t?e:n}function tn(e){if(!(e=nn(e)))return null;for(var n=e;;){if(5===n.tag||6===n.tag)return n;if(n.child)n.child.return=n,n=n.child;else{if(n===e)break;for(;!n.sibling;){if(!n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}}return null}function rn(e,n){for(var t=e.alternate;null!==n;){if(n===e||n===t)return!0;n=n.return}return!1}var ln={},an=null,un=0,on={unsafelyIgnoreFunctions:!0};function sn(e,n){return"object"!=typeof n||null===n||o.deepDiffer(e,n,on)}function cn(e,n,t){if(Array.isArray(n))for(var r=n.length;r--&&0<un;)cn(e,n[r],t);else if(n&&0<un)for(r in an)if(an[r]){var l=n[r];if(void 0!==l){var a=t[r];a&&("function"==typeof l&&(l=!0),void 0===l&&(l=null),"object"!=typeof a?e[r]=l:"function"!=typeof a.diff&&"function"!=typeof a.process||(l="function"==typeof a.process?a.process(l):l,e[r]=l),an[r]=!1,un--)}}}function fn(e,n,t,r){if(!e&&n===t)return e;if(!n||!t)return t?dn(e,t,r):n?pn(e,n,r):e;if(!Array.isArray(n)&&!Array.isArray(t))return hn(e,n,t,r);if(Array.isArray(n)&&Array.isArray(t)){var l,a=n.length<t.length?n.length:t.length;for(l=0;l<a;l++)e=fn(e,n[l],t[l],r);for(;l<n.length;l++)e=pn(e,n[l],r);for(;l<t.length;l++)e=dn(e,t[l],r);return e}return Array.isArray(n)?hn(e,o.flattenStyle(n),t,r):hn(e,n,o.flattenStyle(t),r)}function dn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,ln,n,t);for(var r=0;r<n.length;r++)e=dn(e,n[r],t);return e}function pn(e,n,t){if(!n)return e;if(!Array.isArray(n))return hn(e,n,ln,t);for(var r=0;r<n.length;r++)e=pn(e,n[r],t);return e}function hn(e,n,t,r){var l,a;for(a in t)if(l=r[a]){var i=n[a],u=t[a];"function"==typeof u&&(u=!0,"function"==typeof i&&(i=!0)),void 0===u&&(u=null,void 0===i&&(i=null)),an&&(an[a]=!1),e&&void 0!==e[a]?"object"!=typeof l?e[a]=u:"function"!=typeof l.diff&&"function"!=typeof l.process||(l="function"==typeof l.process?l.process(u):u,e[a]=l):i!==u&&("object"!=typeof l?sn(i,u)&&((e||(e={}))[a]=u):"function"==typeof l.diff||"function"==typeof l.process?(void 0===i||("function"==typeof l.diff?l.diff(i,u):sn(i,u)))&&(l="function"==typeof l.process?l.process(u):u,(e||(e={}))[a]=l):(an=null,un=0,e=fn(e,i,u,l),0<un&&e&&(cn(e,u,l),an=null)))}for(var o in n)void 0===t[o]&&(!(l=r[o])||e&&void 0!==e[o]||void 0!==(i=n[o])&&("object"!=typeof l||"function"==typeof l.diff||"function"==typeof l.process?((e||(e={}))[o]=null,an||(an={}),an[o]||(an[o]=!0,un++)):e=pn(e,i,l)));return e}function gn(e,n){return function(){if(n&&("boolean"!=typeof e.__isMounted||e.__isMounted))return n.apply(e,arguments)}}var mn=(function(){function e(e,n){this._nativeTag=e,this._children=[],this.viewConfig=n}var n=e.prototype;return n.blur=function(){o.TextInputState.blurTextInput(this)},n.focus=function(){o.TextInputState.focusTextInput(this)},n.measure=function(e){o.UIManager.measure(this._nativeTag,gn(this,e))},n.measureInWindow=function(e){o.UIManager.measureInWindow(this._nativeTag,gn(this,e))},n.measureLayout=function(e,n,t){if("number"==typeof e)var r=e;else e._nativeTag&&(r=e._nativeTag);null!=r&&o.UIManager.measureLayout(this._nativeTag,r,gn(this,t),gn(this,n))},n.setNativeProps=function(e){null!=(e=hn(null,ln,e,this.viewConfig.validAttributes))&&o.UIManager.updateView(this._nativeTag,this.viewConfig.uiViewClassName,e)},e})();function vn(){throw Error("The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue.")}var yn=o.ReactNativeViewConfigRegistry.get,bn={},Sn=3;function wn(){var e=Sn;return 1==e%10&&(e+=2),Sn=e+2,e}function kn(e){if("number"==typeof e)ke.delete(e),Ee.delete(e);else{var n=e._nativeTag;ke.delete(n),Ee.delete(n),e._children.forEach(kn)}}function En(e){if(0===e._children.length)return!1;var n=e._children.map(function(e){return"number"==typeof e?e:e._nativeTag});return o.UIManager.setChildren(e._nativeTag,n),!1}var Tn=setTimeout,xn=clearTimeout;function _n(e,n,t){return n="",t&&(n=" (created by "+t+")"),"\n    in "+(e||"Unknown")+n}function Rn(e,n){return e?_n(e.displayName||e.name||null,n,null):""}var Pn=[],Cn=-1;function Nn(e){return{current:e}}function zn(e){0>Cn||(e.current=Pn[Cn],Pn[Cn]=null,Cn--)}function In(e,n){Pn[++Cn]=e.current,e.current=n}var Ln={},Un=Nn(Ln),Mn=Nn(!1),An=Ln;function Dn(e,n){var t=e.type.contextTypes;if(!t)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===n)return r.__reactInternalMemoizedMaskedChildContext;var l,a={};for(l in t)a[l]=n[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function Qn(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Bn(){zn(Mn),zn(Un)}function Fn(e,n,t){if(Un.current!==Ln)throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");In(Un,n),In(Mn,t)}function jn(e,n,t){var r=e.stateNode;if(e=n.childContextTypes,"function"!=typeof r.getChildContext)return t;for(var l in r=r.getChildContext())if(!(l in e))throw Error((Je(n)||"Unknown")+'.getChildContext(): key "'+l+'" is not defined in childContextTypes.');return u({},t,r)}function On(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,An=Un.current,In(Un,e),In(Mn,Mn.current),!0}function Hn(e,n,t){var r=e.stateNode;if(!r)throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");t?(e=jn(e,n,An),r.__reactInternalMemoizedMergedChildContext=e,zn(Mn),zn(Un),In(Un,e)):zn(Mn),In(Mn,t)}var Vn=null,Wn=null;(0,c.unstable_now)();var Yn=8;function qn(e){if(0!=(1&e))return Yn=15,1;if(0!=(2&e))return Yn=14,2;if(0!=(4&e))return Yn=13,4;var n=24&e;return 0!==n?(Yn=12,n):0!=(32&e)?(Yn=11,32):0!==(n=192&e)?(Yn=10,n):0!=(256&e)?(Yn=9,256):0!==(n=3584&e)?(Yn=8,n):0!=(4096&e)?(Yn=7,4096):0!==(n=4186112&e)?(Yn=6,n):0!==(n=62914560&e)?(Yn=5,n):67108864&e?(Yn=4,67108864):0!=(134217728&e)?(Yn=3,134217728):0!==(n=805306368&e)?(Yn=2,n):0!=(1073741824&e)?(Yn=1,1073741824):(Yn=8,e)}function Xn(e){switch(e){case 99:return 15;case 98:return 10;case 97:case 96:return 8;case 95:return 2;default:return 0}}function $n(e){switch(e){case 15:case 14:return 99;case 13:case 12:case 11:case 10:return 98;case 9:case 8:case 7:case 6:case 4:case 5:return 97;case 3:case 2:case 1:return 95;case 0:return 90;default:throw Error("Invalid update priority: "+e+". This is a bug in React.")}}function Gn(e,n){var t=e.pendingLanes;if(0===t)return Yn=0;var r=0,l=0,a=e.expiredLanes,i=e.suspendedLanes,u=e.pingedLanes;if(0!==a)r=a,l=Yn=15;else if(0!==(a=134217727&t)){var o=a&~i;0!==o?(r=qn(o),l=Yn):0!==(u&=a)&&(r=qn(u),l=Yn)}else 0!==(a=t&~i)?(r=qn(a),l=Yn):0!==u&&(r=qn(u),l=Yn);if(0===r)return 0;if(r=t&((0>(r=31-tt(r))?0:1<<r)<<1)-1,0!==n&&n!==r&&0==(n&i)){if(qn(n),l<=Yn)return n;Yn=l}if(0!==(n=e.entangledLanes))for(e=e.entanglements,n&=r;0<n;)l=1<<(t=31-tt(n)),r|=e[t],n&=~l;return r}function Kn(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function Jn(e,n){switch(e){case 15:return 1;case 14:return 2;case 12:return 0===(e=Zn(24&~n))?Jn(10,n):e;case 10:return 0===(e=Zn(192&~n))?Jn(8,n):e;case 8:return 0===(e=Zn(3584&~n))&&(0===(e=Zn(4186112&~n))&&(e=512)),e;case 2:return 0===(n=Zn(805306368&~n))&&(n=268435456),n}throw Error("Invalid update priority: "+e+". This is a bug in React.")}function Zn(e){return e&-e}function et(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function nt(e,n,t){e.pendingLanes|=n;var r=n-1;e.suspendedLanes&=r,e.pingedLanes&=r,(e=e.eventTimes)[n=31-tt(n)]=t}var tt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-(rt(e)/lt|0)|0},rt=Math.log,lt=Math.LN2;var at=c.unstable_runWithPriority,it=c.unstable_scheduleCallback,ut=c.unstable_cancelCallback,ot=c.unstable_shouldYield,st=c.unstable_requestPaint,ct=c.unstable_now,ft=c.unstable_getCurrentPriorityLevel,dt=c.unstable_ImmediatePriority,pt=c.unstable_UserBlockingPriority,ht=c.unstable_NormalPriority,gt=c.unstable_LowPriority,mt=c.unstable_IdlePriority,vt={},yt=void 0!==st?st:function(){},bt=null,St=null,wt=!1,kt=ct(),Et=1e4>kt?ct:function(){return ct()-kt};function Tt(){switch(ft()){case dt:return 99;case pt:return 98;case ht:return 97;case gt:return 96;case mt:return 95;default:throw Error("Unknown priority level.")}}function xt(e){switch(e){case 99:return dt;case 98:return pt;case 97:return ht;case 96:return gt;case 95:return mt;default:throw Error("Unknown priority level.")}}function _t(e,n){return e=xt(e),at(e,n)}function Rt(e,n,t){return e=xt(e),it(e,n,t)}function Pt(){if(null!==St){var e=St;St=null,ut(e)}Ct()}function Ct(){if(!wt&&null!==bt){wt=!0;var e=0;try{var n=bt;_t(99,function(){for(;e<n.length;e++){var t=n[e];do{t=t(!0)}while(null!==t)}}),bt=null}catch(n){throw null!==bt&&(bt=bt.slice(e+1)),it(dt,Pt),n}finally{wt=!1}}}var Nt=Ie.ReactCurrentBatchConfig;var zt="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},It=Object.prototype.hasOwnProperty;function Lt(e,n){if(zt(e,n))return!0;if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(r=0;r<t.length;r++)if(!It.call(n,t[r])||!zt(e[t[r]],n[t[r]]))return!1;return!0}function Ut(e){switch(e.tag){case 5:return _n(e.type,null,null);case 16:return _n("Lazy",null,null);case 13:return _n("Suspense",null,null);case 19:return _n("SuspenseList",null,null);case 0:case 2:case 15:return Rn(e.type,null);case 11:return Rn(e.type.render,null);case 22:return Rn(e.type._render,null);case 1:return e=Rn(e.type,null);default:return""}}function Mt(e){try{var n="";do{n+=Ut(e),e=e.return}while(e);return n}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}function At(e,n){if(e&&e.defaultProps){for(var t in n=u({},n),e=e.defaultProps)void 0===n[t]&&(n[t]=e[t]);return n}return n}var Dt=Nn(null),Qt=null,Bt=null,Ft=null;function jt(){Ft=Bt=Qt=null}function Ot(e){var n=Dt.current;zn(Dt),e.type._context._currentValue=n}function Ht(e,n){for(;null!==e;){var t=e.alternate;if((e.childLanes&n)===n){if(null===t||(t.childLanes&n)===n)break;t.childLanes|=n}else e.childLanes|=n,null!==t&&(t.childLanes|=n);e=e.return}}function Vt(e,n){Qt=e,Ft=Bt=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!=(e.lanes&n)&&(fl=!0),e.firstContext=null)}function Wt(e,n){if(Ft!==e&&!1!==n&&0!==n)if("number"==typeof n&&1073741823!==n||(Ft=e,n=1073741823),n={context:e,observedBits:n,next:null},null===Bt){if(null===Qt)throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");Bt=n,Qt.dependencies={lanes:0,firstContext:n,responders:null}}else Bt=Bt.next=n;return e._currentValue}var Yt=!1;function qt(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null},effects:null}}function Xt(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Gt(e,n){if(null!==(e=e.updateQueue)){var t=(e=e.shared).pending;null===t?n.next=n:(n.next=t.next,t.next=n),e.pending=n}}function Kt(e,n){var t=e.updateQueue,r=e.alternate;if(null!==r&&t===(r=r.updateQueue)){var l=null,a=null;if(null!==(t=t.firstBaseUpdate)){do{var i={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};null===a?l=a=i:a=a.next=i,t=t.next}while(null!==t);null===a?l=a=n:a=a.next=n}else l=a=n;return t={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:a,shared:r.shared,effects:r.effects},void(e.updateQueue=t)}null===(e=t.lastBaseUpdate)?t.firstBaseUpdate=n:e.next=n,t.lastBaseUpdate=n}function Jt(e,n,t,r){var l=e.updateQueue;Yt=!1;var a=l.firstBaseUpdate,i=l.lastBaseUpdate,o=l.shared.pending;if(null!==o){l.shared.pending=null;var s=o,c=s.next;s.next=null,null===i?a=c:i.next=c,i=s;var f=e.alternate;if(null!==f){var d=(f=f.updateQueue).lastBaseUpdate;d!==i&&(null===d?f.firstBaseUpdate=c:d.next=c,f.lastBaseUpdate=s)}}if(null!==a){for(d=l.baseState,i=0,f=c=s=null;;){o=a.lane;var p=a.eventTime;if((r&o)===o){null!==f&&(f=f.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var h=e,g=a;switch(o=n,p=t,g.tag){case 1:if("function"==typeof(h=g.payload)){d=h.call(p,d,o);break e}d=h;break e;case 3:h.flags=-8193&h.flags|64;case 0:if(null===(o="function"==typeof(h=g.payload)?h.call(p,d,o):h)||void 0===o)break e;d=u({},d,o);break e;case 2:Yt=!0}}null!==a.callback&&(e.flags|=32,null===(o=l.effects)?l.effects=[a]:o.push(a))}else p={eventTime:p,lane:o,tag:a.tag,payload:a.payload,callback:a.callback,next:null},null===f?(c=f=p,s=d):f=f.next=p,i|=o;if(null===(a=a.next)){if(null===(o=l.shared.pending))break;a=o.next,o.next=null,l.lastBaseUpdate=o,l.shared.pending=null}}null===f&&(s=d),l.baseState=s,l.firstBaseUpdate=c,l.lastBaseUpdate=f,va|=i,e.lanes=i,e.memoizedState=d}}function Zt(e,n,t){if(e=n.effects,n.effects=null,null!==e)for(n=0;n<e.length;n++){var r=e[n],l=r.callback;if(null!==l){if(r.callback=null,"function"!=typeof l)throw Error("Invalid argument passed as callback. Expected a function. Instead received: "+l);l.call(t)}}}var er=(new s.Component).refs;function nr(e,n,t,r){t=null===(t=t(r,n=e.memoizedState))||void 0===t?n:u({},n,t),e.memoizedState=t,0===e.lanes&&(e.updateQueue.baseState=t)}var tr={isMounted:function(e){return!!(e=e._reactInternals)&&Ze(e)===e},enqueueSetState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=Fa(),l=ja(e),a=$t(r,l);a.tag=1,a.payload=n,void 0!==t&&null!==t&&(a.callback=t),Gt(e,a),Oa(e,l,r)},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=Fa(),r=ja(e),l=$t(t,r);l.tag=2,void 0!==n&&null!==n&&(l.callback=n),Gt(e,l),Oa(e,r,t)}};function rr(e,n,t,r,l,a,i){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,a,i):!n.prototype||!n.prototype.isPureReactComponent||(!Lt(t,r)||!Lt(l,a))}function lr(e,n,t){var r=!1,l=Ln,a=n.contextType;return"object"==typeof a&&null!==a?a=Wt(a):(l=Qn(n)?An:Un.current,a=(r=null!==(r=n.contextTypes)&&void 0!==r)?Dn(e,l):Ln),n=new n(t,a),e.memoizedState=null!==n.state&&void 0!==n.state?n.state:null,n.updater=tr,e.stateNode=n,n._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=a),n}function ar(e,n,t,r){e=n.state,"function"==typeof n.componentWillReceiveProps&&n.componentWillReceiveProps(t,r),"function"==typeof n.UNSAFE_componentWillReceiveProps&&n.UNSAFE_componentWillReceiveProps(t,r),n.state!==e&&tr.enqueueReplaceState(n,n.state,null)}function ir(e,n,t,r){var l=e.stateNode;l.props=t,l.state=e.memoizedState,l.refs=er,qt(e);var a=n.contextType;"object"==typeof a&&null!==a?l.context=Wt(a):(a=Qn(n)?An:Un.current,l.context=Dn(e,a)),Jt(e,t,l,r),l.state=e.memoizedState,"function"==typeof(a=n.getDerivedStateFromProps)&&(nr(e,n,a,t),l.state=e.memoizedState),"function"==typeof n.getDerivedStateFromProps||"function"==typeof l.getSnapshotBeforeUpdate||"function"!=typeof l.UNSAFE_componentWillMount&&"function"!=typeof l.componentWillMount||(n=l.state,"function"==typeof l.componentWillMount&&l.componentWillMount(),"function"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),n!==l.state&&tr.enqueueReplaceState(l,l.state,null),Jt(e,t,l,r),l.state=e.memoizedState),"function"==typeof l.componentDidMount&&(e.flags|=4)}var ur=Array.isArray;function or(e,n,t){if(null!==(e=t.ref)&&"function"!=typeof e&&"object"!=typeof e){if(t._owner){if(t=t._owner){if(1!==t.tag)throw Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");var r=t.stateNode}if(!r)throw Error("Missing owner for string ref "+e+". This error is likely caused by a bug in React. Please file an issue.");var l=""+e;return null!==n&&null!==n.ref&&"function"==typeof n.ref&&n.ref._stringRef===l?n.ref:((n=function(e){var n=r.refs;n===er&&(n=r.refs={}),null===e?delete n[l]:n[l]=e})._stringRef=l,n)}if("string"!=typeof e)throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");if(!t._owner)throw Error("Element ref was specified as a string ("+e+") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information.")}return e}function sr(e,n){if("textarea"!==e.type)throw Error("Objects are not valid as a React child (found: "+("[object Object]"===Object.prototype.toString.call(n)?"object with keys {"+Object.keys(n).join(", ")+"}":n)+"). If you meant to render a collection of children, use an array instead.")}function cr(e){function n(n,t){if(e){var r=n.lastEffect;null!==r?(r.nextEffect=t,n.lastEffect=t):n.firstEffect=n.lastEffect=t,t.nextEffect=null,t.flags=8}}function t(t,r){if(!e)return null;for(;null!==r;)n(t,r),r=r.sibling;return null}function r(e,n){for(e=new Map;null!==n;)null!==n.key?e.set(n.key,n):e.set(n.index,n),n=n.sibling;return e}function l(e,n){return(e=bi(e,n)).index=0,e.sibling=null,e}function a(n,t,r){return n.index=r,e?null!==(r=n.alternate)?(r=r.index)<t?(n.flags=2,t):r:(n.flags=2,t):t}function i(n){return e&&null===n.alternate&&(n.flags=2),n}function u(e,n,t,r){return null===n||6!==n.tag?((n=Ei(t,e.mode,r)).return=e,n):((n=l(n,t)).return=e,n)}function o(e,n,t,r){return null!==n&&n.elementType===t.type?((r=l(n,t.props)).ref=or(e,n,t),r.return=e,r):((r=Si(t.type,t.key,t.props,null,e.mode,r)).ref=or(e,n,t),r.return=e,r)}function s(e,n,t,r){return null===n||4!==n.tag||n.stateNode.containerInfo!==t.containerInfo||n.stateNode.implementation!==t.implementation?((n=Ti(t,e.mode,r)).return=e,n):((n=l(n,t.children||[])).return=e,n)}function c(e,n,t,r,a){return null===n||7!==n.tag?((n=wi(t,e.mode,r,a)).return=e,n):((n=l(n,t)).return=e,n)}function f(e,n,t){if("string"==typeof n||"number"==typeof n)return(n=Ei(""+n,e.mode,t)).return=e,n;if("object"==typeof n&&null!==n){switch(n.$$typeof){case Le:return(t=Si(n.type,n.key,n.props,null,e.mode,t)).ref=or(e,null,n),t.return=e,t;case Ue:return(n=Ti(n,e.mode,t)).return=e,n}if(ur(n)||Ke(n))return(n=wi(n,e.mode,t,null)).return=e,n;sr(e,n)}return null}function d(e,n,t,r){var l=null!==n?n.key:null;if("string"==typeof t||"number"==typeof t)return null!==l?null:u(e,n,""+t,r);if("object"==typeof t&&null!==t){switch(t.$$typeof){case Le:return t.key===l?t.type===Me?c(e,n,t.props.children,r,l):o(e,n,t,r):null;case Ue:return t.key===l?s(e,n,t,r):null}if(ur(t)||Ke(t))return null!==l?null:c(e,n,t,r,null);sr(e,t)}return null}function p(e,n,t,r,l){if("string"==typeof r||"number"==typeof r)return u(n,e=e.get(t)||null,""+r,l);if("object"==typeof r&&null!==r){switch(r.$$typeof){case Le:return e=e.get(null===r.key?t:r.key)||null,r.type===Me?c(n,e,r.props.children,l,r.key):o(n,e,r,l);case Ue:return s(n,e=e.get(null===r.key?t:r.key)||null,r,l)}if(ur(r)||Ke(r))return c(n,e=e.get(t)||null,r,l,null);sr(n,r)}return null}function h(l,i,u,o){for(var s=null,c=null,h=i,g=i=0,m=null;null!==h&&g<u.length;g++){h.index>g?(m=h,h=null):m=h.sibling;var v=d(l,h,u[g],o);if(null===v){null===h&&(h=m);break}e&&h&&null===v.alternate&&n(l,h),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v,h=m}if(g===u.length)return t(l,h),s;if(null===h){for(;g<u.length;g++)null!==(h=f(l,u[g],o))&&(i=a(h,i,g),null===c?s=h:c.sibling=h,c=h);return s}for(h=r(l,h);g<u.length;g++)null!==(m=p(h,l,g,u[g],o))&&(e&&null!==m.alternate&&h.delete(null===m.key?g:m.key),i=a(m,i,g),null===c?s=m:c.sibling=m,c=m);return e&&h.forEach(function(e){return n(l,e)}),s}function g(l,i,u,o){var s=Ke(u);if("function"!=typeof s)throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");if(null==(u=s.call(u)))throw Error("An iterable object provided no iterator.");for(var c=s=null,h=i,g=i=0,m=null,v=u.next();null!==h&&!v.done;g++,v=u.next()){h.index>g?(m=h,h=null):m=h.sibling;var y=d(l,h,v.value,o);if(null===y){null===h&&(h=m);break}e&&h&&null===y.alternate&&n(l,h),i=a(y,i,g),null===c?s=y:c.sibling=y,c=y,h=m}if(v.done)return t(l,h),s;if(null===h){for(;!v.done;g++,v=u.next())null!==(v=f(l,v.value,o))&&(i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return s}for(h=r(l,h);!v.done;g++,v=u.next())null!==(v=p(h,l,g,v.value,o))&&(e&&null!==v.alternate&&h.delete(null===v.key?g:v.key),i=a(v,i,g),null===c?s=v:c.sibling=v,c=v);return e&&h.forEach(function(e){return n(l,e)}),s}return function(e,r,a,u){var o="object"==typeof a&&null!==a&&a.type===Me&&null===a.key;o&&(a=a.props.children);var s="object"==typeof a&&null!==a;if(s)switch(a.$$typeof){case Le:e:{for(s=a.key,o=r;null!==o;){if(o.key===s){switch(o.tag){case 7:if(a.type===Me){t(e,o.sibling),(r=l(o,a.props.children)).return=e,e=r;break e}break;default:if(o.elementType===a.type){t(e,o.sibling),(r=l(o,a.props)).ref=or(e,o,a),r.return=e,e=r;break e}}t(e,o);break}n(e,o),o=o.sibling}a.type===Me?((r=wi(a.props.children,e.mode,u,a.key)).return=e,e=r):((u=Si(a.type,a.key,a.props,null,e.mode,u)).ref=or(e,r,a),u.return=e,e=u)}return i(e);case Ue:e:{for(o=a.key;null!==r;){if(r.key===o){if(4===r.tag&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){t(e,r.sibling),(r=l(r,a.children||[])).return=e,e=r;break e}t(e,r);break}n(e,r),r=r.sibling}(r=Ti(a,e.mode,u)).return=e,e=r}return i(e)}if("string"==typeof a||"number"==typeof a)return a=""+a,null!==r&&6===r.tag?(t(e,r.sibling),(r=l(r,a)).return=e,e=r):(t(e,r),(r=Ei(a,e.mode,u)).return=e,e=r),i(e);if(ur(a))return h(e,r,a,u);if(Ke(a))return g(e,r,a,u);if(s&&sr(e,a),void 0===a&&!o)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error((Je(e.type)||"Component")+"(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.")}return t(e,r)}}var fr=cr(!0),dr=cr(!1),pr={},hr=Nn(pr),gr=Nn(pr),mr=Nn(pr);function vr(e){if(e===pr)throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");return e}function yr(e,n){In(mr,n),In(gr,e),In(hr,pr),zn(hr),In(hr,{isInAParentText:!1})}function br(){zn(hr),zn(gr),zn(mr)}function Sr(e){vr(mr.current);var n=vr(hr.current),t=e.type;t="AndroidTextInput"===t||"RCTMultilineTextInputView"===t||"RCTSinglelineTextInputView"===t||"RCTText"===t||"RCTVirtualText"===t,n!==(t=n.isInAParentText!==t?{isInAParentText:t}:n)&&(In(gr,e),In(hr,t))}function wr(e){gr.current===e&&(zn(hr),zn(gr))}var kr=Nn(0);function Er(e){for(var n=e;null!==n;){if(13===n.tag){var t=n.memoizedState;if(null!==t&&(null===t.dehydrated||vn()||vn()))return n}else if(19===n.tag&&void 0!==n.memoizedProps.revealOrder){if(0!=(64&n.flags))return n}else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===e)break;for(;null===n.sibling;){if(null===n.return||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var Tr=[];function xr(){for(var e=0;e<Tr.length;e++)Tr[e]._workInProgressVersionPrimary=null;Tr.length=0}var _r=Ie.ReactCurrentDispatcher,Rr=Ie.ReactCurrentBatchConfig,Pr=0,Cr=null,Nr=null,zr=null,Ir=!1,Lr=!1;function Ur(){throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.")}function Mr(e,n){if(null===n)return!1;for(var t=0;t<n.length&&t<e.length;t++)if(!zt(e[t],n[t]))return!1;return!0}function Ar(e,n,t,r,l,a){if(Pr=a,Cr=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,_r.current=null===e||null===e.memoizedState?ul:ol,e=t(r,l),Lr){a=0;do{if(Lr=!1,!(25>a))throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");a+=1,zr=Nr=null,n.updateQueue=null,_r.current=sl,e=t(r,l)}while(Lr)}if(_r.current=il,n=null!==Nr&&null!==Nr.next,Pr=0,zr=Nr=Cr=null,Ir=!1,n)throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");return e}function Dr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===zr?Cr.memoizedState=zr=e:zr=zr.next=e,zr}function Qr(){if(null===Nr){var e=Cr.alternate;e=null!==e?e.memoizedState:null}else e=Nr.next;var n=null===zr?Cr.memoizedState:zr.next;if(null!==n)zr=n,Nr=e;else{if(null===e)throw Error("Rendered more hooks than during the previous render.");e={memoizedState:(Nr=e).memoizedState,baseState:Nr.baseState,baseQueue:Nr.baseQueue,queue:Nr.queue,next:null},null===zr?Cr.memoizedState=zr=e:zr=zr.next=e}return zr}function Br(e,n){return"function"==typeof n?n(e):n}function Fr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=Nr,l=r.baseQueue,a=t.pending;if(null!==a){if(null!==l){var i=l.next;l.next=a.next,a.next=i}r.baseQueue=l=a,t.pending=null}if(null!==l){l=l.next,r=r.baseState;var u=i=a=null,o=l;do{var s=o.lane;if((Pr&s)===s)null!==u&&(u=u.next={lane:0,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null}),r=o.eagerReducer===e?o.eagerState:e(r,o.action);else{var c={lane:s,action:o.action,eagerReducer:o.eagerReducer,eagerState:o.eagerState,next:null};null===u?(i=u=c,a=r):u=u.next=c,Cr.lanes|=s,va|=s}o=o.next}while(null!==o&&o!==l);null===u?a=r:u.next=i,zt(r,n.memoizedState)||(fl=!0),n.memoizedState=r,n.baseState=a,n.baseQueue=u,t.lastRenderedState=r}return[n.memoizedState,t.dispatch]}function jr(e){var n=Qr(),t=n.queue;if(null===t)throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");t.lastRenderedReducer=e;var r=t.dispatch,l=t.pending,a=n.memoizedState;if(null!==l){t.pending=null;var i=l=l.next;do{a=e(a,i.action),i=i.next}while(i!==l);zt(a,n.memoizedState)||(fl=!0),n.memoizedState=a,null===n.baseQueue&&(n.baseState=a),t.lastRenderedState=a}return[a,r]}function Or(e,n,t){var r=n._getVersion;r=r(n._source);var l=n._workInProgressVersionPrimary;if(null!==l?e=l===r:(e=e.mutableReadLanes,(e=(Pr&e)===e)&&(n._workInProgressVersionPrimary=r,Tr.push(n))),e)return t(n._source);throw Tr.push(n),Error("Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.")}function Hr(e,n,t,r){var l=sa;if(null===l)throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");var a=n._getVersion,i=a(n._source),u=_r.current,o=u.useState(function(){return Or(l,n,t)}),s=o[1],c=o[0];o=zr;var f=e.memoizedState,d=f.refs,p=d.getSnapshot,h=f.source;f=f.subscribe;var g=Cr;return e.memoizedState={refs:d,source:n,subscribe:r},u.useEffect(function(){d.getSnapshot=t,d.setSnapshot=s;var e=a(n._source);if(!zt(i,e)){e=t(n._source),zt(c,e)||(s(e),e=ja(g),l.mutableReadLanes|=e&l.pendingLanes),e=l.mutableReadLanes,l.entangledLanes|=e;for(var r=l.entanglements,u=e;0<u;){var o=31-tt(u),f=1<<o;r[o]|=e,u&=~f}}},[t,n,r]),u.useEffect(function(){return r(n._source,function(){var e=d.getSnapshot,t=d.setSnapshot;try{t(e(n._source));var r=ja(g);l.mutableReadLanes|=r&l.pendingLanes}catch(e){t(function(){throw e})}})},[n,r]),zt(p,t)&&zt(h,n)&&zt(f,r)||((e={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:c}).dispatch=s=al.bind(null,Cr,e),o.queue=e,o.baseQueue=null,c=Or(l,n,t),o.memoizedState=o.baseState=c),c}function Vr(e,n,t){return Hr(Qr(),e,n,t)}function Wr(e){var n=Dr();return"function"==typeof e&&(e=e()),n.memoizedState=n.baseState=e,e=(e=n.queue={pending:null,dispatch:null,lastRenderedReducer:Br,lastRenderedState:e}).dispatch=al.bind(null,Cr,e),[n.memoizedState,e]}function Yr(e,n,t,r){return e={tag:e,create:n,destroy:t,deps:r,next:null},null===(n=Cr.updateQueue)?(n={lastEffect:null},Cr.updateQueue=n,n.lastEffect=e.next=e):null===(t=n.lastEffect)?n.lastEffect=e.next=e:(r=t.next,t.next=e,e.next=r,n.lastEffect=e),e}function qr(){return Qr().memoizedState}function Xr(e,n,t,r){var l=Dr();Cr.flags|=e,l.memoizedState=Yr(1|n,t,void 0,void 0===r?null:r)}function $r(e,n,t,r){var l=Qr();r=void 0===r?null:r;var a=void 0;if(null!==Nr){var i=Nr.memoizedState;if(a=i.destroy,null!==r&&Mr(r,i.deps))return void Yr(n,t,a,r)}Cr.flags|=e,l.memoizedState=Yr(1|n,t,a,r)}function Gr(e,n){return Xr(516,4,e,n)}function Kr(e,n){return $r(516,4,e,n)}function Jr(e,n){return $r(4,2,e,n)}function Zr(e,n){return"function"==typeof n?(e=e(),n(e),function(){n(null)}):null!==n&&void 0!==n?(e=e(),n.current=e,function(){n.current=null}):void 0}function el(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,$r(4,2,Zr.bind(null,n,e),t)}function nl(){}function tl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(t.memoizedState=[e,n],e)}function rl(e,n){var t=Qr();n=void 0===n?null:n;var r=t.memoizedState;return null!==r&&null!==n&&Mr(n,r[1])?r[0]:(e=e(),t.memoizedState=[e,n],e)}function ll(e,n){var t=Tt();_t(98>t?98:t,function(){e(!0)}),_t(97<t?97:t,function(){var t=Rr.transition;Rr.transition=1;try{e(!1),n()}finally{Rr.transition=t}})}function al(e,n,t){var r=Fa(),l=ja(e),a={lane:l,action:t,eagerReducer:null,eagerState:null,next:null},i=n.pending;if(null===i?a.next=a:(a.next=i.next,i.next=a),n.pending=a,i=e.alternate,e===Cr||null!==i&&i===Cr)Lr=Ir=!0;else{if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=n.lastRenderedReducer))try{var u=n.lastRenderedState,o=i(u,t);if(a.eagerReducer=i,a.eagerState=o,zt(o,u))return}catch(e){}Oa(e,l,r)}}var il={readContext:Wt,useCallback:Ur,useContext:Ur,useEffect:Ur,useImperativeHandle:Ur,useLayoutEffect:Ur,useMemo:Ur,useReducer:Ur,useRef:Ur,useState:Ur,useDebugValue:Ur,useDeferredValue:Ur,useTransition:Ur,useMutableSource:Ur,useOpaqueIdentifier:Ur,unstable_isNewReconciler:!1},ul={readContext:Wt,useCallback:function(e,n){return Dr().memoizedState=[e,void 0===n?null:n],e},useContext:Wt,useEffect:Gr,useImperativeHandle:function(e,n,t){return t=null!==t&&void 0!==t?t.concat([e]):null,Xr(4,2,Zr.bind(null,n,e),t)},useLayoutEffect:function(e,n){return Xr(4,2,e,n)},useMemo:function(e,n){var t=Dr();return n=void 0===n?null:n,e=e(),t.memoizedState=[e,n],e},useReducer:function(e,n,t){var r=Dr();return n=void 0!==t?t(n):n,r.memoizedState=r.baseState=n,e=(e=r.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:n}).dispatch=al.bind(null,Cr,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},Dr().memoizedState=e},useState:Wr,useDebugValue:nl,useDeferredValue:function(e){var n=Wr(e),t=n[0],r=n[1];return Gr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Wr(!1),n=e[0];return e=ll.bind(null,e[1]),Dr().memoizedState=e,[e,n]},useMutableSource:function(e,n,t){var r=Dr();return r.memoizedState={refs:{getSnapshot:n,setSnapshot:null},source:e,subscribe:t},Hr(r,e,n,t)},useOpaqueIdentifier:function(){throw Error("Not yet implemented")},unstable_isNewReconciler:!1},ol={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:Fr,useRef:qr,useState:function(){return Fr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=Fr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=Fr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return Fr(Br)[0]},unstable_isNewReconciler:!1},sl={readContext:Wt,useCallback:tl,useContext:Wt,useEffect:Kr,useImperativeHandle:el,useLayoutEffect:Jr,useMemo:rl,useReducer:jr,useRef:qr,useState:function(){return jr(Br)},useDebugValue:nl,useDeferredValue:function(e){var n=jr(Br),t=n[0],r=n[1];return Kr(function(){var n=Rr.transition;Rr.transition=1;try{r(e)}finally{Rr.transition=n}},[e]),t},useTransition:function(){var e=jr(Br)[0];return[Qr().memoizedState,e]},useMutableSource:Vr,useOpaqueIdentifier:function(){return jr(Br)[0]},unstable_isNewReconciler:!1},cl=Ie.ReactCurrentOwner,fl=!1;function dl(e,n,t,r){n.child=null===e?dr(n,null,t,r):fr(n,e.child,t,r)}function pl(e,n,t,r,l){t=t.render;var a=n.ref;return Vt(n,l),r=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,r,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function hl(e,n,t,r,l,a){if(null===e){var i=t.type;return"function"!=typeof i||vi(i)||void 0!==i.defaultProps||null!==t.compare||void 0!==t.defaultProps?((e=Si(t.type,null,r,n,n.mode,a)).ref=n.ref,e.return=n,n.child=e):(n.tag=15,n.type=i,gl(e,n,i,r,l,a))}return i=e.child,0==(l&a)&&(l=i.memoizedProps,(t=null!==(t=t.compare)?t:Lt)(l,r)&&e.ref===n.ref)?Ul(e,n,a):(n.flags|=1,(e=bi(i,r)).ref=n.ref,e.return=n,n.child=e)}function gl(e,n,t,r,l,a){if(null!==e&&Lt(e.memoizedProps,r)&&e.ref===n.ref){if(fl=!1,0==(a&l))return n.lanes=e.lanes,Ul(e,n,a);0!=(32768&e.flags)&&(fl=!0)}return yl(e,n,t,r,a)}function ml(e,n,t){var r=n.pendingProps,l=r.children,a=null!==e?e.memoizedState:null;if("hidden"===r.mode||"unstable-defer-without-hiding"===r.mode)if(0==(4&n.mode))n.memoizedState={baseLanes:0},Xa(n,t);else{if(0==(1073741824&t))return e=null!==a?a.baseLanes|t:t,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e},Xa(n,e),null;n.memoizedState={baseLanes:0},Xa(n,null!==a?a.baseLanes:t)}else null!==a?(r=a.baseLanes|t,n.memoizedState=null):r=t,Xa(n,r);return dl(e,n,l,t),n.child}function vl(e,n){var t=n.ref;(null===e&&null!==t||null!==e&&e.ref!==t)&&(n.flags|=128)}function yl(e,n,t,r,l){var a=Qn(t)?An:Un.current;return a=Dn(n,a),Vt(n,l),t=Ar(e,n,t,r,a,l),null===e||fl?(n.flags|=1,dl(e,n,t,l),n.child):(n.updateQueue=e.updateQueue,n.flags&=-517,e.lanes&=~l,Ul(e,n,l))}function bl(e,n,t,r,l){if(Qn(t)){var a=!0;On(n)}else a=!1;if(Vt(n,l),null===n.stateNode)null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),lr(n,t,r),ir(n,t,r,l),r=!0;else if(null===e){var i=n.stateNode,u=n.memoizedProps;i.props=u;var o=i.context,s=t.contextType;"object"==typeof s&&null!==s?s=Wt(s):s=Dn(n,s=Qn(t)?An:Un.current);var c=t.getDerivedStateFromProps,f="function"==typeof c||"function"==typeof i.getSnapshotBeforeUpdate;f||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==r||o!==s)&&ar(n,i,r,s),Yt=!1;var d=n.memoizedState;i.state=d,Jt(n,r,i,l),o=n.memoizedState,u!==r||d!==o||Mn.current||Yt?("function"==typeof c&&(nr(n,t,c,r),o=n.memoizedState),(u=Yt||rr(n,t,u,r,d,o,s))?(f||"function"!=typeof i.UNSAFE_componentWillMount&&"function"!=typeof i.componentWillMount||("function"==typeof i.componentWillMount&&i.componentWillMount(),"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount()),"function"==typeof i.componentDidMount&&(n.flags|=4)):("function"==typeof i.componentDidMount&&(n.flags|=4),n.memoizedProps=r,n.memoizedState=o),i.props=r,i.state=o,i.context=s,r=u):("function"==typeof i.componentDidMount&&(n.flags|=4),r=!1)}else{i=n.stateNode,Xt(e,n),u=n.memoizedProps,s=n.type===n.elementType?u:At(n.type,u),i.props=s,f=n.pendingProps,d=i.context,"object"==typeof(o=t.contextType)&&null!==o?o=Wt(o):o=Dn(n,o=Qn(t)?An:Un.current);var p=t.getDerivedStateFromProps;(c="function"==typeof p||"function"==typeof i.getSnapshotBeforeUpdate)||"function"!=typeof i.UNSAFE_componentWillReceiveProps&&"function"!=typeof i.componentWillReceiveProps||(u!==f||d!==o)&&ar(n,i,r,o),Yt=!1,d=n.memoizedState,i.state=d,Jt(n,r,i,l);var h=n.memoizedState;u!==f||d!==h||Mn.current||Yt?("function"==typeof p&&(nr(n,t,p,r),h=n.memoizedState),(s=Yt||rr(n,t,s,r,d,h,o))?(c||"function"!=typeof i.UNSAFE_componentWillUpdate&&"function"!=typeof i.componentWillUpdate||("function"==typeof i.componentWillUpdate&&i.componentWillUpdate(r,h,o),"function"==typeof i.UNSAFE_componentWillUpdate&&i.UNSAFE_componentWillUpdate(r,h,o)),"function"==typeof i.componentDidUpdate&&(n.flags|=4),"function"==typeof i.getSnapshotBeforeUpdate&&(n.flags|=256)):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),n.memoizedProps=r,n.memoizedState=h),i.props=r,i.state=h,i.context=o,r=s):("function"!=typeof i.componentDidUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=4),"function"!=typeof i.getSnapshotBeforeUpdate||u===e.memoizedProps&&d===e.memoizedState||(n.flags|=256),r=!1)}return Sl(e,n,t,r,a,l)}function Sl(e,n,t,r,l,a){vl(e,n);var i=0!=(64&n.flags);if(!r&&!i)return l&&Hn(n,t,!1),Ul(e,n,a);r=n.stateNode,cl.current=n;var u=i&&"function"!=typeof t.getDerivedStateFromError?null:r.render();return n.flags|=1,null!==e&&i?(n.child=fr(n,e.child,null,a),n.child=fr(n,null,u,a)):dl(e,n,u,a),n.memoizedState=r.state,l&&Hn(n,t,!0),n.child}function wl(e){var n=e.stateNode;n.pendingContext?Fn(0,n.pendingContext,n.pendingContext!==n.context):n.context&&Fn(0,n.context,!1),yr(e,n.containerInfo)}var kl,El,Tl,xl,_l={dehydrated:null,retryLane:0};function Rl(e,n,t){var r,l=n.pendingProps,a=kr.current,i=!1;return(r=0!=(64&n.flags))||(r=(null===e||null!==e.memoizedState)&&0!=(2&a)),r?(i=!0,n.flags&=-65):null!==e&&null===e.memoizedState||void 0===l.fallback||!0===l.unstable_avoidThisFallback||(a|=1),In(kr,1&a),null===e?(e=l.children,a=l.fallback,i?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,e):"number"==typeof l.unstable_expectedLoadTime?(e=Pl(n,e,a,t),n.child.memoizedState={baseLanes:t},n.memoizedState=_l,n.lanes=33554432,e):((t=ki({mode:"visible",children:e},n.mode,t,null)).return=n,n.child=t)):(e.memoizedState,i?(l=Nl(e,n,l.children,l.fallback,t),i=n.child,a=e.child.memoizedState,i.memoizedState=null===a?{baseLanes:t}:{baseLanes:a.baseLanes|t},i.childLanes=e.childLanes&~t,n.memoizedState=_l,l):(t=Cl(e,n,l.children,t),n.memoizedState=null,t))}function Pl(e,n,t,r){var l=e.mode,a=e.child;return n={mode:"hidden",children:n},0==(2&l)&&null!==a?(a.childLanes=0,a.pendingProps=n):a=ki(n,l,0,null),t=wi(t,l,r,null),a.return=e,t.return=e,a.sibling=t,e.child=a,t}function Cl(e,n,t,r){var l=e.child;return e=l.sibling,t=bi(l,{mode:"visible",children:t}),0==(2&n.mode)&&(t.lanes=r),t.return=n,t.sibling=null,null!==e&&(e.nextEffect=null,e.flags=8,n.firstEffect=n.lastEffect=e),n.child=t}function Nl(e,n,t,r,l){var a=n.mode,i=e.child;e=i.sibling;var u={mode:"hidden",children:t};return 0==(2&a)&&n.child!==i?((t=n.child).childLanes=0,t.pendingProps=u,null!==(i=t.lastEffect)?(n.firstEffect=t.firstEffect,n.lastEffect=i,i.nextEffect=null):n.firstEffect=n.lastEffect=null):t=bi(i,u),null!==e?r=bi(e,r):(r=wi(r,a,l,null)).flags|=2,r.return=n,t.return=n,t.sibling=r,n.child=t,r}function zl(e,n){e.lanes|=n;var t=e.alternate;null!==t&&(t.lanes|=n),Ht(e.return,n)}function Il(e,n,t,r,l,a){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:r,tail:t,tailMode:l,lastEffect:a}:(i.isBackwards=n,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=t,i.tailMode=l,i.lastEffect=a)}function Ll(e,n,t){var r=n.pendingProps,l=r.revealOrder,a=r.tail;if(dl(e,n,r.children,t),0!=(2&(r=kr.current)))r=1&r|2,n.flags|=64;else{if(null!==e&&0!=(64&e.flags))e:for(e=n.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zl(e,t);else if(19===e.tag)zl(e,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;null===e.sibling;){if(null===e.return||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(In(kr,r),0==(2&n.mode))n.memoizedState=null;else switch(l){case"forwards":for(t=n.child,l=null;null!==t;)null!==(e=t.alternate)&&null===Er(e)&&(l=t),t=t.sibling;null===(t=l)?(l=n.child,n.child=null):(l=t.sibling,t.sibling=null),Il(n,!1,l,t,a,n.lastEffect);break;case"backwards":for(t=null,l=n.child,n.child=null;null!==l;){if(null!==(e=l.alternate)&&null===Er(e)){n.child=l;break}e=l.sibling,l.sibling=t,t=l,l=e}Il(n,!0,t,null,a,n.lastEffect);break;case"together":Il(n,!1,null,null,void 0,n.lastEffect);break;default:n.memoizedState=null}return n.child}function Ul(e,n,t){if(null!==e&&(n.dependencies=e.dependencies),va|=n.lanes,0!=(t&n.childLanes)){if(null!==e&&n.child!==e.child)throw Error("Resuming work not yet implemented.");if(null!==n.child){for(t=bi(e=n.child,e.pendingProps),n.child=t,t.return=n;null!==e.sibling;)e=e.sibling,(t=t.sibling=bi(e,e.pendingProps)).return=n;t.sibling=null}return n.child}return null}function Ml(e,n){switch(e.tailMode){case"hidden":n=e.tail;for(var t=null;null!==n;)null!==n.alternate&&(t=n),n=n.sibling;null===t?e.tail=null:t.sibling=null;break;case"collapsed":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?n||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Al(e,n,t){var r=n.pendingProps;switch(n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:return Qn(n.type)&&Bn(),null;case 3:return br(),zn(Mn),zn(Un),xr(),(r=n.stateNode).pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||r.hydrate||(n.flags|=256),El(n),null;case 5:wr(n);var l=vr(mr.current);if(t=n.type,null!==e&&null!=n.stateNode)Tl(e,n,t,r,l),e.ref!==n.ref&&(n.flags|=128);else{if(!r){if(null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");return null}vr(hr.current),e=wn(),t=yn(t);var a=hn(null,ln,r,t.validAttributes);o.UIManager.createView(e,t.uiViewClassName,l,a),l=new mn(e,t,n),ke.set(e,n),Ee.set(e,r),kl(l,n,!1,!1),n.stateNode=l,En(l)&&(n.flags|=4),null!==n.ref&&(n.flags|=128)}return null;case 6:if(e&&null!=n.stateNode)xl(e,n,e.memoizedProps,r);else{if("string"!=typeof r&&null===n.stateNode)throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");if(e=vr(mr.current),!vr(hr.current).isInAParentText)throw Error("Text strings must be rendered within a <Text> component.");l=wn(),o.UIManager.createView(l,"RCTRawText",e,{text:r}),ke.set(l,n),n.stateNode=l}return null;case 13:return zn(kr),r=n.memoizedState,0!=(64&n.flags)?(n.lanes=t,n):(r=null!==r,l=!1,null!==e&&(l=null!==e.memoizedState),r&&!l&&0!=(2&n.mode)&&(null===e&&!0!==n.memoizedProps.unstable_avoidThisFallback||0!=(1&kr.current)?0===ha&&(ha=3):(0!==ha&&3!==ha||(ha=4),null===sa||0==(134217727&va)&&0==(134217727&ya)||Ya(sa,fa))),(r||l)&&(n.flags|=4),null);case 4:return br(),El(n),null;case 10:return Ot(n),null;case 17:return Qn(n.type)&&Bn(),null;case 19:if(zn(kr),null===(r=n.memoizedState))return null;if(l=0!=(64&n.flags),null===(a=r.rendering))if(l)Ml(r,!1);else{if(0!==ha||null!==e&&0!=(64&e.flags))for(e=n.child;null!==e;){if(null!==(a=Er(e))){for(n.flags|=64,Ml(r,!1),null!==(e=a.updateQueue)&&(n.updateQueue=e,n.flags|=4),null===r.lastEffect&&(n.firstEffect=null),n.lastEffect=r.lastEffect,e=t,r=n.child;null!==r;)t=e,(l=r).flags&=2,l.nextEffect=null,l.firstEffect=null,l.lastEffect=null,null===(a=l.alternate)?(l.childLanes=0,l.lanes=t,l.child=null,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=a.childLanes,l.lanes=a.lanes,l.child=a.child,l.memoizedProps=a.memoizedProps,l.memoizedState=a.memoizedState,l.updateQueue=a.updateQueue,l.type=a.type,t=a.dependencies,l.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return In(kr,1&kr.current|2),n.child}e=e.sibling}null!==r.tail&&Et()>ka&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432)}else{if(!l)if(null!==(e=Er(a))){if(n.flags|=64,l=!0,null!==(e=e.updateQueue)&&(n.updateQueue=e,n.flags|=4),Ml(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate)return null!==(n=n.lastEffect=r.lastEffect)&&(n.nextEffect=null),null}else 2*Et()-r.renderingStartTime>ka&&1073741824!==t&&(n.flags|=64,l=!0,Ml(r,!1),n.lanes=33554432);r.isBackwards?(a.sibling=n.child,n.child=a):(null!==(e=r.last)?e.sibling=a:n.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.lastEffect=n.lastEffect,r.renderingStartTime=Et(),e.sibling=null,n=kr.current,In(kr,l?1&n|2:1&n),e):null;case 23:case 24:return $a(),null!==e&&null!==e.memoizedState!=(null!==n.memoizedState)&&"unstable-defer-without-hiding"!==r.mode&&(n.flags|=4),null}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")}function Dl(e){switch(e.tag){case 1:Qn(e.type)&&Bn();var n=e.flags;return 8192&n?(e.flags=-8193&n|64,e):null;case 3:if(br(),zn(Mn),zn(Un),xr(),0!=(64&(n=e.flags)))throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");return e.flags=-8193&n|64,e;case 5:return wr(e),null;case 13:return zn(kr),8192&(n=e.flags)?(e.flags=-8193&n|64,e):null;case 19:return zn(kr),null;case 4:return br(),null;case 10:return Ot(e),null;case 23:case 24:return $a(),null;default:return null}}function Ql(e,n){return{value:e,source:n,stack:Mt(n)}}if(kl=function(e,n){for(var t=n.child;null!==t;){if(5===t.tag||6===t.tag)e._children.push(t.stateNode);else if(4!==t.tag&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===n)break;for(;null===t.sibling;){if(null===t.return||t.return===n)return;t=t.return}t.sibling.return=t.return,t=t.sibling}},El=function(){},Tl=function(e,n,t,r){e.memoizedProps!==r&&(vr(hr.current),n.updateQueue=bn)&&(n.flags|=4)},xl=function(e,n,t,r){t!==r&&(n.flags|=4)},"function"!=typeof o.ReactFiberErrorDialog.showErrorDialog)throw Error("Expected ReactFiberErrorDialog.showErrorDialog to be a function.");function Bl(e,n){try{!1!==o.ReactFiberErrorDialog.showErrorDialog({componentStack:null!==n.stack?n.stack:"",error:n.value,errorBoundary:null!==e&&1===e.tag?e.stateNode:null})&&console.error(n.value)}catch(e){setTimeout(function(){throw e})}}var Fl="function"==typeof WeakMap?WeakMap:Map;function jl(e,n,t){(t=$t(-1,t)).tag=3,t.payload={element:null};var r=n.value;return t.callback=function(){Ta||(Ta=!0,xa=r),Bl(e,n)},t}function Ol(e,n,t){(t=$t(-1,t)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var l=n.value;t.payload=function(){return Bl(e,n),r(l)}}var a=e.stateNode;return null!==a&&"function"==typeof a.componentDidCatch&&(t.callback=function(){"function"!=typeof r&&(null===_a?_a=new Set([this]):_a.add(this),Bl(e,n));var t=n.stack;this.componentDidCatch(n.value,{componentStack:null!==t?t:""})}),t}var Hl="function"==typeof WeakSet?WeakSet:Set;function Vl(e){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(n){di(e,n)}else n.current=null}function Wl(e,n){switch(n.tag){case 0:case 11:case 15:case 22:return;case 1:if(256&n.flags&&null!==e){var t=e.memoizedProps,r=e.memoizedState;n=(e=n.stateNode).getSnapshotBeforeUpdate(n.elementType===n.type?t:At(n.type,t),r),e.__reactInternalSnapshotBeforeUpdate=n}return;case 3:return;case 5:case 6:case 4:case 17:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function Yl(e,n,t){switch(t.tag){case 0:case 11:case 15:case 22:if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{if(3==(3&e.tag)){var r=e.create;e.destroy=r()}e=e.next}while(e!==n)}if(null!==(n=null!==(n=t.updateQueue)?n.lastEffect:null)){e=n=n.next;do{var l=e;r=l.next,0!=(4&(l=l.tag))&&0!=(1&l)&&(si(t,e),oi(t,e)),e=r}while(e!==n)}return;case 1:return e=t.stateNode,4&t.flags&&(null===n?e.componentDidMount():(r=t.elementType===t.type?n.memoizedProps:At(t.type,n.memoizedProps),e.componentDidUpdate(r,n.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),void(null!==(n=t.updateQueue)&&Zt(t,n,e));case 3:if(null!==(n=t.updateQueue)){if(e=null,null!==t.child)switch(t.child.tag){case 5:e=t.child.stateNode;break;case 1:e=t.child.stateNode}Zt(t,n,e)}return;case 5:case 6:case 4:case 12:case 13:return;case 19:case 17:case 20:case 21:case 23:case 24:return}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ql(e,n){for(var t=e;;){if(5===t.tag){var r=t.stateNode;if(n){var l=r.viewConfig,a=hn(null,ln,{style:{display:"none"}},l.validAttributes);o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}else{r=t.stateNode,a=t.memoizedProps,l=r.viewConfig,a=hn(null,u({},a,{style:[a.style,{display:"none"}]}),a,l.validAttributes),o.UIManager.updateView(r._nativeTag,l.uiViewClassName,a)}}else{if(6===t.tag)throw Error("Not yet implemented.");if((23!==t.tag&&24!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}}function Xl(e,n){if(Wn&&"function"==typeof Wn.onCommitFiberUnmount)try{Wn.onCommitFiberUnmount(Vn,n)}catch(e){}switch(n.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=n.updateQueue)&&null!==(e=e.lastEffect)){var t=e=e.next;do{var r=t,l=r.destroy;if(r=r.tag,void 0!==l)if(0!=(4&r))si(n,t);else{r=n;try{l()}catch(e){di(r,e)}}t=t.next}while(t!==e)}break;case 1:if(Vl(n),"function"==typeof(e=n.stateNode).componentWillUnmount)try{e.props=n.memoizedProps,e.state=n.memoizedState,e.componentWillUnmount()}catch(e){di(n,e)}break;case 5:Vl(n);break;case 4:ea(e,n)}}function $l(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}function Gl(e){return 5===e.tag||3===e.tag||4===e.tag}function Kl(e){e:{for(var n=e.return;null!==n;){if(Gl(n))break e;n=n.return}throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.")}var t=n;switch(n=t.stateNode,t.tag){case 5:var r=!1;break;case 3:case 4:n=n.containerInfo,r=!0;break;default:throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.")}16&t.flags&&(t.flags&=-17);e:n:for(t=e;;){for(;null===t.sibling;){if(null===t.return||Gl(t.return)){t=null;break e}t=t.return}for(t.sibling.return=t.return,t=t.sibling;5!==t.tag&&6!==t.tag&&18!==t.tag;){if(2&t.flags)continue n;if(null===t.child||4===t.tag)continue n;t.child.return=t,t=t.child}if(!(2&t.flags)){t=t.stateNode;break e}}r?Jl(e,t,n):Zl(e,t,n)}function Jl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)if(e=l?e.stateNode:e.stateNode.instance,n){if("number"==typeof t)throw Error("Container does not support insertBefore operation")}else o.UIManager.setChildren(t,["number"==typeof e?e:e._nativeTag]);else if(4!==r&&null!==(e=e.child))for(Jl(e,n,t),e=e.sibling;null!==e;)Jl(e,n,t),e=e.sibling}function Zl(e,n,t){var r=e.tag,l=5===r||6===r;if(l)e=l?e.stateNode:e.stateNode.instance,n?0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[l],[n],[],[],[])):(n=r.indexOf(n),r.splice(n,0,e),o.UIManager.manageChildren(t._nativeTag,[],[],["number"==typeof e?e:e._nativeTag],[n],[])):(n="number"==typeof e?e:e._nativeTag,0<=(l=(r=t._children).indexOf(e))?(r.splice(l,1),r.push(e),o.UIManager.manageChildren(t._nativeTag,[l],[r.length-1],[],[],[])):(r.push(e),o.UIManager.manageChildren(t._nativeTag,[],[],[n],[r.length-1],[])));else if(4!==r&&null!==(e=e.child))for(Zl(e,n,t),e=e.sibling;null!==e;)Zl(e,n,t),e=e.sibling}function ea(e,n){for(var t,r,l=n,a=!1;;){if(!a){a=l.return;e:for(;;){if(null===a)throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");switch(t=a.stateNode,a.tag){case 5:r=!1;break e;case 3:case 4:t=t.containerInfo,r=!0;break e}a=a.return}a=!0}if(5===l.tag||6===l.tag){e:for(var i=e,u=l,s=u;;)if(Xl(i,s),null!==s.child&&4!==s.tag)s.child.return=s,s=s.child;else{if(s===u)break e;for(;null===s.sibling;){if(null===s.return||s.return===u)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}r?(i=t,kn(l.stateNode),o.UIManager.manageChildren(i,[],[],[],[],[0])):(i=t,kn(s=l.stateNode),s=(u=i._children).indexOf(s),u.splice(s,1),o.UIManager.manageChildren(i._nativeTag,[],[],[],[],[s]))}else if(4===l.tag){if(null!==l.child){t=l.stateNode.containerInfo,r=!0,l.child.return=l,l=l.child;continue}}else if(Xl(e,l),null!==l.child){l.child.return=l,l=l.child;continue}if(l===n)break;for(;null===l.sibling;){if(null===l.return||l.return===n)return;4===(l=l.return).tag&&(a=!1)}l.sibling.return=l.return,l=l.sibling}}function na(e,n){switch(n.tag){case 0:case 11:case 14:case 15:case 22:var t=n.updateQueue;if(null!==(t=null!==t?t.lastEffect:null)){var r=t=t.next;do{3==(3&r.tag)&&(n=r.destroy,r.destroy=void 0,void 0!==n&&n()),r=r.next}while(r!==t)}return;case 1:return;case 5:if(null!=(t=n.stateNode)){r=n.memoizedProps,e=null!==e?e.memoizedProps:r;var l=n.updateQueue;n.updateQueue=null,null!==l&&(n=t.viewConfig,Ee.set(t._nativeTag,r),null!=(r=hn(null,e,r,n.validAttributes))&&o.UIManager.updateView(t._nativeTag,n.uiViewClassName,r))}return;case 6:if(null===n.stateNode)throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");return void o.UIManager.updateView(n.stateNode,"RCTRawText",{text:n.memoizedProps});case 3:case 12:return;case 13:return null!==n.memoizedState&&(wa=Et(),ql(n.child,!0)),void ta(n);case 19:return void ta(n);case 17:return;case 23:case 24:return void ql(n,null!==n.memoizedState)}throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.")}function ta(e){var n=e.updateQueue;if(null!==n){e.updateQueue=null;var t=e.stateNode;null===t&&(t=e.stateNode=new Hl),n.forEach(function(n){var r=hi.bind(null,e,n);t.has(n)||(t.add(n),n.then(r,r))})}}function ra(e,n){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(n=n.memoizedState)&&null===n.dehydrated)}var la,aa=Math.ceil,ia=Ie.ReactCurrentDispatcher,ua=Ie.ReactCurrentOwner,oa=0,sa=null,ca=null,fa=0,da=0,pa=Nn(0),ha=0,ga=null,ma=0,va=0,ya=0,ba=0,Sa=null,wa=0,ka=1/0,Ea=null,Ta=!1,xa=null,_a=null,Ra=!1,Pa=null,Ca=90,Na=[],za=[],Ia=null,La=0,Ua=null,Ma=-1,Aa=0,Da=0,Qa=null,Ba=!1;function Fa(){return 0!=(48&oa)?Et():-1!==Ma?Ma:Ma=Et()}function ja(e){if(0==(2&(e=e.mode)))return 1;if(0==(4&e))return 99===Tt()?1:2;if(0===Aa&&(Aa=ma),0!==Nt.transition){0!==Da&&(Da=null!==Sa?Sa.pendingLanes:0),e=Aa;var n=4186112&~Da;return 0===(n&=-n)&&(0===(n=(e=4186112&~e)&-e)&&(n=8192)),n}return e=Tt(),0!=(4&oa)&&98===e?e=Jn(12,Aa):e=Jn(e=Xn(e),Aa),e}function Oa(e,n,t){if(50<La)throw La=0,Ua=null,Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");if(null===(e=Ha(e,n)))return null;nt(e,n,t),e===sa&&(ya|=n,4===ha&&Ya(e,fa));var r=Tt();1===n?0!=(8&oa)&&0==(48&oa)?qa(e):(Va(e,t),0===oa&&(ka=Et()+500,Pt())):(0==(4&oa)||98!==r&&99!==r||(null===Ia?Ia=new Set([e]):Ia.add(e)),Va(e,t)),Sa=e}function Ha(e,n){e.lanes|=n;var t=e.alternate;for(null!==t&&(t.lanes|=n),t=e,e=e.return;null!==e;)e.childLanes|=n,null!==(t=e.alternate)&&(t.childLanes|=n),t=e,e=e.return;return 3===t.tag?t.stateNode:null}function Va(e,n){for(var t=e.callbackNode,r=e.suspendedLanes,l=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var u=31-tt(i),o=1<<u,s=a[u];if(-1===s){if(0==(o&r)||0!=(o&l)){s=n,qn(o);var c=Yn;a[u]=10<=c?s+250:6<=c?s+5e3:-1}}else s<=n&&(e.expiredLanes|=o);i&=~o}if(r=Gn(e,e===sa?fa:0),n=Yn,0===r)null!==t&&(t!==vt&&ut(t),e.callbackNode=null,e.callbackPriority=0);else{if(null!==t){if(e.callbackPriority===n)return;t!==vt&&ut(t)}15===n?(t=qa.bind(null,e),null===bt?(bt=[t],St=it(dt,Ct)):bt.push(t),t=vt):14===n?t=Rt(99,qa.bind(null,e)):t=Rt(t=$n(n),Wa.bind(null,e)),e.callbackPriority=n,e.callbackNode=t}}function Wa(e){if(Ma=-1,Da=Aa=0,0!=(48&oa))throw Error("Should not already be working.");var n=e.callbackNode;if(ui()&&e.callbackNode!==n)return null;var t=Gn(e,e===sa?fa:0);if(0===t)return null;var r=t,l=oa;oa|=16;var a=Ja();for(sa===e&&fa===r||(ka=Et()+500,Ga(e,r));;)try{ni();break}catch(n){Ka(e,n)}if(jt(),ia.current=a,oa=l,null!==ca?r=0:(sa=null,fa=0,r=ha),0!=(ma&ya))Ga(e,0);else if(0!==r){if(2===r&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(t=Kn(e))&&(r=Za(e,t))),1===r)throw n=ga,Ga(e,0),Ya(e,t),Va(e,Et()),n;switch(e.finishedWork=e.current.alternate,e.finishedLanes=t,r){case 0:case 1:throw Error("Root did not complete. This is a bug in React.");case 2:li(e);break;case 3:if(Ya(e,t),(62914560&t)===t&&10<(r=wa+500-Et())){if(0!==Gn(e,0))break;if(((l=e.suspendedLanes)&t)!==t){Fa(),e.pingedLanes|=e.suspendedLanes&l;break}e.timeoutHandle=Tn(li.bind(null,e),r);break}li(e);break;case 4:if(Ya(e,t),(4186112&t)===t)break;for(r=e.eventTimes,l=-1;0<t;){var i=31-tt(t);a=1<<i,(i=r[i])>l&&(l=i),t&=~a}if(t=l,10<(t=(120>(t=Et()-t)?120:480>t?480:1080>t?1080:1920>t?1920:3e3>t?3e3:4320>t?4320:1960*aa(t/1960))-t)){e.timeoutHandle=Tn(li.bind(null,e),t);break}li(e);break;case 5:li(e);break;default:throw Error("Unknown root exit status.")}}return Va(e,Et()),e.callbackNode===n?Wa.bind(null,e):null}function Ya(e,n){for(n&=~ba,n&=~ya,e.suspendedLanes|=n,e.pingedLanes&=~n,e=e.expirationTimes;0<n;){var t=31-tt(n),r=1<<t;e[t]=-1,n&=~r}}function qa(e){if(0!=(48&oa))throw Error("Should not already be working.");if(ui(),e===sa&&0!=(e.expiredLanes&fa)){var n=fa,t=Za(e,n);0!=(ma&ya)&&(t=Za(e,n=Gn(e,n)))}else t=Za(e,n=Gn(e,0));if(0!==e.tag&&2===t&&(oa|=64,e.hydrate&&(e.hydrate=!1),0!==(n=Kn(e))&&(t=Za(e,n))),1===t)throw t=ga,Ga(e,0),Ya(e,n),Va(e,Et()),t;return e.finishedWork=e.current.alternate,e.finishedLanes=n,li(e),Va(e,Et()),null}function Xa(e,n){In(pa,da),da|=n,ma|=n}function $a(){da=pa.current,zn(pa)}function Ga(e,n){e.finishedWork=null,e.finishedLanes=0;var t=e.timeoutHandle;if(-1!==t&&(e.timeoutHandle=-1,xn(t)),null!==ca)for(t=ca.return;null!==t;){var r=t;switch(r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&Bn();break;case 3:br(),zn(Mn),zn(Un),xr();break;case 5:wr(r);break;case 4:br();break;case 13:case 19:zn(kr);break;case 10:Ot(r);break;case 23:case 24:$a()}t=t.return}sa=e,ca=bi(e.current,null),fa=da=ma=n,ha=0,ga=null,ba=ya=va=0}function Ka(e,n){for(;;){var t=ca;try{if(jt(),_r.current=il,Ir){for(var r=Cr.memoizedState;null!==r;){var l=r.queue;null!==l&&(l.pending=null),r=r.next}Ir=!1}if(Pr=0,zr=Nr=Cr=null,Lr=!1,ua.current=null,null===t||null===t.return){ha=1,ga=n,ca=null;break}e:{var a=e,i=t.return,u=t,o=n;if(n=fa,u.flags|=4096,u.firstEffect=u.lastEffect=null,null!==o&&"object"==typeof o&&"function"==typeof o.then){var s=o;if(0==(2&u.mode)){var c=u.alternate;c?(u.updateQueue=c.updateQueue,u.memoizedState=c.memoizedState,u.lanes=c.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=0!=(1&kr.current),d=i;do{var p;if(p=13===d.tag){var h=d.memoizedState;if(null!==h)p=null!==h.dehydrated;else{var g=d.memoizedProps;p=void 0!==g.fallback&&(!0!==g.unstable_avoidThisFallback||!f)}}if(p){var m=d.updateQueue;if(null===m){var v=new Set;v.add(s),d.updateQueue=v}else m.add(s);if(0==(2&d.mode)){if(d.flags|=64,u.flags|=32768,u.flags&=-5029,1===u.tag)if(null===u.alternate)u.tag=17;else{var y=$t(-1,1);y.tag=2,Gt(u,y)}u.lanes|=1;break e}o=void 0,u=n;var b=a.pingCache;if(null===b?(b=a.pingCache=new Fl,o=new Set,b.set(s,o)):void 0===(o=b.get(s))&&(o=new Set,b.set(s,o)),!o.has(u)){o.add(u);var S=pi.bind(null,a,s,u);s.then(S,S)}d.flags|=8192,d.lanes=n;break e}d=d.return}while(null!==d);o=Error((Je(u.type)||"A React component")+" suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.")}5!==ha&&(ha=2),o=Ql(o,u),d=i;do{switch(d.tag){case 3:a=o,d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,jl(d,a,n));break e;case 1:a=o;var w=d.type,k=d.stateNode;if(0==(64&d.flags)&&("function"==typeof w.getDerivedStateFromError||null!==k&&"function"==typeof k.componentDidCatch&&(null===_a||!_a.has(k)))){d.flags|=8192,n&=-n,d.lanes|=n,Kt(d,Ol(d,a,n));break e}}d=d.return}while(null!==d)}ri(t)}catch(e){n=e,ca===t&&null!==t&&(ca=t=t.return);continue}break}}function Ja(){var e=ia.current;return ia.current=il,null===e?il:e}function Za(e,n){var t=oa;oa|=16;var r=Ja();for(sa===e&&fa===n||Ga(e,n);;)try{ei();break}catch(n){Ka(e,n)}if(jt(),oa=t,ia.current=r,null!==ca)throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");return sa=null,fa=0,ha}function ei(){for(;null!==ca;)ti(ca)}function ni(){for(;null!==ca&&!ot();)ti(ca)}function ti(e){var n=la(e.alternate,e,da);e.memoizedProps=e.pendingProps,null===n?ri(e):ca=n,ua.current=null}function ri(e){var n=e;do{var t=n.alternate;if(e=n.return,0==(4096&n.flags)){if(null!==(t=Al(t,n,da)))return void(ca=t);if(24!==(t=n).tag&&23!==t.tag||null===t.memoizedState||0!=(1073741824&da)||0==(4&t.mode)){for(var r=0,l=t.child;null!==l;)r|=l.lanes|l.childLanes,l=l.sibling;t.childLanes=r}null!==e&&0==(4096&e.flags)&&(null===e.firstEffect&&(e.firstEffect=n.firstEffect),null!==n.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=n.firstEffect),e.lastEffect=n.lastEffect),1<n.flags&&(null!==e.lastEffect?e.lastEffect.nextEffect=n:e.firstEffect=n,e.lastEffect=n))}else{if(null!==(t=Dl(n)))return t.flags&=4095,void(ca=t);null!==e&&(e.firstEffect=e.lastEffect=null,e.flags|=4096)}if(null!==(n=n.sibling))return void(ca=n);ca=n=e}while(null!==n);0===ha&&(ha=5)}function li(e){var n=Tt();return _t(99,ai.bind(null,e,n)),null}function ai(e,n){do{ui()}while(null!==Pa);if(0!=(48&oa))throw Error("Should not already be working.");var t=e.finishedWork;if(null===t)return null;if(e.finishedWork=null,e.finishedLanes=0,t===e.current)throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");e.callbackNode=null;var r=t.lanes|t.childLanes,l=r,a=e.pendingLanes&~l;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=l,e.mutableReadLanes&=l,e.entangledLanes&=l,l=e.entanglements;for(var i=e.eventTimes,u=e.expirationTimes;0<a;){var o=31-tt(a),s=1<<o;l[o]=0,i[o]=-1,u[o]=-1,a&=~s}if(null!==Ia&&0==(24&r)&&Ia.has(e)&&Ia.delete(e),e===sa&&(ca=sa=null,fa=0),1<t.flags?null!==t.lastEffect?(t.lastEffect.nextEffect=t,r=t.firstEffect):r=t:r=t.firstEffect,null!==r){l=oa,oa|=32,Qa=ua.current=null,Ba=!1,Ea=r;do{try{ii()}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Qa=null,Ea=r;do{try{for(i=e;null!==Ea;){var c=Ea.flags;if(128&c){var f=Ea.alternate;if(null!==f){var d=f.ref;null!==d&&("function"==typeof d?d(null):d.current=null)}}switch(1038&c){case 2:Kl(Ea),Ea.flags&=-3;break;case 6:Kl(Ea),Ea.flags&=-3,na(Ea.alternate,Ea);break;case 1024:Ea.flags&=-1025;break;case 1028:Ea.flags&=-1025,na(Ea.alternate,Ea);break;case 4:na(Ea.alternate,Ea);break;case 8:ea(i,u=Ea);var p=u.alternate;$l(u),null!==p&&$l(p)}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);e.current=t,Ea=r;do{try{for(c=e;null!==Ea;){var h=Ea.flags;if(36&h&&Yl(c,Ea.alternate,Ea),128&h){f=void 0;var g=Ea.ref;if(null!==g){var m=Ea.stateNode;switch(Ea.tag){case 5:f=m;break;default:f=m}"function"==typeof g?g(f):g.current=f}}Ea=Ea.nextEffect}}catch(e){if(null===Ea)throw Error("Should be working on an effect.");di(Ea,e),Ea=Ea.nextEffect}}while(null!==Ea);Ea=null,yt(),oa=l}else e.current=t;if(Ra)Ra=!1,Pa=e,Ca=n;else for(Ea=r;null!==Ea;)n=Ea.nextEffect,Ea.nextEffect=null,8&Ea.flags&&((h=Ea).sibling=null,h.stateNode=null),Ea=n;if(0===(r=e.pendingLanes)&&(_a=null),1===r?e===Ua?La++:(La=0,Ua=e):La=0,t=t.stateNode,Wn&&"function"==typeof Wn.onCommitFiberRoot)try{Wn.onCommitFiberRoot(Vn,t,void 0,64==(64&t.current.flags))}catch(e){}if(Va(e,Et()),Ta)throw Ta=!1,e=xa,xa=null,e;return 0!=(8&oa)?null:(Pt(),null)}function ii(){for(;null!==Ea;){var e=Ea.alternate;Ba||null===Qa||(0!=(8&Ea.flags)?rn(Ea,Qa)&&(Ba=!0):13===Ea.tag&&ra(e,Ea)&&rn(Ea,Qa)&&(Ba=!0));var n=Ea.flags;0!=(256&n)&&Wl(e,Ea),0==(512&n)||Ra||(Ra=!0,Rt(97,function(){return ui(),null})),Ea=Ea.nextEffect}}function ui(){if(90!==Ca){var e=97<Ca?97:Ca;return Ca=90,_t(e,ci)}return!1}function oi(e,n){Na.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function si(e,n){za.push(n,e),Ra||(Ra=!0,Rt(97,function(){return ui(),null}))}function ci(){if(null===Pa)return!1;var e=Pa;if(Pa=null,0!=(48&oa))throw Error("Cannot flush passive effects while already rendering.");var n=oa;oa|=32;var t=za;za=[];for(var r=0;r<t.length;r+=2){var l=t[r],a=t[r+1],i=l.destroy;if(l.destroy=void 0,"function"==typeof i)try{i()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(t=Na,Na=[],r=0;r<t.length;r+=2){l=t[r],a=t[r+1];try{var u=l.create;l.destroy=u()}catch(e){if(null===a)throw Error("Should be working on an effect.");di(a,e)}}for(u=e.current.firstEffect;null!==u;)e=u.nextEffect,u.nextEffect=null,8&u.flags&&(u.sibling=null,u.stateNode=null),u=e;return oa=n,Pt(),!0}function fi(e,n,t){Gt(e,n=jl(e,n=Ql(t,n),1)),n=Fa(),null!==(e=Ha(e,1))&&(nt(e,1,n),Va(e,n))}function di(e,n){if(3===e.tag)fi(e,e,n);else for(var t=e.return;null!==t;){if(3===t.tag){fi(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r))){var l=Ol(t,e=Ql(n,e),1);if(Gt(t,l),l=Fa(),null!==(t=Ha(t,1)))nt(t,1,l),Va(t,l);else if("function"==typeof r.componentDidCatch&&(null===_a||!_a.has(r)))try{r.componentDidCatch(n,e)}catch(e){}break}}t=t.return}}function pi(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),n=Fa(),e.pingedLanes|=e.suspendedLanes&t,sa===e&&(fa&t)===t&&(4===ha||3===ha&&(62914560&fa)===fa&&500>Et()-wa?Ga(e,0):ba|=t),Va(e,n)}function hi(e,n){var t=e.stateNode;null!==t&&t.delete(n),0===(n=0)&&(0==(2&(n=e.mode))?n=1:0==(4&n)?n=99===Tt()?1:2:(0===Aa&&(Aa=ma),0===(n=Zn(62914560&~Aa))&&(n=4194304))),t=Fa(),null!==(e=Ha(e,n))&&(nt(e,n,t),Va(e,t))}function gi(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.flags=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childLanes=this.lanes=0,this.alternate=null}function mi(e,n,t,r){return new gi(e,n,t,r)}function vi(e){return!(!(e=e.prototype)||!e.isReactComponent)}function yi(e){if("function"==typeof e)return vi(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===Fe)return 11;if(e===He)return 14}return 2}function bi(e,n){var t=e.alternate;return null===t?((t=mi(e.tag,n,e.key,e.mode)).elementType=e.elementType,t.type=e.type,t.stateNode=e.stateNode,t.alternate=e,e.alternate=t):(t.pendingProps=n,t.type=e.type,t.flags=0,t.nextEffect=null,t.firstEffect=null,t.lastEffect=null),t.childLanes=e.childLanes,t.lanes=e.lanes,t.child=e.child,t.memoizedProps=e.memoizedProps,t.memoizedState=e.memoizedState,t.updateQueue=e.updateQueue,n=e.dependencies,t.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},t.sibling=e.sibling,t.index=e.index,t.ref=e.ref,t}function Si(e,n,t,r,l,a){var i=2;if(r=e,"function"==typeof e)vi(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case Me:return wi(t.children,l,a,n);case Ye:i=8,l|=16;break;case Ae:i=8,l|=1;break;case De:return(e=mi(12,t,n,8|l)).elementType=De,e.type=De,e.lanes=a,e;case je:return(e=mi(13,t,n,l)).type=je,e.elementType=je,e.lanes=a,e;case Oe:return(e=mi(19,t,n,l)).elementType=Oe,e.lanes=a,e;case qe:return ki(t,l,a,n);case Xe:return(e=mi(24,t,n,l)).elementType=Xe,e.lanes=a,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case Qe:i=10;break e;case Be:i=9;break e;case Fe:i=11;break e;case He:i=14;break e;case Ve:i=16,r=null;break e;case We:i=22;break e}throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: "+(null==e?e:typeof e)+".")}return(n=mi(i,t,n,l)).elementType=e,n.type=r,n.lanes=a,n}function wi(e,n,t,r){return(e=mi(7,e,r,n)).lanes=t,e}function ki(e,n,t,r){return(e=mi(23,e,r,n)).elementType=qe,e.lanes=t,e}function Ei(e,n,t){return(e=mi(6,e,null,n)).lanes=t,e}function Ti(e,n,t){return(n=mi(4,null!==e.children?e.children:[],e.key,n)).lanes=t,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function xi(e,n,t){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=t,this.callbackNode=null,this.callbackPriority=0,this.eventTimes=et(0),this.expirationTimes=et(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=et(0)}function _i(e,n,t){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:Ue,key:null==r?null:""+r,children:e,containerInfo:n,implementation:t}}function Ri(e){var n=e._reactInternals;if(void 0===n){if("function"==typeof e.render)throw Error("Unable to find node on an unmounted component.");throw Error("Argument appears to not be a ReactComponent. Keys: "+Object.keys(e))}return null===(e=tn(n))?null:e.stateNode}function Pi(e,n,t,r){var l=n.current,a=Fa(),i=ja(l);e:if(t){t=t._reactInternals;n:{if(Ze(t)!==t||1!==t.tag)throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");var u=t;do{switch(u.tag){case 3:u=u.stateNode.context;break n;case 1:if(Qn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break n}}u=u.return}while(null!==u);throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.")}if(1===t.tag){var o=t.type;if(Qn(o)){t=jn(t,o,u);break e}}t=u}else t=Ln;return null===n.context?n.context=t:n.pendingContext=t,(n=$t(a,i)).payload={element:e},null!==(r=void 0===r?null:r)&&(n.callback=r),Gt(l,n),Oa(l,i,a),i}function Ci(e){return null==e?null:"number"==typeof e?e:e._nativeTag?e._nativeTag:e.canonical&&e.canonical._nativeTag?e.canonical._nativeTag:null==(e=Ri(e))?e:e.canonical?e.canonical._nativeTag:e._nativeTag}function Ni(e){var n=zi.get(e);n&&Pi(null,n,null,function(){zi.delete(e)})}la=function(e,n,t){var r=n.lanes;if(null!==e)if(e.memoizedProps!==n.pendingProps||Mn.current)fl=!0;else{if(0==(t&r)){switch(fl=!1,n.tag){case 3:wl(n);break;case 5:Sr(n);break;case 1:Qn(n.type)&&On(n);break;case 4:yr(n,n.stateNode.containerInfo);break;case 10:r=n.memoizedProps.value;var l=n.type._context;In(Dt,l._currentValue),l._currentValue=r;break;case 13:if(null!==n.memoizedState)return 0!=(t&n.child.childLanes)?Rl(e,n,t):(In(kr,1&kr.current),null!==(n=Ul(e,n,t))?n.sibling:null);In(kr,1&kr.current);break;case 19:if(r=0!=(t&n.childLanes),0!=(64&e.flags)){if(r)return Ll(e,n,t);n.flags|=64}if(null!==(l=n.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),In(kr,kr.current),r)break;return null;case 23:case 24:return n.lanes=0,ml(e,n,t)}return Ul(e,n,t)}fl=0!=(32768&e.flags)}else fl=!1;switch(n.lanes=0,n.tag){case 2:if(r=n.type,null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=Dn(n,Un.current),Vt(n,t),l=Ar(null,n,r,e,l,t),n.flags|=1,"object"==typeof l&&null!==l&&"function"==typeof l.render&&void 0===l.$$typeof){if(n.tag=1,n.memoizedState=null,n.updateQueue=null,Qn(r)){var a=!0;On(n)}else a=!1;n.memoizedState=null!==l.state&&void 0!==l.state?l.state:null,qt(n);var i=r.getDerivedStateFromProps;"function"==typeof i&&nr(n,r,i,e),l.updater=tr,n.stateNode=l,l._reactInternals=n,ir(n,r,e,t),n=Sl(null,n,r,!0,a,t)}else n.tag=0,dl(null,n,l,t),n=n.child;return n;case 16:l=n.elementType;e:{switch(null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),e=n.pendingProps,l=(a=l._init)(l._payload),n.type=l,a=n.tag=yi(l),e=At(l,e),a){case 0:n=yl(null,n,l,e,t);break e;case 1:n=bl(null,n,l,e,t);break e;case 11:n=pl(null,n,l,e,t);break e;case 14:n=hl(null,n,l,At(l.type,e),r,t);break e}throw Error("Element type is invalid. Received a promise that resolves to: "+l+". Lazy element type must resolve to a class or function.")}return n;case 0:return r=n.type,l=n.pendingProps,yl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 1:return r=n.type,l=n.pendingProps,bl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 3:if(wl(n),r=n.updateQueue,null===e||null===r)throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");return r=n.pendingProps,l=null!==(l=n.memoizedState)?l.element:null,Xt(e,n),Jt(n,r,null,t),(r=n.memoizedState.element)===l?n=Ul(e,n,t):(dl(e,n,r,t),n=n.child),n;case 5:return Sr(n),r=n.pendingProps.children,vl(e,n),dl(e,n,r,t),n.child;case 6:return null;case 13:return Rl(e,n,t);case 4:return yr(n,n.stateNode.containerInfo),r=n.pendingProps,null===e?n.child=fr(n,null,r,t):dl(e,n,r,t),n.child;case 11:return r=n.type,l=n.pendingProps,pl(e,n,r,l=n.elementType===r?l:At(r,l),t);case 7:return dl(e,n,n.pendingProps,t),n.child;case 8:case 12:return dl(e,n,n.pendingProps.children,t),n.child;case 10:e:{r=n.type._context,l=n.pendingProps,i=n.memoizedProps,a=l.value;var u=n.type._context;if(In(Dt,u._currentValue),u._currentValue=a,null!==i)if(u=i.value,0===(a=zt(u,a)?0:0|("function"==typeof r._calculateChangedBits?r._calculateChangedBits(u,a):1073741823))){if(i.children===l.children&&!Mn.current){n=Ul(e,n,t);break e}}else for(null!==(u=n.child)&&(u.return=n);null!==u;){var o=u.dependencies;if(null!==o){i=u.child;for(var s=o.firstContext;null!==s;){if(s.context===r&&0!=(s.observedBits&a)){1===u.tag&&((s=$t(-1,t&-t)).tag=2,Gt(u,s)),u.lanes|=t,null!==(s=u.alternate)&&(s.lanes|=t),Ht(u.return,t),o.lanes|=t;break}s=s.next}}else i=10===u.tag&&u.type===n.type?null:u.child;if(null!==i)i.return=u;else for(i=u;null!==i;){if(i===n){i=null;break}if(null!==(u=i.sibling)){u.return=i.return,i=u;break}i=i.return}u=i}dl(e,n,l.children,t),n=n.child}return n;case 9:return l=n.type,r=(a=n.pendingProps).children,Vt(n,t),r=r(l=Wt(l,a.unstable_observedBits)),n.flags|=1,dl(e,n,r,t),n.child;case 14:return a=At(l=n.type,n.pendingProps),hl(e,n,l,a=At(l.type,a),r,t);case 15:return gl(e,n,n.type,n.pendingProps,r,t);case 17:return r=n.type,l=n.pendingProps,l=n.elementType===r?l:At(r,l),null!==e&&(e.alternate=null,n.alternate=null,n.flags|=2),n.tag=1,Qn(r)?(e=!0,On(n)):e=!1,Vt(n,t),lr(n,r,l),ir(n,r,l,t),Sl(null,n,r,!0,e,t);case 19:return Ll(e,n,t);case 23:case 24:return ml(e,n,t)}throw Error("Unknown unit of work tag ("+n.tag+"). This error is likely caused by a bug in React. Please file an issue.")},xe=function(e,n){var t=oa;oa|=1;try{return e(n)}finally{0===(oa=t)&&(ka=Et()+500,Pt())}};var zi=new Map,Ii={findFiberByHostInstance:Te,bundleType:0,version:"17.0.1-4e5d7faf5",rendererPackageName:"react-native-renderer",rendererConfig:{getInspectorDataForViewTag:function(){throw Error("getInspectorDataForViewTag() is not available in production")},getInspectorDataForViewAtPoint:function(){throw Error("getInspectorDataForViewAtPoint() is not available in production.")}.bind(null,Ci)}},Li={bundleType:Ii.bundleType,version:Ii.version,rendererPackageName:Ii.rendererPackageName,rendererConfig:Ii.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ie.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=tn(e))?null:e.stateNode},findFiberByHostInstance:Ii.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Ui=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ui.isDisabled&&Ui.supportsFiber)try{Vn=Ui.inject(Li),Wn=Ui}catch(e){}}a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED={computeComponentStackForErrorReporting:function(e){return(e=Te(e))?Mt(e):""}},a.createPortal=function(e,n){return _i(e,n,null,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},a.dispatchCommand=function(e,n,t){null!=e._nativeTag&&(e._internalInstanceHandle?nativeFabricUIManager.dispatchCommand(e._internalInstanceHandle.stateNode.node,n,t):o.UIManager.dispatchViewManagerCommand(e._nativeTag,n,t))},a.findHostInstance_DEPRECATED=function(e){return null==e?null:e._nativeTag?e:e.canonical&&e.canonical._nativeTag?e.canonical:null==(e=Ri(e))?e:e.canonical?e.canonical:e},a.findNodeHandle=Ci,a.render=function(e,n,t){var r=zi.get(n);if(!r){r=new xi(n,0,!1);var l=mi(3,null,null,0);r.current=l,l.stateNode=r,qt(l),zi.set(n,r)}Pi(e,r,null,t);e:if(e=r.current,e.child)switch(e.child.tag){case 5:e=e.child.stateNode;break e;default:e=e.child.stateNode}else e=null;return e},a.unmountComponentAtNode=Ni,a.unmountComponentAtNodeAndRemoveContainer=function(e){Ni(e),o.UIManager.removeRootView(e)},a.unstable_batchedUpdates=Re},88,[6,89,160,14,184]);^~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:114:778: warning: the variable "setImmediate" was not declared in function "h 6#"__d(function(g,r,i,a,m,e,d){'use strict';function n(){}var t=null,o={};function u(n){try{return n.then}catch(n){return t=n,o}}function f(n,u){try{return n(u)}catch(n){return t=n,o}}function c(n,u,f){try{n(u,f)}catch(n){return t=n,o}}function _(t){if('object'!=typeof this)throw new TypeError('Promises must be constructed via new');if('function'!=typeof t)throw new TypeError('Promise constructor\'s argument is not a function');this._U=0,this._V=0,this._W=null,this._X=null,t!==n&&X(t,this)}function s(t,o,u){return new t.constructor(function(f,c){var s=new _(n);s.then(f,c),l(t,new w(o,u,s))})}function l(n,t){for(;3===n._V;)n=n._W;if(_._Y&&_._Y(n),0===n._V)return 0===n._U?(n._U=1,void(n._X=t)):1===n._U?(n._U=2,void(n._X=[n._X,t])):void n._X.push(t);h(n,t)}function h(n,u){setImmediate(function(){var c=1===n._V?u.onFulfilled:u.onRejected;if(null!==c){var _=f(c,n._W);_===o?v(u.promise,t):p(u.promise,_)}else 1===n._V?p(u.promise,n._W):v(u.promise,n._W)})}function p(n,f){if(f===n)return v(n,new TypeError('A promise cannot be resolved with itself.'));if(f&&('object'==typeof f||'function'==typeof f)){var c=u(f);if(c===o)return v(n,t);if(c===n.then&&f instanceof _)return n._V=3,n._W=f,void y(n);if('function'==typeof c)return void X(c.bind(f),n)}n._V=1,n._W=f,y(n)}function v(n,t){n._V=2,n._W=t,_._Z&&_._Z(n,t),y(n)}function y(n){if(1===n._U&&(l(n,n._X),n._X=null),2===n._U){for(var t=0;t<n._X.length;t++)l(n,n._X[t]);n._X=null}}function w(n,t,o){this.onFulfilled='function'==typeof n?n:null,this.onRejected='function'==typeof t?t:null,this.promise=o}function X(n,u){var f=!1,_=c(n,function(n){f||(f=!0,p(u,n))},function(n){f||(f=!0,v(u,n))});f||_!==o||(f=!0,v(u,t))}m.exports=_,_._Y=null,_._Z=null,_._0=n,_.prototype.then=function(t,o){if(this.constructor!==_)return s(this,t,o);var u=new _(n);return l(this,new w(t,o,u)),u}},108,[]);^~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:139:67: warning: the variable "fetch" was not declared in anonymous function " 460#"__d(function(g,r,i,a,m,e,d){'use strict';r(d[0]),m.exports={fetch:fetch,Headers:Headers,Request:Request,Response:Response}},133,[134]);^~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:139:81: warning: the variable "Headers" was not declared in anonymous function " 460#"__d(function(g,r,i,a,m,e,d){'use strict';r(d[0]),m.exports={fetch:fetch,Headers:Headers,Request:Request,Response:Response}},133,[134]);^~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:139:97: warning: the variable "Request" was not declared in anonymous function " 460#"__d(function(g,r,i,a,m,e,d){'use strict';r(d[0]),m.exports={fetch:fetch,Headers:Headers,Request:Request,Response:Response}},133,[134]);^~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:139:114: warning: the variable "Response" was not declared in anonymous function " 460#"__d(function(g,r,i,a,m,e,d){'use strict';r(d[0]),m.exports={fetch:fetch,Headers:Headers,Request:Request,Response:Response}},133,[134]);^~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:140:1583: warning: the variable "FileReader" was not declared in function "b 7#"__d(function(g,r,i,a,m,e,d){var t,o;t=this,o=function(t){'use strict';var o='undefined'!=typeof globalThis&&globalThis||'undefined'!=typeof self&&self||void 0!==o&&o,n={searchParams:'URLSearchParams'in o,iterable:'Symbol'in o&&'iterator'in Symbol,blob:'FileReader'in o&&'Blob'in o&&(function(){try{return new Blob,!0}catch(t){return!1}})(),formData:'FormData'in o,arrayBuffer:'ArrayBuffer'in o};if(n.arrayBuffer)var s=['[object Int8Array]','[object Uint8Array]','[object Uint8ClampedArray]','[object Int16Array]','[object Uint16Array]','[object Int32Array]','[object Uint32Array]','[object Float32Array]','[object Float64Array]'],h=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if('string'!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||''===t)throw new TypeError('Invalid character in header field name');return t.toLowerCase()}function u(t){return'string'!=typeof t&&(t=String(t)),t}function c(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function y(t){this.map={},t instanceof y?t.forEach(function(t,o){this.append(o,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(o){this.append(o,t[o])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError('Already read'));t.bodyUsed=!0}function p(t){return new Promise(function(o,n){t.onload=function(){o(t.result)},t.onerror=function(){n(t.error)}})}function b(t){var o=new FileReader,n=p(o);return o.readAsArrayBuffer(t),n}function w(t){for(var o=new Uint8Array(t),n=new Array(o.length),s=0;s<o.length;s++)n[s]=String.fromCharCode(o[s]);return n.join('')}function v(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){var o;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?'string'==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText='',this.headers.get('content-type')||('string'==typeof t?this.headers.set('content-type','text/plain;charset=UTF-8'):this._bodyBlob&&this._bodyBlob.type?this.headers.set('content-type',this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set('content-type','application/x-www-form-urlencoded;charset=UTF-8'))},n.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error('could not read FormData body as blob');return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=l(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(b)}),this.text=function(){var t,o,n,s=l(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,n=p(o),o.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(w(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error('could not read FormData body as text');return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}y.prototype.append=function(t,o){t=f(t),o=u(o);var n=this.map[t];this.map[t]=n?n+', '+o:o},y.prototype.delete=function(t){delete this.map[f(t)]},y.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},y.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},y.prototype.set=function(t,o){this.map[f(t)]=u(o)},y.prototype.forEach=function(t,o){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(o,this.map[n],n,this)},y.prototype.keys=function(){var t=[];return this.forEach(function(o,n){t.push(n)}),c(t)},y.prototype.values=function(){var t=[];return this.forEach(function(o){t.push(o)}),c(t)},y.prototype.entries=function(){var t=[];return this.forEach(function(o,n){t.push([n,o])}),c(t)},n.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);var E=['DELETE','GET','HEAD','OPTIONS','POST','PUT'];function T(t,o){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,s,h=(o=o||{}).body;if(t instanceof T){if(t.bodyUsed)throw new TypeError('Already read');this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new y(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,h||null==t._bodyInit||(h=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||'same-origin',!o.headers&&this.headers||(this.headers=new y(o.headers)),this.method=(n=o.method||this.method||'GET',s=n.toUpperCase(),E.indexOf(s)>-1?s:n),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,('GET'===this.method||'HEAD'===this.method)&&h)throw new TypeError('Body not allowed for GET or HEAD requests');if(this._initBody(h),!('GET'!==this.method&&'HEAD'!==this.method||'no-store'!==o.cache&&'no-cache'!==o.cache)){var f=/([?&])_=[^&]*/;if(f.test(this.url))this.url=this.url.replace(f,'$1_='+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?'&':'?')+'_='+(new Date).getTime()}}}function A(t){var o=new FormData;return t.trim().split('&').forEach(function(t){if(t){var n=t.split('='),s=n.shift().replace(/\+/g,' '),h=n.join('=').replace(/\+/g,' ');o.append(decodeURIComponent(s),decodeURIComponent(h))}}),o}function B(t,o){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o||(o={}),this.type='default',this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText='statusText'in o?o.statusText:'',this.headers=new y(o.headers),this.url=o.url||'',this._initBody(t)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},_.call(T.prototype),_.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var t=new B(null,{status:0,statusText:''});return t.type='error',t};var x=[301,302,303,307,308];B.redirect=function(t,o){if(-1===x.indexOf(o))throw new RangeError('Invalid status code');return new B(null,{status:o,headers:{location:t}})},t.DOMException=o.DOMException;try{new t.DOMException}catch(o){t.DOMException=function(t,o){this.message=t,this.name=o;var n=Error(t);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function O(s,h){return new Promise(function(f,c){var l=new T(s,h);if(l.signal&&l.signal.aborted)return c(new t.DOMException('Aborted','AbortError'));var p=new XMLHttpRequest;function b(){p.abort()}p.onload=function(){var t,o,n={status:p.status,statusText:p.statusText,headers:(t=p.getAllResponseHeaders()||'',o=new y,t.replace(/\r?\n[\t ]+/g,' ').split(/\r?\n/).forEach(function(t){var n=t.split(':'),s=n.shift().trim();if(s){var h=n.join(':').trim();o.append(s,h)}}),o)};n.url='responseURL'in p?p.responseURL:n.headers.get('X-Request-URL');var s='response'in p?p.response:p.responseText;setTimeout(function(){f(new B(s,n))},0)},p.onerror=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.ontimeout=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.onabort=function(){setTimeout(function(){c(new t.DOMException('Aborted','AbortError'))},0)},p.open(l.method,(function(t){try{return''===t&&o.location.href?o.location.href:t}catch(o){return t}})(l.url),!0),'include'===l.credentials?p.withCredentials=!0:'omit'===l.credentials&&(p.withCredentials=!1),'responseType'in p&&(n.blob?p.responseType='blob':n.arrayBuffer&&l.headers.get('Content-Type')&&-1!==l.headers.get('Content-Type').indexOf('application/octet-stream')&&(p.responseType='arraybuffer')),!h||'object'!=typeof h.headers||h.headers instanceof y?l.headers.forEach(function(t,o){p.setRequestHeader(o,t)}):Object.getOwnPropertyNames(h.headers).forEach(function(t){p.setRequestHeader(t,u(h.headers[t]))}),l.signal&&(l.signal.addEventListener('abort',b),p.onreadystatechange=function(){4===p.readyState&&l.signal.removeEventListener('abort',b)}),p.send(void 0===l._bodyInit?null:l._bodyInit)})}O.polyfill=!0,o.fetch||(o.fetch=O,o.Headers=y,o.Request=T,o.Response=B),t.Headers=y,t.Request=T,t.Response=B,t.fetch=O,Object.defineProperty(t,'__esModule',{value:!0})},'object'==typeof e&&void 0!==m?o(e):'function'==typeof define&&define.amd?define(['exports'],o):o(t.WHATWGFetch={})},134,[]);^~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:140:2045: warning: the variable "Blob" was not declared in anonymous function " 469#"__d(function(g,r,i,a,m,e,d){var t,o;t=this,o=function(t){'use strict';var o='undefined'!=typeof globalThis&&globalThis||'undefined'!=typeof self&&self||void 0!==o&&o,n={searchParams:'URLSearchParams'in o,iterable:'Symbol'in o&&'iterator'in Symbol,blob:'FileReader'in o&&'Blob'in o&&(function(){try{return new Blob,!0}catch(t){return!1}})(),formData:'FormData'in o,arrayBuffer:'ArrayBuffer'in o};if(n.arrayBuffer)var s=['[object Int8Array]','[object Uint8Array]','[object Uint8ClampedArray]','[object Int16Array]','[object Uint16Array]','[object Int32Array]','[object Uint32Array]','[object Float32Array]','[object Float64Array]'],h=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if('string'!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||''===t)throw new TypeError('Invalid character in header field name');return t.toLowerCase()}function u(t){return'string'!=typeof t&&(t=String(t)),t}function c(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function y(t){this.map={},t instanceof y?t.forEach(function(t,o){this.append(o,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(o){this.append(o,t[o])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError('Already read'));t.bodyUsed=!0}function p(t){return new Promise(function(o,n){t.onload=function(){o(t.result)},t.onerror=function(){n(t.error)}})}function b(t){var o=new FileReader,n=p(o);return o.readAsArrayBuffer(t),n}function w(t){for(var o=new Uint8Array(t),n=new Array(o.length),s=0;s<o.length;s++)n[s]=String.fromCharCode(o[s]);return n.join('')}function v(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){var o;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?'string'==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText='',this.headers.get('content-type')||('string'==typeof t?this.headers.set('content-type','text/plain;charset=UTF-8'):this._bodyBlob&&this._bodyBlob.type?this.headers.set('content-type',this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set('content-type','application/x-www-form-urlencoded;charset=UTF-8'))},n.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error('could not read FormData body as blob');return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=l(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(b)}),this.text=function(){var t,o,n,s=l(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,n=p(o),o.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(w(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error('could not read FormData body as text');return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}y.prototype.append=function(t,o){t=f(t),o=u(o);var n=this.map[t];this.map[t]=n?n+', '+o:o},y.prototype.delete=function(t){delete this.map[f(t)]},y.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},y.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},y.prototype.set=function(t,o){this.map[f(t)]=u(o)},y.prototype.forEach=function(t,o){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(o,this.map[n],n,this)},y.prototype.keys=function(){var t=[];return this.forEach(function(o,n){t.push(n)}),c(t)},y.prototype.values=function(){var t=[];return this.forEach(function(o){t.push(o)}),c(t)},y.prototype.entries=function(){var t=[];return this.forEach(function(o,n){t.push([n,o])}),c(t)},n.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);var E=['DELETE','GET','HEAD','OPTIONS','POST','PUT'];function T(t,o){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,s,h=(o=o||{}).body;if(t instanceof T){if(t.bodyUsed)throw new TypeError('Already read');this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new y(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,h||null==t._bodyInit||(h=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||'same-origin',!o.headers&&this.headers||(this.headers=new y(o.headers)),this.method=(n=o.method||this.method||'GET',s=n.toUpperCase(),E.indexOf(s)>-1?s:n),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,('GET'===this.method||'HEAD'===this.method)&&h)throw new TypeError('Body not allowed for GET or HEAD requests');if(this._initBody(h),!('GET'!==this.method&&'HEAD'!==this.method||'no-store'!==o.cache&&'no-cache'!==o.cache)){var f=/([?&])_=[^&]*/;if(f.test(this.url))this.url=this.url.replace(f,'$1_='+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?'&':'?')+'_='+(new Date).getTime()}}}function A(t){var o=new FormData;return t.trim().split('&').forEach(function(t){if(t){var n=t.split('='),s=n.shift().replace(/\+/g,' '),h=n.join('=').replace(/\+/g,' ');o.append(decodeURIComponent(s),decodeURIComponent(h))}}),o}function B(t,o){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o||(o={}),this.type='default',this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText='statusText'in o?o.statusText:'',this.headers=new y(o.headers),this.url=o.url||'',this._initBody(t)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},_.call(T.prototype),_.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var t=new B(null,{status:0,statusText:''});return t.type='error',t};var x=[301,302,303,307,308];B.redirect=function(t,o){if(-1===x.indexOf(o))throw new RangeError('Invalid status code');return new B(null,{status:o,headers:{location:t}})},t.DOMException=o.DOMException;try{new t.DOMException}catch(o){t.DOMException=function(t,o){this.message=t,this.name=o;var n=Error(t);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function O(s,h){return new Promise(function(f,c){var l=new T(s,h);if(l.signal&&l.signal.aborted)return c(new t.DOMException('Aborted','AbortError'));var p=new XMLHttpRequest;function b(){p.abort()}p.onload=function(){var t,o,n={status:p.status,statusText:p.statusText,headers:(t=p.getAllResponseHeaders()||'',o=new y,t.replace(/\r?\n[\t ]+/g,' ').split(/\r?\n/).forEach(function(t){var n=t.split(':'),s=n.shift().trim();if(s){var h=n.join(':').trim();o.append(s,h)}}),o)};n.url='responseURL'in p?p.responseURL:n.headers.get('X-Request-URL');var s='response'in p?p.response:p.responseText;setTimeout(function(){f(new B(s,n))},0)},p.onerror=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.ontimeout=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.onabort=function(){setTimeout(function(){c(new t.DOMException('Aborted','AbortError'))},0)},p.open(l.method,(function(t){try{return''===t&&o.location.href?o.location.href:t}catch(o){return t}})(l.url),!0),'include'===l.credentials?p.withCredentials=!0:'omit'===l.credentials&&(p.withCredentials=!1),'responseType'in p&&(n.blob?p.responseType='blob':n.arrayBuffer&&l.headers.get('Content-Type')&&-1!==l.headers.get('Content-Type').indexOf('application/octet-stream')&&(p.responseType='arraybuffer')),!h||'object'!=typeof h.headers||h.headers instanceof y?l.headers.forEach(function(t,o){p.setRequestHeader(o,t)}):Object.getOwnPropertyNames(h.headers).forEach(function(t){p.setRequestHeader(t,u(h.headers[t]))}),l.signal&&(l.signal.addEventListener('abort',b),p.onreadystatechange=function(){4===p.readyState&&l.signal.removeEventListener('abort',b)}),p.send(void 0===l._bodyInit?null:l._bodyInit)})}O.polyfill=!0,o.fetch||(o.fetch=O,o.Headers=y,o.Request=T,o.Response=B),t.Headers=y,t.Request=T,t.Response=B,t.fetch=O,Object.defineProperty(t,'__esModule',{value:!0})},'object'==typeof e&&void 0!==m?o(e):'function'==typeof define&&define.amd?define(['exports'],o):o(t.WHATWGFetch={})},134,[]);^~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:140:2106: warning: the variable "FormData" was not declared in anonymous function " 469#"__d(function(g,r,i,a,m,e,d){var t,o;t=this,o=function(t){'use strict';var o='undefined'!=typeof globalThis&&globalThis||'undefined'!=typeof self&&self||void 0!==o&&o,n={searchParams:'URLSearchParams'in o,iterable:'Symbol'in o&&'iterator'in Symbol,blob:'FileReader'in o&&'Blob'in o&&(function(){try{return new Blob,!0}catch(t){return!1}})(),formData:'FormData'in o,arrayBuffer:'ArrayBuffer'in o};if(n.arrayBuffer)var s=['[object Int8Array]','[object Uint8Array]','[object Uint8ClampedArray]','[object Int16Array]','[object Uint16Array]','[object Int32Array]','[object Uint32Array]','[object Float32Array]','[object Float64Array]'],h=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if('string'!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||''===t)throw new TypeError('Invalid character in header field name');return t.toLowerCase()}function u(t){return'string'!=typeof t&&(t=String(t)),t}function c(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function y(t){this.map={},t instanceof y?t.forEach(function(t,o){this.append(o,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(o){this.append(o,t[o])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError('Already read'));t.bodyUsed=!0}function p(t){return new Promise(function(o,n){t.onload=function(){o(t.result)},t.onerror=function(){n(t.error)}})}function b(t){var o=new FileReader,n=p(o);return o.readAsArrayBuffer(t),n}function w(t){for(var o=new Uint8Array(t),n=new Array(o.length),s=0;s<o.length;s++)n[s]=String.fromCharCode(o[s]);return n.join('')}function v(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){var o;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?'string'==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText='',this.headers.get('content-type')||('string'==typeof t?this.headers.set('content-type','text/plain;charset=UTF-8'):this._bodyBlob&&this._bodyBlob.type?this.headers.set('content-type',this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set('content-type','application/x-www-form-urlencoded;charset=UTF-8'))},n.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error('could not read FormData body as blob');return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=l(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(b)}),this.text=function(){var t,o,n,s=l(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,n=p(o),o.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(w(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error('could not read FormData body as text');return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}y.prototype.append=function(t,o){t=f(t),o=u(o);var n=this.map[t];this.map[t]=n?n+', '+o:o},y.prototype.delete=function(t){delete this.map[f(t)]},y.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},y.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},y.prototype.set=function(t,o){this.map[f(t)]=u(o)},y.prototype.forEach=function(t,o){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(o,this.map[n],n,this)},y.prototype.keys=function(){var t=[];return this.forEach(function(o,n){t.push(n)}),c(t)},y.prototype.values=function(){var t=[];return this.forEach(function(o){t.push(o)}),c(t)},y.prototype.entries=function(){var t=[];return this.forEach(function(o,n){t.push([n,o])}),c(t)},n.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);var E=['DELETE','GET','HEAD','OPTIONS','POST','PUT'];function T(t,o){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,s,h=(o=o||{}).body;if(t instanceof T){if(t.bodyUsed)throw new TypeError('Already read');this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new y(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,h||null==t._bodyInit||(h=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||'same-origin',!o.headers&&this.headers||(this.headers=new y(o.headers)),this.method=(n=o.method||this.method||'GET',s=n.toUpperCase(),E.indexOf(s)>-1?s:n),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,('GET'===this.method||'HEAD'===this.method)&&h)throw new TypeError('Body not allowed for GET or HEAD requests');if(this._initBody(h),!('GET'!==this.method&&'HEAD'!==this.method||'no-store'!==o.cache&&'no-cache'!==o.cache)){var f=/([?&])_=[^&]*/;if(f.test(this.url))this.url=this.url.replace(f,'$1_='+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?'&':'?')+'_='+(new Date).getTime()}}}function A(t){var o=new FormData;return t.trim().split('&').forEach(function(t){if(t){var n=t.split('='),s=n.shift().replace(/\+/g,' '),h=n.join('=').replace(/\+/g,' ');o.append(decodeURIComponent(s),decodeURIComponent(h))}}),o}function B(t,o){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o||(o={}),this.type='default',this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText='statusText'in o?o.statusText:'',this.headers=new y(o.headers),this.url=o.url||'',this._initBody(t)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},_.call(T.prototype),_.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var t=new B(null,{status:0,statusText:''});return t.type='error',t};var x=[301,302,303,307,308];B.redirect=function(t,o){if(-1===x.indexOf(o))throw new RangeError('Invalid status code');return new B(null,{status:o,headers:{location:t}})},t.DOMException=o.DOMException;try{new t.DOMException}catch(o){t.DOMException=function(t,o){this.message=t,this.name=o;var n=Error(t);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function O(s,h){return new Promise(function(f,c){var l=new T(s,h);if(l.signal&&l.signal.aborted)return c(new t.DOMException('Aborted','AbortError'));var p=new XMLHttpRequest;function b(){p.abort()}p.onload=function(){var t,o,n={status:p.status,statusText:p.statusText,headers:(t=p.getAllResponseHeaders()||'',o=new y,t.replace(/\r?\n[\t ]+/g,' ').split(/\r?\n/).forEach(function(t){var n=t.split(':'),s=n.shift().trim();if(s){var h=n.join(':').trim();o.append(s,h)}}),o)};n.url='responseURL'in p?p.responseURL:n.headers.get('X-Request-URL');var s='response'in p?p.response:p.responseText;setTimeout(function(){f(new B(s,n))},0)},p.onerror=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.ontimeout=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.onabort=function(){setTimeout(function(){c(new t.DOMException('Aborted','AbortError'))},0)},p.open(l.method,(function(t){try{return''===t&&o.location.href?o.location.href:t}catch(o){return t}})(l.url),!0),'include'===l.credentials?p.withCredentials=!0:'omit'===l.credentials&&(p.withCredentials=!1),'responseType'in p&&(n.blob?p.responseType='blob':n.arrayBuffer&&l.headers.get('Content-Type')&&-1!==l.headers.get('Content-Type').indexOf('application/octet-stream')&&(p.responseType='arraybuffer')),!h||'object'!=typeof h.headers||h.headers instanceof y?l.headers.forEach(function(t,o){p.setRequestHeader(o,t)}):Object.getOwnPropertyNames(h.headers).forEach(function(t){p.setRequestHeader(t,u(h.headers[t]))}),l.signal&&(l.signal.addEventListener('abort',b),p.onreadystatechange=function(){4===p.readyState&&l.signal.removeEventListener('abort',b)}),p.send(void 0===l._bodyInit?null:l._bodyInit)})}O.polyfill=!0,o.fetch||(o.fetch=O,o.Headers=y,o.Request=T,o.Response=B),t.Headers=y,t.Request=T,t.Response=B,t.fetch=O,Object.defineProperty(t,'__esModule',{value:!0})},'object'==typeof e&&void 0!==m?o(e):'function'==typeof define&&define.amd?define(['exports'],o):o(t.WHATWGFetch={})},134,[]);^~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:140:2179: warning: the variable "URLSearchParams" was not declared in anonymous function " 469#"__d(function(g,r,i,a,m,e,d){var t,o;t=this,o=function(t){'use strict';var o='undefined'!=typeof globalThis&&globalThis||'undefined'!=typeof self&&self||void 0!==o&&o,n={searchParams:'URLSearchParams'in o,iterable:'Symbol'in o&&'iterator'in Symbol,blob:'FileReader'in o&&'Blob'in o&&(function(){try{return new Blob,!0}catch(t){return!1}})(),formData:'FormData'in o,arrayBuffer:'ArrayBuffer'in o};if(n.arrayBuffer)var s=['[object Int8Array]','[object Uint8Array]','[object Uint8ClampedArray]','[object Int16Array]','[object Uint16Array]','[object Int32Array]','[object Uint32Array]','[object Float32Array]','[object Float64Array]'],h=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if('string'!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||''===t)throw new TypeError('Invalid character in header field name');return t.toLowerCase()}function u(t){return'string'!=typeof t&&(t=String(t)),t}function c(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function y(t){this.map={},t instanceof y?t.forEach(function(t,o){this.append(o,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(o){this.append(o,t[o])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError('Already read'));t.bodyUsed=!0}function p(t){return new Promise(function(o,n){t.onload=function(){o(t.result)},t.onerror=function(){n(t.error)}})}function b(t){var o=new FileReader,n=p(o);return o.readAsArrayBuffer(t),n}function w(t){for(var o=new Uint8Array(t),n=new Array(o.length),s=0;s<o.length;s++)n[s]=String.fromCharCode(o[s]);return n.join('')}function v(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){var o;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?'string'==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText='',this.headers.get('content-type')||('string'==typeof t?this.headers.set('content-type','text/plain;charset=UTF-8'):this._bodyBlob&&this._bodyBlob.type?this.headers.set('content-type',this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set('content-type','application/x-www-form-urlencoded;charset=UTF-8'))},n.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error('could not read FormData body as blob');return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=l(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(b)}),this.text=function(){var t,o,n,s=l(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,n=p(o),o.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(w(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error('could not read FormData body as text');return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}y.prototype.append=function(t,o){t=f(t),o=u(o);var n=this.map[t];this.map[t]=n?n+', '+o:o},y.prototype.delete=function(t){delete this.map[f(t)]},y.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},y.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},y.prototype.set=function(t,o){this.map[f(t)]=u(o)},y.prototype.forEach=function(t,o){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(o,this.map[n],n,this)},y.prototype.keys=function(){var t=[];return this.forEach(function(o,n){t.push(n)}),c(t)},y.prototype.values=function(){var t=[];return this.forEach(function(o){t.push(o)}),c(t)},y.prototype.entries=function(){var t=[];return this.forEach(function(o,n){t.push([n,o])}),c(t)},n.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);var E=['DELETE','GET','HEAD','OPTIONS','POST','PUT'];function T(t,o){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,s,h=(o=o||{}).body;if(t instanceof T){if(t.bodyUsed)throw new TypeError('Already read');this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new y(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,h||null==t._bodyInit||(h=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||'same-origin',!o.headers&&this.headers||(this.headers=new y(o.headers)),this.method=(n=o.method||this.method||'GET',s=n.toUpperCase(),E.indexOf(s)>-1?s:n),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,('GET'===this.method||'HEAD'===this.method)&&h)throw new TypeError('Body not allowed for GET or HEAD requests');if(this._initBody(h),!('GET'!==this.method&&'HEAD'!==this.method||'no-store'!==o.cache&&'no-cache'!==o.cache)){var f=/([?&])_=[^&]*/;if(f.test(this.url))this.url=this.url.replace(f,'$1_='+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?'&':'?')+'_='+(new Date).getTime()}}}function A(t){var o=new FormData;return t.trim().split('&').forEach(function(t){if(t){var n=t.split('='),s=n.shift().replace(/\+/g,' '),h=n.join('=').replace(/\+/g,' ');o.append(decodeURIComponent(s),decodeURIComponent(h))}}),o}function B(t,o){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o||(o={}),this.type='default',this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText='statusText'in o?o.statusText:'',this.headers=new y(o.headers),this.url=o.url||'',this._initBody(t)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},_.call(T.prototype),_.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var t=new B(null,{status:0,statusText:''});return t.type='error',t};var x=[301,302,303,307,308];B.redirect=function(t,o){if(-1===x.indexOf(o))throw new RangeError('Invalid status code');return new B(null,{status:o,headers:{location:t}})},t.DOMException=o.DOMException;try{new t.DOMException}catch(o){t.DOMException=function(t,o){this.message=t,this.name=o;var n=Error(t);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function O(s,h){return new Promise(function(f,c){var l=new T(s,h);if(l.signal&&l.signal.aborted)return c(new t.DOMException('Aborted','AbortError'));var p=new XMLHttpRequest;function b(){p.abort()}p.onload=function(){var t,o,n={status:p.status,statusText:p.statusText,headers:(t=p.getAllResponseHeaders()||'',o=new y,t.replace(/\r?\n[\t ]+/g,' ').split(/\r?\n/).forEach(function(t){var n=t.split(':'),s=n.shift().trim();if(s){var h=n.join(':').trim();o.append(s,h)}}),o)};n.url='responseURL'in p?p.responseURL:n.headers.get('X-Request-URL');var s='response'in p?p.response:p.responseText;setTimeout(function(){f(new B(s,n))},0)},p.onerror=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.ontimeout=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.onabort=function(){setTimeout(function(){c(new t.DOMException('Aborted','AbortError'))},0)},p.open(l.method,(function(t){try{return''===t&&o.location.href?o.location.href:t}catch(o){return t}})(l.url),!0),'include'===l.credentials?p.withCredentials=!0:'omit'===l.credentials&&(p.withCredentials=!1),'responseType'in p&&(n.blob?p.responseType='blob':n.arrayBuffer&&l.headers.get('Content-Type')&&-1!==l.headers.get('Content-Type').indexOf('application/octet-stream')&&(p.responseType='arraybuffer')),!h||'object'!=typeof h.headers||h.headers instanceof y?l.headers.forEach(function(t,o){p.setRequestHeader(o,t)}):Object.getOwnPropertyNames(h.headers).forEach(function(t){p.setRequestHeader(t,u(h.headers[t]))}),l.signal&&(l.signal.addEventListener('abort',b),p.onreadystatechange=function(){4===p.readyState&&l.signal.removeEventListener('abort',b)}),p.send(void 0===l._bodyInit?null:l._bodyInit)})}O.polyfill=!0,o.fetch||(o.fetch=O,o.Headers=y,o.Request=T,o.Response=B),t.Headers=y,t.Request=T,t.Response=B,t.fetch=O,Object.defineProperty(t,'__esModule',{value:!0})},'object'==typeof e&&void 0!==m?o(e):'function'==typeof define&&define.amd?define(['exports'],o):o(t.WHATWGFetch={})},134,[]);^~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:140:7589: warning: the variable "XMLHttpRequest" was not declared in anonymous function " 476#"__d(function(g,r,i,a,m,e,d){var t,o;t=this,o=function(t){'use strict';var o='undefined'!=typeof globalThis&&globalThis||'undefined'!=typeof self&&self||void 0!==o&&o,n={searchParams:'URLSearchParams'in o,iterable:'Symbol'in o&&'iterator'in Symbol,blob:'FileReader'in o&&'Blob'in o&&(function(){try{return new Blob,!0}catch(t){return!1}})(),formData:'FormData'in o,arrayBuffer:'ArrayBuffer'in o};if(n.arrayBuffer)var s=['[object Int8Array]','[object Uint8Array]','[object Uint8ClampedArray]','[object Int16Array]','[object Uint16Array]','[object Int32Array]','[object Uint32Array]','[object Float32Array]','[object Float64Array]'],h=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if('string'!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||''===t)throw new TypeError('Invalid character in header field name');return t.toLowerCase()}function u(t){return'string'!=typeof t&&(t=String(t)),t}function c(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function y(t){this.map={},t instanceof y?t.forEach(function(t,o){this.append(o,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(o){this.append(o,t[o])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError('Already read'));t.bodyUsed=!0}function p(t){return new Promise(function(o,n){t.onload=function(){o(t.result)},t.onerror=function(){n(t.error)}})}function b(t){var o=new FileReader,n=p(o);return o.readAsArrayBuffer(t),n}function w(t){for(var o=new Uint8Array(t),n=new Array(o.length),s=0;s<o.length;s++)n[s]=String.fromCharCode(o[s]);return n.join('')}function v(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){var o;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?'string'==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText='',this.headers.get('content-type')||('string'==typeof t?this.headers.set('content-type','text/plain;charset=UTF-8'):this._bodyBlob&&this._bodyBlob.type?this.headers.set('content-type',this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set('content-type','application/x-www-form-urlencoded;charset=UTF-8'))},n.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error('could not read FormData body as blob');return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=l(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(b)}),this.text=function(){var t,o,n,s=l(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,n=p(o),o.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(w(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error('could not read FormData body as text');return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}y.prototype.append=function(t,o){t=f(t),o=u(o);var n=this.map[t];this.map[t]=n?n+', '+o:o},y.prototype.delete=function(t){delete this.map[f(t)]},y.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},y.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},y.prototype.set=function(t,o){this.map[f(t)]=u(o)},y.prototype.forEach=function(t,o){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(o,this.map[n],n,this)},y.prototype.keys=function(){var t=[];return this.forEach(function(o,n){t.push(n)}),c(t)},y.prototype.values=function(){var t=[];return this.forEach(function(o){t.push(o)}),c(t)},y.prototype.entries=function(){var t=[];return this.forEach(function(o,n){t.push([n,o])}),c(t)},n.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);var E=['DELETE','GET','HEAD','OPTIONS','POST','PUT'];function T(t,o){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,s,h=(o=o||{}).body;if(t instanceof T){if(t.bodyUsed)throw new TypeError('Already read');this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new y(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,h||null==t._bodyInit||(h=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||'same-origin',!o.headers&&this.headers||(this.headers=new y(o.headers)),this.method=(n=o.method||this.method||'GET',s=n.toUpperCase(),E.indexOf(s)>-1?s:n),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,('GET'===this.method||'HEAD'===this.method)&&h)throw new TypeError('Body not allowed for GET or HEAD requests');if(this._initBody(h),!('GET'!==this.method&&'HEAD'!==this.method||'no-store'!==o.cache&&'no-cache'!==o.cache)){var f=/([?&])_=[^&]*/;if(f.test(this.url))this.url=this.url.replace(f,'$1_='+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?'&':'?')+'_='+(new Date).getTime()}}}function A(t){var o=new FormData;return t.trim().split('&').forEach(function(t){if(t){var n=t.split('='),s=n.shift().replace(/\+/g,' '),h=n.join('=').replace(/\+/g,' ');o.append(decodeURIComponent(s),decodeURIComponent(h))}}),o}function B(t,o){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o||(o={}),this.type='default',this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText='statusText'in o?o.statusText:'',this.headers=new y(o.headers),this.url=o.url||'',this._initBody(t)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},_.call(T.prototype),_.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var t=new B(null,{status:0,statusText:''});return t.type='error',t};var x=[301,302,303,307,308];B.redirect=function(t,o){if(-1===x.indexOf(o))throw new RangeError('Invalid status code');return new B(null,{status:o,headers:{location:t}})},t.DOMException=o.DOMException;try{new t.DOMException}catch(o){t.DOMException=function(t,o){this.message=t,this.name=o;var n=Error(t);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function O(s,h){return new Promise(function(f,c){var l=new T(s,h);if(l.signal&&l.signal.aborted)return c(new t.DOMException('Aborted','AbortError'));var p=new XMLHttpRequest;function b(){p.abort()}p.onload=function(){var t,o,n={status:p.status,statusText:p.statusText,headers:(t=p.getAllResponseHeaders()||'',o=new y,t.replace(/\r?\n[\t ]+/g,' ').split(/\r?\n/).forEach(function(t){var n=t.split(':'),s=n.shift().trim();if(s){var h=n.join(':').trim();o.append(s,h)}}),o)};n.url='responseURL'in p?p.responseURL:n.headers.get('X-Request-URL');var s='response'in p?p.response:p.responseText;setTimeout(function(){f(new B(s,n))},0)},p.onerror=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.ontimeout=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.onabort=function(){setTimeout(function(){c(new t.DOMException('Aborted','AbortError'))},0)},p.open(l.method,(function(t){try{return''===t&&o.location.href?o.location.href:t}catch(o){return t}})(l.url),!0),'include'===l.credentials?p.withCredentials=!0:'omit'===l.credentials&&(p.withCredentials=!1),'responseType'in p&&(n.blob?p.responseType='blob':n.arrayBuffer&&l.headers.get('Content-Type')&&-1!==l.headers.get('Content-Type').indexOf('application/octet-stream')&&(p.responseType='arraybuffer')),!h||'object'!=typeof h.headers||h.headers instanceof y?l.headers.forEach(function(t,o){p.setRequestHeader(o,t)}):Object.getOwnPropertyNames(h.headers).forEach(function(t){p.setRequestHeader(t,u(h.headers[t]))}),l.signal&&(l.signal.addEventListener('abort',b),p.onreadystatechange=function(){4===p.readyState&&l.signal.removeEventListener('abort',b)}),p.send(void 0===l._bodyInit?null:l._bodyInit)})}O.polyfill=!0,o.fetch||(o.fetch=O,o.Headers=y,o.Request=T,o.Response=B),t.Headers=y,t.Request=T,t.Response=B,t.fetch=O,Object.defineProperty(t,'__esModule',{value:!0})},'object'==typeof e&&void 0!==m?o(e):'function'==typeof define&&define.amd?define(['exports'],o):o(t.WHATWGFetch={})},134,[]);^~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:140:141: warning: the variable "self" was not declared in function "o 17#"__d(function(g,r,i,a,m,e,d){var t,o;t=this,o=function(t){'use strict';var o='undefined'!=typeof globalThis&&globalThis||'undefined'!=typeof self&&self||void 0!==o&&o,n={searchParams:'URLSearchParams'in o,iterable:'Symbol'in o&&'iterator'in Symbol,blob:'FileReader'in o&&'Blob'in o&&(function(){try{return new Blob,!0}catch(t){return!1}})(),formData:'FormData'in o,arrayBuffer:'ArrayBuffer'in o};if(n.arrayBuffer)var s=['[object Int8Array]','[object Uint8Array]','[object Uint8ClampedArray]','[object Int16Array]','[object Uint16Array]','[object Int32Array]','[object Uint32Array]','[object Float32Array]','[object Float64Array]'],h=ArrayBuffer.isView||function(t){return t&&s.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if('string'!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||''===t)throw new TypeError('Invalid character in header field name');return t.toLowerCase()}function u(t){return'string'!=typeof t&&(t=String(t)),t}function c(t){var o={next:function(){var o=t.shift();return{done:void 0===o,value:o}}};return n.iterable&&(o[Symbol.iterator]=function(){return o}),o}function y(t){this.map={},t instanceof y?t.forEach(function(t,o){this.append(o,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(o){this.append(o,t[o])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError('Already read'));t.bodyUsed=!0}function p(t){return new Promise(function(o,n){t.onload=function(){o(t.result)},t.onerror=function(){n(t.error)}})}function b(t){var o=new FileReader,n=p(o);return o.readAsArrayBuffer(t),n}function w(t){for(var o=new Uint8Array(t),n=new Array(o.length),s=0;s<o.length;s++)n[s]=String.fromCharCode(o[s]);return n.join('')}function v(t){if(t.slice)return t.slice(0);var o=new Uint8Array(t.byteLength);return o.set(new Uint8Array(t)),o.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(t){var o;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?'string'==typeof t?this._bodyText=t:n.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():n.arrayBuffer&&n.blob&&((o=t)&&DataView.prototype.isPrototypeOf(o))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):n.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText='',this.headers.get('content-type')||('string'==typeof t?this.headers.set('content-type','text/plain;charset=UTF-8'):this._bodyBlob&&this._bodyBlob.type?this.headers.set('content-type',this._bodyBlob.type):n.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set('content-type','application/x-www-form-urlencoded;charset=UTF-8'))},n.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error('could not read FormData body as blob');return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=l(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(b)}),this.text=function(){var t,o,n,s=l(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,o=new FileReader,n=p(o),o.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(w(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error('could not read FormData body as text');return Promise.resolve(this._bodyText)},n.formData&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}y.prototype.append=function(t,o){t=f(t),o=u(o);var n=this.map[t];this.map[t]=n?n+', '+o:o},y.prototype.delete=function(t){delete this.map[f(t)]},y.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},y.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},y.prototype.set=function(t,o){this.map[f(t)]=u(o)},y.prototype.forEach=function(t,o){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(o,this.map[n],n,this)},y.prototype.keys=function(){var t=[];return this.forEach(function(o,n){t.push(n)}),c(t)},y.prototype.values=function(){var t=[];return this.forEach(function(o){t.push(o)}),c(t)},y.prototype.entries=function(){var t=[];return this.forEach(function(o,n){t.push([n,o])}),c(t)},n.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);var E=['DELETE','GET','HEAD','OPTIONS','POST','PUT'];function T(t,o){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,s,h=(o=o||{}).body;if(t instanceof T){if(t.bodyUsed)throw new TypeError('Already read');this.url=t.url,this.credentials=t.credentials,o.headers||(this.headers=new y(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,h||null==t._bodyInit||(h=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=o.credentials||this.credentials||'same-origin',!o.headers&&this.headers||(this.headers=new y(o.headers)),this.method=(n=o.method||this.method||'GET',s=n.toUpperCase(),E.indexOf(s)>-1?s:n),this.mode=o.mode||this.mode||null,this.signal=o.signal||this.signal,this.referrer=null,('GET'===this.method||'HEAD'===this.method)&&h)throw new TypeError('Body not allowed for GET or HEAD requests');if(this._initBody(h),!('GET'!==this.method&&'HEAD'!==this.method||'no-store'!==o.cache&&'no-cache'!==o.cache)){var f=/([?&])_=[^&]*/;if(f.test(this.url))this.url=this.url.replace(f,'$1_='+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?'&':'?')+'_='+(new Date).getTime()}}}function A(t){var o=new FormData;return t.trim().split('&').forEach(function(t){if(t){var n=t.split('='),s=n.shift().replace(/\+/g,' '),h=n.join('=').replace(/\+/g,' ');o.append(decodeURIComponent(s),decodeURIComponent(h))}}),o}function B(t,o){if(!(this instanceof B))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');o||(o={}),this.type='default',this.status=void 0===o.status?200:o.status,this.ok=this.status>=200&&this.status<300,this.statusText='statusText'in o?o.statusText:'',this.headers=new y(o.headers),this.url=o.url||'',this._initBody(t)}T.prototype.clone=function(){return new T(this,{body:this._bodyInit})},_.call(T.prototype),_.call(B.prototype),B.prototype.clone=function(){return new B(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},B.error=function(){var t=new B(null,{status:0,statusText:''});return t.type='error',t};var x=[301,302,303,307,308];B.redirect=function(t,o){if(-1===x.indexOf(o))throw new RangeError('Invalid status code');return new B(null,{status:o,headers:{location:t}})},t.DOMException=o.DOMException;try{new t.DOMException}catch(o){t.DOMException=function(t,o){this.message=t,this.name=o;var n=Error(t);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function O(s,h){return new Promise(function(f,c){var l=new T(s,h);if(l.signal&&l.signal.aborted)return c(new t.DOMException('Aborted','AbortError'));var p=new XMLHttpRequest;function b(){p.abort()}p.onload=function(){var t,o,n={status:p.status,statusText:p.statusText,headers:(t=p.getAllResponseHeaders()||'',o=new y,t.replace(/\r?\n[\t ]+/g,' ').split(/\r?\n/).forEach(function(t){var n=t.split(':'),s=n.shift().trim();if(s){var h=n.join(':').trim();o.append(s,h)}}),o)};n.url='responseURL'in p?p.responseURL:n.headers.get('X-Request-URL');var s='response'in p?p.response:p.responseText;setTimeout(function(){f(new B(s,n))},0)},p.onerror=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.ontimeout=function(){setTimeout(function(){c(new TypeError('Network request failed'))},0)},p.onabort=function(){setTimeout(function(){c(new t.DOMException('Aborted','AbortError'))},0)},p.open(l.method,(function(t){try{return''===t&&o.location.href?o.location.href:t}catch(o){return t}})(l.url),!0),'include'===l.credentials?p.withCredentials=!0:'omit'===l.credentials&&(p.withCredentials=!1),'responseType'in p&&(n.blob?p.responseType='blob':n.arrayBuffer&&l.headers.get('Content-Type')&&-1!==l.headers.get('Content-Type').indexOf('application/octet-stream')&&(p.responseType='arraybuffer')),!h||'object'!=typeof h.headers||h.headers instanceof y?l.headers.forEach(function(t,o){p.setRequestHeader(o,t)}):Object.getOwnPropertyNames(h.headers).forEach(function(t){p.setRequestHeader(t,u(h.headers[t]))}),l.signal&&(l.signal.addEventListener('abort',b),p.onreadystatechange=function(){4===p.readyState&&l.signal.removeEventListener('abort',b)}),p.send(void 0===l._bodyInit?null:l._bodyInit)})}O.polyfill=!0,o.fetch||(o.fetch=O,o.Headers=y,o.Request=T,o.Response=B),t.Headers=y,t.Request=T,t.Response=B,t.fetch=O,Object.defineProperty(t,'__esModule',{value:!0})},'object'==typeof e&&void 0!==m?o(e):'function'==typeof define&&define.amd?define(['exports'],o):o(t.WHATWGFetch={})},134,[]);^~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:191:74: warning: the variable "performance" was not declared in anonymous function " 623#"__d(function(g,r,i,a,m,e,d){'use strict';var n,t,o,l;if("object"==typeof performance&&"function"==typeof performance.now){var u=performance;e.unstable_now=function(){return u.now()}}else{var s=Date,c=s.now();e.unstable_now=function(){return s.now()-c}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var f=null,b=null,p=function n(){if(null!==f)try{var t=e.unstable_now();f(!0,t),f=null}catch(t){throw setTimeout(n,0),t}};n=function(t){null!==f?setTimeout(n,0,t):(f=t,setTimeout(p,0))},t=function(n,t){b=setTimeout(n,t)},o=function(){clearTimeout(b)},e.unstable_shouldYield=function(){return!1},l=e.unstable_forceFrameRate=function(){}}else{var v=window.setTimeout,y=window.clearTimeout;if("undefined"!=typeof console){var w=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof w&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var _=!1,h=null,k=-1,T=5,x=0;e.unstable_shouldYield=function(){return e.unstable_now()>=x},l=function(){},e.unstable_forceFrameRate=function(n){0>n||125<n?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<n?Math.floor(1e3/n):5};var P=new MessageChannel,F=P.port2;P.port1.onmessage=function(){if(null!==h){var n=e.unstable_now();x=n+T;try{h(!0,n)?F.postMessage(null):(_=!1,h=null)}catch(n){throw F.postMessage(null),n}}else _=!1},n=function(n){h=n,_||(_=!0,F.postMessage(null))},t=function(n,t){k=v(function(){n(e.unstable_now())},t)},o=function(){y(k),k=-1}}function I(n,t){var o=n.length;n.push(t);e:for(;;){var l=o-1>>>1,u=n[l];if(!(void 0!==u&&0<j(u,t)))break e;n[l]=t,n[o]=u,o=l}}function M(n){return void 0===(n=n[0])?null:n}function C(n){var t=n[0];if(void 0!==t){var o=n.pop();if(o!==t){n[0]=o;e:for(var l=0,u=n.length;l<u;){var s=2*(l+1)-1,c=n[s],f=s+1,b=n[f];if(void 0!==c&&0>j(c,o))void 0!==b&&0>j(b,c)?(n[l]=b,n[f]=o,l=f):(n[l]=c,n[s]=o,l=s);else{if(!(void 0!==b&&0>j(b,o)))break e;n[l]=b,n[f]=o,l=f}}}return t}return null}function j(n,t){var o=n.sortIndex-t.sortIndex;return 0!==o?o:n.id-t.id}var A=[],L=[],q=1,R=null,Y=3,E=!1,N=!1,B=!1;function D(n){for(var t=M(L);null!==t;){if(null===t.callback)C(L);else{if(!(t.startTime<=n))break;C(L),t.sortIndex=t.expirationTime,I(A,t)}t=M(L)}}function U(o){if(B=!1,D(o),!N)if(null!==M(A))N=!0,n(W);else{var l=M(L);null!==l&&t(U,l.startTime-o)}}function W(n,l){N=!1,B&&(B=!1,o()),E=!0;var u=Y;try{for(D(l),R=M(A);null!==R&&(!(R.expirationTime>l)||n&&!e.unstable_shouldYield());){var s=R.callback;if("function"==typeof s){R.callback=null,Y=R.priorityLevel;var c=s(R.expirationTime<=l);l=e.unstable_now(),"function"==typeof c?R.callback=c:R===M(A)&&C(A),D(l)}else C(A);R=M(A)}if(null!==R)var f=!0;else{var b=M(L);null!==b&&t(U,b.startTime-l),f=!1}return f}finally{R=null,Y=u,E=!1}}var z=l;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(n){n.callback=null},e.unstable_continueExecution=function(){N||E||(N=!0,n(W))},e.unstable_getCurrentPriorityLevel=function(){return Y},e.unstable_getFirstCallbackNode=function(){return M(A)},e.unstable_next=function(n){switch(Y){case 1:case 2:case 3:var t=3;break;default:t=Y}var o=Y;Y=t;try{return n()}finally{Y=o}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=z,e.unstable_runWithPriority=function(n,t){switch(n){case 1:case 2:case 3:case 4:case 5:break;default:n=3}var o=Y;Y=n;try{return t()}finally{Y=o}},e.unstable_scheduleCallback=function(l,u,s){var c=e.unstable_now();switch("object"==typeof s&&null!==s?s="number"==typeof(s=s.delay)&&0<s?c+s:c:s=c,l){case 1:var f=-1;break;case 2:f=250;break;case 5:f=1073741823;break;case 4:f=1e4;break;default:f=5e3}return l={id:q++,callback:u,priorityLevel:l,startTime:s,expirationTime:f=s+f,sortIndex:-1},s>c?(l.sortIndex=s,I(L,l),null===M(A)&&l===M(L)&&(B?o():B=!0,t(U,s-c))):(l.sortIndex=f,I(A,l),N||E||(N=!0,n(W))),l},e.unstable_wrapCallback=function(n){var t=Y;return function(){var o=Y;Y=t;try{return n.apply(this,arguments)}finally{Y=o}}}},185,[]);^~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:191:303: warning: the variable "MessageChannel" was not declared in anonymous function " 623#"__d(function(g,r,i,a,m,e,d){'use strict';var n,t,o,l;if("object"==typeof performance&&"function"==typeof performance.now){var u=performance;e.unstable_now=function(){return u.now()}}else{var s=Date,c=s.now();e.unstable_now=function(){return s.now()-c}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var f=null,b=null,p=function n(){if(null!==f)try{var t=e.unstable_now();f(!0,t),f=null}catch(t){throw setTimeout(n,0),t}};n=function(t){null!==f?setTimeout(n,0,t):(f=t,setTimeout(p,0))},t=function(n,t){b=setTimeout(n,t)},o=function(){clearTimeout(b)},e.unstable_shouldYield=function(){return!1},l=e.unstable_forceFrameRate=function(){}}else{var v=window.setTimeout,y=window.clearTimeout;if("undefined"!=typeof console){var w=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof w&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var _=!1,h=null,k=-1,T=5,x=0;e.unstable_shouldYield=function(){return e.unstable_now()>=x},l=function(){},e.unstable_forceFrameRate=function(n){0>n||125<n?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):T=0<n?Math.floor(1e3/n):5};var P=new MessageChannel,F=P.port2;P.port1.onmessage=function(){if(null!==h){var n=e.unstable_now();x=n+T;try{h(!0,n)?F.postMessage(null):(_=!1,h=null)}catch(n){throw F.postMessage(null),n}}else _=!1},n=function(n){h=n,_||(_=!0,F.postMessage(null))},t=function(n,t){k=v(function(){n(e.unstable_now())},t)},o=function(){y(k),k=-1}}function I(n,t){var o=n.length;n.push(t);e:for(;;){var l=o-1>>>1,u=n[l];if(!(void 0!==u&&0<j(u,t)))break e;n[l]=t,n[o]=u,o=l}}function M(n){return void 0===(n=n[0])?null:n}function C(n){var t=n[0];if(void 0!==t){var o=n.pop();if(o!==t){n[0]=o;e:for(var l=0,u=n.length;l<u;){var s=2*(l+1)-1,c=n[s],f=s+1,b=n[f];if(void 0!==c&&0>j(c,o))void 0!==b&&0>j(b,c)?(n[l]=b,n[f]=o,l=f):(n[l]=c,n[s]=o,l=s);else{if(!(void 0!==b&&0>j(b,o)))break e;n[l]=b,n[f]=o,l=f}}}return t}return null}function j(n,t){var o=n.sortIndex-t.sortIndex;return 0!==o?o:n.id-t.id}var A=[],L=[],q=1,R=null,Y=3,E=!1,N=!1,B=!1;function D(n){for(var t=M(L);null!==t;){if(null===t.callback)C(L);else{if(!(t.startTime<=n))break;C(L),t.sortIndex=t.expirationTime,I(A,t)}t=M(L)}}function U(o){if(B=!1,D(o),!N)if(null!==M(A))N=!0,n(W);else{var l=M(L);null!==l&&t(U,l.startTime-o)}}function W(n,l){N=!1,B&&(B=!1,o()),E=!0;var u=Y;try{for(D(l),R=M(A);null!==R&&(!(R.expirationTime>l)||n&&!e.unstable_shouldYield());){var s=R.callback;if("function"==typeof s){R.callback=null,Y=R.priorityLevel;var c=s(R.expirationTime<=l);l=e.unstable_now(),"function"==typeof c?R.callback=c:R===M(A)&&C(A),D(l)}else C(A);R=M(A)}if(null!==R)var f=!0;else{var b=M(L);null!==b&&t(U,b.startTime-l),f=!1}return f}finally{R=null,Y=u,E=!1}}var z=l;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(n){n.callback=null},e.unstable_continueExecution=function(){N||E||(N=!0,n(W))},e.unstable_getCurrentPriorityLevel=function(){return Y},e.unstable_getFirstCallbackNode=function(){return M(A)},e.unstable_next=function(n){switch(Y){case 1:case 2:case 3:var t=3;break;default:t=Y}var o=Y;Y=t;try{return n()}finally{Y=o}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=z,e.unstable_runWithPriority=function(n,t){switch(n){case 1:case 2:case 3:case 4:case 5:break;default:n=3}var o=Y;Y=n;try{return t()}finally{Y=o}},e.unstable_scheduleCallback=function(l,u,s){var c=e.unstable_now();switch("object"==typeof s&&null!==s?s="number"==typeof(s=s.delay)&&0<s?c+s:c:s=c,l){case 1:var f=-1;break;case 2:f=250;break;case 5:f=1073741823;break;case 4:f=1e4;break;default:f=5e3}return l={id:q++,callback:u,priorityLevel:l,startTime:s,expirationTime:f=s+f,sortIndex:-1},s>c?(l.sortIndex=s,I(L,l),null===M(A)&&l===M(L)&&(B?o():B=!0,t(U,s-c))):(l.sortIndex=f,I(A,l),N||E||(N=!0,n(W))),l},e.unstable_wrapCallback=function(n){var t=Y;return function(){var o=Y;Y=t;try{return n.apply(this,arguments)}finally{Y=o}}}},185,[]);^~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:216:316: warning: the variable "document" was not declared in anonymous function " 714#"__d(function(g,r,i,a,m,e,d){'use strict';var n=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.isHoverEnabled=function(){return t};var t=!1;if('web'===n(r(d[1])).default.OS&&Boolean('undefined'!=typeof window&&window.document&&window.document.createElement)){var o=0,u=function(){o=Date.now(),t&&(t=!1)};document.addEventListener('touchstart',u,!0),document.addEventListener('touchmove',u,!0),document.addEventListener('mousemove',function(){t||Date.now()-o<1e3||(t=!0)},!0)}},210,[2,52]);^~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:244:1243: warning: the variable "requestAnimationFrame" was not declared in function "value 318#"__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]);function _(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}var h=r(d[6]),l=r(d[7]).shouldUseNativeDriver,v=(function(v){o(D,h);var f,p,y=(f=D,p=_(),function(){var t,n=u(f);if(p){var s=u(this).constructor;t=Reflect.construct(n,arguments,s)}else t=n.apply(this,arguments);return c(this,t)});function D(n){var s,o,c,u;return t(this,D),(u=y.call(this))._deceleration=null!=(s=n.deceleration)?s:.998,u._velocity=n.velocity,u._useNativeDriver=l(n),u.__isInteraction=null!=(o=n.isInteraction)?o:!u._useNativeDriver,u.__iterations=null!=(c=n.iterations)?c:1,u}return n(D,[{key:"__getNativeAnimationConfig",value:function(){return{type:'decay',deceleration:this._deceleration,velocity:this._velocity,iterations:this.__iterations}}},{key:"start",value:function(t,n,s,o,c){this.__active=!0,this._lastValue=t,this._fromValue=t,this._onUpdate=n,this.__onEnd=s,this._startTime=Date.now(),this._useNativeDriver?this.__startNativeAnimation(c):this._animationFrame=requestAnimationFrame(this.onUpdate.bind(this))}},{key:"onUpdate",value:function(){var t=Date.now(),n=this._fromValue+this._velocity/(1-this._deceleration)*(1-Math.exp(-(1-this._deceleration)*(t-this._startTime)));this._onUpdate(n),Math.abs(this._lastValue-n)<.1?this.__debouncedOnEnd({finished:!0}):(this._lastValue=n,this.__active&&(this._animationFrame=requestAnimationFrame(this.onUpdate.bind(this))))}},{key:"stop",value:function(){s(u(D.prototype),"stop",this).call(this),this.__active=!1,g.cancelAnimationFrame(this._animationFrame),this.__debouncedOnEnd({finished:!1})}}]),D})();m.exports=v},238,[7,8,22,9,11,13,239,220]);^~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:301:3162: warning: the variable "clearImmediate" was not declared in anonymous function " 1106#"__d(function(g,r,i,a,m,e,d){'use strict';var t,n=r(d[0]),u=n(r(d[1])),o=n(r(d[2])),l=n(r(d[3])),c=n(r(d[4])),s=n(r(d[5])),f=n(r(d[6])),p=n(r(d[7]));n(r(d[8]));function k(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}r(d[9]);var y=r(d[10]),v=r(d[11]),S=r(d[12]);function _(t){return{backgroundColor:null!=t.backgroundColor?{value:t.backgroundColor,animated:t.animated}:null,barStyle:null!=t.barStyle?{value:t.barStyle,animated:t.animated}:null,translucent:t.translucent,hidden:null!=t.hidden?{value:t.hidden,animated:t.animated,transition:t.showHideTransition}:null,networkActivityIndicatorVisible:t.networkActivityIndicatorVisible}}var h=(function(t){(0,l.default)(h,t);var n,f,y=(n=h,f=k(),function(){var t,u=(0,s.default)(n);if(f){var o=(0,s.default)(this).constructor;t=Reflect.construct(u,arguments,o)}else t=u.apply(this,arguments);return(0,c.default)(this,t)});function h(){var t;(0,u.default)(this,h);for(var n=arguments.length,o=new Array(n),l=0;l<n;l++)o[l]=arguments[l];return(t=y.call.apply(y,[this].concat(o)))._stackEntry=null,t}return(0,o.default)(h,[{key:"componentDidMount",value:function(){this._stackEntry=h.pushStackEntry(this.props)}},{key:"componentWillUnmount",value:function(){h.popStackEntry(this._stackEntry)}},{key:"componentDidUpdate",value:function(){this._stackEntry=h.replaceStackEntry(this._stackEntry,this.props)}},{key:"render",value:function(){return null}}],[{key:"setHidden",value:function(t,n){n=n||'none',h._defaultProps.hidden.value=t,p.default.setHidden(t)}},{key:"setBarStyle",value:function(t,n){n=n||!1,h._defaultProps.barStyle.value=t,p.default.setStyle(t)}},{key:"setNetworkActivityIndicatorVisible",value:function(t){console.warn('`setNetworkActivityIndicatorVisible` is only available on iOS')}},{key:"setBackgroundColor",value:function(t,n){n=n||!1,h._defaultProps.backgroundColor.value=t;var u=S(t);null!=u?(v('number'==typeof u,'Unexpected color given for StatusBar.setBackgroundColor'),p.default.setColor(u,n)):console.warn("`StatusBar.setBackgroundColor`: Color "+t+" parsed to null or undefined")}},{key:"setTranslucent",value:function(t){h._defaultProps.translucent=t,p.default.setTranslucent(t)}},{key:"pushStackEntry",value:function(t){var n=_(t);return h._propsStack.push(n),h._updatePropsStack(),n}},{key:"popStackEntry",value:function(t){var n=h._propsStack.indexOf(t);-1!==n&&h._propsStack.splice(n,1),h._updatePropsStack()}},{key:"replaceStackEntry",value:function(t,n){var u=_(n),o=h._propsStack.indexOf(t);return-1!==o&&(h._propsStack[o]=u),h._updatePropsStack(),u}}]),h})(y.Component);h._propsStack=[],h._defaultProps=_({animated:!1,showHideTransition:'fade',backgroundColor:null!=(t=p.default.getConstants().DEFAULT_BACKGROUND_COLOR)?t:'black',barStyle:'default',translucent:!1,hidden:!1,networkActivityIndicatorVisible:!1}),h._updateImmediate=null,h._currentValues=null,h.currentHeight=p.default.getConstants().HEIGHT,h.defaultProps={animated:!1,showHideTransition:'fade'},h._updatePropsStack=function(){clearImmediate(h._updateImmediate),h._updateImmediate=setImmediate(function(){var t,n,u=h._currentValues,o=(t=h._propsStack,n=h._defaultProps,t.reduce(function(t,n){for(var u in n)null!=n[u]&&(t[u]=n[u]);return t},(0,f.default)({},n)));p.default.setStyle(o.barStyle.value);var l=S(o.backgroundColor.value);null==l?console.warn("`StatusBar._updatePropsStack`: Color "+o.backgroundColor.value+" parsed to null or undefined"):(v('number'==typeof l,'Unexpected color given in StatusBar._updatePropsStack'),p.default.setColor(l,o.backgroundColor.animated)),u&&u.hidden.value===o.hidden.value||p.default.setHidden(o.hidden.value),u&&u.translucent===o.translucent||p.default.setTranslucent(o.translucent),h._currentValues=o})},m.exports=h},295,[2,7,8,9,11,13,6,296,297,52,14,18,78]);^~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:438:956: warning: the variable "SharedArrayBuffer" was not declared in function "h 27#"__d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),o='function'==typeof Symbol&&'function'==typeof Symbol.for?Symbol.for('nodejs.util.inspect.custom'):null;e.Buffer=s,e.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},e.INSPECT_MAX_BYTES=50;var f=2147483647;function u(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=new Uint8Array(t);return Object.setPrototypeOf(n,s.prototype),n}function s(t,n,o){if('number'==typeof t){if('string'==typeof n)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return h(t,n,o)}function h(t,n,o){if('string'==typeof t)return y(t,n);if(ArrayBuffer.isView(t))return v(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Q(t,ArrayBuffer)||t&&Q(t.buffer,ArrayBuffer))return b(t,n,o);if('undefined'!=typeof SharedArrayBuffer&&(Q(t,SharedArrayBuffer)||t&&Q(t.buffer,SharedArrayBuffer)))return b(t,n,o);if('number'==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var f=t.valueOf&&t.valueOf();if(null!=f&&f!==t)return s.from(f,n,o);var u=E(t);if(u)return u;if('undefined'!=typeof Symbol&&null!=Symbol.toPrimitive&&'function'==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]('string'),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function p(t){if('number'!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t,n,o){return p(t),t<=0?u(t):void 0!==n?'string'==typeof o?u(t).fill(n,o):u(t).fill(n):u(t)}function l(t){return p(t),u(t<0?0:0|B(t))}function y(t,n){if('string'==typeof n&&''!==n||(n='utf8'),!s.isEncoding(n))throw new TypeError('Unknown encoding: '+n);var o=0|A(t,n),f=u(o),h=f.write(t,n);return h!==o&&(f=f.slice(0,h)),f}function w(t){for(var n=t.length<0?0:0|B(t.length),o=u(n),f=0;f<n;f+=1)o[f]=255&t[f];return o}function v(t){if(Q(t,Uint8Array)){var n=new Uint8Array(t);return b(n.buffer,n.byteOffset,n.byteLength)}return w(t)}function b(t,n,o){if(n<0||t.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');var f;return f=void 0===n&&void 0===o?new Uint8Array(t):void 0===o?new Uint8Array(t,n):new Uint8Array(t,n,o),Object.setPrototypeOf(f,s.prototype),f}function E(t){if(s.isBuffer(t)){var n=0|B(t.length),o=u(n);return 0===o.length?o:(t.copy(o,0,0,n),o)}return void 0!==t.length?'number'!=typeof t.length||tt(t.length)?u(0):w(t):'Buffer'===t.type&&Array.isArray(t.data)?w(t.data):void 0}function B(t){if(t>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+' bytes');return 0|t}function A(t,n){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Q(t,ArrayBuffer))return t.byteLength;if('string'!=typeof t)throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type "+typeof t);var o=t.length,f=arguments.length>2&&!0===arguments[2];if(!f&&0===o)return 0;for(var u=!1;;)switch(n){case'ascii':case'latin1':case'binary':return o;case'utf8':case'utf-8':return Z(t).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*o;case'hex':return o>>>1;case'base64':return H(t).length;default:if(u)return f?-1:Z(t).length;n=(''+n).toLowerCase(),u=!0}}function U(t,n,o){var f=!1;if((void 0===n||n<0)&&(n=0),n>this.length)return'';if((void 0===o||o>this.length)&&(o=this.length),o<=0)return'';if((o>>>=0)<=(n>>>=0))return'';for(t||(t='utf8');;)switch(t){case'hex':return D(this,n,o);case'utf8':case'utf-8':return k(this,n,o);case'ascii':return j(this,n,o);case'latin1':case'binary':return z(this,n,o);case'base64':return P(this,n,o);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return F(this,n,o);default:if(f)throw new TypeError('Unknown encoding: '+t);t=(t+'').toLowerCase(),f=!0}}function T(t,n,o){var f=t[n];t[n]=t[o],t[o]=f}function I(t,n,o,f,u){if(0===t.length)return-1;if('string'==typeof o?(f=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),tt(o=+o)&&(o=u?0:t.length-1),o<0&&(o=t.length+o),o>=t.length){if(u)return-1;o=t.length-1}else if(o<0){if(!u)return-1;o=0}if('string'==typeof n&&(n=s.from(n,f)),s.isBuffer(n))return 0===n.length?-1:L(t,n,o,f,u);if('number'==typeof n)return n&=255,'function'==typeof Uint8Array.prototype.indexOf?u?Uint8Array.prototype.indexOf.call(t,n,o):Uint8Array.prototype.lastIndexOf.call(t,n,o):L(t,[n],o,f,u);throw new TypeError('val must be string, number or Buffer')}function L(t,n,o,f,u){var s,h=1,p=t.length,c=n.length;if(void 0!==f&&('ucs2'===(f=String(f).toLowerCase())||'ucs-2'===f||'utf16le'===f||'utf-16le'===f)){if(t.length<2||n.length<2)return-1;h=2,p/=2,c/=2,o/=2}function l(t,n){return 1===h?t[n]:t.readUInt16BE(n*h)}if(u){var y=-1;for(s=o;s<p;s++)if(l(t,s)===l(n,-1===y?0:s-y)){if(-1===y&&(y=s),s-y+1===c)return y*h}else-1!==y&&(s-=s-y),y=-1}else for(o+c>p&&(o=p-c),s=o;s>=0;s--){for(var w=!0,v=0;v<c;v++)if(l(t,s+v)!==l(n,v)){w=!1;break}if(w)return s}return-1}function S(t,n,o,f){o=Number(o)||0;var u=t.length-o;f?(f=Number(f))>u&&(f=u):f=u;var s=n.length;f>s/2&&(f=s/2);for(var h=0;h<f;++h){var p=parseInt(n.substr(2*h,2),16);if(tt(p))return h;t[o+h]=p}return h}function O(t,n,o,f){return K(Z(n,t.length-o),t,o,f)}function R(t,n,o,f){return K($(n),t,o,f)}function x(t,n,o,f){return K(H(n),t,o,f)}function C(t,n,o,f){return K(G(n,t.length-o),t,o,f)}function P(n,o,f){return 0===o&&f===n.length?t.fromByteArray(n):t.fromByteArray(n.slice(o,f))}function k(t,n,o){o=Math.min(t.length,o);for(var f=[],u=n;u<o;){var s,h,p,c,l=t[u],y=null,w=l>239?4:l>223?3:l>191?2:1;if(u+w<=o)switch(w){case 1:l<128&&(y=l);break;case 2:128==(192&(s=t[u+1]))&&(c=(31&l)<<6|63&s)>127&&(y=c);break;case 3:s=t[u+1],h=t[u+2],128==(192&s)&&128==(192&h)&&(c=(15&l)<<12|(63&s)<<6|63&h)>2047&&(c<55296||c>57343)&&(y=c);break;case 4:s=t[u+1],h=t[u+2],p=t[u+3],128==(192&s)&&128==(192&h)&&128==(192&p)&&(c=(15&l)<<18|(63&s)<<12|(63&h)<<6|63&p)>65535&&c<1114112&&(y=c)}null===y?(y=65533,w=1):y>65535&&(y-=65536,f.push(y>>>10&1023|55296),y=56320|1023&y),f.push(y),u+=w}return _(f)}e.kMaxLength=f,s.TYPED_ARRAY_SUPPORT=(function(){try{var t=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(t,n),42===t.foo()}catch(t){return!1}})(),s.TYPED_ARRAY_SUPPORT||'undefined'==typeof console||'function'!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,'parent',{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,'offset',{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,n,o){return h(t,n,o)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,n,o){return c(t,n,o)},s.allocUnsafe=function(t){return l(t)},s.allocUnsafeSlow=function(t){return l(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,n){if(Q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),Q(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.isBuffer(t)||!s.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;for(var o=t.length,f=n.length,u=0,h=Math.min(o,f);u<h;++u)if(t[u]!==n[u]){o=t[u],f=n[u];break}return o<f?-1:f<o?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},s.concat=function(t,n){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);var o;if(void 0===n)for(n=0,o=0;o<t.length;++o)n+=t[o].length;var f=s.allocUnsafe(n),u=0;for(o=0;o<t.length;++o){var h=t[o];if(Q(h,Uint8Array))u+h.length>f.length?s.from(h).copy(f,u):Uint8Array.prototype.set.call(f,h,u);else{if(!s.isBuffer(h))throw new TypeError('"list" argument must be an Array of Buffers');h.copy(f,u)}u+=h.length}return f},s.byteLength=A,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var n=0;n<t;n+=2)T(this,n,n+1);return this},s.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var n=0;n<t;n+=4)T(this,n,n+3),T(this,n+1,n+2);return this},s.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var n=0;n<t;n+=8)T(this,n,n+7),T(this,n+1,n+6),T(this,n+2,n+5),T(this,n+3,n+4);return this},s.prototype.toString=function(){var t=this.length;return 0===t?'':0===arguments.length?k(this,0,t):U.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError('Argument must be a Buffer');return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t='',n=e.INSPECT_MAX_BYTES;return t=this.toString('hex',0,n).replace(/(.{2})/g,'$1 ').trim(),this.length>n&&(t+=' ... '),'<Buffer '+t+'>'},o&&(s.prototype[o]=s.prototype.inspect),s.prototype.compare=function(t,n,o,f,u){if(Q(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type "+typeof t);if(void 0===n&&(n=0),void 0===o&&(o=t?t.length:0),void 0===f&&(f=0),void 0===u&&(u=this.length),n<0||o>t.length||f<0||u>this.length)throw new RangeError('out of range index');if(f>=u&&n>=o)return 0;if(f>=u)return-1;if(n>=o)return 1;if(n>>>=0,o>>>=0,f>>>=0,u>>>=0,this===t)return 0;for(var h=u-f,p=o-n,c=Math.min(h,p),l=this.slice(f,u),y=t.slice(n,o),w=0;w<c;++w)if(l[w]!==y[w]){h=l[w],p=y[w];break}return h<p?-1:p<h?1:0},s.prototype.includes=function(t,n,o){return-1!==this.indexOf(t,n,o)},s.prototype.indexOf=function(t,n,o){return I(this,t,n,o,!0)},s.prototype.lastIndexOf=function(t,n,o){return I(this,t,n,o,!1)},s.prototype.write=function(t,n,o,f){if(void 0===n)f='utf8',o=this.length,n=0;else if(void 0===o&&'string'==typeof n)f=n,o=this.length,n=0;else{if(!isFinite(n))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');n>>>=0,isFinite(o)?(o>>>=0,void 0===f&&(f='utf8')):(f=o,o=void 0)}var u=this.length-n;if((void 0===o||o>u)&&(o=u),t.length>0&&(o<0||n<0)||n>this.length)throw new RangeError('Attempt to write outside buffer bounds');f||(f='utf8');for(var s=!1;;)switch(f){case'hex':return S(this,t,n,o);case'utf8':case'utf-8':return O(this,t,n,o);case'ascii':case'latin1':case'binary':return R(this,t,n,o);case'base64':return x(this,t,n,o);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return C(this,t,n,o);default:if(s)throw new TypeError('Unknown encoding: '+f);f=(''+f).toLowerCase(),s=!0}},s.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function _(t){var n=t.length;if(n<=M)return String.fromCharCode.apply(String,t);for(var o='',f=0;f<n;)o+=String.fromCharCode.apply(String,t.slice(f,f+=M));return o}function j(t,n,o){var f='';o=Math.min(t.length,o);for(var u=n;u<o;++u)f+=String.fromCharCode(127&t[u]);return f}function z(t,n,o){var f='';o=Math.min(t.length,o);for(var u=n;u<o;++u)f+=String.fromCharCode(t[u]);return f}function D(t,n,o){var f=t.length;(!n||n<0)&&(n=0),(!o||o<0||o>f)&&(o=f);for(var u='',s=n;s<o;++s)u+=rt[t[s]];return u}function F(t,n,o){for(var f=t.slice(n,o),u='',s=0;s<f.length-1;s+=2)u+=String.fromCharCode(f[s]+256*f[s+1]);return u}function N(t,n,o){if(t%1!=0||t<0)throw new RangeError('offset is not uint');if(t+n>o)throw new RangeError('Trying to access beyond buffer length')}function Y(t,n,o,f,u,h){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>u||n<h)throw new RangeError('"value" argument is out of bounds');if(o+f>t.length)throw new RangeError('Index out of range')}function q(t,n,o,f,u,s){if(o+f>t.length)throw new RangeError('Index out of range');if(o<0)throw new RangeError('Index out of range')}function V(t,o,f,u,s){return o=+o,f>>>=0,s||q(t,0,f,4),n.write(t,o,f,u,23,4),f+4}function W(t,o,f,u,s){return o=+o,f>>>=0,s||q(t,0,f,8),n.write(t,o,f,u,52,8),f+8}s.prototype.slice=function(t,n){var o=this.length;t=~~t,n=void 0===n?o:~~n,t<0?(t+=o)<0&&(t=0):t>o&&(t=o),n<0?(n+=o)<0&&(n=0):n>o&&(n=o),n<t&&(n=t);var f=this.subarray(t,n);return Object.setPrototypeOf(f,s.prototype),f},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,n,o){t>>>=0,n>>>=0,o||N(t,n,this.length);for(var f=this[t],u=1,s=0;++s<n&&(u*=256);)f+=this[t+s]*u;return f},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,n,o){t>>>=0,n>>>=0,o||N(t,n,this.length);for(var f=this[t+--n],u=1;n>0&&(u*=256);)f+=this[t+--n]*u;return f},s.prototype.readUint8=s.prototype.readUInt8=function(t,n){return t>>>=0,n||N(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,n){return t>>>=0,n||N(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,n){return t>>>=0,n||N(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,n){return t>>>=0,n||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,n){return t>>>=0,n||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,n,o){t>>>=0,n>>>=0,o||N(t,n,this.length);for(var f=this[t],u=1,s=0;++s<n&&(u*=256);)f+=this[t+s]*u;return f>=(u*=128)&&(f-=Math.pow(2,8*n)),f},s.prototype.readIntBE=function(t,n,o){t>>>=0,n>>>=0,o||N(t,n,this.length);for(var f=n,u=1,s=this[t+--f];f>0&&(u*=256);)s+=this[t+--f]*u;return s>=(u*=128)&&(s-=Math.pow(2,8*n)),s},s.prototype.readInt8=function(t,n){return t>>>=0,n||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,n){t>>>=0,n||N(t,2,this.length);var o=this[t]|this[t+1]<<8;return 32768&o?4294901760|o:o},s.prototype.readInt16BE=function(t,n){t>>>=0,n||N(t,2,this.length);var o=this[t+1]|this[t]<<8;return 32768&o?4294901760|o:o},s.prototype.readInt32LE=function(t,n){return t>>>=0,n||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,n){return t>>>=0,n||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,o){return t>>>=0,o||N(t,4,this.length),n.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,o){return t>>>=0,o||N(t,4,this.length),n.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,o){return t>>>=0,o||N(t,8,this.length),n.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,o){return t>>>=0,o||N(t,8,this.length),n.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,n,o,f){(t=+t,n>>>=0,o>>>=0,f)||Y(this,t,n,o,Math.pow(2,8*o)-1,0);var u=1,s=0;for(this[n]=255&t;++s<o&&(u*=256);)this[n+s]=t/u&255;return n+o},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,n,o,f){(t=+t,n>>>=0,o>>>=0,f)||Y(this,t,n,o,Math.pow(2,8*o)-1,0);var u=o-1,s=1;for(this[n+u]=255&t;--u>=0&&(s*=256);)this[n+u]=t/s&255;return n+o},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,1,255,0),this[n]=255&t,n+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,2,65535,0),this[n]=255&t,this[n+1]=t>>>8,n+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=255&t,n+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t,n+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t,n+4},s.prototype.writeIntLE=function(t,n,o,f){if(t=+t,n>>>=0,!f){var u=Math.pow(2,8*o-1);Y(this,t,n,o,u-1,-u)}var s=0,h=1,p=0;for(this[n]=255&t;++s<o&&(h*=256);)t<0&&0===p&&0!==this[n+s-1]&&(p=1),this[n+s]=(t/h>>0)-p&255;return n+o},s.prototype.writeIntBE=function(t,n,o,f){if(t=+t,n>>>=0,!f){var u=Math.pow(2,8*o-1);Y(this,t,n,o,u-1,-u)}var s=o-1,h=1,p=0;for(this[n+s]=255&t;--s>=0&&(h*=256);)t<0&&0===p&&0!==this[n+s+1]&&(p=1),this[n+s]=(t/h>>0)-p&255;return n+o},s.prototype.writeInt8=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=255&t,n+1},s.prototype.writeInt16LE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,2,32767,-32768),this[n]=255&t,this[n+1]=t>>>8,n+2},s.prototype.writeInt16BE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=255&t,n+2},s.prototype.writeInt32LE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,4,2147483647,-2147483648),this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4},s.prototype.writeInt32BE=function(t,n,o){return t=+t,n>>>=0,o||Y(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t,n+4},s.prototype.writeFloatLE=function(t,n,o){return V(this,t,n,!0,o)},s.prototype.writeFloatBE=function(t,n,o){return V(this,t,n,!1,o)},s.prototype.writeDoubleLE=function(t,n,o){return W(this,t,n,!0,o)},s.prototype.writeDoubleBE=function(t,n,o){return W(this,t,n,!1,o)},s.prototype.copy=function(t,n,o,f){if(!s.isBuffer(t))throw new TypeError('argument should be a Buffer');if(o||(o=0),f||0===f||(f=this.length),n>=t.length&&(n=t.length),n||(n=0),f>0&&f<o&&(f=o),f===o)return 0;if(0===t.length||0===this.length)return 0;if(n<0)throw new RangeError('targetStart out of bounds');if(o<0||o>=this.length)throw new RangeError('Index out of range');if(f<0)throw new RangeError('sourceEnd out of bounds');f>this.length&&(f=this.length),t.length-n<f-o&&(f=t.length-n+o);var u=f-o;return this===t&&'function'==typeof Uint8Array.prototype.copyWithin?this.copyWithin(n,o,f):Uint8Array.prototype.set.call(t,this.subarray(o,f),n),u},s.prototype.fill=function(t,n,o,f){if('string'==typeof t){if('string'==typeof n?(f=n,n=0,o=this.length):'string'==typeof o&&(f=o,o=this.length),void 0!==f&&'string'!=typeof f)throw new TypeError('encoding must be a string');if('string'==typeof f&&!s.isEncoding(f))throw new TypeError('Unknown encoding: '+f);if(1===t.length){var u=t.charCodeAt(0);('utf8'===f&&u<128||'latin1'===f)&&(t=u)}}else'number'==typeof t?t&=255:'boolean'==typeof t&&(t=Number(t));if(n<0||this.length<n||this.length<o)throw new RangeError('Out of range index');if(o<=n)return this;var h;if(n>>>=0,o=void 0===o?this.length:o>>>0,t||(t=0),'number'==typeof t)for(h=n;h<o;++h)this[h]=t;else{var p=s.isBuffer(t)?t:s.from(t,f),c=p.length;if(0===c)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(h=0;h<o-n;++h)this[h+n]=p[h%c]}return this};var X=/[^+/0-9A-Za-z-_]/g;function J(t){if((t=(t=t.split('=')[0]).trim().replace(X,'')).length<2)return'';for(;t.length%4!=0;)t+='=';return t}function Z(t,n){var o;n=n||1/0;for(var f=t.length,u=null,s=[],h=0;h<f;++h){if((o=t.charCodeAt(h))>55295&&o<57344){if(!u){if(o>56319){(n-=3)>-1&&s.push(239,191,189);continue}if(h+1===f){(n-=3)>-1&&s.push(239,191,189);continue}u=o;continue}if(o<56320){(n-=3)>-1&&s.push(239,191,189),u=o;continue}o=65536+(u-55296<<10|o-56320)}else u&&(n-=3)>-1&&s.push(239,191,189);if(u=null,o<128){if((n-=1)<0)break;s.push(o)}else if(o<2048){if((n-=2)<0)break;s.push(o>>6|192,63&o|128)}else if(o<65536){if((n-=3)<0)break;s.push(o>>12|224,o>>6&63|128,63&o|128)}else{if(!(o<1114112))throw new Error('Invalid code point');if((n-=4)<0)break;s.push(o>>18|240,o>>12&63|128,o>>6&63|128,63&o|128)}}return s}function $(t){for(var n=[],o=0;o<t.length;++o)n.push(255&t.charCodeAt(o));return n}function G(t,n){for(var o,f,u,s=[],h=0;h<t.length&&!((n-=2)<0);++h)f=(o=t.charCodeAt(h))>>8,u=o%256,s.push(u),s.push(f);return s}function H(n){return t.toByteArray(J(n))}function K(t,n,o,f){for(var u=0;u<f&&!(u+o>=n.length||u>=t.length);++u)n[u+o]=t[u];return u}function Q(t,n){return t instanceof n||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===n.name}function tt(t){return t!=t}var rt=(function(){for(var t=new Array(256),n=0;n<16;++n)for(var o=16*n,f=0;f<16;++f)t[o+f]="0123456789abcdef"[n]+"0123456789abcdef"[f];return t})()},432,[433,434]);^~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:449:4383: warning: the variable "navigator" was not declared in function "k 14#"__d(function(e,t,n,r,a,i,s){var o,c,u=t(s[0]),l=t(s[1]),p=t(s[2]),d=t(s[3]),h=t(s[4]),f=t(s[5]),v=t(s[6]),y=t(s[7]),g=t(s[8]),m=t(s[9]),b=t(s[10]),w=t(s[11]);function k(e){var t=x();return function(){var n,r=f(e);if(t){var a=f(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return h(this,n)}}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=P(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o=window,c=function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=246)})([function(e,t,n){"use strict";(function(e){n.d(t,"r",function(){return y}),n.d(t,"n",function(){return g}),n.d(t,"C",function(){return k}),n.d(t,"y",function(){return x}),n.d(t,"q",function(){return P}),n.d(t,"O",function(){return O}),n.d(t,"h",function(){return C}),n.d(t,"x",function(){return D}),n.d(t,"v",function(){return _}),n.d(t,"w",function(){return E}),n.d(t,"t",function(){return R}),n.d(t,"A",function(){return I}),n.d(t,"s",function(){return M}),n.d(t,"U",function(){return A}),n.d(t,"V",function(){return j}),n.d(t,"W",function(){return T}),n.d(t,"F",function(){return K}),n.d(t,"o",function(){return F}),n.d(t,"R",function(){return L}),n.d(t,"M",function(){return U}),n.d(t,"b",function(){return N}),n.d(t,"p",function(){return V}),n.d(t,"c",function(){return B}),n.d(t,"g",function(){return W}),n.d(t,"N",function(){return H}),n.d(t,"d",function(){return z}),n.d(t,"H",function(){return q}),n.d(t,"Q",function(){return Y}),n.d(t,"K",function(){return G}),n.d(t,"j",function(){return Q}),n.d(t,"S",function(){return J}),n.d(t,"E",function(){return $}),n.d(t,"J",function(){return X}),n.d(t,"I",function(){return Z}),n.d(t,"D",function(){return ee}),n.d(t,"a",function(){return te}),n.d(t,"m",function(){return ne}),n.d(t,"L",function(){return re}),n.d(t,"l",function(){return ae}),n.d(t,"B",function(){return ie}),n.d(t,"T",function(){return se}),n.d(t,"P",function(){return oe}),n.d(t,"f",function(){return ce}),n.d(t,"z",function(){return ue}),n.d(t,"G",function(){return le}),n.d(t,"e",function(){return pe}),n.d(t,"i",function(){return ye}),n.d(t,"u",function(){return ge}),n.d(t,"k",function(){return me});var r=n(27),a=n.n(r),i=n(25),s=n.n(i),o=n(23),c=n.n(o),u=n(97),l=n.n(u),p=n(66),d=n.n(p),h=n(28),f=n.n(h),v='undefined'!=typeof Intl?new Intl.Collator('en',{numeric:!0}):void 0;function y(){return'undefined'!=typeof window?window:void 0!==e?e:null}function g(e){return Object.keys(e).map(function(t){return e[t]})}function k(){return null!==y()&&!x()&&!(document&&document.documentMode)||/Edge/.test(navigator.userAgent)&&window.crypto&&!!window.crypto.subtle}function x(){return'undefined'!=typeof navigator&&'ReactNative'===navigator.product}function P(e,t,n){return e.find(function(e){return e[t]===n})}function O(e,t){return s()(e,t)}function C(){for(var e=[],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var a=0,i=n;a<i.length;a++){var s=i[a];e=e.concat(s)}return e}function D(e){return null!==e&&('function'==typeof e||'object'==typeof e)}function _(e){return null!==e&&'function'==typeof e}function E(e){return null===e||void 0===e}function R(e){return!e||0===e.length}function I(e){return'string'==typeof e||e instanceof String}function M(e,t){return e>t?e:t}function A(e,t,n){return d()(e.concat(t),function(e,t){for(var r,a=S(n);!(r=a()).done;){var i=r.value;if(e[i]!==t[i])return!1}return!0})}function j(e){return f()(e)}function T(e,t){return d()(e,function(e,n){return e[t]===n[t]})}function K(e){return e[e.length-1]}function F(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;e.push(a)}}function L(e,t){for(var n,r=S(t);!(n=r()).done;){U(e,n.value)}}function U(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}function N(e,t){return!e.includes(t)&&(e.push(t),!0)}function V(e,t){a()(e,t)}function B(e,t){return e.filter(function(e){return!t.includes(e)}).concat(t.filter(function(t){return!e.includes(t)}))}function W(e,t){return!(e&&!t||!e&&t)&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof String&&t instanceof String?e===t:J(e,t))}function H(e,t){e.splice(t,1)}function z(e,t){var n=e.slice();return H(n,t),n}function q(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];t.push(e[a])}return t}function Y(e){for(var t,n={},r=S(Object.keys(e).sort());!(t=r()).done;){var a=t.value;n[a]=e[a]}return te(n)}function G(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];E(e[a])||(t[a]=e[a])}return t}function Q(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort(function(e,r){var a=e[t].getTime(),i=r[t].getTime(),s=n?1:-1;return a<i?-1*s:a>i?1*s:0})}function J(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var a=0,i=n;a<i.length;a++){var s=i[a];if(e[s]!==t[s])return!1}return!0}function $(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=void 0;try{i=JSON.parse(e[a])}catch(t){i=e[a]}t[a]=i}return t}function X(e,t){if(e)for(var n,r=S(t);!(n=r()).done;){delete e[n.value]}}function Z(e,t){if(!E(e)){for(var n,r=w({},e),a=S(t);!(n=a()).done;){delete r[n.value]}return r}}function ee(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(function(e,t){return 0===t?e.trim().replace(/[/]*$/g,''):e.trim().replace(/(^[/]*|[/]*$)/g,'')}).filter(function(e){return e.length}).join('/')}function te(e){return e instanceof Date?new Date(e):D(e)?JSON.parse(JSON.stringify(e)):e}function ne(e,t){if(!e||!t)throw'Attempting to deepMerge with null values';return l()(e,t,function(e,t){if(c()(e))return t}),e}function re(e,t){for(var n,r={},a=S(t);!(n=a()).done;){var i=n.value;r[i]=e[i]}return te(r)}function ae(e){for(var t,n=S(Object.getOwnPropertyNames(e));!(t=n()).done;){var r=t.value,a=e[r];a&&'object'==typeof a&&!Object.isFrozen(a)?e[r]=ae(a):e[r]=a}return Object.freeze(e)}function ie(e){try{return new URL(e),!0}catch(e){return!1}}function se(e,t){var n=t/4;return e.substring(0,n)}function oe(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Sleeping for ".concat(e,"ms")),t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},e)}));case 2:case"end":return t.stop()}},null,null,null,Promise)}function ce(e){throw Error('Unchecked case '+e)}function ue(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function le(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc'){case'asc':return m(e).sort(v?function(e,n){return v.compare(e[t],n[t])}:function(e,n){return e[t].localeCompare(n[t],'en',{numeric:!0})});case'desc':return m(e).sort(v?function(e,n){return v.compare(n[t],e[t])}:function(e,n){return n[t].localeCompare(e[t],'en',{numeric:!0})})}}function pe(e,t){return e.length===t.length&&(e.every(function(e){return t.includes(e)})&&t.every(function(t){return e.includes(t)}))}var de,he,fe=1e3,ve=1e3;function ye(e){switch(String(e).length){case de.Seconds:return e*ve;case de.Milliseconds:return e;case de.Microseconds:return Math.floor(e/fe);default:throw"Unhandled timestamp precision: ".concat(e)}}function ge(e){return void 0!==e.error}function me(e){if('undefined'!=typeof Intl&&Intl.DateTimeFormat&&'undefined'!=typeof navigator){if(!he){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;he=new Intl.DateTimeFormat(t,{year:'numeric',month:'short',day:'2-digit',weekday:'long',hour:'2-digit',minute:'2-digit'})}return he.format(e)}return e.toDateString()+' '+e.toLocaleTimeString()}!(function(e){e[e.Seconds=10]="Seconds",e[e.Milliseconds=13]="Milliseconds",e[e.Microseconds=16]="Microseconds"})(de||(de={}))}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"e",function(){return m}),n.d(t,"g",function(){return b}),n.d(t,"d",function(){return w}),n.d(t,"f",function(){return k}),n.d(t,"b",function(){return x}),n.d(t,"c",function(){return O}),n.d(t,"a",function(){return C});var r=n(32),a=n(4),i=n(8),s=n(0),o=n(5),c=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey,o.a.LastSyncBegan,o.a.LastSyncEnd,o.a.DuplicateOf]),u=Object.freeze([o.a.Uuid,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.Legacy003AuthHash,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey]),l=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Legacy003AuthHash,o.a.DuplicateOf]),p=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.WaitingForKey,o.a.DuplicateOf]),d=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.DuplicateOf]),h=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.Content,o.a.ServerUpdatedAt]),f=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),v=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),y=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ServerUpdatedAt,o.a.ServerUpdatedAtTimestamp,o.a.CreatedAtTimestamp,o.a.Deleted,o.a.Dirty,o.a.LastSyncEnd]),g=Object.freeze(d.slice());function m(e,t,n){return P(e,c.slice(),n,t)}function b(e,t,n,r){for(var a,i={},s=S(n||t.fields);!(a=s()).done;){var o=a.value;i[o]=t[o]}if(r)for(var c=0,u=Object.keys(r);c<u.length;c++){var l=u[c];i[l]=r[l]}return x(e,i)}function w(e,t,n){return P(e,D(t),a.a.Constructor,n)}function k(e,t,n){return P(e,_(t),t,n)}function x(e,t){return P(e,e.fields,e.source,t)}function P(e,t,n,i){for(var o,c=Object(s.L)(e,t),u=i instanceof r.a?i.fields.slice():Object.keys(i||[]),l=S(u);!(o=l()).done;){var p=o.value,d=i[p];c[p]=d?Object(s.a)(d):d}var h=Object(s.V)(t.concat(u));return new r.a(c,h,n||a.a.Constructor)}function O(e,t){return P(e,Object.keys(e),t)}function C(e,t){return P(e,u.slice(),void 0,t)}function D(e){if(e===i.b.FileEncrypted||e===i.b.FileDecrypted||e===i.b.FilePreferEncrypted)return l.slice();if(e===i.b.LocalStoragePreferEncrypted||e===i.b.LocalStorageDecrypted||e===i.b.LocalStorageEncrypted)return p.slice();if(e===i.b.Sync||e===i.b.SyncDecrypted)return d.slice();throw"No payload fields found for intent ".concat(e)}function _(e){if(e===a.a.FileImport)return l.slice();if(e===a.a.SessionHistory)return h.slice();if(e===a.a.RemoteHistory)return g.slice();if(e===a.a.ComponentRetrieved)return f.slice();if(e===a.a.ComponentCreated)return v.slice();if(e===a.a.LocalRetrieved||e===a.a.LocalChanged)return p.slice();if(e===a.a.RemoteRetrieved||e===a.a.ConflictData||e===a.a.ConflictUuid||e===a.a.RemoteRejected)return d.slice();if(e===a.a.LocalSaved||e===a.a.RemoteSaved)return y.slice();throw"No payload fields found for source ".concat(e)}},function(e,t,n){"use strict";n.d(t,"k",function(){return a}),n.d(t,"l",function(){return i}),n.d(t,"j",function(){return s}),n.d(t,"m",function(){return o}),n.d(t,"r",function(){return c}),n.d(t,"p",function(){return u}),n.d(t,"a",function(){return l}),n.d(t,"i",function(){return p}),n.d(t,"n",function(){return d}),n.d(t,"s",function(){return h}),n.d(t,"q",function(){return f}),n.d(t,"o",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"h",function(){return g}),n.d(t,"g",function(){return m}),n.d(t,"b",function(){return b}),n.d(t,"f",function(){return w}),n.d(t,"t",function(){return k}),n.d(t,"c",function(){return x}),n.d(t,"e",function(){return S}),n.d(t,"C",function(){return P}),n.d(t,"X",function(){return O}),n.d(t,"A",function(){return C}),n.d(t,"L",function(){return D}),n.d(t,"W",function(){return _}),n.d(t,"E",function(){return E}),n.d(t,"D",function(){return R}),n.d(t,"K",function(){return I}),n.d(t,"J",function(){return M}),n.d(t,"Y",function(){return A}),n.d(t,"Q",function(){return j}),n.d(t,"v",function(){return T}),n.d(t,"O",function(){return K}),n.d(t,"z",function(){return F}),n.d(t,"U",function(){return L}),n.d(t,"G",function(){return U}),n.d(t,"T",function(){return N}),n.d(t,"V",function(){return V}),n.d(t,"u",function(){return B}),n.d(t,"F",function(){return W}),n.d(t,"y",function(){return H}),n.d(t,"P",function(){return z}),n.d(t,"S",function(){return q}),n.d(t,"N",function(){return Y}),n.d(t,"H",function(){return G}),n.d(t,"w",function(){return Q}),n.d(t,"R",function(){return J}),n.d(t,"x",function(){return $}),n.d(t,"M",function(){return X}),n.d(t,"B",function(){return Z}),n.d(t,"I",function(){return ee});var r=n(13),a='A server error occurred while trying to sign in. Please try again.',i='A server error occurred while trying to register. Please try again.',s='Something went wrong while changing your credentials. Your credentials were not changed. Please try again.',o='Could not connect to server.',c='An existing registration request is already in progress.',u='An existing sign in request is already in progress.',l='An existing change credentials request is already in progress.',p='Invalid email or password.',d='A server error occurred while trying to refresh your session. Please try again.',h='Your account session is being renewed with the server. Please try your request again.',f='Too many successive server requests. Please wait a few minutes and try again.',v='Please sign in to an account in order to continue with your request.',y='Failed to get settings.',g='Failed to update settings.',m="Failed to get subscription's information.",b='Failed to access purchase flow.',w='Failed to get offline features.',k="The extension you are attempting to install comes from an \n  untrusted source. Untrusted extensions may lower the security of your data. Do you want to continue?",x="Error downloading package details. Please check the \n  extension link and try again.",S='An unknown issue occurred during offline activation. Please try again.',P='Invalid extension URL.',O='This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.',C='The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.',D='The encryption version for your account is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.com/help/security for more information.',_='Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.',E='Unable to sign in due to insecure password parameters. Please visit standardnotes.com/help/security for more information.',R='Invalid password.',I='Update Recommended',M='Sign In',A="Upgrading your account's encryption version\u2026",j='Setting passcode\u2026',T='Changing passcode\u2026',K='Removing passcode\u2026',F='Do not close the application until this process completes.',L='Unknown error.';function U(e){return"Your password must be at least ".concat(e," characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.")}function N(e,t){return"Strict Sign In has refused the server's sign-in parameters. The latest account version is ".concat(t,", but the server is reporting a version of ").concat(e," for your account. If you'd like to proceed with sign in anyway, please disable Strict Sign In and try again.")}var V='This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.',B="This backup file was created using a newer encryption version than your account's. Please run the available encryption upgrade and try again.",W={FileAccountPassword:'File account password'},H={PasscodeRequired:'Your passcode is required to process your credentials change.',Failed:'Unable to change your credentials due to a sync error. Please try again.'},z={PasscodeRequired:'Your passcode is required in order to register for an account.'},q={PasscodeRequired:'Your passcode is required in order to sign in to your account.',IncorrectMfa:'Incorrect two-factor authentication code. Please try again.',SignInCanceledMissingMfa:'Your sign in request has been canceled.'},Y={SuccessAccount:"Your encryption version has been successfully upgraded. You may be asked to enter your credentials again on other devices you're signed into.",SuccessPasscodeOnly:'Your encryption version has been successfully upgraded.',Fail:'Unable to upgrade encryption version. Please try again.',UpgradingPasscode:'Upgrading local encryption...'},G={KeyRecoveryLoginFlowPrompt:function(e){var t,n=null===(t=e.createdDate)||void 0===t?void 0:t.toLocaleString();switch(e.origination){case r.g.EmailChange:return"Enter your account password as it was when you changed your email on ".concat(n,".");case r.g.PasswordChange:return"Enter your account password after it was changed on ".concat(n,".");case r.g.Registration:return"Enter your account password as it was when you registered ".concat(n,".");case r.g.ProtocolUpgrade:return"Enter your account password as it was when you upgraded your encryption version on ".concat(n,".");case r.g.PasscodeChange:return"Enter your application passcode after it was changed on ".concat(n,".");case r.g.PasscodeCreate:return"Enter your application passcode as it was when you created it on ".concat(n,".");default:throw Error('Unhandled KeyParamsOrigination case for KeyRecoveryLoginFlowPrompt')}},KeyRecoveryLoginFlowReason:'Your account password is required to revalidate your session.',KeyRecoveryLoginFlowInvalidPassword:'Incorrect credentials entered. Please try again.',KeyRecoveryRootKeyReplaced:'Your credentials have successfully been updated.',KeyRecoveryPasscodeRequiredTitle:'Passcode Required',KeyRecoveryPasscodeRequiredText:'You must enter your passcode in order to save your new credentials.',KeyRecoveryPasswordRequired:'Your account password is required to recover an encryption key.',KeyRecoveryKeyRecovered:'Your key has successfully been recovered.',KeyRecoveryUnableToRecover:'Unable to recover your key with the attempted password. Please try again.'},Q={Generic:'Authentication Required',Migration:'Storage Update'},J={EnterEmailAndPassword:'Please enter your account email and password.',RecoverSession:function(e){return e?"Your credentials are needed for ".concat(e," to refresh your session with the server."):'Your credentials are needed to refresh your session with the server.'},SessionRestored:'Your session has been successfully restored.',EnterMfa:'Please enter your two-factor authentication code.',MfaInputPlaceholder:'Two-factor authentication code',EmailInputPlaceholder:'Email',PasswordInputPlaceholder:'Password',KeychainRecoveryErrorTitle:'Invalid Credentials',KeychainRecoveryError:'The email or password you entered is incorrect.\n\nPlease note that this sign-in request is made against the default server. If you are using a custom server, you must uninstall the app then reinstall, and sign back into your account.',RevokeTitle:'Revoke this session?',RevokeConfirmButton:'Revoke',RevokeCancelButton:'Cancel',RevokeText:"The associated app will be signed out and all data removed from the device when it is next launched. You can sign back in on that device at any time.",CurrentSessionRevoked:"Your session has been revoked and all local data has been removed from this device."},$={UnlockApplication:'Authentication is required to unlock the application',NoteAccess:'Authentication is required to view this note',ImportFile:'Authentication is required to import a backup file',AddPasscode:'Authentication is required to add a passcode',RemovePasscode:'Authentication is required to remove your passcode',ChangePasscode:'Authentication is required to change your passcode',ChangeAutolockInterval:'Authentication is required to change autolock timer duration',RevokeSession:'Authentication is required to revoke a session',AccessCloudLink:'Authentication is required to access CloudLink',EnterAccountPassword:'Enter your account password',EnterLocalPasscode:'Enter your application passcode',EnterPasscodeForMigration:'Your application passcode is required to perform an upgrade of your local data storage structure.',EnterPasscodeForRootResave:'Enter your application passcode to continue',EnterCredentialsForProtocolUpgrade:'Enter your credentials to perform encryption upgrade',EnterCredentialsForDecryptedBackupDownload:'Enter your credentials to download a decrypted backup',AccountPasswordPlaceholder:'Account Password',LocalPasscodePlaceholder:'Application Passcode',DecryptEncryptedFile:'Enter the account password associated with the import file',ExportBackup:'Authentication is required to export a backup',DisableBiometrics:'Authentication is required to disable biometrics',UnprotectNote:'Authentication is required to unprotect a note',SearchProtectedNotesText:'Authentication is required to search protected contents',SelectProtectedNote:'Authentication is required to select a protected note',DisableMfa:'Authentication is required to disable two-factor authentication'},X={AccountPassword:'Account Password',LocalPasscode:'Application Passcode',Biometrics:'Biometrics',RememberFor:'Remember For',Mfa:'Two-factor Authentication Code'},Z={MissingSessionTitle:'Missing Session',MissingSessionBody:'We were unable to load your server session. This represents an inconsistency with your application state. Please take an opportunity to backup your data, then sign out and sign back in to resolve this issue.',StorageDecryptErrorTitle:'Storage Error',StorageDecryptErrorBody:"We were unable to decrypt your local storage. Please restart the app and try again. If you're unable to resolve this issue, and you have an account, you may try uninstalling the app then reinstalling, then signing back into your account. Otherwise, please contact help@standardnotes.org for support."},ee={Title:'Restore Keychain',Text:"We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys."}},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i});var r=n(19);n.n(r);n.d(t,"a",function(){return r.ContentType});var a='org.standardnotes.sn';function i(e){var t;return(g(t={},r.ContentType.Note,'note'),g(t,r.ContentType.Tag,'tag'),g(t,r.ContentType.SmartTag,'smart tag'),g(t,r.ContentType.ActionsExtension,'action-based extension'),g(t,r.ContentType.Component,'component'),g(t,r.ContentType.Editor,'editor'),g(t,r.ContentType.Theme,'theme'),g(t,r.ContentType.ServerExtension,'server extension'),g(t,r.ContentType.FilesafeCredentials,'FileSafe credential'),g(t,r.ContentType.FilesafeFileMetadata,'FileSafe file'),g(t,r.ContentType.FilesafeIntegration,'FileSafe integration'),t)[e]}},function(e,t,n){"use strict";var r;function a(e){return[r.RemoteSaved,r.PreSyncSave].includes(e)}function i(e){return[r.RemoteRetrieved,r.ComponentRetrieved,r.RemoteActionRetrieved].includes(e)}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i}),(function(e){e[e.RemoteRetrieved=1]="RemoteRetrieved",e[e.RemoteSaved=2]="RemoteSaved",e[e.LocalSaved=3]="LocalSaved",e[e.LocalRetrieved=4]="LocalRetrieved",e[e.LocalChanged=5]="LocalChanged",e[e.ComponentRetrieved=6]="ComponentRetrieved",e[e.DesktopInstalled=7]="DesktopInstalled",e[e.RemoteActionRetrieved=8]="RemoteActionRetrieved",e[e.FileImport=9]="FileImport",e[e.RemoteConflict=10]="RemoteConflict",e[e.ImportConflict=11]="ImportConflict",e[e.SavedOrSaving=12]="SavedOrSaving",e[e.DecryptedTransient=13]="DecryptedTransient",e[e.ConflictUuid=14]="ConflictUuid",e[e.ConflictData=15]="ConflictData",e[e.SessionHistory=16]="SessionHistory",e[e.Constructor=17]="Constructor",e[e.ComponentCreated=18]="ComponentCreated",e[e.PreSyncSave=19]="PreSyncSave",e[e.RemoteHistory=20]="RemoteHistory",e[e.RemoteRejected=21]="RemoteRejected"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.Uuid="uuid",e.ContentType="content_type",e.ItemsKeyId="items_key_id",e.EncItemKey="enc_item_key",e.Content="content",e.CreatedAt="created_at",e.ServerUpdatedAt="updated_at",e.CreatedAtTimestamp="created_at_timestamp",e.ServerUpdatedAtTimestamp="updated_at_timestamp",e.Deleted="deleted",e.Legacy003AuthHash="auth_hash",e.Legacy003AuthParams="auth_params",e.Dirty="dirty",e.DirtiedDate="dirtiedDate",e.WaitingForKey="waitingForKey",e.ErrorDecrypting="errorDecrypting",e.ErrorDecryptingChanged="errorDecryptingValueChanged",e.LastSyncBegan="lastSyncBegan",e.LastSyncEnd="lastSyncEnd",e.DuplicateOf="duplicate_of"})(r||(r={}))},function(e,t,n){"use strict";var r;function a(e,t){return Number(e)-Number(t)}function i(e,t){return a(e,t)>=0}function s(e,t){return a(e,t)<=0}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"d",function(){return i}),n.d(t,"c",function(){return s}),(function(e){e.V000Base64Decrypted="000",e.V001="001",e.V002="002",e.V003="003",e.V004="004",e[e.VersionLength=3]="VersionLength"})(r||(r={}))},function(e,t,n){"use strict";(function(e){n.d(t,"c",function(){return r}),n.d(t,"a",function(){return a}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return f}),n.d(t,"b",function(){return g});var r,a,i,s=n(16),o=n(12),c=n(18),u=n(1),l=n(0),p=n(21),d=n(3),h=n(4);!(function(e){e[e.UserInteraction=1]="UserInteraction",e[e.Internal=2]="Internal",e[e.NonDirtying=3]="NonDirtying"})(r||(r={})),(function(e){e.Pinned="pinned",e.Archived="archived",e.Locked="locked",e.UserModifiedDate="client_updated_at",e.DefaultEditor="defaultEditor",e.MobileRules="mobileRules",e.NotAvailableOnMobile="notAvailableOnMobile",e.MobileActive="mobileActive",e.LastSize="lastSize",e.PrefersPlainEditor="prefersPlainEditor",e.ComponentInstallError="installError"})(a||(a={})),(function(e){e[e.KeepEarliest=1]="KeepEarliest"})(i||(i={}));var f=(function(){function t(n){var r=this;if(v(this,t),this.protected=!1,this.trashed=!1,this.pinned=!1,this.archived=!1,this.locked=!1,!n.uuid||!n.content_type)throw Error('Cannot create item without both uuid and content_type');n.format===o.a.DecryptedBareObject&&(n.enc_item_key||n.items_key_id||n.auth_hash)&&s.a.error(Error('Creating an item from a decrypted payload should not contain enc params')),this.payload=n,this.conflictOf=n.safeContent.conflict_of,this.duplicateOf=n.duplicate_of,this.createdAtString=this.created_at&&Object(l.k)(this.created_at),n.format===o.a.DecryptedBareObject?(this.userModifiedDate=new Date(this.getAppDomainValue(a.UserModifiedDate)||this.serverUpdatedAt),this.updatedAtString=Object(l.k)(this.userModifiedDate),this.protected=this.payload.safeContent.protected,this.trashed=this.payload.safeContent.trashed,this.pinned=this.getAppDomainValue(a.Pinned),this.archived=this.getAppDomainValue(a.Archived),this.locked=this.getAppDomainValue(a.Locked)):this.userModifiedDate=this.serverUpdatedAt||new Date,e(function(){Object(l.l)(r)})}return y(t,[{key:"payloadRepresentation",value:function(e){return Object(u.b)(this.payload,e)}},{key:"hasRelationshipWithItem",value:function(e){var t;return!!(null===(t=this.payload.safeContent.references)||void 0===t?void 0:t.find(function(t){return t.uuid===e.uuid}))}},{key:"getDomainData",value:function(e){var t=this.payload.safeContent.appData;if(t)return t[e]}},{key:"getAppDomainValue",value:function(e){return this.getDomainData(t.DefaultAppDomain())[e]}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['conflict_of']}},{key:"appDataContentKeysToIgnoreWhenCheckingEquality",value:function(){return[a.UserModifiedDate]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"strategyWhenConflictingWithItem",value:function(e,t){if(this.errorDecrypting)return c.a.KeepLeftDuplicateRight;if(this.isSingleton)return c.a.KeepLeft;if(this.deleted)return c.a.KeepRight;if(e.deleted)return this.payload.source===h.a.FileImport?c.a.KeepLeft:c.a.KeepRight;if(!m(this,e))return c.a.KeepRight;if(m(this,e,['references'])){if(t&&!m(t.itemFromPayload(),e))return c.a.KeepLeft;return e.payload.source===h.a.FileImport||Date.now()-this.userModifiedDate.getTime()<2e4?c.a.KeepLeftDuplicateRight:c.a.DuplicateLeftKeepRight}return c.a.KeepLeftMergeRefs}},{key:"isItemContentEqualWith",value:function(e){return b(this.payload.contentObject,e.payload.contentObject,this.contentKeysToIgnoreWhenCheckingEquality(),this.appDataContentKeysToIgnoreWhenCheckingEquality())}},{key:"satisfiesPredicate",value:function(e){return p.a.ItemSatisfiesPredicate(this,e)}},{key:"uuid",get:function(){return this.payload.uuid}},{key:"content",get:function(){return this.payload.content}},{key:"version",get:function(){if(this.payload.format===o.a.DecryptedBareObject)throw Error('Attempting to access version of decrypted payload');return this.payload.version}},{key:"safeContent",get:function(){return this.payload.safeContent}},{key:"references",get:function(){return this.payload.safeContent.references||[]}},{key:"deleted",get:function(){return this.payload.deleted}},{key:"content_type",get:function(){return this.payload.content_type}},{key:"created_at",get:function(){return this.payload.created_at}},{key:"serverUpdatedAt",get:function(){return this.payload.serverUpdatedAt}},{key:"serverUpdatedAtTimestamp",get:function(){return this.payload.updated_at_timestamp}},{key:"updated_at",get:function(){return this.serverUpdatedAt}},{key:"dirtiedDate",get:function(){return this.payload.dirtiedDate}},{key:"dirty",get:function(){return this.payload.dirty}},{key:"errorDecrypting",get:function(){return this.payload.errorDecrypting}},{key:"waitingForKey",get:function(){return this.payload.waitingForKey}},{key:"errorDecryptingValueChanged",get:function(){return this.payload.errorDecryptingValueChanged}},{key:"lastSyncBegan",get:function(){return this.payload.lastSyncBegan}},{key:"lastSyncEnd",get:function(){return this.payload.lastSyncEnd}},{key:"auth_hash",get:function(){return this.payload.auth_hash}},{key:"auth_params",get:function(){return this.payload.auth_params}},{key:"duplicate_of",get:function(){return this.payload.duplicate_of}},{key:"neverSynced",get:function(){return!this.serverUpdatedAt||0===this.serverUpdatedAt.getTime()}},{key:"isSingleton",get:function(){return!1}},{key:"singletonPredicate",get:function(){throw'Must override SNItem.singletonPredicate'}},{key:"singletonStrategy",get:function(){return i.KeepEarliest}},{key:"isSyncable",get:function(){return!this.errorDecrypting||!0===this.deleted}}],[{key:"DefaultAppDomain",value:function(){return d.b}}]),t})(),g=(function(){function e(t,n){v(this,e),this.item=t,this.type=n,this.payload=t.payload,this.payload.content&&(this.content=Object(l.a)(this.payload.content))}return y(e,[{key:"getUuid",value:function(){return this.payload.uuid}},{key:"getItem",value:function(){return this.item}},{key:"getResult",value:function(){if(this.type===r.NonDirtying)return Object(u.b)(this.payload,{content:this.content});this.payload.deleted||(this.type===r.UserInteraction?this.userModifiedDate=new Date:this.item.userModifiedDate||(this.userModifiedDate=new Date(this.item.serverUpdatedAt)));return Object(u.b)(this.payload,{content:this.content,dirty:!0,dirtiedDate:new Date})}},{key:"mergePayload",value:function(e){this.payload=Object(u.g)(this.payload,e),this.payload.content?this.content=Object(l.a)(this.payload.safeContent):this.content=void 0}},{key:"unsafe_setCustomContent",value:function(e){this.content=Object(l.a)(e)}},{key:"setDeleted",value:function(){this.content=void 0,this.payload=Object(u.b)(this.payload,{content:this.content,deleted:!0})}},{key:"setDomainData",value:function(e,t){this.payload.errorDecrypting||(this.content.appData||(this.content.appData={}),this.content.appData[t]=e)}},{key:"setDomainDataKey",value:function(e,t,n){if(!this.payload.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData;r[n]||(r[n]={}),r[n][e]=t}}},{key:"setAppDataItem",value:function(e,t){this.setDomainDataKey(e,t,f.DefaultAppDomain())}},{key:"addItemAsRelationship",value:function(e){var t=this.content.references||[];t.find(function(t){return t.uuid===e.uuid})||t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}},{key:"removeItemAsRelationship",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!==e.uuid}),this.content.references=t}},{key:"lastSyncBegan",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,lastSyncBegan:e})}},{key:"errorDecrypting",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,errorDecrypting:e})}},{key:"updated_at",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at:e})}},{key:"updated_at_timestamp",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at_timestamp:e})}},{key:"userModifiedDate",set:function(e){this.setAppDataItem(a.UserModifiedDate,e)}},{key:"conflictOf",set:function(e){this.content.conflict_of=e}},{key:"protected",set:function(e){this.content.protected=e}},{key:"trashed",set:function(e){this.content.trashed=e}},{key:"pinned",set:function(e){this.setAppDataItem(a.Pinned,e)}},{key:"archived",set:function(e){this.setAppDataItem(a.Archived,e)}},{key:"locked",set:function(e){this.setAppDataItem(a.Locked,e)}}]),e})();function m(e,t,n){return n||(n=[]),!b(e.content,t.content,e.contentKeysToIgnoreWhenCheckingEquality().concat(n),e.appDataContentKeysToIgnoreWhenCheckingEquality())}function b(e,t,n,r){if((e=Object(l.Q)(e)).appData){var a=e.appData[d.b];Object(l.J)(a,r),a?0===Object.keys(a).length&&delete e.appData:delete e.appData}if(Object(l.J)(e,n),(t=Object(l.Q)(t)).appData){var i=t.appData[d.b];Object(l.J)(i,r),i?0===Object.keys(i).length&&delete t.appData:delete t.appData}return Object(l.J)(t,n),JSON.stringify(e)===JSON.stringify(t)}}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"f",function(){return s}),n.d(t,"e",function(){return o}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return u});var r,a=n(3);function i(e){return e===a.a.RootKey||e===a.a.ItemsKey||e===a.a.EncryptedStorage}function s(e){return e===r.LocalStorageEncrypted||e===r.LocalStorageDecrypted||e===r.LocalStoragePreferEncrypted}function o(e){return e===r.FileEncrypted||e===r.FileDecrypted||e===r.FilePreferEncrypted}function c(e){return e===r.SyncDecrypted||e===r.LocalStorageDecrypted||e===r.FileDecrypted}function u(e){return e===r.Sync||e===r.LocalStorageEncrypted||e===r.FileEncrypted}!(function(e){e[e.Sync=0]="Sync",e[e.SyncDecrypted=1]="SyncDecrypted",e[e.LocalStorageEncrypted=2]="LocalStorageEncrypted",e[e.LocalStorageDecrypted=3]="LocalStorageDecrypted",e[e.LocalStoragePreferEncrypted=4]="LocalStoragePreferEncrypted",e[e.FileEncrypted=5]="FileEncrypted",e[e.FileDecrypted=6]="FileDecrypted",e[e.FilePreferEncrypted=7]="FilePreferEncrypted"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.FullSyncCompleted="sync:full-completed",e.SingleSyncCompleted="sync:single-completed",e.SyncWillBegin="sync:will-begin",e.DownloadFirstSyncCompleted="sync:download-first-completed",e.SyncTakingTooLong="sync:taking-too-long",e.SyncError="sync:error",e.InvalidSession="sync:invalid-session",e.MajorDataChange="major-data-change",e.LocalDataIncrementalLoad="local-data-incremental-load",e.LocalDataLoaded="local-data-loaded",e.EnterOutOfSync="enter-out-of-sync",e.ExitOutOfSync="exit-out-of-sync",e.StatusChanged="status-changed",e.DatabaseWriteError="database-write-error",e.DatabaseReadError="database-read-error"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var r=n(0),a=(function(){function e(){v(this,e),this.eventObservers=[],this.loggingEnabled=!1,this.criticalPromises=[]}return y(e,[{key:"addEventObserver",value:function(e){var t=this;return this.eventObservers.push(e),function(){Object(r.M)(t.eventObservers,e)}}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:n=S(this.eventObservers);case 1:if((r=n()).done){i.next=7;break}return a=r.value,i.next=5,b.awrap(a(e,t));case 5:i.next=1;break;case 7:case"end":return i.stop()}},null,this,null,Promise)}},{key:"blockDeinit",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(Promise.all(this.criticalPromises));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.eventObservers.length=0,this.deviceInterface=void 0}},{key:"executeCriticalFunction",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e(),this.criticalPromises.push(t),n.abrupt("return",t);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"log",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.loggingEnabled){var a,i=new Date,s=i.toLocaleTimeString().replace(' PM','').replace(' AM',''),o="".concat(s,".").concat(i.getMilliseconds());if(n)n=n.map(function(e){return Array.isArray(e)?e.slice():e}),(a=console).log.apply(a,[o,e].concat(m(n)));else console.log(o,e)}}}]),e})()},function(e,t,n){"use strict";n.d(t,"b",function(){return i}),n.d(t,"a",function(){return s});var r=n(7),a=n(3);function i(e){return e.map(function(e){return e.uuid})}function s(e){return e.references||(e.references=[]),e.appData||(e.appData={}),e.appData[a.b]||(e.appData[a.b]={}),e.appData[a.b][r.a.UserModifiedDate]||(e.appData[a.b][r.a.UserModifiedDate]="".concat(new Date)),e}},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.EncryptedString=0]="EncryptedString",e[e.DecryptedBareObject=1]="DecryptedBareObject",e[e.DecryptedBase64String=2]="DecryptedBase64String",e[e.Deleted=3]="Deleted"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"g",function(){return r}),n.d(t,"a",function(){return p}),n.d(t,"b",function(){return d}),n.d(t,"c",function(){return h}),n.d(t,"d",function(){return f}),n.d(t,"e",function(){return g}),n.d(t,"f",function(){return b}),n.d(t,"h",function(){return w});var r,a=n(14),i=n(6),s=n(0);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e.Registration="registration",e.EmailChange="email-change",e.PasswordChange="password-change",e.ProtocolUpgrade="protocol-upgrade",e.PasscodeCreate="passcode-create",e.PasscodeChange="passcode-change"})(r||(r={}));var l=['identifier','pw_cost','pw_nonce','pw_salt','version','origination','created'];function p(e){return g(e)}function d(e){return g(e)}function h(e){return g(e)}function f(e){return g(e)}function g(e){if(e.content)throw Error('Raw key params shouldnt have content; perhaps you passed in a SNRootKeyParams object.');return new w(e)}function m(e){if(e.version)return e.version;var t=e.pw_cost,n=a.a.PbkdfCostsUsed.includes(t),r=a.b.PbkdfCostsUsed.includes(t);return n&&!r?i.a.V001:r&&!n?i.a.V002:r&&n&&e.pw_nonce&&a.b.ImprobablePbkdfCostsUsed.includes(t)?i.a.V001:i.a.V002}function b(e,t){return g({identifier:t||e.data.identifier,pw_cost:e.data.pw_cost,pw_nonce:e.data.pw_nonce,pw_salt:e.data.pw_salt,version:m(e.data),origination:e.data.origination,created:e.data.created})}var w=(function(){function e(t){v(this,e),this.content=c(c({},t),{},{origination:t.origination||r.Registration,version:t.version||m(t)})}return y(e,[{key:"compare",value:function(e){if(this.version!==e.version)return!1;if([i.a.V004,i.a.V003].includes(this.version))return this.identifier===e.identifier&&this.content004.pw_nonce===e.content003.pw_nonce;if([i.a.V002,i.a.V001].includes(this.version))return this.identifier===e.identifier&&this.content002.pw_salt===e.content001.pw_salt;throw Error('Unhandled version in KeyParams.compare')}},{key:"getPortableValue",value:function(){return Object(s.L)(this.content,l)}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"identifier",get:function(){return this.content004.identifier||this.content002.email}},{key:"version",get:function(){return this.content.version}},{key:"origination",get:function(){return this.content.origination}},{key:"content001",get:function(){return this.content}},{key:"content002",get:function(){return this.content}},{key:"content003",get:function(){return this.content}},{key:"content004",get:function(){return this.content}},{key:"createdDate",get:function(){if(this.content004.created)return new Date(Number(this.content004.created))}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return s}),n.d(t,"c",function(){return r}),n.d(t,"d",function(){return a});var r,a,i=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:[3e3,5e3,1e4,6e4],PbkdfOutputLength:512,EncryptionKeyLength:256}),s=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:i.PbkdfCostsUsed.concat([1e5,101e3,102e3,103e3]),ImprobablePbkdfCostsUsed:[3e3,5e3],PbkdfOutputLength:768,EncryptionKeyLength:256,EncryptionIvLength:128});!(function(e){e[e.SaltSeedLength=256]="SaltSeedLength",e[e.PbkdfCost=11e4]="PbkdfCost",e[e.PbkdfOutputLength=768]="PbkdfOutputLength",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionIvLength=128]="EncryptionIvLength"})(r||(r={})),(function(e){e[e.ArgonSaltSeedLength=256]="ArgonSaltSeedLength",e[e.ArgonSaltLength=128]="ArgonSaltLength",e[e.ArgonIterations=5]="ArgonIterations",e[e.ArgonMemLimit=67108864]="ArgonMemLimit",e[e.ArgonOutputKeyBytes=64]="ArgonOutputKeyBytes",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionNonceLength=192]="EncryptionNonceLength"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"c",function(){return i}),n.d(t,"a",function(){return a});var r,a;n(22);function i(e){return e.status===r.HttpStatusExpiredAccessToken}!(function(e){e[e.LocalValidationError=10]="LocalValidationError",e[e.CanceledMfa=11]="CanceledMfa",e[e.UnknownError=12]="UnknownError",e[e.HttpStatusMinSuccess=200]="HttpStatusMinSuccess",e[e.HttpStatusNoContent=204]="HttpStatusNoContent",e[e.HttpStatusMaxSuccess=299]="HttpStatusMaxSuccess",e[e.HttpStatusExpiredAccessToken=498]="HttpStatusExpiredAccessToken",e[e.HttpStatusInvalidSession=401]="HttpStatusInvalidSession",e[e.HttpStatusForbidden=403]="HttpStatusForbidden",e[e.HttpBadRequest=400]="HttpBadRequest"})(r||(r={})),(function(e){e.ConflictingData="sync_conflict",e.UuidConflict="uuid_conflict",e.ContentTypeError="content_type_error",e.ContentError="content_error"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=(function(){function e(){v(this,e)}return y(e,null,[{key:"log",value:function(){this.onLog.apply(this,arguments)}},{key:"error",value:function(e){return this.onError(e),e}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"c",function(){return i});var r,a=n(9);function i(e){var t;return(t={},g(t,a.a.FullSyncCompleted,r.CompletedFullSync),g(t,a.a.SingleSyncCompleted,r.CompletedIncrementalSync),g(t,a.a.SyncError,r.FailedSync),g(t,a.a.SyncTakingTooLong,r.HighLatencySync),g(t,a.a.EnterOutOfSync,r.EnteredOutOfSync),g(t,a.a.ExitOutOfSync,r.ExitedOutOfSync),g(t,a.a.LocalDataLoaded,r.LocalDataLoaded),g(t,a.a.MajorDataChange,r.MajorDataChange),g(t,a.a.LocalDataIncrementalLoad,r.LocalDataIncrementalLoad),g(t,a.a.StatusChanged,r.SyncStatusChanged),g(t,a.a.SyncWillBegin,r.WillSync),g(t,a.a.InvalidSession,r.InvalidSyncSession),g(t,a.a.DatabaseReadError,r.LocalDatabaseReadError),g(t,a.a.DatabaseWriteError,r.LocalDatabaseWriteError),t)[e]}n.d(t,"b",function(){return a.a}),(function(e){e[e.SignedIn=2]="SignedIn",e[e.SignedOut=3]="SignedOut",e[e.CompletedFullSync=5]="CompletedFullSync",e[e.FailedSync=6]="FailedSync",e[e.HighLatencySync=7]="HighLatencySync",e[e.EnteredOutOfSync=8]="EnteredOutOfSync",e[e.ExitedOutOfSync=9]="ExitedOutOfSync",e[e.Started=10]="Started",e[e.Launched=11]="Launched",e[e.LocalDataLoaded=12]="LocalDataLoaded",e[e.KeyStatusChanged=13]="KeyStatusChanged",e[e.MajorDataChange=14]="MajorDataChange",e[e.CompletedRestart=15]="CompletedRestart",e[e.LocalDataIncrementalLoad=16]="LocalDataIncrementalLoad",e[e.SyncStatusChanged=17]="SyncStatusChanged",e[e.WillSync=18]="WillSync",e[e.InvalidSyncSession=19]="InvalidSyncSession",e[e.LocalDatabaseReadError=20]="LocalDatabaseReadError",e[e.LocalDatabaseWriteError=21]="LocalDatabaseWriteError",e[e.CompletedIncrementalSync=22]="CompletedIncrementalSync",e[e.MigrationsLoaded=23]="MigrationsLoaded",e[e.StorageReady=24]="StorageReady",e[e.PreferencesChanged=25]="PreferencesChanged",e[e.ProtectionSessionExpiryDateChanged=26]="ProtectionSessionExpiryDateChanged",e[e.UserRolesChanged=27]="UserRolesChanged",e[e.FeaturesUpdated=28]="FeaturesUpdated"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.KeepLeft=1]="KeepLeft",e[e.KeepRight=2]="KeepRight",e[e.KeepLeftDuplicateRight=3]="KeepLeftDuplicateRight",e[e.DuplicateLeftKeepRight=4]="DuplicateLeftKeepRight",e[e.KeepLeftMergeRefs=5]="KeepLeftMergeRefs"})(r||(r={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(211),t)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(221),t)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(0);function a(e){return e instanceof i?e:Array.isArray(e)?i.FromArray(e):i.FromJson(e)}var i=(function(){function e(t,n,r){if(v(this,e),this.keypath=t,this.operator=n,this.value=r,this.isRecursive()){var i=this.value;this.value=i.map(function(e){return a(e)})}else'true'!==this.value&&'false'!==this.value||(this.value=JSON.parse(this.value))}return y(e,[{key:"isRecursive",value:function(){return['and','or'].includes(this.operator)}},{key:"arrayRepresentation",value:function(){return[this.keypath,this.operator,this.value]}},{key:"valueAsArray",value:function(){return this.value}},{key:"keypathIncludesVerb",value:function(e){if(this.isRecursive()){for(var t,n=S(this.value);!(t=n()).done;){if(t.value.keypathIncludesVerb(e))return!0}return!1}return this.keypath.includes(e)}}],[{key:"FromJson",value:function(t){return new e(t.keypath,t.operator,t.value)}},{key:"FromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"CompoundPredicate",value:function(t){return new e('ignored','and',t)}},{key:"ObjectSatisfiesPredicate",value:function(e,t){if((t=a(t)).isRecursive()){if('and'===t.operator){for(var n,r=S(t.valueAsArray());!(n=r()).done;){var i=n.value;if(!this.ObjectSatisfiesPredicate(e,i))return!1}return!0}if('or'===t.operator){for(var s,o=S(t.valueAsArray());!(s=o()).done;){var c=s.value;if(this.ObjectSatisfiesPredicate(e,c))return!0}return!1}}var u=t.value;if('string'==typeof u&&u.includes('.ago')&&(u=this.DateFromString(u)),'not'===t.operator)return!this.ObjectSatisfiesPredicate(e,u);var l=t.keypath.split('.').reduce(function(e,t){return e&&e[t]},e),p=[!1,'',null,void 0,NaN];return void 0===l?'!='===t.operator?!p.includes(t.value):p.includes(t.value):'='===t.operator?Array.isArray(l)?JSON.stringify(l)===JSON.stringify(u):l===u:'!='===t.operator?Array.isArray(l)?JSON.stringify(l)!==JSON.stringify(u):l!==u:'<'===t.operator?l<u:'>'===t.operator?l>u:'<='===t.operator?l<=u:'>='===t.operator?l>=u:'startsWith'===t.operator?l.startsWith(u):'in'===t.operator?-1!==u.indexOf(l):'includes'===t.operator?this.resolveIncludesPredicate(l,u):'matches'===t.operator&&new RegExp(u).test(l)}},{key:"resolveIncludesPredicate",value:function(t,n){if(Object(r.A)(n))return t.includes(n);var a;a=Array.isArray(n)?e.FromArray(n):n;for(var i,s=S(t);!(i=s()).done;){var o=i.value;if(this.ObjectSatisfiesPredicate(o,a))return!0}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!this.ItemSatisfiesPredicate(e,a))return!1}return!0}},{key:"DateFromString",value:function(e){var t=e.split('.'),n=t[1],r=new Date,a=parseInt(t[0]);return'days'===n?r.setDate(r.getDate()-a):'hours'===n&&r.setHours(r.getHours()-a),r}}]),e})()},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.LastSyncToken="sync_token",e.PaginationToken="cursor_token",e.IntegrityCheck="compute_integrity",e.IntegrityResult="integrity_hash",e.SyncDlLimit="limit",e.SyncPayloads="items",e.ApiVersion="api"})(r||(r={}))},function(e,t,n){"use strict";var r=Array.isArray;e.exports=r},function(e,t,n){"use strict";var r=n(68),a='object'==typeof self&&self&&self.Object===Object&&self,i=r||a||Function('return this')();e.exports=i},function(e,t,n){"use strict";var r=n(173)(n(174));e.exports=r},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(e,t,n){"use strict";var r=n(48),a=n(168);e.exports=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,s=[],o=e.length;for(t=r(t,3);++i<o;){var c=e[i];t(c,i,e)&&(n.push(c),s.push(i))}return a(e,s),n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e){return e&&e.length?r(e):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(241),t)},function(e,t,n){"use strict";var r=n(110),a=n(115);e.exports=function(e,t){var n=a(e,t);return r(n)?n:void 0}},function(e,t,n){"use strict";e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t,n){"use strict";n.d(t,"a",function(){return u});var r=n(11),a=n(5),i=n(4),s=n(6),o=n(0),c=n(12),u=(function(){function e(t,n,u){if(v(this,e),this.fields=n||Object.keys(t),this.source=u||i.a.Constructor,this.uuid=t.uuid,!this.uuid&&this.fields.includes(a.a.Uuid))throw Error("uuid is null, yet this payloads fields indicate it shouldnt be. Content type: ".concat(t.content_type));this.content_type=t.content_type,t.content&&(Object(o.x)(t.content)?this.content=Object(r.a)(t.content):this.content=t.content),this.deleted=t.deleted,this.items_key_id=t.items_key_id,this.enc_item_key=t.enc_item_key,this.created_at=new Date(t.created_at||new Date),this.updated_at=new Date(t.updated_at||0),this.created_at_timestamp=t.created_at_timestamp,this.updated_at_timestamp=t.updated_at_timestamp,t.dirtiedDate&&(this.dirtiedDate=new Date(t.dirtiedDate)),this.dirty=t.dirty,this.errorDecrypting=t.errorDecrypting,this.waitingForKey=t.waitingForKey,this.errorDecryptingValueChanged=t.errorDecryptingValueChanged,this.lastSyncBegan=t.lastSyncBegan?new Date(t.lastSyncBegan):void 0,this.lastSyncEnd=t.lastSyncEnd?new Date(t.lastSyncEnd):void 0,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params,this.duplicate_of=t.duplicate_of,Object(o.A)(this.content)?this.content.startsWith(s.a.V000Base64Decrypted)?this.format=c.a.DecryptedBase64String:this.format=c.a.EncryptedString:Object(o.x)(this.content)?this.format=c.a.DecryptedBareObject:this.format=c.a.Deleted,Object(o.A)(this.content)?this.version=this.content.substring(0,s.a.VersionLength):this.content&&(this.version=this.content.version),Object(o.l)(this)}return y(e,[{key:"ejected",value:function(){for(var e,t=[a.a.Legacy003AuthHash,a.a.Deleted],n=[a.a.DirtiedDate,a.a.ErrorDecrypting,a.a.ErrorDecryptingChanged,a.a.WaitingForKey,a.a.LastSyncBegan,a.a.LastSyncEnd],r={},i=S(this.fields);!(e=i()).done;){var s=e.value;if(!n.includes(s)){var c=this[s];Object(o.w)(c)&&t.includes(s)||(r[s]=c)}}return r}},{key:"safeContent",get:function(){return this.format===c.a.DecryptedBareObject?this.content:{}}},{key:"references",get:function(){return this.safeReferences}},{key:"safeReferences",get:function(){return this.safeContent.references||[]}},{key:"contentObject",get:function(){if(this.format!==c.a.DecryptedBareObject)throw Error('Attempting to access non-object content as object');return this.content}},{key:"contentString",get:function(){if(this.format===c.a.DecryptedBareObject)throw Error('Attempting to access non-string content as string');return this.content}},{key:"discardable",get:function(){return this.deleted&&!this.dirty}},{key:"serverUpdatedAt",get:function(){return this.updated_at}}]),e})()},function(e,t,n){"use strict";var r=n(40),a=n(111),i=n(112),s='[object Null]',o='[object Undefined]',c=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?o:s:c&&c in Object(e)?a(e):i(e)}},function(e,t,n){"use strict";var r;r=(function(){return this})();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,n){"use strict";var r=n(51),a=n(59);e.exports=function(e){return null!=e&&a(e.length)&&!r(e)}},function(e,t,n){"use strict";var r=n(44);e.exports=function(e){if('string'==typeof e||r(e))return e;var t=e+'';return'0'==t&&1/e==-1/0?'-0':t}},function(e,t,n){"use strict";var r=n(100),a=n(101),i=n(102),s=n(103),o=n(104);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(35);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},function(e,t,n){"use strict";var r=n(24).Symbol;e.exports=r},function(e,t,n){"use strict";var r=n(30)(Object,'create');e.exports=r},function(e,t,n){"use strict";var r=n(124);e.exports=function(e,t){var n=e.__data__;return r(t)?n['string'==typeof t?'string':'hash']:n.map}},function(e,t,n){"use strict";var r=9007199254740991,a=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var n=typeof e;return!!(t=null==t?r:t)&&('number'==n||'symbol'!=n&&a.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Symbol]';e.exports=function(e){return'symbol'==typeof e||a(e)&&r(e)==i}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(231),t)},function(e,t,n){"use strict";var r=n(96);n.d(t,"SNSettingsService",function(){return r.a});var a=n(94);n.n(a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n){r(e,t,n)});e.exports=a},function(e,t,n){"use strict";var r=n(98),a=n(154),i=n(64),s=n(23),o=n(165);e.exports=function(e){return'function'==typeof e?e:null==e?i:'object'==typeof e?s(e)?a(e[0],e[1]):r(e):o(e)}},function(e,t,n){"use strict";var r=n(38),a=n(105),i=n(106),s=n(107),o=n(108),c=n(109);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=a,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=c,e.exports=u},function(e,t,n){"use strict";var r=n(30)(n(24),'Map');e.exports=r},function(e,t,n){"use strict";var r=n(33),a=n(26),i='[object AsyncFunction]',s='[object Function]',o='[object GeneratorFunction]',c='[object Proxy]';e.exports=function(e){if(!a(e))return!1;var t=r(e);return t==s||t==o||t==i||t==c}},function(e,t,n){"use strict";var r=n(116),a=n(123),i=n(125),s=n(126),o=n(127);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},function(e,t,n){"use strict";var r=n(75),a=n(147),i=n(36);e.exports=function(e){return i(e)?r(e):a(e)}},function(e,t,n){"use strict";var r=n(142),a=n(31),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,c=r((function(){return arguments})())?r:function(e){return a(e)&&s.call(e,'callee')&&!o.call(e,'callee')};e.exports=c},function(e,t,n){"use strict";(function(e){var r=n(24),a=n(143),i=t&&!t.nodeType&&t,s=i&&'object'==typeof e&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,c=(o?o.isBuffer:void 0)||a;e.exports=c}).call(this,n(57)(e))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";var r=n(144),a=n(145),i=n(146),s=i&&i.isTypedArray,o=s?a(s):r;e.exports=o},function(e,t,n){"use strict";var r=9007199254740991;e.exports=function(e){return'number'==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,n){"use strict";var r=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===('function'==typeof t&&t.prototype||r)}},function(e,t,n){"use strict";var r=n(62),a=n(37);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[a(t[n++])];return n&&n==i?e:void 0}},function(e,t,n){"use strict";var r=n(23),a=n(63),i=n(156),s=n(159);e.exports=function(e,t){return r(e)?e:a(e,t)?[e]:i(s(e))}},function(e,t,n){"use strict";var r=n(23),a=n(44),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!('number'!=n&&'symbol'!=n&&'boolean'!=n&&null!=e&&!a(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},function(e,t,n){"use strict";e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(83);e.exports=function(e,t,n){'__proto__'==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e,t){return t='function'==typeof t?t:void 0,e&&e.length?r(e,void 0,t):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(228),t),a(n(229),t),a(n(230),t)},function(e,t,n){"use strict";(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(34))},function(e,t,n){"use strict";var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+''}catch(e){}}return''}},function(e,t,n){"use strict";var r=n(128),a=n(31);e.exports=function e(t,n,i,s,o){return t===n||(null==t||null==n||!a(t)&&!a(n)?t!=t&&n!=n:r(t,n,i,s,e,o))}},function(e,t,n){"use strict";var r=n(72),a=n(131),i=n(73),s=1,o=2;e.exports=function(e,t,n,c,u,l){var p=n&s,d=e.length,h=t.length;if(d!=h&&!(p&&h>d))return!1;var f=l.get(e),v=l.get(t);if(f&&v)return f==t&&v==e;var y=-1,g=!0,m=n&o?new r:void 0;for(l.set(e,t),l.set(t,e);++y<d;){var b=e[y],w=t[y];if(c)var k=p?c(w,b,y,t,e,l):c(b,w,y,e,t,l);if(void 0!==k){if(k)continue;g=!1;break}if(m){if(!a(t,function(e,t){if(!i(m,t)&&(b===e||u(b,e,n,c,l)))return m.push(t)})){g=!1;break}}else if(b!==w&&!u(b,w,n,c,l)){g=!1;break}}return l.delete(e),l.delete(t),g}},function(e,t,n){"use strict";var r=n(52),a=n(129),i=n(130);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=a,s.prototype.has=i,e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t){return e.has(t)}},function(e,t,n){"use strict";var r=n(24).Uint8Array;e.exports=r},function(e,t,n){"use strict";var r=n(141),a=n(55),i=n(23),s=n(56),o=n(43),c=n(58),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&a(e),p=!n&&!l&&s(e),d=!n&&!l&&!p&&c(e),h=n||l||p||d,f=h?r(e.length,String):[],v=f.length;for(var y in e)!t&&!u.call(e,y)||h&&('length'==y||p&&('offset'==y||'parent'==y)||d&&('buffer'==y||'byteLength'==y||'byteOffset'==y)||o(y,v))||f.push(y);return f}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){"use strict";var r=n(30)(n(24),'Set');e.exports=r},function(e,t,n){"use strict";var r=n(26);e.exports=function(e){return e==e&&!r(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){for(var a=e.length,i=n+(r?1:-1);r?i--:++i<a;)if(t(e[i],i,e))return i;return-1}},function(e,t,n){"use strict";var r=n(49),a=n(82),i=n(178),s=n(180),o=n(26),c=n(86),u=n(85);e.exports=function e(t,n,l,p,d){t!==n&&i(n,function(i,c){if(d||(d=new r),o(i))s(t,n,c,l,e,p,d);else{var h=p?p(u(t,c),i,c+'',t,n,d):void 0;void 0===h&&(h=i),a(t,c,h)}},c)}},function(e,t,n){"use strict";var r=n(65),a=n(35);e.exports=function(e,t,n){(void 0===n||a(e[t],n))&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(30),a=(function(){try{var e=r(Object,'defineProperty');return e({},'',{}),e}catch(e){}})();e.exports=a},function(e,t,n){"use strict";var r=n(76)(Object.getPrototypeOf,Object);e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){if(('constructor'!==t||'function'!=typeof e[t])&&'__proto__'!=t)return e[t]}},function(e,t,n){"use strict";var r=n(75),a=n(192),i=n(36);e.exports=function(e){return i(e)?r(e,!0):a(e)}},function(e,t,n){"use strict";var r=n(194),a=n(201);e.exports=function(e){return r(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(s=e.length>3&&'function'==typeof s?(i--,s):void 0,o&&a(n[0],n[1],o)&&(s=i<3?void 0:s,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,s)}return t})}},function(e,t,n){"use strict";var r=n(72),a=n(202),i=n(206),s=n(73),o=n(207),c=n(53),u=200;e.exports=function(e,t,n){var l=-1,p=a,d=e.length,h=!0,f=[],v=f;if(n)h=!1,p=i;else if(d>=u){var y=t?null:o(e);if(y)return c(y);h=!1,p=s,v=new r}else v=t?[]:f;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=n||0!==g?g:0,h&&m==m){for(var b=v.length;b--;)if(v[b]===m)continue e;t&&v.push(m),f.push(g)}else p(v,m,n)||(v!==f&&v.push(m),f.push(g))}return f}},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(209),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeatureIdentifier=void 0,(function(e){e.AutobiographyTheme="org.standardnotes.theme-autobiography",e.BoldEditor="org.standardnotes.bold-editor",e.CloudLink="org.standardnotes.cloudlink",e.CodeEditor="org.standardnotes.code-editor",e.DailyDropboxBackup="org.standardnotes.daily-dropbox-backup",e.DailyEmailBackup="org.standardnotes.daily-email-backup",e.DailyGDriveBackup="org.standardnotes.daily-gdrive-backup",e.DailyOneDriveBackup="org.standardnotes.daily-onedrive-backup",e.DynamicTheme="org.standardnotes.theme-dynamic",e.Files="org.standardnotes.files",e.Files25GB="org.standardnotes.files-25-gb",e.Files5GB="org.standardnotes.files-5-gb",e.FileSafe="org.standardnotes.file-safe",e.FocusedTheme="org.standardnotes.theme-focus",e.FoldersComponent="org.standardnotes.folders",e.FuturaTheme="org.standardnotes.theme-futura",e.ListedCustomDomain="org.standardnotes.listed-custom-domain",e.MarkdownBasicEditor="org.standardnotes.simple-markdown-editor",e.MarkdownMathEditor="org.standardnotes.fancy-markdown-editor",e.MarkdownMinimistEditor="org.standardnotes.minimal-markdown-editor",e.MarkdownProEditor="org.standardnotes.advanced-markdown-editor",e.MidnightTheme="org.standardnotes.theme-midnight",e.NoDistractionTheme="org.standardnotes.theme-no-distraction",e.NoteHistory30Days="org.standardnotes.note-history-30",e.NoteHistory365Days="org.standardnotes.note-history-365",e.NoteHistoryUnlimited="org.standardnotes.note-history-unlimited",e.PlusEditor="org.standardnotes.plus-editor",e.SheetsEditor="org.standardnotes.standard-sheets",e.SolarizedDarkTheme="org.standardnotes.theme-solarized-dark",e.TagNesting="org.standardnotes.tag-nesting",e.TaskEditor="org.standardnotes.simple-task-editor",e.TitaniumTheme="org.standardnotes.theme-titanium",e.TokenVaultEditor="org.standardnotes.token-vault",e.TwoFactorAuth="org.standardnotes.two-factor-auth",e.TwoFactorAuthManager="org.standardnotes.mfa-link",e.FocusMode="org.standardnotes.focus-mode"})(t.FeatureIdentifier||(t.FeatureIdentifier={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentArea=void 0,(function(e){e.Editor="editor-editor",e.Themes="themes",e.TagsList="tags-list",e.EditorStack="editor-stack",e.NoteTags="note-tags",e.Rooms="rooms",e.Modal="modal",e.Any="*"})(t.ComponentArea||(t.ComponentArea={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentFlag=void 0,(function(e){e.New="New",e.Deprecated="Deprecated"})(t.ComponentFlag||(t.ComponentFlag={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionName=void 0,(function(e){e.AutobiographyTheme="theme:autobiography",e.BoldEditor="editor:bold",e.CloudLink="component:cloud-link",e.CodeEditor="editor:code-editor",e.ComponentFilesafe="component:filesafe",e.ComponentFolders="component:folders",e.DailyDropboxBackup="server:daily-dropbox-backup",e.DailyEmailBackup="server:daily-email-backup",e.DailyGDriveBackup="server:daily-gdrive-backup",e.DailyOneDriveBackup="server:daily-onedrive-backup",e.Files="app:files",e.Files25GB="server:files-25-gb",e.Files5GB="server:files-5-gb",e.FocusedTheme="theme:focused",e.FuturaTheme="theme:futura",e.ListedCustomDomain="listed:custom-domain",e.MarkdownBasicEditor="editor:markdown-basic",e.MarkdownMathEditor="editor:markdown-math",e.MarkdownMinimistEditor="editor:markdown-minimist",e.MarkdownProEditor="editor:markdown-pro",e.MidnightTheme="theme:midnight",e.NoteHistory30Days="server:note-history-30-days",e.NoteHistory365Days="server:note-history-365-days",e.NoteHistoryUnlimited="server:note-history-unlimited",e.PlusEditor="editor:plus",e.SheetsEditor="editor:sheets",e.SolarizedDarkTheme="theme:solarized-dark",e.TagNesting="app:tag-nesting",e.TaskEditor="editor:task-editor",e.ThemeDynamic="theme:dynamic",e.ThemeNoDistraction="theme:no-distraction",e.TitaniumTheme="theme:titanium",e.TokenVaultEditor="editor:token-vault",e.TwoFactorAuth="server:two-factor-auth",e.TwoFactorAuthManager="component:2fa-manager",e.FocusMode="app:focus-mode"})(t.PermissionName||(t.PermissionName={}))},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return i});var r=n(10),a=n(17),i=(function(t){d(r,t);var n=k(r);function r(t){var a;return v(this,r),(a=n.call(this)).application=t,e(function(){a.addAppEventObserver()}),a}return y(r,[{key:"deinit",value:function(){this.application=void 0,this.unsubApp(),this.unsubApp=void 0,p(f(r.prototype),"deinit",this).call(this)}},{key:"addAppEventObserver",value:function(){var e=this;this.application.isStarted()&&this.onAppStart(),this.application.isLaunched()&&this.onAppLaunch(),this.unsubApp=this.application.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(e.onAppEvent(t));case 2:t===a.a.Started?e.onAppStart():t===a.a.Launched?e.onAppLaunch():t===a.a.CompletedFullSync?e.onAppFullSync():t===a.a.CompletedIncrementalSync?e.onAppIncrementalSync():t===a.a.KeyStatusChanged&&e.onAppKeyChange();case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"onAppEvent",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppStart",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppLaunch",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppKeyChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppIncrementalSync",value:function(){}},{key:"onAppFullSync",value:function(){}}]),r})(r.a)}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(10),a=n(2),i=n(15),s=(function(){function e(t,n){v(this,e),this.settingsApi=t,this.userProvider=n}return y(e,[{key:"isReadyForModification",value:function(){return null!=this.getUser()}},{key:"getUser",value:function(){return this.userProvider.getUser()}},{key:"listSettings",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.settingsApi.listSettings(this.userUuid));case 2:if(e=o.sent,t=e.error,n=e.data,null==t){o.next=7;break}throw new Error(t.message);case 7:if(null!=n&&null!=n.settings){o.next=9;break}return o.abrupt("return",{});case 9:for(r={},a=S(n.settings);!(i=a()).done;)s=i.value,r[s.name]=s.value;return o.abrupt("return",r);case 12:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){var t,n,r,a;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((a=s.sent).status!==i.b.HttpBadRequest){s.next=5;break}return s.abrupt("return",null);case 5:if(null==a.error){s.next=7;break}throw new Error(a.error.message);case 7:return s.abrupt("return",null!==(t=null===a||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:null===(r=n.setting)||void 0===r?void 0:r.value)&&void 0!==t?t:null);case 8:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((r=a.sent).status!==i.b.HttpBadRequest){a.next=5;break}return a.abrupt("return",!1);case 5:if(null==r.error){a.next=7;break}throw new Error(r.error.message);case 7:return a.abrupt("return",null!==(t=null===(n=r.data)||void 0===n?void 0:n.success)&&void 0!==t&&t);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){var r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.settingsApi.updateSetting(this.userUuid,e,t,n));case 2:if(r=i.sent,null==(a=r.error)){i.next=6;break}throw new Error(a.message);case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.settingsApi.deleteSetting(this.userUuid,e));case 2:if(t=r.sent,null==(n=t.error)){r.next=6;break}throw new Error(n.message);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.settingsApi=void 0,this.userProvider=void 0}},{key:"userUuid",get:function(){var e=this.getUser();if(null==e||null==e.uuid)throw new Error(a.o);return e.uuid}}]),e})(),o=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).sessionManager=e,a.apiService=r,a}return y(n,[{key:"initializeFromDisk",value:function(){this._provider=new s(this.apiService,this.sessionManager)}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._provider.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this._provider.updateSetting(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){var e;null===(e=this._provider)||void 0===e||e.deinit(),this._provider=void 0,this.sessionManager=void 0,this.apiService=void 0}}]),n})(r.a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n,a){r(e,t,n,a)});e.exports=a},function(e,t,n){"use strict";var r=n(99),a=n(153),i=n(79);e.exports=function(e){var t=a(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){"use strict";var r=n(49),a=n(70);e.exports=function(e,t,n,i){var s=n.length,o=s,c=!i;if(null==e)return!o;for(e=Object(e);s--;){var u=n[s];if(c&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++s<o;){var l=(u=n[s])[0],p=e[l],d=u[1];if(c&&u[2]){if(void 0===p&&!(l in e))return!1}else{var h=new r;if(i)var f=i(p,d,l,e,t,h);if(!(void 0===f?a(d,p,3,i,h):f))return!1}}return!0}},function(e,t,n){"use strict";e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){"use strict";var r=n(39),a=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():a.call(t,n,1),--this.size,0))}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e,t){var n=this.__data__,a=r(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}},function(e,t,n){"use strict";var r=n(38);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.get(e)}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";var r=n(38),a=n(50),i=n(52);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!a||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){"use strict";var r=n(51),a=n(113),i=n(26),s=n(69),o=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,p=u.hasOwnProperty,d=RegExp('^'+l.call(p).replace(/[\\^$.*+?()[\]{}|]/g,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');e.exports=function(e){return!(!i(e)||a(e))&&(r(e)?d:o).test(s(e))}},function(e,t,n){"use strict";var r=n(40),a=Object.prototype,i=a.hasOwnProperty,s=a.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0}catch(e){}var r=s.call(e);return t?e[o]=n:delete e[o],r}},function(e,t,n){"use strict";var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,n){"use strict";var r,a=n(114),i=(r=/[^.]+$/.exec(a&&a.keys&&a.keys.IE_PROTO||''))?'Symbol(src)_1.'+r:'';e.exports=function(e){return!!i&&i in e}},function(e,t,n){"use strict";var r=n(24)['__core-js_shared__'];e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){"use strict";var r=n(117),a=n(38),i=n(50);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||a),string:new r}}},function(e,t,n){"use strict";var r=n(118),a=n(119),i=n(120),s=n(121),o=n(122);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(41);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__',i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===a?void 0:n}return i.call(t,e)?t[e]:void 0}},function(e,t,n){"use strict";var r=n(41),a=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:a.call(t,e)}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__';e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?a:t,this}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return'string'==t||'number'==t||'symbol'==t||'boolean'==t?'__proto__'!==e:null===e}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).get(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).has(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e,t){var n=r(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}},function(e,t,n){"use strict";var r=n(49),a=n(71),i=n(132),s=n(134),o=n(149),c=n(23),u=n(56),l=n(58),p=1,d='[object Arguments]',h='[object Array]',f='[object Object]',v=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,y,g,m){var b=c(e),w=c(t),k=b?h:o(e),x=w?h:o(t),S=(k=k==d?f:k)==f,P=(x=x==d?f:x)==f,O=k==x;if(O&&u(e)){if(!u(t))return!1;b=!0,S=!1}if(O&&!S)return m||(m=new r),b||l(e)?a(e,t,n,y,g,m):i(e,t,k,n,y,g,m);if(!(n&p)){var C=S&&v.call(e,'__wrapped__'),D=P&&v.call(t,'__wrapped__');if(C||D){var _=C?e.value():e,E=D?t.value():t;return m||(m=new r),g(_,E,n,y,m)}}return!!O&&(m||(m=new r),s(e,t,n,y,g,m))}},function(e,t,n){"use strict";var r='__lodash_hash_undefined__';e.exports=function(e){return this.__data__.set(e,r),this}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},function(e,t,n){"use strict";var r=n(40),a=n(74),i=n(35),s=n(71),o=n(133),c=n(53),u=1,l=2,p='[object Boolean]',d='[object Date]',h='[object Error]',f='[object Map]',v='[object Number]',y='[object RegExp]',g='[object Set]',m='[object String]',b='[object Symbol]',w='[object ArrayBuffer]',k='[object DataView]',x=r?r.prototype:void 0,S=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,P,O){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!P(new a(e),new a(t)));case p:case d:case v:return i(+e,+t);case h:return e.name==t.name&&e.message==t.message;case y:case m:return e==t+'';case f:var C=o;case g:var D=r&u;if(C||(C=c),e.size!=t.size&&!D)return!1;var _=O.get(e);if(_)return _==t;r|=l,O.set(e,t);var E=s(C(e),C(t),r,x,P,O);return O.delete(e),E;case b:if(S)return S.call(e)==S.call(t)}return!1}},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},function(e,t,n){"use strict";var r=n(135),a=1,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,s,o,c){var u=n&a,l=r(e),p=l.length;if(p!=r(t).length&&!u)return!1;for(var d=p;d--;){var h=l[d];if(!(u?h in t:i.call(t,h)))return!1}var f=c.get(e),v=c.get(t);if(f&&v)return f==t&&v==e;var y=!0;c.set(e,t),c.set(t,e);for(var g=u;++d<p;){var m=e[h=l[d]],b=t[h];if(s)var w=u?s(b,m,h,t,e,c):s(m,b,h,e,t,c);if(!(void 0===w?m===b||o(m,b,n,s,c):w)){y=!1;break}g||(g='constructor'==h)}if(y&&!g){var k=e.constructor,x=t.constructor;k!=x&&'constructor'in e&&'constructor'in t&&!('function'==typeof k&&k instanceof k&&'function'==typeof x&&x instanceof x)&&(y=!1)}return c.delete(e),c.delete(t),y}},function(e,t,n){"use strict";var r=n(136),a=n(138),i=n(54);e.exports=function(e){return r(e,i,a)}},function(e,t,n){"use strict";var r=n(137),a=n(23);e.exports=function(e,t,n){var i=t(e);return a(e)?i:r(i,n(e))}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}},function(e,t,n){"use strict";var r=n(139),a=n(140),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:a;e.exports=o},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}},function(e,t,n){"use strict";e.exports=function(){return[]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Arguments]';e.exports=function(e){return a(e)&&r(e)==i}},function(e,t,n){"use strict";e.exports=function(){return!1}},function(e,t,n){"use strict";var r=n(33),a=n(59),i=n(31),s={};s['[object Float32Array]']=s['[object Float64Array]']=s['[object Int8Array]']=s['[object Int16Array]']=s['[object Int32Array]']=s['[object Uint8Array]']=s['[object Uint8ClampedArray]']=s['[object Uint16Array]']=s['[object Uint32Array]']=!0,s['[object Arguments]']=s['[object Array]']=s['[object ArrayBuffer]']=s['[object Boolean]']=s['[object DataView]']=s['[object Date]']=s['[object Error]']=s['[object Function]']=s['[object Map]']=s['[object Number]']=s['[object Object]']=s['[object RegExp]']=s['[object Set]']=s['[object String]']=s['[object WeakMap]']=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!s[r(e)]}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){"use strict";(function(e){var r=n(68),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a&&r.process,o=(function(){try{var e=i&&i.require&&i.require('util').types;return e||s&&s.binding&&s.binding('util')}catch(e){}})();e.exports=o}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(60),a=n(148),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return a(e);var t=[];for(var n in Object(e))i.call(e,n)&&'constructor'!=n&&t.push(n);return t}},function(e,t,n){"use strict";var r=n(76)(Object.keys,Object);e.exports=r},function(e,t,n){"use strict";var r=n(150),a=n(50),i=n(151),s=n(77),o=n(152),c=n(33),u=n(69),l=u(r),p=u(a),d=u(i),h=u(s),f=u(o),v=c;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||a&&"[object Map]"!=v(new a)||i&&"[object Promise]"!=v(i.resolve())||s&&"[object Set]"!=v(new s)||o&&"[object WeakMap]"!=v(new o))&&(v=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):'';if(r)switch(r){case l:return"[object DataView]";case p:return"[object Map]";case d:return"[object Promise]";case h:return"[object Set]";case f:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";var r=n(30)(n(24),'DataView');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'Promise');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'WeakMap');e.exports=r},function(e,t,n){"use strict";var r=n(78),a=n(54);e.exports=function(e){for(var t=a(e),n=t.length;n--;){var i=t[n],s=e[i];t[n]=[i,s,r(s)]}return t}},function(e,t,n){"use strict";var r=n(70),a=n(155),i=n(162),s=n(63),o=n(78),c=n(79),u=n(37);e.exports=function(e,t){return s(e)&&o(t)?c(u(e),t):function(n){var s=a(n,e);return void 0===s&&s===t?i(n,e):r(t,s,3)}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e,t,n){var a=null==e?void 0:r(e,t);return void 0===a?n:a}},function(e,t,n){"use strict";var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,i=n(157)(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(''),e.replace(r,function(e,n,r,i){t.push(r?i.replace(a,'$1'):n||e)}),t});e.exports=i},function(e,t,n){"use strict";var r=n(158),a=500;e.exports=function(e){var t=r(e,function(e){return n.size===a&&n.clear(),e}),n=t.cache;return t}},function(e,t,n){"use strict";var r=n(52),a='Expected a function';function i(e,t){if('function'!=typeof e||null!=t&&'function'!=typeof t)throw new TypeError(a);var n=function n(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},function(e,t,n){"use strict";var r=n(160);e.exports=function(e){return null==e?'':r(e)}},function(e,t,n){"use strict";var r=n(40),a=n(161),i=n(23),s=n(44),o=r?r.prototype:void 0,c=o?o.toString:void 0;e.exports=function e(t){if('string'==typeof t)return t;if(i(t))return a(t,e)+'';if(s(t))return c?c.call(t):'';var n=t+'';return'0'==n&&1/t==-1/0?'-0':n}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}},function(e,t,n){"use strict";var r=n(163),a=n(164);e.exports=function(e,t){return null!=e&&a(e,t,r)}},function(e,t,n){"use strict";e.exports=function(e,t){return null!=e&&t in Object(e)}},function(e,t,n){"use strict";var r=n(62),a=n(55),i=n(23),s=n(43),o=n(59),c=n(37);e.exports=function(e,t,n){for(var u=-1,l=(t=r(t,e)).length,p=!1;++u<l;){var d=c(t[u]);if(!(p=null!=e&&n(e,d)))break;e=e[d]}return p||++u!=l?p:!!(l=null==e?0:e.length)&&o(l)&&s(d,l)&&(i(e)||a(e))}},function(e,t,n){"use strict";var r=n(166),a=n(167),i=n(63),s=n(37);e.exports=function(e){return i(e)?r(s(e)):a(e)}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e){return function(t){return r(t,e)}}},function(e,t,n){"use strict";var r=n(169),a=n(43),i=Array.prototype.splice;e.exports=function(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;a(o)?i.call(e,o,1):r(e,o)}}return e}},function(e,t,n){"use strict";var r=n(62),a=n(170),i=n(171),s=n(37);e.exports=function(e,t){return t=r(t,e),null==(e=i(e,t))||delete e[s(a(t))]}},function(e,t,n){"use strict";e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t,n){"use strict";var r=n(61),a=n(172);e.exports=function(e,t){return t.length<2?e:r(e,a(t,0,-1))}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(a);++r<a;)i[r]=e[r+t];return i}},function(e,t,n){"use strict";var r=n(48),a=n(36),i=n(54);e.exports=function(e){return function(t,n,s){var o=Object(t);if(!a(t)){var c=r(n,3);t=i(t),n=function(e){return c(o[e],e,o)}}var u=e(t,n,s);return u>-1?o[c?t[u]:u]:void 0}}},function(e,t,n){"use strict";var r=n(80),a=n(48),i=n(175),s=Math.max;e.exports=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var c=null==n?0:i(n);return c<0&&(c=s(o+c,0)),r(e,a(t,3),c)}},function(e,t,n){"use strict";var r=n(176);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){"use strict";var r=n(177),a=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=r(e))===a||e===-1/0?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,n){"use strict";var r=n(26),a=n(44),i=NaN,s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(a(e))return i;if(r(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=r(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):o.test(e)?i:+e}},function(e,t,n){"use strict";var r=n(179)();e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t,n,r){for(var a=-1,i=Object(t),s=r(t),o=s.length;o--;){var c=s[e?o:++a];if(!1===n(i[c],c,i))break}return t}}},function(e,t,n){"use strict";var r=n(82),a=n(181),i=n(182),s=n(184),o=n(185),c=n(55),u=n(23),l=n(187),p=n(56),d=n(51),h=n(26),f=n(188),v=n(58),y=n(85),g=n(189);e.exports=function(e,t,n,m,b,w,k){var x=y(e,n),S=y(t,n),P=k.get(S);if(P)r(e,n,P);else{var O=w?w(x,S,n+'',e,t,k):void 0,C=void 0===O;if(C){var D=u(S),_=!D&&p(S),E=!D&&!_&&v(S);O=S,D||_||E?u(x)?O=x:l(x)?O=s(x):_?(C=!1,O=a(S,!0)):E?(C=!1,O=i(S,!0)):O=[]:f(S)||c(S)?(O=x,c(x)?O=g(x):h(x)&&!d(x)||(O=o(S))):C=!1}C&&(k.set(S,O),b(O,S,m,w,k),k.delete(S)),r(e,n,O)}}},function(e,t,n){"use strict";(function(e){var r=n(24),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(183);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},function(e,t,n){"use strict";var r=n(74);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t,n){"use strict";e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},function(e,t,n){"use strict";var r=n(186),a=n(84),i=n(60);e.exports=function(e){return'function'!=typeof e.constructor||i(e)?{}:r(a(e))}},function(e,t,n){"use strict";var r=n(26),a=Object.create,i=(function(){function e(){}return function(t){if(!r(t))return{};if(a)return a(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}})();e.exports=i},function(e,t,n){"use strict";var r=n(36),a=n(31);e.exports=function(e){return a(e)&&r(e)}},function(e,t,n){"use strict";var r=n(33),a=n(84),i=n(31),s='[object Object]',o=Function.prototype,c=Object.prototype,u=o.toString,l=c.hasOwnProperty,p=u.call(Object);e.exports=function(e){if(!i(e)||r(e)!=s)return!1;var t=a(e);if(null===t)return!0;var n=l.call(t,'constructor')&&t.constructor;return'function'==typeof n&&n instanceof n&&u.call(n)==p}},function(e,t,n){"use strict";var r=n(190),a=n(86);e.exports=function(e){return r(e,a(e))}},function(e,t,n){"use strict";var r=n(191),a=n(65);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var o=-1,c=t.length;++o<c;){var u=t[o],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?a(n,u,l):r(n,u,l)}return n}},function(e,t,n){"use strict";var r=n(65),a=n(35),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&a(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(26),a=n(60),i=n(193),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=a(e),n=[];for(var o in e)('constructor'!=o||!t&&s.call(e,o))&&n.push(o);return n}},function(e,t,n){"use strict";e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},function(e,t,n){"use strict";var r=n(64),a=n(195),i=n(197);e.exports=function(e,t){return i(a(e,t,r),e+'')}},function(e,t,n){"use strict";var r=n(196),a=Math.max;e.exports=function(e,t,n){return t=a(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=a(i.length-t,0),c=Array(o);++s<o;)c[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(c),r(e,this,u)}}},function(e,t,n){"use strict";e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){"use strict";var r=n(198),a=n(200)(r);e.exports=a},function(e,t,n){"use strict";var r=n(199),a=n(83),i=n(64),s=a?function(e,t){return a(e,'toString',{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},function(e,t,n){"use strict";e.exports=function(e){return function(){return e}}},function(e,t,n){"use strict";var r=800,a=16,i=Date.now;e.exports=function(e){var t=0,n=0;return function(){var s=i(),o=a-(s-n);if(n=s,o>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){"use strict";var r=n(35),a=n(36),i=n(43),s=n(26);e.exports=function(e,t,n){if(!s(n))return!1;var o=typeof t;return!!('number'==o?a(n)&&i(t,n.length):'string'==o&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";var r=n(203);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t,n){"use strict";var r=n(80),a=n(204),i=n(205);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,a,n)}},function(e,t,n){"use strict";e.exports=function(e){return e!=e}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=n-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=-1,a=null==e?0:e.length;++r<a;)if(n(t,e[r]))return!0;return!1}},function(e,t,n){"use strict";var r=n(77),a=n(208),i=n(53),s=r&&1/i(new r([,-0]))[1]==1/0?function(e){return new r(e)}:a;e.exports=s},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";(function(e,t){!(function(e,n){if(!e.setImmediate){var r,a,i,s,o,c=1,u={},l=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){v(e)})}:!(function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}})()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){v(e.data)},r=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(a=p.documentElement,r=function(e){var t=p.createElement("script");t.onreadystatechange=function(){v(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(v,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&v(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return u[c]=a,r(c),c++},d.clearImmediate=h}function h(e){delete u[e]}function f(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}function v(e){if(l)setTimeout(v,0,e);else{var t=u[e];if(t){l=!0;try{f(t)}finally{h(e),l=!1}}}}})("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(34),n(210))},function(e,t,n){"use strict";var r,a,i=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(a===clearTimeout)return clearTimeout(e);if((a===o||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{return a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}!(function(){try{r='function'==typeof setTimeout?setTimeout:s}catch(e){r=s}try{a='function'==typeof clearTimeout?clearTimeout:o}catch(e){a=o}})();var l,p=[],d=!1,h=-1;function f(){d&&l&&(d=!1,l.length?p=l.concat(p):h=-1,p.length&&v())}function v(){if(!d){var e=c(f);d=!0;for(var t=p.length;t;){for(l=p,p=[];++h<t;)l&&l[h].run();h=-1,t=p.length}l=null,d=!1,u(e)}}function y(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new y(e,t)),1!==p.length||d||c(v)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title='browser',i.browser=!0,i.env={},i.argv=[],i.version='',i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error('process.binding is not supported')},i.cwd=function(){return'/'},i.chdir=function(e){throw new Error('process.chdir is not supported')},i.umask=function(){return 0}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(212),t),a(n(213),t),a(n(218),t),a(n(219),t),a(n(220),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentType=void 0,(function(e){e.Any="*",e.Item="SF|Item",e.RootKey="SN|RootKey|NoSync",e.ItemsKey="SN|ItemsKey",e.EncryptedStorage="SN|EncryptedStorage",e.Privileges="SN|Privileges",e.Note="Note",e.Tag="Tag",e.SmartTag="SN|SmartTag",e.Component="SN|Component",e.Editor="SN|Editor",e.ActionsExtension="Extension",e.UserPrefs="SN|UserPreferences",e.HistorySession="SN|HistorySession",e.Theme="SN|Theme",e.ServerExtension="SF|Extension",e.FilesafeCredentials="SN|FileSafe|Credentials",e.FilesafeFileMetadata="SN|FileSafe|FileMetadata",e.FilesafeIntegration="SN|FileSafe|Integration",e.ExtensionRepo="SN|ExtensionRepo",e.Unknown="Unknown"})(t.ContentType||(t.ContentType={}))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.ContentDecoder=void 0;var n=(function(){function t(){v(this,t)}return y(t,[{key:"decode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;try{var r=n>0?t.substring(n):t,a=e.from(r,'base64').toString();return JSON.parse(a)}catch(e){return{}}}},{key:"encode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=JSON.stringify(t),a=e.from(r).toString('base64');return a.padStart(a.length+n,'0')}}]),t})();t.ContentDecoder=n}).call(this,n(214).Buffer)},function(e,t,n){"use strict";(function(e){var r=n(215),a=n(216),i=n(217);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return d(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?v(e,t,n,r):'string'==typeof t?h(e,t,n):y(e,t)}function l(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function p(e,t,n,r){return l(t),t<=0?o(e,t):void 0!==n?'string'==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function d(e,t){if(l(t),e=o(e,t<0?0:0|g(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t,n){if('string'==typeof n&&''!==n||(n='utf8'),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(t,n),a=(e=o(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}function f(e,t){var n=t.length<0?0:0|g(t.length);e=o(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function v(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(r||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t),e}function y(e,t){if(c.isBuffer(t)){var n=0|g(t.length);return 0===(e=o(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||(r=t.length)!=r?o(e,0):f(e,t);if('Buffer'===t.type&&i(t.data))return f(e,t.data)}var r;throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function g(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+' bytes');return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return G(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return $(e).length;default:if(r)return G(e).length;t=(''+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),n<=0)return'';if((n>>>=0)<=(t>>>=0))return'';for(e||(e='utf8');;)switch(e){case'hex':return T(this,t,n);case'utf8':case'utf-8':return R(this,t,n);case'ascii':return A(this,t,n);case'latin1':case'binary':return j(this,t,n);case'base64':return E(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return K(this,t,n);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,a){if(0===e.length)return-1;if('string'==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if('string'==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:x(e,t,n,r,a);if('number'==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):x(e,[t],n,r,a);throw new TypeError('val must be string, number or Buffer')}function x(e,t,n,r,a){var i,s=1,o=e.length,c=t.length;if(void 0!==r&&('ucs2'===(r=String(r).toLowerCase())||'ucs-2'===r||'utf16le'===r||'utf-16le'===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var l=-1;for(i=n;i<o;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>o&&(n=o-c),i=n;i>=0;i--){for(var p=!0,d=0;d<c;d++)if(u(e,i+d)!==u(t,d)){p=!1;break}if(p)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError('Invalid hex string');r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function P(e,t,n,r){return X(G(t,e.length-n),e,n,r)}function O(e,t,n,r){return X(Q(t),e,n,r)}function C(e,t,n,r){return O(e,t,n,r)}function D(e,t,n,r){return X($(t),e,n,r)}function _(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,c,u=e[a],l=null,p=u>239?4:u>223?3:u>191?2:1;if(a+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=p}return M(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:(function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}})(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return p(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('Arguments must be Buffers');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,a),a+=s.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var t=0;t<e;t+=2)w(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?'':0===arguments.length?R(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e='',n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString('hex',0,n).match(/.{2}/g).join(' '),this.length>n&&(e+=' ... ')),'<Buffer '+e+'>'},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError('out of range index');if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,s=n-t,o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),p=0;p<o;++p)if(u[p]!==l[p]){i=u[p],s=l[p];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r='utf8',n=this.length,t=0;else if(void 0===n&&'string'==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');t|=0,isFinite(n)?(n|=0,void 0===r&&(r='utf8')):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return S(this,e,t,n);case'utf8':case'utf-8':return P(this,e,t,n);case'ascii':return O(this,e,t,n);case'latin1':case'binary':return C(this,e,t,n);case'base64':return D(this,e,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return _(this,e,t,n);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var n='',r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function A(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function j(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function T(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a='',i=t;i<n;++i)a+=Y(e[i]);return a}function K(e,t,n){for(var r=e.slice(t,n),a='',i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function L(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError('Index out of range')}function U(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function V(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError('Index out of range');if(n<0)throw new RangeError('Index out of range')}function B(e,t,n,r,i){return i||V(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function W(e,t,n,r,i){return i||V(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var a=t-e;n=new c(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return W(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return W(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError('targetStart out of bounds');if(n<0||n>=this.length)throw new RangeError('sourceStart out of bounds');if(r<0)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if('string'==typeof e){if('string'==typeof t?(r=t,t=0,n=this.length):'string'==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!c.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError('Out of range index');if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),'number'==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:G(new c(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var H=/[^+\/0-9A-Za-z-_]/g;function z(e){if((e=q(e).replace(H,'')).length<2)return'';for(;e.length%4!=0;)e+='=';return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function Y(e){return e<16?'0'+e.toString(16):e.toString(16)}function G(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error('Invalid code point');if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function J(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}function $(e){return r.toByteArray(z(e))}function X(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(34))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],o=r[1],c=new i(l(e,s,o)),p=0,d=o>0?s-4:s;for(n=0;n<d;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=0,o=n-a;s<o;s+=16383)i.push(p(e,s,s+16383>o?o:s+16383));1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+'==')):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+'='));return i.join('')};for(var r=[],a=[],i='undefined'!=typeof Uint8Array?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',o=0,c=s.length;o<c;++o)r[o]=s[o],a[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){return 3*(t+n)/4-n}function p(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join('')}a['-'.charCodeAt(0)]=62,a['_'.charCodeAt(0)]=63},function(e,t,n){"use strict";t.read=function(e,t,n,r,a){var i,s,o=8*a-r-1,c=(1<<o)-1,u=c>>1,l=-7,p=n?a-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=o;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var s,o,c,u=8*i-a-1,l=(1<<u)-1,p=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(o=0,s=l):s+p>=1?(o=(t*c-1)*Math.pow(2,a),s+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+h]=255&o,h+=f,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*v}},function(e,t,n){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==r.call(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTag=void 0,(function(e){e.MfaInvalid="mfa-invalid",e.MfaRequired="mfa-required",e.RefreshTokenInvalid="invalid-refresh-token",e.RefreshTokenExpired="expired-refresh-token",e.AccessTokenExpired="expired-access-token",e.ParametersInvalid="invalid-parameters",e.RevokedSession="revoked-session",e.AuthInvalid="invalid-auth"})(t.ErrorTag||(t.ErrorTag={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(222),t),a(n(90),t),a(n(223),t),a(n(225),t),a(n(93),t),a(n(91),t),a(n(92),t),a(n(226),t),a(n(227),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Features=void 0;for(var a,i=n(19),s=n(91),o=n(92),c=n(93),u=n(90),l=[],p=function(e){var t=e.identifier,n=e.permission_name,r=e.content_type,a=e.area,l=e.flags,p=Object.values(c.PermissionName),d=Object.values(u.FeatureIdentifier),h=Object.values(i.ContentType),f=Object.values(s.ComponentArea),v=Object.values(o.ComponentFlag);if(!d.includes(t))throw Error("Invalid feature identifier ".concat(t));if(!p.includes(n))throw Error("Invalid permission name ".concat(n));if(r&&!h.includes(r))throw Error("Invalid feature content type ".concat(r));if(a&&!f.includes(a))throw Error("Invalid feature area ".concat(a));if(l&&l.some(function(e){return!v.includes(e)}))throw Error("Invalid feature flag ".concat(l))},d=S(r(n(224)).default);!(a=d()).done;){var h=a.value;p(h),l.push(h)}t.Features=l},function(e){e.exports=JSON.parse("[{\"name\":\"Midnight\",\"identifier\":\"org.standardnotes.theme-midnight\",\"permission_name\":\"theme:midnight\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Elegant utilitarianism.\",\"url\":\"#{url_prefix}/themes/midnight\",\"download_url\":\"https://github.com/standardnotes/midnight-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/midnight\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#086DD6\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#086DD6\"}},{\"name\":\"Futura\",\"identifier\":\"org.standardnotes.theme-futura\",\"permission_name\":\"theme:futura\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Calm and relaxed. Take some time off.\",\"url\":\"#{url_prefix}/themes/futura\",\"download_url\":\"https://github.com/standardnotes/futura-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/futura\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#fca429\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#fca429\"}},{\"name\":\"Solarized Dark\",\"identifier\":\"org.standardnotes.theme-solarized-dark\",\"permission_name\":\"theme:solarized-dark\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.3\",\"description\":\"The perfect theme for any time.\",\"url\":\"#{url_prefix}/themes/solarized-dark\",\"download_url\":\"https://github.com/standardnotes/solarized-dark-theme/archive/1.2.3.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/solarized-dark\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#2AA198\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#2AA198\"}},{\"name\":\"Autobiography\",\"identifier\":\"org.standardnotes.theme-autobiography\",\"permission_name\":\"theme:autobiography\",\"content_type\":\"SN|Theme\",\"version\":\"1.0.1\",\"description\":\"A theme for writers and readers.\",\"url\":\"#{url_prefix}/themes/autobiography\",\"download_url\":\"https://github.com/standardnotes/autobiography-theme/archive/1.0.1.zip\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg\",\"flags\":[\"New\"],\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#9D7441\",\"foreground_color\":\"#ECE4DB\",\"border_color\":\"#9D7441\"}},{\"name\":\"Focus\",\"identifier\":\"org.standardnotes.theme-focus\",\"permission_name\":\"theme:focused\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.5\",\"description\":\"For when you need to go in.\",\"url\":\"#{url_prefix}/themes/focus\",\"download_url\":\"https://github.com/standardnotes/focus-theme/archive/1.2.5.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/focused\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#a464c2\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#a464c2\"}},{\"identifier\":\"org.standardnotes.theme-titanium\",\"permission_name\":\"theme:titanium\",\"name\":\"Titanium\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Light on the eyes, heavy on the spirit.\",\"url\":\"#{url_prefix}/themes/titanium\",\"download_url\":\"https://github.com/standardnotes/titanium-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/titanium\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#6e2b9e\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#6e2b9e\"}},{\"identifier\":\"org.standardnotes.theme-dynamic\",\"name\":\"Dynamic\",\"permission_name\":\"theme:dynamic\",\"content_type\":\"SN|Theme\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.0.0\",\"description\":\"A smart theme that minimizes the tags and notes panels when they are not in use.\",\"url\":\"#{url_prefix}/themes/dynamic\",\"download_url\":\"https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/dynamic\"},{\"identifier\":\"org.standardnotes.theme-no-distraction\",\"name\":\"No Distraction\",\"content_type\":\"SN|Theme\",\"permission_name\":\"theme:no-distraction\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.2.2\",\"description\":\"A theme for focusing on your writing.\",\"url\":\"#{url_prefix}/themes/no-distraction\",\"download_url\":\"https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/no-distraction\",\"dock_icon\":{\"type\":\"svg\",\"source\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><path d=\\\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\\\"/></svg>\"}},{\"name\":\"Bold Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.bold-editor\",\"permission_name\":\"editor:bold\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.2.9\",\"description\":\"A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.\",\"url\":\"#{url_prefix}/components/bold-editor\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg\",\"download_url\":\"https://github.com/standardnotes/bold-editor/archive/1.2.9.zip\"},{\"name\":\"Plus Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.plus-editor\",\"permission_name\":\"editor:plus\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.5.0\",\"description\":\"From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.\",\"url\":\"#{url_prefix}/components/plus-editor\",\"download_url\":\"https://github.com/standardnotes/plus-editor/archive/1.5.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/plus-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg\"},{\"name\":\"Markdown Basic\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.simple-markdown-editor\",\"permission_name\":\"editor:markdown-basic\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A Markdown editor with dynamic split-pane preview.\",\"url\":\"#{url_prefix}/components/simple-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg\"},{\"name\":\"Markdown Pro\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.advanced-markdown-editor\",\"permission_name\":\"editor:markdown-pro\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.14\",\"description\":\"A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.\",\"url\":\"#{url_prefix}/components/advanced-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/advanced-markdown-editor/archive/1.3.14.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/advanced-markdown\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg\"},{\"name\":\"Markdown Minimist\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.minimal-markdown-editor\",\"permission_name\":\"editor:markdown-minimist\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F\",\"url\":\"#{url_prefix}/components/minimal-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/minimal-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg\"},{\"name\":\"Markdown Math\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.fancy-markdown-editor\",\"permission_name\":\"editor:markdown-math\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.4\",\"description\":\"A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.\",\"url\":\"#{url_prefix}/components/fancy-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/math-editor/archive/1.3.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/math-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg\"},{\"name\":\"Task Editor\",\"note_type\":\"task\",\"file_type\":\"md\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.simple-task-editor\",\"permission_name\":\"editor:task-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A great way to manage short-term and long-term to-do\\\"s. You can mark tasks as completed, change their order, and edit the text naturally in place.\",\"url\":\"#{url_prefix}/components/simple-task-editor\",\"download_url\":\"https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-task-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg\"},{\"name\":\"Code Editor\",\"note_type\":\"code\",\"file_type\":\"txt\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.code-editor\",\"permission_name\":\"editor:code-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.8\",\"description\":\"Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.\",\"url\":\"#{url_prefix}/components/code-editor\",\"download_url\":\"https://github.com/standardnotes/code-editor/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/code-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg\"},{\"name\":\"TokenVault\",\"note_type\":\"authentication\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.token-vault\",\"permission_name\":\"editor:token-vault\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"2.0.6\",\"description\":\"Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.\",\"url\":\"#{url_prefix}/components/token-vault\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/token-vault/archive/2.0.6.zip\",\"thumbnail_url\":\"https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png\",\"flags\":[\"New\"]},{\"name\":\"Secure Spreadsheets\",\"note_type\":\"spreadsheet\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.standard-sheets\",\"permission_name\":\"editor:sheets\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.\",\"url\":\"#{url_prefix}/components/standard-sheets\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/secure-spreadsheets/archive/1.4.0.zip\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png\"},{\"identifier\":\"org.standardnotes.file-safe\",\"name\":\"FileSafe\",\"permission_name\":\"component:filesafe\",\"content_type\":\"SN|Component\",\"area\":\"editor-stack\",\"version\":\"2.0.10\",\"description\":\"Encrypted attachments for your notes using your Dropbox, Google Drive, or WebDAV server. Limited to 50MB per file.\",\"url\":\"#{url_prefix}/components/filesafe\",\"download_url\":\"https://github.com/standardnotes/filesafe-client/archive/2.0.10.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/filesafe\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/FileSafe-banner.png\"},{\"identifier\":\"org.standardnotes.folders\",\"name\":\"Folders\",\"content_type\":\"SN|Component\",\"permission_name\":\"component:folders\",\"area\":\"tags-list\",\"version\":\"1.3.8\",\"description\":\"Create nested folders with easy drag and drop.\",\"url\":\"#{url_prefix}/components/folders\",\"download_url\":\"https://github.com/standardnotes/folders-component/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/folders\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/components/folders.jpg\"},{\"name\":\"2FA Manager\",\"identifier\":\"org.standardnotes.mfa-link\",\"permission_name\":\"component:2fa-manager\",\"content_type\":\"SN|Component\",\"description\":\"Configure two-factor authentication to add an extra level of security to your account.\",\"version\":\"1.2.4\",\"url\":\"#{url_prefix}/components/mfa-link\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/mfa-link/archive/1.2.4.zip\",\"area\":\"modal\",\"no_expire\":true,\"deletion_warning\":\"Deleting 2FA Manager will not disable 2FA from your account. To disable 2FA, first open 2FA Manager, then follow the prompts.\",\"deprecated\":true},{\"name\":\"\",\"identifier\":\"org.standardnotes.two-factor-auth\",\"permission_name\":\"server:two-factor-auth\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-unlimited\",\"permission_name\":\"server:note-history-unlimited\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-365\",\"permission_name\":\"server:note-history-365-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-30\",\"permission_name\":\"server:note-history-30-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-email-backup\",\"permission_name\":\"server:daily-email-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-dropbox-backup\",\"permission_name\":\"server:daily-dropbox-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-gdrive-backup\",\"permission_name\":\"server:daily-gdrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-onedrive-backup\",\"permission_name\":\"server:daily-onedrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-25-gb\",\"permission_name\":\"server:files-25-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-5-gb\",\"permission_name\":\"server:files-5-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Tag Nesting\",\"identifier\":\"org.standardnotes.tag-nesting\",\"permission_name\":\"app:tag-nesting\",\"description\":\"Create nested tags with easy drag and drop.\",\"version\":\"0.1.0\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files\",\"permission_name\":\"app:files\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"CloudLink\",\"identifier\":\"org.standardnotes.cloudlink\",\"permission_name\":\"component:cloud-link\",\"content_type\":\"SN|Component\",\"description\":\"Manage and install cloud backups, including Note History, Dropbox, Google Drive, OneDrive, and Daily Email Backups.\",\"version\":\"1.2.3\",\"url\":\"#{url_prefix}/components/cloudlink\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Listed Custom Domain\",\"identifier\":\"org.standardnotes.listed-custom-domain\",\"permission_name\":\"listed:custom-domain\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"Focus Mode\",\"identifier\":\"org.standardnotes.focus-mode\",\"permission_name\":\"app:focus-mode\"}]")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoteType=void 0,(function(e){e.Authentication="authentication",e.Code="code",e.Markdown="markdown",e.RichText="rich-text",e.Spreadsheet="spreadsheet",e.Task="task"})(t.NoteType||(t.NoteType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timingSafeEqual=void 0,t.timingSafeEqual=function(e,t){var n=String(e),r=String(t),a=n.length,i=0;a!==r.length&&(r=n,i=1);for(var s=0;s<a;s++)i|=n.charCodeAt(s)^r.charCodeAt(s);return 0===i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(232),t),a(n(233),t),a(n(234),t),a(n(235),t),a(n(236),t),a(n(237),t),a(n(238),t),a(n(239),t),a(n(240),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoleName=void 0,(function(e){e.BasicUser="BASIC_USER",e.CoreUser="CORE_USER",e.PlusUser="PLUS_USER",e.ProUser="PRO_USER"})(t.RoleName||(t.RoleName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionName=void 0,(function(e){e.CorePlan="CORE_PLAN",e.PlusPlan="PLUS_PLAN",e.ProPlan="PRO_PLAN"})(t.SubscriptionName||(t.SubscriptionName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(242),t),a(n(243),t),a(n(244),t),a(n(245),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmailBackupFrequency=void 0,(function(e){e.Daily="daily",e.Weekly="weekly"})(t.EmailBackupFrequency||(t.EmailBackupFrequency={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedBackupsEmailsOption||(t.MuteFailedBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedCloudBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedCloudBackupsEmailsOption||(t.MuteFailedCloudBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingName=void 0,(function(e){e.MfaSecret="MFA_SECRET",e.ExtensionKey="EXTENSION_KEY",e.EmailBackup="EMAIL_BACKUP",e.MuteFailedBackupsEmails="MUTE_FAILED_BACKUPS_EMAILS",e.MuteFailedCloudBackupsEmails="MUTE_FAILED_CLOUD_BACKUPS_EMAILS"})(t.SettingName||(t.SettingName={}))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"SnjsVersion",function(){return h}),n.d(t,"isRightVersionGreaterThanLeft",function(){return x}),n.d(t,"compareSemVersions",function(){return P}),n.d(t,"SNApplicationGroup",function(){return M}),n.d(t,"DeinitSource",function(){return C}),n.d(t,"KeyParamsOrigination",function(){return A.g}),n.d(t,"KeyRecoveryStrings",function(){return j.H}),n.d(t,"SessionStrings",function(){return j.R}),n.d(t,"SNApplication",function(){return ca}),n.d(t,"SNProtocolService",function(){return Gn}),n.d(t,"KeyMode",function(){return Bn}),n.d(t,"SNProtocolOperator001",function(){return An}),n.d(t,"SNProtocolOperator002",function(){return Fn}),n.d(t,"SNProtocolOperator003",function(){return Ln}),n.d(t,"SNProtocolOperator004",function(){return Wn}),n.d(t,"SNRootKey",function(){return Ve}),n.d(t,"SNRootKeyParams",function(){return A.h}),n.d(t,"DeviceInterface",function(){return ua}),n.d(t,"SNItem",function(){return T.d}),n.d(t,"ItemMutator",function(){return T.b}),n.d(t,"AppDataField",function(){return T.a}),n.d(t,"SNItemsKey",function(){return J}),n.d(t,"SNPredicate",function(){return H.a}),n.d(t,"SNNote",function(){return le}),n.d(t,"NoteMutator",function(){return pe}),n.d(t,"SNTag",function(){return oe}),n.d(t,"TagMutator",function(){return ce}),n.d(t,"SNSmartTag",function(){return et}),n.d(t,"SNActionsExtension",function(){return ie}),n.d(t,"ActionsExtensionMutator",function(){return se}),n.d(t,"Action",function(){return ae}),n.d(t,"SNTheme",function(){return B}),n.d(t,"ThemeMutator",function(){return W}),n.d(t,"SNComponent",function(){return N}),n.d(t,"ComponentAction",function(){return E}),n.d(t,"ComponentMutator",function(){return V}),n.d(t,"SNEditor",function(){return Ze}),n.d(t,"SNUserPrefs",function(){return z}),n.d(t,"UserPrefsMutator",function(){return G}),n.d(t,"PrefKey",function(){return U}),n.d(t,"MutationType",function(){return T.c}),n.d(t,"ComponentArea",function(){return L.ComponentArea}),n.d(t,"LiveItem",function(){return la}),n.d(t,"FeatureStatus",function(){return ur}),n.d(t,"SNComponentManager",function(){return an}),n.d(t,"HistoryEntry",function(){return Qn}),n.d(t,"PayloadManager",function(){return sn}),n.d(t,"ItemManager",function(){return _r}),n.d(t,"SNHttpService",function(){return jt}),n.d(t,"ChallengeService",function(){return na}),n.d(t,"PureService",function(){return R.a}),n.d(t,"ApplicationService",function(){return pa.a}),n.d(t,"SNStorageService",function(){return Ie}),n.d(t,"StoragePersistencePolicies",function(){return Oe}),n.d(t,"StorageEncryptionPolicies",function(){return Ce}),n.d(t,"StorageValueModes",function(){return De}),n.d(t,"ValueModesKeys",function(){return _e}),n.d(t,"Challenge",function(){return ye}),n.d(t,"ChallengeReason",function(){return ne}),n.d(t,"ChallengeResponse",function(){return be}),n.d(t,"ChallengeValidation",function(){return te}),n.d(t,"ChallengeValue",function(){return me}),n.d(t,"ChallengePrompt",function(){return ge}),n.d(t,"SNSyncService",function(){return ea}),n.d(t,"SyncSources",function(){return $r}),n.d(t,"SyncModes",function(){return Jr}),n.d(t,"SyncQueueStrategy",function(){return Qr}),n.d(t,"SNCredentialService",function(){return Qe}),n.d(t,"SyncResponse",function(){return Br}),n.d(t,"SyncResponseResolver",function(){return Vr}),n.d(t,"SyncOpStatus",function(){return fr}),n.d(t,"SortPayloadsByRecentAndContentPriority",function(){return Mr}),n.d(t,"SyncUpDownLimit",function(){return Wr}),n.d(t,"SNSessionManager",function(){return Ge}),n.d(t,"SessionEvent",function(){return ze}),n.d(t,"SNMigrationService",function(){return En}),n.d(t,"ButtonType",function(){return St}),n.d(t,"SNHistoryManager",function(){return nr}),n.d(t,"SNProtectionService",function(){return ir}),n.d(t,"SNSingletonManager",function(){return cn}),n.d(t,"SNApiService",function(){return Yt}),n.d(t,"addIfUnique",function(){return _.b}),n.d(t,"arrayByDifference",function(){return _.c}),n.d(t,"Copy",function(){return _.a}),n.d(t,"dateSorted",function(){return _.j}),n.d(t,"deepMerge",function(){return _.m}),n.d(t,"dictToArray",function(){return _.n}),n.d(t,"extendArray",function(){return _.o}),n.d(t,"filterFromArray",function(){return _.p}),n.d(t,"findInArray",function(){return _.q}),n.d(t,"getGlobalScope",function(){return _.r}),n.d(t,"greaterOfTwoDates",function(){return _.s}),n.d(t,"isNullOrUndefined",function(){return _.w}),n.d(t,"isSameDay",function(){return _.z}),n.d(t,"jsonParseEmbeddedKeys",function(){return _.E}),n.d(t,"naturalSort",function(){return _.G}),n.d(t,"omitInPlace",function(){return _.J}),n.d(t,"omitUndefinedCopy",function(){return _.K}),n.d(t,"removeFromArray",function(){return _.M}),n.d(t,"removeFromIndex",function(){return _.N}),n.d(t,"subtractFromArray",function(){return _.R}),n.d(t,"topLevelCompare",function(){return _.S}),n.d(t,"truncateHexString",function(){return _.T}),n.d(t,"uniqueArrayByKey",function(){return _.W}),n.d(t,"uniqCombineObjArrays",function(){return _.U}),n.d(t,"convertTimestampToMilliseconds",function(){return _.i}),n.d(t,"arraysEqual",function(){return _.e}),n.d(t,"isValidUrl",function(){return _.B}),n.d(t,"dateToLocalizedString",function(){return _.k}),n.d(t,"Uuid",function(){return I}),n.d(t,"EncryptionIntent",function(){return Re.b}),n.d(t,"isLocalStorageIntent",function(){return Re.f}),n.d(t,"isFileIntent",function(){return Re.e}),n.d(t,"isDecryptedIntent",function(){return Re.d}),n.d(t,"intentRequiresEncryption",function(){return Re.c}),n.d(t,"ContentTypeUsesRootKeyEncryption",function(){return Re.a}),n.d(t,"ContentType",function(){return F.a}),n.d(t,"displayStringForContentType",function(){return F.c}),n.d(t,"CreateItemFromPayload",function(){return nt}),n.d(t,"Uuids",function(){return Ke.b}),n.d(t,"FillItemContent",function(){return Ke.a}),n.d(t,"ApplicationEvent",function(){return At.a}),n.d(t,"Environment",function(){return he}),n.d(t,"Platform",function(){return fe}),n.d(t,"isEnvironmentWebOrDesktop",function(){return Se}),n.d(t,"isEnvironmentMobile",function(){return Pe}),n.d(t,"platformFromString",function(){return ke}),n.d(t,"environmentFromString",function(){return xe}),n.d(t,"SyncEvent",function(){return on.a}),n.d(t,"MutableCollection",function(){return mt}),n.d(t,"ImmutablePayloadCollection",function(){return bt}),n.d(t,"ItemCollection",function(){return gn}),n.d(t,"CollectionSort",function(){return dn}),n.d(t,"CreateMaxPayloadFromAnyObject",function(){return Ee.e}),n.d(t,"CreateSourcedPayloadFromObject",function(){return Ee.f}),n.d(t,"CreateIntentPayloadFromObject",function(){return Ee.d}),n.d(t,"CreateEncryptionParameters",function(){return Ee.c}),n.d(t,"PayloadByMerging",function(){return Ee.g}),n.d(t,"CopyPayload",function(){return Ee.b}),n.d(t,"PayloadSource",function(){return ht.a}),n.d(t,"isPayloadSourceRetrieved",function(){return ht.c}),n.d(t,"isPayloadSourceInternalChange",function(){return ht.b}),n.d(t,"DeltaOutOfSync",function(){return _t}),n.d(t,"ProtocolVersion",function(){return Q.a}),n.d(t,"PayloadFormat",function(){return ue.a}),n.d(t,"PurePayload",function(){return ft.a}),n.d(t,"PayloadField",function(){return Je.a}),n.d(t,"NotesDisplayCriteria",function(){return br}),n.d(t,"notesMatchingCriteria",function(){return wr}),n.d(t,"StorageKey",function(){return o}),n.d(t,"RawStorageKey",function(){return s}),n.d(t,"NonwrappedStorageKey",function(){return c}),n.d(t,"namespacedKey",function(){return O}),n.d(t,"BaseMigration",function(){return _n}),n.d(t,"ProtectionSessionDurations",function(){return ar}),n.d(t,"SNLog",function(){return we.a}),n.d(t,"Features",function(){return L.Features}),n.d(t,"FeatureIdentifier",function(){return L.FeatureIdentifier}),n.d(t,"RoleName",function(){return sr.RoleName}),n.d(t,"SettingName",function(){return pr.SettingName}),n.d(t,"Migration2_20_0",function(){return Pn}),n.d(t,"ApplicationStage",function(){return ve});var a={};n.r(a),n.d(a,"Migration2_0_0",function(){return kn}),n.d(a,"Migration2_0_15",function(){return xn}),n.d(a,"Migration2_7_0",function(){return Sn}),n.d(a,"Migration2_20_0",function(){return Pn});var i={};n.r(i),n.d(i,"StorageReader2_0_0",function(){return On}),n.d(i,"StorageReader1_0_0",function(){return vn});var s,o,c,h="2.20.3";function x(e,t){return-1===P(e,t)}function P(e,t){for(var n=e.split('.'),r=t.split('.'),a=0;a<r.length;a++){var i=Number(~~r[a]),s=Number(~~n[a]);if(i>s)return-1;if(i<s)return 1}return 0}function O(e,t){return e?"".concat(e,"-").concat(t):t}!(function(e){e.StorageObject="storage",e.DescriptorRecord="descriptors",e.SnjsVersion="snjs_version"})(s||(s={})),(function(e){e.RootKeyParams="ROOT_KEY_PARAMS",e.WrappedRootKey="WRAPPED_ROOT_KEY",e.RootKeyWrapperKeyParams="ROOT_KEY_WRAPPER_KEY_PARAMS",e.Session="session",e.User="user",e.ServerHost="server",e.LegacyUuid="uuid",e.LastSyncToken="syncToken",e.PaginationToken="cursorToken",e.BiometricsState="biometrics_state",e.MobilePasscodeTiming="passcode_timing",e.MobileBiometricsTiming="biometrics_timing",e.MobilePasscodeKeyboardType="passcodeKeyboardType",e.MobilePreferences="preferences",e.MobileScreenshotPrivacyEnabled="screenshotPrivacy_enabled",e.ProtectionExpirey="SessionExpiresAtKey",e.ProtectionSessionLength="SessionLengthKey",e.SessionHistoryPersistable="sessionHistory_persist",e.SessionHistoryRevisions="sessionHistory_revisions",e.SessionHistoryOptimize="sessionHistory_autoOptimize",e.KeyRecoveryUndecryptableItems="key_recovery_undecryptable",e.StorageEncryptionPolicy="storage_policy",e.WebSocketUrl="webSocket_url",e.UserRoles="user_roles",e.UserFeatures="user_features"})(o||(o={})),(function(e){e.MobileFirstRun="first_run"})(c||(c={}));var C,D={WebPasscodeParamsKey:'offlineParams',MobilePasscodeParamsKey:'pc_params',AllAccountKeyParamsKey:'auth_params',WebEncryptedStorageKey:'encryptedStorage',MobileWrappedRootKeyKey:'encrypted_account_keys',MobileBiometricsPrefs:'biometrics_prefs',AllMigrations:'migrations',MobileThemesCache:'ThemePreferencesKey',MobileLightTheme:'lightTheme',MobileDarkTheme:'darkTheme',MobileLastExportDate:'LastExportDateKey',MobileDoNotWarnUnsupportedEditors:'DoNotShowAgainUnsupportedEditorsKey',MobileOptionsState:'options',MobilePasscodeKeyboardType:'passcodeKeyboardType'},_=n(0);!(function(e){e[e.SignOut=1]="SignOut",e[e.Lock=2]="Lock",e[e.AppGroupUnload=3]="AppGroupUnload"})(C||(C={}));var E,R=n(10),I=(function(){function e(){v(this,e)}return y(e,null,[{key:"SetGenerators",value:function(e,t){this.syncUuidFunc=t,this.asyncUuidFunc=e}},{key:"canGenSync",value:function(){return!Object(_.w)(this.syncUuidFunc)}},{key:"GenerateUuid",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.syncUuidFunc){e.next=4;break}return e.abrupt("return",this.syncUuidFunc());case 4:return e.abrupt("return",this.asyncUuidFunc());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"GenerateUuidSynchronously",value:function(){return this.syncUuidFunc()}}]),e})(),M=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).deviceInterface=e,r.changeObservers=[],r.applications=[],r.onApplicationDeinit=function(e,t){var n=t!==C.AppGroupUnload;if(r.primaryApplication===e&&(r.primaryApplication=void 0),Object(_.M)(r.applications,e),t===C.SignOut){if(r.removeDescriptor(r.descriptorForApplication(e)),n){var a=r.getDescriptors();return 0===a.length?r.addNewApplication():r.loadApplicationForDescriptor(a[0])}}else if(t===C.Lock&&n){var i=r.descriptorForApplication(e);return r.loadApplicationForDescriptor(i)}},r}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.deviceInterface.deinit(),this.deviceInterface=void 0}},{key:"initialize",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.callback=e,r.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(s.DescriptorRecord));case 3:if(this.descriptorRecord=r.sent,this.descriptorRecord){r.next=7;break}return r.next=7,b.awrap(this.createDescriptorRecord());case 7:if(t=this.findPrimaryDescriptor()){r.next=10;break}throw Error('No primary application descriptor found. Ensure migrations have been run.');case 10:n=this.buildApplication(t),this.applications.push(n),this.setPrimaryApplication(n,!1);case 13:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createDescriptorRecord",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:t=g({},e='standardnotes',{identifier:e,label:'Main Application',primary:!0}),this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(t)),this.descriptorRecord=t,this.persistDescriptors();case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getApplications",value:function(){return this.applications}},{key:"getDescriptors",value:function(){return Object.values(this.descriptorRecord)}},{key:"findPrimaryDescriptor",value:function(){for(var e,t=S(this.getDescriptors());!(e=t()).done;){var n=e.value;if(n.primary)return n}}},{key:"addApplicationChangeObserver",value:function(e){var t=this;return this.changeObservers.push(e),this.primaryApplication&&e(),function(){Object(_.M)(t.changeObservers,e)}}},{key:"notifyObserversOfAppChange",value:function(){for(var e,t=S(this.changeObservers);!(e=t()).done;){(0,e.value)()}}},{key:"setPrimaryApplication",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=!(r.length>1&&void 0!==r[1])||r[1],this.primaryApplication!==e){a.next=3;break}return a.abrupt("return");case 3:if(this.applications.includes(e)){a.next=5;break}throw Error('Application must be inserted before attempting to switch to it');case 5:if(this.primaryApplication&&this.primaryApplication.deinit(C.AppGroupUnload),this.primaryApplication=e,n=this.descriptorForApplication(e),this.setDescriptorAsPrimary(n),this.notifyObserversOfAppChange(),!t){a.next=13;break}return a.next=13,b.awrap(this.persistDescriptors());case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setDescriptorAsPrimary",value:function(e){for(var t,n=S(this.getDescriptors());!(t=n()).done;){var r=t.value;r.primary=r===e}}},{key:"persistDescriptors",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(this.descriptorRecord));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"renameDescriptor",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e.label=t,n.next=3,b.awrap(this.persistDescriptors());case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"removeDescriptor",value:function(e){return delete this.descriptorRecord[e.identifier],this.persistDescriptors()}},{key:"descriptorForApplication",value:function(e){return this.descriptorRecord[e.identifier]}},{key:"addNewApplication",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(I.GenerateUuid());case 2:return t=i.sent,n=this.getDescriptors().length+1,r={identifier:t,label:e||"Application ".concat(n),primary:!1},a=this.buildApplication(r),this.applications.push(a),this.descriptorRecord[t]=r,i.next=10,b.awrap(this.setPrimaryApplication(a));case 10:return i.next=12,b.awrap(this.persistDescriptors());case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"applicationForDescriptor",value:function(e){return this.applications.find(function(t){return t.identifier===e.identifier})}},{key:"loadApplicationForDescriptor",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=this.applicationForDescriptor(e))||(t=this.buildApplication(e),this.applications.push(t)),n.next=4,b.awrap(this.setPrimaryApplication(t));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"buildApplication",value:function(e){var t=this.callback.applicationCreator(e,this.deviceInterface);return t.setOnDeinit(this.onApplicationDeinit),t}}]),n})(R.a),A=n(13),j=n(2),T=n(7),K=n(18),F=n(3),L=n(20);!(function(e){e.SetSize="set-size",e.StreamItems="stream-items",e.StreamContextItem="stream-context-item",e.SaveItems="save-items",e.SelectItem="select-item",e.AssociateItem="associate-item",e.DeassociateItem="deassociate-item",e.ClearSelection="clear-selection",e.CreateItem="create-item",e.CreateItems="create-items",e.DeleteItems="delete-items",e.SetComponentData="set-component-data",e.InstallLocalComponent="install-local-component",e.ToggleActivateComponent="toggle-activate-component",e.RequestPermissions="request-permissions",e.PresentConflictResolution="present-conflict-resolution",e.DuplicateItem="duplicate-item",e.ComponentRegistered="component-registered",e.ActivateThemes="themes",e.Reply="reply",e.SaveSuccess="save-success",e.SaveError="save-error",e.ThemesActivated="themes-activated",e.KeyDown="key-down",e.KeyUp="key-up",e.Click="click"})(E||(E={}));var U,N=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).permissions=[],r.componentData=r.payload.safeContent.componentData||{},Object(_.B)(r.payload.safeContent.hosted_url)?r.hosted_url=r.payload.safeContent.hosted_url:Object(_.B)(r.payload.safeContent.url)?r.hosted_url=r.payload.safeContent.url:Object(_.B)(r.payload.safeContent.legacy_url)&&(r.hosted_url=r.payload.safeContent.legacy_url),r.local_url=r.payload.safeContent.local_url,r.valid_until=new Date(r.payload.safeContent.valid_until||0),r.offlineOnly=r.payload.safeContent.offlineOnly,r.name=r.payload.safeContent.name,r.area=r.payload.safeContent.area,r.package_info=r.payload.safeContent.package_info||{},r.permissions=r.payload.safeContent.permissions||[],r.active=r.payload.safeContent.active,r.autoupdateDisabled=r.payload.safeContent.autoupdateDisabled,r.disassociatedItemIds=r.payload.safeContent.disassociatedItemIds||[],r.associatedItemIds=r.payload.safeContent.associatedItemIds||[],r.isMobileDefault=r.payload.safeContent.isMobileDefault,r.legacy_url=r.payload.safeContent.hosted_url?void 0:r.payload.safeContent.url,r}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"isEditor",value:function(){return this.area===L.ComponentArea.Editor}},{key:"isTheme",value:function(){return this.content_type===F.a.Theme||this.area===L.ComponentArea.Themes}},{key:"isDefaultEditor",value:function(){return!0===this.getAppDomainValue(T.a.DefaultEditor)}},{key:"getLastSize",value:function(){return this.getAppDomainValue(T.a.LastSize)}},{key:"acceptsThemes",value:function(){var e;return null===(e=this.payload.safeContent.package_info)||void 0===e?void 0:e.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return void 0!=(this.hosted_url||this.legacy_url)}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['active','disassociatedItemIds','associatedItemIds'].concat(p(f(n.prototype),"contentKeysToIgnoreWhenCheckingEquality",this).call(this))}},{key:"isAssociative",value:function(){return n.associativeAreas().includes(this.area)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e)}},{key:"isExpired",get:function(){return this.valid_until.getTime()>0&&this.valid_until<=new Date}},{key:"identifier",get:function(){return this.package_info.identifier}},{key:"isDeprecated",get:function(){var e,t=null!==(e=this.package_info.flags)&&void 0!==e?e:[];return(t=t.map(function(e){return e.toLowerCase()})).includes(L.ComponentFlag.Deprecated)}}],[{key:"associativeAreas",value:function(){return[L.ComponentArea.Editor]}}]),n})(T.d),V=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"associateWithItem",value:function(e){var t=this.typedContent.associatedItemIds||[];Object(_.b)(t,e),this.typedContent.associatedItemIds=t}},{key:"disassociateWithItem",value:function(e){var t=this.typedContent.disassociatedItemIds||[];Object(_.b)(t,e),this.typedContent.disassociatedItemIds=t}},{key:"removeAssociatedItemId",value:function(e){Object(_.M)(this.typedContent.associatedItemIds||[],e)}},{key:"removeDisassociatedItemId",value:function(e){Object(_.M)(this.typedContent.disassociatedItemIds||[],e)}},{key:"setLastSize",value:function(e){this.setAppDataItem(T.a.LastSize,e)}},{key:"typedContent",get:function(){return this.content}},{key:"active",set:function(e){this.typedContent.active=e}},{key:"isMobileDefault",set:function(e){this.typedContent.isMobileDefault=e}},{key:"defaultEditor",set:function(e){this.setAppDataItem(T.a.DefaultEditor,e)}},{key:"componentData",set:function(e){this.typedContent.componentData=e}},{key:"package_info",set:function(e){this.typedContent.package_info=e}},{key:"local_url",set:function(e){this.typedContent.local_url=e}},{key:"hosted_url",set:function(e){this.typedContent.hosted_url=e}},{key:"valid_until",set:function(e){this.typedContent.valid_until=e}},{key:"permissions",set:function(e){this.typedContent.permissions=e}}]),n})(T.b),B=(function(e){d(n,N);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).area=L.ComponentArea.Themes,e}return y(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"getMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDomainValue(T.a.NotAvailableOnMobile)}},{key:"isMobileActive",value:function(){return this.getAppDomainValue(T.a.MobileActive)}}]),n})(),W=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setMobileRules",value:function(e){this.setAppDataItem(T.a.MobileRules,e)}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem(T.a.NotAvailableOnMobile,e)}},{key:"setMobileActive",value:function(e){this.setAppDataItem(T.a.MobileActive,e)}},{key:"local_url",set:function(e){this.content.local_url=e}}]),n})(T.b),H=n(21);!(function(e){e.TagsPanelWidth="tagsPanelWidth",e.NotesPanelWidth="notesPanelWidth",e.EditorWidth="editorWidth",e.EditorLeft="editorLeft",e.EditorMonospaceEnabled="monospaceFont",e.EditorSpellcheck="spellcheck",e.EditorResizersEnabled="marginResizersEnabled",e.SortNotesBy="sortBy",e.SortNotesReverse="sortReverse",e.NotesShowArchived="showArchived",e.NotesShowTrashed="showTrashed",e.NotesHideProtected="hideProtected",e.NotesHidePinned="hidePinned",e.NotesHideNotePreview="hideNotePreview",e.NotesHideDate="hideDate",e.NotesHideTags="hideTags"})(U||(U={}));var z=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getPref",value:function(e){return this.getAppDomainValue(e)}},{key:"isSingleton",get:function(){return!0}},{key:"singletonPredicate",get:function(){return n.singletonPredicate}}]),n})(T.d);z.singletonPredicate=new H.a('content_type','=',F.a.UserPrefs);var q,Y,G=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setPref",value:function(e,t){this.setAppDataItem(e,t)}}]),n})(T.b),Q=n(6),J=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"keyVersion",get:function(){return this.payload.safeContent.version}},{key:"isItemsKey",get:function(){return!0}},{key:"isDefault",get:function(){return this.payload.safeContent.isDefault}},{key:"itemsKey",get:function(){return this.payload.safeContent.itemsKey}},{key:"dataAuthenticationKey",get:function(){if(this.keyVersion===Q.a.V004)throw'Attempting to access legacy data authentication key.';return this.payload.safeContent.dataAuthenticationKey}}]),n})(T.d),$=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"isDefault",set:function(e){this.content.isDefault=e}}]),n})(T.b),X=n(47),Z=n.n(X);!(function(e){e.Encrypted="encrypted",e.Decrypted="decrypted"})(q||(q={})),(function(e){e.Get="get",e.Render="render",e.Show="show",e.Post="post",e.Nested="nested"})(Y||(Y={}));var ee=Number.MIN_SAFE_INTEGER;var te,ne,re,ae=function e(t){var n,r,a;v(this,e),this.id=((ee+=1)===Number.MAX_SAFE_INTEGER&&(ee=Number.MIN_SAFE_INTEGER),ee),Z()(this,t),this.running=null!==(n=t.running)&&void 0!==n&&n,this.error=null!==(r=t.error)&&void 0!==r&&r,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted)),this.subactions=null===(a=t.subactions)||void 0===a?void 0:a.map(function(t){return new e(t)})},ie=(function(e){d(n,N);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).actions=[],r.description=e.safeContent.description,r.url=e.safeContent.hosted_url||e.safeContent.url,r.supported_types=e.safeContent.supported_types,r.deprecation=e.safeContent.deprecation,e.safeContent.actions&&(r.actions=e.safeContent.actions.map(function(e){return new ae(e)})),r}return y(n,[{key:"actionsWithContextForItem",value:function(e){return this.actions.filter(function(t){return t.context===e.content_type||'Item'===t.context})}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}}]),n})(),se=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"description",set:function(e){this.content.description=e}},{key:"supported_types",set:function(e){this.content.supported_types=e}},{key:"actions",set:function(e){this.content.actions=e}},{key:"deprecation",set:function(e){this.content.deprecation=e}}]),n})(T.b),oe=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).title=r.payload.safeContent.title,r}return y(n,[{key:"noteReferences",get:function(){return this.payload.safeReferences.filter(function(e){return e.content_type===F.a.Note})}},{key:"noteCount",get:function(){return this.noteReferences.length}},{key:"isSmartTag",get:function(){return this.content_type===F.a.SmartTag}},{key:"isSystemSmartTag",get:function(){return this.payload.safeContent.isSystemTag}},{key:"isAllTag",get:function(){return this.payload.safeContent.isAllTag}},{key:"isTrashTag",get:function(){return this.payload.safeContent.isTrashTag}},{key:"isArchiveTag",get:function(){return this.payload.safeContent.isArchiveTag}},{key:"parentId",get:function(){var e=this.payload.safeContent.references.find(function(e){return e.content_type===F.a.Tag});return null===e||void 0===e?void 0:e.uuid}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title?1:-1}).map(function(e){return'#'+e.title}).join(' ')}}]),n})(T.d),ce=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"makeChildOf",value:function(e){var t=this.typedContent.references.filter(function(e){return e.content_type!==F.a.Tag});t.push({content_type:F.a.Tag,uuid:e.uuid}),this.typedContent.references=t}},{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}}]),n})(T.b),ue=n(12),le=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).text='',r.hidePreview=!1,r.title=r.payload.safeContent.title,r.text=r.payload.safeContent.text,r.preview_plain=r.payload.safeContent.preview_plain,r.preview_html=r.payload.safeContent.preview_html,r.hidePreview=r.payload.safeContent.hidePreview,e.format===ue.a.DecryptedBareObject&&(r.prefersPlainEditor=r.getAppDomainValue(T.a.PrefersPlainEditor)),Object(_.w)(r.payload.safeContent.mobilePrefersPlainEditor)||(r.mobilePrefersPlainEditor=r.payload.safeContent.mobilePrefersPlainEditor),r}return y(n,[{key:"safeText",value:function(){return this.text||''}},{key:"safeTitle",value:function(){return this.title||''}}]),n})(T.d),pe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}},{key:"text",set:function(e){this.typedContent.text=e}},{key:"hidePreview",set:function(e){this.typedContent.hidePreview=e}},{key:"preview_plain",set:function(e){this.typedContent.preview_plain=e}},{key:"preview_html",set:function(e){this.typedContent.preview_html=e}},{key:"prefersPlainEditor",set:function(e){this.setAppDataItem(T.a.PrefersPlainEditor,e)}}]),n})(T.b);function de(e,t){switch(e.content_type){case F.a.Note:return new pe(e,t);case F.a.Tag:return new ce(e,t);case F.a.Component:return new V(e,t);case F.a.ActionsExtension:return new se(e,t);case F.a.ItemsKey:return new $(e,t);case F.a.UserPrefs:return new G(e,t);case F.a.Theme:return new W(e,t);default:return new T.b(e,t)}}!(function(e){e[e.None=0]="None",e[e.LocalPasscode=1]="LocalPasscode",e[e.AccountPassword=2]="AccountPassword",e[e.Biometric=3]="Biometric",e[e.ProtectionSessionDuration=4]="ProtectionSessionDuration"})(te||(te={})),(function(e){e[e.ApplicationUnlock=1]="ApplicationUnlock",e[e.ResaveRootKey=2]="ResaveRootKey",e[e.ProtocolUpgrade=3]="ProtocolUpgrade",e[e.Migration=4]="Migration",e[e.Custom=5]="Custom",e[e.AccessProtectedNote=6]="AccessProtectedNote",e[e.ImportFile=7]="ImportFile",e[e.AddPasscode=8]="AddPasscode",e[e.RemovePasscode=9]="RemovePasscode",e[e.ChangePasscode=10]="ChangePasscode",e[e.ChangeAutolockInterval=11]="ChangeAutolockInterval",e[e.CreateDecryptedBackupWithProtectedItems=12]="CreateDecryptedBackupWithProtectedItems",e[e.RevokeSession=13]="RevokeSession",e[e.AccessCloudLink=14]="AccessCloudLink",e[e.DecryptEncryptedFile=15]="DecryptEncryptedFile",e[e.ExportBackup=16]="ExportBackup",e[e.DisableBiometrics=17]="DisableBiometrics",e[e.UnprotectNote=18]="UnprotectNote",e[e.SearchProtectedNotesText=19]="SearchProtectedNotesText",e[e.SelectProtectedNote=20]="SelectProtectedNote",e[e.DisableMfa=21]="DisableMfa"})(ne||(ne={})),(function(e){e.Alphanumeric="default",e.Numeric="numeric"})(re||(re={}));var he,fe,ve,ye=(function(){function e(t,n,r,a,i){v(this,e),this.prompts=t,this.reason=n,this.cancelable=r,this._heading=a,this._subheading=i,this.id=Math.random(),Object.freeze(this)}return y(e,[{key:"hasPromptForValidationType",value:function(e){for(var t,n=S(this.prompts);!(t=n()).done;){if(t.value.validation===e)return!0}return!1}},{key:"modalTitle",get:function(){switch(this.reason){case ne.Migration:return j.w.Migration;default:return j.w.Generic}}},{key:"heading",get:function(){if(this._heading)return this._heading;switch(this.reason){case ne.ApplicationUnlock:return j.x.UnlockApplication;case ne.Migration:return j.x.EnterLocalPasscode;case ne.ResaveRootKey:return j.x.EnterPasscodeForRootResave;case ne.ProtocolUpgrade:return j.x.EnterCredentialsForProtocolUpgrade;case ne.AccessProtectedNote:return j.x.NoteAccess;case ne.ImportFile:return j.x.ImportFile;case ne.AddPasscode:return j.x.AddPasscode;case ne.RemovePasscode:return j.x.RemovePasscode;case ne.ChangePasscode:return j.x.ChangePasscode;case ne.ChangeAutolockInterval:return j.x.ChangeAutolockInterval;case ne.CreateDecryptedBackupWithProtectedItems:return j.x.EnterCredentialsForDecryptedBackupDownload;case ne.RevokeSession:return j.x.RevokeSession;case ne.AccessCloudLink:return j.x.AccessCloudLink;case ne.DecryptEncryptedFile:return j.x.DecryptEncryptedFile;case ne.ExportBackup:return j.x.ExportBackup;case ne.DisableBiometrics:return j.x.DisableBiometrics;case ne.UnprotectNote:return j.x.UnprotectNote;case ne.SearchProtectedNotesText:return j.x.SearchProtectedNotesText;case ne.SelectProtectedNote:return j.x.SelectProtectedNote;case ne.DisableMfa:return j.x.DisableMfa;case ne.Custom:return'';default:return Object(_.f)(this.reason)}}},{key:"subheading",get:function(){if(this._subheading)return this._subheading;switch(this.reason){case ne.Migration:return j.x.EnterPasscodeForMigration;default:return}}}]),e})(),ge=function e(t,n,r){v(this,e);var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;switch(this.validation=t,this.secureTextEntry=a,this.keyboardType=i,this.initialValue=s,this.id=Math.random(),this.validation){case te.AccountPassword:this.title=null!==n&&void 0!==n?n:j.M.AccountPassword,this.placeholder=null!==r&&void 0!==r?r:j.M.AccountPassword,this.validates=!0;break;case te.LocalPasscode:this.title=null!==n&&void 0!==n?n:j.M.LocalPasscode,this.placeholder=null!==r&&void 0!==r?r:j.M.LocalPasscode,this.validates=!0;break;case te.Biometric:this.title=null!==n&&void 0!==n?n:j.M.Biometrics,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.ProtectionSessionDuration:this.title=null!==n&&void 0!==n?n:j.M.RememberFor,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.None:this.title=null!==n&&void 0!==n?n:'',this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!1;break;default:Object(_.f)(this.validation)}Object.freeze(this)},me=function e(t,n){v(this,e),this.prompt=t,this.value=n,Object.freeze(this)},be=(function(){function e(t,n,r){v(this,e),this.challenge=t,this.values=n,this.artifacts=r,Object.freeze(this)}return y(e,[{key:"getValueForType",value:function(e){var t=this.values.find(function(t){return t.prompt.validation===e});if(Object(_.w)(t))throw Error('Could not find value for validation type '+e);return t}},{key:"getDefaultValue",value:function(){if(this.values.length>1)throw Error('Attempting to retrieve default response value when more than one value exists');return this.values[0]}}]),e})(),we=n(16);function ke(e){return{'mac-web':fe.MacWeb,'mac-desktop':fe.MacDesktop,'linux-web':fe.LinuxWeb,'linux-desktop':fe.LinuxDesktop,'windows-web':fe.WindowsWeb,'windows-desktop':fe.WindowsDesktop,ios:fe.Ios,android:fe.Android}[e]}function xe(e){return{web:he.Web,desktop:he.Desktop,mobile:he.Mobile}[e]}function Se(e){return e===he.Web||e===he.Desktop}function Pe(e){return e===he.Mobile}!(function(e){e[e.Web=1]="Web",e[e.Desktop=2]="Desktop",e[e.Mobile=3]="Mobile"})(he||(he={})),(function(e){e[e.Ios=1]="Ios",e[e.Android=2]="Android",e[e.MacWeb=3]="MacWeb",e[e.MacDesktop=4]="MacDesktop",e[e.WindowsWeb=5]="WindowsWeb",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.LinuxWeb=7]="LinuxWeb",e[e.LinuxDesktop=8]="LinuxDesktop"})(fe||(fe={})),(function(e){e[e.PreparingForLaunch_0=0]="PreparingForLaunch_0",e[e.ReadyForLaunch_05=.5]="ReadyForLaunch_05",e[e.StorageDecrypted_09=.9]="StorageDecrypted_09",e[e.Launched_10=1]="Launched_10",e[e.LoadingDatabase_11=1.1]="LoadingDatabase_11",e[e.LoadedDatabase_12=1.2]="LoadedDatabase_12",e[e.FullSyncCompleted_13=1.3]="FullSyncCompleted_13",e[e.SignedIn_30=3]="SignedIn_30"})(ve||(ve={}));var Oe,Ce,De,_e,Ee=n(1),Re=n(8);!(function(e){e[e.Default=1]="Default",e[e.Ephemeral=2]="Ephemeral"})(Oe||(Oe={})),(function(e){e[e.Default=1]="Default",e[e.Disabled=2]="Disabled"})(Ce||(Ce={})),(function(e){e[e.Default=1]="Default",e[e.Nonwrapped=2]="Nonwrapped"})(De||(De={})),(function(e){e.Wrapped="wrapped",e.Unwrapped="unwrapped",e.Nonwrapped="nonwrapped"})(_e||(_e={}));var Ie=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).alertService=r,s.identifier=a,s.environment=i,s.storagePersistable=!1,s.needsPersist=!1,s.deviceInterface=e,s.setPersistencePolicy(Oe.Default),s.setEncryptionPolicy(Ce.Default,!1),s}return y(n,[{key:"deinit",value:function(){this.deviceInterface=void 0,this.encryptionDelegate=void 0,this.storagePersistable=!1,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:if(e!==ve.Launched_10){r.next=7;break}this.storagePersistable=!0,this.needsPersist&&this.persistValuesToDisk(),r.next=12;break;case 7:if(e!==ve.StorageDecrypted_09){r.next=12;break}return r.next=10,b.awrap(this.getValue(o.StorageEncryptionPolicy));case 10:(t=r.sent)&&this.setEncryptionPolicy(t,!1);case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setPersistencePolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.persistencePolicy=e,this.persistencePolicy!==Oe.Ephemeral){t.next=6;break}return t.next=4,b.awrap(this.deviceInterface.removeAllRawStorageValues());case 4:return t.next=6,b.awrap(this.clearAllPayloads());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setEncryptionPolicy",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],e!==Ce.Disabled||this.environment===he.Mobile){r.next=3;break}throw Error('Disabling storage encryption is only available on mobile.');case 3:if(this.encryptionPolicy=e,!t){r.next=7;break}return r.next=7,b.awrap(this.setValue(o.StorageEncryptionPolicy,e));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.persistencePolicy===Oe.Ephemeral}},{key:"initializeFromDisk",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getRawStorageValue(this.getPersistenceKey()));case 2:e=n.sent,t=e?JSON.parse(e):void 0,this.setInitialValues(t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){e||(e=this.defaultValuesObject()),e[_e.Unwrapped]||(e[_e.Unwrapped]={}),this.values=e}},{key:"isStorageWrapped",value:function(){var e=this.values[_e.Wrapped];return!Object(_.w)(e)&&Object.keys(e).length>0}},{key:"canDecryptWithKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.values[_e.Wrapped],r.next=3,b.awrap(this.decryptWrappedValue(t,e));case 3:return n=r.sent,r.abrupt("return",!n.errorDecrypting);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"decryptWrappedValue",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!==e&&void 0!==e&&e.content_type){a.next=2;break}throw Error('Attempting to decrypt nonexistent wrapped value');case 2:return n=Object(Ee.e)(e,{content_type:F.a.EncryptedStorage}),a.next=5,b.awrap(this.encryptionDelegate.payloadByDecryptingPayload(n,t));case 5:return r=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptStorage",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.values[_e.Wrapped],n.next=3,b.awrap(this.decryptWrappedValue(e));case 3:if(!(t=n.sent).errorDecrypting){n.next=6;break}throw we.a.error(Error('Unable to decrypt storage.'));case 6:this.values[_e.Unwrapped]=Object(_.a)(t.contentObject);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistValuesToDisk",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.storagePersistable){t.next=3;break}return this.needsPersist=!0,t.abrupt("return");case 3:if(this.persistencePolicy!==Oe.Ephemeral){t.next=5;break}return t.abrupt("return");case 5:return this.needsPersist=!1,t.next=8,b.awrap(this.immediatelyPersistValuesToDisk());case 8:e=t.sent,this.values[_e.Wrapped]=e[_e.Wrapped];case 10:case"end":return t.stop()}},null,this,null,Promise)}},{key:"immediatelyPersistValuesToDisk",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(e.generatePersistableValues());case 2:return n=r.sent,r.next=5,b.awrap(null===(t=e.deviceInterface)||void 0===t?void 0:t.setRawStorageValue(e.getPersistenceKey(),JSON.stringify(n)));case 5:return r.abrupt("return",n);case 6:case"end":return r.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generatePersistableValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=w({},this.values),n=t[_e.Unwrapped],i.t0=Object(Ee.e),i.next=5,b.awrap(I.GenerateUuid());case 5:return i.t1=i.sent,i.t2=n,i.t3=F.a.EncryptedStorage,i.t4={uuid:i.t1,content:i.t2,content_type:i.t3},r=(0,i.t0)(i.t4),i.next=12,b.awrap(null===(e=this.encryptionDelegate)||void 0===e?void 0:e.payloadByEncryptingPayload(r,Re.b.LocalStoragePreferEncrypted));case 12:return(a=i.sent)&&(t[_e.Wrapped]=a.ejected(),t[_e.Unwrapped]=void 0),i.abrupt("return",t);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=r.length>2&&void 0!==r[2]?r[2]:De.Default,this.values){a.next=3;break}throw Error("Attempting to set storage key ".concat(e," before loading local storage."));case 3:return this.values[this.domainKeyForMode(n)][e]=t,a.abrupt("return",this.persistValuesToDisk());case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De.Default,n=arguments.length>2?arguments[2]:void 0;if(!this.values)throw Error("Attempting to get storage key ".concat(e," before loading local storage."));if(!this.values[this.domainKeyForMode(t)])throw Error("Storage domain mode not available ".concat(t," for key ").concat(e));var r=this.values[this.domainKeyForMode(t)][e];return Object(_.w)(r)?n:r}},{key:"removeValue",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:De.Default,this.values){a.next=3;break}throw Error("Attempting to remove storage key ".concat(e," before loading local storage."));case 3:if(null===(n=this.values[this.domainKeyForMode(t)])||void 0===n||!n[e]){a.next=7;break}return delete n[e],a.abrupt("return",this.persistValuesToDisk());case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.encryptionPolicy}},{key:"getPersistenceKey",value:function(){return O(this.identifier,s.StorageObject)}},{key:"defaultValuesObject",value:function(e,t,r){return n.defaultValuesObject(e,t,r)}},{key:"domainKeyForMode",value:function(e){if(e===De.Default)return _e.Unwrapped;if(e===De.Nonwrapped)return _e.Nonwrapped;throw Error('Invalid mode')}},{key:"clearValues",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,b.awrap(this.immediatelyPersistValuesToDisk());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAllRawPayloads",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads(this.identifier));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"savePayload",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.savePayloads([e]));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"savePayloads",value:function(e){var t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.persistencePolicy!==Oe.Ephemeral){o.next=2;break}return o.abrupt("return");case 2:t=[],n=S(e);case 4:if((r=n()).done){o.next=19;break}if(!(a=r.value).discardable){o.next=11;break}return o.next=9,b.awrap(this.deletePayloadWithId(a.uuid));case 9:o.next=17;break;case 11:if(a.uuid){o.next=13;break}throw Error('Attempting to persist payload with no uuid');case 13:return o.next=15,b.awrap(this.encryptionDelegate.payloadByEncryptingPayload(a,this.encryptionPolicy===Ce.Default?Re.b.LocalStoragePreferEncrypted:Re.b.LocalStorageDecrypted));case 15:i=o.sent,t.push(i.ejected());case 17:o.next=4;break;case 19:return o.abrupt("return",this.executeCriticalFunction(function(){var e;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null===(e=s.deviceInterface)||void 0===e?void 0:e.saveRawDatabasePayloads(t,s.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 20:case"end":return o.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(e);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(this.deletePayloadWithId(r.uuid));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deletePayloadWithId",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.deviceInterface.removeRawDatabasePayloadWithId(e,t.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"clearAllPayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.deviceInterface.removeAllRawDatabasePayloads(e.identifier));case 1:case"end":return t.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"clearAllData",value:function(){var e=this;return this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.clearValues());case 2:return t.next=4,b.awrap(e.clearAllPayloads());case 4:return t.next=6,b.awrap(e.deviceInterface.removeRawStorageValue(O(e.identifier,s.SnjsVersion)));case 6:return t.next=8,b.awrap(e.deviceInterface.removeRawStorageValue(e.getPersistenceKey()));case 8:case"end":return t.stop()}},null,null,null,Promise)})}}],[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return g(e={},_e.Wrapped,t),g(e,_e.Unwrapped,n),g(e,_e.Nonwrapped,r),e}}]),n})(R.a),Me=(function(){function e(){v(this,e)}return y(e,null,[{key:"FromRawStorageValue",value:function(e){if(e.jwt)return new Ae(e.jwt);var t=e;return new je(t.accessToken,t.accessExpiration,t.refreshToken,t.refreshExpiration)}}]),e})(),Ae=(function(e){d(n,Me);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).jwt=e,r}return y(n,[{key:"canExpire",value:function(){return!1}},{key:"authorizationValue",get:function(){return this.jwt}}]),n})(),je=(function(e){d(n,Me);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).accessToken=e,s.accessExpiration=r,s.refreshToken=a,s.refreshExpiration=i,s}return y(n,[{key:"getExpireAt",value:function(){return this.accessExpiration||0}},{key:"canExpire",value:function(){return!0}},{key:"isExpired",value:function(){return this.getExpireAt()<Date.now()}},{key:"authorizationValue",get:function(){return this.accessToken}}],[{key:"FromApiResponse",value:function(e){var t=e.data.session.access_token,r=e.data.session.refresh_token;return new n(t,e.data.session.access_expiration,r,e.data.session.refresh_expiration)}}]),n})(),Te=n(15),Ke=n(11),Fe=n(67);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this,e)).keyParams=r,a}return y(n,[{key:"compare",value:function(e){if(this.keyVersion!==e.keyVersion)return!1;var t=!(!this.serverPassword||!e.serverPassword);return Object(Fe.timingSafeEqual)(this.masterKey,e.masterKey)&&(!t||Object(Fe.timingSafeEqual)(this.serverPassword,e.serverPassword))}},{key:"persistableValueWhenWrapping",value:function(){var e=this.getKeychainValue();return e.keyParams=this.keyParams.getPortableValue(),e}},{key:"getKeychainValue",value:function(){var e={version:this.keyVersion};return this.masterKey&&(e.masterKey=this.masterKey),this.dataAuthenticationKey&&(e.dataAuthenticationKey=this.dataAuthenticationKey),e}},{key:"typedContent",get:function(){return this.safeContent}},{key:"keyVersion",get:function(){if(!this.payload.safeContent.version)throw'Attempting to create key without version.';return this.payload.safeContent.version}},{key:"isRootKey",get:function(){return!0}},{key:"itemsKey",get:function(){return this.masterKey}},{key:"masterKey",get:function(){return this.payload.safeContent.masterKey}},{key:"serverPassword",get:function(){return this.payload.safeContent.serverPassword}},{key:"dataAuthenticationKey",get:function(){return this.payload.safeContent.dataAuthenticationKey}}],[{key:"Create",value:function(e,t){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t){s.next=4;break}return s.next=3,b.awrap(I.GenerateUuid());case 3:t=s.sent;case 4:if(e.version||(e.dataAuthenticationKey?e.version=Q.a.V002:e.version=Q.a.V001),r=Object(Ee.e)({uuid:t,content_type:F.a.RootKey,content:Object(Ke.a)(e)}),a=e.keyParams){s.next=9;break}throw Error('Attempting to create root key without key params');case 9:return i=a instanceof A.h?a:new A.h(a),s.abrupt("return",new n(r,i));case 11:case"end":return s.stop()}},null,null,null,Promise)}},{key:"ExpandedCopy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=e.typedContent,a.next=3,b.awrap(this.Create(Ue(Ue({},n),{},{keyParams:t||n.keyParams})));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(T.d);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){He(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ze,qe=function(e){return e.trim().toLowerCase()};!(function(e){e.Restored="SessionRestored",e.Revoked="SessionRevoked"})(ze||(ze={}));var Ye,Ge=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).storageService=e,c.apiService=r,c.alertService=a,c.protocolService=i,c.challengeService=s,c.webSocketsService=o,c.isSessionRenewChallengePresented=!1,r.setInvalidSessionObserver(function(e){e?c.notifyEvent(ze.Revoked):c.reauthenticateInvalidSession()}),c}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.alertService=void 0,this.challengeService=void 0,this.webSocketsService=void 0,this.user=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.storageService.getValue(o.User));case 2:if(this.user=r.sent,this.user){r.next=8;break}return r.next=6,b.awrap(this.storageService.getValue(o.LegacyUuid));case 6:(e=r.sent)&&(this.user={uuid:e,email:e});case 8:return r.next=10,b.awrap(this.storageService.getValue(o.Session));case 10:if(!(t=r.sent)){r.next=16;break}return n=Me.FromRawStorageValue(t),r.next=15,b.awrap(this.setSession(n,!1));case 15:this.webSocketsService.startWebSocketConnection(n.authorizationValue);case 16:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=!(n.length>1&&void 0!==n[1])||n[1],r.next=3,b.awrap(this.apiService.setSession(e,t));case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"online",value:function(){return!this.offline()}},{key:"offline",value:function(){return Object(_.w)(this.apiService.getSession())}},{key:"getUser",value:function(){return this.user}},{key:"getSession",value:function(){return this.apiService.getSession()}},{key:"signOut",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.user=void 0,!(e=this.apiService.getSession())||!e.canExpire()){t.next=6;break}return t.next=5,b.awrap(this.apiService.signOut());case 5:this.webSocketsService.closeWebSocketConnection();case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isSignedIn",value:function(){return void 0!=this.getUser()}},{key:"isSignedIntoFirstPartyServer",value:function(){return this.isSignedIn()&&!this.apiService.isThirdPartyHostUsed()}},{key:"reauthenticateInvalidSession",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=!(i.length>0&&void 0!==i[0])||i[0],n=i.length>1?i[1]:void 0,!this.isSessionRenewChallengePresented){s.next=4;break}return s.abrupt("return");case 4:return this.isSessionRenewChallengePresented=!0,r=new ye([new ge(te.None,void 0,j.R.EmailInputPlaceholder,!1),new ge(te.None,void 0,j.R.PasswordInputPlaceholder)],ne.Custom,t,j.R.EnterEmailAndPassword,j.R.RecoverSession(null===(e=this.getUser())||void 0===e?void 0:e.email)),s.abrupt("return",new Promise(function(e){a.challengeService.addChallengeObserver(r,{onCancel:function(){a.isSessionRenewChallengePresented=!1},onComplete:function(){a.isSessionRenewChallengePresented=!1},onNonvalidatedSubmit:function(t){var i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=t.values[0].value,s=t.values[1].value,u.next=4,b.awrap(a.protocolService.getAccountKeyParams());case 4:return o=u.sent,u.next=7,b.awrap(a.signIn(i,s,!1,a.storageService.isEphemeralSession(),null===o||void 0===o?void 0:o.version));case 7:(c=u.sent).response.error?(a.challengeService.setValidationStatusForChallenge(r,t.values[1],!1),null===n||void 0===n||n(c.response)):(e(),a.challengeService.completeChallenge(r),a.notifyEvent(ze.Restored),a.alertService.alert(j.R.SessionRestored));case 9:case"end":return u.stop()}},null,null,null,Promise)}}),a.challengeService.promptForChallengeResponse(r)}));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSubscription",value:function(){return this.apiService.getSubscription(this.user.uuid)}},{key:"promptForMfaValue",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=new ye([new ge(te.None,j.M.Mfa,j.R.MfaInputPlaceholder,!1,re.Numeric)],ne.Custom,!0,j.R.EnterMfa),n.next=3,b.awrap(this.challengeService.promptForChallengeResponse(e));case 3:if(!(t=n.sent)){n.next=7;break}return this.challengeService.completeChallenge(e),n.abrupt("return",t.values[0].value);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"register",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(t.length<8)){u.next=2;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.G(8))});case 2:return u.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(r=u.sent,a=r.wrappingKey,!r.canceled){u.next=9;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.P.PasscodeRequired,Te.b.LocalValidationError)});case 9:return e=qe(e),u.next=12,b.awrap(this.protocolService.createRootKey(e,t,A.g.Registration));case 12:return i=u.sent,s=i.serverPassword,o=i.keyParams,u.next=17,b.awrap(this.apiService.register(e,s,o,n));case 17:if((c=u.sent).error||!c.data){u.next=21;break}return u.next=21,b.awrap(this.handleSuccessAuthResponse(c,i,a));case 21:return u.abrupt("return",{response:c,rootKey:i});case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"retrieveKeyParams",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.apiService.getAccountKeyParams(e,t,n));case 2:if(!(r=c.sent).error&&!Object(_.w)(r.data)){c.next=17;break}if(!n){c.next=7;break}return c.next=7,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 7:if(null===(a=r.error)||void 0===a||null===(i=a.payload)||void 0===i||!i.mfa_key){c.next=16;break}return c.next=10,b.awrap(this.promptForMfaValue());case 10:if(s=c.sent){c.next=13;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa)});case 13:return c.abrupt("return",this.retrieveKeyParams(e,r.error.payload.mfa_key,s));case 16:return c.abrupt("return",{response:r});case 17:if((o=Object(A.f)(r,e))&&o.version){c.next=20;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 20:return c.abrupt("return",{keyParams:o,response:r,mfaKeyPath:t,mfaCode:n});case 21:case"end":return c.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=o.length>2&&void 0!==o[2]&&o[2],r=o.length>3&&void 0!==o[3]&&o[3],a=o.length>4?o[4]:void 0,c.next=5,b.awrap(this.performSignIn(e,t,n,r,a));case 5:if(!(i=c.sent).response.error||i.response.error.status===Te.b.LocalValidationError||i.response.error.status===Te.b.CanceledMfa){c.next=15;break}if((s=qe(e))===e){c.next=12;break}return c.abrupt("return",this.performSignIn(s,t,n,r,a));case 12:return c.abrupt("return",i);case 13:c.next=16;break;case 15:return c.abrupt("return",i);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"performSignIn",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=arguments;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return n=p.length>2&&void 0!==p[2]&&p[2],r=p.length>3&&void 0!==p[3]&&p[3],a=p.length>4?p[4]:void 0,d.next=5,b.awrap(this.retrieveKeyParams(e));case 5:if(!(i=d.sent).response.error){d.next=8;break}return d.abrupt("return",{response:i.response});case 8:if(s=i.keyParams,this.protocolService.supportedVersions().includes(s.version)){d.next=15;break}if(!this.protocolService.isVersionNewerThanLibraryVersion(s.version)){d.next=14;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.X)});case 14:return d.abrupt("return",{response:this.apiService.createErrorResponse(j.A)});case 15:if(!this.protocolService.isProtocolVersionOutdated(s.version)){d.next=25;break}if(o=this.protocolService.costMinimumForVersion(s.version),!(s.content002.pw_cost<o)){d.next=19;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.E)});case 19:return c=j.L,d.next=22,b.awrap(this.alertService.confirm(c,j.K,j.J));case 22:if(d.sent){d.next=25;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 25:if(this.protocolService.platformSupportsKeyDerivation(s)){d.next=27;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.W)});case 27:if(n&&(a=this.protocolService.getLatestVersion()),Object(_.w)(a)){d.next=31;break}if(Object(Q.d)(s.version,a)){d.next=31;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.T(s.version,a))});case 31:return d.next=33,b.awrap(this.protocolService.computeRootKey(t,s));case 33:return u=d.sent,d.next=36,b.awrap(this.bypassChecksAndSignInWithRootKey(e,u,i.mfaKeyPath,i.mfaCode,r));case 36:return l=d.sent,d.abrupt("return",{response:l});case 38:case"end":return d.stop()}},null,this,null,Promise)}},{key:"bypassChecksAndSignInWithRootKey",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return a=d.length>4&&void 0!==d[4]&&d[4],h.next=3,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 3:if(i=h.sent,s=i.wrappingKey,!i.canceled){h.next=8;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.PasscodeRequired,Te.b.LocalValidationError));case 8:return h.next=10,b.awrap(this.apiService.signIn(e,t.serverPassword,n,r,a));case 10:if((o=h.sent).error||!o.data){h.next=20;break}return h.next=14,b.awrap(Ve.ExpandedCopy(t,o.data.key_params));case 14:return c=h.sent,h.next=17,b.awrap(this.handleSuccessAuthResponse(o,c,s));case 17:return h.abrupt("return",o);case 20:if(null===(u=o.error)||void 0===u||null===(l=u.payload)||void 0===l||!l.mfa_key){h.next=32;break}if(!r){h.next=24;break}return h.next=24,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 24:return h.next=26,b.awrap(this.promptForMfaValue());case 26:if(p=h.sent){h.next=29;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa));case 29:return h.abrupt("return",this.bypassChecksAndSignInWithRootKey(e,t,o.error.payload.mfa_key,p));case 32:return h.abrupt("return",o);case 33:case"end":return h.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.user.uuid,r.next=3,b.awrap(this.apiService.changeCredentials({userUuid:t,currentServerPassword:e.currentServerPassword,newServerPassword:e.newRootKey.serverPassword,newKeyParams:e.newRootKey.keyParams,newEmail:e.newEmail}));case 3:return n=r.sent,r.abrupt("return",this.processChangeCredentialsResponse(n,e.newRootKey,e.wrappingKey));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getSessionsList());case 2:if(!(e=t.sent).error&&!Object(_.w)(e.data)){t.next=5;break}return t.abrupt("return",e);case 5:return e.data=e.data.map(function(e){return We(We({},e),{},{updated_at:new Date(e.updated_at)})}).sort(function(e,t){return e.updated_at<t.updated_at?1:-1}),t.abrupt("return",e);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeSession",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.deleteSession(e));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.getSessionsList());case 2:if(void 0==(e=s.sent).error&&void 0!=e.data){s.next=5;break}throw new Error(null!==(t=null===(n=e.error)||void 0===n?void 0:n.message)&&void 0!==t?t:j.m);case 5:return r=e.data,a=r.filter(function(e){return!e.current}),s.next=9,b.awrap(Promise.all(a.map(function(e){return i.revokeSession(e.uuid)})));case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"processChangeCredentialsResponse",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.error||!e.data){a.next=3;break}return a.next=3,b.awrap(this.handleSuccessAuthResponse(e,t,n));case 3:return a.abrupt("return",{response:e,keyParams:null===(r=e.data)||void 0===r?void 0:r.key_params});case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleSuccessAuthResponse",value:function(e,t,n){var r,a,i,s;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.protocolService.setRootKey(t,n));case 2:return r=e.data,a=r.user,this.user=a,c.next=7,b.awrap(this.storageService.setValue(o.User,a));case 7:if(this.apiService.setHost(this.apiService.getHost()),!r.token){c.next=15;break}return i=new Ae(r.token),c.next=12,b.awrap(this.setSession(i));case 12:this.webSocketsService.startWebSocketConnection(i.authorizationValue),c.next=20;break;case 15:if(!r.session){c.next=20;break}return s=je.FromApiResponse(e),c.next=19,b.awrap(this.setSession(s));case 19:this.webSocketsService.startWebSocketConnection(s.authorizationValue);case 20:case"end":return c.stop()}},null,this,null,Promise)}}]),n})(R.a);!(function(e){e.SignedInOrRegistered="SignedInOrRegistered"})(Ye||(Ye={}));var Qe=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).sessionManager=e,l.syncService=r,l.storageService=a,l.itemManager=i,l.protocolService=s,l.alertService=o,l.challengeService=c,l.protectionService=u,l.signingIn=!1,l.registering=!1,l}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.sessionManager=void 0,this.syncService=void 0,this.storageService=void 0,this.itemManager=void 0,this.protocolService=void 0,this.alertService=void 0,this.challengeService=void 0,this.protectionService=void 0}},{key:"register",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=!(i.length>3&&void 0!==i[3])||i[3],!this.protocolService.hasAccount()){s.next=4;break}throw Error('Tried to register when an account already exists.');case 4:if(!this.registering){s.next=6;break}throw Error('Already registering.');case 6:return this.registering=!0,s.prev=7,this.lockSyncing(),s.next=11,b.awrap(this.sessionManager.register(e,t,n));case 11:if((a=s.sent).response.error){s.next=32;break}return this.syncService.resetSyncState(),s.next=16,b.awrap(this.storageService.setPersistencePolicy(n?Oe.Ephemeral:Oe.Default));case 16:if(!r){s.next=21;break}return s.next=19,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 19:s.next=24;break;case 21:return this.itemManager.removeAllItemsFromMemory(),s.next=24,b.awrap(this.clearDatabase());case 24:return s.next=26,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 26:return this.unlockSyncing(),s.next=29,b.awrap(this.syncService.downloadFirstSync(300));case 29:this.protocolService.decryptErroredItems(),s.next=33;break;case 32:this.unlockSyncing();case 33:return s.abrupt("return",a.response);case 34:return s.prev=34,this.registering=!1,s.finish(34);case 37:case"end":return s.stop()}},null,this,[[7,,34,37]],Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o,c=this,u=arguments;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],r=u.length>3&&void 0!==u[3]&&u[3],a=!(u.length>4&&void 0!==u[4])||u[4],i=u.length>5&&void 0!==u[5]&&u[5],!this.protocolService.hasAccount()){l.next=6;break}throw Error('Tried to sign in when an account already exists.');case 6:if(!this.signingIn){l.next=8;break}throw Error('Already signing in.');case 8:return this.signingIn=!0,l.prev=9,this.lockSyncing(),l.next=13,b.awrap(this.sessionManager.signIn(e,t,n,r));case 13:if((s=l.sent).response.error){l.next=37;break}return this.syncService.resetSyncState(),l.next=18,b.awrap(this.storageService.setPersistencePolicy(r?Oe.Ephemeral:Oe.Default));case 18:if(!a){l.next=23;break}return l.next=21,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 21:l.next=26;break;case 23:return this.itemManager.removeAllItemsFromMemory(),l.next=26,b.awrap(this.clearDatabase());case 26:return l.next=28,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 28:if(this.unlockSyncing(),o=this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0,awaitAll:i}).then(function(){i||c.protocolService.decryptErroredItems()}),!i){l.next=35;break}return l.next=33,b.awrap(o);case 33:return l.next=35,b.awrap(this.protocolService.decryptErroredItems());case 35:l.next=38;break;case 37:this.unlockSyncing();case 38:return l.abrupt("return",s.response);case 39:return l.prev=39,this.signingIn=!1,l.finish(39);case 42:case"end":return l.stop()}},null,this,[[9,,39,42]],Promise)}},{key:"correctiveSignIn",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.lockSyncing(),n.next=3,b.awrap(this.sessionManager.bypassChecksAndSignInWithRootKey(e.keyParams.identifier,e));case 3:if((t=n.sent).error){n.next=10;break}return n.next=7,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 7:this.unlockSyncing(),this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0}),this.protocolService.decryptErroredItems();case 10:return this.unlockSyncing(),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.performCredentialsChange(e));case 2:return(t=n.sent).error&&this.alertService.alert(t.error.message),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.sessionManager.signOut());case 2:return e.next=4,b.awrap(this.protocolService.clearLocalKeyState());case 4:return e.next=6,b.awrap(this.storageService.clearAllData());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performProtocolUpgrade",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return e=this.protocolService.hasPasscode(),t=this.protocolService.hasAccount(),n=[],e&&n.push(new ge(te.LocalPasscode,void 0,j.x.LocalPasscodePlaceholder)),t&&n.push(new ge(te.AccountPassword,void 0,j.x.AccountPasswordPlaceholder)),r=new ye(n,ne.ProtocolUpgrade,!0),p.next=8,b.awrap(this.challengeService.promptForChallengeResponse(r));case 8:if(a=p.sent){p.next=11;break}return p.abrupt("return",{canceled:!0});case 11:return p.next=13,b.awrap(this.alertService.blockingDialog(j.z,j.Y));case 13:if(i=p.sent,p.prev=14,e&&(o=a.getValueForType(te.LocalPasscode),s=o.value),!t){p.next=24;break}return c=a.getValueForType(te.AccountPassword),u=c.value,p.next=21,b.awrap(this.changeCredentials({currentPassword:u,newPassword:u,passcode:s,origination:A.g.ProtocolUpgrade,validateNewPasswordStrength:!1}));case 21:if(null===(l=p.sent)||void 0===l||!l.error){p.next=24;break}return p.abrupt("return",{error:l.error});case 24:if(!e){p.next=29;break}return p.next=27,b.awrap(this.removePasscodeWithoutWarning());case 27:return p.next=29,b.awrap(this.setPasscodeWithoutWarning(s,A.g.ProtocolUpgrade));case 29:return p.abrupt("return",{success:!0});case 32:return p.prev=32,p.t0=p.catch(14),p.abrupt("return",{error:p.t0});case 35:return p.prev=35,i(),p.finish(35);case 38:case"end":return p.stop()}},null,this,[[14,32,35,38]],Promise)}},{key:"addPasscode",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e.length<1)){n.next=2;break}return n.abrupt("return",!1);case 2:return n.next=4,b.awrap(this.protectionService.authorizeAddingPasscode());case 4:if(n.sent){n.next=6;break}return n.abrupt("return",!1);case 6:return n.next=8,b.awrap(this.alertService.blockingDialog(j.z,j.Q));case 8:return t=n.sent,n.prev=9,n.next=12,b.awrap(this.setPasscodeWithoutWarning(e,A.g.PasscodeCreate));case 12:return n.abrupt("return",!0);case 13:return n.prev=13,t(),n.finish(13);case 16:case"end":return n.stop()}},null,this,[[9,,13,16]],Promise)}},{key:"removePasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeRemovingPasscode());case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,b.awrap(this.alertService.blockingDialog(j.z,j.O));case 6:return e=t.sent,t.prev=7,t.next=10,b.awrap(this.removePasscodeWithoutWarning());case 10:return t.abrupt("return",!0);case 11:return t.prev=11,e(),t.finish(11);case 14:case"end":return t.stop()}},null,this,[[7,,11,14]],Promise)}},{key:"changePasscode",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:A.g.PasscodeChange,!(e.length<1)){a.next=3;break}return a.abrupt("return",!1);case 3:return a.next=5,b.awrap(this.protectionService.authorizeChangingPasscode());case 5:if(a.sent){a.next=7;break}return a.abrupt("return",!1);case 7:return a.next=9,b.awrap(this.alertService.blockingDialog(j.z,t===A.g.ProtocolUpgrade?j.N.UpgradingPasscode:j.v));case 9:return n=a.sent,a.prev=10,a.next=13,b.awrap(this.removePasscodeWithoutWarning());case 13:return a.next=15,b.awrap(this.setPasscodeWithoutWarning(e,t));case 15:return a.abrupt("return",!0);case 16:return a.prev=16,n(),a.finish(16);case 19:case"end":return a.stop()}},null,this,[[10,,16,19]],Promise)}},{key:"setPasscodeWithoutWarning",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(I.GenerateUuid());case 2:return n=a.sent,a.next=5,b.awrap(this.protocolService.createRootKey(n,e,t));case 5:return r=a.sent,a.next=8,b.awrap(this.protocolService.setNewRootKeyWrapper(r));case 8:return a.next=10,b.awrap(this.rewriteItemsKeys());case 10:return a.next=12,b.awrap(this.syncService.sync());case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"removePasscodeWithoutWarning",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protocolService.removeRootKeyWrapper());case 2:return e.next=4,b.awrap(this.rewriteItemsKeys());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"rewriteItemsKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.itemsKeys(),t=e.map(function(e){return e.payloadRepresentation()}),n.next=4,b.awrap(this.storageService.deletePayloads(t));case 4:return n.next=6,b.awrap(this.syncService.persistPayloads(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"clearDatabase",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performCredentialsChange",value:function(e){var t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(this.challengeService.getWrappingKeyIfApplicable(e.passcode));case 2:if(t=u.sent,n=t.wrappingKey,!t.canceled){u.next=7;break}return u.abrupt("return",{error:Error(j.y.PasscodeRequired)});case 7:if(void 0===e.newPassword||!e.validateNewPasswordStrength){u.next=10;break}if(!(e.newPassword.length<8)){u.next=10;break}return u.abrupt("return",{error:Error(Object(j.G)(8))});case 10:return u.next=12,b.awrap(this.protocolService.validateAccountPassword(e.currentPassword));case 12:if(u.sent.valid){u.next=15;break}return u.abrupt("return",{error:Error(j.D)});case 15:return r=this.sessionManager.getUser(),a=r.email,u.next=19,b.awrap(this.recomputeRootKeysForCredentialChange({currentPassword:e.currentPassword,currentEmail:a,origination:e.origination,newEmail:e.newEmail,newPassword:e.newPassword}));case 19:return i=u.sent,this.lockSyncing(),u.next=23,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.currentRootKey.serverPassword,newRootKey:i.newRootKey,wrappingKey:n,newEmail:e.newEmail}));case 23:if(s=u.sent,this.unlockSyncing(),s.response.error){u.next=45;break}return u.next=28,b.awrap(this.protocolService.createNewItemsKeyWithRollback());case 28:return o=u.sent,u.next=31,b.awrap(this.protocolService.reencryptItemsKeys());case 31:return u.next=33,b.awrap(this.syncService.sync({awaitAll:!0}));case 33:if(c=this.protocolService.getDefaultItemsKey(),!c.neverSynced){u.next=45;break}return u.next=38,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.newRootKey.serverPassword,newRootKey:i.currentRootKey,wrappingKey:n}));case 38:return u.next=40,b.awrap(this.protocolService.reencryptItemsKeys());case 40:return u.next=42,b.awrap(o());case 42:return u.next=44,b.awrap(this.syncService.sync({awaitAll:!0}));case 44:return u.abrupt("return",{error:Error(j.y.Failed)});case 45:return u.abrupt("return",s.response);case 46:case"end":return u.stop()}},null,this,null,Promise)}},{key:"recomputeRootKeysForCredentialChange",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=b,i.t1=this.protocolService,i.t2=e.currentPassword,i.next=5,b.awrap(this.protocolService.getRootKeyParams());case 5:return i.t3=i.sent,i.t4=i.t1.computeRootKey.call(i.t1,i.t2,i.t3),i.next=9,i.t0.awrap.call(i.t0,i.t4);case 9:return r=i.sent,i.next=12,b.awrap(this.protocolService.createRootKey(null!==(t=e.newEmail)&&void 0!==t?t:e.currentEmail,null!==(n=e.newPassword)&&void 0!==n?n:e.currentPassword,e.origination));case 12:return a=i.sent,i.abrupt("return",{currentRootKey:r,newRootKey:a});case 14:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),Je=n(5),$e=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",get:function(){return this.payload.safeContent.migratedToUserSetting}},{key:"migratedToOfflineEntitlements",get:function(){return this.payload.safeContent.migratedToOfflineEntitlements}},{key:"onlineUrl",get:function(){return this.payload.safeContent.url}},{key:"offlineFeaturesUrl",get:function(){return this.payload.safeContent.offlineFeaturesUrl}},{key:"offlineKey",get:function(){return this.payload.safeContent.offlineKey}}]),n})(T.d),Xe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",set:function(e){this.content.migratedToUserSetting=e}},{key:"migratedToOfflineEntitlements",set:function(e){this.content.migratedToOfflineEntitlements=e}},{key:"offlineFeaturesUrl",set:function(e){this.content.offlineFeaturesUrl=e}},{key:"offlineKey",set:function(e){this.content.offlineKey=e}}]),n})(T.b),Ze=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).notes=[],r.data={},r.url=e.safeContent.url,r.name=e.safeContent.name,r.data=e.safeContent.data||{},r.isDefault=e.safeContent.default,r.systemEditor=e.safeContent.systemEditor,r}return n})(T.d),et=(function(e){d(n,oe);var t=k(n);function n(e){var r;return v(this,n),r=t.call(this,e),e.safeContent.predicate&&(r.predicate=H.a.FromJson(e.safeContent.predicate)),r}return n})(),tt=(g(r={},F.a.Note,le),g(r,F.a.Tag,oe),g(r,F.a.ItemsKey,J),g(r,F.a.SmartTag,et),g(r,F.a.ActionsExtension,ie),g(r,F.a.Editor,Ze),g(r,F.a.Theme,B),g(r,F.a.Component,N),g(r,F.a.UserPrefs,z),g(r,F.a.ExtensionRepo,$e),r);function nt(e){return new(tt[e.content_type]||T.d)(e)}var rt=n(27),at=n.n(rt);function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){ot(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ct=g({},F.a.Note,function(e,t,n){var r=n.all(F.a.Component).map(function(e){return nt(e)}).filter(function(e){return e.area===L.ComponentArea.Editor}).find(function(t){return t.isExplicitlyEnabledForItem(e.uuid)});if(r){var a=new V(r,T.c.Internal);return a.associateWithItem(t.uuid),[a.getResult()]}});function ut(e,t,n,r){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(!e.errorDecrypting){p.next=2;break}throw Error('Attempting to duplicate errored payload');case 2:return a=[],p.next=5,b.awrap(I.GenerateUuid());case 5:return p.t0=p.sent,p.t1=new Date,p.t2=e.uuid,(i={uuid:p.t0,dirty:!0,dirtiedDate:p.t1,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:p.t2}).content=st(st({},e.safeContent),r),n&&(i.content.conflict_of=e.uuid),s=Object(Ee.b)(e,i),a.push(s),o=t.elementsReferencingElement(e),c=pt(o,[{uuid:s.uuid,content_type:s.content_type}]),Object(_.o)(a,c),(u=ct[e.content_type])&&(l=u(e,s,t))&&Object(_.o)(a,l),p.abrupt("return",a);case 19:case"end":return p.stop()}},null,null,null,Promise)}function lt(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=[],u.t0=Object(Ee.b),u.t1=e,u.next=5,b.awrap(I.GenerateUuid());case 5:return u.t2=u.sent,u.t3=new Date,u.t4=e.uuid,u.t5={uuid:u.t2,dirty:!0,dirtiedDate:u.t3,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:u.t4},r=(0,u.t0)(u.t1,u.t5),n.push(r),a=t.elementsReferencingElement(e),i=pt(a,[{uuid:r.uuid,content_type:r.content_type}],[e.uuid]),Object(_.o)(n,i),e.content_type===F.a.ItemsKey&&(s=t.all().filter(function(t){return t.items_key_id===e.uuid}),(o=s.map(function(e){return Object(Ee.b)(e,{items_key_id:r.uuid})})).length>0&&Object(_.o)(n,o)),c=Object(Ee.b)(e,{deleted:!0,dirty:!1,content:void 0}),n.push(c),u.abrupt("return",n);case 18:case"end":return u.stop()}},null,null,null,Promise)}function pt(e,t,n){for(var r,a=[],i=S(e);!(r=i()).done;){var s=r.value,o=s.contentObject.references.slice();if(t)for(var c,u=S(t);!(c=u()).done;){var l=c.value;o.push(l)}if(n)for(var p,d=S(n);!(p=d()).done;){var h=p.value;at()(o,{uuid:h})}var f=Object(Ee.b)(s,{dirty:!0,dirtiedDate:new Date,content:st(st({},s.safeContent),{},{references:o})});a.push(f)}return a}function dt(e,t){var n=nt(e),r=nt(t);return n.isItemContentEqualWith(r)}var ht=n(4),ft=n(32),vt=(function(){function e(t,n,r,a){v(this,e),this.baseCollection=t,this.applyCollection=n,this.relatedCollectionSet=r,this.historyMap=a}return y(e,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:throw'Must override PayloadDelta.resultingCollection.';case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"findBasePayload",value:function(e){return this.baseCollection.find(e)}},{key:"findRelatedPayload",value:function(e,t){var n,r=null===(n=this.relatedCollectionSet)||void 0===n?void 0:n.collectionForSource(t);return null===r||void 0===r?void 0:r.find(e)}}]),e})(),yt=function(e){return e[0]},gt=(function(){function e(){v(this,e),this.directMap={},this.inverseMap={}}return y(e,[{key:"makeCopy",value:function(){var t=new e;return t.directMap=w({},this.directMap),t.inverseMap=w({},this.inverseMap),t}},{key:"getDirectRelationships",value:function(e){return this.directMap[e]||[]}},{key:"getInverseRelationships",value:function(e){return this.inverseMap[e]||[]}},{key:"establishRelationship",value:function(e,t){this.establishDirectRelationship(e,t),this.establishInverseRelationship(e,t)}},{key:"deestablishRelationship",value:function(e,t){this.deestablishDirectRelationship(e,t),this.deestablishInverseRelationship(e,t)}},{key:"setAllRelationships",value:function(e,t){var n=this.directMap[e]||[];this.directMap[e]=t;for(var r,a=S(n);!(r=a()).done;){var i=r.value;this.deestablishInverseRelationship(e,i)}for(var s,o=S(t);!(s=o()).done;){var c=s.value;this.establishInverseRelationship(e,c)}}},{key:"removeFromMap",value:function(e){for(var t,n=S(this.directMap[e]||[]);!(t=n()).done;){var r=t.value;Object(_.M)(this.inverseMap[r]||[],e)}delete this.directMap[e];for(var a,i=S(this.inverseMap[e]||[]);!(a=i()).done;){var s=a.value;Object(_.M)(this.directMap[s]||[],e)}delete this.inverseMap[e]}},{key:"establishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.b)(n,t),this.directMap[e]=n}},{key:"establishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.b)(n,e),this.inverseMap[t]=n}},{key:"deestablishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.M)(n,t),this.directMap[e]=n}},{key:"deestablishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.M)(n,e),this.inverseMap[t]=n}}]),e})(),mt=(function(){function e(){v(this,e);var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.map={},this.typedMap={},this.dirtyIndex=new Set,this.invalidsIndex=new Set,this.nondeletedIndex=new Set,t?(this.map=n,this.typedMap=r,this.referenceMap=a,this.conflictMap=i):(this.referenceMap=new gt,this.conflictMap=new gt)}return y(e,[{key:"uuids",value:function(){return Object.keys(this.map)}},{key:"all",value:function(e){var t=this;if(e){if(Array.isArray(e)){for(var n,r=[],a=S(e);!(n=a()).done;){var i=n.value;Object(_.o)(r,this.typedMap[i]||[])}return r}var s;return(null===(s=this.typedMap[e])||void 0===s?void 0:s.slice())||[]}return Object.keys(this.map).map(function(e){return t.map[e]})}},{key:"find",value:function(e){return this.map[e]}},{key:"dirtyElements",value:function(){var e=Array.from(this.dirtyIndex);return this.findAll(e)}},{key:"invalidElements",value:function(){var e=Array.from(this.invalidsIndex);return this.findAll(e)}},{key:"nondeletedElements",value:function(){var e=Array.from(this.nondeletedIndex);return this.findAll(e)}},{key:"findAll",value:function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],a=S(e);!(t=a()).done;){var i=t.value,s=this.map[i];(s||n)&&r.push(s)}return r}},{key:"set",value:function(e){if(0!==(e=Array.isArray(e)?e:[e]).length)for(var t,n=S(e);!(t=n()).done;){var r=t.value;if(this.map[r.uuid]=r,this.setToTypedMap(r),r.dirty?this.dirtyIndex.add(r.uuid):this.dirtyIndex.delete(r.uuid),r.errorDecrypting||r.waitingForKey?this.invalidsIndex.add(r.uuid):this.invalidsIndex.delete(r.uuid),r.deleted)this.referenceMap.removeFromMap(r.uuid),this.nondeletedIndex.delete(r.uuid);else{this.nondeletedIndex.add(r.uuid);var a=r.safeContent.conflict_of;a&&this.conflictMap.establishRelationship(a,r.uuid),this.referenceMap.setAllRelationships(r.uuid,r.references.map(function(e){return e.uuid}))}}else console.warn('Attempting to set 0 elements onto collection')}},{key:"discard",value:function(e){for(var t,n=S(e=Array.isArray(e)?e:[e]);!(t=n()).done;){var r=t.value;this.conflictMap.removeFromMap(r.uuid),this.referenceMap.removeFromMap(r.uuid),this.deleteFromTypedMap(r),delete this.map[r.uuid]}}},{key:"setToTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),t.push(e),this.typedMap[e.content_type]=t}},{key:"deleteFromTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),this.typedMap[e.content_type]=t}},{key:"uuidsThatReferenceUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getInverseRelationships(e)}},{key:"elementsReferencingElement",value:function(e,t){var n=this.uuidsThatReferenceUuid(e.uuid),r=this.findAll(n);return t?r.filter(function(e){return e.content_type===t}):r}},{key:"uuidReferencesForUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getDirectRelationships(e)}},{key:"referencesForElement",value:function(e){var t=this.referenceMap.getDirectRelationships(e.uuid);return this.findAll(t)}},{key:"conflictsOf",value:function(e){var t=this.conflictMap.getDirectRelationships(e);return this.findAll(t)}}]),e})(),bt=(function(e){d(n,mt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"mutableCopy",value:function(){var e=w({},this.map),t=w({},this.typedMap),n=this.referenceMap.makeCopy(),r=this.conflictMap.makeCopy();return new mt(!0,e,t,n,r)}},{key:"payloads",get:function(){return this.all()}}],[{key:"WithPayloads",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=new n;return r.source=t,e.length>0&&r.set(e),Object.freeze(r),r}},{key:"FromCollection",value:function(e){var t=new n(!0,Object.freeze(w({},e.map)),Object.freeze(w({},e.typedMap)),Object.freeze(e.referenceMap.makeCopy()),Object.freeze(e.conflictMap.makeCopy()));return Object.freeze(t),t}}]),n})();function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach(function(t){xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var St,Pt,Ot,Ct=(function(){function e(t,n,r,a,i){v(this,e),this.baseCollection=t,this.basePayload=n,this.applyPayload=r,this.source=a,this.historyMap=i}return y(e,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return t=nt(this.basePayload),n=nt(this.applyPayload),r=(null===(e=this.historyMap)||void 0===e?void 0:e[this.basePayload.uuid])||[],a=yt(r),i=t.strategyWhenConflictingWithItem(n,a),o.next=7,b.awrap(this.payloadsByHandlingStrategy(i));case 7:return s=o.sent,o.abrupt("return",bt.WithPayloads(s,this.source));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingStrategy",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if((t=this.baseCollection.conflictsOf(this.applyPayload.uuid)[0])&&dt(t,this.applyPayload)&&(e=K.a.KeepLeft),e!==K.a.KeepLeft){y.next=7;break}return n=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),r=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),a=Object(Ee.b)(this.basePayload,{updated_at:n,updated_at_timestamp:r,dirty:!0,dirtiedDate:new Date}),y.abrupt("return",[a]);case 7:if(e!==K.a.KeepRight){y.next=10;break}return i=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",[i]);case 10:if(e!==K.a.KeepLeftDuplicateRight){y.next=18;break}return s=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),o=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),c=Object(Ee.b)(this.basePayload,{updated_at:s,updated_at_timestamp:o,dirty:!0,dirtiedDate:new Date}),y.next=16,b.awrap(ut(this.applyPayload,this.baseCollection,!0));case 16:return u=y.sent,y.abrupt("return",[c].concat(u));case 18:if(e!==K.a.DuplicateLeftKeepRight){y.next=24;break}return y.next=21,b.awrap(ut(this.basePayload,this.baseCollection,!0));case 21:return l=y.sent,p=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",l.concat([p]));case 24:if(e!==K.a.KeepLeftMergeRefs){y.next=30;break}return d=Object(_.U)(this.basePayload.contentObject.references,this.applyPayload.contentObject.references,['uuid','content_type']),h=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),f=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),v=Object(Ee.b)(this.basePayload,{updated_at:h,updated_at_timestamp:f,dirty:!0,dirtiedDate:new Date,content:kt(kt({},this.basePayload.safeContent),{},{references:d})}),y.abrupt("return",[v]);case 30:throw Error('Unhandled strategy');case 31:case"end":return y.stop()}},null,this,null,Promise)}}]),e})(),Dt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}return r=n.value,s.next=6,b.awrap(this.payloadsByHandlingPayload(r,e));case 6:a=s.sent,i=a.map(function(e){return Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date,deleted:!1})}),Object(_.o)(e,i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.FileImport));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingPayload",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=t.find(function(t){return t.contentObject.conflict_of===e.uuid}))||(n=t.find(function(t){return t.uuid===e.uuid})),n||(n=this.findBasePayload(e.uuid)),n){i.next=5;break}return i.abrupt("return",[e]);case 5:return r=new Ct(this.baseCollection,n,e,ht.a.FileImport),i.next=8,b.awrap(r.resultingCollection());case 8:return a=i.sent,i.abrupt("return",a.all());case 10:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(),_t=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=17;break}if(r=n.value,e.push(r),a=this.findBasePayload(r.uuid)){s.next=8;break}return s.abrupt("continue",15);case 8:if(!dt(r,a)){s.next=11;break}return s.abrupt("continue",15);case 11:return s.next=13,b.awrap(ut(a,this.baseCollection,!0));case 13:i=s.sent,Object(_.o)(e,i);case 15:s.next=2;break;case 17:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 18:case"end":return s.stop()}},null,this,null,Promise)}}]),n})(),Et=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.applyCollection.source!==ht.a.ConflictUuid){e.next=4;break}return e.abrupt("return",this.collectionsByHandlingUuidConflicts());case 4:if(this.applyCollection.source!==ht.a.ConflictData){e.next=8;break}return e.abrupt("return",this.collectionsByHandlingDataConflicts());case 8:throw"Unhandled conflict type ".concat(this.applyCollection.source);case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingDataConflicts",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){u.next=19;break}if(r=n.value,a=this.findBasePayload(r.uuid)){u.next=8;break}return e.push(r),u.abrupt("continue",17);case 8:if((i=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient))||r.deleted){u.next=11;break}throw'Unable to find decrypted counterpart for data conflict.';case 11:return s=new Ct(this.baseCollection,a,i||r,ht.a.ConflictData,this.historyMap),u.next=14,b.awrap(s.resultingCollection());case 14:o=u.sent,c=o.all(),Object(_.o)(e,c);case 17:u.next=2;break;case 19:return u.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingUuidConflicts",value:function(){var e,t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:e=[],t=this.baseCollection.mutableCopy(),n=function(n){var r,a,i;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=e.find(function(e){return e.uuid===n.uuid}),a=r||s.findRelatedPayload(n.uuid,ht.a.DecryptedTransient)){o.next=6;break}return we.a.error(Error('Cannot find decrypted payload in conflict handling')),console.error('Unable to find decrypted counterpart for payload',n),o.abrupt("return","continue");case 6:return o.next=8,b.awrap(lt(a,bt.FromCollection(t)));case 8:i=o.sent,t.set(i),Object(_.p)(e,function(e){return Object(Ke.b)(i).includes(e.uuid)}),Object(_.o)(e,i);case 12:case"end":return o.stop()}},null,null,null,Promise)},r=S(this.applyCollection.all());case 4:if((a=r()).done){o.next=13;break}return i=a.value,o.next=8,b.awrap(n(i));case 8:if("continue"!==o.sent){o.next=11;break}return o.abrupt("continue",11);case 11:o.next=4;break;case 13:return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 14:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Rt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y;return b.async(function(g){for(;;)switch(g.prev=g.next){case 0:e=[],t=[],n=S(this.applyCollection.all());case 3:if((r=n()).done){g.next=22;break}if(a=r.value,i=this.findRelatedPayload(a.uuid,ht.a.SavedOrSaving),s=this.findRelatedPayload(a.uuid,ht.a.DecryptedTransient)){g.next=12;break}if(a.deleted){g.next=10;break}throw'Cannot find decrypted for non-deleted payload.';case 10:return e.push(a),g.abrupt("continue",20);case 12:if(!i){g.next=15;break}return t.push(s),g.abrupt("continue",20);case 15:if(null===(o=this.findBasePayload(a.uuid))||void 0===o||!o.dirty||o.errorDecrypting){g.next=19;break}return t.push(s),g.abrupt("continue",20);case 19:e.push(s);case 20:g.next=3;break;case 22:c=[],u=0,l=t;case 24:if(!(u<l.length)){g.next=41;break}if(p=l[u],d=this.findRelatedPayload(p.uuid,ht.a.DecryptedTransient)){g.next=29;break}return g.abrupt("continue",38);case 29:if(h=this.findBasePayload(p.uuid)){g.next=32;break}return g.abrupt("continue",38);case 32:return f=new Ct(this.baseCollection,h,d,ht.a.ConflictData),g.next=35,b.awrap(f.resultingCollection());case 35:v=g.sent,y=v.all(),Object(_.o)(c,y);case 38:u++,g.next=24;break;case 41:return g.abrupt("return",bt.WithPayloads(e.concat(c),ht.a.RemoteRetrieved));case 42:case"end":return g.stop()}},null,this,null,Promise)}}]),n})(),It=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:for(e=[],t=S(this.applyCollection.all());!(n=t()).done;)r=n.value,a=this.findBasePayload(r.uuid),i=a?a.deleted:r.deleted,s=Object(Ee.f)(r,ht.a.RemoteSaved,{lastSyncEnd:new Date,deleted:i,dirty:i}),e.push(s);return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteSaved));case 3:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Mt=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l){var p;return v(this,n),(p=t.call(this)).itemManager=e,p.payloadManager=r,p.apiService=a,p.protocolService=i,p.challengeService=s,p.alertService=o,p.storageService=c,p.syncService=u,p.credentialService=l,p.decryptionQueue=[],p.isProcessingQueue=!1,p.removeItemObserver=p.itemManager.addObserver([F.a.ItemsKey],function(e,t,n,r,a){if(a!==ht.a.LocalChanged){var i=e.concat(t).filter(function(e){return e.errorDecrypting});i.length>0&&p.handleUndecryptableItemsKeys(i),r.length>0&&p.handleIgnoredItemsKeys(r)}}),p}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.apiService=void 0,this.protocolService=void 0,this.challengeService=void 0,this.alertService=void 0,this.credentialService=void 0,this.syncService=void 0,this.storageService=void 0,this.removeItemObserver(),this.removeItemObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:p(f(n.prototype),"handleApplicationStage",this).call(this,e),e===ve.LoadedDatabase_12&&this.processPersistedUndecryptables();case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleIgnoredItemsKeys",value:function(e){var t=this,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(!(n.length>1&&void 0!==n[1])||n[1])){r.next=4;break}return r.next=4,b.awrap(this.saveToUndecryptables(e));case 4:return r.next=6,b.awrap(this.addKeysToQueue(e,function(e,n){n.success&&t.removeFromUndecryptables(e)}));case 6:return r.next=8,b.awrap(this.beginProcessingQueue());case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"handleUndecryptableItemsKeys",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.addKeysToQueue(e));case 2:return t.next=4,b.awrap(this.beginProcessingQueue());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"processPersistedUndecryptables",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getUndecryptables());case 2:if(e=r.sent,0!==(t=Object.values(e)).length){r.next=6;break}return r.abrupt("return");case 6:return n=t.map(function(e){return Object(Ee.e)(e)}).map(function(e){return nt(e)}),r.abrupt("return",this.handleIgnoredItemsKeys(n,!1));case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getUndecryptables",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.KeyRecoveryUndecryptableItems,De.Default,{}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"persistUndecryptables",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.KeyRecoveryUndecryptableItems,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"saveToUndecryptables",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.getUndecryptables());case 2:for(t=i.sent,n=S(e);!(r=n()).done;)a=r.value,t[a.uuid]=a.payload.ejected();return i.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"removeFromUndecryptables",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getUndecryptables());case 2:return delete(t=n.sent)[e.uuid],n.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getClientKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getAccountKeyParams());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"serverKeyParamsAreSafe",value:function(e){return Object(Q.d)(this.serverParams.version,e.version)}},{key:"performServerSignIn",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(e),j.H.KeyRecoveryLoginFlowReason),i.next=3,b.awrap(this.challengeService.promptForChallengeResponse(t));case 3:if(n=i.sent){i.next=6;break}return i.abrupt("return",void 0);case 6:return this.challengeService.completeChallenge(t),r=n.values[0].value,i.next=10,b.awrap(this.protocolService.computeRootKey(r,e));case 10:return a=i.sent,i.next=13,b.awrap(this.credentialService.correctiveSignIn(a));case 13:if(i.sent.error){i.next=19;break}return this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced),i.abrupt("return",a);case 19:return i.next=21,b.awrap(this.alertService.alert(j.H.KeyRecoveryLoginFlowInvalidPassword));case 21:return i.abrupt("return",this.performServerSignIn(e));case 22:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",void 0);case 2:return n.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(e=n.sent,t=e.wrappingKey,!e.canceled){n.next=11;break}return n.next=10,b.awrap(this.alertService.alert(j.H.KeyRecoveryPasscodeRequiredText,j.H.KeyRecoveryPasscodeRequiredTitle));case 10:return n.abrupt("return",this.getWrappingKeyIfApplicable());case 11:return n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"addKeysToQueue",value:function(e,t){var n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:n=function(e){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(s.protocolService.getKeyEmbeddedKeyParams(e));case 2:if(n=i.sent){i.next=5;break}return i.abrupt("return","continue");case 5:r={key:e,keyParams:n,callback:t},a=new Promise(function(e){r.resolve=e}),r.promise=a,s.decryptionQueue.push(r);case 9:case"end":return i.stop()}},null,null,null,Promise)},r=S(e);case 2:if((a=r()).done){o.next=11;break}return i=a.value,o.next=6,b.awrap(n(i));case 6:if("continue"!==o.sent){o.next=9;break}return o.abrupt("continue",9);case 9:o.next=2;break;case 11:case"end":return o.stop()}},null,null,null,Promise)}},{key:"readdQueueItem",value:function(e){var t=new Promise(function(t){e.resolve=t});e.promise=t,this.decryptionQueue.unshift(e)}},{key:"beginProcessingQueue",value:function(){var e,t,n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.isProcessingQueue){c.next=2;break}return c.abrupt("return");case 2:return this.isProcessingQueue=!0,c.next=5,b.awrap(this.getClientKeyParams());case 5:if(e=c.sent,this.serverParams||!e){c.next=11;break}return c.next=9,b.awrap(this.apiService.getAccountKeyParams(e.identifier));case 9:!(t=c.sent).error&&t.data&&(this.serverParams=Object(A.f)(t));case 11:if(n=this.protocolService.hasAccount(),r=this.protocolService.hasPasscode(),a=!n&&!r,i=this.decryptionQueue[0],!a){c.next=24;break}return c.next=18,b.awrap(this.performServerSignIn(i.keyParams));case 18:if(!(s=c.sent)){c.next=24;break}return c.next=22,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(s,!0));case 22:Object(_.M)(this.decryptionQueue,i),i=this.decryptionQueue[0];case 24:if(!i){c.next=31;break}return this.popQueueItem(i),c.next=28,b.awrap(i.promise);case 28:i=this.decryptionQueue[0],c.next=24;break;case 31:this.queuePromise.then(function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(o.isProcessingQueue=!1,!o.serverParams){n.next=9;break}return n.next=4,b.awrap(o.getClientKeyParams());case 4:if(e=n.sent,t=e&&!o.serverParams.compare(e),!o.serverKeyParamsAreSafe(e)||!t){n.next=9;break}return n.next=9,b.awrap(o.performServerSignIn(o.serverParams));case 9:o.syncService.isOutOfSync()&&o.syncService.sync({checkIntegrity:!0});case 10:case"end":return n.stop()}},null,null,null,Promise)});case 32:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueItem",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P;return b.async(function(O){for(;;)switch(O.prev=O.next){case 0:if(e.resolve){O.next=2;break}throw Error('Attempting to pop queue element with no resolve function');case 2:return Object(_.M)(this.decryptionQueue,e),t=e.keyParams,n=e.key,r=e.resolve,a=!1,O.next=9,b.awrap(this.getClientKeyParams());case 9:return i=O.sent,this.serverParams&&i&&!i.compare(this.serverParams)&&t.compare(this.serverParams)&&this.serverKeyParamsAreSafe(this.serverParams)&&(s=Object(_.j)(this.itemManager.nonErroredItemsForContentType(F.a.ItemsKey),Je.a.CreatedAt,!1)[0],o=!Object(_.w)(s),c=n.created_at>(null===s||void 0===s?void 0:s.created_at),a=!o||c),u=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(t),j.H.KeyRecoveryPasswordRequired),O.next=14,b.awrap(this.challengeService.promptForChallengeResponse(u));case 14:if(l=O.sent){O.next=20;break}return r(d={success:!1}),null===(p=e.callback)||void 0===p||p.call(e,n,d),O.abrupt("return");case 20:return h=l.values[0].value,O.next=23,b.awrap(this.protocolService.computeRootKey(h,t));case 23:return f=O.sent,O.next=26,b.awrap(this.protocolService.payloadByDecryptingPayload(n.payload,f));case 26:if(v=O.sent,this.challengeService.completeChallenge(u),v.errorDecrypting){O.next=38;break}return O.next=31,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(f,a,[v]));case 31:for(g=O.sent,r(m={success:!0}),null===(y=e.callback)||void 0===y||y.call(e,n,m),w=S(g);!(k=w()).done;)(x=k.value).resolve(m),null===(P=x.callback)||void 0===P||P.call(x,x.key,m);O.next=42;break;case 38:return O.next=40,b.awrap(this.alertService.alert(j.H.KeyRecoveryUnableToRecover));case 40:this.readdQueueItem(e),r({success:!1});case 42:case"end":return O.stop()}},null,this,null,Promise)}},{key:"handleDecryptionOfAllKeysMatchingCorrectRootKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:[],!t){c.next=7;break}return c.next=4,b.awrap(this.getWrappingKeyIfApplicable());case 4:return r=c.sent,c.next=7,b.awrap(this.protocolService.setRootKey(e,r));case 7:return a=this.popQueueForKeyParams(e.keyParams),c.next=10,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a.map(function(e){return e.key.payload}),e));case 10:return i=c.sent,s=n.concat(i),this.payloadManager.emitPayloads(s,ht.a.DecryptedTransient),c.next=15,b.awrap(this.storageService.savePayloads(s));case 15:return t?this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced):this.alertService.alert(j.H.KeyRecoveryKeyRecovered),c.abrupt("return",a);case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueForKeyParams",value:function(e){for(var t,n=[],r=[],a=S(this.decryptionQueue);!(t=a()).done;){var i=t.value;i.keyParams.compare(e)?n.push(i):r.push(i)}return this.decryptionQueue=r,n}},{key:"queuePromise",get:function(){return Promise.all(this.decryptionQueue.map(function(e){return e.promise}))}}]),n})(R.a),At=n(17);!(function(e){e[e.Info=0]="Info",e[e.Danger=1]="Danger"})(St||(St={})),(function(e){e.Get="GET",e.Post="POST",e.Put="PUT",e.Patch="PATCH",e.Delete="DELETE"})(Pt||(Pt={})),(function(e){e.RevokedSession="revoked-session"})(Ot||(Ot={}));var jt=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).environment=e,a.appVersion=r,a}return y(n,[{key:"getAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Get,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"postAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Post,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"putAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Put,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"patchAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Patch,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Delete,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"runHttp",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.createXmlRequest(e),n.abrupt("return",this.runRequest(t,e.verb,e.params));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createXmlRequest",value:function(e){var t=new XMLHttpRequest;e.params&&e.verb===Pt.Get&&Object.keys(e.params).length>0&&(e.url=this.urlForUrlAndParams(e.url,e.params)),t.open(e.verb,e.url,!0),t.setRequestHeader('Content-type','application/json'),t.setRequestHeader('X-SNJS-Version',h);var n="".concat(he[this.environment],"-").concat(this.appVersion);return t.setRequestHeader('X-Application-Version',n),e.authentication&&t.setRequestHeader('Authorization','Bearer '+e.authentication),e.customHeaders&&e.customHeaders.length>0&&e.customHeaders.forEach(function(e){var n=e.key,r=e.value;t.setRequestHeader(n,r)}),t}},{key:"runRequest",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,i){e.onreadystatechange=function(){r.stateChangeHandlerForRequest(e,a,i)},t===Pt.Post||t===Pt.Put||t===Pt.Patch||t===Pt.Delete?e.send(JSON.stringify(n)):e.send()}));case 1:case"end":return a.stop()}},null,null,null,Promise)}},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.status,a={status:r};try{if(r!==Te.b.HttpStatusNoContent){var i=JSON.parse(e.responseText);i.data||(a.data=i),w(a,i)}}catch(e){console.error(e)}r>=Te.b.HttpStatusMinSuccess&&r<=Te.b.HttpStatusMaxSuccess?t(a):(r===Te.b.HttpStatusForbidden?a.error={message:j.q,status:r}:Object(_.w)(a.error)&&(Object(_.w)(a.data)||Object(_.w)(a.data.error)?a.error={message:j.U,status:r}:a.error=a.data.error),n(a))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map(function(e){return e+'='+encodeURIComponent(t[e])}).join('&');return e.includes('?')?e+'&'+n:e+'?'+n}}]),n})(R.a),Tt=n(22),Kt=['api.standardnotes.com','api-dev.standardnotes.com','sync.standardnotes.org'],Ft=['api-dev.standardnotes.com','api.standardnotes.com','extensions.standardnotes.com','extensions.standardnotes.org','features.standardnotes.com'],Lt='localhost';function Ut(e){try{var t=new URL(e).host;return t.startsWith(Lt)||Kt.includes(t)}catch(e){return!1}}var Nt=['listed.to'];function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(n),!0).forEach(function(t){Wt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ht,zt={keyParams:'/v1/login-params',register:'/v1/users',signIn:'/v1/login',changeCredentials:function(e){return"/v1/users/".concat(e,"/attributes/credentials")},sync:'/v1/items',signOut:'/v1/logout',refreshSession:'/v1/sessions/refresh',sessions:'/v1/sessions',session:function(e){return"/v1/sessions/".concat(e)},itemRevisions:function(e){return"/v1/items/".concat(e,"/revisions")},itemRevision:function(e,t){return"/v1/items/".concat(e,"/revisions/").concat(t)},userFeatures:function(e){return"/v1/users/".concat(e,"/features")},settings:function(e){return"/v1/users/".concat(e,"/settings")},setting:function(e,t){return"/v1/users/".concat(e,"/settings/").concat(t)},subscription:function(e){return"/v1/users/".concat(e,"/subscription")},purchase:'/v1/purchase',subscriptionTokens:'/v1/subscription-tokens',offlineFeatures:'/v1/offline/features'},qt={subscriptions:'/v2/subscriptions'};!(function(e){e.MetaReceived="MetaReceived"})(Ht||(Ht={}));var Yt=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).httpService=e,i.storageService=r,i.host=a,i.registering=!1,i.authenticating=!1,i.changing=!1,i.refreshingSession=!1,i}return y(n,[{key:"deinit",value:function(){this.httpService=void 0,this.storageService=void 0,this.invalidSessionObserver=void 0,this.session=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"setInvalidSessionObserver",value:function(e){this.invalidSessionObserver=e}},{key:"loadHost",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ServerHost));case 2:e=t.sent,this.host=e||this.host||window._default_sync_server;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.host=e,t.next=3,b.awrap(this.storageService.setValue(o.ServerHost,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.host}},{key:"isThirdPartyHostUsed",value:function(){return!Ut(this.getHost()||'')}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],this.session=e,!t){r.next=5;break}return r.next=5,b.awrap(this.storageService.setValue(o.Session,e));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSession",value:function(){return this.session}},{key:"params",value:function(e){var t=Z()(e,g({},Tt.a.ApiVersion,this.apiVersion));return t}},{key:"createErrorResponse",value:function(e,t){return{error:{message:e,status:t}}}},{key:"errorResponseWithFallbackMessage",value:function(e,t){var n,r,a;null!==(n=e.error)&&void 0!==n&&n.message||(e.error=Bt(Bt({},e.error),{},{status:null!==(r=null===(a=e.error)||void 0===a?void 0:a.status)&&void 0!==r?r:Te.b.UnknownError,message:t}));return e}},{key:"processMetaObject",value:function(e){e.auth&&e.auth.userUuid&&e.auth.roles&&this.notifyEvent(Ht.MetaReceived,{userUuid:e.auth.userUuid,userRoles:e.auth.roles})}},{key:"processResponse",value:function(e){e.meta&&this.processMetaObject(e.meta)}},{key:"request",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.awrap(this.httpService.runHttp(e));case 3:return t=n.sent,this.processResponse(t),n.abrupt("return",t);case 8:return n.prev=8,n.t0=n.catch(0),n.abrupt("return",this.errorResponseWithFallbackMessage(n.t0,e.fallbackErrorMessage));case 11:case"end":return n.stop()}},null,this,[[0,8]],Promise)}},{key:"getAccountKeyParams",value:function(e,t,n){var r,a=this.params({email:e});return t&&n&&(a[t]=n),this.request({verb:Pt.Get,url:Object(_.D)(this.host,zt.keyParams),fallbackErrorMessage:j.k,params:a,authentication:null===(r=this.session)||void 0===r?void 0:r.authorizationValue})}},{key:"register",value:function(e,t,n,r){var a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.registering){o.next=2;break}return o.abrupt("return",this.createErrorResponse(j.r));case 2:return this.registering=!0,a=Object(_.D)(this.host,zt.register),i=this.params(Bt({password:t,email:e,ephemeral:r},n.getPortableValue())),o.next=7,b.awrap(this.request({verb:Pt.Post,url:a,fallbackErrorMessage:j.l,params:i}));case 7:return s=o.sent,this.registering=!1,o.abrupt("return",s);case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t,n,r){var a,i,s,o,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>4&&void 0!==c[4]&&c[4],!this.authenticating){u.next=3;break}return u.abrupt("return",this.createErrorResponse(j.p));case 3:return this.authenticating=!0,i=Object(_.D)(this.host,zt.signIn),s=this.params({email:e,password:t,ephemeral:a}),n&&r&&(s[n]=r),u.next=9,b.awrap(this.request({verb:Pt.Post,url:i,params:s,fallbackErrorMessage:j.k}));case 9:return o=u.sent,this.authenticating=!1,u.abrupt("return",o);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e=Object(_.D)(this.host,zt.signOut);return this.httpService.postAbsolute(e,void 0,this.session.authorizationValue).catch(function(e){return e})}},{key:"changeCredentials",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.changing){s.next=2;break}return s.abrupt("return",this.createErrorResponse(j.a));case 2:if(!(t=this.preprocessingError())){s.next=5;break}return s.abrupt("return",t);case 5:return this.changing=!0,n=Object(_.D)(this.host,zt.changeCredentials(e.userUuid)),r=this.params(Bt({current_password:e.currentServerPassword,new_password:e.newServerPassword,new_email:e.newEmail},e.newKeyParams.getPortableValue())),s.next=10,b.awrap(this.httpService.putAbsolute(n,r,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Object(Te.c)(e)){t.next=2;break}return t.abrupt("return",i.refreshSessionThenRetryRequest({verb:Pt.Put,url:n,params:r}));case 2:return t.abrupt("return",i.errorResponseWithFallbackMessage(e,j.j));case 3:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return a=s.sent,this.processResponse(a),this.changing=!1,s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"sync",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=this,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:if(i=h.length>4&&void 0!==h[4]&&h[4],s=h.length>5?h[5]:void 0,o=h.length>6?h[6]:void 0,!(c=this.preprocessingError())){f.next=6;break}return f.abrupt("return",c);case 6:return u=Object(_.D)(this.host,zt.sync),l=this.params((g(a={},Tt.a.SyncPayloads,e.map(function(e){return e.ejected()})),g(a,Tt.a.LastSyncToken,t),g(a,Tt.a.PaginationToken,n),g(a,Tt.a.IntegrityCheck,i),g(a,Tt.a.SyncDlLimit,r),g(a,"content_type",s),g(a,"event",o),a)),f.next=10,b.awrap(this.httpService.postAbsolute(u,l,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(d.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){t.next=3;break}return t.abrupt("return",d.refreshSessionThenRetryRequest({verb:Pt.Post,url:u,params:l}));case 3:return t.abrupt("return",d.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return p=f.sent,this.processResponse(p),f.abrupt("return",p);case 13:case"end":return f.stop()}},null,this,null,Promise)}},{key:"refreshSessionThenRetryRequest",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.refreshSession());case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=7;break}return n.abrupt("return",t);case 7:return n.abrupt("return",this.httpService.runHttp(Bt(Bt({},e),{},{authentication:this.session.authorizationValue})).catch(function(e){return e}));case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"refreshSession",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(e=this.preprocessingError())){s.next=3;break}return s.abrupt("return",e);case 3:return this.refreshingSession=!0,t=Object(_.D)(this.host,zt.refreshSession),n=this.session,r=this.params({access_token:n.accessToken,refresh_token:n.refreshToken}),s.next=9,b.awrap(this.httpService.postAbsolute(t,r).then(function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=je.FromApiResponse(e),n.next=3,b.awrap(i.setSession(t));case 3:return i.processResponse(e),n.abrupt("return",e);case 5:case"end":return n.stop()}},null,null,null,Promise)}).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),i.errorResponseWithFallbackMessage(e,j.n)}));case 9:return a=s.sent,this.refreshingSession=!1,s.abrupt("return",a);case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e=this.preprocessingError())){a.next=3;break}return a.abrupt("return",e);case 3:return t=Object(_.D)(this.host,zt.sessions),a.next=6,b.awrap(this.httpService.getAbsolute(t,{},this.session.authorizationValue).catch(function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){n.next=3;break}return n.abrupt("return",r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}));case 3:return n.abrupt("return",r.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return n.stop()}},null,null,null,Promise)}));case 6:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSession",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.session(e)),i.next=6,b.awrap(this.httpService.deleteAbsolute(n,{uuid:e},this.session.authorizationValue).catch(function(e){var t=e;return a.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?a.refreshSessionThenRetryRequest({verb:Pt.Delete,url:n}):a.errorResponseWithFallbackMessage(t,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getItemRevisions",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.itemRevisions(e)),i.next=6,b.awrap(this.httpService.getAbsolute(n,void 0,this.session.authorizationValue).catch(function(e){return a.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?a.refreshSessionThenRetryRequest({verb:Pt.Get,url:n}):a.errorResponseWithFallbackMessage(e,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getRevision",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(n=this.preprocessingError())){s.next=3;break}return s.abrupt("return",n);case 3:return r=Object(_.D)(this.host,zt.itemRevision(t,e.uuid)),s.next=6,b.awrap(this.httpService.getAbsolute(r,void 0,this.session.authorizationValue).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?i.refreshSessionThenRetryRequest({verb:Pt.Get,url:r}):i.errorResponseWithFallbackMessage(e,j.m)}));case 6:return a=s.sent,this.processResponse(a),s.abrupt("return",a);case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getUserFeatures",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=Object(_.D)(this.host,zt.userFeatures(e)),a.next=3,b.awrap(this.httpService.getAbsolute(t,void 0,this.session.authorizationValue).catch(function(e){return r.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}):r.errorResponseWithFallbackMessage(e,j.m)}));case 3:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"tokenRefreshableRequest",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(t=this.preprocessingError())){a.next=3;break}return a.abrupt("return",t);case 3:return a.next=5,b.awrap(this.httpService.runHttp(e).catch(function(t){return r.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?r.refreshSessionThenRetryRequest(e):r.errorResponseWithFallbackMessage(t,e.fallbackErrorMessage)}));case 5:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"listSettings",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.settings(e)),fallbackErrorMessage:j.d,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n,r){var a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return i={name:t,value:n,sensitive:r},s.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Put,url:Object(_.D)(this.host,zt.settings(e)),authentication:null===(a=this.session)||void 0===a?void 0:a.authorizationValue,fallbackErrorMessage:j.h,params:i}));case 2:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.setting(e,t.toLowerCase())),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.d}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Delete,url:Object(_.D)(this.host,zt.setting(e,t)),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.h}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"downloadFeatureUrl",value:function(e){return this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.k})}},{key:"getSubscription",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscription(e)),a.next=3,b.awrap(this.request({verb:Pt.Get,url:n,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue,fallbackErrorMessage:j.g}));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=Object(_.D)(this.host,qt.subscriptions),n.next=3,b.awrap(this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.g}));case 3:return t=n.sent,n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getNewSubscriptionToken",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscriptionTokens),a.next=3,b.awrap(this.request({verb:Pt.Post,url:n,authentication:null===(e=this.session)||void 0===e?void 0:e.authorizationValue,fallbackErrorMessage:j.b}));case 3:return r=a.sent,a.abrupt("return",null===(t=r.data)||void 0===t?void 0:t.token);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"downloadOfflineFeaturesFromRepo",value:function(e){var t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,n=e.offlineFeaturesUrl,r=e.offlineKey,a=new URL(n),i=a.host,Ft.includes(i)){o.next=6;break}return o.abrupt("return",{error:'This offline features host is not in the trusted allowlist.'});case 6:return o.next=8,b.awrap(this.request({verb:Pt.Get,url:n,fallbackErrorMessage:j.f,customHeaders:[{key:'x-offline-token',value:r}]}));case 8:return s=o.sent,o.abrupt("return",{features:(null===(t=s.data)||void 0===t?void 0:t.features)||[]});case 12:return o.prev=12,o.t0=o.catch(0),o.abrupt("return",{error:j.e});case 15:case"end":return o.stop()}},null,this,[[0,12]],Promise)}},{key:"preprocessingError",value:function(){return this.refreshingSession?this.createErrorResponse(j.s):this.session?void 0:this.createErrorResponse(j.o)}},{key:"preprocessAuthenticatedErrorResponse",value:function(e){var t,n;e.status===Te.b.HttpStatusInvalidSession&&this.session&&(null===(t=this.invalidSessionObserver)||void 0===t||t.call(this,(null===(n=e.error)||void 0===n?void 0:n.tag)===Ot.RevokedSession))}},{key:"apiVersion",get:function(){return"20200115"}}]),n})(R.a),Gt=n(25),Qt=n.n(Gt),Jt=n(28),$t=n.n(Jt);function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach(function(t){en(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tn,nn=Object.freeze([F.a.ActionsExtension,F.a.Component,F.a.Editor,F.a.ExtensionRepo,F.a.FilesafeCredentials,F.a.FilesafeFileMetadata,F.a.FilesafeIntegration,F.a.ServerExtension,F.a.SmartTag,F.a.Tag,F.a.Theme]),rn='org.standardnotes.sn.components';!(function(e){e.Shift="Shift",e.Ctrl="Control",e.Meta="Meta"})(tn||(tn={}));var an=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).componentState={},c.streamObservers=[],c.contextStreamObservers=[],c.permissionDialogs=[],c.handlers=[],c.templateComponents=[],c.detectFocusChange=function(){for(var e,t=function(e){if(document.activeElement===e)return c.timeout(function(){for(var t,n=c.findComponent(e.dataset.componentId),r=S(c.handlers);!(t=r()).done;){var a=t.value;a.focusHandler&&a.focusHandler(n,!0)}}),"break"},n=S(c.allComponentIframes());!(e=n()).done;){if("break"===t(e.value))break}},c.onWindowMessage=function(e){e.data.sessionKey&&(c.log('Component manager received message',e.data),c.handleMessage(c.componentForSessionKey(e.data.sessionKey),e.data))},c.timeout=o||setTimeout.bind(window),c.itemManager=e,c.syncService=r,c.alertService=a,c.environment=i,c.platform=s,c.configureForGeneralUsage(),i!==he.Mobile&&c.configureForNonMobileUsage(),c}return y(n,[{key:"componentsForArea",value:function(e){return this.components.filter(function(t){return t.area===e})}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.streamObservers.length=0,this.contextStreamObservers.length=0,this.permissionDialogs.length=0,this.templateComponents.length=0,this.handlers.length=0,this.itemManager=void 0,this.syncService=void 0,this.alertService=void 0,this.removeItemObserver(),this.removeItemObserver=null,window&&!this.isMobile&&(window.removeEventListener('focus',this.detectFocusChange,!0),window.removeEventListener('blur',this.detectFocusChange,!0),window.removeEventListener('message',this.onWindowMessage))}},{key:"setDesktopManager",value:function(e){this.desktopManager=e,this.configureForDesktop()}},{key:"configureForGeneralUsage",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n,r,a,i,s){var o=Object(_.h)(t,n,r),c=o.filter(function(e){return e.content_type===F.a.Component||e.content_type===F.a.Theme});c.length>0&&i!==ht.a.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(c),c.filter(function(e){return e.isTheme()}).length>0&&e.postActiveThemesToAllComponents();for(var u,l=S(c);!(u=l()).done;){var p=u.value;if(!p.isEditor()){var d=!!e.iframeForComponent(p.uuid);!p.active&&d&&e.deactivateComponent(p.uuid)}}e.notifyStreamObservers(o,i,s)})}},{key:"notifyStreamObservers",value:function(e,t,n){for(var r,a=this,i=function(t){if(n&&n===t.componentUuid)return"continue";var r=e.filter(function(e){return-1!==t.contentTypes.indexOf(e.content_type)});if(0===r.length)return"continue";var i=[{name:E.StreamItems,content_types:t.contentTypes.sort()}];a.runWithPermissions(t.componentUuid,i,function(){a.sendItemsInReply(t.componentUuid,r,t.originalMessage)})},s=S(this.streamObservers);!(r=s()).done;)i(r.value);for(var o,c=[{name:E.StreamContextItem}],u=function(r){if(n&&n===r.componentUuid)return"continue";for(var i,s=S(a.handlers);!(i=s()).done;){var o=i.value;if((o.areas.includes(r.area)||o.areas.includes(L.ComponentArea.Any))&&o.contextRequestHandler){var u=o.contextRequestHandler(r.componentUuid);if(u)if("continue"===(function(){var n=Qt()(e,{uuid:u.uuid});if(n){if(n.deleted)return"continue";a.runWithPermissions(r.componentUuid,c,function(){a.sendContextItemInReply(r.componentUuid,n,r.originalMessage,t)})}})())continue}}},l=S(this.contextStreamObservers);!(o=l()).done;)u(o.value)}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location],n=e.hosted_url,r=e.local_url&&e.local_url.replace("sn://",'');return t.includes(n)||t.includes(r)}},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener('focus',this.detectFocusChange,!0):window.attachEvent('onfocusout',this.detectFocusChange),window.addEventListener?window.addEventListener('blur',this.detectFocusChange,!0):window.attachEvent('onblur',this.detectFocusChange),window.addEventListener('message',this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver(function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()})}},{key:"postActiveThemesToAllComponents",value:function(){for(var e,t=S(this.components);!(e=t()).done;){var n=e.value;this.findOrCreateDataForComponent(n.uuid).window&&this.postActiveThemesToComponent(n)}}},{key:"getActiveThemes",value:function(){if(this.environment===he.Mobile)throw Error('getActiveThemes must be handled separately by mobile');return this.componentsForArea(L.ComponentArea.Themes).filter(function(e){return e.active})}},{key:"urlsForActiveThemes",value:function(){for(var e,t=[],n=S(this.getActiveThemes());!(e=n()).done;){var r=e.value,a=this.urlForComponent(r);a&&t.push(a)}return t}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()},n={action:E.ActivateThemes,data:t};this.sendMessageToComponent(e,n)}},{key:"findComponent",value:function(e){return this.templateComponents.find(function(t){return t.uuid===e})||this.itemManager.findItem(e)}},{key:"addTemporaryTemplateComponent",value:function(e){this.templateComponents.push(e)}},{key:"removeTemporaryTemplateComponent",value:function(e){this.templateComponents=this.templateComponents.filter(function(t){return t.uuid!==e.uuid})}},{key:"contextItemDidChangeInArea",value:function(e){for(var t,n=S(this.handlers);!(t=n()).done;){var r=t.value;if(r.areas.includes(e)||r.areas.includes(L.ComponentArea.Any))for(var a,i=S(this.contextStreamObservers.filter(function(t){return t.area===e}));!(a=i()).done;){var s=a.value;if(r.contextRequestHandler){var o=r.contextRequestHandler(s.componentUuid);o&&this.sendContextItemInReply(s.componentUuid,o,s.originalMessage)}}}}},{key:"isComponentHidden",value:function(e){return!0===this.findOrCreateDataForComponent(e.uuid).hidden}},{key:"setComponentHidden",value:function(e,t){var n=this.findOrCreateDataForComponent(e.uuid);if(t)n.hidden=!0;else if(n.hidden){n.hidden=!1;var r=Qt()(this.contextStreamObservers,{identifier:e.uuid});r&&this.handleStreamContextItemMessage(e,r.originalMessage);var a=Qt()(this.streamObservers,{identifier:e.uuid});a&&this.handleStreamItemsMessage(e,a.originalMessage)}}},{key:"jsonForItem",value:function(e,t,n){var r=n===ht.a.RemoteSaved||n===ht.a.LocalSaved||n===ht.a.PreSyncSave,a=(e.getDomainData(rn)||{})[t.getClientDataKey()]||{},i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.serverUpdatedAt,deleted:e.deleted,isMetadataUpdate:r,content:e.content,clientData:a};return this.responseItemsByRemovingPrivateProperties([i],t)[0]}},{key:"sendItemsInReply",value:function(e,t,n,r){var a=this,i=this.findComponent(e);this.log('Component manager send items in reply',i,t,n);var s={},o=t.map(function(e){return a.jsonForItem(e,i,r)});s.items=o,this.replyToMessage(i,n,s)}},{key:"sendContextItemInReply",value:function(e,t,n,r){var a=this.findComponent(e);this.log('Component manager send context item in reply','component:',a,'item: ',t,'originalMessage: ',n);var i={item:this.jsonForItem(t,a,r)};this.replyToMessage(a,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:E.Reply,original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n,r=[E.ComponentRegistered,E.ActivateThemes],a=this.findOrCreateDataForComponent(e.uuid);if(!a.hidden||r.includes(t.action))if(a.window||t.action!==E.Reply){this.log('Component manager send message to component',e,'message: ',t);var i=this.urlForComponent(e);i&&a.window?(i.startsWith('http')||i.startsWith('file')||(i=window.location.href+i),null===(n=a.window)||void 0===n||n.postMessage(this.isMobile?JSON.stringify(t):t,i)):this.alertService.alert("Standard Notes is trying to communicate with ".concat(e.name,", ")+'but an error is occurring. Please restart this extension and try again.')}else this.log('Component has been deallocated in between message send and reply',e,t);else this.log('Component disabled for current item, ignoring messages.',e.name)}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(!t)return null;if(this.isMobile){var n=this.platform===fe.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter(function(t){return t.hosted_url===e||t.legacy_url===e})[0]}},{key:"sessionKeyForComponent",value:function(e){return this.findOrCreateDataForComponent(e.uuid).sessionKey}},{key:"componentForSessionKey",value:function(e){for(var t,n=this,r=function(r){var a=n.componentState[r];if((null===a||void 0===a?void 0:a.sessionKey)===e)return t=n.components.find(function(e){return e.uuid===r}),"break"},a=0,i=Object.keys(this.componentState);a<i.length;a++){if("break"===r(i[a]))break}if(!t)for(var s,o=S(this.handlers);!(s=o()).done;){var c=s.value;if(c.componentForSessionKeyHandler&&(t=c.componentForSessionKeyHandler(e)))break}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log('Component not defined for message, returning',t),void this.alertService.alert("An extension is trying to communicate with Standard Notes, but there is an error establishing a bridge. Please restart the app and try again.");var r=[E.SaveItems,E.AssociateItem,E.DeassociateItem,E.CreateItem,E.CreateItems,E.DeleteItems,E.SetComponentData];if(this.getReadonlyStateForComponent(e).readonly&&r.includes(t.action))this.alertService.alert("The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes."));else{if(t.action===E.StreamItems)this.handleStreamItemsMessage(e,t);else if(t.action===E.StreamContextItem)this.handleStreamContextItemMessage(e,t);else if(t.action===E.SetComponentData)this.handleSetComponentDataMessage(e,t);else if(t.action===E.DeleteItems)this.handleDeleteItemsMessage(e,t);else if(t.action===E.CreateItems||t.action===E.CreateItem)this.handleCreateItemsMessage(e,t);else if(t.action===E.SaveItems)this.handleSaveItemsMessage(e,t);else if(t.action===E.ToggleActivateComponent){var a=this.itemManager.findItem(t.data.uuid);this.handleToggleComponentMessage(a)}else t.action===E.RequestPermissions?this.handleRequestPermissionsMessage(e,t):t.action===E.InstallLocalComponent?this.handleInstallLocalComponentMessage(e,t):t.action===E.DuplicateItem&&this.handleDuplicateItemMessage(e,t);for(var i,s=function(r){r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes(L.ComponentArea.Any))&&n.timeout(function(){r.actionHandler(e,t.action,t.data)})},o=S(this.handlers);!(i=o()).done;){s(i.value)}}}},{key:"responseItemsByRemovingPrivateProperties",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&this.isNativeExtension(t))return e;var r=['autoupdateDisabled','permissions','active'];return n&&(r=r.concat(['hosted_url','local_url'])),e.map(function(e){var t=r.slice();if(n&&e.content_type!==F.a.ServerExtension&&t.push('url'),!e.content||Object(_.A)(e.content))return e;for(var a={},i=0,s=Object.entries(e.content);i<s.length;i++){var o=s[i],c=l(o,2),u=c[0],p=c[1];t.includes(u)||(a[u]=p)}return Zt(Zt({},e),{},{content:a})})}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=t.data.content_types.filter(function(e){return nn.includes(e)}).sort(),a=[{name:E.StreamItems,content_types:r}];this.runWithPermissions(e.uuid,a,function(){Qt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t,contentTypes:r});for(var a,i=[],s=S(r);!(a=s()).done;){var o=a.value;Object(_.o)(i,n.itemManager.nonErroredItemsForContentType(o))}n.sendItemsInReply(e.uuid,i,t)})}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:E.StreamContextItem}];this.runWithPermissions(e.uuid,r,function(){Qt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t});for(var r,a=S(n.handlersForArea(e.area));!(r=a()).done;){var i=r.value;if(i.contextRequestHandler){var s=i.contextRequestHandler(e.uuid);s&&n.sendContextItemInReply(e.uuid,s,t)}}})}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){for(var t,n=[],r=S(this.handlersForArea(e.area));!(t=r()).done;){var a=t.value;if(a.contextRequestHandler){var i=a.contextRequestHandler(e.uuid);i&&n.push(i.uuid)}}return n}},{key:"handlersForArea",value:function(e){return this.handlers.filter(function(t){return t.areas.includes(e)})}},{key:"handleSaveItemsMessage",value:function(e,t){for(var n,r=this,a=t.data.items,i=[],s=this.itemIdsInContextJurisdictionForComponent(e),o=a.slice(),c=S(a.slice());!(n=c()).done;){var u=n.value;if(s.includes(u.uuid)){i.push({name:E.StreamContextItem}),Object(_.M)(o,u);break}}if(o.length>0){var l=$t()(o.map(function(e){return e.content_type})).sort();i.push({name:E.StreamItems,content_types:l})}this.runWithPermissions(e.uuid,i,function(){var n,i,s,o,c,u,l,p,d,h,f,v,y,g,m;return b.async(function(k){for(;;)switch(k.prev=k.next){case 0:a=r.responseItemsByRemovingPrivateProperties(a,e,!0),n=Object(Ke.b)(a),i=r.itemManager.findItems(n,!0),s=0,o=0,c=S(i);case 6:if((u=c()).done){k.next=13;break}if(l=u.value){k.next=10;break}return k.abrupt("continue",11);case 10:l.locked&&(at()(a,{uuid:l.uuid}),s++,l.content_type===F.a.Note&&o++);case 11:k.next=6;break;case 13:if(1!==o){k.next=18;break}return r.alertService.alert('The note you are attempting to save has editing disabled','Note has Editing Disabled'),k.abrupt("return");case 18:if(!(s>0)){k.next=23;break}return p=1===s?'item':o===s?'notes':'items',d=1===s?'has':'have',r.alertService.alert("".concat(s," ").concat(p," you are attempting to save ").concat(d," editing disabled."),'Items have Editing Disabled'),k.abrupt("return");case 23:h=a.map(function(e){return Object(Ee.f)(e,ht.a.ComponentRetrieved)}),f=S(h);case 25:if((v=f()).done){k.next=38;break}if(y=v.value,g=r.itemManager.findItem(y.uuid)){k.next=34;break}return m=nt(y),k.next=32,b.awrap(r.itemManager.insertItem(m));case 32:k.next=36;break;case 34:if(y.content_type===g.content_type){k.next=36;break}throw Error('Extension is trying to modify content type of item.');case 36:k.next=25;break;case 38:return k.next=40,b.awrap(r.itemManager.changeItems(n,function(t){var n=Object(_.O)(h,{uuid:t.getUuid()});t.mergePayload(n);var r=Object(_.O)(a,{uuid:t.getUuid()});if(r.clientData){var i=Object(_.a)(t.getItem().getDomainData(rn)||{});i[e.getClientDataKey()]=r.clientData,t.setDomainData(i,rn)}},T.c.UserInteraction,ht.a.ComponentRetrieved,e.uuid));case 40:r.syncService.sync().then(function(){var n=w({},t);n.action=E.SaveSuccess,r.replyToMessage(e,t,{}),r.handleMessage(e,n)}).catch(function(){var n=w({},t);n.action=E.SaveError,r.replyToMessage(e,t,{error:E.SaveError}),r.handleMessage(e,n)});case 41:case"end":return k.stop()}},null,null,null,Promise)})}},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,a=this.itemManager.findItem(r.uuid),i=[{name:E.StreamItems,content_types:[a.content_type]}];this.runWithPermissions(e.uuid,i,function(){var r;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(n.itemManager.duplicateItem(a.uuid));case 2:r=i.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(r,e)});case 5:case"end":return i.stop()}},null,null,null,Promise)})}},{key:"handleCreateItemsMessage",value:function(e,t){var n=this,r=t.data.item?[t.data.item]:t.data.items,a=$t()(r.map(function(e){return e.content_type})),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:r=n.responseItemsByRemovingPrivateProperties(r,e),a=[],i=function(t){var r,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(t.uuid){o.next=4;break}return o.next=3,b.awrap(I.GenerateUuid());case 3:t.uuid=o.sent;case 4:return r=Object(Ee.f)(t,ht.a.ComponentCreated),i=nt(r),o.next=8,b.awrap(n.itemManager.insertItem(i));case 8:return s=o.sent,o.next=11,b.awrap(n.itemManager.changeItem(s.uuid,function(n){if(t.clientData){var r=Object(_.a)(s.getDomainData(rn)||{});r[e.getClientDataKey()]=t.clientData,n.setDomainData(r,rn)}},T.c.UserInteraction,ht.a.ComponentCreated,e.uuid));case 11:a.push(s);case 12:case"end":return o.stop()}},null,null,null,Promise)},s=S(r);case 4:if((o=s()).done){l.next=10;break}return c=o.value,l.next=8,b.awrap(i(c));case 8:l.next=4;break;case 10:n.syncService.sync(),u=t.action===E.CreateItem?{item:n.jsonForItem(a[0],e)}:{items:a.map(function(t){return n.jsonForItem(t,e)})},n.replyToMessage(e,t,u);case 13:case"end":return l.stop()}},null,null,null,Promise)})}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=t.data.items.filter(function(e){return nn.includes(e.content_type)}),a=$t()(r.map(function(e){return e.content_type})).sort(),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return i=1===(a=r).length?'item':'items',s=null,p.next=5,b.awrap(n.alertService.confirm("Are you sure you want to delete ".concat(a.length," ").concat(i,"?")));case 5:if(!p.sent){p.next=25;break}o=S(a);case 8:if((c=o()).done){p.next=21;break}if(u=c.value,l=n.itemManager.findItem(u.uuid)){p.next=14;break}return n.alertService.alert('The item you are trying to delete cannot be found.'),p.abrupt("continue",19);case 14:if(![F.a.Component,F.a.Theme].includes(l.content_type)){p.next=17;break}return p.next=17,b.awrap(n.deactivateComponent(l.uuid));case 17:return p.next=19,b.awrap(n.itemManager.setItemToBeDeleted(l.uuid,ht.a.ComponentRetrieved));case 19:p.next=8;break;case 21:n.syncService.sync(),s={deleted:!0},p.next=26;break;case 25:s={deleted:!1};case 26:n.replyToMessage(e,t,s);case 27:case"end":return p.stop()}},null,null,null,Promise)})}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,t.data.permissions,function(){n.replyToMessage(e,t,{approved:!0})})}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,[],function(){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(n.itemManager.changeComponent(e.uuid,function(e){e.componentData=t.data.componentData}));case 2:n.syncService.sync();case 3:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"handleToggleComponentMessage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.toggleComponent(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"toggleComponent",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.area!==L.ComponentArea.Modal){s.next=4;break}this.openModalComponent(e),s.next=29;break;case 4:if(!e.active){s.next=9;break}return s.next=7,b.awrap(this.deactivateComponent(e.uuid));case 7:s.next=29;break;case 9:if(e.content_type!==F.a.Theme){s.next=27;break}return t=e,n=this.getActiveThemes(),s.next=14,b.awrap(this.activateComponent(e.uuid));case 14:if(t.isLayerable()){s.next=25;break}return s.next=17,b.awrap(Object(_.P)(10));case 17:r=S(n);case 18:if((a=r()).done){s.next=25;break}if(!(i=a.value)||i.isLayerable()){s.next=23;break}return s.next=23,b.awrap(this.deactivateComponent(i.uuid));case 23:s.next=18;break;case 25:s.next=29;break;case 27:return s.next=29,b.awrap(this.activateComponent(e.uuid));case 29:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.itemManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){var r=this.findComponent(e);t=Object(_.a)(t);for(var a,i=r.permissions,s=function(e){var n=i.find(function(t){return t.name===e.name});if(!n)return"continue";var r=e.content_types;if(!r)return Object(_.p)(t,e),"continue";for(var a,s=S(n.content_types);!(a=s()).done;){var o=a.value;Object(_.M)(r,o)}0===r.length&&Object(_.p)(t,e)},o=S(t.slice());!(a=o()).done;)s(a.value);t.length>0?this.promptForPermissions(r,t,function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:e&&n();case 1:case"end":return t.stop()}},null,null,null,Promise)}):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,a={component:e,permissions:t,permissionsString:this.permissionsStringForPermissions(t,e),actionBlock:n,callback:function(n){var i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(i=r.findComponent(e.uuid),!n){p.next=9;break}for(r.log('Changing component to expand permissions',e),s=Object(_.a)(i.permissions),o=function(e){var t=s.find(function(t){return t.name===e.name});if(t){var n=t.content_types||[];t.content_types=$t()(n.concat(e.content_types))}else s.push(e)},c=S(t);!(u=c()).done;)l=u.value,o(l);return p.next=8,b.awrap(r.itemManager.changeItem(e.uuid,function(e){e.permissions=s}));case 8:r.syncService.sync();case 9:r.permissionDialogs=r.permissionDialogs.filter(function(r){if(r===a)return r.actionBlock&&r.actionBlock(n),!1;var i;return!!(r.component!==e||r.permissions!==t&&(i=t,r.permissions.some(function(e){return!i.find(function(t){return JSON.stringify(t)===JSON.stringify(e)})})))||(n&&r.actionBlock&&r.actionBlock(n),!1)}),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 11:case"end":return p.stop()}},null,null,null,Promise)}},i=Qt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(a),i?this.log('Existing dialog, not presenting.'):this.presentPermissionsDialog(a)}},{key:"presentPermissionsDialog",value:function(e){throw'Must override SNComponentManager.presentPermissionsDialog'}},{key:"openModalComponent",value:function(e){throw'Must override SNComponentManager.openModalComponent'}},{key:"registerHandler",value:function(e){var t=this;return this.handlers.push(e),function(){var n=Qt()(t.handlers,{identifier:e.identifier});n?Object(_.M)(t.handlers,n):t.log('Attempting to deregister non-existing handler')}}},{key:"findOrCreateDataForComponent",value:function(e){var t=this.componentState[e];return t||(t={},this.componentState[e]=t),t}},{key:"setReadonlyStateForComponent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.findOrCreateDataForComponent(e.uuid);r.readonly=t,r.lockReadonly=n}},{key:"getReadonlyStateForComponent",value:function(e){var t=this.findOrCreateDataForComponent(e.uuid);return{readonly:t.readonly,lockReadonly:t.lockReadonly}}},{key:"registerComponentWindow",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return(n=this.findOrCreateDataForComponent(e.uuid)).window===t&&this.log('Web > componentManager','attempting to re-register same component window.'),this.log('Web > componentManager > registerComponentWindow','component: ',e,'window: ',t),n.window=t,r.next=6,b.awrap(I.GenerateUuid());case 6:n.sessionKey=r.sent,this.sendMessageToComponent(e,{action:E.ComponentRegistered,sessionKey:n.sessionKey,componentData:e.componentData,data:{uuid:e.uuid,environment:(s=this.environment,o=void 0,(g(o={},he.Web,'web'),g(o,he.Desktop,'desktop'),g(o,he.Mobile,'mobile'),o)[s]),platform:(a=this.platform,i=void 0,(g(i={},fe.MacWeb,'mac-web'),g(i,fe.MacDesktop,'mac-desktop'),g(i,fe.LinuxWeb,'linux-web'),g(i,fe.LinuxDesktop,'linux-desktop'),g(i,fe.WindowsWeb,'windows-web'),g(i,fe.WindowsDesktop,'windows-desktop'),g(i,fe.Ios,'ios'),g(i,fe.Android,'android'),i)[a]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(e),this.desktopManager&&this.desktopManager.notifyComponentActivation(e);case 10:case"end":return r.stop()}var a,i,s,o},null,this,null,Promise)}},{key:"activateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Activating component',e),(t=this.findComponent(e)).active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!0}));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"onComponentIframeDestroyed",value:function(e){this.deregisterComponent(e)}},{key:"deregisterComponent",value:function(e){this.log('Degregistering component',e),delete this.componentState[e],this.streamObservers=this.streamObservers.filter(function(t){return t.componentUuid!==e}),this.contextStreamObservers=this.contextStreamObservers.filter(function(t){return t.componentUuid!==e});var t=this.findComponent(e);(null===t||void 0===t?void 0:t.area)===L.ComponentArea.Themes&&this.postActiveThemesToAllComponents()}},{key:"deactivateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Deactivating component',e),null===(t=this.findComponent(e))||void 0===t||!t.active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!1}));case 5:this.findOrCreateDataForComponent(e).sessionKey=void 0,this.deregisterComponent(e);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deleteComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isComponentActive",value:function(e){return e.active}},{key:"allComponentIframes",value:function(){return this.isMobile?[]:Array.from(document.getElementsByTagName('iframe'))}},{key:"iframeForComponent",value:function(e){for(var t,n=S(this.allComponentIframes());!(t=n()).done;){var r=t.value;if(r.dataset.componentId===e)return r}}},{key:"handleSetSizeEvent",value:function(e,t){var n=function(e,n){var r=Object(_.A)(n.width)?n.width:"".concat(t.width,"px"),a=Object(_.A)(n.height)?n.height:"".concat(t.height,"px");e&&e.setAttribute('style',"width:".concat(r,"; height:").concat(a,";"))};if(e.area===L.ComponentArea.Rooms||e.area===L.ComponentArea.Modal){var r=e.area===L.ComponentArea.Rooms?'inner':'outer',a=document.getElementById("component-content-".concat(r,"-").concat(e.uuid));a&&n(a,t)}else{var i=this.iframeForComponent(e.uuid);if(!i)return;if(n(i,t),e.area===L.ComponentArea.EditorStack){var s=i.parentElement;s&&n(s,t)}}}},{key:"editorForNote",value:function(e){for(var t,n,r=S(this.componentsForArea(L.ComponentArea.Editor));!(t=r()).done;){var a=t.value;if(a.isExplicitlyEnabledForItem(e.uuid))return a}return this.isMobile?e.mobilePrefersPlainEditor||(n=this.getDefaultEditor()):e.prefersPlainEditor||(n=this.getDefaultEditor()),n&&!n.isExplicitlyDisabledForItem(e.uuid)?n:void 0}},{key:"getDefaultEditor",value:function(){var e=this.componentsForArea(L.ComponentArea.Editor);return this.isMobile?e.filter(function(e){return e.isMobileDefault})[0]:e.filter(function(e){return e.isDefaultEditor()})[0]}},{key:"permissionsStringForPermissions",value:function(e,t){if(0===e.length)return'.';var n=[],r=[];return e.forEach(function(e){switch(e.name){case E.StreamItems:if(!e.content_types)return;e.content_types.forEach(function(e){var t=Object(F.c)(e);t?n.push("".concat(t,"s")):n.push("items of type ".concat(e))});break;case E.StreamContextItem:var a,i=(g(a={},L.ComponentArea.EditorStack,'working note'),g(a,L.ComponentArea.NoteTags,'working note'),g(a,L.ComponentArea.Editor,'working note'),a);r.push(i[t.area])}}),n=$t()(n),r=$t()(r),0===n.length&&0===r.length?'.':n.concat(r).join(', ')+'.'}},{key:"isDesktop",get:function(){return this.environment===he.Desktop}},{key:"isMobile",get:function(){return this.environment===he.Mobile}},{key:"components",get:function(){var e=this.itemManager.getDisplayableItems(F.a.Component),t=this.itemManager.getDisplayableItems(F.a.Theme);return e.concat(t)}}]),n})(R.a),sn=(function(e){d(n,e);var t=k(n);function n(){var e;return v(this,n),(e=t.call(this)).changeObservers=[],e.emitQueue=[],e.overwriteProtection=[F.a.ItemsKey],e.collection=new mt,e}return y(n,[{key:"getMasterCollection",value:function(){return bt.FromCollection(this.collection)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.changeObservers.length=0,this.resetState()}},{key:"resetState",value:function(){this.collection=new mt}},{key:"find",value:function(e){return this.collection.findAll(e)}},{key:"emitCollection",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.emitPayloads(e.all(),e.source,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"emitPayload",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.emitPayloads([e],t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitPayloads",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return 0===e.length&&console.warn('Attempting to emit 0 payloads.'),a.abrupt("return",new Promise(function(a){r.emitQueue.push({payloads:e,source:t,sourceKey:n,resolve:a}),1===r.emitQueue.length&&r.popQueue()}));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"popQueue",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=this.emitQueue[0],t=this.mergePayloadsOntoMaster(e.payloads),n=t.changed,r=t.inserted,a=t.discarded,i=t.ignored,this.notifyChangeObservers(n,r,a,i,e.source,e.sourceKey),Object(_.M)(this.emitQueue,e),e.resolve(n.concat(r,a)),this.emitQueue.length>0&&this.popQueue();case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"mergePayloadsOntoMaster",value:function(e){for(var t,n=[],r=[],a=[],i=[],s=S(e);!(t=s()).done;){var o=t.value;if(o.uuid&&o.content_type){var c=this.collection.find(o.uuid);if(o.errorDecrypting&&c&&!c.errorDecrypting&&this.overwriteProtection.includes(o.content_type))i.push(o);else{var u=c?Object(Ee.g)(c,o):o;u.discardable?(this.collection.discard(u),a.push(u)):(this.collection.set(u),c?n.push(u):r.push(u))}}else console.error('Payload is corrupt:',o)}return{changed:n,inserted:r,discarded:a,ignored:i}}},{key:"addObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var a={types:e,priority:r,callback:t};return this.changeObservers.push(a),function(){Object(_.M)(n.changeObservers,a)}}},{key:"notifyChangeObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return t.includes(F.a.Any)?e.slice():e.slice().filter(function(e){return t.includes(e.content_type)})},c=S(this.changeObservers.slice().sort(function(e,t){return e.priority<t.priority?-1:1}));!(s=c()).done;){var u=s.value;u.callback(o(e,u.types),o(t,u.types),o(n,u.types),o(r,u.types),a,i)}}},{key:"importPayloads",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new Dt(this.getMasterCollection(),bt.WithPayloads(e,ht.a.FileImport),void 0),r.next=3,b.awrap(t.resultingCollection());case 3:return n=r.sent,r.next=6,b.awrap(this.emitCollection(n));case 6:return r.abrupt("return",Object(Ke.b)(n.payloads));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removePayloadLocally",value:function(e){this.collection.discard(e)}}]),n})(R.a),on=n(9),cn=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).itemManager=e,a.syncService=r,a.resolveQueue=[],a.registeredPredicates=[],a.itemManager=e,a.syncService=r,a.addObservers(),a}return y(n,[{key:"deinit",value:function(){this.syncService=void 0,this.itemManager=void 0,this.resolveQueue.length=0,this.registeredPredicates.length=0,this.removeItemObserver(),this.removeItemObserver=void 0,this.removeSyncObserver(),this.removeSyncObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"popResolveQueue",value:function(){var e=this.resolveQueue.slice();return this.resolveQueue=[],e}},{key:"addObservers",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n){if(t.length>0){var r=t.filter(function(e){return e.errorDecryptingValueChanged});r.length>0&&(e.resolveQueue=e.resolveQueue.concat(r))}n.length>0&&(e.resolveQueue=e.resolveQueue.concat(n))}),this.removeSyncObserver=this.syncService.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==on.a.DownloadFirstSyncCompleted&&t!==on.a.FullSyncCompleted){n.next=3;break}return n.next=3,b.awrap(e.resolveSingletonsForItems(e.popResolveQueue(),t));case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"registerPredicate",value:function(e){this.registeredPredicates.push(e)}},{key:"validItemsMatchingPredicate",value:function(e){return this.itemManager.itemsMatchingPredicate(e).filter(function(e){return!e.errorDecrypting})}},{key:"resolveSingletonsForItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=this;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:n=function(e){for(var t,n=S(p.registeredPredicates);!(t=n()).done;){var r=t.value;if(e.satisfiesPredicate(r))return p.validItemsMatchingPredicate(r)}},r=function(e){return e.isSingleton?p.validItemsMatchingPredicate(e.singletonPredicate):null},a=function(e){var t=r(e);return t&&t.length>0?t:n(e)},i=[],s=S(e);case 5:if((o=s()).done){d.next=17;break}if(c=o.value,!i.includes(c)){d.next=9;break}return d.abrupt("continue",15);case 9:if(u=a(c),Object(_.o)(i,u||[]),u&&!(u.length<=1)){d.next=13;break}return d.abrupt("continue",15);case 13:return d.next=15,b.awrap(this.handleStrategy(u,c.singletonStrategy));case 15:d.next=5;break;case 17:if(!(i.length>0&&t===on.a.FullSyncCompleted)){d.next=20;break}return d.next=20,b.awrap(null===(l=this.syncService)||void 0===l?void 0:l.sync());case 20:case"end":return d.stop()}},null,this,null,Promise)}},{key:"handleStrategy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t===T.e.KeepEarliest){a.next=2;break}throw'Unhandled singleton strategy';case 2:return n=e.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at<t.created_at?-1:1}),r=Object(_.d)(n,0),a.next=6,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(r)));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"findSingleton",value:function(e){var t=this.validItemsMatchingPredicate(e);if(t.length>0)return t[0]}},{key:"findOrCreateSingleton",value:function(e,t,n){var r,a,i,s,o,c,u,l=this;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(r=this.findSingleton(e),Object(_.w)(r)){p.next=3;break}return p.abrupt("return",r);case 3:if(this.syncService.getLastSyncDate()){p.next=13;break}return i=this.itemManager.addObserver(t,function(t,n){if(n.length>0){var r=l.itemManager.subItemsMatchingPredicates(n,[e]);r.length>0&&(a=r[0])}}),p.next=7,b.awrap(this.syncService.sync());case 7:if(i(),!a){p.next=10;break}return p.abrupt("return",a);case 10:if(!((s=this.validItemsMatchingPredicate(e)).length>0)){p.next=13;break}return p.abrupt("return",s[0]);case 13:if(!(o=this.itemManager.itemsMatchingPredicate(e).filter(function(e){return e.errorDecrypting})).length){p.next=17;break}return p.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(o)));case 17:return p.t0=Object(Ee.e),p.next=20,b.awrap(I.GenerateUuid());case 20:return p.t1=p.sent,p.t2=t,p.t3=n,p.t4=new Date,p.t5={uuid:p.t1,content_type:p.t2,content:p.t3,dirty:!0,dirtiedDate:p.t4},c=(0,p.t0)(p.t5),p.next=28,b.awrap(this.itemManager.emitItemFromPayload(c));case 28:return u=p.sent,this.syncService.sync(),p.abrupt("return",u);case 31:case"end":return p.stop()}},null,this,null,Promise)}}]),n})(R.a);function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach(function(t){pn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dn,hn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c){var u;return v(this,n),(u=t.call(this)).itemManager=e,u.alertService=r,u.previousPasswords=[],u.itemManager=e,u.alertService=r,u.deviceInterface=a,u.httpService=i,u.payloadManager=s,u.protocolService=o,u.syncService=c,u.previousPasswords=[],u}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.alertService=void 0,this.deviceInterface=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.syncService=void 0,this.previousPasswords.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"getExtensions",value:function(){return this.itemManager.nonErroredItemsForContentType(F.a.ActionsExtension)}},{key:"extensionsInContextOfItem",value:function(e){return this.getExtensions().filter(function(t){return t.supported_types.includes(e.content_type)||t.actionsWithContextForItem(e).length>0})}},{key:"loadExtensionInContextOfItem",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n={content_type:t.content_type,item_uuid:t.uuid},u.next=3,b.awrap(this.httpService.getAbsolute(e.url,n).catch(function(e){return console.error('Error loading extension',e),null}));case 3:if(r=u.sent){u.next=6;break}return u.abrupt("return");case 6:return a=r.description||e.description,i=r.supported_types||e.supported_types,s=r.actions?r.actions.map(function(e){return new ae(e)}):[],(o=new se(e,T.c.UserInteraction)).deprecation=r.deprecation,o.description=a,o.supported_types=i,o.actions=s,c=o.getResult(),u.abrupt("return",nt(c));case 16:case"end":return u.stop()}},null,this,null,Promise)}},{key:"runAction",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=e.verb,a.next='get'===a.t0?3:'render'===a.t0?7:'show'===a.t0?11:'post'===a.t0?15:19;break;case 3:return a.next=5,b.awrap(this.handleGetAction(e,n));case 5:return r=a.sent,a.abrupt("break",20);case 7:return a.next=9,b.awrap(this.handleRenderAction(e,n));case 9:return r=a.sent,a.abrupt("break",20);case 11:return a.next=13,b.awrap(this.handleShowAction(e));case 13:return r=a.sent,a.abrupt("break",20);case 15:return a.next=17,b.awrap(this.handlePostAction(e,t));case 17:return r=a.sent,a.abrupt("break",20);case 19:return a.abrupt("break",20);case 20:return a.abrupt("return",r);case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleGetAction",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.alertService.confirm("Are you sure you want to replace the current note contents with this action's results?"));case 2:if(!n.sent){n.next=7;break}return n.abrupt("return",this.runConfirmedGetAction(e,t));case 7:return n.abrupt("return",{error:{status:1,message:'Action canceled by user.'}});case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"runConfirmedGetAction",value:function(e,t){var n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.httpService.getAbsolute(e.url).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return a.alertService.alert(t.message),{error:t}}));case 2:if(!(n=i.sent).error){i.next=5;break}return i.abrupt("return",n);case 5:return i.next=7,b.awrap(this.payloadByDecryptingResponse(n,t));case 7:return r=i.sent,i.next=10,b.awrap(this.payloadManager.emitPayload(Object(Ee.b)(r,{dirty:!0,dirtiedDate:new Date}),ht.a.RemoteActionRetrieved));case 10:return this.syncService.sync(),i.abrupt("return",ln(ln({},n),{},{item:n.item}));case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleRenderAction",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.httpService.getAbsolute(e.url).then(function(e){var n,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(r.payloadByDecryptingResponse(e,t));case 2:if(!(n=i.sent)){i.next=6;break}return a=nt(n),i.abrupt("return",ln(ln({},e),{},{item:a}));case 6:case"end":return i.stop()}},null,null,null,Promise)}).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return r.alertService.alert(t.message),{error:t}}));case 2:return n=a.sent,a.abrupt("return",n);case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingResponse",value:function(e,t,n){var r,a,i,s,o,c,u,l,p,d,h,f=arguments;return b.async(function(v){for(;;)switch(v.prev=v.next){case 0:return r=f.length>3&&void 0!==f[3]?f[3]:[],a=Object(Ee.e)(e.item),v.next=4,b.awrap(this.protocolService.payloadByDecryptingPayload(a,n));case 4:if((i=v.sent).errorDecrypting){v.next=7;break}return v.abrupt("return",i);case 7:if(s=e.keyParams||e.auth_params){v.next=11;break}return this.alertService.alert("We were unable to decrypt this revision using your current keys, and this revision is missing metadata that would allow us to try different keys to decrypt it. This can likely be fixed with some manual intervention. Please email hello@standardnotes.org for assistance."),v.abrupt("return",void 0);case 11:o=this.protocolService.createKeyParams(s),c=S(this.previousPasswords);case 13:if((u=c()).done){v.next=30;break}if(l=u.value,!r.includes(l)){v.next=17;break}return v.abrupt("continue",28);case 17:return r.push(l),v.next=20,b.awrap(this.protocolService.computeRootKey(l,o));case 20:if(p=v.sent){v.next=23;break}return v.abrupt("continue",28);case 23:return v.next=25,b.awrap(this.payloadByDecryptingResponse(e,t,p,r));case 25:if(!(d=v.sent)){v.next=28;break}return v.abrupt("return",d);case 28:v.next=13;break;case 30:return v.next=32,b.awrap(t());case 32:if(h=v.sent,!this.previousPasswords.includes(h)){v.next=35;break}return v.abrupt("return",void 0);case 35:return this.previousPasswords.push(h),v.abrupt("return",this.payloadByDecryptingResponse(e,t,n));case 37:case"end":return v.stop()}},null,this,null,Promise)}},{key:"handlePostAction",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=e.access_type===q.Decrypted,s.next=3,b.awrap(this.outgoingPayloadForItem(t,n));case 3:return r=s.sent,a={items:[r]},s.abrupt("return",this.httpService.postAbsolute(e.url,a).then(function(e){return e}).catch(function(e){return console.error('Action error response:',e),i.alertService.alert('An issue occurred while processing this action. Please try again.'),e}));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleShowAction",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.deviceInterface.openUrl(e.url),t.abrupt("return",{});case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"outgoingPayloadForItem",value:function(e){var t,n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=a.length>1&&void 0!==a[1]&&a[1],n=t?Re.b.FileDecrypted:Re.b.FileEncrypted,i.next=4,b.awrap(this.protocolService.payloadByEncryptingPayload(e.payloadRepresentation(),n));case 4:return r=i.sent,i.abrupt("return",r.ejected());case 6:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),fn=(function(){function e(t,n,r){v(this,e),this.deviceInterface=t,this.identifier=n,this.environment=r}return y(e,null,[{key:"version",value:function(){throw Error('Must override')}}]),e})(),vn=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getJsonParsedRawStorageValue(D.AllAccountKeyParamsKey));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getRawKeychainValue());case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getRawStorageValue('mk'));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!!Pe(this.environment)}}],[{key:"version",value:function(){return"1.0.0"}}]),n})(),yn=(function(){function e(t){v(this,e),this.services=t,this.stageHandlers={},this.registerStageHandlers()}return y(e,[{key:"registerStageHandler",value:function(e,t){this.stageHandlers[e]=t}},{key:"markDone",value:function(){var e;null===(e=this.onDoneHandler)||void 0===e||e.call(this),this.onDoneHandler=void 0}},{key:"promptForPasscodeUntilCorrect",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new ye([new ge(te.None)],ne.Migration,!1),r.abrupt("return",new Promise(function(r){n.services.challengeService.addChallengeObserver(t,{onNonvalidatedSubmit:function(a){var i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return i=a.values[0],s=i.value,o.next=4,b.awrap(e(s));case 4:o.sent?(n.services.challengeService.completeChallenge(t),r(s)):n.services.challengeService.setValidationStatusForChallenge(t,i,!1);case 6:case"end":return o.stop()}},null,null,null,Promise)}}),n.services.challengeService.promptForChallengeResponse(t)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}},{key:"onDone",value:function(e){this.onDoneHandler=e}},{key:"handleStage",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t=this.stageHandlers[e])){n.next=4;break}return n.next=4,b.awrap(t());case 4:case"end":return n.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){throw'Must override'}}]),e})();!(function(e){e.CreatedAt="created_at",e.UpdatedAt="userModifiedDate",e.Title="title"})(dn||(dn={}));var gn=(function(e){d(n,mt);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).displaySortBy={},e.displayFilter={},e.filteredMap={},e.sortedMap={},e}return y(n,[{key:"set",value:function(e){e=Object(_.W)(Array.isArray(e)?e:[e],'uuid'),p(f(n.prototype),"set",this).call(this,e),this.filterSortElements(e)}},{key:"discard",value:function(e){e=Array.isArray(e)?e:[e],p(f(n.prototype),"discard",this).call(this,e),this.filterSortElements(e)}},{key:"setDisplayOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn.CreatedAt,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc',r=arguments.length>3?arguments[3]:void 0,a=this.displaySortBy[e],i=this.displayFilter[e];if(!a||a.key!==t||a.dir!==n||i||r){this.displaySortBy[e]=t?{key:t,dir:n}:void 0,this.displayFilter[e]=r,this.filteredMap[e]={},this.sortedMap[e]=[];var s=this.all(e);s.length>0&&this.filterSortElements(s)}}},{key:"displayElements",value:function(e){var t=this.sortedMap[e];if(!t)throw Error("Attempting to access display elements for\n        non-configured content type ".concat(e));return t.slice()}},{key:"filterSortElements",value:function(e){if(0!==Object.keys(this.displaySortBy).length){for(var t,n=new Set,r=S(e);!(t=r()).done;){var a=t.value,i=a.content_type,s=this.displaySortBy[i];if(s){var o=this.displayFilter[i],c=this.filteredMap[i],u=this.sortedMap[i],l=c[a.uuid],p=Object(_.w)(l)?void 0:u[l];if(!(a.deleted||!this.map[a.uuid])&&(!o||o(a)))if(Object(_.w)(p))u.push(a),n.add(i);else{var d=p.errorDecrypting?void 0:p[s.key],h=a[s.key];u[l]=a;var f=p.pinned!==a.pinned;Object(_.g)(d,h)&&!f||n.add(i)}else Object(_.w)(l)||(delete c[a.uuid],u[l]=void 0,n.add(i))}}for(var v,y=S(n.values());!(v=y()).done;){var g=v.value;this.resortContentType(g)}}}},{key:"resortContentType",value:function(e){for(var t,n=this.sortedMap[e],r=this.displaySortBy[e],a=this.filteredMap[e],i=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t)return-1;if(!n)return 1;if(!a){if(t.pinned&&n.pinned)return e(t,n,!0);if(t.pinned)return-1;if(n.pinned)return 1}var i=t[r.key]||'',s=n[r.key]||'',o=1;return'asc'===r.dir&&(o*=-1),r.key===dn.Title?o*i.localeCompare(s,'en',{numeric:!0}):i>s?-1*o:i<s?1*o:0},s=[],o=0,c=S(n.sort(function(e,t){return i(e,t)}));!(t=c()).done;){var u=t.value;u&&(s.push(u),a[u.uuid]=o,o++)}this.sortedMap[e]=s}}]),n})();function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(n),!0).forEach(function(t){wn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=(function(e){d(n,yn);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).legacyReader=new vn(r.services.deviceInterface,r.services.identifier,r.services.environment),r}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Se(e.services.environment)){t.next=5;break}return t.next=3,b.awrap(e.migrateStorageStructureForWebDesktop());case 3:t.next=8;break;case 5:if(!Pe(e.services.environment)){t.next=8;break}return t.next=8,b.awrap(e.migrateStorageStructureForMobile());case 8:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.StorageDecrypted_09,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.migrateArbitraryRawStorageToManagedStorageAllPlatforms());case 2:if(!Pe(e.services.environment)){t.next=5;break}return t.next=5,b.awrap(e.migrateMobilePreferences());case 5:return t.next=7,b.awrap(e.migrateSessionStorage());case 7:return t.next=9,b.awrap(e.deleteLegacyStorageValues());case 9:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.LoadingDatabase_11,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createDefaultItemsKeyForAllPlatforms());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"migrateStorageStructureForWebDesktop",value:function(){var e,t,n,r,a,i,s,c,u,l,p,d,h,f,v,y,m,w,k,x,S;return b.async(function(P){for(;;)switch(P.prev=P.next){case 0:return t=this.services.deviceInterface,g(e={},_e.Wrapped,{}),g(e,_e.Unwrapped,{}),g(e,_e.Nonwrapped,{}),n=e,P.next=4,b.awrap(this.legacyReader.getAccountKeyParams());case 4:return(r=P.sent)&&(n.nonwrapped[o.RootKeyParams]=r),P.next=8,b.awrap(t.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 8:if(!(a=P.sent)){P.next=37;break}return i=Object(Ee.e)(a),P.next=13,b.awrap(this.webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage(i));case 13:if(s=P.sent,c=s.key,u=s.decryptedStoragePayload,l=s.keyParams,n.nonwrapped[o.RootKeyWrapperKeyParams]=l.getPortableValue(),p=Object(_.a)(u.contentObject.storage),d=Object(_.E)(p),h=d[D.AllAccountKeyParamsKey],n.nonwrapped[o.RootKeyParams]=h,f=c,!!Object(_.w)(d.mk)){P.next=32;break}return P.next=27,b.awrap(this.webDesktopHelperExtractAndWrapAccountKeysFromValueStore(c,h,d));case 27:v=P.sent,y=v.accountKey,m=v.wrappedKey,f=y,n.nonwrapped[o.WrappedRootKey]=m;case 32:return P.next=34,b.awrap(this.webDesktopHelperEncryptStorage(f,u,d));case 34:n.wrapped=P.sent,P.next=55;break;case 37:return P.next=39,b.awrap(this.services.deviceInterface.getRawStorageValue('ak'));case 39:return w=P.sent,P.next=42,b.awrap(this.services.deviceInterface.getRawStorageValue('mk'));case 42:if(k=P.sent,!w&&!k){P.next=55;break}if(P.t0=null===r||void 0===r?void 0:r.version,P.t0){P.next=49;break}return P.next=48,b.awrap(this.getFallbackRootKeyVersion());case 48:P.t0=P.sent;case 49:return x=P.t0,P.next=52,b.awrap(Ve.Create({masterKey:k,dataAuthenticationKey:w,version:x,keyParams:r}));case 52:return S=P.sent,P.next=55,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(S.getKeychainValue(),this.services.identifier));case 55:return P.next=57,b.awrap(this.allPlatformHelperSetStorageStructure(n));case 57:case"end":return P.stop()}},null,this,null,Promise)}},{key:"allPlatformHelperSetStorageStructure",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Ie.defaultValuesObject(e.wrapped,e.unwrapped,e.nonwrapped))[_e.Unwrapped]=void 0,n.next=4,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.StorageObject),JSON.stringify(t)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.WebPasscodeParamsKey));case 2:return t=s.sent,n=this.services.protocolService.createKeyParams(t),s.next=6,b.awrap(this.promptForPasscodeUntilCorrect(function(t){return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(i.services.protocolService.computeRootKey(t,n));case 2:return a=s.sent,s.next=5,b.awrap(i.services.protocolService.payloadByDecryptingPayload(e,a));case 5:return r=s.sent,s.abrupt("return",!r.errorDecrypting);case 7:case"end":return s.stop()}},null,null,null,Promise)}));case 6:return s.abrupt("return",{decryptedStoragePayload:r,key:a,keyParams:n});case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperExtractAndWrapAccountKeysFromValueStore",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.t0=null===t||void 0===t?void 0:t.version,c.t0){c.next=5;break}return c.next=4,b.awrap(this.getFallbackRootKeyVersion());case 4:c.t0=c.sent;case 5:return a=c.t0,c.next=8,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:a,keyParams:t}));case 8:if(i=c.sent,delete n.mk,delete n.pw,delete n.ak,s=Object(Ee.e)(i),!e){c.next=17;break}return c.next=16,b.awrap(this.services.protocolService.payloadByEncryptingPayload(s,Re.b.LocalStorageEncrypted,e));case 16:o=c.sent;case 17:return c.abrupt("return",{accountKey:i,wrappedKey:null===(r=o)||void 0===r?void 0:r.ejected()});case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperEncryptStorage",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.services.protocolService.payloadByEncryptingPayload(Object(Ee.b)(t,{content_type:F.a.EncryptedStorage,content:n}),Re.b.LocalStoragePreferEncrypted,e));case 2:return r=a.sent,a.abrupt("return",r.ejected());case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"migrateStorageStructureForMobile",value:function(){var e,t,n,r,a,i,s,u,l,p,d,h,f,v,y,m,w,k,x,S,P,O,C,E,R=this;return b.async(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,b.awrap(this.services.deviceInterface.getRawKeychainValue());case 2:return n=M.sent,M.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileWrappedRootKeyKey));case 5:if(M.t0=M.sent,M.t0){M.next=8;break}M.t0=null===n||void 0===n?void 0:n.encryptedAccountKeys;case 8:return r=M.t0,M.next=11,b.awrap(this.legacyReader.getAccountKeyParams());case 11:return a=M.sent,M.next=14,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 14:return i=M.sent,M.next=17,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(c.MobileFirstRun));case 17:return s=M.sent,g(t={},_e.Nonwrapped,(g(e={},o.WrappedRootKey,r),g(e,o.RootKeyWrapperKeyParams,Object(_.I)(i,['hash'])),g(e,o.RootKeyParams,a),g(e,c.MobileFirstRun,s),e)),g(t,_e.Unwrapped,{}),g(t,_e.Wrapped,{}),u=t,M.next=21,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileBiometricsPrefs));case 21:return(l=M.sent)&&(u.nonwrapped[o.BiometricsState]=l.enabled,u.nonwrapped[o.MobileBiometricsTiming]=l.timing),M.next=25,b.awrap(this.services.deviceInterface.getRawStorageValue(D.MobilePasscodeKeyboardType));case 25:if((p=M.sent)&&(u.nonwrapped[o.MobilePasscodeKeyboardType]=p),!i){M.next=75;break}if(h=this.services.protocolService.createKeyParams(i),f=function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(R.promptForPasscodeUntilCorrect(function(t){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(R.services.protocolService.computeRootKey(t,h));case 2:if(e=u.sent,!(i=null===n||void 0===n?void 0:null===(a=n.offline)||void 0===a?void 0:a.pw)){u.next=8;break}return u.abrupt("return",e.serverPassword===i);case 8:if(!r){u.next=15;break}return u.next=11,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),e));case 11:return s=u.sent,u.abrupt("return",!s.errorDecrypting);case 15:return u.next=17,b.awrap(R.services.deviceInterface.getAllRawDatabasePayloads(R.services.identifier));case 17:if(o=u.sent[0]){u.next=20;break}throw Error('Passcode only migration aborting due to missing keychain.offline.pw');case 20:return u.next=22,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(o),e));case 22:return c=u.sent,u.abrupt("return",!c.errorDecrypting);case 24:case"end":return u.stop()}},null,null,null,Promise)}));case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},null,null,null,Promise)},u.nonwrapped[o.MobilePasscodeTiming]=null===n||void 0===n?void 0:null===(d=n.offline)||void 0===d?void 0:d.timing,!r){M.next=55;break}return M.next=34,b.awrap(f());case 34:return v=M.sent,M.next=37,b.awrap(this.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),v));case 37:if(y=M.sent,m=y.contentObject.accountKeys,M.t1=m.version||(null===a||void 0===a?void 0:a.version),M.t1){M.next=44;break}return M.next=43,b.awrap(this.getFallbackRootKeyVersion());case 43:M.t1=M.sent;case 44:return w=M.t1,k=Object(Ee.b)(y,{content:{masterKey:m.mk,dataAuthenticationKey:m.ak,version:w,keyParams:a,accountKeys:void 0}}),M.next=48,b.awrap(this.services.protocolService.payloadByEncryptingPayload(k,Re.b.LocalStoragePreferEncrypted,v));case 48:return x=M.sent,u.nonwrapped[o.WrappedRootKey]=x.ejected(),m.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",m.jwt),M.next=53,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 53:M.next=73;break;case 55:if(r){M.next=73;break}return M.next=58,b.awrap(f());case 58:return S=M.sent,M.t2=Object(Ee.e),M.next=62,b.awrap(I.GenerateUuid());case 62:return M.t3=M.sent,M.t4=Object(Ke.a)(u.unwrapped),M.t5=F.a.EncryptedStorage,M.t6={uuid:M.t3,content:M.t4,content_type:M.t5},P=(0,M.t2)(M.t6),M.next=69,b.awrap(this.services.protocolService.payloadByEncryptingPayload(P,Re.b.LocalStoragePreferEncrypted,S));case 69:return O=M.sent,u.wrapped=O.ejected(),M.next=73,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 73:M.next=89;break;case 75:if(!!Object(_.w)(null===n||void 0===n?void 0:n.mk)){M.next=89;break}if(M.t7=n.version||(null===a||void 0===a?void 0:a.version),M.t7){M.next=82;break}return M.next=81,b.awrap(this.getFallbackRootKeyVersion());case 81:M.t7=M.sent;case 82:return C=M.t7,M.next=85,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:C,keyParams:a}));case 85:return E=M.sent,M.next=88,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(E.getKeychainValue(),this.services.identifier));case 88:n.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",n.jwt);case 89:return M.next=91,b.awrap(this.allPlatformHelperSetStorageStructure(u));case 91:case"end":return M.stop()}},null,this,null,Promise)}},{key:"getFallbackRootKeyVersion",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.services.deviceInterface.getAllRawDatabasePayloads(this.services.identifier));case 2:if(e=n.sent[0]){n.next=5;break}return n.abrupt("return",Q.a.V002);case 5:return t=Object(Ee.e)(e),n.abrupt("return",t.version||Q.a.V002);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateArbitraryRawStorageToManagedStorageAllPlatforms",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getAllRawStorageKeyValues());case 2:e=p.sent,t=Object(_.H)(D),n=function(e){try{return JSON.parse(e)}catch(t){return e}},r=this.services.identifier,a=S(e);case 7:if((i=a()).done){p.next=20;break}if(s=i.value,o=s.key,c=s.value,u=r&&r.length>0&&o.startsWith(r),!t.includes(o)&&!u){p.next=14;break}return p.abrupt("continue",18);case 14:if(Object(_.w)(c)){p.next=18;break}return l=n(c),p.next=18,b.awrap(this.services.storageService.setValue(o,l));case 18:p.next=7;break;case 20:case"end":return p.stop()}},null,this,null,Promise)}},{key:"deleteLegacyStorageValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e=['mk','ak','pw','encryptionKey','authKey','jwt','ephemeral','cachedThemes'],t=[].concat(m(Object(_.H)(o)),m(Object(_.H)(D)),e),n=S(t);case 3:if((r=n()).done){i.next=9;break}return a=r.value,i.next=7,b.awrap(this.services.deviceInterface.removeRawStorageValue(a));case 7:i.next=3;break;case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"migrateMobilePreferences",value:function(){var e,t,n,r,a,i,s,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileLastExportDate));case 2:return e=p.sent,p.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileDoNotWarnUnsupportedEditors));case 5:return t=p.sent,p.next=8,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileOptionsState));case 8:return n=p.sent,r={},n&&(u=n.sortBy,r={sortBy:'updated_at'===u||'client_updated_at'===u?dn.UpdatedAt:u,sortReverse:null!==(a=n.sortReverse)&&void 0!==a&&a,hideNotePreview:null!==(i=n.hidePreviews)&&void 0!==i&&i,hideDate:null!==(s=n.hideDates)&&void 0!==s&&s,hideTags:null!==(c=n.hideTags)&&void 0!==c&&c}),l=bn(bn({},r),{},{lastExportDate:null!==e&&void 0!==e?e:void 0,doNotShowAgainUnsupportedEditors:null!==t&&void 0!==t&&t}),p.next=14,b.awrap(this.services.storageService.setValue(o.MobilePreferences,l));case 14:case"end":return p.stop()}},null,this,null,Promise)}},{key:"migrateSessionStorage",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return e='user',i.next=3,b.awrap(this.services.storageService.getValue("jwt"));case 3:return t=i.sent,i.next=6,b.awrap(this.services.storageService.getValue(e));case 6:if(n=i.sent,t||n&&(t=n.jwt),t){i.next=15;break}if(!!Object(_.w)(n)){i.next=14;break}t='junk-value',i.next=15;break;case 14:return i.abrupt("return");case 15:return r=new Ae(t),i.next=18,b.awrap(this.services.storageService.setValue(o.Session,r));case 18:if(!Pe(this.services.environment)){i.next=25;break}return i.next=21,b.awrap(this.services.storageService.getValue(e));case 21:if(!(a=i.sent)||!a.server){i.next=25;break}return i.next=25,b.awrap(this.services.storageService.setValue(o.ServerHost,a.server));case 25:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createDefaultItemsKeyForAllPlatforms",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e=this.services.protocolService.getRootKey())){i.next=18;break}return i.next=4,b.awrap(this.services.protocolService.getRootKeyParams());case 4:return t=i.sent,n=Q.a.V001,i.t0=Object(Ee.e),i.next=9,b.awrap(I.GenerateUuid());case 9:return i.t1=i.sent,i.t2=F.a.ItemsKey,i.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t.version||n}),i.t4=new Date,i.t5={uuid:i.t1,content_type:i.t2,content:i.t3,dirty:!0,dirtiedDate:i.t4},r=(0,i.t0)(i.t5),a=nt(r),i.next=18,b.awrap(this.services.itemManager.emitItemFromPayload(a.payloadRepresentation(),ht.a.LocalChanged));case 18:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return"2.0.0"}}]),n})(),xn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createNewDefaultItemsKeyIfNecessary());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"createNewDefaultItemsKeyIfNecessary",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.services.protocolService.needsNewRootKeyBasedItemsKey()){e.next=3;break}return e.next=3,b.awrap(this.services.protocolService.createNewDefaultItemsKey());case 3:case"end":return e.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.0.15'}}]),n})(),Sn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.FullSyncCompleted_13,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteBatchManagerSingleton());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteBatchManagerSingleton",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e='org.standardnotes.batch-manager',t=H.a.CompoundPredicate([new H.a('content_type','=',F.a.Component),new H.a('package_info.identifier','=',e)]),!(n=this.services.singletonManager.findSingleton(t))){r.next=6;break}return r.next=6,b.awrap(this.services.itemManager.setItemToBeDeleted(n.uuid));case 6:case"end":return r.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.7.0'}}]),n})(),Pn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteMfaItems());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteMfaItems",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e='SF|MFA',t=this.services.itemManager.getItems(e),n=S(t);case 3:if((r=n()).done){i.next=10;break}return a=r.value,this.services.itemManager.removeItemLocally(a),i.next=8,b.awrap(this.services.storageService.deletePayloadWithId(a.uuid));case 8:i.next=3;break;case 10:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.20.0'}}]),n})(),On=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getStorage",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=O(this.identifier,s.StorageObject),r.next=3,b.awrap(this.deviceInterface.getRawStorageValue(e));case 3:return t=r.sent,n=t?JSON.parse(t):void 0,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getNonWrappedValue",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getStorage());case 2:if(n=r.sent){r.next=5;break}return r.abrupt("return",void 0);case 5:return r.abrupt("return",null===(t=n[_e.Nonwrapped])||void 0===t?void 0:t[e]);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getNonWrappedValue(o.RootKeyParams));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getNonWrappedValue(o.WrappedRootKey));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!0}}],[{key:"version",value:function(){return"2.0.0"}}]),n})();function Cn(e){for(var t,n=S(Object.values(i).sort(function(e,t){return-1*P(e.version(),t.version())}));!(t=n()).done;){var r=t.value;if(r.version()===e)return r;if(x(r.version(),e))return r}throw Error("Cannot find reader for version ".concat(e))}function Dn(e,t,n,r){return new(Cn(e))(t,n,r)}var _n=(function(e){d(n,yn);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).didPreRun=!1,e}return y(n,[{key:"preRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storeVersionNumber());case 2:this.didPreRun=!0;case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.needsKeychainRepair());case 2:if(!t.sent){t.next=5;break}return t.next=5,b.awrap(e.repairMissingKeychain());case 5:e.markDone();case 6:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"getStoredVersion",value:function(){var e=O(this.services.identifier,s.SnjsVersion);return this.services.deviceInterface.getRawStorageValue(e)}},{key:"storeVersionNumber",value:function(){var e,t,n,r,a,i,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return e=O(this.services.identifier,s.SnjsVersion),c.next=3,b.awrap(this.getStoredVersion());case 3:if(c.sent){c.next=38;break}t=!1,n=0,r=['migrations','ephemeral','user','cachedThemes','syncToken','encryptedStorage'];case 8:if(!(n<r.length)){c.next=19;break}return a=r[n],c.next=12,b.awrap(this.services.deviceInterface.getRawStorageValue(a));case 12:if(!c.sent){c.next=16;break}return t=!0,c.abrupt("break",19);case 16:n++,c.next=8;break;case 19:if(!t){c.next=24;break}return c.next=22,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"1.0.0"));case 22:c.next=38;break;case 24:return i=O(this.services.identifier,"last_migration_timestamp"),c.next=27,b.awrap(this.services.deviceInterface.getRawStorageValue(i));case 27:if(o=c.sent,!!Object(_.w)(o)){c.next=36;break}return c.next=32,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"2.0.0"));case 32:return c.next=34,b.awrap(this.services.deviceInterface.removeRawStorageValue("last_migration_timestamp"));case 34:c.next=38;break;case 36:return c.next=38,b.awrap(this.services.deviceInterface.setRawStorageValue(e,h));case 38:case"end":return c.stop()}},null,this,null,Promise)}},{key:"loadReader",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.reader){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,b.awrap(this.getStoredVersion());case 4:e=t.sent,this.reader=Dn(e,this.services.deviceInterface,this.services.identifier,this.services.environment);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"needsKeychainRepair",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.didPreRun){t.next=2;break}throw Error('Attempting to access specialized function before prerun');case 2:if(this.reader){t.next=5;break}return t.next=5,b.awrap(this.loadReader());case 5:if(this.reader.usesKeychain){t.next=8;break}return t.abrupt("return",!1);case 8:return t.next=10,b.awrap(this.reader.getAccountKeyParams());case 10:if(e=t.sent,!Object(_.w)(e)){t.next=14;break}return t.abrupt("return",!1);case 14:return t.next=16,b.awrap(this.reader.hasPasscode());case 16:if(!t.sent){t.next=19;break}return t.abrupt("return",!1);case 19:return t.next=21,b.awrap(this.reader.hasNonWrappedAccountKeys());case 21:if(!t.sent){t.next=24;break}return t.abrupt("return",!1);case 24:return t.abrupt("return",!0);case 25:case"end":return t.stop()}},null,this,null,Promise)}},{key:"repairMissingKeychain",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getStoredVersion());case 2:return e=a.sent,a.next=5,b.awrap(this.reader.getAccountKeyParams());case 5:return t=a.sent,n=new ye([new ge(te.None,void 0,j.R.PasswordInputPlaceholder,!0)],ne.Custom,!1,j.I.Title,j.I.Text),a.abrupt("return",new Promise(function(a){r.services.challengeService.addChallengeObserver(n,{onNonvalidatedSubmit:function(i){var s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return s=i.values[0].value,o=r.services.protocolService.createKeyParams(t),d.next=4,b.awrap(r.services.protocolService.computeRootKey(s,o));case 4:return c=d.sent,d.next=7,b.awrap(r.services.deviceInterface.getAllRawDatabasePayloads(r.services.identifier));case 7:if(u=d.sent,(l=u.find(function(e){var t=Object(Ee.e)(e);return Object(Re.a)(t.content_type)}))||(l=u[0]),l){d.next=12;break}throw we.a.error(Error('Attempting keychain recovery validation but no items present.'));case 12:return d.next=14,b.awrap(r.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(l),c));case 14:if(!d.sent.errorDecrypting){d.next=19;break}r.services.challengeService.setValidationStatusForChallenge(n,i.values[0],!1),d.next=29;break;case 19:if("1.0.0"!==e){d.next=24;break}return d.next=22,b.awrap(r.services.deviceInterface.legacy_setRawKeychainValue({mk:c.masterKey,ak:c.dataAuthenticationKey,version:o.version}));case 22:d.next=27;break;case 24:return p=c.getKeychainValue(),d.next=27,b.awrap(r.services.deviceInterface.setNamespacedKeychainValue(p,r.services.identifier));case 27:a(),r.services.challengeService.completeChallenge(n);case 29:case"end":return d.stop()}},null,null,null,Promise)}}),r.services.challengeService.promptForChallengeResponse(n)}));case 8:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(),En=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).services=e,r}return y(n,[{key:"deinit",value:function(){this.services=void 0,this.activeMigrations&&(this.activeMigrations.length=0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.runBaseMigrationPreRun());case 2:return r.t0=b,r.t1=n,r.next=6,b.awrap(this.getStoredSnjsVersion());case 6:return r.t2=r.sent,r.t3=r.t1.getRequiredMigrations.call(r.t1,r.t2),r.next=10,r.t0.awrap.call(r.t0,r.t3);case 10:if(e=r.sent,this.activeMigrations=this.instantiateMigrationClasses(e),!(this.activeMigrations.length>0)){r.next=17;break}Object(_.F)(this.activeMigrations).onDone(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(t.markMigrationsAsDone());case 2:case"end":return e.stop()}},null,null,null,Promise)}),r.next=19;break;case 17:return r.next=19,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 19:case"end":return r.stop()}},null,this,null,Promise)}},{key:"markMigrationsAsDone",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"runBaseMigrationPreRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.baseMigration=new _n(this.services),e.next=3,b.awrap(this.baseMigration.preRun());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:return t.next=4,b.awrap(this.handleStage(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleApplicationEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.a.SignedIn){t.next=3;break}return t.next=3,b.awrap(this.handleStage(ve.SignedIn_30));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPendingMigrations",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=n,t.next=4,b.awrap(this.getStoredSnjsVersion());case 4:return t.t2=t.sent,t.t3=t.t1.getRequiredMigrations.call(t.t1,t.t2),t.next=8,t.t0.awrap.call(t.t0,t.t3);case 8:if(e=t.sent,t.t4=e.length>0,t.t4){t.next=14;break}return t.next=13,b.awrap(this.baseMigration.needsKeychainRepair());case 13:t.t4=t.sent;case 14:return t.abrupt("return",t.t4);case 15:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getStoredSnjsVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.services.deviceInterface.getRawStorageValue(O(this.services.identifier,s.SnjsVersion)));case 2:if(e=t.sent){t.next=5;break}throw we.a.error(Error('Snjs version missing from storage, run base migration.'));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"instantiateMigrationClasses",value:function(e){var t=this;return e.map(function(e){return new e(t.services)})}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.baseMigration.handleStage(e));case 2:t=S(this.activeMigrations);case 3:if((n=t()).done){a.next=9;break}return r=n.value,a.next=7,b.awrap(r.handleStage(e));case 7:a.next=3;break;case 9:case"end":return a.stop()}},null,this,null,Promise)}}],[{key:"getRequiredMigrations",value:function(e){var t,n,r,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:t=[],n=Object.keys(a).map(function(e){return a[e]}).sort(function(e,t){return P(e.version(),t.version())}),r=S(n);case 3:if((i=r()).done){c.next=11;break}if(s=i.value,(o=s.version())!==e){c.next=8;break}return c.abrupt("continue",9);case 8:x(e,o)&&t.push(s);case 9:c.next=3;break;case 11:return c.abrupt("return",t);case 12:case"end":return c.stop()}},null,null,null,Promise)}}]),n})(R.a),Rn=n(14),In=(function(){function e(t){v(this,e),this.crypto=t}return y(e,[{key:"firstHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"secondHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"splitKey",value:function(e,t){for(var n=e.length/t,r=[],a=0;a<t;a++){var i=e.slice(n*a,n*(a+1));r.push(i)}return r}},{key:"createItemsKey",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.generateNewItemsKeyContent());case 2:return e=n.sent,n.t0=Object(Ee.e),n.next=6,b.awrap(I.GenerateUuid());case 6:return n.t1=n.sent,n.t2=F.a.ItemsKey,n.t3=Object(Ke.a)(e),n.t4={uuid:n.t1,content_type:n.t2,content:n.t3},t=(0,n.t0)(n.t4),n.abrupt("return",nt(t));case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,n){var r,a,i;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==ue.a.DecryptedBareObject){n.next=4;break}return n.abrupt("return",Object(Ee.c)({content:e.content}));case 4:if(t!==ue.a.DecryptedBase64String){n.next=13;break}return r=JSON.stringify(e.content),n.next=8,b.awrap(this.crypto.base64Encode(r));case 8:return a=n.sent,i=Q.a.V000Base64Decrypted+a,n.abrupt("return",Object(Ee.c)({content:i}));case 13:throw"Must override generateEncryptedParameters to handle format ".concat(t,".");case 14:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var n,r,a,i;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=e.format)!==ue.a.DecryptedBareObject){t.next=5;break}return t.abrupt("return",e);case 5:if(n!==ue.a.DecryptedBase64String){t.next=20;break}return r=e.contentString.substring(Q.a.VersionLength,e.contentString.length),t.prev=7,t.next=10,b.awrap(this.crypto.base64Decode(r));case 10:i=t.sent,a=JSON.parse(i),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),a=e.content;case 17:return t.abrupt("return",Object(Ee.a)(e,{content:a}));case 20:throw Error("Must override generateDecryptedParameters to handle format ".concat(n,"."));case 21:case"end":return t.stop()}},null,this,[[7,14]],Promise)}}]),e})(),Mn='00000000000000000000000000000000',An=(function(e){d(n,In);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'AES-256'}},{key:"generateNewItemsKeyContent",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=Rn.a.EncryptionKeyLength,r.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=r.sent,n={itemsKey:t,version:Q.a.V001},r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Rn.a.PbkdfMinCost,o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.a.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+'SN'+a));case 6:return i=o.sent,s=Object(A.a)({email:e,pw_cost:r,pw_nonce:a,pw_salt:i,version:Q.a.V001,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcDecrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"encryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcEncrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c,u,l;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){d.next=2;break}return d.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){d.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r){d.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return d.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.a.EncryptionKeyLength));case 8:return a=d.sent,d.next=11,b.awrap(this.encryptString(a,r.itemsKey));case 11:return i=d.sent,d.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=d.sent,d.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=d.sent,d.next=20,b.awrap(this.encryptString(JSON.stringify(e.content),s));case 20:return c=d.sent,u=r.keyVersion+c,d.next=24,b.awrap(this.crypto.hmac256(u,o));case 24:return l=d.sent,d.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:u,enc_item_key:i,auth_hash:l}));case 26:case"end":return d.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){l.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:return a=e.enc_item_key,a=this.version+a,i=this.encryptionComponentsFromString(a,t.itemsKey),l.next=11,b.awrap(this.decryptString(i.ciphertext,i.key));case 11:if(s=l.sent){l.next=15;break}return console.error('Error decrypting parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 15:return l.next=17,b.awrap(this.firstHalfOfKey(s));case 17:return o=l.sent,c=this.encryptionComponentsFromString(e.contentString,o),l.next=21,b.awrap(this.decryptString(c.ciphertext,c.key));case 21:if(u=l.sent){l.next=26;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 27:case"end":return l.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString",value:function(e,t){var n=e.substring(0,Q.a.VersionLength);return{ciphertext:e.substring(Q.a.VersionLength,e.length),version:n,key:t}}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content001.pw_salt,t.content001.pw_cost,Rn.a.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,2),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],version:Q.a.V001,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V001}}]),n})();function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach(function(t){Kn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=(function(e){d(n,An);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.b.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V002},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Object(_.F)(Rn.b.PbkdfCostsUsed),o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.b.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+':'+a));case 6:return i=o.sent,s=Object(A.b)({email:e,pw_nonce:a,pw_cost:r,pw_salt:i,version:Q.a.V002,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcDecrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcEncrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptTextParams",value:function(e,t,n,r,a,i){var s,o,c,u,l,p,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,b.awrap(this.crypto.generateRandomKey(Rn.b.EncryptionIvLength));case 2:return s=h.sent,h.next=5,b.awrap(this.encryptString002(e,t,s));case 5:return o=h.sent,c=[a,r,s,o].join(':'),h.next=9,b.awrap(this.crypto.hmac256(c,n));case 9:if(u=h.sent,l=[a,u,r,s,o],!i){h.next=16;break}return h.next=14,b.awrap(this.crypto.base64Encode(JSON.stringify(i.content)));case 14:p=h.sent,l.push(p);case 16:return d=l.join(':'),h.abrupt("return",d);case 18:case"end":return h.stop()}},null,this,null,Promise)}},{key:"decryptTextParams",value:function(e,t,n,r,a,i){var s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n){o.next=2;break}throw'Attempting to decryptTextParams with null encryptionKey';case 2:return o.next=4,b.awrap(this.crypto.hmac256(e,i));case 4:if(s=o.sent,!1!==this.crypto.timingSafeEqual(a,s)){o.next=8;break}return we.a.error(Error('Auth hash does not match.')),o.abrupt("return",null);case 8:return o.abrupt("return",this.decryptString002(t,n,r));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(t=this.encryptionComponentsFromString002(e.enc_item_key),n=t.keyParams){i.next=4;break}return i.abrupt("return",void 0);case 4:return i.t0=JSON,i.next=7,b.awrap(this.crypto.base64Decode(n));case 7:return i.t1=i.sent,r=i.t0.parse.call(i.t0,i.t1),a=Tn({},r),i.abrupt("return",a);case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r&&r.itemsKey){u.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return u.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.b.EncryptionKeyLength));case 8:return a=u.sent,u.next=11,b.awrap(this.encryptTextParams(a,r.itemsKey,r.dataAuthenticationKey,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 11:return i=u.sent,u.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=u.sent,u.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=u.sent,u.next=20,b.awrap(this.encryptTextParams(JSON.stringify(e.content),s,o,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 20:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:c,enc_item_key:i}));case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u,l,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){h.next=3;break}return h.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){h.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:if(t&&t.itemsKey){h.next=8;break}throw Error('Attempting to generateDecryptedParameters with no itemsKey.');case 8:return a=e.enc_item_key,i=this.encryptionComponentsFromString002(a,t.itemsKey,t.dataAuthenticationKey),h.next=12,b.awrap(this.decryptTextParams(i.ciphertextToAuth,i.contentCiphertext,i.encryptionKey,i.iv,i.authHash,i.authKey));case 12:if(s=h.sent){h.next=16;break}return console.error('Error decrypting item_key parameters',e),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 16:return h.next=18,b.awrap(this.firstHalfOfKey(s));case 18:return o=h.sent,h.next=21,b.awrap(this.secondHalfOfKey(s));case 21:return c=h.sent,u=this.encryptionComponentsFromString002(e.contentString,o,c),h.next=25,b.awrap(this.decryptTextParams(u.ciphertextToAuth,u.contentCiphertext,u.encryptionKey,u.iv,u.authHash,u.authKey));case 25:if(l=h.sent){h.next=30;break}return h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 30:return h.prev=30,h.t0=JSON,h.next=34,b.awrap(this.crypto.base64Decode(u.keyParams));case 34:h.t1=h.sent,d=h.t0.parse.call(h.t0,h.t1),h.next=40;break;case 38:h.prev=38,h.t2=h.catch(30);case 40:return h.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(l),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,auth_params:d,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 41:case"end":return h.stop()}},null,this,[[30,38]],Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content002.pw_salt,t.content002.pw_cost,Rn.b.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,3),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],dataAuthenticationKey:r[2],version:Q.a.V002,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString002",value:function(e,t,n){var r=e.split(':');return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],keyParams:r[5],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(':'),encryptionKey:t,authKey:n}}},{key:"version",get:function(){return Q.a.V002}}]),n})(),Ln=(function(e){d(n,Fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.c.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V003},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.generateSalt(t.content003.identifier,Q.a.V003,Rn.c.PbkdfCost,t.content003.pw_nonce));case 2:return n=s.sent,s.next=5,b.awrap(this.crypto.pbkdf2(e,n,Rn.c.PbkdfCost,Rn.c.PbkdfOutputLength));case 5:return r=s.sent,a=this.splitKey(r,3),s.next=9,b.awrap(Ve.Create({serverPassword:a[0],masterKey:a[1],dataAuthenticationKey:a[2],version:Q.a.V003,keyParams:t.getPortableValue()}));case 9:return i=s.sent,s.abrupt("return",i);case 11:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V003,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.c.SaltSeedLength));case 3:return a=s.sent,i=Object(A.c)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"generateSalt",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.sha256([e,'SF',t,n,r].join(':')));case 2:return a=i.sent,i.abrupt("return",a);case 4:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V003}}]),n})();function Un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach(function(t){Vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bn,Wn=(function(e){d(n,Ln);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'XChaCha20-Poly1305'}},{key:"generateNewItemsKeyContent",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 2:return e=n.sent,t={itemsKey:e,version:Q.a.V004},n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateSalt004",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.crypto.sha256([e,t].join(":")));case 2:return n=r.sent,r.abrupt("return",Object(_.T)(n,Rn.d.ArgonSaltLength));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V004,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.d.ArgonSaltSeedLength));case 3:return a=s.sent,i=Object(A.d)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"encryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n){a.next=2;break}throw'encryptString null nonce';case 2:if(t){a.next=4;break}throw'encryptString null rawKey';case 4:return a.t0=this.crypto,a.t1=e,a.t2=n,a.t3=t,a.next=10,b.awrap(this.authenticatedDataToString(r));case 10:return a.t4=a.sent,a.abrupt("return",a.t0.xchacha20Encrypt.call(a.t0,a.t1,a.t2,a.t3,a.t4));case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.crypto.xchacha20Decrypt(e,n,t,r));case 1:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateEncryptedProtocolString",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionNonceLength));case 2:return r=o.sent,a=Q.a.V004,o.next=6,b.awrap(this.encryptString004(e,t,r,n));case 6:return i=o.sent,o.t0=a,o.t1=r,o.t2=i,o.next=12,b.awrap(this.authenticatedDataToString(n));case 12:return o.t3=o.sent,s=[o.t0,o.t1,o.t2,o.t3],o.abrupt("return",s.join(":"));case 15:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.format===ue.a.EncryptedString){a.next=2;break}throw Error('Attempting to get embedded key params of already decrypted item');case 2:return t=this.deconstructEncryptedPayloadString(e.enc_item_key),n=t.rawAuthenticatedData,a.next=6,b.awrap(this.stringToAuthenticatedData(n));case 6:return r=a.sent,a.abrupt("return",r);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateAuthenticatedDataForPayload",value:function(e,t){var n={u:e.uuid,v:Q.a.V004};if(Object(Re.a)(e.content_type))return Nn(Nn({},n),{},{kp:t.keyParams.content});if(!(t instanceof J))throw Error('Attempting to use non-items key for regular item.');return n}},{key:"authenticatedDataToString",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.base64Encode(JSON.stringify(Object(_.Q)(Object(_.K)(e)))));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"stringToAuthenticatedData",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=JSON,r.next=3,b.awrap(this.crypto.base64Decode(e));case 3:return r.t1=r.sent,n=r.t0.parse.call(r.t0,r.t1),r.abrupt("return",Object(_.Q)(Nn(Nn({},n),t)));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(e.uuid){u.next=6;break}throw'payload.uuid cannot be null';case 6:if(r&&r.itemsKey){u.next=8;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 8:return u.next=10,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 10:return a=u.sent,i=JSON.stringify(e.content),s=this.generateAuthenticatedDataForPayload(e,r),u.next=15,b.awrap(this.generateEncryptedProtocolString(i,a,s));case 15:return o=u.sent,u.next=18,b.awrap(this.generateEncryptedProtocolString(a,r.itemsKey,s));case 18:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:o,enc_item_key:c}));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.uuid){l.next=5;break}throw'encryptedParameters.uuid cannot be null';case 5:if(t&&t.itemsKey){l.next=7;break}throw'Attempting to generateDecryptedParameters with no itemsKey.';case 7:return a=this.deconstructEncryptedPayloadString(e.enc_item_key),l.next=10,b.awrap(this.stringToAuthenticatedData(a.rawAuthenticatedData,{u:e.uuid,v:e.version}));case 10:return i=l.sent,l.next=13,b.awrap(this.authenticatedDataToString(i));case 13:return s=l.sent,l.next=16,b.awrap(this.decryptString004(a.ciphertext,t.itemsKey,a.nonce,s));case 16:if(o=l.sent){l.next=20;break}return console.error('Error decrypting itemKey parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 20:return c=this.deconstructEncryptedPayloadString(e.contentString),l.next=23,b.awrap(this.decryptString004(c.ciphertext,o,c.nonce,s));case 23:if(u=l.sent){l.next=28;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 28:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 29:case"end":return l.stop()}},null,this,null,Promise)}},{key:"deconstructEncryptedPayloadString",value:function(e){var t=e.split(":");return{version:t[0],nonce:t[1],ciphertext:t[2],rawAuthenticatedData:t[3]}}},{key:"deriveKey",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.generateSalt004(t.content004.identifier,t.content004.pw_nonce));case 2:return n=o.sent,o.next=5,b.awrap(this.crypto.argon2(e,n,Rn.d.ArgonIterations,Rn.d.ArgonMemLimit,Rn.d.ArgonOutputKeyBytes));case 5:return r=o.sent,a=this.splitKey(r,2),i=a[0],s=a[1],o.abrupt("return",Ve.Create({masterKey:i,serverPassword:s,version:Q.a.V004,keyParams:t.getPortableValue()}));case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V004}}]),n})();function Hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(n),!0).forEach(function(t){qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e[e.RootKeyNone=0]="RootKeyNone",e[e.RootKeyOnly=1]="RootKeyOnly",e[e.RootKeyPlusWrapper=2]="RootKeyPlusWrapper",e[e.WrapperOnly=3]="WrapperOnly"})(Bn||(Bn={}));var Yn=Q.a.V003,Gn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).itemManager=e,c.payloadManager=r,c.storageService=i,c.identifier=s,c.operators={},c.keyMode=Bn.RootKeyNone,c.keyObservers=[],c.itemManager=e,c.payloadManager=r,c.deviceInterface=a,c.storageService=i,c.crypto=o,Object(_.y)()?I.SetGenerators(c.crypto.generateUUID,void 0):I.SetGenerators(c.crypto.generateUUID,c.crypto.generateUUIDSync),Object.defineProperty(u(c),'rootKey',{enumerable:!1,writable:!0}),c.removeItemsObserver=c.itemManager.addObserver([F.a.ItemsKey],function(e,t){e.concat(t).length>0&&c.decryptErroredItems()}),c}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.deviceInterface=void 0,this.storageService=void 0,this.crypto.deinit(),this.crypto=void 0,this.operators={},this.keyObservers.length=0,this.removeItemsObserver(),this.removeItemsObserver=null,this.rootKey=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:return e=a.sent,a.next=5,b.awrap(this.getAccountKeyParams());case 5:return t=a.sent,a.next=8,b.awrap(this.hasRootKeyWrapper());case 8:if(n=a.sent,r=!Object(_.w)(e)||!Object(_.w)(t),!n||!r){a.next=14;break}this.keyMode=Bn.RootKeyPlusWrapper,a.next=27;break;case 14:if(!n||r){a.next=18;break}this.keyMode=Bn.WrapperOnly,a.next=27;break;case 18:if(n||!r){a.next=22;break}this.keyMode=Bn.RootKeyOnly,a.next=27;break;case 22:if(n||r){a.next=26;break}this.keyMode=Bn.RootKeyNone,a.next=27;break;case 26:throw'Invalid key mode condition';case 27:if(this.keyMode!==Bn.RootKeyOnly){a.next=33;break}return a.next=30,b.awrap(this.getRootKeyFromKeychain());case 30:return this.rootKey=a.sent,a.next=33,b.awrap(this.notifyObserversOfKeyChange());case 33:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getEncryptionSourceVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasAccount()){t.next=4;break}return t.abrupt("return",this.getUserVersion());case 4:if(!this.hasPasscode()){t.next=9;break}return t.next=7,b.awrap(this.getRootKeyWrapperKeyParams());case 7:return e=t.sent,t.abrupt("return",e.version);case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getEncryptionDisplayName",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getEncryptionSourceVersion());case 2:if(!(e=t.sent)){t.next=5;break}return t.abrupt("return",this.operatorForVersion(e).getEncryptionDisplayName());case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLatestVersion",value:function(){return Q.a.V004}},{key:"hasAccount",value:function(){switch(this.keyMode){case Bn.RootKeyNone:case Bn.WrapperOnly:return!1;case Bn.RootKeyOnly:case Bn.RootKeyPlusWrapper:return!0;default:throw Error("Unhandled keyMode value '".concat(this.keyMode,"'."))}}},{key:"getUserVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getAccountKeyParams());case 2:return e=t.sent,t.abrupt("return",null===e||void 0===e?void 0:e.version);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"upgradeAvailable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.accountUpgradeAvailable());case 2:return e=n.sent,n.next=5,b.awrap(this.passcodeUpgradeAvailable());case 5:return t=n.sent,n.abrupt("return",e||t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"accountUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"passcodeUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e.version!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"platformSupportsKeyDerivation",value:function(e){return Object(Q.b)(e.version,Q.a.V004)>=0||(!!Object(_.C)()||Object(_.y)())}},{key:"supportedVersions",value:function(){return[Q.a.V001,Q.a.V002,Q.a.V003,Q.a.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.getLatestVersion();return 1===Object(Q.b)(e,t)}},{key:"isProtocolVersionOutdated",value:function(e){var t,n=(g(t={},Q.a.V001,Date.parse('2018-01-01')),g(t,Q.a.V002,Date.parse('2020-01-01')),t)[e];return!!n&&(new Date).getTime()>n}},{key:"costMinimumForVersion",value:function(e){if(Object(Q.b)(e,Q.a.V003)>=0)throw'Cost minimums only apply to versions <= 002';if(e===Q.a.V001)return Rn.a.PbkdfMinCost;if(e===Q.a.V002)return Rn.b.PbkdfMinCost;throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===Q.a.V001)return new An(this.crypto);if(e===Q.a.V002)return new Fn(this.crypto);if(e===Q.a.V003)return new Ln(this.crypto);if(e===Q.a.V004)return new Wn(this.crypto);if(e===Q.a.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw Error("Unable to find operator for version ".concat(e))}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=t.version,r=this.operatorForVersion(n),a.abrupt("return",r.computeRootKey(e,t));case 3:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return a=r?this.operatorForVersion(r):this.defaultOperator(),i.abrupt("return",a.createRootKey(e,t,n));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"payloadContentFormatForIntent",value:function(e,t){if(t){if(e===Re.b.Sync||e===Re.b.FileEncrypted||e===Re.b.FilePreferEncrypted||e===Re.b.LocalStorageEncrypted||e===Re.b.LocalStoragePreferEncrypted)return ue.a.EncryptedString;throw'Unhandled encrypted case in protocolService.payloadContentFormatForIntent.'}if(e===Re.b.LocalStorageDecrypted||e===Re.b.LocalStoragePreferEncrypted||e===Re.b.FileDecrypted||e===Re.b.FilePreferEncrypted)return ue.a.DecryptedBareObject;if(e===Re.b.SyncDecrypted)return ue.a.DecryptedBase64String;throw'Unhandled decrypted case in protocolService.payloadContentFormatForIntent.'}},{key:"payloadByEncryptingPayload",value:function(e,t,n){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(!e.errorDecrypting){l.next=2;break}return l.abrupt("return",e);case 2:if(!e.deleted){l.next=4;break}return l.abrupt("return",e);case 4:if(!Object(_.w)(t)){l.next=6;break}throw Error('Attempting to encrypt payload with null intent');case 6:if(n||Object(Re.d)(t)){l.next=10;break}return l.next=9,b.awrap(this.keyToUseForEncryptionOfPayload(e,t));case 9:n=l.sent;case 10:if(n||!Object(Re.c)(t)){l.next=12;break}throw Error('Attempting to generate encrypted payload with no key.');case 12:if(e.format===ue.a.DecryptedBareObject){l.next=14;break}throw Error('Attempting to encrypt already encrypted payload.');case 14:if(e.content){l.next=16;break}throw Error('Attempting to encrypt payload with no content.');case 16:if(e.uuid){l.next=18;break}throw Error('Attempting to encrypt payload with no uuid.');case 18:if(!(null!==(r=n)&&void 0!==r&&r.errorDecrypting||null!==(a=n)&&void 0!==a&&a.waitingForKey)){l.next=20;break}throw Error('Attempting to encrypt payload with encrypted key.');case 20:return i=n?n.keyVersion:this.getLatestVersion(),s=this.payloadContentFormatForIntent(t,n),o=this.operatorForVersion(i),l.next=25,b.awrap(o.generateEncryptedParameters(e,s,n));case 25:if(c=l.sent){l.next=28;break}throw'Unable to generate encryption parameters';case 28:return u=Object(Ee.d)(e,t,c),l.abrupt("return",u);case 30:case"end":return l.stop()}},null,this,null,Promise)}},{key:"payloadsByEncryptingPayloads",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){u.next=11;break}return s=i.value,o=Object(_.v)(t)?t(s):t,u.next=7,b.awrap(this.payloadByEncryptingPayload(s,o,n));case 7:c=u.sent,r.push(c);case 9:u.next=2;break;case 11:return u.abrupt("return",r);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingPayload",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content){c.next=3;break}return we.a.error(Error('Attempting to decrypt payload that has no content.')),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0}));case 3:if((r=e.format)!==ue.a.DecryptedBareObject){c.next=6;break}return c.abrupt("return",e);case 6:if(t||r!==ue.a.EncryptedString){c.next=10;break}if(t=this.keyToUseForDecryptionOfPayload(e)){c.next=10;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 10:if(null===(n=t)||void 0===n||!n.errorDecrypting){c.next=12;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 12:return a=e.version,i=e.source,s=this.operatorForVersion(a),c.prev=15,c.next=18,b.awrap(s.generateDecryptedParameters(e,t));case 18:return o=c.sent,c.abrupt("return",Object(Ee.e)(e,o,i));case 22:return c.prev=22,c.t0=c.catch(15),console.error('Error decrypting payload',e,c.t0),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:case"end":return c.stop()}},null,this,[[15,22]],Promise)}},{key:"payloadsByDecryptingPayloads",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e){n.next=2;break}return n.abrupt("return",e);case 2:if(!0!==e.deleted||!Object(_.w)(e.content)){n.next=4;break}return n.abrupt("return",e);case 4:if(Object(_.A)(e.content)){n.next=7;break}return n.abrupt("return",e);case 7:return n.abrupt("return",r.payloadByDecryptingPayload(e,t));case 8:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",Promise.all(e.map(function(e){return n(e)})));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"decryptErroredItems",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==(e=this.itemManager.invalidItems.filter(function(e){return e.content_type!==F.a.ItemsKey})).length){r.next=3;break}return r.abrupt("return");case 3:return t=e.map(function(e){return e.payloadRepresentation()}),r.next=6,b.awrap(this.payloadsByDecryptingPayloads(t));case 6:return n=r.sent,r.next=9,b.awrap(this.payloadManager.emitPayloads(n,ht.a.LocalChanged));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsByDecryptingBackupFile",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v=this;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if(n=e.keyParams||e.auth_params,r=e.items,a=r.map(function(e){return Object(Ee.f)(e,ht.a.FileImport)}),i=[],!n){y.next=28;break}return s=this.createKeyParams(n),y.next=8,b.awrap(this.computeRootKey(t,s));case 8:return o=y.sent,c=a.filter(function(e){return e.content_type===F.a.ItemsKey}),y.next=12,b.awrap(this.payloadsByDecryptingPayloads(c,o));case 12:u=y.sent,l=u.map(function(e){return nt(e)}),Object(_.o)(i,u),p=function(e){var t,n,r,a;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content_type!==F.a.ItemsKey){c.next=2;break}return c.abrupt("return","continue");case 2:return c.prev=2,e.items_key_id&&(t=v.itemsKeyForPayload(e)),t||(n=u.find(function(t){return e.items_key_id===t.uuid}),r=e.version,n?t=nt(n):Object(Q.d)(s.version,Q.a.V004)?t=v.defaultItemsKeyForItemVersion(r,l):Object(Q.b)(r,Q.a.V003)<=0&&(t=o)),c.next=7,b.awrap(v.payloadByDecryptingPayload(e,t));case 7:a=c.sent,i.push(a),c.next=15;break;case 11:c.prev=11,c.t0=c.catch(2),i.push(Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting})),console.error('Error decrypting payload',e,c.t0);case 15:case"end":return c.stop()}},null,null,[[2,11]],Promise)},d=S(a);case 17:if((h=d()).done){y.next=26;break}return f=h.value,y.next=21,b.awrap(p(f));case 21:if("continue"!==y.sent){y.next=24;break}return y.abrupt("continue",24);case 24:y.next=17;break;case 26:y.next=29;break;case 28:i=a;case 29:return y.abrupt("return",i);case 30:case"end":return y.stop()}},null,this,null,Promise)}},{key:"createKeyParams",value:function(e){return Object(A.e)(e)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return t=this.itemManager.items,e===Re.b.FileDecrypted&&(t=t.filter(function(e){return e.content_type!==F.a.ItemsKey})),n=Promise.all(t.map(function(t){if(t.errorDecrypting)return t.payload.ejected();var n=Object(Ee.f)(t.payload,ht.a.FileImport);return i.payloadByEncryptingPayload(n,e).then(function(e){return e.ejected()})})),s.t0=this.getLatestVersion(),s.next=6,b.awrap(n);case 6:if(s.t1=s.sent,r={version:s.t0,items:s.t1},e!==Re.b.FileEncrypted){s.next=13;break}return s.next=11,b.awrap(this.getRootKeyParams());case 11:a=s.sent,r.keyParams=null===a||void 0===a?void 0:a.getPortableValue();case 13:return s.abrupt("return",r);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"onKeyStatusChange",value:function(e){var t=this;return this.keyObservers.push(e),function(){Object(_.M)(t.keyObservers,e)}}},{key:"notifyObserversOfKeyChange",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:e=S(this.keyObservers);case 1:if((t=e()).done){r.next=7;break}return n=t.value,r.next=5,b.awrap(n());case 5:r.next=1;break;case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getRootKeyFromKeychain",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:if(e=n.sent,!Object(_.w)(e)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.t0=b,n.t1=Ve,n.t2=zn,n.t3=zn({},e),n.t4={},n.next=12,b.awrap(this.getRootKeyParams());case 12:return n.t5=n.sent,n.t6={keyParams:n.t5},n.t7=(0,n.t2)(n.t3,n.t4,n.t6),n.t8=n.t1.Create.call(n.t1,n.t7),n.next=18,n.t0.awrap.call(n.t0,n.t8);case 18:return t=n.sent,n.abrupt("return",t);case 20:case"end":return n.stop()}},null,this,null,Promise)}},{key:"saveRootKeyToKeychain",value:function(){var e,t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Object(_.w)(this.rootKey)){n.next=2;break}throw'Attempting to non-existent root key to the keychain.';case 2:if(this.keyMode===Bn.RootKeyOnly){n.next=4;break}throw'Should not be persisting wrapped key to keychain.';case 4:return e=this.rootKey.getKeychainValue(),n.abrupt("return",this.executeCriticalFunction(function(){return t.deviceInterface.setNamespacedKeychainValue(e,t.identifier)}));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasRootKeyWrapper",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){return this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper}},{key:"rootKeyNeedsUnwrapping",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.hasRootKeyWrapper());case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}e.t0=Object(_.w)(this.rootKey);case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyWrapperKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getWrappedRootKey",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.WrappedRootKey,De.Nonwrapped));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode!==Bn.WrapperOnly){e.next=4;break}return e.abrupt("return",this.getRootKeyWrapperKeyParams());case 4:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){e.next=8;break}return e.abrupt("return",this.getAccountKeyParams());case 8:if(this.keyMode!==Bn.RootKeyNone){e.next=12;break}return e.abrupt("return",void 0);case 12:throw"Unhandled key mode for getRootKeyParams ".concat(this.keyMode);case 13:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateWrappingKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:if(t=a.sent,this.keyMode!==Bn.WrapperOnly){a.next=7;break}return a.abrupt("return",this.storageService.canDecryptWithKey(e));case 7:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){a.next=15;break}return n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:return r=a.sent,a.abrupt("return",!r.errorDecrypting);case 15:throw'Unhandled case in validateWrappingKey';case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeWrappingKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=r.sent,r.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=r.sent,r.abrupt("return",n);case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"unwrapRootKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.keyMode!==Bn.WrapperOnly){a.next=3;break}return this.rootKey=e,a.abrupt("return");case 3:if(this.keyMode===Bn.RootKeyPlusWrapper){a.next=5;break}throw'Invalid key mode condition for unwrapping.';case 5:return a.next=7,b.awrap(this.getWrappedRootKey());case 7:return t=a.sent,n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:if(!(r=a.sent).errorDecrypting){a.next=16;break}throw Error('Unable to decrypt root key with provided wrapping key.');case 16:return a.next=18,b.awrap(Ve.Create(r.contentObject,r.uuid));case 18:return this.rootKey=a.sent,a.next=21,b.awrap(this.notifyObserversOfKeyChange());case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setNewRootKeyWrapper",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.keyMode!==Bn.RootKeyNone){t.next=4;break}this.keyMode=Bn.WrapperOnly,t.next=9;break;case 4:if(this.keyMode!==Bn.RootKeyOnly){t.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,t.next=9;break;case 8:throw Error('Attempting to set wrapper on already wrapped key.');case 9:return t.next=11,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 11:if(this.keyMode!==Bn.WrapperOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){t.next=26;break}if(this.keyMode!==Bn.WrapperOnly){t.next=18;break}return this.rootKey=e,t.next=16,b.awrap(this.reencryptItemsKeys());case 16:t.next=20;break;case 18:return t.next=20,b.awrap(this.wrapAndPersistRootKey(e));case 20:return t.next=22,b.awrap(this.storageService.setValue(o.RootKeyWrapperKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 22:return t.next=24,b.awrap(this.notifyObserversOfKeyChange());case 24:t.next=27;break;case 26:throw Error('Invalid keyMode on setNewRootKeyWrapper');case 27:case"end":return t.stop()}},null,this,null,Promise)}},{key:"wrapAndPersistRootKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=Object(Ee.e)(this.rootKey,{content:this.rootKey.persistableValueWhenWrapping()}),r.next=3,b.awrap(this.payloadByEncryptingPayload(t,Re.b.LocalStorageEncrypted,e));case 3:return n=r.sent,r.next=6,b.awrap(this.storageService.setValue(o.WrappedRootKey,n.ejected(),De.Nonwrapped));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removeRootKeyWrapper",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper){e.next=2;break}throw Error('Attempting to remove root key wrapper on unwrapped key.');case 2:return this.keyMode===Bn.WrapperOnly?(this.keyMode=Bn.RootKeyNone,this.rootKey=void 0):this.keyMode===Bn.RootKeyPlusWrapper&&(this.keyMode=Bn.RootKeyOnly),e.next=5,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 5:return e.next=7,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 7:if(this.keyMode!==Bn.RootKeyOnly){e.next=10;break}return e.next=10,b.awrap(this.saveRootKeyToKeychain());case 10:return e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.keyParams){n.next=2;break}throw Error('keyParams must be supplied if setting root key.');case 2:if(this.rootKey!==e){n.next=4;break}throw Error('Attempting to set root key as same current value.');case 4:if(this.keyMode!==Bn.WrapperOnly){n.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,n.next=16;break;case 8:if(this.keyMode!==Bn.RootKeyNone){n.next=12;break}this.keyMode=Bn.RootKeyOnly,n.next=16;break;case 12:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){n.next=15;break}n.next=16;break;case 15:throw Error("Unhandled key mode for setNewRootKey ".concat(this.keyMode));case 16:return this.rootKey=e,n.next=19,b.awrap(this.storageService.setValue(o.RootKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 19:if(this.keyMode!==Bn.RootKeyOnly){n.next=24;break}return n.next=22,b.awrap(this.saveRootKeyToKeychain());case 22:n.next=29;break;case 24:if(this.keyMode!==Bn.RootKeyPlusWrapper){n.next=29;break}if(t){n.next=27;break}throw Error('wrappingKey must be supplied');case 27:return n.next=29,b.awrap(this.wrapAndPersistRootKey(t));case 29:return n.next=31,b.awrap(this.notifyObserversOfKeyChange());case 31:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getRootKey",value:function(){return this.rootKey}},{key:"clearLocalKeyState",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 2:return e.next=4,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 6:return e.next=8,b.awrap(this.storageService.removeValue(o.RootKeyParams,De.Nonwrapped));case 8:return this.keyMode=Bn.RootKeyNone,this.rootKey=void 0,e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:if(n=a.sent,!(r=this.rootKey.compare(n))){a.next=11;break}return a.abrupt("return",{valid:r,artifacts:{rootKey:n}});case 11:return a.abrupt("return",{valid:!1});case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"validatePasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=a.sent,a.next=8,b.awrap(this.validateWrappingKey(n));case 8:if(!(r=a.sent)){a.next=13;break}return a.abrupt("return",{valid:r,artifacts:{wrappingKey:n}});case 13:return a.abrupt("return",{valid:!1});case 14:case"end":return a.stop()}},null,this,null,Promise)}},{key:"keyToUseForEncryptionOfPayload",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Object(_.w)(t)){s.next=2;break}throw'Intent must be supplied when looking up key for encryption of item.';case 2:if(!Object(Re.a)(e.content_type)){s.next=13;break}if(n=this.getRootKey()){s.next=10;break}if(!Object(Re.c)(t)){s.next=9;break}throw Error('Root key encryption is required but no root key is available.');case 9:return s.abrupt("return",void 0);case 10:return s.abrupt("return",n);case 13:return r=this.getDefaultItemsKey(),s.next=16,b.awrap(this.getUserVersion());case 16:if(!(a=s.sent)||a===(null===r||void 0===r?void 0:r.keyVersion)){s.next=22;break}return i=this.latestItemsKeys(),s.abrupt("return",i.find(function(e){return e.keyVersion===a}));case 22:return s.abrupt("return",r);case 23:case"end":return s.stop()}},null,this,null,Promise)}},{key:"keyToUseForDecryptionOfPayload",value:function(e){if(Object(Re.a)(e.content_type))return this.getRootKey();if(e.items_key_id)return this.itemsKeyForPayload(e);var t=e.version;if(t!==this.getLatestVersion())return this.defaultItemsKeyForItemVersion(t);we.a.error(Error('No associated key found for item encrypted with latest protocol version.'))}},{key:"onSyncEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.b.FullSyncCompleted){t.next=3;break}return t.next=3,b.awrap(this.handleFullSyncCompletion());case 3:if(e!==At.b.DownloadFirstSyncCompleted){t.next=6;break}return t.next=6,b.awrap(this.handleDownloadFirstSyncCompletion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleDownloadFirstSyncCompletion",value:function(){var e,t,n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.hasAccount()){c.next=2;break}return c.abrupt("return");case 2:if(e=this.latestItemsKeys(),t=e.filter(function(e){return e.neverSynced}),n=e.filter(function(e){return!e.neverSynced}),r=n.find(function(e){return e.isDefault}),!!Object(_.w)(r)){c.next=12;break}return c.next=10,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(t)));case 10:c.next=21;break;case 12:if(!(a=this.getRootKey())){c.next=21;break}if(!((i=t.filter(function(e){return e.keyVersion!==a.keyVersion})).length>0)){c.next=18;break}return c.next=18,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(i)));case 18:if(0!==this.latestItemsKeys().length){c.next=21;break}return c.next=21,b.awrap(this.createNewDefaultItemsKey());case 21:return c.next=23,b.awrap(this.getUserVersion());case 23:if(s=c.sent,o=this.latestItemsKeys().find(function(e){return e.keyVersion===s}),!Object(_.w)(o)){c.next=28;break}return c.next=28,b.awrap(this.createNewDefaultItemsKey());case 28:this.syncUnsycnedItemsKeys();case 29:case"end":return c.stop()}},null,this,null,Promise)}},{key:"handleFullSyncCompletion",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,b.awrap(this.createNewDefaultItemsKey());case 4:if(this.keyMode!==Bn.WrapperOnly){e.next=6;break}return e.abrupt("return",this.repersistAllItems());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"syncUnsycnedItemsKeys",value:function(){if(this.hasAccount()){var e=this.latestItemsKeys().filter(function(e){return e.neverSynced&&!e.dirty&&!e.deleted});e.length>0&&this.itemManager.setItemsDirty(Object(Ke.b)(e))}}},{key:"repersistAllItems",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e)}),n.abrupt("return",this.storageService.savePayloads(t));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"latestItemsKeys",value:function(){return this.itemManager.itemsKeys()}},{key:"itemsKeyForPayload",value:function(e){return this.latestItemsKeys().find(function(t){return t.uuid===e.items_key_id||t.duplicateOf===e.items_key_id})}},{key:"getDefaultItemsKey",value:function(){var e=this.latestItemsKeys();if(1===e.length)return e[0];var t=e.filter(function(e){return e.isDefault});if(t.length>1){var n=t.filter(function(e){return!e.neverSynced});if(n.length,n.length>0)return n[0]}return t[0]}},{key:"getKeyEmbeddedKeyParams",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.payload.format!==ue.a.DecryptedBareObject){s.next=2;break}return s.abrupt("return",void 0);case 2:return t=e.version,n=this.operatorForVersion(t),s.next=6,b.awrap(n.getPayloadAuthenticatedData(e.payload));case 6:if(r=s.sent){s.next=9;break}return s.abrupt("return",void 0);case 9:if(!Object(Q.c)(t,Q.a.V003)){s.next=14;break}return a=r,s.abrupt("return",this.createKeyParams(a));case 14:return i=r.kp,s.abrupt("return",this.createKeyParams(i));case 16:case"end":return s.stop()}},null,this,null,Promise)}},{key:"reencryptItemsKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!((e=this.latestItemsKeys()).length>0)){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"defaultItemsKeyForItemVersion",value:function(e,t){var n=t||this.latestItemsKeys(),r=n.find(function(t){return t.isDefault&&t.keyVersion===e});return r||n.find(function(t){return t.keyVersion===e})}},{key:"needsNewRootKeyBasedItemsKey",value:function(){if(!this.hasAccount())return!1;var e=this.getRootKey();if(!e)return!1;if(Object(Q.b)(e.keyVersion,Yn)>0)return!1;var t=this.getDefaultItemsKey();return!t||t.itemsKey!==e.itemsKey}},{key:"createNewDefaultItemsKey",value:function(){var e,t,n,r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e=this.getRootKey(),t=e?e.keyVersion:this.getLatestVersion(),!(Object(Q.b)(t,Yn)<=0)){l.next=14;break}return l.t0=Object(Ee.e),l.next=6,b.awrap(I.GenerateUuid());case 6:l.t1=l.sent,l.t2=F.a.ItemsKey,l.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t}),l.t4={uuid:l.t1,content_type:l.t2,content:l.t3},r=(0,l.t0)(l.t4),n=nt(r),l.next=17;break;case 14:return l.next=16,b.awrap(this.operatorForVersion(t).createItemsKey());case 16:n=l.sent;case 17:a=this.latestItemsKeys(),i=a.filter(function(e){return e.isDefault}),s=S(i);case 20:if((o=s()).done){l.next=26;break}return c=o.value,l.next=24,b.awrap(this.itemManager.changeItemsKey(c.uuid,function(e){e.isDefault=!1}));case 24:l.next=20;break;case 26:return l.next=28,b.awrap(this.itemManager.insertItem(n));case 28:return u=l.sent,l.next=31,b.awrap(this.itemManager.changeItemsKey(u.uuid,function(e){e.isDefault=!0}));case 31:return l.abrupt("return",u);case 32:case"end":return l.stop()}},null,this,null,Promise)}},{key:"createNewItemsKeyWithRollback",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=this.getDefaultItemsKey(),a.next=3,b.awrap(this.createNewDefaultItemsKey());case 3:return t=a.sent,n=function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(Promise.all([r.itemManager.setItemToBeDeleted(t.uuid),r.itemManager.changeItem(e.uuid,function(e){e.isDefault=!0})]));case 2:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getPasswordCreatedDate",value:function(){var e=this.getRootKey();return e?e.keyParams.createdDate:void 0}}]),n})(R.a),Qn=(function(){function e(t,n){v(this,e),this.defaultContentKeyToDiffOn='text',this.payload=Object(Ee.b)(t),this.previousEntry=n,this.hasPreviousEntry=!Object(_.w)(n);var r=this.payload.content[this.defaultContentKeyToDiffOn];this.textCharDiffLength=r?n?r.length-n.payload.content[this.defaultContentKeyToDiffOn].length:this.payload.content[this.defaultContentKeyToDiffOn].length:0}return y(e,[{key:"itemFromPayload",value:function(){return nt(this.payload)}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=this.itemFromPayload(),n=e.itemFromPayload();return!(t.userModifiedDate.getTime()!==n.userModifiedDate.getTime())&&t.isItemContentEqualWith(n)}},{key:"isDiscardable",value:function(){return!1}},{key:"operationVector",value:function(){return void 0!==this.textCharDiffLength?this.hasPreviousEntry&&0!==this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!==this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}}]),e})(),Jn=(function(e){d(n,Qn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"previewTitle",value:function(){return this.payload.updated_at.getTime()>0?this.payload.updated_at.toLocaleString():this.payload.created_at.toLocaleString()}},{key:"previewSubTitle",value:function(){return this.hasPreviousEntry?this.textCharDiffLength<0?"".concat(-1*this.textCharDiffLength," characters removed"):this.textCharDiffLength>0?"".concat(this.textCharDiffLength," characters added"):'Title or metadata changed':"".concat(this.textCharDiffLength," characters loaded")}},{key:"isDiscardable",value:function(){return Object(_.t)(this.payload.safeContent.text)}}]),n})();function $n(e,t){return new(Xn(e[Je.a.ContentType]))(e,t)}function Xn(e){switch(e){case F.a.Note:return Jn;default:return Qn}}var Zn,er,tr=20,nr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s){var o;return v(this,n),(o=t.call(this)).itemManager=e,o.storageService=r,o.apiService=a,o.protocolService=i,o.deviceInterface=s,o.persistable=!1,o.autoOptimize=!1,o.historyStaging={},o.history={},o.historyTypes=[F.a.Note],o.itemRevisionThreshold=tr,o.removeChangeObserver=o.itemManager.addObserver(o.historyTypes,function(e,t){o.recordNewHistoryForItems(e.concat(t))}),o}return y(n,[{key:"deinit",value:function(){this.cancelPendingPersist(),this.itemManager=void 0,this.storageService=void 0,this.history=void 0,this.removeChangeObserver&&(this.removeChangeObserver(),this.removeChangeObserver=void 0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.SessionHistoryPersistable));case 2:return this.persistable=e.sent,e.next=5,b.awrap(this.getPersistedHistory());case 5:return this.history=e.sent,e.next=8,b.awrap(this.storageService.getValue(o.SessionHistoryOptimize,void 0,!0));case 8:this.autoOptimize=e.sent;case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPersistedHistory",value:function(){var e,t,n,r,a,i,s,c,u,p,d,h,f,v,y,g;return b.async(function(m){for(;;)switch(m.prev=m.next){case 0:return e={},m.next=3,b.awrap(this.storageService.getValue(o.SessionHistoryRevisions));case 3:if(t=m.sent){m.next=6;break}return m.abrupt("return",e);case 6:for(n=0,r=Object.entries(t);n<r.length;n++){for(a=r[n],i=l(a,2),s=i[0],c=i[1],u=c.slice().reverse(),p=[],d=S(u);!(h=d()).done;)f=h.value,v=Object(Ee.f)(f.payload,ht.a.SessionHistory),y=yt(p),g=$n(v,y),p.unshift(g);e[s]=p}return m.abrupt("return",e);case 8:case"end":return m.stop()}},null,this,null,Promise)}},{key:"recordNewHistoryForItems",value:function(e){for(var t,n=!1,r=S(e);!(t=r()).done;){var a=t.value;if(this.historyTypes.includes(a.content_type)){var i=a.payload;if(!a.deleted&&i.format===ue.a.DecryptedBareObject){var s=this.history[a.uuid]||[],o=yt(s),c=$n(Object(Ee.f)(a,ht.a.SessionHistory),o);if(!c.isDiscardable()){var u=this.historyStaging[a.uuid];this.historyStaging[a.uuid]=c,u&&(u.isSameAsEntry(c)||o&&u.isSameAsEntry(o)||(s.unshift(u),this.history[a.uuid]=s,this.autoOptimize&&this.optimizeHistoryForItem(a.uuid),n=!0))}}}}n&&this.saveToDisk()}},{key:"isDiskEnabled",value:function(){return this.persistable}},{key:"isAutoOptimizeEnabled",value:function(){return this.autoOptimize}},{key:"cancelPendingPersist",value:function(){this.saveTimeout&&('cancel'in this.deviceInterface.timeout?this.deviceInterface.timeout.cancel(this.saveTimeout):clearTimeout(this.saveTimeout))}},{key:"saveToDisk",value:function(){var e=this;if(this.persistable){this.cancelPendingPersist();var t=this.persistableHistoryValue();this.saveTimeout=this.deviceInterface.timeout(function(){e.storageService.setValue(o.SessionHistoryRevisions,t)},2e3)}}},{key:"persistableHistoryValue",value:function(){for(var e={},t=0,n=Object.entries(this.history);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1].map(function(e){return{payload:e.payload}});e[i]=s}return e}},{key:"setSessionItemRevisionThreshold",value:function(e){this.itemRevisionThreshold=e}},{key:"sessionHistoryForItem",value:function(e){return this.history[e.uuid]||[]}},{key:"clearHistoryForItem",value:function(e){delete this.history[e.uuid],this.saveToDisk()}},{key:"clearAllHistory",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.history={},e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleDiskSaving",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistable=!this.persistable,!this.persistable){e.next=6;break}this.storageService.setValue(o.SessionHistoryPersistable,!0),this.saveToDisk(),e.next=8;break;case 6:return this.storageService.setValue(o.SessionHistoryPersistable,!1),e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 8:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleAutoOptimize",value:function(){this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageService.setValue(o.SessionHistoryOptimize,!0):this.storageService.setValue(o.SessionHistoryOptimize,!1)}},{key:"getHistoryMapCopy",value:function(){for(var e=w({},this.history),t=0,n=Object.entries(e);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1];e[i]=s.slice()}return Object.freeze(e)}},{key:"remoteHistoryForItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.getItemRevisions(e.uuid));case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.abrupt("return",t.data);case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"fetchRemoteRevision",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.apiService.getRevision(t,e));case 2:if(!(n=o.sent).error&&!Object(_.w)(n.data)){o.next=5;break}return o.abrupt("return",void 0);case 5:return r=n.data,a=Object(Ee.e)(r,{uuid:r.item_uuid}),i=Object(Ee.f)(a,ht.a.RemoteHistory),o.next=10,b.awrap(this.protocolService.payloadByDecryptingPayload(i));case 10:if(!(s=o.sent).errorDecrypting){o.next=13;break}return o.abrupt("return",void 0);case 13:return o.abrupt("return",new Qn(s));case 14:case"end":return o.stop()}},null,this,null,Promise)}},{key:"optimizeHistoryForItem",value:function(e){var t=this.history[e]||[];if(!(t.length<=this.itemRevisionThreshold)){for(var n=function(e){return e.deltaSize()>25},r=[],a=function(e,a,i){if(i){if(r.unshift(e),n(e)&&-1===e.operationVector()){var s=t[a+1];s&&r.unshift(s)}}else Object(_.M)(r,e)},i=t.length-1;i>=0;i--){var s=t[i];a(s,i,0===i||i===t.length-1||n(s))}var o=t.filter(function(e){return r.includes(e)});this.history[e]=o}}}]),n})(R.a);!(function(e){e.SessionExpiryDateChanged="SessionExpiryDateChanged"})(Zn||(Zn={})),(function(e){e[e.None=0]="None",e[e.FiveMinutes=300]="FiveMinutes",e[e.OneHour=3600]="OneHour",e[e.OneWeek=604800]="OneWeek"})(er||(er={}));var rr,ar=[{valueInSeconds:er.None,label:"Don't Remember"},{valueInSeconds:er.FiveMinutes,label:'5 Minutes'},{valueInSeconds:er.OneHour,label:'1 Hour'},{valueInSeconds:er.OneWeek,label:'1 Week'}],ir=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).protocolService=e,s.challengeService=r,s.storageService=a,s.itemManager=i,s.sessionExpiryTimeout=-1,s}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.challengeService=void 0,this.storageService=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return e===ve.LoadedDatabase_12&&this.updateSessionExpiryTimer(this.getSessionExpiryDate()),Promise.resolve()}},{key:"hasProtectionSources",value:function(){return this.protocolService.hasAccount()||this.protocolService.hasPasscode()||this.hasBiometricsEnabled()}},{key:"areProtectionsEnabled",value:function(){return this.hasProtectionSources()&&this.getSessionExpiryDate()<=new Date}},{key:"hasBiometricsEnabled",value:function(){var e=this.storageService.getValue(o.BiometricsState,De.Nonwrapped);return Boolean(e)}},{key:"enableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to enable biometrics when they already are enabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.storageService.setValue(o.BiometricsState,!0,De.Nonwrapped));case 5:return e.abrupt("return",!0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"disableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to disable biometrics when they already are disabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.validateOrRenewSession(ne.DisableBiometrics));case 5:if(!e.sent){e.next=11;break}return e.next=8,b.awrap(this.storageService.setValue(o.BiometricsState,!1,De.Nonwrapped));case 8:return e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"createLaunchChallenge",value:function(){var e=[];return this.hasBiometricsEnabled()&&e.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&e.push(new ge(te.LocalPasscode)),e.length>0?new ye(e,ne.ApplicationUnlock,!1):void 0}},{key:"protectNote",value:function(e){return this.itemManager.changeItem(e.uuid,function(e){e.protected=!0})}},{key:"unprotectNote",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.validateOrRenewSession(ne.UnprotectNote));case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.itemManager.changeItem(e.uuid,function(e){e.protected=!1}));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){c.next=15;break}if(s=i.value,(o=s.protected&&this.areProtectionsEnabled())&&!n&&(n=this.validateOrRenewSession(t)),c.t0=!o,c.t0){c.next=11;break}return c.next=10,b.awrap(n);case 10:c.t0=c.sent;case 11:if(!c.t0){c.next=13;break}r.push(s);case 13:c.next=2;break;case 15:return c.abrupt("return",r);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){return this.itemManager.changeItems(Object(Ke.b)(e),function(e){e.protected=!0})}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.authorizeProtectedActionForNotes(e,ne.UnprotectNote));case 2:return t=n.sent,n.abrupt("return",this.itemManager.changeItems(Object(Ke.b)(t),function(e){e.protected=!1}));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeNoteAccess",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.protected){t.next=2;break}return t.abrupt("return",!0);case 2:return t.abrupt("return",this.validateOrRenewSession(ne.AccessProtectedNote));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeAddingPasscode",value:function(){return this.validateOrRenewSession(ne.AddPasscode)}},{key:"authorizeChangingPasscode",value:function(){return this.validateOrRenewSession(ne.ChangePasscode)}},{key:"authorizeRemovingPasscode",value:function(){return this.validateOrRenewSession(ne.RemovePasscode)}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.validateOrRenewSession(ne.SearchProtectedNotesText)}},{key:"authorizeFileImport",value:function(){return this.validateOrRenewSession(ne.ImportFile)}},{key:"authorizeBackupCreation",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.validateOrRenewSession(ne.ExportBackup,{fallBackToAccountPassword:e}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeMfaDisable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.DisableMfa,{requireAccountPassword:!0}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeAutolockIntervalChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.ChangeAutolockInterval));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeSessionRevoking",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.RevokeSession));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeCloudLinkAccess",value:function(){return this.validateOrRenewSession(ne.AccessCloudLink)}},{key:"validateOrRenewSession",value:function(e){var t,n,r,a,i,s,o,c,u,l=arguments;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>1&&void 0!==l[1]?l[1]:{},n=t.fallBackToAccountPassword,r=void 0===n||n,a=t.requireAccountPassword,i=void 0!==a&&a,!(this.getSessionExpiryDate()>new Date)){p.next=3;break}return p.abrupt("return",!0);case 3:if(s=[],this.hasBiometricsEnabled()&&s.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&s.push(new ge(te.LocalPasscode)),!i){p.next=10;break}if(this.protocolService.hasAccount()){p.next=9;break}throw Error('Requiring account password for challenge with no account');case 9:s.push(new ge(te.AccountPassword));case 10:if(0!==s.length){p.next=16;break}if(!r||!this.protocolService.hasAccount()){p.next=15;break}s.push(new ge(te.AccountPassword)),p.next=16;break;case 15:return p.abrupt("return",!0);case 16:return p.t0=s,p.t1=ge,p.t2=te.ProtectionSessionDuration,p.t3=void 0,p.t4=void 0,p.t5=void 0,p.t6=void 0,p.next=25,b.awrap(this.getSessionLength());case 25:return p.t7=p.sent,p.t8=new p.t1(p.t2,p.t3,p.t4,p.t5,p.t6,p.t7),p.t0.push.call(p.t0,p.t8),p.next=30,b.awrap(this.challengeService.promptForChallengeResponse(new ye(s,e,!0)));case 30:if(!(o=p.sent)){p.next=42;break}if(u=null===(c=o.values.find(function(e){return e.prompt.validation===te.ProtectionSessionDuration}))||void 0===c?void 0:c.value,!Object(_.w)(u)){p.next=37;break}we.a.error(Error('No valid protection session length found. Got '+u)),p.next=39;break;case 37:return p.next=39,b.awrap(this.setSessionLength(u));case 39:return p.abrupt("return",!0);case 42:return p.abrupt("return",!1);case 43:case"end":return p.stop()}},null,this,null,Promise)}},{key:"getSessionExpiryDate",value:function(){var e=this.storageService.getValue(o.ProtectionExpirey);return e?new Date(e):new Date}},{key:"clearSession",value:function(){return this.setSessionExpiryDate(new Date)}},{key:"setSessionExpiryDate",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.ProtectionExpirey,e));case 2:this.notifyEvent(Zn.SessionExpiryDateChanged);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSessionLength",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ProtectionSessionLength));case 2:if(!(e=t.sent)){t.next=7;break}return t.abrupt("return",e);case 7:return t.abrupt("return",er.None);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setSessionLength",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.storageService.setValue(o.ProtectionSessionLength,e));case 2:return(t=new Date).setSeconds(t.getSeconds()+e),n.next=6,b.awrap(this.setSessionExpiryDate(t));case 6:this.updateSessionExpiryTimer(t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSessionExpiryTimer",value:function(e){var t=this,n=e.getTime();if(n>Date.now()){clearTimeout(this.sessionExpiryTimeout),this.sessionExpiryTimeout=setTimeout(function(){t.setSessionExpiryDate(new Date)},n-Date.now())}}}]),n})(R.a),sr=n(45),or=n(19);!(function(e){e.UserRoleMessageReceived="WebSocketMessageReceived"})(rr||(rr={}));var cr,ur,lr=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.webSocketUrl=r,a}return y(n,[{key:"setWebSocketUrl",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.webSocketUrl=e,t.next=3,b.awrap(this.storageService.setValue(o.WebSocketUrl,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadWebSocketUrl",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.WebSocketUrl));case 2:e=t.sent,this.webSocketUrl=e||this.webSocketUrl||window._websocket_url;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"startWebSocketConnection",value:function(e){if(this.webSocketUrl)try{this.webSocket=new WebSocket("".concat(this.webSocketUrl,"?authToken=Bearer+").concat(e)),this.webSocket.onmessage=this.onWebSocketMessage.bind(this),this.webSocket.onclose=this.onWebSocketClose.bind(this)}catch(e){console.error('Error starting WebSocket connection',e)}}},{key:"closeWebSocketConnection",value:function(){var e;null===(e=this.webSocket)||void 0===e||e.close()}},{key:"onWebSocketMessage",value:function(e){var t=JSON.parse(e.data);this.notifyEvent(rr.UserRoleMessageReceived,t)}},{key:"onWebSocketClose",value:function(){this.webSocket=void 0}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.storageService=void 0,this.closeWebSocketConnection()}}]),n})(R.a),pr=n(29);!(function(e){e.UserRolesChanged="UserRolesChanged",e.FeaturesUpdated="FeaturesUpdated"})(cr||(cr={})),(function(e){e.NoUserSubscription="NoUserSubscription",e.NotInCurrentPlan="NotInCurrentPlan",e.InCurrentPlanButExpired="InCurrentPlanButExpired",e.Entitled="Entitled"})(ur||(ur={}));var dr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l,p,d){var h;return v(this,n),(h=t.call(this)).storageService=e,h.apiService=r,h.itemManager=a,h.componentManager=i,h.webSocketsService=s,h.settingsService=o,h.credentialService=c,h.syncService=u,h.alertService=l,h.sessionManager=p,h.crypto=d,h.deinited=!1,h.roles=[],h.features=[],h.needsInitialFeaturesUpdate=!0,h.completedSuccessfulFeaturesRetrieval=!1,h.removeApiServiceObserver=r.addEventObserver(function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==Ht.MetaReceived){a.next=6;break}if(h.syncService.completedOnlineDownloadFirstSync){a.next=3;break}return a.abrupt("return");case 3:return n=t.userUuid,r=t.userRoles,a.next=6,b.awrap(h.updateRoles(n,r.map(function(e){return e.name})));case 6:case"end":return a.stop()}},null,null,null,Promise)}),h.removeWebSocketsServiceObserver=s.addEventObserver(function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e!==rr.UserRoleMessageReceived){i.next=6;break}return n=t.payload,r=n.userUuid,a=n.currentRoles,i.next=4,b.awrap(h.setRoles(a));case 4:return i.next=6,b.awrap(h.updateFeatures(r));case 6:case"end":return i.stop()}},null,null,null,Promise)}),h.removefeatureReposObserver=h.itemManager.addObserver(or.ContentType.ExtensionRepo,function(e,t,n,r,a){var i,s;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=[ht.a.Constructor,ht.a.LocalRetrieved,ht.a.RemoteRetrieved,ht.a.FileImport],!a||!i.includes(a)){n.next=10;break}if(s=[].concat(m(e),m(t)).filter(function(e){return!e.deleted}),!h.sessionManager.isSignedIntoFirstPartyServer()){n.next=8;break}return n.next=6,b.awrap(h.migrateFeatureRepoToUserSetting(s));case 6:n.next=10;break;case 8:return n.next=10,b.awrap(h.migrateFeatureRepoToOfflineEntitlements(s));case 10:case"end":return n.stop()}},null,null,null,Promise)}),h.removeSignInObserver=h.credentialService.addEventObserver(function(e){if(e===Ye.SignedInOrRegistered){var t=h.itemManager.getItems(or.ContentType.ExtensionRepo);h.apiService.isThirdPartyHostUsed()||h.migrateFeatureRepoToUserSetting(t)}}),h}return y(n,[{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.FullSyncCompleted_13&&(t=this.getOfflineRepo())&&this.downloadOfflineFeatures(t);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setOfflineFeaturesCode",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,t=e.replace(/\s/g,''),i.next=4,b.awrap(this.crypto.base64Decode(t));case 4:if(n=i.sent,r=this.parseOfflineEntitlementsCode(n),!Object(_.u)(r)){i.next=8;break}return i.abrupt("return",r);case 8:return i.next=10,b.awrap(this.itemManager.createItem(or.ContentType.ExtensionRepo,Object(Ke.a)({offlineFeaturesUrl:r.featuresUrl,offlineKey:r.extensionKey,migratedToOfflineEntitlements:!0}),!0));case 10:return a=i.sent,this.syncService.sync(),i.abrupt("return",this.downloadOfflineFeatures(a));case 15:return i.prev=15,i.t0=i.catch(0),i.abrupt("return",{error:j.e});case 18:case"end":return i.stop()}},null,this,[[0,15]],Promise)}},{key:"getOfflineRepo",value:function(){return this.itemManager.getItems(or.ContentType.ExtensionRepo).filter(function(e){return e.migratedToOfflineEntitlements})[0]}},{key:"hasOfflineRepo",value:function(){return void 0!=this.getOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this.getOfflineRepo())){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 4:return t.next=6,b.awrap(this.storageService.removeValue(o.UserFeatures));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"parseOfflineEntitlementsCode",value:function(e){try{var t=JSON.parse(e);return{featuresUrl:t.featuresUrl,extensionKey:t.extensionKey}}catch(e){return{error:j.e}}}},{key:"downloadOfflineFeatures",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.downloadOfflineFeaturesFromRepo(e));case 2:if(t=n.sent,!Object(_.u)(t)){n.next=5;break}return n.abrupt("return",t);case 5:return n.next=7,b.awrap(this.didDownloadFeatures(t.features));case 7:return n.next=9,b.awrap(this.mapFeaturesToItems(t.features));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToUserSetting",value:function(){var e,t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:[],t=S(e);case 2:if((n=t()).done){c.next=17;break}if(!(r=n.value).migratedToUserSetting){c.next=6;break}return c.abrupt("continue",15);case 6:if(!r.onlineUrl){c.next=15;break}if(a=r.onlineUrl,!((i=a.match(/\w{32,64}/))&&i.length>0)){c.next=15;break}return s=i[0],c.next=13,b.awrap(this.settingsService.updateSetting(pr.SettingName.ExtensionKey,s,!0));case 13:return c.next=15,b.awrap(this.itemManager.changeFeatureRepo(r.uuid,function(e){e.migratedToUserSetting=!0}));case 15:c.next=2;break;case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToOfflineEntitlements",value:function(){var e,t,n,r,a,i,s,o=this,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=c.length>0&&void 0!==c[0]?c[0]:[],t=S(e);case 2:if((n=t()).done){u.next=17;break}if(!(r=n.value).migratedToOfflineEntitlements){u.next=6;break}return u.abrupt("continue",15);case 6:if(!r.onlineUrl){u.next=15;break}if(a=r.onlineUrl,i=new URL(a),i.origin.includes("https://extensions.standardnotes.org")){u.next=11;break}return u.abrupt("continue",15);case 11:if(!((s=a.match(/\w{32,64}/))&&s.length>0)){u.next=15;break}return u.next=15,b.awrap((function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=s[0],n.next=3,b.awrap(o.itemManager.changeFeatureRepo(r.uuid,function(t){t.offlineFeaturesUrl="https://api.standardnotes.com/v1/offline/features",t.offlineKey=e,t.migratedToOfflineEntitlements=!0}));case 3:return t=n.sent,n.next=6,b.awrap(o.downloadOfflineFeatures(t));case 6:case"end":return n.stop()}},null,null,null,Promise)})());case 15:u.next=2;break;case 17:case"end":return u.stop()}},null,null,null,Promise)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.UserRoles,void 0,[]));case 2:return this.roles=e.sent,e.next=5,b.awrap(this.storageService.getValue(o.UserFeatures,void 0,[]));case 5:this.features=e.sent;case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"updateRoles",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.haveRolesChanged(t)&&!this.needsInitialFeaturesUpdate){n.next=7;break}return this.needsInitialFeaturesUpdate=!1,n.next=5,b.awrap(this.setRoles(t));case 5:return n.next=7,b.awrap(this.updateFeatures(e));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setRoles",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles=e,Object(_.e)(this.roles,e)||this.notifyEvent(cr.UserRolesChanged),t.next=4,b.awrap(this.storageService.setValue(o.UserRoles,this.roles));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"didDownloadFeatures",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.features=e,this.completedSuccessfulFeaturesRetrieval=!0,this.notifyEvent(cr.FeaturesUpdated),t.next=5,b.awrap(this.storageService.setValue(o.UserFeatures,this.features));case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getFeature",value:function(e){return this.features.find(function(t){return t.identifier===e})}},{key:"hasPaidOnlineOrOfflineSubscription",value:function(){if(this.sessionManager.isSignedIntoFirstPartyServer()){var e=this.roles,t=[sr.RoleName.BasicUser];return e.some(function(e){return!t.includes(e)})}return this.hasOfflineRepo()}},{key:"getFeatureStatus",value:function(e){if(void 0==L.Features.find(function(t){return t.identifier===e})){var t=this.itemManager.components.find(function(t){return t.identifier===e});return null!==t&&void 0!==t&&t.isExpired?ur.InCurrentPlanButExpired:ur.Entitled}if(this.hasPaidOnlineOrOfflineSubscription()&&!this.completedSuccessfulFeaturesRetrieval)return ur.Entitled;if(!this.hasPaidOnlineOrOfflineSubscription())return ur.NoUserSubscription;var n=this.features.find(function(t){return t.identifier===e});return n?n.expires_at&&new Date(n.expires_at).getTime()<(new Date).getTime()?this.roles.includes(n.role_name)?ur.InCurrentPlanButExpired:ur.NotInCurrentPlan:ur.Entitled:ur.NotInCurrentPlan}},{key:"haveRolesChanged",value:function(e){var t=this;return e.some(function(e){return!t.roles.includes(e)})||this.roles.some(function(t){return!e.includes(t)})}},{key:"updateFeatures",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.apiService.getUserFeatures(e));case 2:if((t=r.sent).error||!t.data||this.deinited){r.next=10;break}return(n=t.data.features).forEach(function(e){e.expires_at&&(e.expires_at=Object(_.i)(e.expires_at))}),r.next=8,b.awrap(this.didDownloadFeatures(n));case 8:return r.next=10,b.awrap(this.mapFeaturesToItems(n));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"componentContentForFeatureDescription",value:function(e){var t={area:e.area,hosted_url:e.url,name:e.name,package_info:e,valid_until:new Date(e.expires_at||0)};return Object(Ke.a)(t)}},{key:"mapFeaturesToItems",value:function(e){var t,n,r,a,i,s,o,c,u=this;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:t=this.itemManager.getItems([or.ContentType.Component,or.ContentType.Theme]),n=[],r=new Date,a=!1,i=function(e){var i,s,o,c;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e.content_type){l.next=2;break}return l.abrupt("return","continue");case 2:if(!e.url||Object(_.B)(e.url)){l.next=5;break}return l.abrupt("return","continue");case 5:if(i=new Date(e.expires_at||0).getTime()<r.getTime(),s=t.find(function(t){return!!t.safeContent.package_info&&(t.safeContent.package_info.identifier===e.identifier&&!t.deleted)}),o=s,!s){l.next=21;break}if(c=new Date(e.expires_at||0),!(e.url!==s.hosted_url||e.version!==s.package_info.version||c.getTime()!==s.valid_until.getTime())){l.next=18;break}return l.next=14,b.awrap(u.itemManager.changeComponent(s.uuid,function(t){t.hosted_url=e.url,t.package_info=e,t.valid_until=c}));case 14:o=l.sent,a=!0,l.next=19;break;case 18:o=s;case 19:l.next=26;break;case 21:if(i&&e.content_type!==or.ContentType.Component){l.next=26;break}return l.next=24,b.awrap(u.itemManager.createItem(e.content_type,u.componentContentForFeatureDescription(e),!0));case 24:o=l.sent,a=!0;case 26:i&&o&&(e.content_type===or.ContentType.Component?u.componentManager.setReadonlyStateForComponent(o,i):(n.push(o.uuid),a=!0));case 27:case"end":return l.stop()}},null,null,null,Promise)},s=S(e);case 6:if((o=s()).done){l.next=15;break}return c=o.value,l.next=10,b.awrap(i(c));case 10:if("continue"!==l.sent){l.next=13;break}return l.abrupt("continue",13);case 13:l.next=6;break;case 15:return l.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(n));case 17:a&&this.syncService.sync();case 18:case"end":return l.stop()}},null,this,null,Promise)}},{key:"validateAndDownloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=e,i.prev=1,i.next=4,b.awrap(this.crypto.base64Decode(e));case 4:t=i.sent,i.next=9;break;case 7:i.prev=7,i.t0=i.catch(1);case 9:if(i.prev=9,n=[].concat(Ft,Nt),r=new URL(t),a=r.host,n.includes(a)){i.next=20;break}return i.next=15,b.awrap(this.alertService.confirm(j.t,'Install extension from an untrusted source?','Proceed to install',St.Danger,'Cancel'));case 15:if(!i.sent){i.next=18;break}return i.abrupt("return",this.downloadExternalFeature(t));case 18:i.next=21;break;case 20:return i.abrupt("return",this.downloadExternalFeature(t));case 21:i.next=26;break;case 23:i.prev=23,i.t1=i.catch(9),this.alertService.alert(j.C);case 26:case"end":return i.stop()}},null,this,[[1,7],[9,23]],Promise)}},{key:"downloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.apiService.downloadFeatureUrl(e));case 2:if(!(t=i.sent).error){i.next=7;break}return i.next=6,b.awrap(this.alertService.alert(j.c));case 6:return i.abrupt("return",void 0);case 7:if((n=t.data).content_type){i.next=10;break}return i.abrupt("return");case 10:return r=this.componentContentForFeatureDescription(n),i.next=13,b.awrap(this.itemManager.createTemplateItem(n.content_type,r));case 13:return a=i.sent,i.abrupt("return",a);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.removeSignInObserver(),this.removeSignInObserver=void 0,this.removeApiServiceObserver(),this.removeApiServiceObserver=void 0,this.removeWebSocketsServiceObserver(),this.removeWebSocketsServiceObserver=void 0,this.removefeatureReposObserver(),this.removefeatureReposObserver=void 0,this.roles=void 0,this.storageService=void 0,this.apiService=void 0,this.itemManager=void 0,this.componentManager=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.credentialService=void 0,this.syncService=void 0,this.alertService=void 0,this.sessionManager=void 0,this.crypto=void 0,this.deinited=!0}}]),n})(R.a),hr=n(46),fr=(function(){function e(t,n){v(this,e),this.completedUpload=0,this.totalUpload=0,this.downloaded=0,this.databaseLoadCurrent=0,this.databaseLoadTotal=0,this.databaseLoadDone=!1,this.syncing=!1,this.interval=t,this.receiver=n}return y(e,[{key:"deinit",value:function(){this.stopTimingMonitor()}},{key:"setUploadStatus",value:function(e,t){this.completedUpload=e,this.totalUpload=t,this.receiver(on.a.StatusChanged)}},{key:"setDownloadStatus",value:function(e){this.downloaded+=e,this.receiver(on.a.StatusChanged)}},{key:"setDatabaseLoadStatus",value:function(e,t,n){this.databaseLoadCurrent=e,this.databaseLoadTotal=t,this.databaseLoadDone=n,n?this.receiver(on.a.LocalDataLoaded):this.receiver(on.a.LocalDataIncrementalLoad)}},{key:"getStats",value:function(){return{uploadCompletionCount:this.completedUpload,uploadTotalCount:this.totalUpload,downloadCount:this.downloaded,localDataDone:this.databaseLoadDone,localDataCurrent:this.databaseLoadCurrent,localDataTotal:this.databaseLoadTotal}}},{key:"setDidBegin",value:function(){this.syncing=!0,this.syncStart=new Date}},{key:"setDidEnd",value:function(){this.syncing=!1,this.syncEnd=new Date}},{key:"startTimingMonitor",value:function(){var e=this;this.timingMonitor&&this.stopTimingMonitor(),this.timingMonitor=this.interval(function(){e.secondsSinceSyncStart>5&&(e.receiver(on.a.SyncTakingTooLong),e.stopTimingMonitor())},500)}},{key:"stopTimingMonitor",value:function(){Object.prototype.hasOwnProperty.call(this.interval,'cancel')?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return!!this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.syncing=!1,this.error=null,this.stopTimingMonitor(),this.receiver(on.a.StatusChanged)}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return((new Date).getTime()-this.syncStart.getTime())/1e3}}]),e})();function vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mr,br=(function(){function e(){v(this,e),this.tags=[],this.includePinned=!0,this.includeProtected=!0,this.includeTrashed=!1,this.includeArchived=!1}return y(e,[{key:"computeFilters",value:function(e){for(var t,n=this,r=this.tags.filter(function(e){return!e.isSmartTag}),a=this.tags.filter(function(e){return e.isSmartTag}),i=a.filter(function(e){return e.isSystemSmartTag}),s=a.filter(function(e){return!e.isSystemSmartTag}),o=!1,c=!1,u=[],l=S(i);!(t=l()).done;){var p=t.value;p.isArchiveTag?(u.push(function(e){return e.archived&&!e.deleted}),o=!0):p.isTrashTag&&(u.push(function(e){return e.trashed&&!e.deleted}),c=!0)}if(s.length>0){var d=H.a.CompoundPredicate(s.map(function(e){return e.predicate}));u.push(function(t){if(d.keypathIncludesVerb('tags')){var n=yr(yr(yr({},t),t.payload),{},{tags:e.elementsReferencingElement(t,F.a.Tag)});return H.a.ObjectSatisfiesPredicate(n,d)}return H.a.ObjectSatisfiesPredicate(t,d)})}else if(r.length>0)for(var h,f=function(e){u.push(function(t){return e.hasRelationshipWithItem(t)})},v=S(r);!(h=v()).done;){f(h.value)}return this.searchQuery&&u.push(function(t){return xr(t,n.searchQuery,e)}),this.includePinned||u.push(function(e){return!e.pinned}),this.includeProtected||u.push(function(e){return!e.protected}),this.includeTrashed||c||u.push(function(e){return!e.trashed}),this.includeArchived||o||c||u.push(function(e){return!e.archived}),u}}],[{key:"Create",value:function(t){var n=new e;return w(n,t),Object.freeze(n)}},{key:"Copy",value:function(t,n){var r=new e;return w(r,t),w(r,n),Object.freeze(r)}}]),e})();function wr(e,t){var n=e.computeFilters(t);return t.displayElements(F.a.Note).filter(function(e){return kr(e,n)})}function kr(e,t){for(var n,r=S(t);!(n=r()).done;){if(!(0,n.value)(e))return!1}return!0}function xr(e,t,n){var r=n.elementsReferencingElement(e,F.a.Tag).some(function(e){return Pr(e,t.query)!==mr.None});if(e.protected&&!t.includeProtectedNoteText){var a=Sr(e,t.query);return a===mr.Title||a===mr.TitleAndText||r}return Sr(e,t.query)!==mr.None||r}function Sr(e,t){if(0===t.length)return mr.TitleAndText;var n=e.safeTitle().toLowerCase(),r=e.safeText().toLowerCase(),a=t.toLowerCase(),i=a.split(' '),s=Or(a);if(s)return(n.includes(s)?mr.Title:mr.None)+(r.includes(s)?mr.Text:mr.None);if(Cr(a))return e.uuid===a?mr.Uuid:mr.None;var o=i.every(function(e){return n.indexOf(e)>=0}),c=i.every(function(e){return r.indexOf(e)>=0});return(o?mr.Title:0)+(c?mr.Text:0)}function Pr(e,t){if(0===t.length)return mr.None;var n=e.title.toLowerCase(),r=t.toLowerCase(),a=r.split(' '),i=Or(r);return i?n.includes(i)?mr.Title:mr.None:a.every(function(e){return n.indexOf(e)>=0})?mr.Title:mr.None}function Or(e){var t=e.match(/"(.*?)"/);return t?t[1]:null}function Cr(e){return!!e.match(/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)}!(function(e){e[e.None=0]="None",e[e.Title=1]="Title",e[e.Text=2]="Text",e[e.TitleAndText=3]="TitleAndText",e[e.Uuid=5]="Uuid"})(mr||(mr={}));var Dr=(function(){function e(t){v(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:br.Create({});this.collection=t,this.criteria=n,this.displayedNotes=[],this.needsRebuilding=!0}return y(e,[{key:"setCriteria",value:function(e){this.criteria=e,this.collection.setDisplayOptions(F.a.Note,e.sortProperty,e.sortDirection),this.needsRebuilding=!0}},{key:"notesMatchingSmartTag",value:function(e){var t;return wr((t=e,br.Create({tags:[t]})),this.collection)}},{key:"rebuildList",value:function(){var e=this,t=br.Copy(this.criteria,{tags:this.criteria.tags.map(function(t){return t.isSystemSmartTag?t:e.collection.find(t.uuid)})});this.displayedNotes=wr(t,this.collection)}},{key:"setNeedsRebuilding",value:function(){this.needsRebuilding=!0}},{key:"displayElements",value:function(){return this.needsRebuilding&&(this.rebuildList(),this.needsRebuilding=!1),this.displayedNotes.slice()}}]),e})(),_r=(function(e){d(n,e);var t=k(n);function n(e){var r,a,i,s;return v(this,n),(r=t.call(this)).payloadManager=e,r.observers=[],r.payloadManager=e,r.systemSmartTags=(a=Object(Ee.e)({uuid:Er,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'All notes',isSystemTag:!0,isAllTag:!0})}),i=Object(Ee.e)({uuid:Rr,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Archived',isSystemTag:!0,isArchiveTag:!0})}),s=Object(Ee.e)({uuid:Ir,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Trash',isSystemTag:!0,isTrashTag:!0})}),[nt(a),nt(i),nt(s)]),r.createCollection(),r.unsubChangeObserver=r.payloadManager.addObserver(F.a.Any,r.setPayloads.bind(u(r))),r}return y(n,[{key:"createCollection",value:function(){this.collection=new gn,this.collection.setDisplayOptions(F.a.Note,dn.CreatedAt,'dsc'),this.collection.setDisplayOptions(F.a.Tag,dn.Title,'dsc'),this.collection.setDisplayOptions(F.a.ItemsKey,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Component,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Theme,dn.Title,'asc'),this.collection.setDisplayOptions(F.a.SmartTag,dn.Title,'asc'),this.notesView=new Dr(this.collection)}},{key:"setDisplayOptions",value:function(e,t,n,r){e===F.a.Note&&console.warn("Called setDisplayOptions with ContentType.Note. setNotesDisplayCriteria should be used instead."),this.collection.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.notesView.setCriteria(e)}},{key:"getDisplayableItems",value:function(e){return e===F.a.Note?this.notesView.displayElements():this.collection.displayElements(e)}},{key:"deinit",value:function(){this.unsubChangeObserver(),this.unsubChangeObserver=void 0,this.payloadManager=void 0,this.collection=void 0,this.notesView=void 0}},{key:"resetState",value:function(){this.createCollection()}},{key:"findItem",value:function(e){return this.collection.find(e)}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.collection.findAll(e,t)}},{key:"itemsKeys",value:function(){return this.collection.displayElements(F.a.ItemsKey)}},{key:"addObserver",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]);var r={contentType:e,callback:t};return this.observers.push(r),function(){Object(_.M)(n.observers,r)}}},{key:"itemsReferencingItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.collection.uuidsThatReferenceUuid(e);return this.findItems(t)}},{key:"referencesForItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.findItem(e).references.map(function(e){return e.uuid});return this.findItems(t)}},{key:"setPayloads",value:function(e,t,n,r,a,i){var s=e.map(function(e){return nt(e)}),o=t.map(function(e){return nt(e)}),c=r.map(function(e){return nt(e)}),u=s.concat(o);u.length>0&&this.collection.set(u);for(var l,p=n.map(function(e){return nt(e)}),d=S(p);!(l=d()).done;){var h=l.value;this.collection.discard(h)}this.notesView.setNeedsRebuilding(),this.notifyObservers(s,o,p,c,a,i)}},{key:"notifyObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return e.filter(function(e){return t.includes(F.a.Any)||t.includes(e.content_type)})},c=S(this.observers.slice());!(s=c()).done;){var u=s.value,l=o(e,u.contentType),p=o(t,u.contentType),d=o(n,u.contentType),h=o(r,u.contentType);0===l.length&&0===p.length&&0===d.length&&0===h.length||u.callback(l,p,d,h,a,i)}}},{key:"changeItem",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=s.length>2&&void 0!==s[2]?s[2]:T.c.UserInteraction,r=s.length>3&&void 0!==s[3]?s[3]:ht.a.LocalChanged,a=s.length>4?s[4]:void 0,Object(_.A)(e)){o.next=5;break}throw Error('Invalid uuid for changeItem');case 5:return o.next=7,b.awrap(this.changeItems([e],t,n,r,a));case 7:return i=o.sent,o.abrupt("return",i[0]);case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:n=h.length>2&&void 0!==h[2]?h[2]:T.c.UserInteraction,r=h.length>3&&void 0!==h[3]?h[3]:ht.a.LocalChanged,a=h.length>4?h[4]:void 0,i=this.findItems(e,!0),s=[],o=S(i);case 6:if((c=o()).done){f.next=16;break}if(u=c.value){f.next=10;break}throw Error('Attempting to change non-existant item');case 10:l=de(u,n),t&&t(l),p=l.getResult(),s.push(p);case 14:f.next=6;break;case 16:return f.next=18,b.awrap(this.payloadManager.emitPayloads(s,r,a));case 18:return d=this.findItems(s.map(function(e){return e.uuid})),f.abrupt("return",d);case 20:case"end":return f.stop()}},null,this,null,Promise)}},{key:"changeNote",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant note');case 6:return s=new pe(i,n),c.abrupt("return",this.applyTransform(s,t,r,a));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeTag",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant tag');case 6:return s=new ce(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeComponent",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant component');case 6:return s=new V(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeFeatureRepo",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant repo');case 6:return s=new Xe(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeActionsExtension",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant extension');case 6:return s=new se(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeItemsKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant itemsKey');case 6:return s=new $(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"applyTransform",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:ht.a.LocalChanged,r=i.length>3?i[3]:void 0,t(e),a=e.getResult(),s.abrupt("return",this.payloadManager.emitPayload(a,n,r));case 5:case"end":return s.stop()}},null,this,null,Promise)}},{key:"setItemDirty",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]&&r[1],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return a.next=5,b.awrap(this.setItemsDirty([e],t));case 5:return n=a.sent,a.abrupt("return",n[0]);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemsDirty",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=n.length>1&&void 0!==n[1]&&n[1],Object(_.A)(e[0])){r.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return r.abrupt("return",this.changeItems(e,void 0,t?T.c.UserInteraction:T.c.Internal));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getDirtyItems",value:function(){return this.collection.dirtyElements().filter(function(e){return e.isSyncable})}},{key:"duplicateItem",value:function(e){var t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return t=o.length>1&&void 0!==o[1]&&o[1],n=o.length>2?o[2]:void 0,r=this.findItem(e),a=Object(Ee.e)(r),c.next=6,b.awrap(ut(a,this.payloadManager.getMasterCollection(),t,n));case 6:return i=c.sent,c.next=9,b.awrap(this.payloadManager.emitPayloads(i,ht.a.LocalChanged));case 9:return s=this.findItem(i[0].uuid),c.abrupt("return",s);case 11:case"end":return c.stop()}},null,this,null,Promise)}},{key:"createItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=i.length>3?i[3]:void 0,e){s.next=4;break}throw'Attempting to create item with no contentType';case 4:return s.t0=Object(Ee.e),s.next=7,b.awrap(I.GenerateUuid());case 7:return s.t1=s.sent,s.t2=e,s.t3=t?Object(Ke.a)(t):void 0,s.t4=n,s.t5={uuid:s.t1,content_type:s.t2,content:s.t3,dirty:s.t4},s.t6=r,a=(0,s.t0)(s.t5,s.t6),s.next=16,b.awrap(this.payloadManager.emitPayload(a,ht.a.Constructor));case 16:return s.abrupt("return",this.findItem(a.uuid));case 17:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Object(Ee.e),r.next=3,b.awrap(I.GenerateUuid());case 3:return r.t1=r.sent,r.t2=e,r.t3=Object(Ke.a)(t||{}),r.t4={uuid:r.t1,content_type:r.t2,content:r.t3},n=(0,r.t0)(r.t4),r.abrupt("return",nt(n));case 9:case"end":return r.stop()}},null,null,null,Promise)}},{key:"insertItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemFromPayload(e.payload));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"insertItems",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemsFromPayloads(e.map(function(e){return e.payload})));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emitItemFromPayload",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:ht.a.Constructor,r.next=3,b.awrap(this.payloadManager.emitPayload(e,t));case 3:return r.abrupt("return",this.findItem(e.uuid));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitItemsFromPayloads",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:ht.a.Constructor,a.next=3,b.awrap(this.payloadManager.emitPayloads(e,t));case 3:return n=Object(Ke.b)(e),a.abrupt("return",this.findItems(n));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemToBeDeleted",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this.collection.uuidsThatReferenceUuid(e),r=this.findItem(e),u.next=4,b.awrap(this.changeItem(e,function(e){e.setDeleted()},void 0,t));case 4:a=u.sent,i=S(n);case 6:if((s=i()).done){u.next=14;break}if(o=s.value,!(c=this.findItem(o))){u.next=12;break}return u.next=12,b.awrap(this.changeItem(c.uuid,function(e){e.removeItemAsRelationship(r)}));case 12:u.next=6;break;case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}},null,this,null,Promise)}},{key:"setItemsToBeDeleted",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.all(e.map(function(e){return t.setItemToBeDeleted(e)})));case 1:case"end":return n.stop()}},null,null,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.collection.all(e);return t?n.filter(function(e){return!e.errorDecrypting&&!e.waitingForKey}):n}},{key:"nonErroredItemsForContentType",value:function(e){return this.collection.all(e).filter(function(e){return!e.errorDecrypting&&!e.waitingForKey})}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.subItemsMatchingPredicates(this.items,e)}},{key:"subItemsMatchingPredicates",value:function(e,t){return e.filter(function(e){if(e.deleted)return!1;for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!e.satisfiesPredicate(a))return!1}return!0})}},{key:"findTagByTitle",value:function(e){var t=e.toLowerCase();return this.tags.find(function(e){return e.title.toLowerCase()===t})}},{key:"searchTags",value:function(e,t){var n=this;return Object(_.G)(this.tags.filter(function(r){var a=new RegExp("^".concat(e,"|").concat(".").concat(e),'i').test(r.title),i=!!t&&n.itemsReferencingItem(t.uuid).some(function(e){return(null===e||void 0===e?void 0:e.uuid)===r.uuid});return a&&!i}),'title')}},{key:"getTagParent",value:function(e){var t=this.findItem(e).parentId;if(t)return this.findItem(t)}},{key:"getTagParentChain",value:function(e){for(var t=this.findItem(e).parentId,n=[];t;){var r=this.findItem(t);n.unshift(r),t=r.parentId}return n}},{key:"getTagChildren",value:function(e){var t=this.findItem(e);return this.collection.elementsReferencingElement(t)}},{key:"isTagAncestor",value:function(e,t){for(var n=this.findItem(t).parentId;n;){if(n===e)return!0;n=this.findItem(n).parentId}return!1}},{key:"isValidTagParent",value:function(e,t){return e!==t&&!this.isTagAncestor(t,e)}},{key:"setTagParent",value:function(e,t){if(e.uuid===t.uuid)throw new Error('can not set a tag parent of itself');if(this.isTagAncestor(t.uuid,e.uuid))throw new Error('can not set a tag ancestor of itself');return this.changeTag(t.uuid,function(t){t.makeChildOf(e)})}},{key:"unsetTagParent",value:function(e){var t=this.getTagParent(e.uuid);return t?this.changeTag(e.uuid,function(e){e.removeItemAsRelationship(t)}):Promise.resolve(e)}},{key:"addTagToNote",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.changeItem(t.uuid,function(t){t.addItemAsRelationship(e)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getSortedTagsForNote",value:function(e){return Object(_.G)(this.itemsReferencingItem(e.uuid).filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===F.a.Tag}),'title')}},{key:"findOrCreateTagByTitle",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.findTagByTitle(e),n.t0=t,n.t0){n.next=6;break}return n.next=5,b.awrap(this.createItem(F.a.Tag,Object(Ke.a)({title:e}),!0));case 5:n.t0=n.sent;case 6:return n.abrupt("return",n.t0);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"notesMatchingSmartTag",value:function(e){return this.notesView.notesMatchingSmartTag(e)}},{key:"emptyTrash",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.trashedItems,t.abrupt("return",this.setItemsToBeDeleted(Object(Ke.b)(e)));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){var e=this.collection.displayElements(F.a.SmartTag);return this.systemSmartTags.concat(e)}},{key:"removeAllItemsFromMemory",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Object(Ke.b)(this.items),t.next=3,b.awrap(this.changeItems(e,function(e){e.setDeleted()},T.c.NonDirtying));case 3:this.resetState(),this.payloadManager.resetState();case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"removeItemLocally",value:function(e){this.collection.discard(e),this.payloadManager.removePayloadLocally(e.payload)}},{key:"items",get:function(){return this.collection.all()}},{key:"nonDeletedItems",get:function(){return this.collection.nondeletedElements()}},{key:"invalidItems",get:function(){return this.collection.invalidElements()}},{key:"notes",get:function(){return this.notesView.displayElements()}},{key:"tags",get:function(){return this.collection.displayElements(F.a.Tag)}},{key:"components",get:function(){return this.collection.displayElements(F.a.Component)}},{key:"trashSmartTag",get:function(){return this.systemSmartTags.find(function(e){return e.isTrashTag})}},{key:"trashedItems",get:function(){return this.notesMatchingSmartTag(this.trashSmartTag)}},{key:"noteCount",get:function(){return this.collection.all(F.a.Note).length}}]),n})(R.a),Er='all-notes',Rr='archived-notes',Ir='trashed-notes';function Mr(e,t){return e.sort(function(e,n){var r=new Date(n.serverUpdatedAt).getTime()-new Date(e.serverUpdatedAt).getTime(),a=0,i=0;return t&&(a=t.indexOf(e.content_type),i=t.indexOf(n.content_type),-1===a&&(a=t.length),-1===i&&(i=t.length)),a===i?r:a<i?-1:1})}var Ar=(function(){function e(t,n){v(this,e),this.discordance=0,this.outOfSync=!1,this.receiver=t,this.maxDiscordance=n,this.reset()}return y(e,[{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"reset",value:function(){this.lastPreSyncSave=void 0,this.lastSyncDate=void 0,this.discordance=0,this.outOfSync=!1}},{key:"getLastClientIntegrityHash",value:function(){return this.lastClientHash}},{key:"clearIntegrityHashes",value:function(){this.lastClientHash=void 0,this.lastServerHash=void 0}},{key:"setIntegrityHashes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.lastClientHash=e,this.lastServerHash=t,!t||0===t.length||!e||e===t?(this.outOfSync&&(this.outOfSync=!1,this.receiver(on.a.ExitOutOfSync)),this.discordance=0):(this.discordance++,this.discordance>=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(on.a.EnterOutOfSync)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordance<this.maxDiscordance}}]),e})(),jr=Object.freeze([F.a.ServerExtension]);function Tr(e){return e.filter(function(e){var t=![ue.a.DecryptedBareObject,ue.a.DecryptedBase64String].includes(e.format),n=jr.includes(e.content_type),r=t||n;return r||console.error('Filtering disallowed payload',e),r})}var Kr=(function(){function e(t,n,r,a,i){v(this,e),this.apiService=t,this.protocolService=n,this.contentType=r,this.customEvent=a,this.limit=i,this.progress={retrievedPayloads:[]}}return y(e,[{key:"run",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.apiService.sync([],this.progress.lastSyncToken,this.progress.paginationToken,this.limit||500,!1,this.contentType,this.customEvent));case 2:return r=s.sent,a=Tr(r.data.retrieved_items.map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)})),s.next=6,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a));case 6:if(i=s.sent,this.progress.retrievedPayloads=this.progress.retrievedPayloads.concat(i),this.progress.lastSyncToken=null===(e=r.data)||void 0===e?void 0:e.sync_token,this.progress.paginationToken=null===(t=r.data)||void 0===t?void 0:t.cursor_token,null===(n=r.data)||void 0===n||!n.cursor_token){s.next=14;break}return s.abrupt("return",this.run());case 14:return s.abrupt("return",this.progress.retrievedPayloads);case 15:case"end":return s.stop()}},null,this,null,Promise)}}]),e})(),Fr=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}if(r=n.value,a=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient)){s.next=7;break}throw'Unable to find decrypted counterpart for rejected payload.';case 7:i=Object(Ee.f)(a,ht.a.RemoteRejected,{lastSyncEnd:new Date,dirty:!1}),e.push(i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRejected));case 12:case"end":return s.stop()}},null,this,null,Promise)}}]),n})();function Lr(e){if(e===ht.a.RemoteRetrieved)return Rt;if(e===ht.a.RemoteSaved)return It;if(e===ht.a.ConflictData||e===ht.a.ConflictUuid)return Et;if(e===ht.a.RemoteRejected)return Fr;throw"No delta class found for source ".concat(ht.a[e])}var Ur,Nr=(function(){function e(t){v(this,e),this.collections=t,Object.freeze(this)}return y(e,[{key:"collectionForSource",value:function(e){return this.collections.find(function(t){return t.source===e})}}]),e})(),Vr=(function(){function e(t,n,r,a,i){v(this,e),this.response=t,this.baseCollection=r,this.historyMap=i,this.relatedCollectionSet=new Nr([bt.WithPayloads(n,ht.a.DecryptedTransient),bt.WithPayloads(a,ht.a.SavedOrSaving)])}return y(e,[{key:"collectionsByProcessingResponse",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return e=[],s.next=3,b.awrap(this.collectionByProcessingPayloads(this.response.retrievedPayloads,ht.a.RemoteRetrieved));case 3:return(t=s.sent).all().length>0&&e.push(t),s.next=7,b.awrap(this.collectionByProcessingPayloads(this.response.savedPayloads,ht.a.RemoteSaved));case 7:if((n=s.sent).all().length>0&&e.push(n),!(this.response.uuidConflictPayloads.length>0)){s.next=14;break}return s.next=12,b.awrap(this.collectionByProcessingPayloads(this.response.uuidConflictPayloads,ht.a.ConflictUuid));case 12:(r=s.sent).all().length>0&&e.push(r);case 14:if(!(this.response.dataConflictPayloads.length>0)){s.next=19;break}return s.next=17,b.awrap(this.collectionByProcessingPayloads(this.response.dataConflictPayloads,ht.a.ConflictData));case 17:(a=s.sent).all().length>0&&e.push(a);case 19:if(!(this.response.rejectedPayloads.length>0)){s.next=24;break}return s.next=22,b.awrap(this.collectionByProcessingPayloads(this.response.rejectedPayloads,ht.a.RemoteRejected));case 22:(i=s.sent).all().length>0&&e.push(i);case 24:return s.abrupt("return",e);case 25:case"end":return s.stop()}},null,this,null,Promise)}},{key:"collectionByProcessingPayloads",value:function(e,t){var n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=bt.WithPayloads(Tr(e),t),r=Lr(t),a=new r(this.baseCollection,n,this.relatedCollectionSet,this.historyMap),c.next=5,b.awrap(a.resultingCollection());case 5:return i=c.sent,s=i.all().map(function(e){var t=o.finalDirtyStateForPayload(e);return Object(Ee.b)(e,{dirty:t,dirtiedDate:t?new Date:void 0})}),c.abrupt("return",bt.WithPayloads(s,t));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"finalDirtyStateForPayload",value:function(e){var t=this.baseCollection.find(e.uuid);return t?!t.dirtiedDate||e.dirtiedDate&&e.dirtiedDate>t.dirtiedDate?e.dirty:!e.discardable&&t.dirtiedDate>=t.lastSyncBegan:e.dirty}}]),e})(),Br=(function(){function e(t){var n,r;v(this,e),this.rawResponse=t,this.savedPayloads=this.filterRawItemArray(null===(n=t.data)||void 0===n?void 0:n.saved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteSaved)}),this.retrievedPayloads=this.filterRawItemArray(null===(r=t.data)||void 0===r?void 0:r.retrieved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)}),this.dataConflictPayloads=this.filterRawItemArray(this.rawDataConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictData)}),this.uuidConflictPayloads=this.filterRawItemArray(this.rawUuidConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictUuid)}),this.rejectedPayloads=this.filterRawItemArray(this.rawRejectedPayloads).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRejected)}),this.deletedPayloads=this.allProcessedPayloads.filter(function(e){return e.discardable}),Object(_.l)(this)}return y(e,[{key:"filterRawItemArray",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return!!e.uuid})}},{key:"error",get:function(){var e;return this.rawResponse.error||(null===(e=this.rawResponse.data)||void 0===e?void 0:e.error)}},{key:"status",get:function(){return this.rawResponse.status}},{key:"lastSyncToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.LastSyncToken]}},{key:"paginationToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.PaginationToken]}},{key:"integrityHash",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.IntegrityResult]}},{key:"checkIntegrity",get:function(){return this.integrityHash&&!this.paginationToken}},{key:"numberOfItemsInvolved",get:function(){return this.allProcessedPayloads.length}},{key:"allProcessedPayloads",get:function(){return this.savedPayloads.concat(this.retrievedPayloads).concat(this.dataConflictPayloads).concat(this.uuidConflictPayloads).concat(this.rejectedPayloads)}},{key:"rawUuidConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.UuidConflict}).map(function(e){return e.unsaved_item||e.item})}},{key:"rawDataConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ConflictingData}).map(function(e){return e.server_item||e.item})}},{key:"rawRejectedPayloads",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ContentTypeError||e.type===Te.a.ContentError}).map(function(e){return e.unsaved_item})}},{key:"rawConflictObjects",get:function(){var e,t,n=(null===(e=this.rawResponse.data)||void 0===e?void 0:e.conflicts)||[],r=(null===(t=this.rawResponse.data)||void 0===t?void 0:t.unsaved)||[];return n.concat(r)}},{key:"hasError",get:function(){return!Object(_.w)(this.rawResponse.error)}}]),e})();!(function(e){e[e.Response=1]="Response",e[e.StatusChanged=2]="StatusChanged"})(Ur||(Ur={}));var Wr=150,Hr=(function(){function e(t,n,r,a,i,s){v(this,e),this.payloads=t,this.receiver=n,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.id=Math.random(),this.responses=[],this.payloads=t,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.receiver=n,this.pendingPayloads=t.slice()}return y(e,[{key:"popPayloads",value:function(e){var t=this.pendingPayloads.slice(0,e);return Object(_.R)(this.pendingPayloads,t),t}},{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.receiver(Ur.StatusChanged,void 0,{completedUploadCount:this.totalUploadCount-this.pendingUploadCount,totalUploadCount:this.totalUploadCount}));case 2:return e=this.popPayloads(this.upLimit),r.next=5,b.awrap(this.apiService.sync(e,this.lastSyncToken,this.paginationToken,this.downLimit,this.checkIntegrity,void 0,void 0));case 5:return t=r.sent,n=new Br(t),this.responses.push(n),this.lastSyncToken=n.lastSyncToken,this.paginationToken=n.paginationToken,r.next=12,b.awrap(this.receiver(Ur.Response,n));case 12:if(this.done){r.next=14;break}return r.abrupt("return",this.run());case 14:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsSavedOrSaving",get:function(){return Object(_.c)(this.payloads,this.pendingPayloads)}},{key:"done",get:function(){return 0===this.pendingPayloads.length&&!this.paginationToken}},{key:"pendingUploadCount",get:function(){return this.pendingPayloads.length}},{key:"totalUploadCount",get:function(){return this.payloads.length}},{key:"upLimit",get:function(){return Wr}},{key:"downLimit",get:function(){return Wr}},{key:"numberOfItemsInvolved",get:function(){for(var e,t=0,n=S(this.responses);!(e=n()).done;){t+=e.value.numberOfItemsInvolved}return t}}]),e})(),zr=(function(){function e(t,n){v(this,e),this.payloads=t,this.receiver=n}return y(e,[{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=this.payloads.map(function(e){return Object(Ee.f)(e,ht.a.LocalSaved,{dirty:!1,lastSyncEnd:new Date})}),t=Object(_.a)(e),n=new Br({data:{saved_items:t}}),r.next=5,b.awrap(this.receiver(Ur.Response,n));case 5:case"end":return r.stop()}},null,this,null,Promise)}}]),e})();function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Qr,Jr,$r,Xr=5,Zr=15;!(function(e){e[e.ResolveOnNext=1]="ResolveOnNext",e[e.ForceSpawnNew=2]="ForceSpawnNew"})(Qr||(Qr={})),(function(e){e[e.Default=1]="Default",e[e.DownloadFirst=2]="DownloadFirst"})(Jr||(Jr={})),(function(e){e[e.External=1]="External",e[e.SpawnQueue=2]="SpawnQueue",e[e.ResolveQueue=3]="ResolveQueue",e[e.MoreDirtyItems=4]="MoreDirtyItems",e[e.AfterDownloadFirst=5]="AfterDownloadFirst",e[e.IntegrityCheck=6]="IntegrityCheck",e[e.ResolveOutOfSync=7]="ResolveOutOfSync"})($r||($r={}));var ea=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).itemManager=e,l.sessionManager=r,l.protocolService=a,l.storageService=i,l.payloadManager=s,l.apiService=o,l.historyService=c,l.resolveQueue=[],l.spawnQueue=[],l.completedOnlineDownloadFirstSync=!1,l.majorChangeThreshold=Zr,l.maxDiscordance=Xr,l.locked=!1,l.databaseLoaded=!1,l.syncLock=!1,l.dealloced=!1,l.localLoadPriorty=[F.a.ItemsKey,F.a.UserPrefs,F.a.Component,F.a.Theme],l.itemManager=e,l.sessionManager=r,l.protocolService=a,l.payloadManager=s,l.storageService=i,l.apiService=o,l.interval=u,l.initializeStatus(),l.initializeState(),l}return y(n,[{key:"onNewDatabaseCreated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.getLastSyncToken());case 2:if(!e.sent){e.next=5;break}return e.next=5,b.awrap(this.clearSyncPositionTokens());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.dealloced=!0,this.sessionManager=void 0,this.itemManager=void 0,this.protocolService=void 0,this.payloadManager=void 0,this.storageService=void 0,this.apiService=void 0,this.interval=void 0,this.state.reset(),this.opStatus.reset(),this.state=void 0,this.opStatus=void 0,this.resolveQueue.length=0,this.spawnQueue.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeStatus",value:function(){var e=this;this.opStatus=new fr(this.interval,function(t){e.notifyEvent(t)})}},{key:"initializeState",value:function(){var e=this;this.state=new Ar(function(t){t===on.a.EnterOutOfSync?e.notifyEvent(on.a.EnterOutOfSync):t===on.a.ExitOutOfSync&&e.notifyEvent(on.a.ExitOutOfSync)},this.maxDiscordance)}},{key:"lockSyncing",value:function(){this.locked=!0}},{key:"unlockSyncing",value:function(){this.locked=!1}},{key:"isOutOfSync",value:function(){return this.state.isOutOfSync()}},{key:"getLastSyncDate",value:function(){return this.state.lastSyncDate}},{key:"getStatus",value:function(){return this.opStatus}},{key:"resetSyncState",value:function(){this.state.reset()}},{key:"isDatabaseLoaded",value:function(){return this.databaseLoaded}},{key:"getDatabasePayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageService.getAllRawPayloads().catch(function(t){throw e.notifyEvent(on.a.DatabaseReadError,t),t}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadDatabasePayloads",value:function(e){var t,n,r,a,i,s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.databaseLoaded){d.next=2;break}throw'Attempting to initialize already initialized local database.';case 2:if(0!==e.length){d.next=6;break}return this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0),d.abrupt("return");case 6:return t=e.map(function(e){try{return Object(Ee.e)(e)}catch(e){return void console.error('Creating payload failed',e)}}).filter(function(e){return!Object(_.w)(e)}),n=Mr(t,this.localLoadPriorty),r=n.filter(function(e){return e.content_type===F.a.ItemsKey}),Object(_.R)(n,r),d.next=12,b.awrap(this.protocolService.payloadsByDecryptingPayloads(r));case 12:return a=d.sent,d.next=15,b.awrap(this.payloadManager.emitPayloads(a,ht.a.LocalRetrieved));case 15:i=n.length,s=100,o=Math.ceil(i/s),c=0;case 19:if(!(c<o)){d.next=32;break}return u=c*s,l=n.slice(u,u+s),d.next=24,b.awrap(this.protocolService.payloadsByDecryptingPayloads(l));case 24:return p=d.sent,d.next=27,b.awrap(this.payloadManager.emitPayloads(p,ht.a.LocalRetrieved));case 27:this.notifyEvent(on.a.LocalDataIncrementalLoad),this.opStatus.setDatabaseLoadStatus(u,i,!1);case 29:c++,d.next=19;break;case 32:this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0);case 34:case"end":return d.stop()}},null,this,null,Promise)}},{key:"setLastSyncToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.syncToken=e,t.abrupt("return",this.storageService.setValue(o.LastSyncToken,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setPaginationToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cursorToken=e,!e){t.next=5;break}return t.abrupt("return",this.storageService.setValue(o.PaginationToken,e));case 5:return t.abrupt("return",this.storageService.removeValue(o.PaginationToken));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLastSyncToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.syncToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.LastSyncToken));case 3:this.syncToken=e.sent;case 4:return e.abrupt("return",this.syncToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPaginationToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cursorToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.PaginationToken));case 3:this.cursorToken=e.sent;case 4:return e.abrupt("return",this.cursorToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"clearSyncPositionTokens",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.syncToken=void 0,this.cursorToken=void 0,e.next=4,b.awrap(this.storageService.removeValue(o.LastSyncToken));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.PaginationToken));case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"itemsNeedingSync",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.itemManager.getDirtyItems(),t.abrupt("return",e);case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"alternateUuidForItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=this.itemManager.findItem(e),n=Object(Ee.e)(t),a.next=4,b.awrap(lt(n,this.payloadManager.getMasterCollection()));case 4:return r=a.sent,a.next=7,b.awrap(this.payloadManager.emitPayloads(r,ht.a.LocalChanged));case 7:return a.next=9,b.awrap(this.persistPayloads(r));case 9:return a.abrupt("return",this.itemManager.findItem(r[0].uuid));case 10:case"end":return a.stop()}},null,this,null,Promise)}},{key:"markAllItemsAsNeedingSync",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.log('Marking all items as needing sync'),e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e,{dirty:!0,dirtiedDate:new Date})}),n.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 5:return n.next=7,b.awrap(this.persistPayloads(t));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"popPayloadsNeedingPreSyncSave",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.state.lastPreSyncSave){r.next=3;break}return r.abrupt("return",e);case 3:return n=e.filter(function(e){return!e.dirtiedDate||e.dirtiedDate>t}),this.state.lastPreSyncSave=new Date,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"queueStrategyResolveOnNext",value:function(){var e=this;return new Promise(function(t,n){e.resolveQueue.push({resolve:t,reject:n})})}},{key:"queueStrategyForceSpawnNew",value:function(e){var t=this;return new Promise(function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})})}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(_.N)(this.spawnQueue,0),this.log('Syncing again from spawn queue'),this.sync(Yr({queueStrategy:Qr.ForceSpawnNew,source:$r.SpawnQueue},e.options)).then(function(){e.resolve()}).catch(function(){e.reject()})}},{key:"payloadsByPreparingForServer",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.protocolService.payloadsByEncryptingPayloads(e,function(e){return jr.includes(e.content_type)?Re.b.SyncDecrypted:Re.b.Sync}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"downloadFirstSync",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:n=5,r=0;case 2:if(!(r<n)){a.next=14;break}return a.next=5,b.awrap(this.sync(Yr({mode:Jr.DownloadFirst,queueStrategy:Qr.ForceSpawnNew},t)).catch(console.error));case 5:if(!this.completedOnlineDownloadFirstSync){a.next=9;break}return a.abrupt("return");case 9:return a.next=11,b.awrap(Object(_.P)(e));case 11:r++,a.next=2;break;case 14:console.error("Failed downloadFirstSync after ".concat(n," tries"));case 15:case"end":return a.stop()}},null,this,null,Promise)}},{key:"awaitCurrentSyncs",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.lastSyncInvokationPromise);case 2:return e.next=4,b.awrap(this.currentSyncRequestPromise);case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"sync",value:function(){var e,t=arguments;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},this.lastSyncInvokationPromise=this.performSync(e),n.abrupt("return",this.lastSyncInvokationPromise);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"performSync",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P=this,O=arguments;return b.async(function(C){for(;;)switch(C.prev=C.next){case 0:if(e=O.length>0&&void 0!==O[0]?O[0]:{},!this.locked){C.next=4;break}return this.log('Sync Locked'),C.abrupt("return");case 4:return t=function(){return P.syncLock},n=function(){P.syncLock=!0},r=function(){P.syncLock=!1},a=this.opStatus.syncInProgress,i=this.databaseLoaded,(s=!t())&&i&&!a&&n(),e.source||(e.source=$r.External),C.next=14,b.awrap(this.itemsNeedingSync());case 14:return o=C.sent,c=new Date,u=o.filter(function(e){return e.neverSynced&&e.deleted}),Object(_.R)(o,u),l=o.map(function(e){return e.payloadRepresentation()}),C.next=21,b.awrap(this.popPayloadsNeedingPreSyncSave(l));case 21:return p=C.sent,C.next=24,b.awrap(this.persistPayloads(p));case 24:if(d=this.resolveQueue.slice(),h=Object(_.w)(e.queueStrategy)?Qr.ResolveOnNext:e.queueStrategy,!a&&i&&s){C.next=37;break}if(this.log(s?a?'Attempting to sync while existing sync in progress.':'Attempting to sync before local database has loaded.':'Another function call has begun preparing for sync.'),h!==Qr.ResolveOnNext){C.next=32;break}return C.abrupt("return",this.queueStrategyResolveOnNext());case 32:if(h!==Qr.ForceSpawnNew){C.next=36;break}return C.abrupt("return",this.queueStrategyForceSpawnNew({mode:e.mode,checkIntegrity:e.checkIntegrity,source:e.source}));case 36:throw Error("Unhandled timing strategy ".concat(h));case 37:if(!this.dealloced){C.next=39;break}return C.abrupt("return");case 39:return this.opStatus.setDidBegin(),C.next=42,b.awrap(this.notifyEvent(on.a.SyncWillBegin));case 42:if(Object(_.R)(this.resolveQueue,d),!(o.length>0)){C.next=46;break}return C.next=46,b.awrap(this.itemManager.changeItems(Object(Ke.b)(o),function(e){e.lastSyncBegan=c},T.c.NonDirtying,ht.a.PreSyncSave));case 46:if(this.protocolService.hasAccount()!==this.sessionManager.online()&&this.handleInvalidSessionState(),f=this.sessionManager.online(),D=e.mode,v=f&&!P.completedOnlineDownloadFirstSync?Jr.DownloadFirst:Object(_.w)(D)?Jr.Default:D,y=[],v!==Jr.Default){C.next=63;break}if(!f||this.completedOnlineDownloadFirstSync){C.next=54;break}throw Error('Attempting to default mode sync without having completed initial.');case 54:if(!f){C.next=60;break}return C.next=57,b.awrap(this.payloadsByPreparingForServer(l));case 57:y=C.sent,C.next=61;break;case 60:y=l;case 61:C.next=64;break;case 63:v===Jr.DownloadFirst&&(y=[]);case 64:if(!f){C.next=70;break}return C.next=67,b.awrap(this.syncOnlineOperation(y,e.checkIntegrity,e.source,v));case 67:g=C.sent,C.next=73;break;case 70:return C.next=72,b.awrap(this.syncOfflineOperation(y,e.source,v));case 72:g=C.sent;case 73:return this.currentSyncRequestPromise=g.run(),C.next=76,b.awrap(this.currentSyncRequestPromise);case 76:if(!this.dealloced){C.next=78;break}return C.abrupt("return");case 78:if(this.opStatus.setDidEnd(),r(),!this.opStatus.hasError()){C.next=82;break}return C.abrupt("return");case 82:if(this.opStatus.reset(),this.state.lastSyncDate=new Date,g instanceof Hr&&g.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(on.a.MajorDataChange),!(u.length>0)){C.next=88;break}return C.next=88,b.awrap(this.handleNeverSyncedDeleted(u));case 88:if(v===Jr.DownloadFirst){C.next=91;break}return C.next=91,b.awrap(this.notifyEvent(on.a.FullSyncCompleted,{source:e.source}));case 91:if(v!==Jr.DownloadFirst){C.next=99;break}return f&&(this.completedOnlineDownloadFirstSync=!0),C.next=95,b.awrap(this.notifyEvent(on.a.DownloadFirstSyncCompleted));case 95:return C.next=97,b.awrap(this.sync({source:$r.AfterDownloadFirst,checkIntegrity:!0,awaitAll:e.awaitAll}));case 97:C.next=125;break;case 99:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){C.next=107;break}if(this.log('Syncing again from resolve queue'),m=this.sync({source:$r.ResolveQueue,checkIntegrity:e.checkIntegrity}),!e.awaitAll){C.next=105;break}return C.next=105,b.awrap(m);case 105:C.next=125;break;case 107:return C.next=109,b.awrap(this.itemsNeedingSync());case 109:if(C.t0=C.sent.length,!(C.t0>0)){C.next=115;break}return C.next=113,b.awrap(this.sync({source:$r.MoreDirtyItems,checkIntegrity:e.checkIntegrity,awaitAll:e.awaitAll}));case 113:C.next=125;break;case 115:if(!(g instanceof Hr&&g.checkIntegrity)){C.next=124;break}if(!this.state.needsSync||!g.done){C.next=122;break}if(this.log('Syncing again from integrity check'),w=this.sync({checkIntegrity:!0,queueStrategy:Qr.ForceSpawnNew,source:$r.IntegrityCheck,awaitAll:e.awaitAll}),!e.awaitAll){C.next=122;break}return C.next=122,b.awrap(w);case 122:C.next=125;break;case 124:this.state.clearIntegrityHashes();case 125:for(k=S(d);!(x=k()).done;)x.value.resolve();case 126:case"end":return C.stop()}var D},null,this,null,Promise)}},{key:"handleInvalidSessionState",value:function(){we.a.error(Error('Session missing while attempting to sync.')),this.sessionManager.reauthenticateInvalidSession()}},{key:"syncOnlineOperation",value:function(e,t,n,r){var a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.t0=Hr,s.t1=e,s.t2=function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next=r.t0===Ur.Response?3:r.t0===Ur.StatusChanged?13:15;break;case 3:if(!i.dealloced){r.next=5;break}return r.abrupt("return");case 5:if(!t.hasError){r.next=10;break}return r.next=8,b.awrap(i.handleErrorServerResponse(t));case 8:r.next=12;break;case 10:return r.next=12,b.awrap(i.handleSuccessServerResponse(a,t));case 12:return r.abrupt("break",15);case 13:return i.opStatus.setUploadStatus(n.completedUploadCount,n.totalUploadCount),r.abrupt("break",15);case 15:case"end":return r.stop()}},null,null,null,Promise)},s.next=5,b.awrap(this.getLastSyncToken());case 5:return s.t3=s.sent,s.next=8,b.awrap(this.getPaginationToken());case 8:return s.t4=s.sent,s.t5=t,s.t6=this.apiService,a=new s.t0(s.t1,s.t2,s.t3,s.t4,s.t5,s.t6),this.log('Syncing online user','source:',n,'operation id',a.id,'integrity check',t,'mode:',r,'payloads:',e),s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"syncOfflineOperation",value:function(e,t,n){var r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return this.log('Syncing offline user','source:',t,'mode:',n,'payloads:',e),r=new zr(e,function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!a.dealloced){n.next=2;break}return n.abrupt("return");case 2:if(e!==Ur.Response){n.next=5;break}return n.next=5,b.awrap(a.handleOfflineResponse(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}),i.abrupt("return",r);case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleOfflineResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.log('Offline Sync Response',e.rawResponse),!((t=e.savedPayloads).length>0)){a.next=8;break}return a.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalSaved));case 5:return n=this.payloadManager.find(Object(Ke.b)(t)),a.next=8,b.awrap(this.persistPayloads(n));case 8:if(!((r=e.deletedPayloads).length>0)){a.next=12;break}return a.next=12,b.awrap(this.deletePayloads(r));case 12:return this.opStatus.clearError(),this.opStatus.setDownloadStatus(e.retrievedPayloads.length),a.next=16,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,e));case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleErrorServerResponse",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.log('Sync Error',e),401===e.status&&this.notifyEvent(on.a.InvalidSession),null===(t=this.opStatus)||void 0===t||t.setError(e.error),this.notifyEvent(on.a.SyncError,e.error);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleSuccessServerResponse",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k;return b.async(function(x){for(;;)switch(x.prev=x.next){case 0:if(!this._simulate_latency){x.next=3;break}return x.next=3,b.awrap(Object(_.P)(this._simulate_latency.latency));case 3:this.log('Online Sync Response','operation id',e.id,t.rawResponse),this.setLastSyncToken(t.lastSyncToken),this.setPaginationToken(t.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus(t.retrievedPayloads.length),n=[],r=t.allProcessedPayloads,a={},i=S(r);case 12:if((s=i()).done){x.next=25;break}if(!(o=s.value).deleted&&o.fields.includes(Je.a.Content)){x.next=16;break}return x.abrupt("continue",23);case 16:return c=a[o.items_key_id],u=c?nt(c):void 0,x.next=20,b.awrap(this.protocolService.payloadByDecryptingPayload(o,u));case 20:(l=x.sent).content_type===F.a.ItemsKey&&(a[l.uuid]=l),n.push(l);case 23:x.next=12;break;case 25:return p=this.payloadManager.getMasterCollection(),d=this.historyService.getHistoryMapCopy(),h=new Vr(t,n,p,e.payloadsSavedOrSaving,d),x.next=30,b.awrap(h.collectionsByProcessingResponse());case 30:f=x.sent,v=S(f);case 32:if((y=v()).done){x.next=41;break}return g=y.value,x.next=36,b.awrap(this.payloadManager.emitCollection(g));case 36:return m=x.sent,x.next=39,b.awrap(this.persistPayloads(m));case 39:x.next=32;break;case 41:if(!((w=t.deletedPayloads).length>0)){x.next=45;break}return x.next=45,b.awrap(this.deletePayloads(w));case 45:return x.next=47,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,t));case 47:if(!t.checkIntegrity){x.next=53;break}return x.next=50,b.awrap(this.computeDataIntegrityHash());case 50:return k=x.sent,x.next=53,b.awrap(this.state.setIntegrityHashes(k,t.integrityHash));case 53:case"end":return x.stop()}},null,this,null,Promise)}},{key:"handleNeverSyncedDeleted",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e.map(function(e){return e.payloadRepresentation({dirty:!1})}),n.next=3,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.persistPayloads(t));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistPayloads",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(0!==e.length&&!this.dealloced){n.next=2;break}return n.abrupt("return");case 2:return n.abrupt("return",this.storageService.savePayloads(e).catch(function(e){t.notifyEvent(on.a.DatabaseWriteError,e),we.a.error(e)}));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.persistPayloads(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"computeDataIntegrityHash",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:u.prev=0,e=this.itemManager.nonDeletedItems.sort(function(e,t){return t.serverUpdatedAtTimestamp-e.serverUpdatedAtTimestamp}),t=[],n=1e3,r=S(e);case 5:if((a=r()).done){u.next=14;break}if(i=a.value,s=i.serverUpdatedAtTimestamp){u.next=10;break}return u.abrupt("return",void 0);case 10:o=Math.floor(s/n),t.push(o);case 12:u.next=5;break;case 14:return c=t.join(','),u.abrupt("return",this.protocolService.crypto.sha256(c));case 18:return u.prev=18,u.t0=u.catch(0),console.error('Error computing data integrity hash',u.t0),u.abrupt("return",void 0);case 22:case"end":return u.stop()}},null,this,[[0,18]],Promise)}},{key:"resolveOutOfSync",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=new Kr(this.apiService,this.protocolService,void 0,'resolve-out-of-sync'),a.next=3,b.awrap(e.run());case 3:return t=a.sent,n=new _t(this.payloadManager.getMasterCollection(),bt.WithPayloads(t,ht.a.RemoteRetrieved),void 0,this.historyService.getHistoryMapCopy()),a.next=7,b.awrap(n.resultingCollection());case 7:return r=a.sent,a.next=10,b.awrap(this.payloadManager.emitCollection(r));case 10:return a.next=12,b.awrap(this.persistPayloads(r.payloads));case 12:return a.abrupt("return",this.sync({checkIntegrity:!0,source:$r.ResolveOutOfSync}));case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"statelessDownloadAllItems",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=new Kr(this.apiService,this.protocolService,e,t),a.next=3,b.awrap(n.run());case 3:return r=a.sent,a.abrupt("return",r.map(function(e){return nt(e)}));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_clearLastSyncDate",value:function(){this.state.lastSyncDate=void 0}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=void 0}}]),n})(R.a),ta=(function(){function e(t,n,r,a,i,s){v(this,e),this.challenge=t,this.onValidValue=n,this.onInvalidValue=r,this.onNonvalidatedSubmit=a,this.onComplete=i,this.onCancel=s,this.nonvalidatedValues=[],this.validValues=[],this.invalidValues=[],this.artifacts={}}return y(e,[{key:"complete",value:function(e){var t;e||(e=new be(this.challenge,this.validValues,this.artifacts)),null===(t=this.onComplete)||void 0===t||t.call(this,e)}},{key:"nonvalidatedSubmit",value:function(){var e,t=new be(this.challenge,this.nonvalidatedValues.slice(),this.artifacts);null===(e=this.onNonvalidatedSubmit)||void 0===e||e.call(this,t),this.nonvalidatedValues=[]}},{key:"cancel",value:function(){var e;null===(e=this.onCancel)||void 0===e||e.call(this)}},{key:"isFinished",value:function(){return this.validValues.length===this.challenge.prompts.length}},{key:"nonvalidatedPrompts",value:function(){return this.challenge.prompts.filter(function(e){return!e.validates})}},{key:"addNonvalidatedValue",value:function(e){var t=this.nonvalidatedValues,n=t.find(function(t){return t.prompt.id===e.prompt.id});n&&Object(_.M)(t,n),t.push(e),this.nonvalidatedValues.length===this.nonvalidatedPrompts().length&&this.nonvalidatedSubmit()}},{key:"setValueStatus",value:function(e,t,n){var r,a,i=t?this.validValues:this.invalidValues,s=i.find(function(t){return t.prompt.validation===e.prompt.validation});(s&&Object(_.M)(i,s),i.push(e),w(this.artifacts,n),this.isFinished())?this.complete():t?null===(r=this.onValidValue)||void 0===r||r.call(this,e):null===(a=this.onInvalidValue)||void 0===a||a.call(this,e)}}]),e})(),na=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.protocolService=r,a.challengeOperations={},a.challengeObservers={},a}return y(n,[{key:"deinit",value:function(){this.storageService=void 0,this.protocolService=void 0,this.sendChallenge=void 0,this.challengeOperations=void 0,this.challengeObservers=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"promptForChallengeResponse",value:function(e){var t=this;return new Promise(function(n){t.createOrGetChallengeOperation(e,n),t.sendChallenge(e)})}},{key:"validateChallengeValue",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.prompt.validation,t.next=t.t0===te.LocalPasscode?3:t.t0===te.AccountPassword?4:t.t0===te.Biometric?5:t.t0===te.ProtectionSessionDuration?6:7;break;case 3:return t.abrupt("return",this.protocolService.validatePasscode(e.value));case 4:return t.abrupt("return",this.protocolService.validateAccountPassword(e.value));case 5:return t.abrupt("return",{valid:!0===e.value});case 6:return t.abrupt("return",{valid:(n=e.value,'number'==typeof n&&Object.values(er).includes(n))});case 7:throw Error("Unhandled validation mode ".concat(e.prompt.validation));case 8:case"end":return t.stop()}var n},null,this,null,Promise)}},{key:"promptForCorrectPasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=new ye([new ge(te.LocalPasscode)],e,!0),a.next=3,b.awrap(this.promptForChallengeResponse(t));case 3:if(n=a.sent){a.next=6;break}return a.abrupt("return",void 0);case 6:return r=n.getValueForType(te.LocalPasscode),a.abrupt("return",r.value);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",{});case 2:if(e){n.next=8;break}return n.next=5,b.awrap(this.promptForCorrectPasscode(ne.ResaveRootKey));case 5:if(e=n.sent){n.next=8;break}return n.abrupt("return",{canceled:!0});case 8:return n.next=10,b.awrap(this.protocolService.computeWrappingKey(e));case 10:return t=n.sent,n.abrupt("return",{wrappingKey:t});case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"isPasscodeLocked",value:function(){return this.protocolService.rootKeyNeedsUnwrapping()}},{key:"addChallengeObserver",value:function(e,t){var n=this.challengeObservers[e.id]||[];return n.push(t),this.challengeObservers[e.id]=n,function(){Object(_.M)(n,t)}}},{key:"createOrGetChallengeOperation",value:function(e,t){var n=this,r=this.getChallengeOperation(e);return r||(r=new ta(e,function(t){n.onChallengeValidValue(e,t)},function(t){n.onChallengeInvalidValue(e,t)},function(r){n.onChallengeNonvalidatedSubmit(e,r),t(r)},function(r){n.onChallengeComplete(e,r),t(r)},function(){n.onChallengeCancel(e),t(void 0)}),this.challengeOperations[e.id]=r),r}},{key:"performOnObservers",value:function(e,t){for(var n,r=S(this.challengeObservers[e.id]||[]);!(n=r()).done;){t(n.value)}}},{key:"onChallengeValidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onValidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeInvalidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onInvalidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeNonvalidatedSubmit",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onNonvalidatedSubmit)||void 0===n||n.call(e,t)})}},{key:"onChallengeComplete",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onComplete)||void 0===n||n.call(e,t)})}},{key:"onChallengeCancel",value:function(e){this.performOnObservers(e,function(e){var t;null===(t=e.onCancel)||void 0===t||t.call(e)})}},{key:"getChallengeOperation",value:function(e){return this.challengeOperations[e.id]}},{key:"deleteChallengeOperation",value:function(e){delete this.challengeOperations[e.challenge.id]}},{key:"cancelChallenge",value:function(e){var t=this.challengeOperations[e.id];t.cancel(),this.deleteChallengeOperation(t)}},{key:"completeChallenge",value:function(e){var t=this.challengeOperations[e.id];t.complete(),this.deleteChallengeOperation(t)}},{key:"submitValuesForChallenge",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(0!==t.length){c.next=2;break}throw Error('Attempting to submit 0 values for challenge');case 2:n=S(t);case 3:if((r=n()).done){c.next=18;break}if((a=r.value).prompt.validates){c.next=10;break}this.getChallengeOperation(e).addNonvalidatedValue(a),c.next=16;break;case 10:return c.next=12,b.awrap(this.validateChallengeValue(a));case 12:i=c.sent,s=i.valid,o=i.artifacts,this.setValidationStatusForChallenge(e,a,s,o);case 16:c.next=3;break;case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"setValidationStatusForChallenge",value:function(e,t,n,r){var a=this.getChallengeOperation(e);a.setValueStatus(t,n,r),a.isFinished()&&(this.deleteChallengeOperation(a),delete this.challengeObservers[a.challenge.id])}}]),n})(R.a),ra=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).singletonManager=e,i.itemManager=r,i.syncService=a,i.shouldReload=!0,i.reloading=!1,i.removeItemObserver=r.addObserver(F.a.UserPrefs,function(){i.shouldReload=!0}),i.removeSyncObserver=a.addEventObserver(function(e){e===on.a.FullSyncCompleted&&i.reload()}),i}return y(n,[{key:"deinit",value:function(){var e,t;null===(e=this.removeItemObserver)||void 0===e||e.call(this),null===(t=this.removeSyncObserver)||void 0===t||t.call(this),this.singletonManager=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.LoadedDatabase_12&&(this.preferences=this.singletonManager.findSingleton(z.singletonPredicate),this.preferences&&this.notifyEvent("preferencesChanged"));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){var n,r;return null!==(n=null===(r=this.preferences)||void 0===r?void 0:r.getPref(e))&&void 0!==n?n:t}},{key:"setValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.preferences){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,b.awrap(this.itemManager.changeItem(this.preferences.uuid,function(n){n.setPref(e,t)}));case 4:this.preferences=n.sent,this.notifyEvent("preferencesChanged"),this.syncService.sync();case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"reload",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.shouldReload&&!this.reloading){t.next=2;break}return t.abrupt("return");case 2:return this.reloading=!0,t.prev=3,e=this.preferences,t.next=7,b.awrap(this.singletonManager.findOrCreateSingleton(z.singletonPredicate,F.a.UserPrefs,Object(Ke.a)({})));case 7:this.preferences=t.sent,((null===e||void 0===e?void 0:e.uuid)!==this.preferences.uuid||this.preferences.userModifiedDate>e.userModifiedDate)&&this.notifyEvent('preferencesChanged'),this.shouldReload=!1;case 10:return t.prev=10,this.reloading=!1,t.finish(10);case 13:case"end":return t.stop()}},null,this,[[3,,10,13]],Promise)}}]),n})(R.a),aa=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).settingsService=e,i.crypto=r,i.featuresService=a,i}return y(n,[{key:"saveMfaSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.updateSetting(pr.SettingName.MfaSecret,e,!0));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaActivated",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.getSensitiveSetting(pr.SettingName.MfaSecret));case 2:return e=t.sent,t.abrupt("return",null!=e&&0!=e);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.crypto.generateOtpSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.totpToken(e,Date.now(),6,30));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null!=t,!n.t0){n.next=7;break}return n.t1=t,n.next=5,b.awrap(this.getOtpToken(e));case 5:n.t2=n.sent,n.t0=n.t1===n.t2;case 7:if(n.t0){n.next=10;break}throw new Error(j.S.IncorrectMfa);case 10:return n.abrupt("return",this.saveMfaSetting(e));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.settingsService.deleteSetting(pr.SettingName.MfaSecret));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){var e,t=this.featuresService.getFeature(L.FeatureIdentifier.TwoFactorAuth);return void 0!=t&&(!0===t.no_expire||(null!==(e=t.expires_at)&&void 0!==e?e:0)>Date.now())}},{key:"deinit",value:function(){this.settingsService=void 0,this.crypto=void 0,this.featuresService=void 0,p(f(n.prototype),"deinit",this).call(this)}}]),n})(R.a);function ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(n),!0).forEach(function(t){oa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=(function(){function e(t,n,r,a,i,s,o,c,u){v(this,e);var l=arguments.length>9&&void 0!==arguments[9]&&arguments[9],p=arguments.length>10?arguments[10]:void 0;if(this.environment=t,this.platform=n,this.deviceInterface=r,this.crypto=a,this.alertService=i,this.identifier=s,this.swapClasses=o,this.defaultHost=c,this.appVersion=u,this.enableV4=l,this.webSocketUrl=p,this.eventHandlers=[],this.services=[],this.streamRemovers=[],this.serviceObservers=[],this.managedSubscribers=[],this.createdNewDatabase=!1,this.started=!1,this.launched=!1,this.dealloced=!1,this.revokingSession=!1,this.handledFullSyncStage=!1,!we.a.onLog)throw Error('SNLog.onLog must be set.');if(!we.a.onError)throw Error('SNLog.onError must be set.');if(!r)throw Error('Device Interface must be supplied.');if(!t)throw Error('Environment must be supplied when creating an application.');if(!n)throw Error('Platform must be supplied when creating an application.');if(!a)throw Error('Crypto has to be supplied when creating an application.');if(!i)throw Error('AlertService must be supplied when creating an application.');if(!s)throw Error('ApplicationIdentifier must be supplied when creating an application.');if(!o)throw Error('SwapClasses array must be supplied when creating an application.');if(!c)throw Error('defaultHost must be supplied when creating an application.');if(!u)throw Error('appVersion must be supplied when creating an application.');this.constructServices()}return y(e,[{key:"prepareForLaunch",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.setLaunchCallback(e),r.next=3,b.awrap(this.deviceInterface.openDatabase(this.identifier).catch(function(e){n.notifyEvent(At.a.LocalDatabaseReadError,e)}));case 3:return t=r.sent,this.createdNewDatabase=(null===t||void 0===t?void 0:t.isNewDatabase)||!1,r.next=7,b.awrap(this.migrationService.initialize());case 7:return r.next=9,b.awrap(this.notifyEvent(At.a.MigrationsLoaded));case 9:return r.next=11,b.awrap(this.handleStage(ve.PreparingForLaunch_0));case 11:return r.next=13,b.awrap(this.storageService.initializeFromDisk());case 13:return r.next=15,b.awrap(this.notifyEvent(At.a.StorageReady));case 15:return r.next=17,b.awrap(this.protocolService.initialize());case 17:return r.next=19,b.awrap(this.handleStage(ve.ReadyForLaunch_05));case 19:return this.started=!0,r.next=22,b.awrap(this.notifyEvent(At.a.Started));case 22:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setLaunchCallback",value:function(e){this.challengeService.sendChallenge=e.receiveChallenge}},{key:"launch",value:function(){var e,t,n,r,a,i=this,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(e=s.length>0&&void 0!==s[0]&&s[0],this.launched=!1,!(t=this.getLaunchChallenge())){o.next=11;break}return o.next=6,b.awrap(this.challengeService.promptForChallengeResponse(t));case 6:if(n=o.sent){o.next=9;break}throw Error('Launch challenge was cancelled.');case 9:return o.next=11,b.awrap(this.handleLaunchChallengeResponse(n));case 11:if(!this.storageService.isStorageWrapped()){o.next=20;break}return o.prev=12,o.next=15,b.awrap(this.storageService.decryptStorage());case 15:o.next=20;break;case 17:o.prev=17,o.t0=o.catch(12),this.alertService.alert(j.B.StorageDecryptErrorBody,j.B.StorageDecryptErrorTitle);case 20:return o.next=22,b.awrap(this.handleStage(ve.StorageDecrypted_09));case 22:return o.next=24,b.awrap(this.apiService.loadHost());case 24:return o.next=26,b.awrap(this.webSocketsService.loadWebSocketUrl());case 26:return o.next=28,b.awrap(this.sessionManager.initializeFromDisk());case 28:return this.historyManager.initializeFromDisk(),this.settingsService.initializeFromDisk(),o.next=32,b.awrap(this.featuresService.initializeFromDisk());case 32:return this.launched=!0,o.next=35,b.awrap(this.notifyEvent(At.a.Launched));case 35:return o.next=37,b.awrap(this.handleStage(ve.Launched_10));case 37:return o.next=39,b.awrap(this.syncService.getDatabasePayloads());case 39:return r=o.sent,o.next=42,b.awrap(this.handleStage(ve.LoadingDatabase_11));case 42:if(!this.createdNewDatabase){o.next=45;break}return o.next=45,b.awrap(this.syncService.onNewDatabaseCreated());case 45:if(a=this.syncService.loadDatabasePayloads(r).then(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.dealloced){e.next=2;break}throw'Application has been destroyed.';case 2:return e.next=4,b.awrap(i.handleStage(ve.LoadedDatabase_12));case 4:return i.beginAutoSyncTimer(),e.next=7,b.awrap(i.syncService.sync({mode:Jr.DownloadFirst}));case 7:case"end":return e.stop()}},null,null,null,Promise)}),!e){o.next=49;break}return o.next=49,b.awrap(a);case 49:case"end":return o.stop()}},null,this,[[12,17]],Promise)}},{key:"onStart",value:function(){}},{key:"onLaunch",value:function(){}},{key:"getLaunchChallenge",value:function(){return this.protectionService.createLaunchChallenge()}},{key:"handleLaunchChallengeResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!e.challenge.hasPromptForValidationType(te.LocalPasscode)){a.next=9;break}if(n=null===(t=e.artifacts)||void 0===t?void 0:t.wrappingKey){a.next=7;break}return r=e.getValueForType(te.LocalPasscode),a.next=6,b.awrap(this.protocolService.computeWrappingKey(r.value));case 6:n=a.sent;case 7:return a.next=9,b.awrap(this.protocolService.unwrapRootKey(n));case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval(function(){e.syncService.log('Syncing from autosync'),e.sync()},3e4)}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(this.services);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(r.handleApplicationStage(e));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(_.M)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver(function(n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:n===e&&t(e);case 1:case"end":return r.stop()}},null,null,null,Promise)},e)}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e===At.a.Started?this.onStart():e===At.a.Launched&&this.onLaunch(),n=S(this.eventHandlers.slice());case 2:if((r=n()).done){i.next=14;break}if(!(a=r.value).singleEvent||a.singleEvent!==e){i.next=9;break}return i.next=7,b.awrap(a.callback(e,t||{}));case 7:i.next=12;break;case 9:if(a.singleEvent){i.next=12;break}return i.next=12,b.awrap(a.callback(e,t||{}));case 12:i.next=2;break;case 14:this.migrationService.handleApplicationEvent(e);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date}),n.next=3,b.awrap(this.payloadManager.emitPayload(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.syncService.sync());case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"findItem",value:function(e){return this.itemManager.findItem(e)}},{key:"allItems",value:function(){return this.itemManager.items}},{key:"findItems",value:function(e){return this.itemManager.itemsMatchingPredicate(e)}},{key:"getAll",value:function(e){return this.itemManager.findItems(e)}},{key:"mergeItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.emitItemFromPayload(e.payloadRepresentation(),t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createManagedItem",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=a.length>3?a[3]:void 0,i.abrupt("return",this.itemManager.createItem(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.createTemplateItem(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createItemFromPayload",value:function(e){return nt(e)}},{key:"createPayloadFromObject",value:function(e){return Object(Ee.e)(e)}},{key:"getLastSyncDate",value:function(){return this.syncService.getLastSyncDate()}},{key:"getSyncStatus",value:function(){return this.syncService.getStatus()}},{key:"getSessions",value:function(){return this.sessionManager.getSessionsList()}},{key:"revokeSession",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeSessionRevoking());case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.sessionManager.revokeSession(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.revokeAllOtherSessions());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"userCanManageSessions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent,!Object(_.w)(e)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",Object(Q.b)(e,Q.a.V004)>=0);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUserSubscription",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.sessionManager.getSubscription());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data.subscription);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getAvailableSubscriptions());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setItemNeedsSync",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]&&n[1],r.abrupt("return",this.itemManager.setItemDirty(e.uuid,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setItemsNeedsSync",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 2:return t.next=4,b.awrap(this.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emptyTrash",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.itemManager.emptyTrash());case 2:return e.next=4,b.awrap(this.sync());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getTrashedItems",value:function(){return this.itemManager.trashedItems}},{key:"setDisplayOptions",value:function(e,t,n,r){this.itemManager.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.itemManager.setNotesDisplayCriteria(e)}},{key:"getDisplayableItems",value:function(e){return this.itemManager.getDisplayableItems(e)}},{key:"insertItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=de(e,T.c.UserInteraction),n=t.getResult(),a.next=4,b.awrap(this.itemManager.emitItemFromPayload(n));case 4:return r=a.sent,a.abrupt("return",r);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"saveItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.itemManager.findItem(e)){n.next=3;break}throw Error('Attempting to save non-inserted item');case 3:if(t.dirty){n.next=6;break}return n.next=6,b.awrap(this.itemManager.changeItem(e,void 0,T.c.Internal));case 6:return n.next=8,b.awrap(this.syncService.sync());case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,Object(_.A)(e)){s.next=5;break}throw Error('Must use uuid to change item');case 5:return s.next=7,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0,r));case 7:return s.next=9,b.awrap(this.syncService.sync(a));case 9:return s.abrupt("return",this.findItem(e));case 10:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItems",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,s.next=5,b.awrap(this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0,r));case 5:return s.next=7,b.awrap(this.syncService.sync(a));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeItem",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=!(r.length>2&&void 0!==r[2])||r[2],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid to change item');case 3:return a.next=5,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0));case 5:return a.abrupt("return",this.findItem(e));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=!(r.length>2&&void 0!==r[2])||r[2],a.abrupt("return",this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"protectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNote(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNote(e));case 2:return t=n.sent,Object(_.w)(t)||this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.authorizeProtectedActionForNotes(e,t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.itemManager.getItems(e,t)}},{key:"notesMatchingSmartTag",value:function(e){return this.itemManager.notesMatchingSmartTag(e)}},{key:"referencesForItem",value:function(e,t){var n=this.itemManager.referencesForItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"referencingForItem",value:function(e,t){var n=this.itemManager.itemsReferencingItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"duplicateItem",value:function(e,t){var n=this.itemManager.duplicateItem(e.uuid,!1,t);return this.sync(),n}},{key:"findTagByTitle",value:function(e){return this.itemManager.findTagByTitle(e)}},{key:"searchTags",value:function(e,t){return this.itemManager.searchTags(e,t)}},{key:"isValidTagParent",value:function(e,t){return this.itemManager.isValidTagParent(e,t)}},{key:"setTagParent",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.itemManager.setTagParent(e,t));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unsetTagParent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.unsetTagParent(e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getTagParent",value:function(e){return this.itemManager.getTagParent(e.uuid)}},{key:"getTagParentChain",value:function(e){return this.itemManager.getTagParentChain(e.uuid)}},{key:"getTagChildren",value:function(e){return this.itemManager.getTagChildren(e.uuid)}},{key:"getSortedTagsForNote",value:function(e){return this.itemManager.getSortedTagsForNote(e)}},{key:"findOrCreateTag",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.findOrCreateTagByTitle(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){return this.itemManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.itemManager.noteCount}},{key:"streamItems",value:function(e,t){var n=this,r=this.itemManager.addObserver(e,function(e,n,r,a,i){var s=e.concat(n).concat(r);t(s,i)}),a=this.itemManager.getItems(e);return a.length>0&&t(a),this.streamRemovers.push(r),function(){r(),Object(_.M)(n.streamRemovers,r)}}},{key:"toggleComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.componentManager.toggleComponent(e));case 2:return t.next=4,b.awrap(this.syncService.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.apiService.setHost(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.apiService.getHost()}},{key:"setCustomHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.setHost(e));case 2:return t.next=4,b.awrap(this.webSocketsService.setWebSocketUrl(void 0));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUser",value:function(){if(!this.launched)throw Error('Attempting to access user before application unlocked');return this.sessionManager.getUser()}},{key:"getUserPasswordCreationDate",value:function(){return this.protocolService.getPasswordCreatedDate()}},{key:"getProtocolEncryptionDisplayName",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getEncryptionDisplayName());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getUserVersion",value:function(){return this.protocolService.getUserVersion()}},{key:"protocolUpgradeAvailable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isEncryptionAvailable",value:function(){return this.hasAccount()||this.hasPasscode()}},{key:"upgradeProtocolVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.credentialService.performProtocolUpgrade());case 2:return(e=t.sent).success?this.hasAccount()?this.alertService.alert(j.N.SuccessAccount):this.alertService.alert(j.N.SuccessPasscodeOnly):e.error&&this.alertService.alert(j.N.Fail),t.abrupt("return",e);case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"noAccount",value:function(){return!this.hasAccount()}},{key:"hasAccount",value:function(){return this.protocolService.hasAccount()}},{key:"hasProtectionSources",value:function(){return this.protectionService.hasProtectionSources()}},{key:"areProtectionsEnabled",value:function(){return this.protectionService.areProtectionsEnabled()}},{key:"getProtectionSessionExpiryDate",value:function(){return this.protectionService.getSessionExpiryDate()}},{key:"clearProtectionSession",value:function(){return this.protectionService.clearSession()}},{key:"authorizeNoteAccess",value:function(e){return this.protectionService.authorizeNoteAccess(e)}},{key:"authorizeAutolockIntervalChange",value:function(){return this.protectionService.authorizeAutolockIntervalChange()}},{key:"authorizeCloudLinkAccess",value:function(){return this.protectionService.authorizeCloudLinkAccess()}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.protectionService.authorizeSearchingProtectedNotesText()}},{key:"importData",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if(t=d.length>1&&void 0!==d[1]&&d[1],!e.version){h.next=11;break}if(n=e.version,this.protocolService.supportedVersions().includes(n)){h.next=6;break}return h.abrupt("return",{error:j.V});case 6:return h.next=8,b.awrap(this.getUserVersion());case 8:if(!(r=h.sent)||1!==Object(Q.b)(n,r)){h.next=11;break}return h.abrupt("return",{error:j.u});case 11:if(!e.auth_params&&!e.keyParams){h.next=20;break}return i=new ye([new ge(te.None,j.F.FileAccountPassword,void 0,!0)],ne.DecryptEncryptedFile,!0),h.next=15,b.awrap(this.challengeService.promptForChallengeResponse(i));case 15:if(s=h.sent,!Object(_.w)(s)){h.next=18;break}return h.abrupt("return");case 18:this.challengeService.completeChallenge(i),a=s.values[0].value;case 20:return h.next=22,b.awrap(this.protectionService.authorizeFileImport());case 22:if(h.sent){h.next=24;break}return h.abrupt("return");case 24:return h.next=26,b.awrap(this.protocolService.payloadsByDecryptingBackupFile(e,a));case 26:return o=h.sent,c=o.filter(function(e){return!e.errorDecrypting&&e.format!==ue.a.EncryptedString}).map(function(e){return e.content_type===F.a.Component&&e.safeContent.active?Object(Ee.b)(e,{content:sa(sa({},e.safeContent),{},{active:!1})}):e}),h.next=30,b.awrap(this.payloadManager.importPayloads(c));case 30:if(u=h.sent,l=this.sync(),!t){h.next=35;break}return h.next=35,b.awrap(l);case 35:return p=this.getAll(u),h.abrupt("return",{affectedItems:p,errorCount:o.length-c.length});case 37:case"end":return h.stop()}},null,this,null,Promise)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=i.length>1&&void 0!==i[1]&&i[1],n=e===Re.b.FileEncrypted,r=e===Re.b.FileDecrypted,a=n&&t||r,s.t0=a,!s.t0){s.next=9;break}return s.next=8,b.awrap(this.protectionService.authorizeBackupCreation(n));case 8:s.t0=!s.sent;case 9:if(!s.t0){s.next=11;break}return s.abrupt("return");case 11:return s.abrupt("return",this.protocolService.createBackupFile(e));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"sync",value:function(e){return this.syncService.sync(e)}},{key:"isOutOfSync",value:function(){return this.syncService.isOutOfSync()}},{key:"resolveOutOfSync",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.storageService.setValue(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){return this.storageService.getValue(e,t)}},{key:"removeValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.storageService.removeValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getPreference",value:function(e,t){return this.preferencesService.getValue(e,t)}},{key:"setPreference",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.preferencesService.setValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"prepareForDeinit",value:function(){var e,t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e=n.length>0&&void 0!==n[0]?n[0]:0,t=Promise.all(this.services.map(function(e){return e.blockDeinit()})),0!==e){r.next=7;break}return r.next=5,b.awrap(t);case 5:r.next=9;break;case 7:return r.next=9,b.awrap(Promise.race([t,Object(_.P)(e)]));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"promptForCustomChallenge",value:function(e){var t;return null===(t=this.challengeService)||void 0===t?void 0:t.promptForChallengeResponse(e)}},{key:"addChallengeObserver",value:function(e,t){return this.challengeService.addChallengeObserver(e,t)}},{key:"submitValuesForChallenge",value:function(e,t){return this.challengeService.submitValuesForChallenge(e,t)}},{key:"cancelChallenge",value:function(e){this.challengeService.cancelChallenge(e)}},{key:"setOnDeinit",value:function(e){this.onDeinit=e}},{key:"deinit",value:function(e){var t;clearInterval(this.autoSyncInterval);for(var n,r=S(this.serviceObservers);!(n=r()).done;){(0,n.value)()}for(var a,i=S(this.managedSubscribers);!(a=i()).done;){(0,a.value)()}for(var s,o=S(this.services);!(s=o()).done;){s.value.deinit()}null===(t=this.onDeinit)||void 0===t||t.call(this,this,e),this.onDeinit=void 0,this.crypto=void 0,this.createdNewDatabase=!1,this.services.length=0,this.serviceObservers.length=0,this.managedSubscribers.length=0,this.streamRemovers.length=0,this.clearServices(),this.dealloced=!0,this.started=!1}},{key:"register",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=!(a.length>3&&void 0!==a[3])||a[3],i.abrupt("return",this.credentialService.register(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return n=s.length>2&&void 0!==s[2]&&s[2],r=s.length>3&&void 0!==s[3]&&s[3],a=!(s.length>4&&void 0!==s[4])||s[4],i=s.length>5&&void 0!==s[5]&&s[5],o.abrupt("return",this.credentialService.signIn(e,t,n,r,a,i));case 5:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeEmail",value:function(e,t,n){var r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:A.g.EmailChange,i.abrupt("return",this.credentialService.changeCredentials({currentPassword:t,newEmail:e,passcode:n,origination:r,validateNewPasswordStrength:!1}));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"changePassword",value:function(e,t,n){var r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=i.length>3&&void 0!==i[3]?i[3]:A.g.PasswordChange,a=!(i.length>4&&void 0!==i[4])||i[4],s.abrupt("return",this.credentialService.changeCredentials({currentPassword:e,newPassword:t,passcode:n,origination:r,validateNewPasswordStrength:a}));case 3:case"end":return s.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e=i.length>0&&void 0!==i[0]&&i[0],t=function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(a.credentialService.signOut());case 2:return e.next=4,b.awrap(a.notifyEvent(At.a.SignedOut));case 4:return e.next=6,b.awrap(a.prepareForDeinit());case 6:a.deinit(C.SignOut);case 7:case"end":return e.stop()}},null,null,null,Promise)},!e){s.next=6;break}return s.next=5,b.awrap(t());case 5:return s.abrupt("return");case 6:if(!((n=this.itemManager.getDirtyItems()).length>0)){s.next=17;break}return r=1===n.length,s.next=11,b.awrap(this.alertService.confirm("There ".concat(r?'is':'are'," ").concat(n.length," ").concat(r?'item':'items'," with unsynced changes. If you sign out, these changes will be lost forever. Are you sure you want to sign out?")));case 11:if(!s.sent){s.next=15;break}return s.next=15,b.awrap(t());case 15:s.next=19;break;case 17:return s.next=19,b.awrap(t());case 19:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleRevokedSession",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.revokingSession){t.next=2;break}return t.abrupt("return");case 2:return this.revokingSession=!0,e=this.alertService,t.next=6,b.awrap(this.signOut(!0));case 6:e.alert(j.R.CurrentSessionRevoked);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.protocolService.validateAccountPassword(e));case 2:return t=r.sent,n=t.valid,r.abrupt("return",n);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isStarted",value:function(){return this.started}},{key:"isLaunched",value:function(){return this.launched}},{key:"hasBiometrics",value:function(){return this.protectionService.hasBiometricsEnabled()}},{key:"enableBiometrics",value:function(){return this.protectionService.enableBiometrics()}},{key:"disableBiometrics",value:function(){return this.protectionService.disableBiometrics()}},{key:"hasPasscode",value:function(){return this.protocolService.hasPasscode()}},{key:"isLocked",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.challengeService.isPasscodeLocked());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"lock",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=500,t.next=3,b.awrap(this.prepareForDeinit(e));case 3:return t.abrupt("return",this.deinit(C.Lock));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"addPasscode",value:function(e){return this.credentialService.addPasscode(e)}},{key:"removePasscode",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.credentialService.removePasscode());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"changePasscode",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:A.g.PasscodeChange,r.abrupt("return",this.credentialService.changePasscode(e,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.storageService.getStorageEncryptionPolicy()}},{key:"setStorageEncryptionPolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setEncryptionPolicy(e));case 2:return t.abrupt("return",this.protocolService.repersistAllItems());case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableEphemeralPersistencePolicy",value:function(){return this.storageService.setPersistencePolicy(Oe.Ephemeral)}},{key:"hasPendingMigrations",value:function(){return this.migrationService.hasPendingMigrations()}},{key:"generateUuid",value:function(){return I.GenerateUuid()}},{key:"presentKeyRecoveryWizard",value:function(){return this.keyRecoveryService.processPersistedUndecryptables()}},{key:"changeDeviceInterface",value:function(e){this.deviceInterface=e;for(var t,n=S(this.services);!(t=n()).done;){var r=t.value;r.deviceInterface&&(r.deviceInterface=e)}}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.settingsService.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=r.length>2&&void 0!==r[2]&&r[2],a.abrupt("return",this.settingsService.updateSetting(e,t,n));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){return this.mfaService.isMfaFeatureAvailable()}},{key:"isMfaActivated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.isMfaActivated());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.generateMfaSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mfaService.getOtpToken(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.mfaService.enableMfa(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protectionService.authorizeMfaDisable());case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",this.mfaService.disableMfa());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"downloadExternalFeature",value:function(e){return this.featuresService.validateAndDownloadExternalFeature(e)}},{key:"getFeature",value:function(e){return this.featuresService.getFeature(e)}},{key:"getFeatureStatus",value:function(e){return this.featuresService.getFeatureStatus(e)}},{key:"getNewSubscriptionToken",value:function(){return this.apiService.getNewSubscriptionToken()}},{key:"setOfflineFeaturesCode",value:function(e){return this.featuresService.setOfflineFeaturesCode(e)}},{key:"hasOfflineRepo",value:function(){return this.featuresService.hasOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.featuresService.deleteOfflineFeatureRepo());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isThirdPartyHostUsed",value:function(){return this.apiService.isThirdPartyHostUsed()}},{key:"constructServices",value:function(){this.createPayloadManager(),this.createItemManager(),this.createStorageManager(),this.createProtocolService();var e={payloadByEncryptingPayload:this.protocolService.payloadByEncryptingPayload.bind(this.protocolService),payloadByDecryptingPayload:this.protocolService.payloadByDecryptingPayload.bind(this.protocolService)};this.storageService.encryptionDelegate=e,this.createChallengeService(),this.createHttpManager(),this.createApiService(),this.createWebSocketsService(),this.createSessionManager(),this.createHistoryManager(),this.createSyncManager(),this.createProtectionService(),this.createCredentialService(),this.createKeyRecoveryService(),this.createSingletonManager(),this.createComponentManager(),this.createActionsManager(),this.createPreferencesService(),this.createSettingsService(),this.createFeaturesService(),this.createMigrationService(),this.createMfaService()}},{key:"clearServices",value:function(){this.migrationService=void 0,this.alertService=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.sessionManager=void 0,this.syncService=void 0,this.challengeService=void 0,this.singletonManager=void 0,this.componentManager=void 0,this.protectionService=void 0,this.actionsManager=void 0,this.historyManager=void 0,this.itemManager=void 0,this.keyRecoveryService=void 0,this.preferencesService=void 0,this.featuresService=void 0,this.credentialService=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.mfaService=void 0,this.services=[]}},{key:"createFeaturesService",value:function(){var e=this;this.featuresService=new dr(this.storageService,this.apiService,this.itemManager,this.componentManager,this.webSocketsService,this.settingsService,this.credentialService,this.syncService,this.alertService,this.sessionManager,this.crypto),this.serviceObservers.push(this.featuresService.addEventObserver(function(t){switch(t){case cr.UserRolesChanged:e.notifyEvent(At.a.UserRolesChanged);break;case cr.FeaturesUpdated:e.notifyEvent(At.a.FeaturesUpdated);break;default:Object(_.f)(t)}})),this.services.push(this.featuresService)}},{key:"createWebSocketsService",value:function(){this.webSocketsService=new lr(this.storageService,this.webSocketUrl),this.services.push(this.webSocketsService)}},{key:"createMigrationService",value:function(){this.migrationService=new En({protocolService:this.protocolService,deviceInterface:this.deviceInterface,storageService:this.storageService,sessionManager:this.sessionManager,challengeService:this.challengeService,itemManager:this.itemManager,singletonManager:this.singletonManager,featuresService:this.featuresService,environment:this.environment,identifier:this.identifier}),this.services.push(this.migrationService)}},{key:"createCredentialService",value:function(){var e=this;this.credentialService=new Qe(this.sessionManager,this.syncService,this.storageService,this.itemManager,this.protocolService,this.alertService,this.challengeService,this.protectionService),this.serviceObservers.push(this.credentialService.addEventObserver(function(t){switch(t){case Ye.SignedInOrRegistered:e.notifyEvent(At.a.SignedIn);break;default:Object(_.f)(t)}})),this.services.push(this.credentialService)}},{key:"createApiService",value:function(){this.apiService=new Yt(this.httpService,this.storageService,this.defaultHost),this.services.push(this.apiService)}},{key:"createItemManager",value:function(){this.itemManager=new _r(this.payloadManager),this.services.push(this.itemManager)}},{key:"createComponentManager",value:function(){var e=this.getClass(an);this.componentManager=new e(this.itemManager,this.syncService,this.alertService,this.environment,this.platform,this.deviceInterface.timeout),this.services.push(this.componentManager)}},{key:"createHttpManager",value:function(){this.httpService=new jt(this.environment,this.appVersion),this.services.push(this.httpService)}},{key:"createPayloadManager",value:function(){this.payloadManager=new sn,this.services.push(this.payloadManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new cn(this.itemManager,this.syncService),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new Ie(this.deviceInterface,this.alertService,this.identifier,this.environment),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(){var e=this;this.protocolService=new Gn(this.itemManager,this.payloadManager,this.deviceInterface,this.storageService,this.identifier,this.crypto),this.protocolService.onKeyStatusChange(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.notifyEvent(At.a.KeyStatusChanged));case 2:case"end":return t.stop()}},null,null,null,Promise)}),this.services.push(this.protocolService)}},{key:"createKeyRecoveryService",value:function(){this.keyRecoveryService=new Mt(this.itemManager,this.payloadManager,this.apiService,this.protocolService,this.challengeService,this.alertService,this.storageService,this.syncService,this.credentialService),this.services.push(this.keyRecoveryService)}},{key:"createSessionManager",value:function(){var e=this;this.sessionManager=new Ge(this.storageService,this.apiService,this.alertService,this.protocolService,this.challengeService,this.webSocketsService),this.serviceObservers.push(this.sessionManager.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=t,n.next=n.t0===ze.Restored?3:n.t0===ze.Revoked?5:8;break;case 3:return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.sync());case 2:e.protocolService.needsNewRootKeyBasedItemsKey()&&e.protocolService.createNewDefaultItemsKey().then(function(){e.sync()});case 3:case"end":return t.stop()}},null,null,null,Promise),n.abrupt("break",9);case 5:return n.next=7,b.awrap(e.handleRevokedSession());case 7:return n.abrupt("break",9);case 8:Object(_.f)(t);case 9:case"end":return n.stop()}},null,null,null,Promise)})),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new ea(this.itemManager,this.sessionManager,this.protocolService,this.storageService,this.payloadManager,this.apiService,this.historyManager,this.deviceInterface.interval);var t=this.syncService.addEventObserver(function(t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(n=Object(At.c)(t))){r.next=9;break}return r.next=4,b.awrap(e.notifyEvent(n));case 4:if(n!==At.a.CompletedFullSync){r.next=9;break}if(e.handledFullSyncStage){r.next=9;break}return e.handledFullSyncStage=!0,r.next=9,b.awrap(e.handleStage(ve.FullSyncCompleted_13));case 9:return r.next=11,b.awrap(e.protocolService.onSyncEvent(t));case 11:case"end":return r.stop()}},null,null,null,Promise)});this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createChallengeService",value:function(){this.challengeService=new na(this.storageService,this.protocolService),this.services.push(this.challengeService)}},{key:"createProtectionService",value:function(){var e=this;this.protectionService=new ir(this.protocolService,this.challengeService,this.storageService,this.itemManager),this.serviceObservers.push(this.protectionService.addEventObserver(function(t){t===Zn.SessionExpiryDateChanged&&e.notifyEvent(At.a.ProtectionSessionExpiryDateChanged)})),this.services.push(this.protectionService)}},{key:"createHistoryManager",value:function(){this.historyManager=new nr(this.itemManager,this.storageService,this.apiService,this.protocolService,this.deviceInterface),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new hn(this.itemManager,this.alertService,this.deviceInterface,this.httpService,this.payloadManager,this.protocolService,this.syncService),this.services.push(this.actionsManager)}},{key:"createPreferencesService",value:function(){var e=this;this.preferencesService=new ra(this.singletonManager,this.itemManager,this.syncService),this.serviceObservers.push(this.preferencesService.addEventObserver(function(){e.notifyEvent(At.a.PreferencesChanged)})),this.services.push(this.preferencesService)}},{key:"createSettingsService",value:function(){this.settingsService=new hr.SNSettingsService(this.sessionManager,this.apiService),this.services.push(this.settingsService)}},{key:"createMfaService",value:function(){this.mfaService=new aa(this.settingsService,this.crypto,this.featuresService),this.services.push(this.mfaService)}},{key:"getClass",value:function(e){var t=this.swapClasses.find(function(t){return t.swap===e});return t?t.with:e}}]),e})(),ua=(function(){function e(t,n){v(this,e),this.timeout=t||setTimeout.bind(Object(_.r)()),this.interval=n||setInterval.bind(Object(_.r)())}return y(e,[{key:"deinit",value:function(){this.timeout=void 0,this.interval=void 0}},{key:"getJsonParsedRawStorageValue",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getRawStorageValue(e));case 2:if(t=n.sent,!Object(_.w)(t)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.prev=5,n.abrupt("return",JSON.parse(t));case 9:return n.prev=9,n.t0=n.catch(5),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,[[5,9]],Promise)}}]),e})(),la=(function(){function e(t,n,r){var a=this;v(this,e),this.item=n.findItem(t),r&&r(this.item),this.removeObserver=n.streamItems(this.item.content_type,function(e){var n;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:(n=e.find(function(e){return e.uuid===t}))&&(a.item=n,r&&r(a.item));case 2:case"end":return i.stop()}},null,null,null,Promise)})}return y(e,[{key:"deinit",value:function(){this.removeObserver?(this.removeObserver(),this.removeObserver=void 0):console.error('A LiveItem is attempting to be deinited more than once.')}}]),e})(),pa=n(95)}])},'object'==typeof i&&'object'==typeof a?a.exports=c():'function'==typeof define&&define.amd?define("SNLibrary",[],c):'object'==typeof i?i.SNLibrary=c():o.SNLibrary=c()},443,[12,35,22,9,11,13,7,8,249,43,279,6]);^~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:449:7731: warning: the variable "URL" was not declared in function "ie"__d(function(e,t,n,r,a,i,s){var o,c,u=t(s[0]),l=t(s[1]),p=t(s[2]),d=t(s[3]),h=t(s[4]),f=t(s[5]),v=t(s[6]),y=t(s[7]),g=t(s[8]),m=t(s[9]),b=t(s[10]),w=t(s[11]);function k(e){var t=x();return function(){var n,r=f(e);if(t){var a=f(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return h(this,n)}}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=P(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o=window,c=function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=246)})([function(e,t,n){"use strict";(function(e){n.d(t,"r",function(){return y}),n.d(t,"n",function(){return g}),n.d(t,"C",function(){return k}),n.d(t,"y",function(){return x}),n.d(t,"q",function(){return P}),n.d(t,"O",function(){return O}),n.d(t,"h",function(){return C}),n.d(t,"x",function(){return D}),n.d(t,"v",function(){return _}),n.d(t,"w",function(){return E}),n.d(t,"t",function(){return R}),n.d(t,"A",function(){return I}),n.d(t,"s",function(){return M}),n.d(t,"U",function(){return A}),n.d(t,"V",function(){return j}),n.d(t,"W",function(){return T}),n.d(t,"F",function(){return K}),n.d(t,"o",function(){return F}),n.d(t,"R",function(){return L}),n.d(t,"M",function(){return U}),n.d(t,"b",function(){return N}),n.d(t,"p",function(){return V}),n.d(t,"c",function(){return B}),n.d(t,"g",function(){return W}),n.d(t,"N",function(){return H}),n.d(t,"d",function(){return z}),n.d(t,"H",function(){return q}),n.d(t,"Q",function(){return Y}),n.d(t,"K",function(){return G}),n.d(t,"j",function(){return Q}),n.d(t,"S",function(){return J}),n.d(t,"E",function(){return $}),n.d(t,"J",function(){return X}),n.d(t,"I",function(){return Z}),n.d(t,"D",function(){return ee}),n.d(t,"a",function(){return te}),n.d(t,"m",function(){return ne}),n.d(t,"L",function(){return re}),n.d(t,"l",function(){return ae}),n.d(t,"B",function(){return ie}),n.d(t,"T",function(){return se}),n.d(t,"P",function(){return oe}),n.d(t,"f",function(){return ce}),n.d(t,"z",function(){return ue}),n.d(t,"G",function(){return le}),n.d(t,"e",function(){return pe}),n.d(t,"i",function(){return ye}),n.d(t,"u",function(){return ge}),n.d(t,"k",function(){return me});var r=n(27),a=n.n(r),i=n(25),s=n.n(i),o=n(23),c=n.n(o),u=n(97),l=n.n(u),p=n(66),d=n.n(p),h=n(28),f=n.n(h),v='undefined'!=typeof Intl?new Intl.Collator('en',{numeric:!0}):void 0;function y(){return'undefined'!=typeof window?window:void 0!==e?e:null}function g(e){return Object.keys(e).map(function(t){return e[t]})}function k(){return null!==y()&&!x()&&!(document&&document.documentMode)||/Edge/.test(navigator.userAgent)&&window.crypto&&!!window.crypto.subtle}function x(){return'undefined'!=typeof navigator&&'ReactNative'===navigator.product}function P(e,t,n){return e.find(function(e){return e[t]===n})}function O(e,t){return s()(e,t)}function C(){for(var e=[],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var a=0,i=n;a<i.length;a++){var s=i[a];e=e.concat(s)}return e}function D(e){return null!==e&&('function'==typeof e||'object'==typeof e)}function _(e){return null!==e&&'function'==typeof e}function E(e){return null===e||void 0===e}function R(e){return!e||0===e.length}function I(e){return'string'==typeof e||e instanceof String}function M(e,t){return e>t?e:t}function A(e,t,n){return d()(e.concat(t),function(e,t){for(var r,a=S(n);!(r=a()).done;){var i=r.value;if(e[i]!==t[i])return!1}return!0})}function j(e){return f()(e)}function T(e,t){return d()(e,function(e,n){return e[t]===n[t]})}function K(e){return e[e.length-1]}function F(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;e.push(a)}}function L(e,t){for(var n,r=S(t);!(n=r()).done;){U(e,n.value)}}function U(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}function N(e,t){return!e.includes(t)&&(e.push(t),!0)}function V(e,t){a()(e,t)}function B(e,t){return e.filter(function(e){return!t.includes(e)}).concat(t.filter(function(t){return!e.includes(t)}))}function W(e,t){return!(e&&!t||!e&&t)&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof String&&t instanceof String?e===t:J(e,t))}function H(e,t){e.splice(t,1)}function z(e,t){var n=e.slice();return H(n,t),n}function q(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];t.push(e[a])}return t}function Y(e){for(var t,n={},r=S(Object.keys(e).sort());!(t=r()).done;){var a=t.value;n[a]=e[a]}return te(n)}function G(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];E(e[a])||(t[a]=e[a])}return t}function Q(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort(function(e,r){var a=e[t].getTime(),i=r[t].getTime(),s=n?1:-1;return a<i?-1*s:a>i?1*s:0})}function J(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var a=0,i=n;a<i.length;a++){var s=i[a];if(e[s]!==t[s])return!1}return!0}function $(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=void 0;try{i=JSON.parse(e[a])}catch(t){i=e[a]}t[a]=i}return t}function X(e,t){if(e)for(var n,r=S(t);!(n=r()).done;){delete e[n.value]}}function Z(e,t){if(!E(e)){for(var n,r=w({},e),a=S(t);!(n=a()).done;){delete r[n.value]}return r}}function ee(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(function(e,t){return 0===t?e.trim().replace(/[/]*$/g,''):e.trim().replace(/(^[/]*|[/]*$)/g,'')}).filter(function(e){return e.length}).join('/')}function te(e){return e instanceof Date?new Date(e):D(e)?JSON.parse(JSON.stringify(e)):e}function ne(e,t){if(!e||!t)throw'Attempting to deepMerge with null values';return l()(e,t,function(e,t){if(c()(e))return t}),e}function re(e,t){for(var n,r={},a=S(t);!(n=a()).done;){var i=n.value;r[i]=e[i]}return te(r)}function ae(e){for(var t,n=S(Object.getOwnPropertyNames(e));!(t=n()).done;){var r=t.value,a=e[r];a&&'object'==typeof a&&!Object.isFrozen(a)?e[r]=ae(a):e[r]=a}return Object.freeze(e)}function ie(e){try{return new URL(e),!0}catch(e){return!1}}function se(e,t){var n=t/4;return e.substring(0,n)}function oe(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Sleeping for ".concat(e,"ms")),t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},e)}));case 2:case"end":return t.stop()}},null,null,null,Promise)}function ce(e){throw Error('Unchecked case '+e)}function ue(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function le(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc'){case'asc':return m(e).sort(v?function(e,n){return v.compare(e[t],n[t])}:function(e,n){return e[t].localeCompare(n[t],'en',{numeric:!0})});case'desc':return m(e).sort(v?function(e,n){return v.compare(n[t],e[t])}:function(e,n){return n[t].localeCompare(e[t],'en',{numeric:!0})})}}function pe(e,t){return e.length===t.length&&(e.every(function(e){return t.includes(e)})&&t.every(function(t){return e.includes(t)}))}var de,he,fe=1e3,ve=1e3;function ye(e){switch(String(e).length){case de.Seconds:return e*ve;case de.Milliseconds:return e;case de.Microseconds:return Math.floor(e/fe);default:throw"Unhandled timestamp precision: ".concat(e)}}function ge(e){return void 0!==e.error}function me(e){if('undefined'!=typeof Intl&&Intl.DateTimeFormat&&'undefined'!=typeof navigator){if(!he){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;he=new Intl.DateTimeFormat(t,{year:'numeric',month:'short',day:'2-digit',weekday:'long',hour:'2-digit',minute:'2-digit'})}return he.format(e)}return e.toDateString()+' '+e.toLocaleTimeString()}!(function(e){e[e.Seconds=10]="Seconds",e[e.Milliseconds=13]="Milliseconds",e[e.Microseconds=16]="Microseconds"})(de||(de={}))}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"e",function(){return m}),n.d(t,"g",function(){return b}),n.d(t,"d",function(){return w}),n.d(t,"f",function(){return k}),n.d(t,"b",function(){return x}),n.d(t,"c",function(){return O}),n.d(t,"a",function(){return C});var r=n(32),a=n(4),i=n(8),s=n(0),o=n(5),c=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey,o.a.LastSyncBegan,o.a.LastSyncEnd,o.a.DuplicateOf]),u=Object.freeze([o.a.Uuid,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.Legacy003AuthHash,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey]),l=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Legacy003AuthHash,o.a.DuplicateOf]),p=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.WaitingForKey,o.a.DuplicateOf]),d=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.DuplicateOf]),h=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.Content,o.a.ServerUpdatedAt]),f=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),v=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),y=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ServerUpdatedAt,o.a.ServerUpdatedAtTimestamp,o.a.CreatedAtTimestamp,o.a.Deleted,o.a.Dirty,o.a.LastSyncEnd]),g=Object.freeze(d.slice());function m(e,t,n){return P(e,c.slice(),n,t)}function b(e,t,n,r){for(var a,i={},s=S(n||t.fields);!(a=s()).done;){var o=a.value;i[o]=t[o]}if(r)for(var c=0,u=Object.keys(r);c<u.length;c++){var l=u[c];i[l]=r[l]}return x(e,i)}function w(e,t,n){return P(e,D(t),a.a.Constructor,n)}function k(e,t,n){return P(e,_(t),t,n)}function x(e,t){return P(e,e.fields,e.source,t)}function P(e,t,n,i){for(var o,c=Object(s.L)(e,t),u=i instanceof r.a?i.fields.slice():Object.keys(i||[]),l=S(u);!(o=l()).done;){var p=o.value,d=i[p];c[p]=d?Object(s.a)(d):d}var h=Object(s.V)(t.concat(u));return new r.a(c,h,n||a.a.Constructor)}function O(e,t){return P(e,Object.keys(e),t)}function C(e,t){return P(e,u.slice(),void 0,t)}function D(e){if(e===i.b.FileEncrypted||e===i.b.FileDecrypted||e===i.b.FilePreferEncrypted)return l.slice();if(e===i.b.LocalStoragePreferEncrypted||e===i.b.LocalStorageDecrypted||e===i.b.LocalStorageEncrypted)return p.slice();if(e===i.b.Sync||e===i.b.SyncDecrypted)return d.slice();throw"No payload fields found for intent ".concat(e)}function _(e){if(e===a.a.FileImport)return l.slice();if(e===a.a.SessionHistory)return h.slice();if(e===a.a.RemoteHistory)return g.slice();if(e===a.a.ComponentRetrieved)return f.slice();if(e===a.a.ComponentCreated)return v.slice();if(e===a.a.LocalRetrieved||e===a.a.LocalChanged)return p.slice();if(e===a.a.RemoteRetrieved||e===a.a.ConflictData||e===a.a.ConflictUuid||e===a.a.RemoteRejected)return d.slice();if(e===a.a.LocalSaved||e===a.a.RemoteSaved)return y.slice();throw"No payload fields found for source ".concat(e)}},function(e,t,n){"use strict";n.d(t,"k",function(){return a}),n.d(t,"l",function(){return i}),n.d(t,"j",function(){return s}),n.d(t,"m",function(){return o}),n.d(t,"r",function(){return c}),n.d(t,"p",function(){return u}),n.d(t,"a",function(){return l}),n.d(t,"i",function(){return p}),n.d(t,"n",function(){return d}),n.d(t,"s",function(){return h}),n.d(t,"q",function(){return f}),n.d(t,"o",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"h",function(){return g}),n.d(t,"g",function(){return m}),n.d(t,"b",function(){return b}),n.d(t,"f",function(){return w}),n.d(t,"t",function(){return k}),n.d(t,"c",function(){return x}),n.d(t,"e",function(){return S}),n.d(t,"C",function(){return P}),n.d(t,"X",function(){return O}),n.d(t,"A",function(){return C}),n.d(t,"L",function(){return D}),n.d(t,"W",function(){return _}),n.d(t,"E",function(){return E}),n.d(t,"D",function(){return R}),n.d(t,"K",function(){return I}),n.d(t,"J",function(){return M}),n.d(t,"Y",function(){return A}),n.d(t,"Q",function(){return j}),n.d(t,"v",function(){return T}),n.d(t,"O",function(){return K}),n.d(t,"z",function(){return F}),n.d(t,"U",function(){return L}),n.d(t,"G",function(){return U}),n.d(t,"T",function(){return N}),n.d(t,"V",function(){return V}),n.d(t,"u",function(){return B}),n.d(t,"F",function(){return W}),n.d(t,"y",function(){return H}),n.d(t,"P",function(){return z}),n.d(t,"S",function(){return q}),n.d(t,"N",function(){return Y}),n.d(t,"H",function(){return G}),n.d(t,"w",function(){return Q}),n.d(t,"R",function(){return J}),n.d(t,"x",function(){return $}),n.d(t,"M",function(){return X}),n.d(t,"B",function(){return Z}),n.d(t,"I",function(){return ee});var r=n(13),a='A server error occurred while trying to sign in. Please try again.',i='A server error occurred while trying to register. Please try again.',s='Something went wrong while changing your credentials. Your credentials were not changed. Please try again.',o='Could not connect to server.',c='An existing registration request is already in progress.',u='An existing sign in request is already in progress.',l='An existing change credentials request is already in progress.',p='Invalid email or password.',d='A server error occurred while trying to refresh your session. Please try again.',h='Your account session is being renewed with the server. Please try your request again.',f='Too many successive server requests. Please wait a few minutes and try again.',v='Please sign in to an account in order to continue with your request.',y='Failed to get settings.',g='Failed to update settings.',m="Failed to get subscription's information.",b='Failed to access purchase flow.',w='Failed to get offline features.',k="The extension you are attempting to install comes from an \n  untrusted source. Untrusted extensions may lower the security of your data. Do you want to continue?",x="Error downloading package details. Please check the \n  extension link and try again.",S='An unknown issue occurred during offline activation. Please try again.',P='Invalid extension URL.',O='This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.',C='The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.',D='The encryption version for your account is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.com/help/security for more information.',_='Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.',E='Unable to sign in due to insecure password parameters. Please visit standardnotes.com/help/security for more information.',R='Invalid password.',I='Update Recommended',M='Sign In',A="Upgrading your account's encryption version\u2026",j='Setting passcode\u2026',T='Changing passcode\u2026',K='Removing passcode\u2026',F='Do not close the application until this process completes.',L='Unknown error.';function U(e){return"Your password must be at least ".concat(e," characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.")}function N(e,t){return"Strict Sign In has refused the server's sign-in parameters. The latest account version is ".concat(t,", but the server is reporting a version of ").concat(e," for your account. If you'd like to proceed with sign in anyway, please disable Strict Sign In and try again.")}var V='This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.',B="This backup file was created using a newer encryption version than your account's. Please run the available encryption upgrade and try again.",W={FileAccountPassword:'File account password'},H={PasscodeRequired:'Your passcode is required to process your credentials change.',Failed:'Unable to change your credentials due to a sync error. Please try again.'},z={PasscodeRequired:'Your passcode is required in order to register for an account.'},q={PasscodeRequired:'Your passcode is required in order to sign in to your account.',IncorrectMfa:'Incorrect two-factor authentication code. Please try again.',SignInCanceledMissingMfa:'Your sign in request has been canceled.'},Y={SuccessAccount:"Your encryption version has been successfully upgraded. You may be asked to enter your credentials again on other devices you're signed into.",SuccessPasscodeOnly:'Your encryption version has been successfully upgraded.',Fail:'Unable to upgrade encryption version. Please try again.',UpgradingPasscode:'Upgrading local encryption...'},G={KeyRecoveryLoginFlowPrompt:function(e){var t,n=null===(t=e.createdDate)||void 0===t?void 0:t.toLocaleString();switch(e.origination){case r.g.EmailChange:return"Enter your account password as it was when you changed your email on ".concat(n,".");case r.g.PasswordChange:return"Enter your account password after it was changed on ".concat(n,".");case r.g.Registration:return"Enter your account password as it was when you registered ".concat(n,".");case r.g.ProtocolUpgrade:return"Enter your account password as it was when you upgraded your encryption version on ".concat(n,".");case r.g.PasscodeChange:return"Enter your application passcode after it was changed on ".concat(n,".");case r.g.PasscodeCreate:return"Enter your application passcode as it was when you created it on ".concat(n,".");default:throw Error('Unhandled KeyParamsOrigination case for KeyRecoveryLoginFlowPrompt')}},KeyRecoveryLoginFlowReason:'Your account password is required to revalidate your session.',KeyRecoveryLoginFlowInvalidPassword:'Incorrect credentials entered. Please try again.',KeyRecoveryRootKeyReplaced:'Your credentials have successfully been updated.',KeyRecoveryPasscodeRequiredTitle:'Passcode Required',KeyRecoveryPasscodeRequiredText:'You must enter your passcode in order to save your new credentials.',KeyRecoveryPasswordRequired:'Your account password is required to recover an encryption key.',KeyRecoveryKeyRecovered:'Your key has successfully been recovered.',KeyRecoveryUnableToRecover:'Unable to recover your key with the attempted password. Please try again.'},Q={Generic:'Authentication Required',Migration:'Storage Update'},J={EnterEmailAndPassword:'Please enter your account email and password.',RecoverSession:function(e){return e?"Your credentials are needed for ".concat(e," to refresh your session with the server."):'Your credentials are needed to refresh your session with the server.'},SessionRestored:'Your session has been successfully restored.',EnterMfa:'Please enter your two-factor authentication code.',MfaInputPlaceholder:'Two-factor authentication code',EmailInputPlaceholder:'Email',PasswordInputPlaceholder:'Password',KeychainRecoveryErrorTitle:'Invalid Credentials',KeychainRecoveryError:'The email or password you entered is incorrect.\n\nPlease note that this sign-in request is made against the default server. If you are using a custom server, you must uninstall the app then reinstall, and sign back into your account.',RevokeTitle:'Revoke this session?',RevokeConfirmButton:'Revoke',RevokeCancelButton:'Cancel',RevokeText:"The associated app will be signed out and all data removed from the device when it is next launched. You can sign back in on that device at any time.",CurrentSessionRevoked:"Your session has been revoked and all local data has been removed from this device."},$={UnlockApplication:'Authentication is required to unlock the application',NoteAccess:'Authentication is required to view this note',ImportFile:'Authentication is required to import a backup file',AddPasscode:'Authentication is required to add a passcode',RemovePasscode:'Authentication is required to remove your passcode',ChangePasscode:'Authentication is required to change your passcode',ChangeAutolockInterval:'Authentication is required to change autolock timer duration',RevokeSession:'Authentication is required to revoke a session',AccessCloudLink:'Authentication is required to access CloudLink',EnterAccountPassword:'Enter your account password',EnterLocalPasscode:'Enter your application passcode',EnterPasscodeForMigration:'Your application passcode is required to perform an upgrade of your local data storage structure.',EnterPasscodeForRootResave:'Enter your application passcode to continue',EnterCredentialsForProtocolUpgrade:'Enter your credentials to perform encryption upgrade',EnterCredentialsForDecryptedBackupDownload:'Enter your credentials to download a decrypted backup',AccountPasswordPlaceholder:'Account Password',LocalPasscodePlaceholder:'Application Passcode',DecryptEncryptedFile:'Enter the account password associated with the import file',ExportBackup:'Authentication is required to export a backup',DisableBiometrics:'Authentication is required to disable biometrics',UnprotectNote:'Authentication is required to unprotect a note',SearchProtectedNotesText:'Authentication is required to search protected contents',SelectProtectedNote:'Authentication is required to select a protected note',DisableMfa:'Authentication is required to disable two-factor authentication'},X={AccountPassword:'Account Password',LocalPasscode:'Application Passcode',Biometrics:'Biometrics',RememberFor:'Remember For',Mfa:'Two-factor Authentication Code'},Z={MissingSessionTitle:'Missing Session',MissingSessionBody:'We were unable to load your server session. This represents an inconsistency with your application state. Please take an opportunity to backup your data, then sign out and sign back in to resolve this issue.',StorageDecryptErrorTitle:'Storage Error',StorageDecryptErrorBody:"We were unable to decrypt your local storage. Please restart the app and try again. If you're unable to resolve this issue, and you have an account, you may try uninstalling the app then reinstalling, then signing back into your account. Otherwise, please contact help@standardnotes.org for support."},ee={Title:'Restore Keychain',Text:"We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys."}},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i});var r=n(19);n.n(r);n.d(t,"a",function(){return r.ContentType});var a='org.standardnotes.sn';function i(e){var t;return(g(t={},r.ContentType.Note,'note'),g(t,r.ContentType.Tag,'tag'),g(t,r.ContentType.SmartTag,'smart tag'),g(t,r.ContentType.ActionsExtension,'action-based extension'),g(t,r.ContentType.Component,'component'),g(t,r.ContentType.Editor,'editor'),g(t,r.ContentType.Theme,'theme'),g(t,r.ContentType.ServerExtension,'server extension'),g(t,r.ContentType.FilesafeCredentials,'FileSafe credential'),g(t,r.ContentType.FilesafeFileMetadata,'FileSafe file'),g(t,r.ContentType.FilesafeIntegration,'FileSafe integration'),t)[e]}},function(e,t,n){"use strict";var r;function a(e){return[r.RemoteSaved,r.PreSyncSave].includes(e)}function i(e){return[r.RemoteRetrieved,r.ComponentRetrieved,r.RemoteActionRetrieved].includes(e)}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i}),(function(e){e[e.RemoteRetrieved=1]="RemoteRetrieved",e[e.RemoteSaved=2]="RemoteSaved",e[e.LocalSaved=3]="LocalSaved",e[e.LocalRetrieved=4]="LocalRetrieved",e[e.LocalChanged=5]="LocalChanged",e[e.ComponentRetrieved=6]="ComponentRetrieved",e[e.DesktopInstalled=7]="DesktopInstalled",e[e.RemoteActionRetrieved=8]="RemoteActionRetrieved",e[e.FileImport=9]="FileImport",e[e.RemoteConflict=10]="RemoteConflict",e[e.ImportConflict=11]="ImportConflict",e[e.SavedOrSaving=12]="SavedOrSaving",e[e.DecryptedTransient=13]="DecryptedTransient",e[e.ConflictUuid=14]="ConflictUuid",e[e.ConflictData=15]="ConflictData",e[e.SessionHistory=16]="SessionHistory",e[e.Constructor=17]="Constructor",e[e.ComponentCreated=18]="ComponentCreated",e[e.PreSyncSave=19]="PreSyncSave",e[e.RemoteHistory=20]="RemoteHistory",e[e.RemoteRejected=21]="RemoteRejected"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.Uuid="uuid",e.ContentType="content_type",e.ItemsKeyId="items_key_id",e.EncItemKey="enc_item_key",e.Content="content",e.CreatedAt="created_at",e.ServerUpdatedAt="updated_at",e.CreatedAtTimestamp="created_at_timestamp",e.ServerUpdatedAtTimestamp="updated_at_timestamp",e.Deleted="deleted",e.Legacy003AuthHash="auth_hash",e.Legacy003AuthParams="auth_params",e.Dirty="dirty",e.DirtiedDate="dirtiedDate",e.WaitingForKey="waitingForKey",e.ErrorDecrypting="errorDecrypting",e.ErrorDecryptingChanged="errorDecryptingValueChanged",e.LastSyncBegan="lastSyncBegan",e.LastSyncEnd="lastSyncEnd",e.DuplicateOf="duplicate_of"})(r||(r={}))},function(e,t,n){"use strict";var r;function a(e,t){return Number(e)-Number(t)}function i(e,t){return a(e,t)>=0}function s(e,t){return a(e,t)<=0}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"d",function(){return i}),n.d(t,"c",function(){return s}),(function(e){e.V000Base64Decrypted="000",e.V001="001",e.V002="002",e.V003="003",e.V004="004",e[e.VersionLength=3]="VersionLength"})(r||(r={}))},function(e,t,n){"use strict";(function(e){n.d(t,"c",function(){return r}),n.d(t,"a",function(){return a}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return f}),n.d(t,"b",function(){return g});var r,a,i,s=n(16),o=n(12),c=n(18),u=n(1),l=n(0),p=n(21),d=n(3),h=n(4);!(function(e){e[e.UserInteraction=1]="UserInteraction",e[e.Internal=2]="Internal",e[e.NonDirtying=3]="NonDirtying"})(r||(r={})),(function(e){e.Pinned="pinned",e.Archived="archived",e.Locked="locked",e.UserModifiedDate="client_updated_at",e.DefaultEditor="defaultEditor",e.MobileRules="mobileRules",e.NotAvailableOnMobile="notAvailableOnMobile",e.MobileActive="mobileActive",e.LastSize="lastSize",e.PrefersPlainEditor="prefersPlainEditor",e.ComponentInstallError="installError"})(a||(a={})),(function(e){e[e.KeepEarliest=1]="KeepEarliest"})(i||(i={}));var f=(function(){function t(n){var r=this;if(v(this,t),this.protected=!1,this.trashed=!1,this.pinned=!1,this.archived=!1,this.locked=!1,!n.uuid||!n.content_type)throw Error('Cannot create item without both uuid and content_type');n.format===o.a.DecryptedBareObject&&(n.enc_item_key||n.items_key_id||n.auth_hash)&&s.a.error(Error('Creating an item from a decrypted payload should not contain enc params')),this.payload=n,this.conflictOf=n.safeContent.conflict_of,this.duplicateOf=n.duplicate_of,this.createdAtString=this.created_at&&Object(l.k)(this.created_at),n.format===o.a.DecryptedBareObject?(this.userModifiedDate=new Date(this.getAppDomainValue(a.UserModifiedDate)||this.serverUpdatedAt),this.updatedAtString=Object(l.k)(this.userModifiedDate),this.protected=this.payload.safeContent.protected,this.trashed=this.payload.safeContent.trashed,this.pinned=this.getAppDomainValue(a.Pinned),this.archived=this.getAppDomainValue(a.Archived),this.locked=this.getAppDomainValue(a.Locked)):this.userModifiedDate=this.serverUpdatedAt||new Date,e(function(){Object(l.l)(r)})}return y(t,[{key:"payloadRepresentation",value:function(e){return Object(u.b)(this.payload,e)}},{key:"hasRelationshipWithItem",value:function(e){var t;return!!(null===(t=this.payload.safeContent.references)||void 0===t?void 0:t.find(function(t){return t.uuid===e.uuid}))}},{key:"getDomainData",value:function(e){var t=this.payload.safeContent.appData;if(t)return t[e]}},{key:"getAppDomainValue",value:function(e){return this.getDomainData(t.DefaultAppDomain())[e]}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['conflict_of']}},{key:"appDataContentKeysToIgnoreWhenCheckingEquality",value:function(){return[a.UserModifiedDate]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"strategyWhenConflictingWithItem",value:function(e,t){if(this.errorDecrypting)return c.a.KeepLeftDuplicateRight;if(this.isSingleton)return c.a.KeepLeft;if(this.deleted)return c.a.KeepRight;if(e.deleted)return this.payload.source===h.a.FileImport?c.a.KeepLeft:c.a.KeepRight;if(!m(this,e))return c.a.KeepRight;if(m(this,e,['references'])){if(t&&!m(t.itemFromPayload(),e))return c.a.KeepLeft;return e.payload.source===h.a.FileImport||Date.now()-this.userModifiedDate.getTime()<2e4?c.a.KeepLeftDuplicateRight:c.a.DuplicateLeftKeepRight}return c.a.KeepLeftMergeRefs}},{key:"isItemContentEqualWith",value:function(e){return b(this.payload.contentObject,e.payload.contentObject,this.contentKeysToIgnoreWhenCheckingEquality(),this.appDataContentKeysToIgnoreWhenCheckingEquality())}},{key:"satisfiesPredicate",value:function(e){return p.a.ItemSatisfiesPredicate(this,e)}},{key:"uuid",get:function(){return this.payload.uuid}},{key:"content",get:function(){return this.payload.content}},{key:"version",get:function(){if(this.payload.format===o.a.DecryptedBareObject)throw Error('Attempting to access version of decrypted payload');return this.payload.version}},{key:"safeContent",get:function(){return this.payload.safeContent}},{key:"references",get:function(){return this.payload.safeContent.references||[]}},{key:"deleted",get:function(){return this.payload.deleted}},{key:"content_type",get:function(){return this.payload.content_type}},{key:"created_at",get:function(){return this.payload.created_at}},{key:"serverUpdatedAt",get:function(){return this.payload.serverUpdatedAt}},{key:"serverUpdatedAtTimestamp",get:function(){return this.payload.updated_at_timestamp}},{key:"updated_at",get:function(){return this.serverUpdatedAt}},{key:"dirtiedDate",get:function(){return this.payload.dirtiedDate}},{key:"dirty",get:function(){return this.payload.dirty}},{key:"errorDecrypting",get:function(){return this.payload.errorDecrypting}},{key:"waitingForKey",get:function(){return this.payload.waitingForKey}},{key:"errorDecryptingValueChanged",get:function(){return this.payload.errorDecryptingValueChanged}},{key:"lastSyncBegan",get:function(){return this.payload.lastSyncBegan}},{key:"lastSyncEnd",get:function(){return this.payload.lastSyncEnd}},{key:"auth_hash",get:function(){return this.payload.auth_hash}},{key:"auth_params",get:function(){return this.payload.auth_params}},{key:"duplicate_of",get:function(){return this.payload.duplicate_of}},{key:"neverSynced",get:function(){return!this.serverUpdatedAt||0===this.serverUpdatedAt.getTime()}},{key:"isSingleton",get:function(){return!1}},{key:"singletonPredicate",get:function(){throw'Must override SNItem.singletonPredicate'}},{key:"singletonStrategy",get:function(){return i.KeepEarliest}},{key:"isSyncable",get:function(){return!this.errorDecrypting||!0===this.deleted}}],[{key:"DefaultAppDomain",value:function(){return d.b}}]),t})(),g=(function(){function e(t,n){v(this,e),this.item=t,this.type=n,this.payload=t.payload,this.payload.content&&(this.content=Object(l.a)(this.payload.content))}return y(e,[{key:"getUuid",value:function(){return this.payload.uuid}},{key:"getItem",value:function(){return this.item}},{key:"getResult",value:function(){if(this.type===r.NonDirtying)return Object(u.b)(this.payload,{content:this.content});this.payload.deleted||(this.type===r.UserInteraction?this.userModifiedDate=new Date:this.item.userModifiedDate||(this.userModifiedDate=new Date(this.item.serverUpdatedAt)));return Object(u.b)(this.payload,{content:this.content,dirty:!0,dirtiedDate:new Date})}},{key:"mergePayload",value:function(e){this.payload=Object(u.g)(this.payload,e),this.payload.content?this.content=Object(l.a)(this.payload.safeContent):this.content=void 0}},{key:"unsafe_setCustomContent",value:function(e){this.content=Object(l.a)(e)}},{key:"setDeleted",value:function(){this.content=void 0,this.payload=Object(u.b)(this.payload,{content:this.content,deleted:!0})}},{key:"setDomainData",value:function(e,t){this.payload.errorDecrypting||(this.content.appData||(this.content.appData={}),this.content.appData[t]=e)}},{key:"setDomainDataKey",value:function(e,t,n){if(!this.payload.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData;r[n]||(r[n]={}),r[n][e]=t}}},{key:"setAppDataItem",value:function(e,t){this.setDomainDataKey(e,t,f.DefaultAppDomain())}},{key:"addItemAsRelationship",value:function(e){var t=this.content.references||[];t.find(function(t){return t.uuid===e.uuid})||t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}},{key:"removeItemAsRelationship",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!==e.uuid}),this.content.references=t}},{key:"lastSyncBegan",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,lastSyncBegan:e})}},{key:"errorDecrypting",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,errorDecrypting:e})}},{key:"updated_at",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at:e})}},{key:"updated_at_timestamp",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at_timestamp:e})}},{key:"userModifiedDate",set:function(e){this.setAppDataItem(a.UserModifiedDate,e)}},{key:"conflictOf",set:function(e){this.content.conflict_of=e}},{key:"protected",set:function(e){this.content.protected=e}},{key:"trashed",set:function(e){this.content.trashed=e}},{key:"pinned",set:function(e){this.setAppDataItem(a.Pinned,e)}},{key:"archived",set:function(e){this.setAppDataItem(a.Archived,e)}},{key:"locked",set:function(e){this.setAppDataItem(a.Locked,e)}}]),e})();function m(e,t,n){return n||(n=[]),!b(e.content,t.content,e.contentKeysToIgnoreWhenCheckingEquality().concat(n),e.appDataContentKeysToIgnoreWhenCheckingEquality())}function b(e,t,n,r){if((e=Object(l.Q)(e)).appData){var a=e.appData[d.b];Object(l.J)(a,r),a?0===Object.keys(a).length&&delete e.appData:delete e.appData}if(Object(l.J)(e,n),(t=Object(l.Q)(t)).appData){var i=t.appData[d.b];Object(l.J)(i,r),i?0===Object.keys(i).length&&delete t.appData:delete t.appData}return Object(l.J)(t,n),JSON.stringify(e)===JSON.stringify(t)}}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"f",function(){return s}),n.d(t,"e",function(){return o}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return u});var r,a=n(3);function i(e){return e===a.a.RootKey||e===a.a.ItemsKey||e===a.a.EncryptedStorage}function s(e){return e===r.LocalStorageEncrypted||e===r.LocalStorageDecrypted||e===r.LocalStoragePreferEncrypted}function o(e){return e===r.FileEncrypted||e===r.FileDecrypted||e===r.FilePreferEncrypted}function c(e){return e===r.SyncDecrypted||e===r.LocalStorageDecrypted||e===r.FileDecrypted}function u(e){return e===r.Sync||e===r.LocalStorageEncrypted||e===r.FileEncrypted}!(function(e){e[e.Sync=0]="Sync",e[e.SyncDecrypted=1]="SyncDecrypted",e[e.LocalStorageEncrypted=2]="LocalStorageEncrypted",e[e.LocalStorageDecrypted=3]="LocalStorageDecrypted",e[e.LocalStoragePreferEncrypted=4]="LocalStoragePreferEncrypted",e[e.FileEncrypted=5]="FileEncrypted",e[e.FileDecrypted=6]="FileDecrypted",e[e.FilePreferEncrypted=7]="FilePreferEncrypted"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.FullSyncCompleted="sync:full-completed",e.SingleSyncCompleted="sync:single-completed",e.SyncWillBegin="sync:will-begin",e.DownloadFirstSyncCompleted="sync:download-first-completed",e.SyncTakingTooLong="sync:taking-too-long",e.SyncError="sync:error",e.InvalidSession="sync:invalid-session",e.MajorDataChange="major-data-change",e.LocalDataIncrementalLoad="local-data-incremental-load",e.LocalDataLoaded="local-data-loaded",e.EnterOutOfSync="enter-out-of-sync",e.ExitOutOfSync="exit-out-of-sync",e.StatusChanged="status-changed",e.DatabaseWriteError="database-write-error",e.DatabaseReadError="database-read-error"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var r=n(0),a=(function(){function e(){v(this,e),this.eventObservers=[],this.loggingEnabled=!1,this.criticalPromises=[]}return y(e,[{key:"addEventObserver",value:function(e){var t=this;return this.eventObservers.push(e),function(){Object(r.M)(t.eventObservers,e)}}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:n=S(this.eventObservers);case 1:if((r=n()).done){i.next=7;break}return a=r.value,i.next=5,b.awrap(a(e,t));case 5:i.next=1;break;case 7:case"end":return i.stop()}},null,this,null,Promise)}},{key:"blockDeinit",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(Promise.all(this.criticalPromises));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.eventObservers.length=0,this.deviceInterface=void 0}},{key:"executeCriticalFunction",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e(),this.criticalPromises.push(t),n.abrupt("return",t);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"log",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.loggingEnabled){var a,i=new Date,s=i.toLocaleTimeString().replace(' PM','').replace(' AM',''),o="".concat(s,".").concat(i.getMilliseconds());if(n)n=n.map(function(e){return Array.isArray(e)?e.slice():e}),(a=console).log.apply(a,[o,e].concat(m(n)));else console.log(o,e)}}}]),e})()},function(e,t,n){"use strict";n.d(t,"b",function(){return i}),n.d(t,"a",function(){return s});var r=n(7),a=n(3);function i(e){return e.map(function(e){return e.uuid})}function s(e){return e.references||(e.references=[]),e.appData||(e.appData={}),e.appData[a.b]||(e.appData[a.b]={}),e.appData[a.b][r.a.UserModifiedDate]||(e.appData[a.b][r.a.UserModifiedDate]="".concat(new Date)),e}},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.EncryptedString=0]="EncryptedString",e[e.DecryptedBareObject=1]="DecryptedBareObject",e[e.DecryptedBase64String=2]="DecryptedBase64String",e[e.Deleted=3]="Deleted"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"g",function(){return r}),n.d(t,"a",function(){return p}),n.d(t,"b",function(){return d}),n.d(t,"c",function(){return h}),n.d(t,"d",function(){return f}),n.d(t,"e",function(){return g}),n.d(t,"f",function(){return b}),n.d(t,"h",function(){return w});var r,a=n(14),i=n(6),s=n(0);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e.Registration="registration",e.EmailChange="email-change",e.PasswordChange="password-change",e.ProtocolUpgrade="protocol-upgrade",e.PasscodeCreate="passcode-create",e.PasscodeChange="passcode-change"})(r||(r={}));var l=['identifier','pw_cost','pw_nonce','pw_salt','version','origination','created'];function p(e){return g(e)}function d(e){return g(e)}function h(e){return g(e)}function f(e){return g(e)}function g(e){if(e.content)throw Error('Raw key params shouldnt have content; perhaps you passed in a SNRootKeyParams object.');return new w(e)}function m(e){if(e.version)return e.version;var t=e.pw_cost,n=a.a.PbkdfCostsUsed.includes(t),r=a.b.PbkdfCostsUsed.includes(t);return n&&!r?i.a.V001:r&&!n?i.a.V002:r&&n&&e.pw_nonce&&a.b.ImprobablePbkdfCostsUsed.includes(t)?i.a.V001:i.a.V002}function b(e,t){return g({identifier:t||e.data.identifier,pw_cost:e.data.pw_cost,pw_nonce:e.data.pw_nonce,pw_salt:e.data.pw_salt,version:m(e.data),origination:e.data.origination,created:e.data.created})}var w=(function(){function e(t){v(this,e),this.content=c(c({},t),{},{origination:t.origination||r.Registration,version:t.version||m(t)})}return y(e,[{key:"compare",value:function(e){if(this.version!==e.version)return!1;if([i.a.V004,i.a.V003].includes(this.version))return this.identifier===e.identifier&&this.content004.pw_nonce===e.content003.pw_nonce;if([i.a.V002,i.a.V001].includes(this.version))return this.identifier===e.identifier&&this.content002.pw_salt===e.content001.pw_salt;throw Error('Unhandled version in KeyParams.compare')}},{key:"getPortableValue",value:function(){return Object(s.L)(this.content,l)}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"identifier",get:function(){return this.content004.identifier||this.content002.email}},{key:"version",get:function(){return this.content.version}},{key:"origination",get:function(){return this.content.origination}},{key:"content001",get:function(){return this.content}},{key:"content002",get:function(){return this.content}},{key:"content003",get:function(){return this.content}},{key:"content004",get:function(){return this.content}},{key:"createdDate",get:function(){if(this.content004.created)return new Date(Number(this.content004.created))}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return s}),n.d(t,"c",function(){return r}),n.d(t,"d",function(){return a});var r,a,i=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:[3e3,5e3,1e4,6e4],PbkdfOutputLength:512,EncryptionKeyLength:256}),s=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:i.PbkdfCostsUsed.concat([1e5,101e3,102e3,103e3]),ImprobablePbkdfCostsUsed:[3e3,5e3],PbkdfOutputLength:768,EncryptionKeyLength:256,EncryptionIvLength:128});!(function(e){e[e.SaltSeedLength=256]="SaltSeedLength",e[e.PbkdfCost=11e4]="PbkdfCost",e[e.PbkdfOutputLength=768]="PbkdfOutputLength",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionIvLength=128]="EncryptionIvLength"})(r||(r={})),(function(e){e[e.ArgonSaltSeedLength=256]="ArgonSaltSeedLength",e[e.ArgonSaltLength=128]="ArgonSaltLength",e[e.ArgonIterations=5]="ArgonIterations",e[e.ArgonMemLimit=67108864]="ArgonMemLimit",e[e.ArgonOutputKeyBytes=64]="ArgonOutputKeyBytes",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionNonceLength=192]="EncryptionNonceLength"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"c",function(){return i}),n.d(t,"a",function(){return a});var r,a;n(22);function i(e){return e.status===r.HttpStatusExpiredAccessToken}!(function(e){e[e.LocalValidationError=10]="LocalValidationError",e[e.CanceledMfa=11]="CanceledMfa",e[e.UnknownError=12]="UnknownError",e[e.HttpStatusMinSuccess=200]="HttpStatusMinSuccess",e[e.HttpStatusNoContent=204]="HttpStatusNoContent",e[e.HttpStatusMaxSuccess=299]="HttpStatusMaxSuccess",e[e.HttpStatusExpiredAccessToken=498]="HttpStatusExpiredAccessToken",e[e.HttpStatusInvalidSession=401]="HttpStatusInvalidSession",e[e.HttpStatusForbidden=403]="HttpStatusForbidden",e[e.HttpBadRequest=400]="HttpBadRequest"})(r||(r={})),(function(e){e.ConflictingData="sync_conflict",e.UuidConflict="uuid_conflict",e.ContentTypeError="content_type_error",e.ContentError="content_error"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=(function(){function e(){v(this,e)}return y(e,null,[{key:"log",value:function(){this.onLog.apply(this,arguments)}},{key:"error",value:function(e){return this.onError(e),e}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"c",function(){return i});var r,a=n(9);function i(e){var t;return(t={},g(t,a.a.FullSyncCompleted,r.CompletedFullSync),g(t,a.a.SingleSyncCompleted,r.CompletedIncrementalSync),g(t,a.a.SyncError,r.FailedSync),g(t,a.a.SyncTakingTooLong,r.HighLatencySync),g(t,a.a.EnterOutOfSync,r.EnteredOutOfSync),g(t,a.a.ExitOutOfSync,r.ExitedOutOfSync),g(t,a.a.LocalDataLoaded,r.LocalDataLoaded),g(t,a.a.MajorDataChange,r.MajorDataChange),g(t,a.a.LocalDataIncrementalLoad,r.LocalDataIncrementalLoad),g(t,a.a.StatusChanged,r.SyncStatusChanged),g(t,a.a.SyncWillBegin,r.WillSync),g(t,a.a.InvalidSession,r.InvalidSyncSession),g(t,a.a.DatabaseReadError,r.LocalDatabaseReadError),g(t,a.a.DatabaseWriteError,r.LocalDatabaseWriteError),t)[e]}n.d(t,"b",function(){return a.a}),(function(e){e[e.SignedIn=2]="SignedIn",e[e.SignedOut=3]="SignedOut",e[e.CompletedFullSync=5]="CompletedFullSync",e[e.FailedSync=6]="FailedSync",e[e.HighLatencySync=7]="HighLatencySync",e[e.EnteredOutOfSync=8]="EnteredOutOfSync",e[e.ExitedOutOfSync=9]="ExitedOutOfSync",e[e.Started=10]="Started",e[e.Launched=11]="Launched",e[e.LocalDataLoaded=12]="LocalDataLoaded",e[e.KeyStatusChanged=13]="KeyStatusChanged",e[e.MajorDataChange=14]="MajorDataChange",e[e.CompletedRestart=15]="CompletedRestart",e[e.LocalDataIncrementalLoad=16]="LocalDataIncrementalLoad",e[e.SyncStatusChanged=17]="SyncStatusChanged",e[e.WillSync=18]="WillSync",e[e.InvalidSyncSession=19]="InvalidSyncSession",e[e.LocalDatabaseReadError=20]="LocalDatabaseReadError",e[e.LocalDatabaseWriteError=21]="LocalDatabaseWriteError",e[e.CompletedIncrementalSync=22]="CompletedIncrementalSync",e[e.MigrationsLoaded=23]="MigrationsLoaded",e[e.StorageReady=24]="StorageReady",e[e.PreferencesChanged=25]="PreferencesChanged",e[e.ProtectionSessionExpiryDateChanged=26]="ProtectionSessionExpiryDateChanged",e[e.UserRolesChanged=27]="UserRolesChanged",e[e.FeaturesUpdated=28]="FeaturesUpdated"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.KeepLeft=1]="KeepLeft",e[e.KeepRight=2]="KeepRight",e[e.KeepLeftDuplicateRight=3]="KeepLeftDuplicateRight",e[e.DuplicateLeftKeepRight=4]="DuplicateLeftKeepRight",e[e.KeepLeftMergeRefs=5]="KeepLeftMergeRefs"})(r||(r={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(211),t)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(221),t)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(0);function a(e){return e instanceof i?e:Array.isArray(e)?i.FromArray(e):i.FromJson(e)}var i=(function(){function e(t,n,r){if(v(this,e),this.keypath=t,this.operator=n,this.value=r,this.isRecursive()){var i=this.value;this.value=i.map(function(e){return a(e)})}else'true'!==this.value&&'false'!==this.value||(this.value=JSON.parse(this.value))}return y(e,[{key:"isRecursive",value:function(){return['and','or'].includes(this.operator)}},{key:"arrayRepresentation",value:function(){return[this.keypath,this.operator,this.value]}},{key:"valueAsArray",value:function(){return this.value}},{key:"keypathIncludesVerb",value:function(e){if(this.isRecursive()){for(var t,n=S(this.value);!(t=n()).done;){if(t.value.keypathIncludesVerb(e))return!0}return!1}return this.keypath.includes(e)}}],[{key:"FromJson",value:function(t){return new e(t.keypath,t.operator,t.value)}},{key:"FromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"CompoundPredicate",value:function(t){return new e('ignored','and',t)}},{key:"ObjectSatisfiesPredicate",value:function(e,t){if((t=a(t)).isRecursive()){if('and'===t.operator){for(var n,r=S(t.valueAsArray());!(n=r()).done;){var i=n.value;if(!this.ObjectSatisfiesPredicate(e,i))return!1}return!0}if('or'===t.operator){for(var s,o=S(t.valueAsArray());!(s=o()).done;){var c=s.value;if(this.ObjectSatisfiesPredicate(e,c))return!0}return!1}}var u=t.value;if('string'==typeof u&&u.includes('.ago')&&(u=this.DateFromString(u)),'not'===t.operator)return!this.ObjectSatisfiesPredicate(e,u);var l=t.keypath.split('.').reduce(function(e,t){return e&&e[t]},e),p=[!1,'',null,void 0,NaN];return void 0===l?'!='===t.operator?!p.includes(t.value):p.includes(t.value):'='===t.operator?Array.isArray(l)?JSON.stringify(l)===JSON.stringify(u):l===u:'!='===t.operator?Array.isArray(l)?JSON.stringify(l)!==JSON.stringify(u):l!==u:'<'===t.operator?l<u:'>'===t.operator?l>u:'<='===t.operator?l<=u:'>='===t.operator?l>=u:'startsWith'===t.operator?l.startsWith(u):'in'===t.operator?-1!==u.indexOf(l):'includes'===t.operator?this.resolveIncludesPredicate(l,u):'matches'===t.operator&&new RegExp(u).test(l)}},{key:"resolveIncludesPredicate",value:function(t,n){if(Object(r.A)(n))return t.includes(n);var a;a=Array.isArray(n)?e.FromArray(n):n;for(var i,s=S(t);!(i=s()).done;){var o=i.value;if(this.ObjectSatisfiesPredicate(o,a))return!0}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!this.ItemSatisfiesPredicate(e,a))return!1}return!0}},{key:"DateFromString",value:function(e){var t=e.split('.'),n=t[1],r=new Date,a=parseInt(t[0]);return'days'===n?r.setDate(r.getDate()-a):'hours'===n&&r.setHours(r.getHours()-a),r}}]),e})()},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.LastSyncToken="sync_token",e.PaginationToken="cursor_token",e.IntegrityCheck="compute_integrity",e.IntegrityResult="integrity_hash",e.SyncDlLimit="limit",e.SyncPayloads="items",e.ApiVersion="api"})(r||(r={}))},function(e,t,n){"use strict";var r=Array.isArray;e.exports=r},function(e,t,n){"use strict";var r=n(68),a='object'==typeof self&&self&&self.Object===Object&&self,i=r||a||Function('return this')();e.exports=i},function(e,t,n){"use strict";var r=n(173)(n(174));e.exports=r},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(e,t,n){"use strict";var r=n(48),a=n(168);e.exports=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,s=[],o=e.length;for(t=r(t,3);++i<o;){var c=e[i];t(c,i,e)&&(n.push(c),s.push(i))}return a(e,s),n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e){return e&&e.length?r(e):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(241),t)},function(e,t,n){"use strict";var r=n(110),a=n(115);e.exports=function(e,t){var n=a(e,t);return r(n)?n:void 0}},function(e,t,n){"use strict";e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t,n){"use strict";n.d(t,"a",function(){return u});var r=n(11),a=n(5),i=n(4),s=n(6),o=n(0),c=n(12),u=(function(){function e(t,n,u){if(v(this,e),this.fields=n||Object.keys(t),this.source=u||i.a.Constructor,this.uuid=t.uuid,!this.uuid&&this.fields.includes(a.a.Uuid))throw Error("uuid is null, yet this payloads fields indicate it shouldnt be. Content type: ".concat(t.content_type));this.content_type=t.content_type,t.content&&(Object(o.x)(t.content)?this.content=Object(r.a)(t.content):this.content=t.content),this.deleted=t.deleted,this.items_key_id=t.items_key_id,this.enc_item_key=t.enc_item_key,this.created_at=new Date(t.created_at||new Date),this.updated_at=new Date(t.updated_at||0),this.created_at_timestamp=t.created_at_timestamp,this.updated_at_timestamp=t.updated_at_timestamp,t.dirtiedDate&&(this.dirtiedDate=new Date(t.dirtiedDate)),this.dirty=t.dirty,this.errorDecrypting=t.errorDecrypting,this.waitingForKey=t.waitingForKey,this.errorDecryptingValueChanged=t.errorDecryptingValueChanged,this.lastSyncBegan=t.lastSyncBegan?new Date(t.lastSyncBegan):void 0,this.lastSyncEnd=t.lastSyncEnd?new Date(t.lastSyncEnd):void 0,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params,this.duplicate_of=t.duplicate_of,Object(o.A)(this.content)?this.content.startsWith(s.a.V000Base64Decrypted)?this.format=c.a.DecryptedBase64String:this.format=c.a.EncryptedString:Object(o.x)(this.content)?this.format=c.a.DecryptedBareObject:this.format=c.a.Deleted,Object(o.A)(this.content)?this.version=this.content.substring(0,s.a.VersionLength):this.content&&(this.version=this.content.version),Object(o.l)(this)}return y(e,[{key:"ejected",value:function(){for(var e,t=[a.a.Legacy003AuthHash,a.a.Deleted],n=[a.a.DirtiedDate,a.a.ErrorDecrypting,a.a.ErrorDecryptingChanged,a.a.WaitingForKey,a.a.LastSyncBegan,a.a.LastSyncEnd],r={},i=S(this.fields);!(e=i()).done;){var s=e.value;if(!n.includes(s)){var c=this[s];Object(o.w)(c)&&t.includes(s)||(r[s]=c)}}return r}},{key:"safeContent",get:function(){return this.format===c.a.DecryptedBareObject?this.content:{}}},{key:"references",get:function(){return this.safeReferences}},{key:"safeReferences",get:function(){return this.safeContent.references||[]}},{key:"contentObject",get:function(){if(this.format!==c.a.DecryptedBareObject)throw Error('Attempting to access non-object content as object');return this.content}},{key:"contentString",get:function(){if(this.format===c.a.DecryptedBareObject)throw Error('Attempting to access non-string content as string');return this.content}},{key:"discardable",get:function(){return this.deleted&&!this.dirty}},{key:"serverUpdatedAt",get:function(){return this.updated_at}}]),e})()},function(e,t,n){"use strict";var r=n(40),a=n(111),i=n(112),s='[object Null]',o='[object Undefined]',c=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?o:s:c&&c in Object(e)?a(e):i(e)}},function(e,t,n){"use strict";var r;r=(function(){return this})();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,n){"use strict";var r=n(51),a=n(59);e.exports=function(e){return null!=e&&a(e.length)&&!r(e)}},function(e,t,n){"use strict";var r=n(44);e.exports=function(e){if('string'==typeof e||r(e))return e;var t=e+'';return'0'==t&&1/e==-1/0?'-0':t}},function(e,t,n){"use strict";var r=n(100),a=n(101),i=n(102),s=n(103),o=n(104);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(35);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},function(e,t,n){"use strict";var r=n(24).Symbol;e.exports=r},function(e,t,n){"use strict";var r=n(30)(Object,'create');e.exports=r},function(e,t,n){"use strict";var r=n(124);e.exports=function(e,t){var n=e.__data__;return r(t)?n['string'==typeof t?'string':'hash']:n.map}},function(e,t,n){"use strict";var r=9007199254740991,a=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var n=typeof e;return!!(t=null==t?r:t)&&('number'==n||'symbol'!=n&&a.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Symbol]';e.exports=function(e){return'symbol'==typeof e||a(e)&&r(e)==i}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(231),t)},function(e,t,n){"use strict";var r=n(96);n.d(t,"SNSettingsService",function(){return r.a});var a=n(94);n.n(a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n){r(e,t,n)});e.exports=a},function(e,t,n){"use strict";var r=n(98),a=n(154),i=n(64),s=n(23),o=n(165);e.exports=function(e){return'function'==typeof e?e:null==e?i:'object'==typeof e?s(e)?a(e[0],e[1]):r(e):o(e)}},function(e,t,n){"use strict";var r=n(38),a=n(105),i=n(106),s=n(107),o=n(108),c=n(109);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=a,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=c,e.exports=u},function(e,t,n){"use strict";var r=n(30)(n(24),'Map');e.exports=r},function(e,t,n){"use strict";var r=n(33),a=n(26),i='[object AsyncFunction]',s='[object Function]',o='[object GeneratorFunction]',c='[object Proxy]';e.exports=function(e){if(!a(e))return!1;var t=r(e);return t==s||t==o||t==i||t==c}},function(e,t,n){"use strict";var r=n(116),a=n(123),i=n(125),s=n(126),o=n(127);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},function(e,t,n){"use strict";var r=n(75),a=n(147),i=n(36);e.exports=function(e){return i(e)?r(e):a(e)}},function(e,t,n){"use strict";var r=n(142),a=n(31),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,c=r((function(){return arguments})())?r:function(e){return a(e)&&s.call(e,'callee')&&!o.call(e,'callee')};e.exports=c},function(e,t,n){"use strict";(function(e){var r=n(24),a=n(143),i=t&&!t.nodeType&&t,s=i&&'object'==typeof e&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,c=(o?o.isBuffer:void 0)||a;e.exports=c}).call(this,n(57)(e))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";var r=n(144),a=n(145),i=n(146),s=i&&i.isTypedArray,o=s?a(s):r;e.exports=o},function(e,t,n){"use strict";var r=9007199254740991;e.exports=function(e){return'number'==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,n){"use strict";var r=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===('function'==typeof t&&t.prototype||r)}},function(e,t,n){"use strict";var r=n(62),a=n(37);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[a(t[n++])];return n&&n==i?e:void 0}},function(e,t,n){"use strict";var r=n(23),a=n(63),i=n(156),s=n(159);e.exports=function(e,t){return r(e)?e:a(e,t)?[e]:i(s(e))}},function(e,t,n){"use strict";var r=n(23),a=n(44),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!('number'!=n&&'symbol'!=n&&'boolean'!=n&&null!=e&&!a(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},function(e,t,n){"use strict";e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(83);e.exports=function(e,t,n){'__proto__'==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e,t){return t='function'==typeof t?t:void 0,e&&e.length?r(e,void 0,t):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(228),t),a(n(229),t),a(n(230),t)},function(e,t,n){"use strict";(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(34))},function(e,t,n){"use strict";var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+''}catch(e){}}return''}},function(e,t,n){"use strict";var r=n(128),a=n(31);e.exports=function e(t,n,i,s,o){return t===n||(null==t||null==n||!a(t)&&!a(n)?t!=t&&n!=n:r(t,n,i,s,e,o))}},function(e,t,n){"use strict";var r=n(72),a=n(131),i=n(73),s=1,o=2;e.exports=function(e,t,n,c,u,l){var p=n&s,d=e.length,h=t.length;if(d!=h&&!(p&&h>d))return!1;var f=l.get(e),v=l.get(t);if(f&&v)return f==t&&v==e;var y=-1,g=!0,m=n&o?new r:void 0;for(l.set(e,t),l.set(t,e);++y<d;){var b=e[y],w=t[y];if(c)var k=p?c(w,b,y,t,e,l):c(b,w,y,e,t,l);if(void 0!==k){if(k)continue;g=!1;break}if(m){if(!a(t,function(e,t){if(!i(m,t)&&(b===e||u(b,e,n,c,l)))return m.push(t)})){g=!1;break}}else if(b!==w&&!u(b,w,n,c,l)){g=!1;break}}return l.delete(e),l.delete(t),g}},function(e,t,n){"use strict";var r=n(52),a=n(129),i=n(130);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=a,s.prototype.has=i,e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t){return e.has(t)}},function(e,t,n){"use strict";var r=n(24).Uint8Array;e.exports=r},function(e,t,n){"use strict";var r=n(141),a=n(55),i=n(23),s=n(56),o=n(43),c=n(58),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&a(e),p=!n&&!l&&s(e),d=!n&&!l&&!p&&c(e),h=n||l||p||d,f=h?r(e.length,String):[],v=f.length;for(var y in e)!t&&!u.call(e,y)||h&&('length'==y||p&&('offset'==y||'parent'==y)||d&&('buffer'==y||'byteLength'==y||'byteOffset'==y)||o(y,v))||f.push(y);return f}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){"use strict";var r=n(30)(n(24),'Set');e.exports=r},function(e,t,n){"use strict";var r=n(26);e.exports=function(e){return e==e&&!r(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){for(var a=e.length,i=n+(r?1:-1);r?i--:++i<a;)if(t(e[i],i,e))return i;return-1}},function(e,t,n){"use strict";var r=n(49),a=n(82),i=n(178),s=n(180),o=n(26),c=n(86),u=n(85);e.exports=function e(t,n,l,p,d){t!==n&&i(n,function(i,c){if(d||(d=new r),o(i))s(t,n,c,l,e,p,d);else{var h=p?p(u(t,c),i,c+'',t,n,d):void 0;void 0===h&&(h=i),a(t,c,h)}},c)}},function(e,t,n){"use strict";var r=n(65),a=n(35);e.exports=function(e,t,n){(void 0===n||a(e[t],n))&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(30),a=(function(){try{var e=r(Object,'defineProperty');return e({},'',{}),e}catch(e){}})();e.exports=a},function(e,t,n){"use strict";var r=n(76)(Object.getPrototypeOf,Object);e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){if(('constructor'!==t||'function'!=typeof e[t])&&'__proto__'!=t)return e[t]}},function(e,t,n){"use strict";var r=n(75),a=n(192),i=n(36);e.exports=function(e){return i(e)?r(e,!0):a(e)}},function(e,t,n){"use strict";var r=n(194),a=n(201);e.exports=function(e){return r(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(s=e.length>3&&'function'==typeof s?(i--,s):void 0,o&&a(n[0],n[1],o)&&(s=i<3?void 0:s,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,s)}return t})}},function(e,t,n){"use strict";var r=n(72),a=n(202),i=n(206),s=n(73),o=n(207),c=n(53),u=200;e.exports=function(e,t,n){var l=-1,p=a,d=e.length,h=!0,f=[],v=f;if(n)h=!1,p=i;else if(d>=u){var y=t?null:o(e);if(y)return c(y);h=!1,p=s,v=new r}else v=t?[]:f;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=n||0!==g?g:0,h&&m==m){for(var b=v.length;b--;)if(v[b]===m)continue e;t&&v.push(m),f.push(g)}else p(v,m,n)||(v!==f&&v.push(m),f.push(g))}return f}},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(209),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeatureIdentifier=void 0,(function(e){e.AutobiographyTheme="org.standardnotes.theme-autobiography",e.BoldEditor="org.standardnotes.bold-editor",e.CloudLink="org.standardnotes.cloudlink",e.CodeEditor="org.standardnotes.code-editor",e.DailyDropboxBackup="org.standardnotes.daily-dropbox-backup",e.DailyEmailBackup="org.standardnotes.daily-email-backup",e.DailyGDriveBackup="org.standardnotes.daily-gdrive-backup",e.DailyOneDriveBackup="org.standardnotes.daily-onedrive-backup",e.DynamicTheme="org.standardnotes.theme-dynamic",e.Files="org.standardnotes.files",e.Files25GB="org.standardnotes.files-25-gb",e.Files5GB="org.standardnotes.files-5-gb",e.FileSafe="org.standardnotes.file-safe",e.FocusedTheme="org.standardnotes.theme-focus",e.FoldersComponent="org.standardnotes.folders",e.FuturaTheme="org.standardnotes.theme-futura",e.ListedCustomDomain="org.standardnotes.listed-custom-domain",e.MarkdownBasicEditor="org.standardnotes.simple-markdown-editor",e.MarkdownMathEditor="org.standardnotes.fancy-markdown-editor",e.MarkdownMinimistEditor="org.standardnotes.minimal-markdown-editor",e.MarkdownProEditor="org.standardnotes.advanced-markdown-editor",e.MidnightTheme="org.standardnotes.theme-midnight",e.NoDistractionTheme="org.standardnotes.theme-no-distraction",e.NoteHistory30Days="org.standardnotes.note-history-30",e.NoteHistory365Days="org.standardnotes.note-history-365",e.NoteHistoryUnlimited="org.standardnotes.note-history-unlimited",e.PlusEditor="org.standardnotes.plus-editor",e.SheetsEditor="org.standardnotes.standard-sheets",e.SolarizedDarkTheme="org.standardnotes.theme-solarized-dark",e.TagNesting="org.standardnotes.tag-nesting",e.TaskEditor="org.standardnotes.simple-task-editor",e.TitaniumTheme="org.standardnotes.theme-titanium",e.TokenVaultEditor="org.standardnotes.token-vault",e.TwoFactorAuth="org.standardnotes.two-factor-auth",e.TwoFactorAuthManager="org.standardnotes.mfa-link",e.FocusMode="org.standardnotes.focus-mode"})(t.FeatureIdentifier||(t.FeatureIdentifier={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentArea=void 0,(function(e){e.Editor="editor-editor",e.Themes="themes",e.TagsList="tags-list",e.EditorStack="editor-stack",e.NoteTags="note-tags",e.Rooms="rooms",e.Modal="modal",e.Any="*"})(t.ComponentArea||(t.ComponentArea={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentFlag=void 0,(function(e){e.New="New",e.Deprecated="Deprecated"})(t.ComponentFlag||(t.ComponentFlag={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionName=void 0,(function(e){e.AutobiographyTheme="theme:autobiography",e.BoldEditor="editor:bold",e.CloudLink="component:cloud-link",e.CodeEditor="editor:code-editor",e.ComponentFilesafe="component:filesafe",e.ComponentFolders="component:folders",e.DailyDropboxBackup="server:daily-dropbox-backup",e.DailyEmailBackup="server:daily-email-backup",e.DailyGDriveBackup="server:daily-gdrive-backup",e.DailyOneDriveBackup="server:daily-onedrive-backup",e.Files="app:files",e.Files25GB="server:files-25-gb",e.Files5GB="server:files-5-gb",e.FocusedTheme="theme:focused",e.FuturaTheme="theme:futura",e.ListedCustomDomain="listed:custom-domain",e.MarkdownBasicEditor="editor:markdown-basic",e.MarkdownMathEditor="editor:markdown-math",e.MarkdownMinimistEditor="editor:markdown-minimist",e.MarkdownProEditor="editor:markdown-pro",e.MidnightTheme="theme:midnight",e.NoteHistory30Days="server:note-history-30-days",e.NoteHistory365Days="server:note-history-365-days",e.NoteHistoryUnlimited="server:note-history-unlimited",e.PlusEditor="editor:plus",e.SheetsEditor="editor:sheets",e.SolarizedDarkTheme="theme:solarized-dark",e.TagNesting="app:tag-nesting",e.TaskEditor="editor:task-editor",e.ThemeDynamic="theme:dynamic",e.ThemeNoDistraction="theme:no-distraction",e.TitaniumTheme="theme:titanium",e.TokenVaultEditor="editor:token-vault",e.TwoFactorAuth="server:two-factor-auth",e.TwoFactorAuthManager="component:2fa-manager",e.FocusMode="app:focus-mode"})(t.PermissionName||(t.PermissionName={}))},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return i});var r=n(10),a=n(17),i=(function(t){d(r,t);var n=k(r);function r(t){var a;return v(this,r),(a=n.call(this)).application=t,e(function(){a.addAppEventObserver()}),a}return y(r,[{key:"deinit",value:function(){this.application=void 0,this.unsubApp(),this.unsubApp=void 0,p(f(r.prototype),"deinit",this).call(this)}},{key:"addAppEventObserver",value:function(){var e=this;this.application.isStarted()&&this.onAppStart(),this.application.isLaunched()&&this.onAppLaunch(),this.unsubApp=this.application.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(e.onAppEvent(t));case 2:t===a.a.Started?e.onAppStart():t===a.a.Launched?e.onAppLaunch():t===a.a.CompletedFullSync?e.onAppFullSync():t===a.a.CompletedIncrementalSync?e.onAppIncrementalSync():t===a.a.KeyStatusChanged&&e.onAppKeyChange();case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"onAppEvent",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppStart",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppLaunch",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppKeyChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppIncrementalSync",value:function(){}},{key:"onAppFullSync",value:function(){}}]),r})(r.a)}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(10),a=n(2),i=n(15),s=(function(){function e(t,n){v(this,e),this.settingsApi=t,this.userProvider=n}return y(e,[{key:"isReadyForModification",value:function(){return null!=this.getUser()}},{key:"getUser",value:function(){return this.userProvider.getUser()}},{key:"listSettings",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.settingsApi.listSettings(this.userUuid));case 2:if(e=o.sent,t=e.error,n=e.data,null==t){o.next=7;break}throw new Error(t.message);case 7:if(null!=n&&null!=n.settings){o.next=9;break}return o.abrupt("return",{});case 9:for(r={},a=S(n.settings);!(i=a()).done;)s=i.value,r[s.name]=s.value;return o.abrupt("return",r);case 12:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){var t,n,r,a;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((a=s.sent).status!==i.b.HttpBadRequest){s.next=5;break}return s.abrupt("return",null);case 5:if(null==a.error){s.next=7;break}throw new Error(a.error.message);case 7:return s.abrupt("return",null!==(t=null===a||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:null===(r=n.setting)||void 0===r?void 0:r.value)&&void 0!==t?t:null);case 8:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((r=a.sent).status!==i.b.HttpBadRequest){a.next=5;break}return a.abrupt("return",!1);case 5:if(null==r.error){a.next=7;break}throw new Error(r.error.message);case 7:return a.abrupt("return",null!==(t=null===(n=r.data)||void 0===n?void 0:n.success)&&void 0!==t&&t);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){var r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.settingsApi.updateSetting(this.userUuid,e,t,n));case 2:if(r=i.sent,null==(a=r.error)){i.next=6;break}throw new Error(a.message);case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.settingsApi.deleteSetting(this.userUuid,e));case 2:if(t=r.sent,null==(n=t.error)){r.next=6;break}throw new Error(n.message);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.settingsApi=void 0,this.userProvider=void 0}},{key:"userUuid",get:function(){var e=this.getUser();if(null==e||null==e.uuid)throw new Error(a.o);return e.uuid}}]),e})(),o=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).sessionManager=e,a.apiService=r,a}return y(n,[{key:"initializeFromDisk",value:function(){this._provider=new s(this.apiService,this.sessionManager)}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._provider.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this._provider.updateSetting(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){var e;null===(e=this._provider)||void 0===e||e.deinit(),this._provider=void 0,this.sessionManager=void 0,this.apiService=void 0}}]),n})(r.a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n,a){r(e,t,n,a)});e.exports=a},function(e,t,n){"use strict";var r=n(99),a=n(153),i=n(79);e.exports=function(e){var t=a(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){"use strict";var r=n(49),a=n(70);e.exports=function(e,t,n,i){var s=n.length,o=s,c=!i;if(null==e)return!o;for(e=Object(e);s--;){var u=n[s];if(c&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++s<o;){var l=(u=n[s])[0],p=e[l],d=u[1];if(c&&u[2]){if(void 0===p&&!(l in e))return!1}else{var h=new r;if(i)var f=i(p,d,l,e,t,h);if(!(void 0===f?a(d,p,3,i,h):f))return!1}}return!0}},function(e,t,n){"use strict";e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){"use strict";var r=n(39),a=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():a.call(t,n,1),--this.size,0))}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e,t){var n=this.__data__,a=r(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}},function(e,t,n){"use strict";var r=n(38);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.get(e)}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";var r=n(38),a=n(50),i=n(52);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!a||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){"use strict";var r=n(51),a=n(113),i=n(26),s=n(69),o=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,p=u.hasOwnProperty,d=RegExp('^'+l.call(p).replace(/[\\^$.*+?()[\]{}|]/g,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');e.exports=function(e){return!(!i(e)||a(e))&&(r(e)?d:o).test(s(e))}},function(e,t,n){"use strict";var r=n(40),a=Object.prototype,i=a.hasOwnProperty,s=a.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0}catch(e){}var r=s.call(e);return t?e[o]=n:delete e[o],r}},function(e,t,n){"use strict";var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,n){"use strict";var r,a=n(114),i=(r=/[^.]+$/.exec(a&&a.keys&&a.keys.IE_PROTO||''))?'Symbol(src)_1.'+r:'';e.exports=function(e){return!!i&&i in e}},function(e,t,n){"use strict";var r=n(24)['__core-js_shared__'];e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){"use strict";var r=n(117),a=n(38),i=n(50);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||a),string:new r}}},function(e,t,n){"use strict";var r=n(118),a=n(119),i=n(120),s=n(121),o=n(122);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(41);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__',i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===a?void 0:n}return i.call(t,e)?t[e]:void 0}},function(e,t,n){"use strict";var r=n(41),a=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:a.call(t,e)}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__';e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?a:t,this}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return'string'==t||'number'==t||'symbol'==t||'boolean'==t?'__proto__'!==e:null===e}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).get(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).has(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e,t){var n=r(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}},function(e,t,n){"use strict";var r=n(49),a=n(71),i=n(132),s=n(134),o=n(149),c=n(23),u=n(56),l=n(58),p=1,d='[object Arguments]',h='[object Array]',f='[object Object]',v=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,y,g,m){var b=c(e),w=c(t),k=b?h:o(e),x=w?h:o(t),S=(k=k==d?f:k)==f,P=(x=x==d?f:x)==f,O=k==x;if(O&&u(e)){if(!u(t))return!1;b=!0,S=!1}if(O&&!S)return m||(m=new r),b||l(e)?a(e,t,n,y,g,m):i(e,t,k,n,y,g,m);if(!(n&p)){var C=S&&v.call(e,'__wrapped__'),D=P&&v.call(t,'__wrapped__');if(C||D){var _=C?e.value():e,E=D?t.value():t;return m||(m=new r),g(_,E,n,y,m)}}return!!O&&(m||(m=new r),s(e,t,n,y,g,m))}},function(e,t,n){"use strict";var r='__lodash_hash_undefined__';e.exports=function(e){return this.__data__.set(e,r),this}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},function(e,t,n){"use strict";var r=n(40),a=n(74),i=n(35),s=n(71),o=n(133),c=n(53),u=1,l=2,p='[object Boolean]',d='[object Date]',h='[object Error]',f='[object Map]',v='[object Number]',y='[object RegExp]',g='[object Set]',m='[object String]',b='[object Symbol]',w='[object ArrayBuffer]',k='[object DataView]',x=r?r.prototype:void 0,S=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,P,O){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!P(new a(e),new a(t)));case p:case d:case v:return i(+e,+t);case h:return e.name==t.name&&e.message==t.message;case y:case m:return e==t+'';case f:var C=o;case g:var D=r&u;if(C||(C=c),e.size!=t.size&&!D)return!1;var _=O.get(e);if(_)return _==t;r|=l,O.set(e,t);var E=s(C(e),C(t),r,x,P,O);return O.delete(e),E;case b:if(S)return S.call(e)==S.call(t)}return!1}},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},function(e,t,n){"use strict";var r=n(135),a=1,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,s,o,c){var u=n&a,l=r(e),p=l.length;if(p!=r(t).length&&!u)return!1;for(var d=p;d--;){var h=l[d];if(!(u?h in t:i.call(t,h)))return!1}var f=c.get(e),v=c.get(t);if(f&&v)return f==t&&v==e;var y=!0;c.set(e,t),c.set(t,e);for(var g=u;++d<p;){var m=e[h=l[d]],b=t[h];if(s)var w=u?s(b,m,h,t,e,c):s(m,b,h,e,t,c);if(!(void 0===w?m===b||o(m,b,n,s,c):w)){y=!1;break}g||(g='constructor'==h)}if(y&&!g){var k=e.constructor,x=t.constructor;k!=x&&'constructor'in e&&'constructor'in t&&!('function'==typeof k&&k instanceof k&&'function'==typeof x&&x instanceof x)&&(y=!1)}return c.delete(e),c.delete(t),y}},function(e,t,n){"use strict";var r=n(136),a=n(138),i=n(54);e.exports=function(e){return r(e,i,a)}},function(e,t,n){"use strict";var r=n(137),a=n(23);e.exports=function(e,t,n){var i=t(e);return a(e)?i:r(i,n(e))}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}},function(e,t,n){"use strict";var r=n(139),a=n(140),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:a;e.exports=o},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}},function(e,t,n){"use strict";e.exports=function(){return[]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Arguments]';e.exports=function(e){return a(e)&&r(e)==i}},function(e,t,n){"use strict";e.exports=function(){return!1}},function(e,t,n){"use strict";var r=n(33),a=n(59),i=n(31),s={};s['[object Float32Array]']=s['[object Float64Array]']=s['[object Int8Array]']=s['[object Int16Array]']=s['[object Int32Array]']=s['[object Uint8Array]']=s['[object Uint8ClampedArray]']=s['[object Uint16Array]']=s['[object Uint32Array]']=!0,s['[object Arguments]']=s['[object Array]']=s['[object ArrayBuffer]']=s['[object Boolean]']=s['[object DataView]']=s['[object Date]']=s['[object Error]']=s['[object Function]']=s['[object Map]']=s['[object Number]']=s['[object Object]']=s['[object RegExp]']=s['[object Set]']=s['[object String]']=s['[object WeakMap]']=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!s[r(e)]}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){"use strict";(function(e){var r=n(68),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a&&r.process,o=(function(){try{var e=i&&i.require&&i.require('util').types;return e||s&&s.binding&&s.binding('util')}catch(e){}})();e.exports=o}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(60),a=n(148),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return a(e);var t=[];for(var n in Object(e))i.call(e,n)&&'constructor'!=n&&t.push(n);return t}},function(e,t,n){"use strict";var r=n(76)(Object.keys,Object);e.exports=r},function(e,t,n){"use strict";var r=n(150),a=n(50),i=n(151),s=n(77),o=n(152),c=n(33),u=n(69),l=u(r),p=u(a),d=u(i),h=u(s),f=u(o),v=c;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||a&&"[object Map]"!=v(new a)||i&&"[object Promise]"!=v(i.resolve())||s&&"[object Set]"!=v(new s)||o&&"[object WeakMap]"!=v(new o))&&(v=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):'';if(r)switch(r){case l:return"[object DataView]";case p:return"[object Map]";case d:return"[object Promise]";case h:return"[object Set]";case f:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";var r=n(30)(n(24),'DataView');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'Promise');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'WeakMap');e.exports=r},function(e,t,n){"use strict";var r=n(78),a=n(54);e.exports=function(e){for(var t=a(e),n=t.length;n--;){var i=t[n],s=e[i];t[n]=[i,s,r(s)]}return t}},function(e,t,n){"use strict";var r=n(70),a=n(155),i=n(162),s=n(63),o=n(78),c=n(79),u=n(37);e.exports=function(e,t){return s(e)&&o(t)?c(u(e),t):function(n){var s=a(n,e);return void 0===s&&s===t?i(n,e):r(t,s,3)}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e,t,n){var a=null==e?void 0:r(e,t);return void 0===a?n:a}},function(e,t,n){"use strict";var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,i=n(157)(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(''),e.replace(r,function(e,n,r,i){t.push(r?i.replace(a,'$1'):n||e)}),t});e.exports=i},function(e,t,n){"use strict";var r=n(158),a=500;e.exports=function(e){var t=r(e,function(e){return n.size===a&&n.clear(),e}),n=t.cache;return t}},function(e,t,n){"use strict";var r=n(52),a='Expected a function';function i(e,t){if('function'!=typeof e||null!=t&&'function'!=typeof t)throw new TypeError(a);var n=function n(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},function(e,t,n){"use strict";var r=n(160);e.exports=function(e){return null==e?'':r(e)}},function(e,t,n){"use strict";var r=n(40),a=n(161),i=n(23),s=n(44),o=r?r.prototype:void 0,c=o?o.toString:void 0;e.exports=function e(t){if('string'==typeof t)return t;if(i(t))return a(t,e)+'';if(s(t))return c?c.call(t):'';var n=t+'';return'0'==n&&1/t==-1/0?'-0':n}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}},function(e,t,n){"use strict";var r=n(163),a=n(164);e.exports=function(e,t){return null!=e&&a(e,t,r)}},function(e,t,n){"use strict";e.exports=function(e,t){return null!=e&&t in Object(e)}},function(e,t,n){"use strict";var r=n(62),a=n(55),i=n(23),s=n(43),o=n(59),c=n(37);e.exports=function(e,t,n){for(var u=-1,l=(t=r(t,e)).length,p=!1;++u<l;){var d=c(t[u]);if(!(p=null!=e&&n(e,d)))break;e=e[d]}return p||++u!=l?p:!!(l=null==e?0:e.length)&&o(l)&&s(d,l)&&(i(e)||a(e))}},function(e,t,n){"use strict";var r=n(166),a=n(167),i=n(63),s=n(37);e.exports=function(e){return i(e)?r(s(e)):a(e)}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e){return function(t){return r(t,e)}}},function(e,t,n){"use strict";var r=n(169),a=n(43),i=Array.prototype.splice;e.exports=function(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;a(o)?i.call(e,o,1):r(e,o)}}return e}},function(e,t,n){"use strict";var r=n(62),a=n(170),i=n(171),s=n(37);e.exports=function(e,t){return t=r(t,e),null==(e=i(e,t))||delete e[s(a(t))]}},function(e,t,n){"use strict";e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t,n){"use strict";var r=n(61),a=n(172);e.exports=function(e,t){return t.length<2?e:r(e,a(t,0,-1))}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(a);++r<a;)i[r]=e[r+t];return i}},function(e,t,n){"use strict";var r=n(48),a=n(36),i=n(54);e.exports=function(e){return function(t,n,s){var o=Object(t);if(!a(t)){var c=r(n,3);t=i(t),n=function(e){return c(o[e],e,o)}}var u=e(t,n,s);return u>-1?o[c?t[u]:u]:void 0}}},function(e,t,n){"use strict";var r=n(80),a=n(48),i=n(175),s=Math.max;e.exports=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var c=null==n?0:i(n);return c<0&&(c=s(o+c,0)),r(e,a(t,3),c)}},function(e,t,n){"use strict";var r=n(176);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){"use strict";var r=n(177),a=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=r(e))===a||e===-1/0?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,n){"use strict";var r=n(26),a=n(44),i=NaN,s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(a(e))return i;if(r(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=r(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):o.test(e)?i:+e}},function(e,t,n){"use strict";var r=n(179)();e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t,n,r){for(var a=-1,i=Object(t),s=r(t),o=s.length;o--;){var c=s[e?o:++a];if(!1===n(i[c],c,i))break}return t}}},function(e,t,n){"use strict";var r=n(82),a=n(181),i=n(182),s=n(184),o=n(185),c=n(55),u=n(23),l=n(187),p=n(56),d=n(51),h=n(26),f=n(188),v=n(58),y=n(85),g=n(189);e.exports=function(e,t,n,m,b,w,k){var x=y(e,n),S=y(t,n),P=k.get(S);if(P)r(e,n,P);else{var O=w?w(x,S,n+'',e,t,k):void 0,C=void 0===O;if(C){var D=u(S),_=!D&&p(S),E=!D&&!_&&v(S);O=S,D||_||E?u(x)?O=x:l(x)?O=s(x):_?(C=!1,O=a(S,!0)):E?(C=!1,O=i(S,!0)):O=[]:f(S)||c(S)?(O=x,c(x)?O=g(x):h(x)&&!d(x)||(O=o(S))):C=!1}C&&(k.set(S,O),b(O,S,m,w,k),k.delete(S)),r(e,n,O)}}},function(e,t,n){"use strict";(function(e){var r=n(24),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(183);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},function(e,t,n){"use strict";var r=n(74);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t,n){"use strict";e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},function(e,t,n){"use strict";var r=n(186),a=n(84),i=n(60);e.exports=function(e){return'function'!=typeof e.constructor||i(e)?{}:r(a(e))}},function(e,t,n){"use strict";var r=n(26),a=Object.create,i=(function(){function e(){}return function(t){if(!r(t))return{};if(a)return a(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}})();e.exports=i},function(e,t,n){"use strict";var r=n(36),a=n(31);e.exports=function(e){return a(e)&&r(e)}},function(e,t,n){"use strict";var r=n(33),a=n(84),i=n(31),s='[object Object]',o=Function.prototype,c=Object.prototype,u=o.toString,l=c.hasOwnProperty,p=u.call(Object);e.exports=function(e){if(!i(e)||r(e)!=s)return!1;var t=a(e);if(null===t)return!0;var n=l.call(t,'constructor')&&t.constructor;return'function'==typeof n&&n instanceof n&&u.call(n)==p}},function(e,t,n){"use strict";var r=n(190),a=n(86);e.exports=function(e){return r(e,a(e))}},function(e,t,n){"use strict";var r=n(191),a=n(65);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var o=-1,c=t.length;++o<c;){var u=t[o],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?a(n,u,l):r(n,u,l)}return n}},function(e,t,n){"use strict";var r=n(65),a=n(35),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&a(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(26),a=n(60),i=n(193),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=a(e),n=[];for(var o in e)('constructor'!=o||!t&&s.call(e,o))&&n.push(o);return n}},function(e,t,n){"use strict";e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},function(e,t,n){"use strict";var r=n(64),a=n(195),i=n(197);e.exports=function(e,t){return i(a(e,t,r),e+'')}},function(e,t,n){"use strict";var r=n(196),a=Math.max;e.exports=function(e,t,n){return t=a(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=a(i.length-t,0),c=Array(o);++s<o;)c[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(c),r(e,this,u)}}},function(e,t,n){"use strict";e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){"use strict";var r=n(198),a=n(200)(r);e.exports=a},function(e,t,n){"use strict";var r=n(199),a=n(83),i=n(64),s=a?function(e,t){return a(e,'toString',{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},function(e,t,n){"use strict";e.exports=function(e){return function(){return e}}},function(e,t,n){"use strict";var r=800,a=16,i=Date.now;e.exports=function(e){var t=0,n=0;return function(){var s=i(),o=a-(s-n);if(n=s,o>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){"use strict";var r=n(35),a=n(36),i=n(43),s=n(26);e.exports=function(e,t,n){if(!s(n))return!1;var o=typeof t;return!!('number'==o?a(n)&&i(t,n.length):'string'==o&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";var r=n(203);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t,n){"use strict";var r=n(80),a=n(204),i=n(205);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,a,n)}},function(e,t,n){"use strict";e.exports=function(e){return e!=e}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=n-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=-1,a=null==e?0:e.length;++r<a;)if(n(t,e[r]))return!0;return!1}},function(e,t,n){"use strict";var r=n(77),a=n(208),i=n(53),s=r&&1/i(new r([,-0]))[1]==1/0?function(e){return new r(e)}:a;e.exports=s},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";(function(e,t){!(function(e,n){if(!e.setImmediate){var r,a,i,s,o,c=1,u={},l=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){v(e)})}:!(function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}})()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){v(e.data)},r=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(a=p.documentElement,r=function(e){var t=p.createElement("script");t.onreadystatechange=function(){v(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(v,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&v(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return u[c]=a,r(c),c++},d.clearImmediate=h}function h(e){delete u[e]}function f(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}function v(e){if(l)setTimeout(v,0,e);else{var t=u[e];if(t){l=!0;try{f(t)}finally{h(e),l=!1}}}}})("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(34),n(210))},function(e,t,n){"use strict";var r,a,i=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(a===clearTimeout)return clearTimeout(e);if((a===o||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{return a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}!(function(){try{r='function'==typeof setTimeout?setTimeout:s}catch(e){r=s}try{a='function'==typeof clearTimeout?clearTimeout:o}catch(e){a=o}})();var l,p=[],d=!1,h=-1;function f(){d&&l&&(d=!1,l.length?p=l.concat(p):h=-1,p.length&&v())}function v(){if(!d){var e=c(f);d=!0;for(var t=p.length;t;){for(l=p,p=[];++h<t;)l&&l[h].run();h=-1,t=p.length}l=null,d=!1,u(e)}}function y(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new y(e,t)),1!==p.length||d||c(v)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title='browser',i.browser=!0,i.env={},i.argv=[],i.version='',i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error('process.binding is not supported')},i.cwd=function(){return'/'},i.chdir=function(e){throw new Error('process.chdir is not supported')},i.umask=function(){return 0}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(212),t),a(n(213),t),a(n(218),t),a(n(219),t),a(n(220),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentType=void 0,(function(e){e.Any="*",e.Item="SF|Item",e.RootKey="SN|RootKey|NoSync",e.ItemsKey="SN|ItemsKey",e.EncryptedStorage="SN|EncryptedStorage",e.Privileges="SN|Privileges",e.Note="Note",e.Tag="Tag",e.SmartTag="SN|SmartTag",e.Component="SN|Component",e.Editor="SN|Editor",e.ActionsExtension="Extension",e.UserPrefs="SN|UserPreferences",e.HistorySession="SN|HistorySession",e.Theme="SN|Theme",e.ServerExtension="SF|Extension",e.FilesafeCredentials="SN|FileSafe|Credentials",e.FilesafeFileMetadata="SN|FileSafe|FileMetadata",e.FilesafeIntegration="SN|FileSafe|Integration",e.ExtensionRepo="SN|ExtensionRepo",e.Unknown="Unknown"})(t.ContentType||(t.ContentType={}))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.ContentDecoder=void 0;var n=(function(){function t(){v(this,t)}return y(t,[{key:"decode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;try{var r=n>0?t.substring(n):t,a=e.from(r,'base64').toString();return JSON.parse(a)}catch(e){return{}}}},{key:"encode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=JSON.stringify(t),a=e.from(r).toString('base64');return a.padStart(a.length+n,'0')}}]),t})();t.ContentDecoder=n}).call(this,n(214).Buffer)},function(e,t,n){"use strict";(function(e){var r=n(215),a=n(216),i=n(217);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return d(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?v(e,t,n,r):'string'==typeof t?h(e,t,n):y(e,t)}function l(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function p(e,t,n,r){return l(t),t<=0?o(e,t):void 0!==n?'string'==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function d(e,t){if(l(t),e=o(e,t<0?0:0|g(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t,n){if('string'==typeof n&&''!==n||(n='utf8'),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(t,n),a=(e=o(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}function f(e,t){var n=t.length<0?0:0|g(t.length);e=o(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function v(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(r||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t),e}function y(e,t){if(c.isBuffer(t)){var n=0|g(t.length);return 0===(e=o(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||(r=t.length)!=r?o(e,0):f(e,t);if('Buffer'===t.type&&i(t.data))return f(e,t.data)}var r;throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function g(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+' bytes');return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return G(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return $(e).length;default:if(r)return G(e).length;t=(''+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),n<=0)return'';if((n>>>=0)<=(t>>>=0))return'';for(e||(e='utf8');;)switch(e){case'hex':return T(this,t,n);case'utf8':case'utf-8':return R(this,t,n);case'ascii':return A(this,t,n);case'latin1':case'binary':return j(this,t,n);case'base64':return E(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return K(this,t,n);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,a){if(0===e.length)return-1;if('string'==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if('string'==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:x(e,t,n,r,a);if('number'==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):x(e,[t],n,r,a);throw new TypeError('val must be string, number or Buffer')}function x(e,t,n,r,a){var i,s=1,o=e.length,c=t.length;if(void 0!==r&&('ucs2'===(r=String(r).toLowerCase())||'ucs-2'===r||'utf16le'===r||'utf-16le'===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var l=-1;for(i=n;i<o;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>o&&(n=o-c),i=n;i>=0;i--){for(var p=!0,d=0;d<c;d++)if(u(e,i+d)!==u(t,d)){p=!1;break}if(p)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError('Invalid hex string');r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function P(e,t,n,r){return X(G(t,e.length-n),e,n,r)}function O(e,t,n,r){return X(Q(t),e,n,r)}function C(e,t,n,r){return O(e,t,n,r)}function D(e,t,n,r){return X($(t),e,n,r)}function _(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,c,u=e[a],l=null,p=u>239?4:u>223?3:u>191?2:1;if(a+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=p}return M(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:(function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}})(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return p(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('Arguments must be Buffers');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,a),a+=s.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var t=0;t<e;t+=2)w(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?'':0===arguments.length?R(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e='',n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString('hex',0,n).match(/.{2}/g).join(' '),this.length>n&&(e+=' ... ')),'<Buffer '+e+'>'},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError('out of range index');if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,s=n-t,o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),p=0;p<o;++p)if(u[p]!==l[p]){i=u[p],s=l[p];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r='utf8',n=this.length,t=0;else if(void 0===n&&'string'==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');t|=0,isFinite(n)?(n|=0,void 0===r&&(r='utf8')):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return S(this,e,t,n);case'utf8':case'utf-8':return P(this,e,t,n);case'ascii':return O(this,e,t,n);case'latin1':case'binary':return C(this,e,t,n);case'base64':return D(this,e,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return _(this,e,t,n);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var n='',r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function A(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function j(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function T(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a='',i=t;i<n;++i)a+=Y(e[i]);return a}function K(e,t,n){for(var r=e.slice(t,n),a='',i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function L(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError('Index out of range')}function U(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function V(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError('Index out of range');if(n<0)throw new RangeError('Index out of range')}function B(e,t,n,r,i){return i||V(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function W(e,t,n,r,i){return i||V(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var a=t-e;n=new c(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return W(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return W(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError('targetStart out of bounds');if(n<0||n>=this.length)throw new RangeError('sourceStart out of bounds');if(r<0)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if('string'==typeof e){if('string'==typeof t?(r=t,t=0,n=this.length):'string'==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!c.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError('Out of range index');if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),'number'==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:G(new c(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var H=/[^+\/0-9A-Za-z-_]/g;function z(e){if((e=q(e).replace(H,'')).length<2)return'';for(;e.length%4!=0;)e+='=';return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function Y(e){return e<16?'0'+e.toString(16):e.toString(16)}function G(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error('Invalid code point');if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function J(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}function $(e){return r.toByteArray(z(e))}function X(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(34))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],o=r[1],c=new i(l(e,s,o)),p=0,d=o>0?s-4:s;for(n=0;n<d;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=0,o=n-a;s<o;s+=16383)i.push(p(e,s,s+16383>o?o:s+16383));1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+'==')):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+'='));return i.join('')};for(var r=[],a=[],i='undefined'!=typeof Uint8Array?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',o=0,c=s.length;o<c;++o)r[o]=s[o],a[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){return 3*(t+n)/4-n}function p(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join('')}a['-'.charCodeAt(0)]=62,a['_'.charCodeAt(0)]=63},function(e,t,n){"use strict";t.read=function(e,t,n,r,a){var i,s,o=8*a-r-1,c=(1<<o)-1,u=c>>1,l=-7,p=n?a-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=o;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var s,o,c,u=8*i-a-1,l=(1<<u)-1,p=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(o=0,s=l):s+p>=1?(o=(t*c-1)*Math.pow(2,a),s+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+h]=255&o,h+=f,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*v}},function(e,t,n){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==r.call(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTag=void 0,(function(e){e.MfaInvalid="mfa-invalid",e.MfaRequired="mfa-required",e.RefreshTokenInvalid="invalid-refresh-token",e.RefreshTokenExpired="expired-refresh-token",e.AccessTokenExpired="expired-access-token",e.ParametersInvalid="invalid-parameters",e.RevokedSession="revoked-session",e.AuthInvalid="invalid-auth"})(t.ErrorTag||(t.ErrorTag={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(222),t),a(n(90),t),a(n(223),t),a(n(225),t),a(n(93),t),a(n(91),t),a(n(92),t),a(n(226),t),a(n(227),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Features=void 0;for(var a,i=n(19),s=n(91),o=n(92),c=n(93),u=n(90),l=[],p=function(e){var t=e.identifier,n=e.permission_name,r=e.content_type,a=e.area,l=e.flags,p=Object.values(c.PermissionName),d=Object.values(u.FeatureIdentifier),h=Object.values(i.ContentType),f=Object.values(s.ComponentArea),v=Object.values(o.ComponentFlag);if(!d.includes(t))throw Error("Invalid feature identifier ".concat(t));if(!p.includes(n))throw Error("Invalid permission name ".concat(n));if(r&&!h.includes(r))throw Error("Invalid feature content type ".concat(r));if(a&&!f.includes(a))throw Error("Invalid feature area ".concat(a));if(l&&l.some(function(e){return!v.includes(e)}))throw Error("Invalid feature flag ".concat(l))},d=S(r(n(224)).default);!(a=d()).done;){var h=a.value;p(h),l.push(h)}t.Features=l},function(e){e.exports=JSON.parse("[{\"name\":\"Midnight\",\"identifier\":\"org.standardnotes.theme-midnight\",\"permission_name\":\"theme:midnight\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Elegant utilitarianism.\",\"url\":\"#{url_prefix}/themes/midnight\",\"download_url\":\"https://github.com/standardnotes/midnight-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/midnight\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#086DD6\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#086DD6\"}},{\"name\":\"Futura\",\"identifier\":\"org.standardnotes.theme-futura\",\"permission_name\":\"theme:futura\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Calm and relaxed. Take some time off.\",\"url\":\"#{url_prefix}/themes/futura\",\"download_url\":\"https://github.com/standardnotes/futura-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/futura\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#fca429\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#fca429\"}},{\"name\":\"Solarized Dark\",\"identifier\":\"org.standardnotes.theme-solarized-dark\",\"permission_name\":\"theme:solarized-dark\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.3\",\"description\":\"The perfect theme for any time.\",\"url\":\"#{url_prefix}/themes/solarized-dark\",\"download_url\":\"https://github.com/standardnotes/solarized-dark-theme/archive/1.2.3.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/solarized-dark\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#2AA198\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#2AA198\"}},{\"name\":\"Autobiography\",\"identifier\":\"org.standardnotes.theme-autobiography\",\"permission_name\":\"theme:autobiography\",\"content_type\":\"SN|Theme\",\"version\":\"1.0.1\",\"description\":\"A theme for writers and readers.\",\"url\":\"#{url_prefix}/themes/autobiography\",\"download_url\":\"https://github.com/standardnotes/autobiography-theme/archive/1.0.1.zip\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg\",\"flags\":[\"New\"],\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#9D7441\",\"foreground_color\":\"#ECE4DB\",\"border_color\":\"#9D7441\"}},{\"name\":\"Focus\",\"identifier\":\"org.standardnotes.theme-focus\",\"permission_name\":\"theme:focused\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.5\",\"description\":\"For when you need to go in.\",\"url\":\"#{url_prefix}/themes/focus\",\"download_url\":\"https://github.com/standardnotes/focus-theme/archive/1.2.5.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/focused\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#a464c2\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#a464c2\"}},{\"identifier\":\"org.standardnotes.theme-titanium\",\"permission_name\":\"theme:titanium\",\"name\":\"Titanium\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Light on the eyes, heavy on the spirit.\",\"url\":\"#{url_prefix}/themes/titanium\",\"download_url\":\"https://github.com/standardnotes/titanium-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/titanium\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#6e2b9e\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#6e2b9e\"}},{\"identifier\":\"org.standardnotes.theme-dynamic\",\"name\":\"Dynamic\",\"permission_name\":\"theme:dynamic\",\"content_type\":\"SN|Theme\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.0.0\",\"description\":\"A smart theme that minimizes the tags and notes panels when they are not in use.\",\"url\":\"#{url_prefix}/themes/dynamic\",\"download_url\":\"https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/dynamic\"},{\"identifier\":\"org.standardnotes.theme-no-distraction\",\"name\":\"No Distraction\",\"content_type\":\"SN|Theme\",\"permission_name\":\"theme:no-distraction\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.2.2\",\"description\":\"A theme for focusing on your writing.\",\"url\":\"#{url_prefix}/themes/no-distraction\",\"download_url\":\"https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/no-distraction\",\"dock_icon\":{\"type\":\"svg\",\"source\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><path d=\\\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\\\"/></svg>\"}},{\"name\":\"Bold Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.bold-editor\",\"permission_name\":\"editor:bold\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.2.9\",\"description\":\"A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.\",\"url\":\"#{url_prefix}/components/bold-editor\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg\",\"download_url\":\"https://github.com/standardnotes/bold-editor/archive/1.2.9.zip\"},{\"name\":\"Plus Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.plus-editor\",\"permission_name\":\"editor:plus\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.5.0\",\"description\":\"From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.\",\"url\":\"#{url_prefix}/components/plus-editor\",\"download_url\":\"https://github.com/standardnotes/plus-editor/archive/1.5.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/plus-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg\"},{\"name\":\"Markdown Basic\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.simple-markdown-editor\",\"permission_name\":\"editor:markdown-basic\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A Markdown editor with dynamic split-pane preview.\",\"url\":\"#{url_prefix}/components/simple-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg\"},{\"name\":\"Markdown Pro\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.advanced-markdown-editor\",\"permission_name\":\"editor:markdown-pro\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.14\",\"description\":\"A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.\",\"url\":\"#{url_prefix}/components/advanced-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/advanced-markdown-editor/archive/1.3.14.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/advanced-markdown\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg\"},{\"name\":\"Markdown Minimist\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.minimal-markdown-editor\",\"permission_name\":\"editor:markdown-minimist\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F\",\"url\":\"#{url_prefix}/components/minimal-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/minimal-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg\"},{\"name\":\"Markdown Math\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.fancy-markdown-editor\",\"permission_name\":\"editor:markdown-math\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.4\",\"description\":\"A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.\",\"url\":\"#{url_prefix}/components/fancy-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/math-editor/archive/1.3.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/math-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg\"},{\"name\":\"Task Editor\",\"note_type\":\"task\",\"file_type\":\"md\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.simple-task-editor\",\"permission_name\":\"editor:task-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A great way to manage short-term and long-term to-do\\\"s. You can mark tasks as completed, change their order, and edit the text naturally in place.\",\"url\":\"#{url_prefix}/components/simple-task-editor\",\"download_url\":\"https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-task-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg\"},{\"name\":\"Code Editor\",\"note_type\":\"code\",\"file_type\":\"txt\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.code-editor\",\"permission_name\":\"editor:code-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.8\",\"description\":\"Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.\",\"url\":\"#{url_prefix}/components/code-editor\",\"download_url\":\"https://github.com/standardnotes/code-editor/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/code-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg\"},{\"name\":\"TokenVault\",\"note_type\":\"authentication\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.token-vault\",\"permission_name\":\"editor:token-vault\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"2.0.6\",\"description\":\"Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.\",\"url\":\"#{url_prefix}/components/token-vault\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/token-vault/archive/2.0.6.zip\",\"thumbnail_url\":\"https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png\",\"flags\":[\"New\"]},{\"name\":\"Secure Spreadsheets\",\"note_type\":\"spreadsheet\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.standard-sheets\",\"permission_name\":\"editor:sheets\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.\",\"url\":\"#{url_prefix}/components/standard-sheets\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/secure-spreadsheets/archive/1.4.0.zip\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png\"},{\"identifier\":\"org.standardnotes.file-safe\",\"name\":\"FileSafe\",\"permission_name\":\"component:filesafe\",\"content_type\":\"SN|Component\",\"area\":\"editor-stack\",\"version\":\"2.0.10\",\"description\":\"Encrypted attachments for your notes using your Dropbox, Google Drive, or WebDAV server. Limited to 50MB per file.\",\"url\":\"#{url_prefix}/components/filesafe\",\"download_url\":\"https://github.com/standardnotes/filesafe-client/archive/2.0.10.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/filesafe\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/FileSafe-banner.png\"},{\"identifier\":\"org.standardnotes.folders\",\"name\":\"Folders\",\"content_type\":\"SN|Component\",\"permission_name\":\"component:folders\",\"area\":\"tags-list\",\"version\":\"1.3.8\",\"description\":\"Create nested folders with easy drag and drop.\",\"url\":\"#{url_prefix}/components/folders\",\"download_url\":\"https://github.com/standardnotes/folders-component/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/folders\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/components/folders.jpg\"},{\"name\":\"2FA Manager\",\"identifier\":\"org.standardnotes.mfa-link\",\"permission_name\":\"component:2fa-manager\",\"content_type\":\"SN|Component\",\"description\":\"Configure two-factor authentication to add an extra level of security to your account.\",\"version\":\"1.2.4\",\"url\":\"#{url_prefix}/components/mfa-link\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/mfa-link/archive/1.2.4.zip\",\"area\":\"modal\",\"no_expire\":true,\"deletion_warning\":\"Deleting 2FA Manager will not disable 2FA from your account. To disable 2FA, first open 2FA Manager, then follow the prompts.\",\"deprecated\":true},{\"name\":\"\",\"identifier\":\"org.standardnotes.two-factor-auth\",\"permission_name\":\"server:two-factor-auth\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-unlimited\",\"permission_name\":\"server:note-history-unlimited\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-365\",\"permission_name\":\"server:note-history-365-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-30\",\"permission_name\":\"server:note-history-30-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-email-backup\",\"permission_name\":\"server:daily-email-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-dropbox-backup\",\"permission_name\":\"server:daily-dropbox-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-gdrive-backup\",\"permission_name\":\"server:daily-gdrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-onedrive-backup\",\"permission_name\":\"server:daily-onedrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-25-gb\",\"permission_name\":\"server:files-25-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-5-gb\",\"permission_name\":\"server:files-5-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Tag Nesting\",\"identifier\":\"org.standardnotes.tag-nesting\",\"permission_name\":\"app:tag-nesting\",\"description\":\"Create nested tags with easy drag and drop.\",\"version\":\"0.1.0\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files\",\"permission_name\":\"app:files\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"CloudLink\",\"identifier\":\"org.standardnotes.cloudlink\",\"permission_name\":\"component:cloud-link\",\"content_type\":\"SN|Component\",\"description\":\"Manage and install cloud backups, including Note History, Dropbox, Google Drive, OneDrive, and Daily Email Backups.\",\"version\":\"1.2.3\",\"url\":\"#{url_prefix}/components/cloudlink\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Listed Custom Domain\",\"identifier\":\"org.standardnotes.listed-custom-domain\",\"permission_name\":\"listed:custom-domain\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"Focus Mode\",\"identifier\":\"org.standardnotes.focus-mode\",\"permission_name\":\"app:focus-mode\"}]")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoteType=void 0,(function(e){e.Authentication="authentication",e.Code="code",e.Markdown="markdown",e.RichText="rich-text",e.Spreadsheet="spreadsheet",e.Task="task"})(t.NoteType||(t.NoteType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timingSafeEqual=void 0,t.timingSafeEqual=function(e,t){var n=String(e),r=String(t),a=n.length,i=0;a!==r.length&&(r=n,i=1);for(var s=0;s<a;s++)i|=n.charCodeAt(s)^r.charCodeAt(s);return 0===i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(232),t),a(n(233),t),a(n(234),t),a(n(235),t),a(n(236),t),a(n(237),t),a(n(238),t),a(n(239),t),a(n(240),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoleName=void 0,(function(e){e.BasicUser="BASIC_USER",e.CoreUser="CORE_USER",e.PlusUser="PLUS_USER",e.ProUser="PRO_USER"})(t.RoleName||(t.RoleName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionName=void 0,(function(e){e.CorePlan="CORE_PLAN",e.PlusPlan="PLUS_PLAN",e.ProPlan="PRO_PLAN"})(t.SubscriptionName||(t.SubscriptionName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(242),t),a(n(243),t),a(n(244),t),a(n(245),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmailBackupFrequency=void 0,(function(e){e.Daily="daily",e.Weekly="weekly"})(t.EmailBackupFrequency||(t.EmailBackupFrequency={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedBackupsEmailsOption||(t.MuteFailedBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedCloudBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedCloudBackupsEmailsOption||(t.MuteFailedCloudBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingName=void 0,(function(e){e.MfaSecret="MFA_SECRET",e.ExtensionKey="EXTENSION_KEY",e.EmailBackup="EMAIL_BACKUP",e.MuteFailedBackupsEmails="MUTE_FAILED_BACKUPS_EMAILS",e.MuteFailedCloudBackupsEmails="MUTE_FAILED_CLOUD_BACKUPS_EMAILS"})(t.SettingName||(t.SettingName={}))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"SnjsVersion",function(){return h}),n.d(t,"isRightVersionGreaterThanLeft",function(){return x}),n.d(t,"compareSemVersions",function(){return P}),n.d(t,"SNApplicationGroup",function(){return M}),n.d(t,"DeinitSource",function(){return C}),n.d(t,"KeyParamsOrigination",function(){return A.g}),n.d(t,"KeyRecoveryStrings",function(){return j.H}),n.d(t,"SessionStrings",function(){return j.R}),n.d(t,"SNApplication",function(){return ca}),n.d(t,"SNProtocolService",function(){return Gn}),n.d(t,"KeyMode",function(){return Bn}),n.d(t,"SNProtocolOperator001",function(){return An}),n.d(t,"SNProtocolOperator002",function(){return Fn}),n.d(t,"SNProtocolOperator003",function(){return Ln}),n.d(t,"SNProtocolOperator004",function(){return Wn}),n.d(t,"SNRootKey",function(){return Ve}),n.d(t,"SNRootKeyParams",function(){return A.h}),n.d(t,"DeviceInterface",function(){return ua}),n.d(t,"SNItem",function(){return T.d}),n.d(t,"ItemMutator",function(){return T.b}),n.d(t,"AppDataField",function(){return T.a}),n.d(t,"SNItemsKey",function(){return J}),n.d(t,"SNPredicate",function(){return H.a}),n.d(t,"SNNote",function(){return le}),n.d(t,"NoteMutator",function(){return pe}),n.d(t,"SNTag",function(){return oe}),n.d(t,"TagMutator",function(){return ce}),n.d(t,"SNSmartTag",function(){return et}),n.d(t,"SNActionsExtension",function(){return ie}),n.d(t,"ActionsExtensionMutator",function(){return se}),n.d(t,"Action",function(){return ae}),n.d(t,"SNTheme",function(){return B}),n.d(t,"ThemeMutator",function(){return W}),n.d(t,"SNComponent",function(){return N}),n.d(t,"ComponentAction",function(){return E}),n.d(t,"ComponentMutator",function(){return V}),n.d(t,"SNEditor",function(){return Ze}),n.d(t,"SNUserPrefs",function(){return z}),n.d(t,"UserPrefsMutator",function(){return G}),n.d(t,"PrefKey",function(){return U}),n.d(t,"MutationType",function(){return T.c}),n.d(t,"ComponentArea",function(){return L.ComponentArea}),n.d(t,"LiveItem",function(){return la}),n.d(t,"FeatureStatus",function(){return ur}),n.d(t,"SNComponentManager",function(){return an}),n.d(t,"HistoryEntry",function(){return Qn}),n.d(t,"PayloadManager",function(){return sn}),n.d(t,"ItemManager",function(){return _r}),n.d(t,"SNHttpService",function(){return jt}),n.d(t,"ChallengeService",function(){return na}),n.d(t,"PureService",function(){return R.a}),n.d(t,"ApplicationService",function(){return pa.a}),n.d(t,"SNStorageService",function(){return Ie}),n.d(t,"StoragePersistencePolicies",function(){return Oe}),n.d(t,"StorageEncryptionPolicies",function(){return Ce}),n.d(t,"StorageValueModes",function(){return De}),n.d(t,"ValueModesKeys",function(){return _e}),n.d(t,"Challenge",function(){return ye}),n.d(t,"ChallengeReason",function(){return ne}),n.d(t,"ChallengeResponse",function(){return be}),n.d(t,"ChallengeValidation",function(){return te}),n.d(t,"ChallengeValue",function(){return me}),n.d(t,"ChallengePrompt",function(){return ge}),n.d(t,"SNSyncService",function(){return ea}),n.d(t,"SyncSources",function(){return $r}),n.d(t,"SyncModes",function(){return Jr}),n.d(t,"SyncQueueStrategy",function(){return Qr}),n.d(t,"SNCredentialService",function(){return Qe}),n.d(t,"SyncResponse",function(){return Br}),n.d(t,"SyncResponseResolver",function(){return Vr}),n.d(t,"SyncOpStatus",function(){return fr}),n.d(t,"SortPayloadsByRecentAndContentPriority",function(){return Mr}),n.d(t,"SyncUpDownLimit",function(){return Wr}),n.d(t,"SNSessionManager",function(){return Ge}),n.d(t,"SessionEvent",function(){return ze}),n.d(t,"SNMigrationService",function(){return En}),n.d(t,"ButtonType",function(){return St}),n.d(t,"SNHistoryManager",function(){return nr}),n.d(t,"SNProtectionService",function(){return ir}),n.d(t,"SNSingletonManager",function(){return cn}),n.d(t,"SNApiService",function(){return Yt}),n.d(t,"addIfUnique",function(){return _.b}),n.d(t,"arrayByDifference",function(){return _.c}),n.d(t,"Copy",function(){return _.a}),n.d(t,"dateSorted",function(){return _.j}),n.d(t,"deepMerge",function(){return _.m}),n.d(t,"dictToArray",function(){return _.n}),n.d(t,"extendArray",function(){return _.o}),n.d(t,"filterFromArray",function(){return _.p}),n.d(t,"findInArray",function(){return _.q}),n.d(t,"getGlobalScope",function(){return _.r}),n.d(t,"greaterOfTwoDates",function(){return _.s}),n.d(t,"isNullOrUndefined",function(){return _.w}),n.d(t,"isSameDay",function(){return _.z}),n.d(t,"jsonParseEmbeddedKeys",function(){return _.E}),n.d(t,"naturalSort",function(){return _.G}),n.d(t,"omitInPlace",function(){return _.J}),n.d(t,"omitUndefinedCopy",function(){return _.K}),n.d(t,"removeFromArray",function(){return _.M}),n.d(t,"removeFromIndex",function(){return _.N}),n.d(t,"subtractFromArray",function(){return _.R}),n.d(t,"topLevelCompare",function(){return _.S}),n.d(t,"truncateHexString",function(){return _.T}),n.d(t,"uniqueArrayByKey",function(){return _.W}),n.d(t,"uniqCombineObjArrays",function(){return _.U}),n.d(t,"convertTimestampToMilliseconds",function(){return _.i}),n.d(t,"arraysEqual",function(){return _.e}),n.d(t,"isValidUrl",function(){return _.B}),n.d(t,"dateToLocalizedString",function(){return _.k}),n.d(t,"Uuid",function(){return I}),n.d(t,"EncryptionIntent",function(){return Re.b}),n.d(t,"isLocalStorageIntent",function(){return Re.f}),n.d(t,"isFileIntent",function(){return Re.e}),n.d(t,"isDecryptedIntent",function(){return Re.d}),n.d(t,"intentRequiresEncryption",function(){return Re.c}),n.d(t,"ContentTypeUsesRootKeyEncryption",function(){return Re.a}),n.d(t,"ContentType",function(){return F.a}),n.d(t,"displayStringForContentType",function(){return F.c}),n.d(t,"CreateItemFromPayload",function(){return nt}),n.d(t,"Uuids",function(){return Ke.b}),n.d(t,"FillItemContent",function(){return Ke.a}),n.d(t,"ApplicationEvent",function(){return At.a}),n.d(t,"Environment",function(){return he}),n.d(t,"Platform",function(){return fe}),n.d(t,"isEnvironmentWebOrDesktop",function(){return Se}),n.d(t,"isEnvironmentMobile",function(){return Pe}),n.d(t,"platformFromString",function(){return ke}),n.d(t,"environmentFromString",function(){return xe}),n.d(t,"SyncEvent",function(){return on.a}),n.d(t,"MutableCollection",function(){return mt}),n.d(t,"ImmutablePayloadCollection",function(){return bt}),n.d(t,"ItemCollection",function(){return gn}),n.d(t,"CollectionSort",function(){return dn}),n.d(t,"CreateMaxPayloadFromAnyObject",function(){return Ee.e}),n.d(t,"CreateSourcedPayloadFromObject",function(){return Ee.f}),n.d(t,"CreateIntentPayloadFromObject",function(){return Ee.d}),n.d(t,"CreateEncryptionParameters",function(){return Ee.c}),n.d(t,"PayloadByMerging",function(){return Ee.g}),n.d(t,"CopyPayload",function(){return Ee.b}),n.d(t,"PayloadSource",function(){return ht.a}),n.d(t,"isPayloadSourceRetrieved",function(){return ht.c}),n.d(t,"isPayloadSourceInternalChange",function(){return ht.b}),n.d(t,"DeltaOutOfSync",function(){return _t}),n.d(t,"ProtocolVersion",function(){return Q.a}),n.d(t,"PayloadFormat",function(){return ue.a}),n.d(t,"PurePayload",function(){return ft.a}),n.d(t,"PayloadField",function(){return Je.a}),n.d(t,"NotesDisplayCriteria",function(){return br}),n.d(t,"notesMatchingCriteria",function(){return wr}),n.d(t,"StorageKey",function(){return o}),n.d(t,"RawStorageKey",function(){return s}),n.d(t,"NonwrappedStorageKey",function(){return c}),n.d(t,"namespacedKey",function(){return O}),n.d(t,"BaseMigration",function(){return _n}),n.d(t,"ProtectionSessionDurations",function(){return ar}),n.d(t,"SNLog",function(){return we.a}),n.d(t,"Features",function(){return L.Features}),n.d(t,"FeatureIdentifier",function(){return L.FeatureIdentifier}),n.d(t,"RoleName",function(){return sr.RoleName}),n.d(t,"SettingName",function(){return pr.SettingName}),n.d(t,"Migration2_20_0",function(){return Pn}),n.d(t,"ApplicationStage",function(){return ve});var a={};n.r(a),n.d(a,"Migration2_0_0",function(){return kn}),n.d(a,"Migration2_0_15",function(){return xn}),n.d(a,"Migration2_7_0",function(){return Sn}),n.d(a,"Migration2_20_0",function(){return Pn});var i={};n.r(i),n.d(i,"StorageReader2_0_0",function(){return On}),n.d(i,"StorageReader1_0_0",function(){return vn});var s,o,c,h="2.20.3";function x(e,t){return-1===P(e,t)}function P(e,t){for(var n=e.split('.'),r=t.split('.'),a=0;a<r.length;a++){var i=Number(~~r[a]),s=Number(~~n[a]);if(i>s)return-1;if(i<s)return 1}return 0}function O(e,t){return e?"".concat(e,"-").concat(t):t}!(function(e){e.StorageObject="storage",e.DescriptorRecord="descriptors",e.SnjsVersion="snjs_version"})(s||(s={})),(function(e){e.RootKeyParams="ROOT_KEY_PARAMS",e.WrappedRootKey="WRAPPED_ROOT_KEY",e.RootKeyWrapperKeyParams="ROOT_KEY_WRAPPER_KEY_PARAMS",e.Session="session",e.User="user",e.ServerHost="server",e.LegacyUuid="uuid",e.LastSyncToken="syncToken",e.PaginationToken="cursorToken",e.BiometricsState="biometrics_state",e.MobilePasscodeTiming="passcode_timing",e.MobileBiometricsTiming="biometrics_timing",e.MobilePasscodeKeyboardType="passcodeKeyboardType",e.MobilePreferences="preferences",e.MobileScreenshotPrivacyEnabled="screenshotPrivacy_enabled",e.ProtectionExpirey="SessionExpiresAtKey",e.ProtectionSessionLength="SessionLengthKey",e.SessionHistoryPersistable="sessionHistory_persist",e.SessionHistoryRevisions="sessionHistory_revisions",e.SessionHistoryOptimize="sessionHistory_autoOptimize",e.KeyRecoveryUndecryptableItems="key_recovery_undecryptable",e.StorageEncryptionPolicy="storage_policy",e.WebSocketUrl="webSocket_url",e.UserRoles="user_roles",e.UserFeatures="user_features"})(o||(o={})),(function(e){e.MobileFirstRun="first_run"})(c||(c={}));var C,D={WebPasscodeParamsKey:'offlineParams',MobilePasscodeParamsKey:'pc_params',AllAccountKeyParamsKey:'auth_params',WebEncryptedStorageKey:'encryptedStorage',MobileWrappedRootKeyKey:'encrypted_account_keys',MobileBiometricsPrefs:'biometrics_prefs',AllMigrations:'migrations',MobileThemesCache:'ThemePreferencesKey',MobileLightTheme:'lightTheme',MobileDarkTheme:'darkTheme',MobileLastExportDate:'LastExportDateKey',MobileDoNotWarnUnsupportedEditors:'DoNotShowAgainUnsupportedEditorsKey',MobileOptionsState:'options',MobilePasscodeKeyboardType:'passcodeKeyboardType'},_=n(0);!(function(e){e[e.SignOut=1]="SignOut",e[e.Lock=2]="Lock",e[e.AppGroupUnload=3]="AppGroupUnload"})(C||(C={}));var E,R=n(10),I=(function(){function e(){v(this,e)}return y(e,null,[{key:"SetGenerators",value:function(e,t){this.syncUuidFunc=t,this.asyncUuidFunc=e}},{key:"canGenSync",value:function(){return!Object(_.w)(this.syncUuidFunc)}},{key:"GenerateUuid",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.syncUuidFunc){e.next=4;break}return e.abrupt("return",this.syncUuidFunc());case 4:return e.abrupt("return",this.asyncUuidFunc());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"GenerateUuidSynchronously",value:function(){return this.syncUuidFunc()}}]),e})(),M=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).deviceInterface=e,r.changeObservers=[],r.applications=[],r.onApplicationDeinit=function(e,t){var n=t!==C.AppGroupUnload;if(r.primaryApplication===e&&(r.primaryApplication=void 0),Object(_.M)(r.applications,e),t===C.SignOut){if(r.removeDescriptor(r.descriptorForApplication(e)),n){var a=r.getDescriptors();return 0===a.length?r.addNewApplication():r.loadApplicationForDescriptor(a[0])}}else if(t===C.Lock&&n){var i=r.descriptorForApplication(e);return r.loadApplicationForDescriptor(i)}},r}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.deviceInterface.deinit(),this.deviceInterface=void 0}},{key:"initialize",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.callback=e,r.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(s.DescriptorRecord));case 3:if(this.descriptorRecord=r.sent,this.descriptorRecord){r.next=7;break}return r.next=7,b.awrap(this.createDescriptorRecord());case 7:if(t=this.findPrimaryDescriptor()){r.next=10;break}throw Error('No primary application descriptor found. Ensure migrations have been run.');case 10:n=this.buildApplication(t),this.applications.push(n),this.setPrimaryApplication(n,!1);case 13:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createDescriptorRecord",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:t=g({},e='standardnotes',{identifier:e,label:'Main Application',primary:!0}),this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(t)),this.descriptorRecord=t,this.persistDescriptors();case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getApplications",value:function(){return this.applications}},{key:"getDescriptors",value:function(){return Object.values(this.descriptorRecord)}},{key:"findPrimaryDescriptor",value:function(){for(var e,t=S(this.getDescriptors());!(e=t()).done;){var n=e.value;if(n.primary)return n}}},{key:"addApplicationChangeObserver",value:function(e){var t=this;return this.changeObservers.push(e),this.primaryApplication&&e(),function(){Object(_.M)(t.changeObservers,e)}}},{key:"notifyObserversOfAppChange",value:function(){for(var e,t=S(this.changeObservers);!(e=t()).done;){(0,e.value)()}}},{key:"setPrimaryApplication",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=!(r.length>1&&void 0!==r[1])||r[1],this.primaryApplication!==e){a.next=3;break}return a.abrupt("return");case 3:if(this.applications.includes(e)){a.next=5;break}throw Error('Application must be inserted before attempting to switch to it');case 5:if(this.primaryApplication&&this.primaryApplication.deinit(C.AppGroupUnload),this.primaryApplication=e,n=this.descriptorForApplication(e),this.setDescriptorAsPrimary(n),this.notifyObserversOfAppChange(),!t){a.next=13;break}return a.next=13,b.awrap(this.persistDescriptors());case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setDescriptorAsPrimary",value:function(e){for(var t,n=S(this.getDescriptors());!(t=n()).done;){var r=t.value;r.primary=r===e}}},{key:"persistDescriptors",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(this.descriptorRecord));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"renameDescriptor",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e.label=t,n.next=3,b.awrap(this.persistDescriptors());case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"removeDescriptor",value:function(e){return delete this.descriptorRecord[e.identifier],this.persistDescriptors()}},{key:"descriptorForApplication",value:function(e){return this.descriptorRecord[e.identifier]}},{key:"addNewApplication",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(I.GenerateUuid());case 2:return t=i.sent,n=this.getDescriptors().length+1,r={identifier:t,label:e||"Application ".concat(n),primary:!1},a=this.buildApplication(r),this.applications.push(a),this.descriptorRecord[t]=r,i.next=10,b.awrap(this.setPrimaryApplication(a));case 10:return i.next=12,b.awrap(this.persistDescriptors());case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"applicationForDescriptor",value:function(e){return this.applications.find(function(t){return t.identifier===e.identifier})}},{key:"loadApplicationForDescriptor",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=this.applicationForDescriptor(e))||(t=this.buildApplication(e),this.applications.push(t)),n.next=4,b.awrap(this.setPrimaryApplication(t));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"buildApplication",value:function(e){var t=this.callback.applicationCreator(e,this.deviceInterface);return t.setOnDeinit(this.onApplicationDeinit),t}}]),n})(R.a),A=n(13),j=n(2),T=n(7),K=n(18),F=n(3),L=n(20);!(function(e){e.SetSize="set-size",e.StreamItems="stream-items",e.StreamContextItem="stream-context-item",e.SaveItems="save-items",e.SelectItem="select-item",e.AssociateItem="associate-item",e.DeassociateItem="deassociate-item",e.ClearSelection="clear-selection",e.CreateItem="create-item",e.CreateItems="create-items",e.DeleteItems="delete-items",e.SetComponentData="set-component-data",e.InstallLocalComponent="install-local-component",e.ToggleActivateComponent="toggle-activate-component",e.RequestPermissions="request-permissions",e.PresentConflictResolution="present-conflict-resolution",e.DuplicateItem="duplicate-item",e.ComponentRegistered="component-registered",e.ActivateThemes="themes",e.Reply="reply",e.SaveSuccess="save-success",e.SaveError="save-error",e.ThemesActivated="themes-activated",e.KeyDown="key-down",e.KeyUp="key-up",e.Click="click"})(E||(E={}));var U,N=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).permissions=[],r.componentData=r.payload.safeContent.componentData||{},Object(_.B)(r.payload.safeContent.hosted_url)?r.hosted_url=r.payload.safeContent.hosted_url:Object(_.B)(r.payload.safeContent.url)?r.hosted_url=r.payload.safeContent.url:Object(_.B)(r.payload.safeContent.legacy_url)&&(r.hosted_url=r.payload.safeContent.legacy_url),r.local_url=r.payload.safeContent.local_url,r.valid_until=new Date(r.payload.safeContent.valid_until||0),r.offlineOnly=r.payload.safeContent.offlineOnly,r.name=r.payload.safeContent.name,r.area=r.payload.safeContent.area,r.package_info=r.payload.safeContent.package_info||{},r.permissions=r.payload.safeContent.permissions||[],r.active=r.payload.safeContent.active,r.autoupdateDisabled=r.payload.safeContent.autoupdateDisabled,r.disassociatedItemIds=r.payload.safeContent.disassociatedItemIds||[],r.associatedItemIds=r.payload.safeContent.associatedItemIds||[],r.isMobileDefault=r.payload.safeContent.isMobileDefault,r.legacy_url=r.payload.safeContent.hosted_url?void 0:r.payload.safeContent.url,r}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"isEditor",value:function(){return this.area===L.ComponentArea.Editor}},{key:"isTheme",value:function(){return this.content_type===F.a.Theme||this.area===L.ComponentArea.Themes}},{key:"isDefaultEditor",value:function(){return!0===this.getAppDomainValue(T.a.DefaultEditor)}},{key:"getLastSize",value:function(){return this.getAppDomainValue(T.a.LastSize)}},{key:"acceptsThemes",value:function(){var e;return null===(e=this.payload.safeContent.package_info)||void 0===e?void 0:e.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return void 0!=(this.hosted_url||this.legacy_url)}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['active','disassociatedItemIds','associatedItemIds'].concat(p(f(n.prototype),"contentKeysToIgnoreWhenCheckingEquality",this).call(this))}},{key:"isAssociative",value:function(){return n.associativeAreas().includes(this.area)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e)}},{key:"isExpired",get:function(){return this.valid_until.getTime()>0&&this.valid_until<=new Date}},{key:"identifier",get:function(){return this.package_info.identifier}},{key:"isDeprecated",get:function(){var e,t=null!==(e=this.package_info.flags)&&void 0!==e?e:[];return(t=t.map(function(e){return e.toLowerCase()})).includes(L.ComponentFlag.Deprecated)}}],[{key:"associativeAreas",value:function(){return[L.ComponentArea.Editor]}}]),n})(T.d),V=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"associateWithItem",value:function(e){var t=this.typedContent.associatedItemIds||[];Object(_.b)(t,e),this.typedContent.associatedItemIds=t}},{key:"disassociateWithItem",value:function(e){var t=this.typedContent.disassociatedItemIds||[];Object(_.b)(t,e),this.typedContent.disassociatedItemIds=t}},{key:"removeAssociatedItemId",value:function(e){Object(_.M)(this.typedContent.associatedItemIds||[],e)}},{key:"removeDisassociatedItemId",value:function(e){Object(_.M)(this.typedContent.disassociatedItemIds||[],e)}},{key:"setLastSize",value:function(e){this.setAppDataItem(T.a.LastSize,e)}},{key:"typedContent",get:function(){return this.content}},{key:"active",set:function(e){this.typedContent.active=e}},{key:"isMobileDefault",set:function(e){this.typedContent.isMobileDefault=e}},{key:"defaultEditor",set:function(e){this.setAppDataItem(T.a.DefaultEditor,e)}},{key:"componentData",set:function(e){this.typedContent.componentData=e}},{key:"package_info",set:function(e){this.typedContent.package_info=e}},{key:"local_url",set:function(e){this.typedContent.local_url=e}},{key:"hosted_url",set:function(e){this.typedContent.hosted_url=e}},{key:"valid_until",set:function(e){this.typedContent.valid_until=e}},{key:"permissions",set:function(e){this.typedContent.permissions=e}}]),n})(T.b),B=(function(e){d(n,N);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).area=L.ComponentArea.Themes,e}return y(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"getMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDomainValue(T.a.NotAvailableOnMobile)}},{key:"isMobileActive",value:function(){return this.getAppDomainValue(T.a.MobileActive)}}]),n})(),W=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setMobileRules",value:function(e){this.setAppDataItem(T.a.MobileRules,e)}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem(T.a.NotAvailableOnMobile,e)}},{key:"setMobileActive",value:function(e){this.setAppDataItem(T.a.MobileActive,e)}},{key:"local_url",set:function(e){this.content.local_url=e}}]),n})(T.b),H=n(21);!(function(e){e.TagsPanelWidth="tagsPanelWidth",e.NotesPanelWidth="notesPanelWidth",e.EditorWidth="editorWidth",e.EditorLeft="editorLeft",e.EditorMonospaceEnabled="monospaceFont",e.EditorSpellcheck="spellcheck",e.EditorResizersEnabled="marginResizersEnabled",e.SortNotesBy="sortBy",e.SortNotesReverse="sortReverse",e.NotesShowArchived="showArchived",e.NotesShowTrashed="showTrashed",e.NotesHideProtected="hideProtected",e.NotesHidePinned="hidePinned",e.NotesHideNotePreview="hideNotePreview",e.NotesHideDate="hideDate",e.NotesHideTags="hideTags"})(U||(U={}));var z=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getPref",value:function(e){return this.getAppDomainValue(e)}},{key:"isSingleton",get:function(){return!0}},{key:"singletonPredicate",get:function(){return n.singletonPredicate}}]),n})(T.d);z.singletonPredicate=new H.a('content_type','=',F.a.UserPrefs);var q,Y,G=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setPref",value:function(e,t){this.setAppDataItem(e,t)}}]),n})(T.b),Q=n(6),J=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"keyVersion",get:function(){return this.payload.safeContent.version}},{key:"isItemsKey",get:function(){return!0}},{key:"isDefault",get:function(){return this.payload.safeContent.isDefault}},{key:"itemsKey",get:function(){return this.payload.safeContent.itemsKey}},{key:"dataAuthenticationKey",get:function(){if(this.keyVersion===Q.a.V004)throw'Attempting to access legacy data authentication key.';return this.payload.safeContent.dataAuthenticationKey}}]),n})(T.d),$=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"isDefault",set:function(e){this.content.isDefault=e}}]),n})(T.b),X=n(47),Z=n.n(X);!(function(e){e.Encrypted="encrypted",e.Decrypted="decrypted"})(q||(q={})),(function(e){e.Get="get",e.Render="render",e.Show="show",e.Post="post",e.Nested="nested"})(Y||(Y={}));var ee=Number.MIN_SAFE_INTEGER;var te,ne,re,ae=function e(t){var n,r,a;v(this,e),this.id=((ee+=1)===Number.MAX_SAFE_INTEGER&&(ee=Number.MIN_SAFE_INTEGER),ee),Z()(this,t),this.running=null!==(n=t.running)&&void 0!==n&&n,this.error=null!==(r=t.error)&&void 0!==r&&r,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted)),this.subactions=null===(a=t.subactions)||void 0===a?void 0:a.map(function(t){return new e(t)})},ie=(function(e){d(n,N);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).actions=[],r.description=e.safeContent.description,r.url=e.safeContent.hosted_url||e.safeContent.url,r.supported_types=e.safeContent.supported_types,r.deprecation=e.safeContent.deprecation,e.safeContent.actions&&(r.actions=e.safeContent.actions.map(function(e){return new ae(e)})),r}return y(n,[{key:"actionsWithContextForItem",value:function(e){return this.actions.filter(function(t){return t.context===e.content_type||'Item'===t.context})}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}}]),n})(),se=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"description",set:function(e){this.content.description=e}},{key:"supported_types",set:function(e){this.content.supported_types=e}},{key:"actions",set:function(e){this.content.actions=e}},{key:"deprecation",set:function(e){this.content.deprecation=e}}]),n})(T.b),oe=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).title=r.payload.safeContent.title,r}return y(n,[{key:"noteReferences",get:function(){return this.payload.safeReferences.filter(function(e){return e.content_type===F.a.Note})}},{key:"noteCount",get:function(){return this.noteReferences.length}},{key:"isSmartTag",get:function(){return this.content_type===F.a.SmartTag}},{key:"isSystemSmartTag",get:function(){return this.payload.safeContent.isSystemTag}},{key:"isAllTag",get:function(){return this.payload.safeContent.isAllTag}},{key:"isTrashTag",get:function(){return this.payload.safeContent.isTrashTag}},{key:"isArchiveTag",get:function(){return this.payload.safeContent.isArchiveTag}},{key:"parentId",get:function(){var e=this.payload.safeContent.references.find(function(e){return e.content_type===F.a.Tag});return null===e||void 0===e?void 0:e.uuid}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title?1:-1}).map(function(e){return'#'+e.title}).join(' ')}}]),n})(T.d),ce=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"makeChildOf",value:function(e){var t=this.typedContent.references.filter(function(e){return e.content_type!==F.a.Tag});t.push({content_type:F.a.Tag,uuid:e.uuid}),this.typedContent.references=t}},{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}}]),n})(T.b),ue=n(12),le=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).text='',r.hidePreview=!1,r.title=r.payload.safeContent.title,r.text=r.payload.safeContent.text,r.preview_plain=r.payload.safeContent.preview_plain,r.preview_html=r.payload.safeContent.preview_html,r.hidePreview=r.payload.safeContent.hidePreview,e.format===ue.a.DecryptedBareObject&&(r.prefersPlainEditor=r.getAppDomainValue(T.a.PrefersPlainEditor)),Object(_.w)(r.payload.safeContent.mobilePrefersPlainEditor)||(r.mobilePrefersPlainEditor=r.payload.safeContent.mobilePrefersPlainEditor),r}return y(n,[{key:"safeText",value:function(){return this.text||''}},{key:"safeTitle",value:function(){return this.title||''}}]),n})(T.d),pe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}},{key:"text",set:function(e){this.typedContent.text=e}},{key:"hidePreview",set:function(e){this.typedContent.hidePreview=e}},{key:"preview_plain",set:function(e){this.typedContent.preview_plain=e}},{key:"preview_html",set:function(e){this.typedContent.preview_html=e}},{key:"prefersPlainEditor",set:function(e){this.setAppDataItem(T.a.PrefersPlainEditor,e)}}]),n})(T.b);function de(e,t){switch(e.content_type){case F.a.Note:return new pe(e,t);case F.a.Tag:return new ce(e,t);case F.a.Component:return new V(e,t);case F.a.ActionsExtension:return new se(e,t);case F.a.ItemsKey:return new $(e,t);case F.a.UserPrefs:return new G(e,t);case F.a.Theme:return new W(e,t);default:return new T.b(e,t)}}!(function(e){e[e.None=0]="None",e[e.LocalPasscode=1]="LocalPasscode",e[e.AccountPassword=2]="AccountPassword",e[e.Biometric=3]="Biometric",e[e.ProtectionSessionDuration=4]="ProtectionSessionDuration"})(te||(te={})),(function(e){e[e.ApplicationUnlock=1]="ApplicationUnlock",e[e.ResaveRootKey=2]="ResaveRootKey",e[e.ProtocolUpgrade=3]="ProtocolUpgrade",e[e.Migration=4]="Migration",e[e.Custom=5]="Custom",e[e.AccessProtectedNote=6]="AccessProtectedNote",e[e.ImportFile=7]="ImportFile",e[e.AddPasscode=8]="AddPasscode",e[e.RemovePasscode=9]="RemovePasscode",e[e.ChangePasscode=10]="ChangePasscode",e[e.ChangeAutolockInterval=11]="ChangeAutolockInterval",e[e.CreateDecryptedBackupWithProtectedItems=12]="CreateDecryptedBackupWithProtectedItems",e[e.RevokeSession=13]="RevokeSession",e[e.AccessCloudLink=14]="AccessCloudLink",e[e.DecryptEncryptedFile=15]="DecryptEncryptedFile",e[e.ExportBackup=16]="ExportBackup",e[e.DisableBiometrics=17]="DisableBiometrics",e[e.UnprotectNote=18]="UnprotectNote",e[e.SearchProtectedNotesText=19]="SearchProtectedNotesText",e[e.SelectProtectedNote=20]="SelectProtectedNote",e[e.DisableMfa=21]="DisableMfa"})(ne||(ne={})),(function(e){e.Alphanumeric="default",e.Numeric="numeric"})(re||(re={}));var he,fe,ve,ye=(function(){function e(t,n,r,a,i){v(this,e),this.prompts=t,this.reason=n,this.cancelable=r,this._heading=a,this._subheading=i,this.id=Math.random(),Object.freeze(this)}return y(e,[{key:"hasPromptForValidationType",value:function(e){for(var t,n=S(this.prompts);!(t=n()).done;){if(t.value.validation===e)return!0}return!1}},{key:"modalTitle",get:function(){switch(this.reason){case ne.Migration:return j.w.Migration;default:return j.w.Generic}}},{key:"heading",get:function(){if(this._heading)return this._heading;switch(this.reason){case ne.ApplicationUnlock:return j.x.UnlockApplication;case ne.Migration:return j.x.EnterLocalPasscode;case ne.ResaveRootKey:return j.x.EnterPasscodeForRootResave;case ne.ProtocolUpgrade:return j.x.EnterCredentialsForProtocolUpgrade;case ne.AccessProtectedNote:return j.x.NoteAccess;case ne.ImportFile:return j.x.ImportFile;case ne.AddPasscode:return j.x.AddPasscode;case ne.RemovePasscode:return j.x.RemovePasscode;case ne.ChangePasscode:return j.x.ChangePasscode;case ne.ChangeAutolockInterval:return j.x.ChangeAutolockInterval;case ne.CreateDecryptedBackupWithProtectedItems:return j.x.EnterCredentialsForDecryptedBackupDownload;case ne.RevokeSession:return j.x.RevokeSession;case ne.AccessCloudLink:return j.x.AccessCloudLink;case ne.DecryptEncryptedFile:return j.x.DecryptEncryptedFile;case ne.ExportBackup:return j.x.ExportBackup;case ne.DisableBiometrics:return j.x.DisableBiometrics;case ne.UnprotectNote:return j.x.UnprotectNote;case ne.SearchProtectedNotesText:return j.x.SearchProtectedNotesText;case ne.SelectProtectedNote:return j.x.SelectProtectedNote;case ne.DisableMfa:return j.x.DisableMfa;case ne.Custom:return'';default:return Object(_.f)(this.reason)}}},{key:"subheading",get:function(){if(this._subheading)return this._subheading;switch(this.reason){case ne.Migration:return j.x.EnterPasscodeForMigration;default:return}}}]),e})(),ge=function e(t,n,r){v(this,e);var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;switch(this.validation=t,this.secureTextEntry=a,this.keyboardType=i,this.initialValue=s,this.id=Math.random(),this.validation){case te.AccountPassword:this.title=null!==n&&void 0!==n?n:j.M.AccountPassword,this.placeholder=null!==r&&void 0!==r?r:j.M.AccountPassword,this.validates=!0;break;case te.LocalPasscode:this.title=null!==n&&void 0!==n?n:j.M.LocalPasscode,this.placeholder=null!==r&&void 0!==r?r:j.M.LocalPasscode,this.validates=!0;break;case te.Biometric:this.title=null!==n&&void 0!==n?n:j.M.Biometrics,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.ProtectionSessionDuration:this.title=null!==n&&void 0!==n?n:j.M.RememberFor,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.None:this.title=null!==n&&void 0!==n?n:'',this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!1;break;default:Object(_.f)(this.validation)}Object.freeze(this)},me=function e(t,n){v(this,e),this.prompt=t,this.value=n,Object.freeze(this)},be=(function(){function e(t,n,r){v(this,e),this.challenge=t,this.values=n,this.artifacts=r,Object.freeze(this)}return y(e,[{key:"getValueForType",value:function(e){var t=this.values.find(function(t){return t.prompt.validation===e});if(Object(_.w)(t))throw Error('Could not find value for validation type '+e);return t}},{key:"getDefaultValue",value:function(){if(this.values.length>1)throw Error('Attempting to retrieve default response value when more than one value exists');return this.values[0]}}]),e})(),we=n(16);function ke(e){return{'mac-web':fe.MacWeb,'mac-desktop':fe.MacDesktop,'linux-web':fe.LinuxWeb,'linux-desktop':fe.LinuxDesktop,'windows-web':fe.WindowsWeb,'windows-desktop':fe.WindowsDesktop,ios:fe.Ios,android:fe.Android}[e]}function xe(e){return{web:he.Web,desktop:he.Desktop,mobile:he.Mobile}[e]}function Se(e){return e===he.Web||e===he.Desktop}function Pe(e){return e===he.Mobile}!(function(e){e[e.Web=1]="Web",e[e.Desktop=2]="Desktop",e[e.Mobile=3]="Mobile"})(he||(he={})),(function(e){e[e.Ios=1]="Ios",e[e.Android=2]="Android",e[e.MacWeb=3]="MacWeb",e[e.MacDesktop=4]="MacDesktop",e[e.WindowsWeb=5]="WindowsWeb",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.LinuxWeb=7]="LinuxWeb",e[e.LinuxDesktop=8]="LinuxDesktop"})(fe||(fe={})),(function(e){e[e.PreparingForLaunch_0=0]="PreparingForLaunch_0",e[e.ReadyForLaunch_05=.5]="ReadyForLaunch_05",e[e.StorageDecrypted_09=.9]="StorageDecrypted_09",e[e.Launched_10=1]="Launched_10",e[e.LoadingDatabase_11=1.1]="LoadingDatabase_11",e[e.LoadedDatabase_12=1.2]="LoadedDatabase_12",e[e.FullSyncCompleted_13=1.3]="FullSyncCompleted_13",e[e.SignedIn_30=3]="SignedIn_30"})(ve||(ve={}));var Oe,Ce,De,_e,Ee=n(1),Re=n(8);!(function(e){e[e.Default=1]="Default",e[e.Ephemeral=2]="Ephemeral"})(Oe||(Oe={})),(function(e){e[e.Default=1]="Default",e[e.Disabled=2]="Disabled"})(Ce||(Ce={})),(function(e){e[e.Default=1]="Default",e[e.Nonwrapped=2]="Nonwrapped"})(De||(De={})),(function(e){e.Wrapped="wrapped",e.Unwrapped="unwrapped",e.Nonwrapped="nonwrapped"})(_e||(_e={}));var Ie=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).alertService=r,s.identifier=a,s.environment=i,s.storagePersistable=!1,s.needsPersist=!1,s.deviceInterface=e,s.setPersistencePolicy(Oe.Default),s.setEncryptionPolicy(Ce.Default,!1),s}return y(n,[{key:"deinit",value:function(){this.deviceInterface=void 0,this.encryptionDelegate=void 0,this.storagePersistable=!1,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:if(e!==ve.Launched_10){r.next=7;break}this.storagePersistable=!0,this.needsPersist&&this.persistValuesToDisk(),r.next=12;break;case 7:if(e!==ve.StorageDecrypted_09){r.next=12;break}return r.next=10,b.awrap(this.getValue(o.StorageEncryptionPolicy));case 10:(t=r.sent)&&this.setEncryptionPolicy(t,!1);case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setPersistencePolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.persistencePolicy=e,this.persistencePolicy!==Oe.Ephemeral){t.next=6;break}return t.next=4,b.awrap(this.deviceInterface.removeAllRawStorageValues());case 4:return t.next=6,b.awrap(this.clearAllPayloads());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setEncryptionPolicy",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],e!==Ce.Disabled||this.environment===he.Mobile){r.next=3;break}throw Error('Disabling storage encryption is only available on mobile.');case 3:if(this.encryptionPolicy=e,!t){r.next=7;break}return r.next=7,b.awrap(this.setValue(o.StorageEncryptionPolicy,e));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.persistencePolicy===Oe.Ephemeral}},{key:"initializeFromDisk",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getRawStorageValue(this.getPersistenceKey()));case 2:e=n.sent,t=e?JSON.parse(e):void 0,this.setInitialValues(t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){e||(e=this.defaultValuesObject()),e[_e.Unwrapped]||(e[_e.Unwrapped]={}),this.values=e}},{key:"isStorageWrapped",value:function(){var e=this.values[_e.Wrapped];return!Object(_.w)(e)&&Object.keys(e).length>0}},{key:"canDecryptWithKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.values[_e.Wrapped],r.next=3,b.awrap(this.decryptWrappedValue(t,e));case 3:return n=r.sent,r.abrupt("return",!n.errorDecrypting);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"decryptWrappedValue",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!==e&&void 0!==e&&e.content_type){a.next=2;break}throw Error('Attempting to decrypt nonexistent wrapped value');case 2:return n=Object(Ee.e)(e,{content_type:F.a.EncryptedStorage}),a.next=5,b.awrap(this.encryptionDelegate.payloadByDecryptingPayload(n,t));case 5:return r=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptStorage",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.values[_e.Wrapped],n.next=3,b.awrap(this.decryptWrappedValue(e));case 3:if(!(t=n.sent).errorDecrypting){n.next=6;break}throw we.a.error(Error('Unable to decrypt storage.'));case 6:this.values[_e.Unwrapped]=Object(_.a)(t.contentObject);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistValuesToDisk",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.storagePersistable){t.next=3;break}return this.needsPersist=!0,t.abrupt("return");case 3:if(this.persistencePolicy!==Oe.Ephemeral){t.next=5;break}return t.abrupt("return");case 5:return this.needsPersist=!1,t.next=8,b.awrap(this.immediatelyPersistValuesToDisk());case 8:e=t.sent,this.values[_e.Wrapped]=e[_e.Wrapped];case 10:case"end":return t.stop()}},null,this,null,Promise)}},{key:"immediatelyPersistValuesToDisk",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(e.generatePersistableValues());case 2:return n=r.sent,r.next=5,b.awrap(null===(t=e.deviceInterface)||void 0===t?void 0:t.setRawStorageValue(e.getPersistenceKey(),JSON.stringify(n)));case 5:return r.abrupt("return",n);case 6:case"end":return r.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generatePersistableValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=w({},this.values),n=t[_e.Unwrapped],i.t0=Object(Ee.e),i.next=5,b.awrap(I.GenerateUuid());case 5:return i.t1=i.sent,i.t2=n,i.t3=F.a.EncryptedStorage,i.t4={uuid:i.t1,content:i.t2,content_type:i.t3},r=(0,i.t0)(i.t4),i.next=12,b.awrap(null===(e=this.encryptionDelegate)||void 0===e?void 0:e.payloadByEncryptingPayload(r,Re.b.LocalStoragePreferEncrypted));case 12:return(a=i.sent)&&(t[_e.Wrapped]=a.ejected(),t[_e.Unwrapped]=void 0),i.abrupt("return",t);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=r.length>2&&void 0!==r[2]?r[2]:De.Default,this.values){a.next=3;break}throw Error("Attempting to set storage key ".concat(e," before loading local storage."));case 3:return this.values[this.domainKeyForMode(n)][e]=t,a.abrupt("return",this.persistValuesToDisk());case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De.Default,n=arguments.length>2?arguments[2]:void 0;if(!this.values)throw Error("Attempting to get storage key ".concat(e," before loading local storage."));if(!this.values[this.domainKeyForMode(t)])throw Error("Storage domain mode not available ".concat(t," for key ").concat(e));var r=this.values[this.domainKeyForMode(t)][e];return Object(_.w)(r)?n:r}},{key:"removeValue",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:De.Default,this.values){a.next=3;break}throw Error("Attempting to remove storage key ".concat(e," before loading local storage."));case 3:if(null===(n=this.values[this.domainKeyForMode(t)])||void 0===n||!n[e]){a.next=7;break}return delete n[e],a.abrupt("return",this.persistValuesToDisk());case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.encryptionPolicy}},{key:"getPersistenceKey",value:function(){return O(this.identifier,s.StorageObject)}},{key:"defaultValuesObject",value:function(e,t,r){return n.defaultValuesObject(e,t,r)}},{key:"domainKeyForMode",value:function(e){if(e===De.Default)return _e.Unwrapped;if(e===De.Nonwrapped)return _e.Nonwrapped;throw Error('Invalid mode')}},{key:"clearValues",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,b.awrap(this.immediatelyPersistValuesToDisk());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAllRawPayloads",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads(this.identifier));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"savePayload",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.savePayloads([e]));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"savePayloads",value:function(e){var t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.persistencePolicy!==Oe.Ephemeral){o.next=2;break}return o.abrupt("return");case 2:t=[],n=S(e);case 4:if((r=n()).done){o.next=19;break}if(!(a=r.value).discardable){o.next=11;break}return o.next=9,b.awrap(this.deletePayloadWithId(a.uuid));case 9:o.next=17;break;case 11:if(a.uuid){o.next=13;break}throw Error('Attempting to persist payload with no uuid');case 13:return o.next=15,b.awrap(this.encryptionDelegate.payloadByEncryptingPayload(a,this.encryptionPolicy===Ce.Default?Re.b.LocalStoragePreferEncrypted:Re.b.LocalStorageDecrypted));case 15:i=o.sent,t.push(i.ejected());case 17:o.next=4;break;case 19:return o.abrupt("return",this.executeCriticalFunction(function(){var e;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null===(e=s.deviceInterface)||void 0===e?void 0:e.saveRawDatabasePayloads(t,s.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 20:case"end":return o.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(e);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(this.deletePayloadWithId(r.uuid));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deletePayloadWithId",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.deviceInterface.removeRawDatabasePayloadWithId(e,t.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"clearAllPayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.deviceInterface.removeAllRawDatabasePayloads(e.identifier));case 1:case"end":return t.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"clearAllData",value:function(){var e=this;return this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.clearValues());case 2:return t.next=4,b.awrap(e.clearAllPayloads());case 4:return t.next=6,b.awrap(e.deviceInterface.removeRawStorageValue(O(e.identifier,s.SnjsVersion)));case 6:return t.next=8,b.awrap(e.deviceInterface.removeRawStorageValue(e.getPersistenceKey()));case 8:case"end":return t.stop()}},null,null,null,Promise)})}}],[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return g(e={},_e.Wrapped,t),g(e,_e.Unwrapped,n),g(e,_e.Nonwrapped,r),e}}]),n})(R.a),Me=(function(){function e(){v(this,e)}return y(e,null,[{key:"FromRawStorageValue",value:function(e){if(e.jwt)return new Ae(e.jwt);var t=e;return new je(t.accessToken,t.accessExpiration,t.refreshToken,t.refreshExpiration)}}]),e})(),Ae=(function(e){d(n,Me);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).jwt=e,r}return y(n,[{key:"canExpire",value:function(){return!1}},{key:"authorizationValue",get:function(){return this.jwt}}]),n})(),je=(function(e){d(n,Me);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).accessToken=e,s.accessExpiration=r,s.refreshToken=a,s.refreshExpiration=i,s}return y(n,[{key:"getExpireAt",value:function(){return this.accessExpiration||0}},{key:"canExpire",value:function(){return!0}},{key:"isExpired",value:function(){return this.getExpireAt()<Date.now()}},{key:"authorizationValue",get:function(){return this.accessToken}}],[{key:"FromApiResponse",value:function(e){var t=e.data.session.access_token,r=e.data.session.refresh_token;return new n(t,e.data.session.access_expiration,r,e.data.session.refresh_expiration)}}]),n})(),Te=n(15),Ke=n(11),Fe=n(67);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this,e)).keyParams=r,a}return y(n,[{key:"compare",value:function(e){if(this.keyVersion!==e.keyVersion)return!1;var t=!(!this.serverPassword||!e.serverPassword);return Object(Fe.timingSafeEqual)(this.masterKey,e.masterKey)&&(!t||Object(Fe.timingSafeEqual)(this.serverPassword,e.serverPassword))}},{key:"persistableValueWhenWrapping",value:function(){var e=this.getKeychainValue();return e.keyParams=this.keyParams.getPortableValue(),e}},{key:"getKeychainValue",value:function(){var e={version:this.keyVersion};return this.masterKey&&(e.masterKey=this.masterKey),this.dataAuthenticationKey&&(e.dataAuthenticationKey=this.dataAuthenticationKey),e}},{key:"typedContent",get:function(){return this.safeContent}},{key:"keyVersion",get:function(){if(!this.payload.safeContent.version)throw'Attempting to create key without version.';return this.payload.safeContent.version}},{key:"isRootKey",get:function(){return!0}},{key:"itemsKey",get:function(){return this.masterKey}},{key:"masterKey",get:function(){return this.payload.safeContent.masterKey}},{key:"serverPassword",get:function(){return this.payload.safeContent.serverPassword}},{key:"dataAuthenticationKey",get:function(){return this.payload.safeContent.dataAuthenticationKey}}],[{key:"Create",value:function(e,t){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t){s.next=4;break}return s.next=3,b.awrap(I.GenerateUuid());case 3:t=s.sent;case 4:if(e.version||(e.dataAuthenticationKey?e.version=Q.a.V002:e.version=Q.a.V001),r=Object(Ee.e)({uuid:t,content_type:F.a.RootKey,content:Object(Ke.a)(e)}),a=e.keyParams){s.next=9;break}throw Error('Attempting to create root key without key params');case 9:return i=a instanceof A.h?a:new A.h(a),s.abrupt("return",new n(r,i));case 11:case"end":return s.stop()}},null,null,null,Promise)}},{key:"ExpandedCopy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=e.typedContent,a.next=3,b.awrap(this.Create(Ue(Ue({},n),{},{keyParams:t||n.keyParams})));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(T.d);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){He(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ze,qe=function(e){return e.trim().toLowerCase()};!(function(e){e.Restored="SessionRestored",e.Revoked="SessionRevoked"})(ze||(ze={}));var Ye,Ge=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).storageService=e,c.apiService=r,c.alertService=a,c.protocolService=i,c.challengeService=s,c.webSocketsService=o,c.isSessionRenewChallengePresented=!1,r.setInvalidSessionObserver(function(e){e?c.notifyEvent(ze.Revoked):c.reauthenticateInvalidSession()}),c}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.alertService=void 0,this.challengeService=void 0,this.webSocketsService=void 0,this.user=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.storageService.getValue(o.User));case 2:if(this.user=r.sent,this.user){r.next=8;break}return r.next=6,b.awrap(this.storageService.getValue(o.LegacyUuid));case 6:(e=r.sent)&&(this.user={uuid:e,email:e});case 8:return r.next=10,b.awrap(this.storageService.getValue(o.Session));case 10:if(!(t=r.sent)){r.next=16;break}return n=Me.FromRawStorageValue(t),r.next=15,b.awrap(this.setSession(n,!1));case 15:this.webSocketsService.startWebSocketConnection(n.authorizationValue);case 16:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=!(n.length>1&&void 0!==n[1])||n[1],r.next=3,b.awrap(this.apiService.setSession(e,t));case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"online",value:function(){return!this.offline()}},{key:"offline",value:function(){return Object(_.w)(this.apiService.getSession())}},{key:"getUser",value:function(){return this.user}},{key:"getSession",value:function(){return this.apiService.getSession()}},{key:"signOut",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.user=void 0,!(e=this.apiService.getSession())||!e.canExpire()){t.next=6;break}return t.next=5,b.awrap(this.apiService.signOut());case 5:this.webSocketsService.closeWebSocketConnection();case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isSignedIn",value:function(){return void 0!=this.getUser()}},{key:"isSignedIntoFirstPartyServer",value:function(){return this.isSignedIn()&&!this.apiService.isThirdPartyHostUsed()}},{key:"reauthenticateInvalidSession",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=!(i.length>0&&void 0!==i[0])||i[0],n=i.length>1?i[1]:void 0,!this.isSessionRenewChallengePresented){s.next=4;break}return s.abrupt("return");case 4:return this.isSessionRenewChallengePresented=!0,r=new ye([new ge(te.None,void 0,j.R.EmailInputPlaceholder,!1),new ge(te.None,void 0,j.R.PasswordInputPlaceholder)],ne.Custom,t,j.R.EnterEmailAndPassword,j.R.RecoverSession(null===(e=this.getUser())||void 0===e?void 0:e.email)),s.abrupt("return",new Promise(function(e){a.challengeService.addChallengeObserver(r,{onCancel:function(){a.isSessionRenewChallengePresented=!1},onComplete:function(){a.isSessionRenewChallengePresented=!1},onNonvalidatedSubmit:function(t){var i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=t.values[0].value,s=t.values[1].value,u.next=4,b.awrap(a.protocolService.getAccountKeyParams());case 4:return o=u.sent,u.next=7,b.awrap(a.signIn(i,s,!1,a.storageService.isEphemeralSession(),null===o||void 0===o?void 0:o.version));case 7:(c=u.sent).response.error?(a.challengeService.setValidationStatusForChallenge(r,t.values[1],!1),null===n||void 0===n||n(c.response)):(e(),a.challengeService.completeChallenge(r),a.notifyEvent(ze.Restored),a.alertService.alert(j.R.SessionRestored));case 9:case"end":return u.stop()}},null,null,null,Promise)}}),a.challengeService.promptForChallengeResponse(r)}));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSubscription",value:function(){return this.apiService.getSubscription(this.user.uuid)}},{key:"promptForMfaValue",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=new ye([new ge(te.None,j.M.Mfa,j.R.MfaInputPlaceholder,!1,re.Numeric)],ne.Custom,!0,j.R.EnterMfa),n.next=3,b.awrap(this.challengeService.promptForChallengeResponse(e));case 3:if(!(t=n.sent)){n.next=7;break}return this.challengeService.completeChallenge(e),n.abrupt("return",t.values[0].value);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"register",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(t.length<8)){u.next=2;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.G(8))});case 2:return u.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(r=u.sent,a=r.wrappingKey,!r.canceled){u.next=9;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.P.PasscodeRequired,Te.b.LocalValidationError)});case 9:return e=qe(e),u.next=12,b.awrap(this.protocolService.createRootKey(e,t,A.g.Registration));case 12:return i=u.sent,s=i.serverPassword,o=i.keyParams,u.next=17,b.awrap(this.apiService.register(e,s,o,n));case 17:if((c=u.sent).error||!c.data){u.next=21;break}return u.next=21,b.awrap(this.handleSuccessAuthResponse(c,i,a));case 21:return u.abrupt("return",{response:c,rootKey:i});case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"retrieveKeyParams",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.apiService.getAccountKeyParams(e,t,n));case 2:if(!(r=c.sent).error&&!Object(_.w)(r.data)){c.next=17;break}if(!n){c.next=7;break}return c.next=7,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 7:if(null===(a=r.error)||void 0===a||null===(i=a.payload)||void 0===i||!i.mfa_key){c.next=16;break}return c.next=10,b.awrap(this.promptForMfaValue());case 10:if(s=c.sent){c.next=13;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa)});case 13:return c.abrupt("return",this.retrieveKeyParams(e,r.error.payload.mfa_key,s));case 16:return c.abrupt("return",{response:r});case 17:if((o=Object(A.f)(r,e))&&o.version){c.next=20;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 20:return c.abrupt("return",{keyParams:o,response:r,mfaKeyPath:t,mfaCode:n});case 21:case"end":return c.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=o.length>2&&void 0!==o[2]&&o[2],r=o.length>3&&void 0!==o[3]&&o[3],a=o.length>4?o[4]:void 0,c.next=5,b.awrap(this.performSignIn(e,t,n,r,a));case 5:if(!(i=c.sent).response.error||i.response.error.status===Te.b.LocalValidationError||i.response.error.status===Te.b.CanceledMfa){c.next=15;break}if((s=qe(e))===e){c.next=12;break}return c.abrupt("return",this.performSignIn(s,t,n,r,a));case 12:return c.abrupt("return",i);case 13:c.next=16;break;case 15:return c.abrupt("return",i);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"performSignIn",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=arguments;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return n=p.length>2&&void 0!==p[2]&&p[2],r=p.length>3&&void 0!==p[3]&&p[3],a=p.length>4?p[4]:void 0,d.next=5,b.awrap(this.retrieveKeyParams(e));case 5:if(!(i=d.sent).response.error){d.next=8;break}return d.abrupt("return",{response:i.response});case 8:if(s=i.keyParams,this.protocolService.supportedVersions().includes(s.version)){d.next=15;break}if(!this.protocolService.isVersionNewerThanLibraryVersion(s.version)){d.next=14;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.X)});case 14:return d.abrupt("return",{response:this.apiService.createErrorResponse(j.A)});case 15:if(!this.protocolService.isProtocolVersionOutdated(s.version)){d.next=25;break}if(o=this.protocolService.costMinimumForVersion(s.version),!(s.content002.pw_cost<o)){d.next=19;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.E)});case 19:return c=j.L,d.next=22,b.awrap(this.alertService.confirm(c,j.K,j.J));case 22:if(d.sent){d.next=25;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 25:if(this.protocolService.platformSupportsKeyDerivation(s)){d.next=27;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.W)});case 27:if(n&&(a=this.protocolService.getLatestVersion()),Object(_.w)(a)){d.next=31;break}if(Object(Q.d)(s.version,a)){d.next=31;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.T(s.version,a))});case 31:return d.next=33,b.awrap(this.protocolService.computeRootKey(t,s));case 33:return u=d.sent,d.next=36,b.awrap(this.bypassChecksAndSignInWithRootKey(e,u,i.mfaKeyPath,i.mfaCode,r));case 36:return l=d.sent,d.abrupt("return",{response:l});case 38:case"end":return d.stop()}},null,this,null,Promise)}},{key:"bypassChecksAndSignInWithRootKey",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return a=d.length>4&&void 0!==d[4]&&d[4],h.next=3,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 3:if(i=h.sent,s=i.wrappingKey,!i.canceled){h.next=8;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.PasscodeRequired,Te.b.LocalValidationError));case 8:return h.next=10,b.awrap(this.apiService.signIn(e,t.serverPassword,n,r,a));case 10:if((o=h.sent).error||!o.data){h.next=20;break}return h.next=14,b.awrap(Ve.ExpandedCopy(t,o.data.key_params));case 14:return c=h.sent,h.next=17,b.awrap(this.handleSuccessAuthResponse(o,c,s));case 17:return h.abrupt("return",o);case 20:if(null===(u=o.error)||void 0===u||null===(l=u.payload)||void 0===l||!l.mfa_key){h.next=32;break}if(!r){h.next=24;break}return h.next=24,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 24:return h.next=26,b.awrap(this.promptForMfaValue());case 26:if(p=h.sent){h.next=29;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa));case 29:return h.abrupt("return",this.bypassChecksAndSignInWithRootKey(e,t,o.error.payload.mfa_key,p));case 32:return h.abrupt("return",o);case 33:case"end":return h.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.user.uuid,r.next=3,b.awrap(this.apiService.changeCredentials({userUuid:t,currentServerPassword:e.currentServerPassword,newServerPassword:e.newRootKey.serverPassword,newKeyParams:e.newRootKey.keyParams,newEmail:e.newEmail}));case 3:return n=r.sent,r.abrupt("return",this.processChangeCredentialsResponse(n,e.newRootKey,e.wrappingKey));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getSessionsList());case 2:if(!(e=t.sent).error&&!Object(_.w)(e.data)){t.next=5;break}return t.abrupt("return",e);case 5:return e.data=e.data.map(function(e){return We(We({},e),{},{updated_at:new Date(e.updated_at)})}).sort(function(e,t){return e.updated_at<t.updated_at?1:-1}),t.abrupt("return",e);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeSession",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.deleteSession(e));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.getSessionsList());case 2:if(void 0==(e=s.sent).error&&void 0!=e.data){s.next=5;break}throw new Error(null!==(t=null===(n=e.error)||void 0===n?void 0:n.message)&&void 0!==t?t:j.m);case 5:return r=e.data,a=r.filter(function(e){return!e.current}),s.next=9,b.awrap(Promise.all(a.map(function(e){return i.revokeSession(e.uuid)})));case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"processChangeCredentialsResponse",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.error||!e.data){a.next=3;break}return a.next=3,b.awrap(this.handleSuccessAuthResponse(e,t,n));case 3:return a.abrupt("return",{response:e,keyParams:null===(r=e.data)||void 0===r?void 0:r.key_params});case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleSuccessAuthResponse",value:function(e,t,n){var r,a,i,s;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.protocolService.setRootKey(t,n));case 2:return r=e.data,a=r.user,this.user=a,c.next=7,b.awrap(this.storageService.setValue(o.User,a));case 7:if(this.apiService.setHost(this.apiService.getHost()),!r.token){c.next=15;break}return i=new Ae(r.token),c.next=12,b.awrap(this.setSession(i));case 12:this.webSocketsService.startWebSocketConnection(i.authorizationValue),c.next=20;break;case 15:if(!r.session){c.next=20;break}return s=je.FromApiResponse(e),c.next=19,b.awrap(this.setSession(s));case 19:this.webSocketsService.startWebSocketConnection(s.authorizationValue);case 20:case"end":return c.stop()}},null,this,null,Promise)}}]),n})(R.a);!(function(e){e.SignedInOrRegistered="SignedInOrRegistered"})(Ye||(Ye={}));var Qe=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).sessionManager=e,l.syncService=r,l.storageService=a,l.itemManager=i,l.protocolService=s,l.alertService=o,l.challengeService=c,l.protectionService=u,l.signingIn=!1,l.registering=!1,l}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.sessionManager=void 0,this.syncService=void 0,this.storageService=void 0,this.itemManager=void 0,this.protocolService=void 0,this.alertService=void 0,this.challengeService=void 0,this.protectionService=void 0}},{key:"register",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=!(i.length>3&&void 0!==i[3])||i[3],!this.protocolService.hasAccount()){s.next=4;break}throw Error('Tried to register when an account already exists.');case 4:if(!this.registering){s.next=6;break}throw Error('Already registering.');case 6:return this.registering=!0,s.prev=7,this.lockSyncing(),s.next=11,b.awrap(this.sessionManager.register(e,t,n));case 11:if((a=s.sent).response.error){s.next=32;break}return this.syncService.resetSyncState(),s.next=16,b.awrap(this.storageService.setPersistencePolicy(n?Oe.Ephemeral:Oe.Default));case 16:if(!r){s.next=21;break}return s.next=19,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 19:s.next=24;break;case 21:return this.itemManager.removeAllItemsFromMemory(),s.next=24,b.awrap(this.clearDatabase());case 24:return s.next=26,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 26:return this.unlockSyncing(),s.next=29,b.awrap(this.syncService.downloadFirstSync(300));case 29:this.protocolService.decryptErroredItems(),s.next=33;break;case 32:this.unlockSyncing();case 33:return s.abrupt("return",a.response);case 34:return s.prev=34,this.registering=!1,s.finish(34);case 37:case"end":return s.stop()}},null,this,[[7,,34,37]],Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o,c=this,u=arguments;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],r=u.length>3&&void 0!==u[3]&&u[3],a=!(u.length>4&&void 0!==u[4])||u[4],i=u.length>5&&void 0!==u[5]&&u[5],!this.protocolService.hasAccount()){l.next=6;break}throw Error('Tried to sign in when an account already exists.');case 6:if(!this.signingIn){l.next=8;break}throw Error('Already signing in.');case 8:return this.signingIn=!0,l.prev=9,this.lockSyncing(),l.next=13,b.awrap(this.sessionManager.signIn(e,t,n,r));case 13:if((s=l.sent).response.error){l.next=37;break}return this.syncService.resetSyncState(),l.next=18,b.awrap(this.storageService.setPersistencePolicy(r?Oe.Ephemeral:Oe.Default));case 18:if(!a){l.next=23;break}return l.next=21,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 21:l.next=26;break;case 23:return this.itemManager.removeAllItemsFromMemory(),l.next=26,b.awrap(this.clearDatabase());case 26:return l.next=28,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 28:if(this.unlockSyncing(),o=this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0,awaitAll:i}).then(function(){i||c.protocolService.decryptErroredItems()}),!i){l.next=35;break}return l.next=33,b.awrap(o);case 33:return l.next=35,b.awrap(this.protocolService.decryptErroredItems());case 35:l.next=38;break;case 37:this.unlockSyncing();case 38:return l.abrupt("return",s.response);case 39:return l.prev=39,this.signingIn=!1,l.finish(39);case 42:case"end":return l.stop()}},null,this,[[9,,39,42]],Promise)}},{key:"correctiveSignIn",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.lockSyncing(),n.next=3,b.awrap(this.sessionManager.bypassChecksAndSignInWithRootKey(e.keyParams.identifier,e));case 3:if((t=n.sent).error){n.next=10;break}return n.next=7,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 7:this.unlockSyncing(),this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0}),this.protocolService.decryptErroredItems();case 10:return this.unlockSyncing(),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.performCredentialsChange(e));case 2:return(t=n.sent).error&&this.alertService.alert(t.error.message),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.sessionManager.signOut());case 2:return e.next=4,b.awrap(this.protocolService.clearLocalKeyState());case 4:return e.next=6,b.awrap(this.storageService.clearAllData());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performProtocolUpgrade",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return e=this.protocolService.hasPasscode(),t=this.protocolService.hasAccount(),n=[],e&&n.push(new ge(te.LocalPasscode,void 0,j.x.LocalPasscodePlaceholder)),t&&n.push(new ge(te.AccountPassword,void 0,j.x.AccountPasswordPlaceholder)),r=new ye(n,ne.ProtocolUpgrade,!0),p.next=8,b.awrap(this.challengeService.promptForChallengeResponse(r));case 8:if(a=p.sent){p.next=11;break}return p.abrupt("return",{canceled:!0});case 11:return p.next=13,b.awrap(this.alertService.blockingDialog(j.z,j.Y));case 13:if(i=p.sent,p.prev=14,e&&(o=a.getValueForType(te.LocalPasscode),s=o.value),!t){p.next=24;break}return c=a.getValueForType(te.AccountPassword),u=c.value,p.next=21,b.awrap(this.changeCredentials({currentPassword:u,newPassword:u,passcode:s,origination:A.g.ProtocolUpgrade,validateNewPasswordStrength:!1}));case 21:if(null===(l=p.sent)||void 0===l||!l.error){p.next=24;break}return p.abrupt("return",{error:l.error});case 24:if(!e){p.next=29;break}return p.next=27,b.awrap(this.removePasscodeWithoutWarning());case 27:return p.next=29,b.awrap(this.setPasscodeWithoutWarning(s,A.g.ProtocolUpgrade));case 29:return p.abrupt("return",{success:!0});case 32:return p.prev=32,p.t0=p.catch(14),p.abrupt("return",{error:p.t0});case 35:return p.prev=35,i(),p.finish(35);case 38:case"end":return p.stop()}},null,this,[[14,32,35,38]],Promise)}},{key:"addPasscode",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e.length<1)){n.next=2;break}return n.abrupt("return",!1);case 2:return n.next=4,b.awrap(this.protectionService.authorizeAddingPasscode());case 4:if(n.sent){n.next=6;break}return n.abrupt("return",!1);case 6:return n.next=8,b.awrap(this.alertService.blockingDialog(j.z,j.Q));case 8:return t=n.sent,n.prev=9,n.next=12,b.awrap(this.setPasscodeWithoutWarning(e,A.g.PasscodeCreate));case 12:return n.abrupt("return",!0);case 13:return n.prev=13,t(),n.finish(13);case 16:case"end":return n.stop()}},null,this,[[9,,13,16]],Promise)}},{key:"removePasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeRemovingPasscode());case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,b.awrap(this.alertService.blockingDialog(j.z,j.O));case 6:return e=t.sent,t.prev=7,t.next=10,b.awrap(this.removePasscodeWithoutWarning());case 10:return t.abrupt("return",!0);case 11:return t.prev=11,e(),t.finish(11);case 14:case"end":return t.stop()}},null,this,[[7,,11,14]],Promise)}},{key:"changePasscode",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:A.g.PasscodeChange,!(e.length<1)){a.next=3;break}return a.abrupt("return",!1);case 3:return a.next=5,b.awrap(this.protectionService.authorizeChangingPasscode());case 5:if(a.sent){a.next=7;break}return a.abrupt("return",!1);case 7:return a.next=9,b.awrap(this.alertService.blockingDialog(j.z,t===A.g.ProtocolUpgrade?j.N.UpgradingPasscode:j.v));case 9:return n=a.sent,a.prev=10,a.next=13,b.awrap(this.removePasscodeWithoutWarning());case 13:return a.next=15,b.awrap(this.setPasscodeWithoutWarning(e,t));case 15:return a.abrupt("return",!0);case 16:return a.prev=16,n(),a.finish(16);case 19:case"end":return a.stop()}},null,this,[[10,,16,19]],Promise)}},{key:"setPasscodeWithoutWarning",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(I.GenerateUuid());case 2:return n=a.sent,a.next=5,b.awrap(this.protocolService.createRootKey(n,e,t));case 5:return r=a.sent,a.next=8,b.awrap(this.protocolService.setNewRootKeyWrapper(r));case 8:return a.next=10,b.awrap(this.rewriteItemsKeys());case 10:return a.next=12,b.awrap(this.syncService.sync());case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"removePasscodeWithoutWarning",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protocolService.removeRootKeyWrapper());case 2:return e.next=4,b.awrap(this.rewriteItemsKeys());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"rewriteItemsKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.itemsKeys(),t=e.map(function(e){return e.payloadRepresentation()}),n.next=4,b.awrap(this.storageService.deletePayloads(t));case 4:return n.next=6,b.awrap(this.syncService.persistPayloads(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"clearDatabase",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performCredentialsChange",value:function(e){var t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(this.challengeService.getWrappingKeyIfApplicable(e.passcode));case 2:if(t=u.sent,n=t.wrappingKey,!t.canceled){u.next=7;break}return u.abrupt("return",{error:Error(j.y.PasscodeRequired)});case 7:if(void 0===e.newPassword||!e.validateNewPasswordStrength){u.next=10;break}if(!(e.newPassword.length<8)){u.next=10;break}return u.abrupt("return",{error:Error(Object(j.G)(8))});case 10:return u.next=12,b.awrap(this.protocolService.validateAccountPassword(e.currentPassword));case 12:if(u.sent.valid){u.next=15;break}return u.abrupt("return",{error:Error(j.D)});case 15:return r=this.sessionManager.getUser(),a=r.email,u.next=19,b.awrap(this.recomputeRootKeysForCredentialChange({currentPassword:e.currentPassword,currentEmail:a,origination:e.origination,newEmail:e.newEmail,newPassword:e.newPassword}));case 19:return i=u.sent,this.lockSyncing(),u.next=23,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.currentRootKey.serverPassword,newRootKey:i.newRootKey,wrappingKey:n,newEmail:e.newEmail}));case 23:if(s=u.sent,this.unlockSyncing(),s.response.error){u.next=45;break}return u.next=28,b.awrap(this.protocolService.createNewItemsKeyWithRollback());case 28:return o=u.sent,u.next=31,b.awrap(this.protocolService.reencryptItemsKeys());case 31:return u.next=33,b.awrap(this.syncService.sync({awaitAll:!0}));case 33:if(c=this.protocolService.getDefaultItemsKey(),!c.neverSynced){u.next=45;break}return u.next=38,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.newRootKey.serverPassword,newRootKey:i.currentRootKey,wrappingKey:n}));case 38:return u.next=40,b.awrap(this.protocolService.reencryptItemsKeys());case 40:return u.next=42,b.awrap(o());case 42:return u.next=44,b.awrap(this.syncService.sync({awaitAll:!0}));case 44:return u.abrupt("return",{error:Error(j.y.Failed)});case 45:return u.abrupt("return",s.response);case 46:case"end":return u.stop()}},null,this,null,Promise)}},{key:"recomputeRootKeysForCredentialChange",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=b,i.t1=this.protocolService,i.t2=e.currentPassword,i.next=5,b.awrap(this.protocolService.getRootKeyParams());case 5:return i.t3=i.sent,i.t4=i.t1.computeRootKey.call(i.t1,i.t2,i.t3),i.next=9,i.t0.awrap.call(i.t0,i.t4);case 9:return r=i.sent,i.next=12,b.awrap(this.protocolService.createRootKey(null!==(t=e.newEmail)&&void 0!==t?t:e.currentEmail,null!==(n=e.newPassword)&&void 0!==n?n:e.currentPassword,e.origination));case 12:return a=i.sent,i.abrupt("return",{currentRootKey:r,newRootKey:a});case 14:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),Je=n(5),$e=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",get:function(){return this.payload.safeContent.migratedToUserSetting}},{key:"migratedToOfflineEntitlements",get:function(){return this.payload.safeContent.migratedToOfflineEntitlements}},{key:"onlineUrl",get:function(){return this.payload.safeContent.url}},{key:"offlineFeaturesUrl",get:function(){return this.payload.safeContent.offlineFeaturesUrl}},{key:"offlineKey",get:function(){return this.payload.safeContent.offlineKey}}]),n})(T.d),Xe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",set:function(e){this.content.migratedToUserSetting=e}},{key:"migratedToOfflineEntitlements",set:function(e){this.content.migratedToOfflineEntitlements=e}},{key:"offlineFeaturesUrl",set:function(e){this.content.offlineFeaturesUrl=e}},{key:"offlineKey",set:function(e){this.content.offlineKey=e}}]),n})(T.b),Ze=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).notes=[],r.data={},r.url=e.safeContent.url,r.name=e.safeContent.name,r.data=e.safeContent.data||{},r.isDefault=e.safeContent.default,r.systemEditor=e.safeContent.systemEditor,r}return n})(T.d),et=(function(e){d(n,oe);var t=k(n);function n(e){var r;return v(this,n),r=t.call(this,e),e.safeContent.predicate&&(r.predicate=H.a.FromJson(e.safeContent.predicate)),r}return n})(),tt=(g(r={},F.a.Note,le),g(r,F.a.Tag,oe),g(r,F.a.ItemsKey,J),g(r,F.a.SmartTag,et),g(r,F.a.ActionsExtension,ie),g(r,F.a.Editor,Ze),g(r,F.a.Theme,B),g(r,F.a.Component,N),g(r,F.a.UserPrefs,z),g(r,F.a.ExtensionRepo,$e),r);function nt(e){return new(tt[e.content_type]||T.d)(e)}var rt=n(27),at=n.n(rt);function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){ot(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ct=g({},F.a.Note,function(e,t,n){var r=n.all(F.a.Component).map(function(e){return nt(e)}).filter(function(e){return e.area===L.ComponentArea.Editor}).find(function(t){return t.isExplicitlyEnabledForItem(e.uuid)});if(r){var a=new V(r,T.c.Internal);return a.associateWithItem(t.uuid),[a.getResult()]}});function ut(e,t,n,r){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(!e.errorDecrypting){p.next=2;break}throw Error('Attempting to duplicate errored payload');case 2:return a=[],p.next=5,b.awrap(I.GenerateUuid());case 5:return p.t0=p.sent,p.t1=new Date,p.t2=e.uuid,(i={uuid:p.t0,dirty:!0,dirtiedDate:p.t1,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:p.t2}).content=st(st({},e.safeContent),r),n&&(i.content.conflict_of=e.uuid),s=Object(Ee.b)(e,i),a.push(s),o=t.elementsReferencingElement(e),c=pt(o,[{uuid:s.uuid,content_type:s.content_type}]),Object(_.o)(a,c),(u=ct[e.content_type])&&(l=u(e,s,t))&&Object(_.o)(a,l),p.abrupt("return",a);case 19:case"end":return p.stop()}},null,null,null,Promise)}function lt(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=[],u.t0=Object(Ee.b),u.t1=e,u.next=5,b.awrap(I.GenerateUuid());case 5:return u.t2=u.sent,u.t3=new Date,u.t4=e.uuid,u.t5={uuid:u.t2,dirty:!0,dirtiedDate:u.t3,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:u.t4},r=(0,u.t0)(u.t1,u.t5),n.push(r),a=t.elementsReferencingElement(e),i=pt(a,[{uuid:r.uuid,content_type:r.content_type}],[e.uuid]),Object(_.o)(n,i),e.content_type===F.a.ItemsKey&&(s=t.all().filter(function(t){return t.items_key_id===e.uuid}),(o=s.map(function(e){return Object(Ee.b)(e,{items_key_id:r.uuid})})).length>0&&Object(_.o)(n,o)),c=Object(Ee.b)(e,{deleted:!0,dirty:!1,content:void 0}),n.push(c),u.abrupt("return",n);case 18:case"end":return u.stop()}},null,null,null,Promise)}function pt(e,t,n){for(var r,a=[],i=S(e);!(r=i()).done;){var s=r.value,o=s.contentObject.references.slice();if(t)for(var c,u=S(t);!(c=u()).done;){var l=c.value;o.push(l)}if(n)for(var p,d=S(n);!(p=d()).done;){var h=p.value;at()(o,{uuid:h})}var f=Object(Ee.b)(s,{dirty:!0,dirtiedDate:new Date,content:st(st({},s.safeContent),{},{references:o})});a.push(f)}return a}function dt(e,t){var n=nt(e),r=nt(t);return n.isItemContentEqualWith(r)}var ht=n(4),ft=n(32),vt=(function(){function e(t,n,r,a){v(this,e),this.baseCollection=t,this.applyCollection=n,this.relatedCollectionSet=r,this.historyMap=a}return y(e,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:throw'Must override PayloadDelta.resultingCollection.';case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"findBasePayload",value:function(e){return this.baseCollection.find(e)}},{key:"findRelatedPayload",value:function(e,t){var n,r=null===(n=this.relatedCollectionSet)||void 0===n?void 0:n.collectionForSource(t);return null===r||void 0===r?void 0:r.find(e)}}]),e})(),yt=function(e){return e[0]},gt=(function(){function e(){v(this,e),this.directMap={},this.inverseMap={}}return y(e,[{key:"makeCopy",value:function(){var t=new e;return t.directMap=w({},this.directMap),t.inverseMap=w({},this.inverseMap),t}},{key:"getDirectRelationships",value:function(e){return this.directMap[e]||[]}},{key:"getInverseRelationships",value:function(e){return this.inverseMap[e]||[]}},{key:"establishRelationship",value:function(e,t){this.establishDirectRelationship(e,t),this.establishInverseRelationship(e,t)}},{key:"deestablishRelationship",value:function(e,t){this.deestablishDirectRelationship(e,t),this.deestablishInverseRelationship(e,t)}},{key:"setAllRelationships",value:function(e,t){var n=this.directMap[e]||[];this.directMap[e]=t;for(var r,a=S(n);!(r=a()).done;){var i=r.value;this.deestablishInverseRelationship(e,i)}for(var s,o=S(t);!(s=o()).done;){var c=s.value;this.establishInverseRelationship(e,c)}}},{key:"removeFromMap",value:function(e){for(var t,n=S(this.directMap[e]||[]);!(t=n()).done;){var r=t.value;Object(_.M)(this.inverseMap[r]||[],e)}delete this.directMap[e];for(var a,i=S(this.inverseMap[e]||[]);!(a=i()).done;){var s=a.value;Object(_.M)(this.directMap[s]||[],e)}delete this.inverseMap[e]}},{key:"establishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.b)(n,t),this.directMap[e]=n}},{key:"establishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.b)(n,e),this.inverseMap[t]=n}},{key:"deestablishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.M)(n,t),this.directMap[e]=n}},{key:"deestablishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.M)(n,e),this.inverseMap[t]=n}}]),e})(),mt=(function(){function e(){v(this,e);var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.map={},this.typedMap={},this.dirtyIndex=new Set,this.invalidsIndex=new Set,this.nondeletedIndex=new Set,t?(this.map=n,this.typedMap=r,this.referenceMap=a,this.conflictMap=i):(this.referenceMap=new gt,this.conflictMap=new gt)}return y(e,[{key:"uuids",value:function(){return Object.keys(this.map)}},{key:"all",value:function(e){var t=this;if(e){if(Array.isArray(e)){for(var n,r=[],a=S(e);!(n=a()).done;){var i=n.value;Object(_.o)(r,this.typedMap[i]||[])}return r}var s;return(null===(s=this.typedMap[e])||void 0===s?void 0:s.slice())||[]}return Object.keys(this.map).map(function(e){return t.map[e]})}},{key:"find",value:function(e){return this.map[e]}},{key:"dirtyElements",value:function(){var e=Array.from(this.dirtyIndex);return this.findAll(e)}},{key:"invalidElements",value:function(){var e=Array.from(this.invalidsIndex);return this.findAll(e)}},{key:"nondeletedElements",value:function(){var e=Array.from(this.nondeletedIndex);return this.findAll(e)}},{key:"findAll",value:function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],a=S(e);!(t=a()).done;){var i=t.value,s=this.map[i];(s||n)&&r.push(s)}return r}},{key:"set",value:function(e){if(0!==(e=Array.isArray(e)?e:[e]).length)for(var t,n=S(e);!(t=n()).done;){var r=t.value;if(this.map[r.uuid]=r,this.setToTypedMap(r),r.dirty?this.dirtyIndex.add(r.uuid):this.dirtyIndex.delete(r.uuid),r.errorDecrypting||r.waitingForKey?this.invalidsIndex.add(r.uuid):this.invalidsIndex.delete(r.uuid),r.deleted)this.referenceMap.removeFromMap(r.uuid),this.nondeletedIndex.delete(r.uuid);else{this.nondeletedIndex.add(r.uuid);var a=r.safeContent.conflict_of;a&&this.conflictMap.establishRelationship(a,r.uuid),this.referenceMap.setAllRelationships(r.uuid,r.references.map(function(e){return e.uuid}))}}else console.warn('Attempting to set 0 elements onto collection')}},{key:"discard",value:function(e){for(var t,n=S(e=Array.isArray(e)?e:[e]);!(t=n()).done;){var r=t.value;this.conflictMap.removeFromMap(r.uuid),this.referenceMap.removeFromMap(r.uuid),this.deleteFromTypedMap(r),delete this.map[r.uuid]}}},{key:"setToTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),t.push(e),this.typedMap[e.content_type]=t}},{key:"deleteFromTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),this.typedMap[e.content_type]=t}},{key:"uuidsThatReferenceUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getInverseRelationships(e)}},{key:"elementsReferencingElement",value:function(e,t){var n=this.uuidsThatReferenceUuid(e.uuid),r=this.findAll(n);return t?r.filter(function(e){return e.content_type===t}):r}},{key:"uuidReferencesForUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getDirectRelationships(e)}},{key:"referencesForElement",value:function(e){var t=this.referenceMap.getDirectRelationships(e.uuid);return this.findAll(t)}},{key:"conflictsOf",value:function(e){var t=this.conflictMap.getDirectRelationships(e);return this.findAll(t)}}]),e})(),bt=(function(e){d(n,mt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"mutableCopy",value:function(){var e=w({},this.map),t=w({},this.typedMap),n=this.referenceMap.makeCopy(),r=this.conflictMap.makeCopy();return new mt(!0,e,t,n,r)}},{key:"payloads",get:function(){return this.all()}}],[{key:"WithPayloads",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=new n;return r.source=t,e.length>0&&r.set(e),Object.freeze(r),r}},{key:"FromCollection",value:function(e){var t=new n(!0,Object.freeze(w({},e.map)),Object.freeze(w({},e.typedMap)),Object.freeze(e.referenceMap.makeCopy()),Object.freeze(e.conflictMap.makeCopy()));return Object.freeze(t),t}}]),n})();function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach(function(t){xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var St,Pt,Ot,Ct=(function(){function e(t,n,r,a,i){v(this,e),this.baseCollection=t,this.basePayload=n,this.applyPayload=r,this.source=a,this.historyMap=i}return y(e,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return t=nt(this.basePayload),n=nt(this.applyPayload),r=(null===(e=this.historyMap)||void 0===e?void 0:e[this.basePayload.uuid])||[],a=yt(r),i=t.strategyWhenConflictingWithItem(n,a),o.next=7,b.awrap(this.payloadsByHandlingStrategy(i));case 7:return s=o.sent,o.abrupt("return",bt.WithPayloads(s,this.source));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingStrategy",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if((t=this.baseCollection.conflictsOf(this.applyPayload.uuid)[0])&&dt(t,this.applyPayload)&&(e=K.a.KeepLeft),e!==K.a.KeepLeft){y.next=7;break}return n=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),r=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),a=Object(Ee.b)(this.basePayload,{updated_at:n,updated_at_timestamp:r,dirty:!0,dirtiedDate:new Date}),y.abrupt("return",[a]);case 7:if(e!==K.a.KeepRight){y.next=10;break}return i=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",[i]);case 10:if(e!==K.a.KeepLeftDuplicateRight){y.next=18;break}return s=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),o=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),c=Object(Ee.b)(this.basePayload,{updated_at:s,updated_at_timestamp:o,dirty:!0,dirtiedDate:new Date}),y.next=16,b.awrap(ut(this.applyPayload,this.baseCollection,!0));case 16:return u=y.sent,y.abrupt("return",[c].concat(u));case 18:if(e!==K.a.DuplicateLeftKeepRight){y.next=24;break}return y.next=21,b.awrap(ut(this.basePayload,this.baseCollection,!0));case 21:return l=y.sent,p=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",l.concat([p]));case 24:if(e!==K.a.KeepLeftMergeRefs){y.next=30;break}return d=Object(_.U)(this.basePayload.contentObject.references,this.applyPayload.contentObject.references,['uuid','content_type']),h=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),f=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),v=Object(Ee.b)(this.basePayload,{updated_at:h,updated_at_timestamp:f,dirty:!0,dirtiedDate:new Date,content:kt(kt({},this.basePayload.safeContent),{},{references:d})}),y.abrupt("return",[v]);case 30:throw Error('Unhandled strategy');case 31:case"end":return y.stop()}},null,this,null,Promise)}}]),e})(),Dt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}return r=n.value,s.next=6,b.awrap(this.payloadsByHandlingPayload(r,e));case 6:a=s.sent,i=a.map(function(e){return Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date,deleted:!1})}),Object(_.o)(e,i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.FileImport));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingPayload",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=t.find(function(t){return t.contentObject.conflict_of===e.uuid}))||(n=t.find(function(t){return t.uuid===e.uuid})),n||(n=this.findBasePayload(e.uuid)),n){i.next=5;break}return i.abrupt("return",[e]);case 5:return r=new Ct(this.baseCollection,n,e,ht.a.FileImport),i.next=8,b.awrap(r.resultingCollection());case 8:return a=i.sent,i.abrupt("return",a.all());case 10:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(),_t=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=17;break}if(r=n.value,e.push(r),a=this.findBasePayload(r.uuid)){s.next=8;break}return s.abrupt("continue",15);case 8:if(!dt(r,a)){s.next=11;break}return s.abrupt("continue",15);case 11:return s.next=13,b.awrap(ut(a,this.baseCollection,!0));case 13:i=s.sent,Object(_.o)(e,i);case 15:s.next=2;break;case 17:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 18:case"end":return s.stop()}},null,this,null,Promise)}}]),n})(),Et=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.applyCollection.source!==ht.a.ConflictUuid){e.next=4;break}return e.abrupt("return",this.collectionsByHandlingUuidConflicts());case 4:if(this.applyCollection.source!==ht.a.ConflictData){e.next=8;break}return e.abrupt("return",this.collectionsByHandlingDataConflicts());case 8:throw"Unhandled conflict type ".concat(this.applyCollection.source);case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingDataConflicts",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){u.next=19;break}if(r=n.value,a=this.findBasePayload(r.uuid)){u.next=8;break}return e.push(r),u.abrupt("continue",17);case 8:if((i=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient))||r.deleted){u.next=11;break}throw'Unable to find decrypted counterpart for data conflict.';case 11:return s=new Ct(this.baseCollection,a,i||r,ht.a.ConflictData,this.historyMap),u.next=14,b.awrap(s.resultingCollection());case 14:o=u.sent,c=o.all(),Object(_.o)(e,c);case 17:u.next=2;break;case 19:return u.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingUuidConflicts",value:function(){var e,t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:e=[],t=this.baseCollection.mutableCopy(),n=function(n){var r,a,i;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=e.find(function(e){return e.uuid===n.uuid}),a=r||s.findRelatedPayload(n.uuid,ht.a.DecryptedTransient)){o.next=6;break}return we.a.error(Error('Cannot find decrypted payload in conflict handling')),console.error('Unable to find decrypted counterpart for payload',n),o.abrupt("return","continue");case 6:return o.next=8,b.awrap(lt(a,bt.FromCollection(t)));case 8:i=o.sent,t.set(i),Object(_.p)(e,function(e){return Object(Ke.b)(i).includes(e.uuid)}),Object(_.o)(e,i);case 12:case"end":return o.stop()}},null,null,null,Promise)},r=S(this.applyCollection.all());case 4:if((a=r()).done){o.next=13;break}return i=a.value,o.next=8,b.awrap(n(i));case 8:if("continue"!==o.sent){o.next=11;break}return o.abrupt("continue",11);case 11:o.next=4;break;case 13:return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 14:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Rt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y;return b.async(function(g){for(;;)switch(g.prev=g.next){case 0:e=[],t=[],n=S(this.applyCollection.all());case 3:if((r=n()).done){g.next=22;break}if(a=r.value,i=this.findRelatedPayload(a.uuid,ht.a.SavedOrSaving),s=this.findRelatedPayload(a.uuid,ht.a.DecryptedTransient)){g.next=12;break}if(a.deleted){g.next=10;break}throw'Cannot find decrypted for non-deleted payload.';case 10:return e.push(a),g.abrupt("continue",20);case 12:if(!i){g.next=15;break}return t.push(s),g.abrupt("continue",20);case 15:if(null===(o=this.findBasePayload(a.uuid))||void 0===o||!o.dirty||o.errorDecrypting){g.next=19;break}return t.push(s),g.abrupt("continue",20);case 19:e.push(s);case 20:g.next=3;break;case 22:c=[],u=0,l=t;case 24:if(!(u<l.length)){g.next=41;break}if(p=l[u],d=this.findRelatedPayload(p.uuid,ht.a.DecryptedTransient)){g.next=29;break}return g.abrupt("continue",38);case 29:if(h=this.findBasePayload(p.uuid)){g.next=32;break}return g.abrupt("continue",38);case 32:return f=new Ct(this.baseCollection,h,d,ht.a.ConflictData),g.next=35,b.awrap(f.resultingCollection());case 35:v=g.sent,y=v.all(),Object(_.o)(c,y);case 38:u++,g.next=24;break;case 41:return g.abrupt("return",bt.WithPayloads(e.concat(c),ht.a.RemoteRetrieved));case 42:case"end":return g.stop()}},null,this,null,Promise)}}]),n})(),It=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:for(e=[],t=S(this.applyCollection.all());!(n=t()).done;)r=n.value,a=this.findBasePayload(r.uuid),i=a?a.deleted:r.deleted,s=Object(Ee.f)(r,ht.a.RemoteSaved,{lastSyncEnd:new Date,deleted:i,dirty:i}),e.push(s);return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteSaved));case 3:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Mt=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l){var p;return v(this,n),(p=t.call(this)).itemManager=e,p.payloadManager=r,p.apiService=a,p.protocolService=i,p.challengeService=s,p.alertService=o,p.storageService=c,p.syncService=u,p.credentialService=l,p.decryptionQueue=[],p.isProcessingQueue=!1,p.removeItemObserver=p.itemManager.addObserver([F.a.ItemsKey],function(e,t,n,r,a){if(a!==ht.a.LocalChanged){var i=e.concat(t).filter(function(e){return e.errorDecrypting});i.length>0&&p.handleUndecryptableItemsKeys(i),r.length>0&&p.handleIgnoredItemsKeys(r)}}),p}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.apiService=void 0,this.protocolService=void 0,this.challengeService=void 0,this.alertService=void 0,this.credentialService=void 0,this.syncService=void 0,this.storageService=void 0,this.removeItemObserver(),this.removeItemObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:p(f(n.prototype),"handleApplicationStage",this).call(this,e),e===ve.LoadedDatabase_12&&this.processPersistedUndecryptables();case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleIgnoredItemsKeys",value:function(e){var t=this,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(!(n.length>1&&void 0!==n[1])||n[1])){r.next=4;break}return r.next=4,b.awrap(this.saveToUndecryptables(e));case 4:return r.next=6,b.awrap(this.addKeysToQueue(e,function(e,n){n.success&&t.removeFromUndecryptables(e)}));case 6:return r.next=8,b.awrap(this.beginProcessingQueue());case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"handleUndecryptableItemsKeys",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.addKeysToQueue(e));case 2:return t.next=4,b.awrap(this.beginProcessingQueue());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"processPersistedUndecryptables",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getUndecryptables());case 2:if(e=r.sent,0!==(t=Object.values(e)).length){r.next=6;break}return r.abrupt("return");case 6:return n=t.map(function(e){return Object(Ee.e)(e)}).map(function(e){return nt(e)}),r.abrupt("return",this.handleIgnoredItemsKeys(n,!1));case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getUndecryptables",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.KeyRecoveryUndecryptableItems,De.Default,{}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"persistUndecryptables",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.KeyRecoveryUndecryptableItems,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"saveToUndecryptables",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.getUndecryptables());case 2:for(t=i.sent,n=S(e);!(r=n()).done;)a=r.value,t[a.uuid]=a.payload.ejected();return i.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"removeFromUndecryptables",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getUndecryptables());case 2:return delete(t=n.sent)[e.uuid],n.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getClientKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getAccountKeyParams());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"serverKeyParamsAreSafe",value:function(e){return Object(Q.d)(this.serverParams.version,e.version)}},{key:"performServerSignIn",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(e),j.H.KeyRecoveryLoginFlowReason),i.next=3,b.awrap(this.challengeService.promptForChallengeResponse(t));case 3:if(n=i.sent){i.next=6;break}return i.abrupt("return",void 0);case 6:return this.challengeService.completeChallenge(t),r=n.values[0].value,i.next=10,b.awrap(this.protocolService.computeRootKey(r,e));case 10:return a=i.sent,i.next=13,b.awrap(this.credentialService.correctiveSignIn(a));case 13:if(i.sent.error){i.next=19;break}return this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced),i.abrupt("return",a);case 19:return i.next=21,b.awrap(this.alertService.alert(j.H.KeyRecoveryLoginFlowInvalidPassword));case 21:return i.abrupt("return",this.performServerSignIn(e));case 22:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",void 0);case 2:return n.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(e=n.sent,t=e.wrappingKey,!e.canceled){n.next=11;break}return n.next=10,b.awrap(this.alertService.alert(j.H.KeyRecoveryPasscodeRequiredText,j.H.KeyRecoveryPasscodeRequiredTitle));case 10:return n.abrupt("return",this.getWrappingKeyIfApplicable());case 11:return n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"addKeysToQueue",value:function(e,t){var n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:n=function(e){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(s.protocolService.getKeyEmbeddedKeyParams(e));case 2:if(n=i.sent){i.next=5;break}return i.abrupt("return","continue");case 5:r={key:e,keyParams:n,callback:t},a=new Promise(function(e){r.resolve=e}),r.promise=a,s.decryptionQueue.push(r);case 9:case"end":return i.stop()}},null,null,null,Promise)},r=S(e);case 2:if((a=r()).done){o.next=11;break}return i=a.value,o.next=6,b.awrap(n(i));case 6:if("continue"!==o.sent){o.next=9;break}return o.abrupt("continue",9);case 9:o.next=2;break;case 11:case"end":return o.stop()}},null,null,null,Promise)}},{key:"readdQueueItem",value:function(e){var t=new Promise(function(t){e.resolve=t});e.promise=t,this.decryptionQueue.unshift(e)}},{key:"beginProcessingQueue",value:function(){var e,t,n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.isProcessingQueue){c.next=2;break}return c.abrupt("return");case 2:return this.isProcessingQueue=!0,c.next=5,b.awrap(this.getClientKeyParams());case 5:if(e=c.sent,this.serverParams||!e){c.next=11;break}return c.next=9,b.awrap(this.apiService.getAccountKeyParams(e.identifier));case 9:!(t=c.sent).error&&t.data&&(this.serverParams=Object(A.f)(t));case 11:if(n=this.protocolService.hasAccount(),r=this.protocolService.hasPasscode(),a=!n&&!r,i=this.decryptionQueue[0],!a){c.next=24;break}return c.next=18,b.awrap(this.performServerSignIn(i.keyParams));case 18:if(!(s=c.sent)){c.next=24;break}return c.next=22,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(s,!0));case 22:Object(_.M)(this.decryptionQueue,i),i=this.decryptionQueue[0];case 24:if(!i){c.next=31;break}return this.popQueueItem(i),c.next=28,b.awrap(i.promise);case 28:i=this.decryptionQueue[0],c.next=24;break;case 31:this.queuePromise.then(function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(o.isProcessingQueue=!1,!o.serverParams){n.next=9;break}return n.next=4,b.awrap(o.getClientKeyParams());case 4:if(e=n.sent,t=e&&!o.serverParams.compare(e),!o.serverKeyParamsAreSafe(e)||!t){n.next=9;break}return n.next=9,b.awrap(o.performServerSignIn(o.serverParams));case 9:o.syncService.isOutOfSync()&&o.syncService.sync({checkIntegrity:!0});case 10:case"end":return n.stop()}},null,null,null,Promise)});case 32:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueItem",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P;return b.async(function(O){for(;;)switch(O.prev=O.next){case 0:if(e.resolve){O.next=2;break}throw Error('Attempting to pop queue element with no resolve function');case 2:return Object(_.M)(this.decryptionQueue,e),t=e.keyParams,n=e.key,r=e.resolve,a=!1,O.next=9,b.awrap(this.getClientKeyParams());case 9:return i=O.sent,this.serverParams&&i&&!i.compare(this.serverParams)&&t.compare(this.serverParams)&&this.serverKeyParamsAreSafe(this.serverParams)&&(s=Object(_.j)(this.itemManager.nonErroredItemsForContentType(F.a.ItemsKey),Je.a.CreatedAt,!1)[0],o=!Object(_.w)(s),c=n.created_at>(null===s||void 0===s?void 0:s.created_at),a=!o||c),u=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(t),j.H.KeyRecoveryPasswordRequired),O.next=14,b.awrap(this.challengeService.promptForChallengeResponse(u));case 14:if(l=O.sent){O.next=20;break}return r(d={success:!1}),null===(p=e.callback)||void 0===p||p.call(e,n,d),O.abrupt("return");case 20:return h=l.values[0].value,O.next=23,b.awrap(this.protocolService.computeRootKey(h,t));case 23:return f=O.sent,O.next=26,b.awrap(this.protocolService.payloadByDecryptingPayload(n.payload,f));case 26:if(v=O.sent,this.challengeService.completeChallenge(u),v.errorDecrypting){O.next=38;break}return O.next=31,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(f,a,[v]));case 31:for(g=O.sent,r(m={success:!0}),null===(y=e.callback)||void 0===y||y.call(e,n,m),w=S(g);!(k=w()).done;)(x=k.value).resolve(m),null===(P=x.callback)||void 0===P||P.call(x,x.key,m);O.next=42;break;case 38:return O.next=40,b.awrap(this.alertService.alert(j.H.KeyRecoveryUnableToRecover));case 40:this.readdQueueItem(e),r({success:!1});case 42:case"end":return O.stop()}},null,this,null,Promise)}},{key:"handleDecryptionOfAllKeysMatchingCorrectRootKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:[],!t){c.next=7;break}return c.next=4,b.awrap(this.getWrappingKeyIfApplicable());case 4:return r=c.sent,c.next=7,b.awrap(this.protocolService.setRootKey(e,r));case 7:return a=this.popQueueForKeyParams(e.keyParams),c.next=10,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a.map(function(e){return e.key.payload}),e));case 10:return i=c.sent,s=n.concat(i),this.payloadManager.emitPayloads(s,ht.a.DecryptedTransient),c.next=15,b.awrap(this.storageService.savePayloads(s));case 15:return t?this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced):this.alertService.alert(j.H.KeyRecoveryKeyRecovered),c.abrupt("return",a);case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueForKeyParams",value:function(e){for(var t,n=[],r=[],a=S(this.decryptionQueue);!(t=a()).done;){var i=t.value;i.keyParams.compare(e)?n.push(i):r.push(i)}return this.decryptionQueue=r,n}},{key:"queuePromise",get:function(){return Promise.all(this.decryptionQueue.map(function(e){return e.promise}))}}]),n})(R.a),At=n(17);!(function(e){e[e.Info=0]="Info",e[e.Danger=1]="Danger"})(St||(St={})),(function(e){e.Get="GET",e.Post="POST",e.Put="PUT",e.Patch="PATCH",e.Delete="DELETE"})(Pt||(Pt={})),(function(e){e.RevokedSession="revoked-session"})(Ot||(Ot={}));var jt=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).environment=e,a.appVersion=r,a}return y(n,[{key:"getAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Get,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"postAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Post,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"putAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Put,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"patchAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Patch,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Delete,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"runHttp",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.createXmlRequest(e),n.abrupt("return",this.runRequest(t,e.verb,e.params));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createXmlRequest",value:function(e){var t=new XMLHttpRequest;e.params&&e.verb===Pt.Get&&Object.keys(e.params).length>0&&(e.url=this.urlForUrlAndParams(e.url,e.params)),t.open(e.verb,e.url,!0),t.setRequestHeader('Content-type','application/json'),t.setRequestHeader('X-SNJS-Version',h);var n="".concat(he[this.environment],"-").concat(this.appVersion);return t.setRequestHeader('X-Application-Version',n),e.authentication&&t.setRequestHeader('Authorization','Bearer '+e.authentication),e.customHeaders&&e.customHeaders.length>0&&e.customHeaders.forEach(function(e){var n=e.key,r=e.value;t.setRequestHeader(n,r)}),t}},{key:"runRequest",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,i){e.onreadystatechange=function(){r.stateChangeHandlerForRequest(e,a,i)},t===Pt.Post||t===Pt.Put||t===Pt.Patch||t===Pt.Delete?e.send(JSON.stringify(n)):e.send()}));case 1:case"end":return a.stop()}},null,null,null,Promise)}},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.status,a={status:r};try{if(r!==Te.b.HttpStatusNoContent){var i=JSON.parse(e.responseText);i.data||(a.data=i),w(a,i)}}catch(e){console.error(e)}r>=Te.b.HttpStatusMinSuccess&&r<=Te.b.HttpStatusMaxSuccess?t(a):(r===Te.b.HttpStatusForbidden?a.error={message:j.q,status:r}:Object(_.w)(a.error)&&(Object(_.w)(a.data)||Object(_.w)(a.data.error)?a.error={message:j.U,status:r}:a.error=a.data.error),n(a))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map(function(e){return e+'='+encodeURIComponent(t[e])}).join('&');return e.includes('?')?e+'&'+n:e+'?'+n}}]),n})(R.a),Tt=n(22),Kt=['api.standardnotes.com','api-dev.standardnotes.com','sync.standardnotes.org'],Ft=['api-dev.standardnotes.com','api.standardnotes.com','extensions.standardnotes.com','extensions.standardnotes.org','features.standardnotes.com'],Lt='localhost';function Ut(e){try{var t=new URL(e).host;return t.startsWith(Lt)||Kt.includes(t)}catch(e){return!1}}var Nt=['listed.to'];function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(n),!0).forEach(function(t){Wt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ht,zt={keyParams:'/v1/login-params',register:'/v1/users',signIn:'/v1/login',changeCredentials:function(e){return"/v1/users/".concat(e,"/attributes/credentials")},sync:'/v1/items',signOut:'/v1/logout',refreshSession:'/v1/sessions/refresh',sessions:'/v1/sessions',session:function(e){return"/v1/sessions/".concat(e)},itemRevisions:function(e){return"/v1/items/".concat(e,"/revisions")},itemRevision:function(e,t){return"/v1/items/".concat(e,"/revisions/").concat(t)},userFeatures:function(e){return"/v1/users/".concat(e,"/features")},settings:function(e){return"/v1/users/".concat(e,"/settings")},setting:function(e,t){return"/v1/users/".concat(e,"/settings/").concat(t)},subscription:function(e){return"/v1/users/".concat(e,"/subscription")},purchase:'/v1/purchase',subscriptionTokens:'/v1/subscription-tokens',offlineFeatures:'/v1/offline/features'},qt={subscriptions:'/v2/subscriptions'};!(function(e){e.MetaReceived="MetaReceived"})(Ht||(Ht={}));var Yt=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).httpService=e,i.storageService=r,i.host=a,i.registering=!1,i.authenticating=!1,i.changing=!1,i.refreshingSession=!1,i}return y(n,[{key:"deinit",value:function(){this.httpService=void 0,this.storageService=void 0,this.invalidSessionObserver=void 0,this.session=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"setInvalidSessionObserver",value:function(e){this.invalidSessionObserver=e}},{key:"loadHost",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ServerHost));case 2:e=t.sent,this.host=e||this.host||window._default_sync_server;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.host=e,t.next=3,b.awrap(this.storageService.setValue(o.ServerHost,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.host}},{key:"isThirdPartyHostUsed",value:function(){return!Ut(this.getHost()||'')}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],this.session=e,!t){r.next=5;break}return r.next=5,b.awrap(this.storageService.setValue(o.Session,e));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSession",value:function(){return this.session}},{key:"params",value:function(e){var t=Z()(e,g({},Tt.a.ApiVersion,this.apiVersion));return t}},{key:"createErrorResponse",value:function(e,t){return{error:{message:e,status:t}}}},{key:"errorResponseWithFallbackMessage",value:function(e,t){var n,r,a;null!==(n=e.error)&&void 0!==n&&n.message||(e.error=Bt(Bt({},e.error),{},{status:null!==(r=null===(a=e.error)||void 0===a?void 0:a.status)&&void 0!==r?r:Te.b.UnknownError,message:t}));return e}},{key:"processMetaObject",value:function(e){e.auth&&e.auth.userUuid&&e.auth.roles&&this.notifyEvent(Ht.MetaReceived,{userUuid:e.auth.userUuid,userRoles:e.auth.roles})}},{key:"processResponse",value:function(e){e.meta&&this.processMetaObject(e.meta)}},{key:"request",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.awrap(this.httpService.runHttp(e));case 3:return t=n.sent,this.processResponse(t),n.abrupt("return",t);case 8:return n.prev=8,n.t0=n.catch(0),n.abrupt("return",this.errorResponseWithFallbackMessage(n.t0,e.fallbackErrorMessage));case 11:case"end":return n.stop()}},null,this,[[0,8]],Promise)}},{key:"getAccountKeyParams",value:function(e,t,n){var r,a=this.params({email:e});return t&&n&&(a[t]=n),this.request({verb:Pt.Get,url:Object(_.D)(this.host,zt.keyParams),fallbackErrorMessage:j.k,params:a,authentication:null===(r=this.session)||void 0===r?void 0:r.authorizationValue})}},{key:"register",value:function(e,t,n,r){var a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.registering){o.next=2;break}return o.abrupt("return",this.createErrorResponse(j.r));case 2:return this.registering=!0,a=Object(_.D)(this.host,zt.register),i=this.params(Bt({password:t,email:e,ephemeral:r},n.getPortableValue())),o.next=7,b.awrap(this.request({verb:Pt.Post,url:a,fallbackErrorMessage:j.l,params:i}));case 7:return s=o.sent,this.registering=!1,o.abrupt("return",s);case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t,n,r){var a,i,s,o,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>4&&void 0!==c[4]&&c[4],!this.authenticating){u.next=3;break}return u.abrupt("return",this.createErrorResponse(j.p));case 3:return this.authenticating=!0,i=Object(_.D)(this.host,zt.signIn),s=this.params({email:e,password:t,ephemeral:a}),n&&r&&(s[n]=r),u.next=9,b.awrap(this.request({verb:Pt.Post,url:i,params:s,fallbackErrorMessage:j.k}));case 9:return o=u.sent,this.authenticating=!1,u.abrupt("return",o);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e=Object(_.D)(this.host,zt.signOut);return this.httpService.postAbsolute(e,void 0,this.session.authorizationValue).catch(function(e){return e})}},{key:"changeCredentials",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.changing){s.next=2;break}return s.abrupt("return",this.createErrorResponse(j.a));case 2:if(!(t=this.preprocessingError())){s.next=5;break}return s.abrupt("return",t);case 5:return this.changing=!0,n=Object(_.D)(this.host,zt.changeCredentials(e.userUuid)),r=this.params(Bt({current_password:e.currentServerPassword,new_password:e.newServerPassword,new_email:e.newEmail},e.newKeyParams.getPortableValue())),s.next=10,b.awrap(this.httpService.putAbsolute(n,r,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Object(Te.c)(e)){t.next=2;break}return t.abrupt("return",i.refreshSessionThenRetryRequest({verb:Pt.Put,url:n,params:r}));case 2:return t.abrupt("return",i.errorResponseWithFallbackMessage(e,j.j));case 3:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return a=s.sent,this.processResponse(a),this.changing=!1,s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"sync",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=this,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:if(i=h.length>4&&void 0!==h[4]&&h[4],s=h.length>5?h[5]:void 0,o=h.length>6?h[6]:void 0,!(c=this.preprocessingError())){f.next=6;break}return f.abrupt("return",c);case 6:return u=Object(_.D)(this.host,zt.sync),l=this.params((g(a={},Tt.a.SyncPayloads,e.map(function(e){return e.ejected()})),g(a,Tt.a.LastSyncToken,t),g(a,Tt.a.PaginationToken,n),g(a,Tt.a.IntegrityCheck,i),g(a,Tt.a.SyncDlLimit,r),g(a,"content_type",s),g(a,"event",o),a)),f.next=10,b.awrap(this.httpService.postAbsolute(u,l,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(d.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){t.next=3;break}return t.abrupt("return",d.refreshSessionThenRetryRequest({verb:Pt.Post,url:u,params:l}));case 3:return t.abrupt("return",d.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return p=f.sent,this.processResponse(p),f.abrupt("return",p);case 13:case"end":return f.stop()}},null,this,null,Promise)}},{key:"refreshSessionThenRetryRequest",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.refreshSession());case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=7;break}return n.abrupt("return",t);case 7:return n.abrupt("return",this.httpService.runHttp(Bt(Bt({},e),{},{authentication:this.session.authorizationValue})).catch(function(e){return e}));case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"refreshSession",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(e=this.preprocessingError())){s.next=3;break}return s.abrupt("return",e);case 3:return this.refreshingSession=!0,t=Object(_.D)(this.host,zt.refreshSession),n=this.session,r=this.params({access_token:n.accessToken,refresh_token:n.refreshToken}),s.next=9,b.awrap(this.httpService.postAbsolute(t,r).then(function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=je.FromApiResponse(e),n.next=3,b.awrap(i.setSession(t));case 3:return i.processResponse(e),n.abrupt("return",e);case 5:case"end":return n.stop()}},null,null,null,Promise)}).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),i.errorResponseWithFallbackMessage(e,j.n)}));case 9:return a=s.sent,this.refreshingSession=!1,s.abrupt("return",a);case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e=this.preprocessingError())){a.next=3;break}return a.abrupt("return",e);case 3:return t=Object(_.D)(this.host,zt.sessions),a.next=6,b.awrap(this.httpService.getAbsolute(t,{},this.session.authorizationValue).catch(function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){n.next=3;break}return n.abrupt("return",r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}));case 3:return n.abrupt("return",r.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return n.stop()}},null,null,null,Promise)}));case 6:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSession",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.session(e)),i.next=6,b.awrap(this.httpService.deleteAbsolute(n,{uuid:e},this.session.authorizationValue).catch(function(e){var t=e;return a.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?a.refreshSessionThenRetryRequest({verb:Pt.Delete,url:n}):a.errorResponseWithFallbackMessage(t,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getItemRevisions",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.itemRevisions(e)),i.next=6,b.awrap(this.httpService.getAbsolute(n,void 0,this.session.authorizationValue).catch(function(e){return a.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?a.refreshSessionThenRetryRequest({verb:Pt.Get,url:n}):a.errorResponseWithFallbackMessage(e,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getRevision",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(n=this.preprocessingError())){s.next=3;break}return s.abrupt("return",n);case 3:return r=Object(_.D)(this.host,zt.itemRevision(t,e.uuid)),s.next=6,b.awrap(this.httpService.getAbsolute(r,void 0,this.session.authorizationValue).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?i.refreshSessionThenRetryRequest({verb:Pt.Get,url:r}):i.errorResponseWithFallbackMessage(e,j.m)}));case 6:return a=s.sent,this.processResponse(a),s.abrupt("return",a);case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getUserFeatures",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=Object(_.D)(this.host,zt.userFeatures(e)),a.next=3,b.awrap(this.httpService.getAbsolute(t,void 0,this.session.authorizationValue).catch(function(e){return r.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}):r.errorResponseWithFallbackMessage(e,j.m)}));case 3:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"tokenRefreshableRequest",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(t=this.preprocessingError())){a.next=3;break}return a.abrupt("return",t);case 3:return a.next=5,b.awrap(this.httpService.runHttp(e).catch(function(t){return r.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?r.refreshSessionThenRetryRequest(e):r.errorResponseWithFallbackMessage(t,e.fallbackErrorMessage)}));case 5:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"listSettings",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.settings(e)),fallbackErrorMessage:j.d,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n,r){var a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return i={name:t,value:n,sensitive:r},s.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Put,url:Object(_.D)(this.host,zt.settings(e)),authentication:null===(a=this.session)||void 0===a?void 0:a.authorizationValue,fallbackErrorMessage:j.h,params:i}));case 2:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.setting(e,t.toLowerCase())),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.d}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Delete,url:Object(_.D)(this.host,zt.setting(e,t)),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.h}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"downloadFeatureUrl",value:function(e){return this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.k})}},{key:"getSubscription",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscription(e)),a.next=3,b.awrap(this.request({verb:Pt.Get,url:n,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue,fallbackErrorMessage:j.g}));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=Object(_.D)(this.host,qt.subscriptions),n.next=3,b.awrap(this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.g}));case 3:return t=n.sent,n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getNewSubscriptionToken",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscriptionTokens),a.next=3,b.awrap(this.request({verb:Pt.Post,url:n,authentication:null===(e=this.session)||void 0===e?void 0:e.authorizationValue,fallbackErrorMessage:j.b}));case 3:return r=a.sent,a.abrupt("return",null===(t=r.data)||void 0===t?void 0:t.token);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"downloadOfflineFeaturesFromRepo",value:function(e){var t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,n=e.offlineFeaturesUrl,r=e.offlineKey,a=new URL(n),i=a.host,Ft.includes(i)){o.next=6;break}return o.abrupt("return",{error:'This offline features host is not in the trusted allowlist.'});case 6:return o.next=8,b.awrap(this.request({verb:Pt.Get,url:n,fallbackErrorMessage:j.f,customHeaders:[{key:'x-offline-token',value:r}]}));case 8:return s=o.sent,o.abrupt("return",{features:(null===(t=s.data)||void 0===t?void 0:t.features)||[]});case 12:return o.prev=12,o.t0=o.catch(0),o.abrupt("return",{error:j.e});case 15:case"end":return o.stop()}},null,this,[[0,12]],Promise)}},{key:"preprocessingError",value:function(){return this.refreshingSession?this.createErrorResponse(j.s):this.session?void 0:this.createErrorResponse(j.o)}},{key:"preprocessAuthenticatedErrorResponse",value:function(e){var t,n;e.status===Te.b.HttpStatusInvalidSession&&this.session&&(null===(t=this.invalidSessionObserver)||void 0===t||t.call(this,(null===(n=e.error)||void 0===n?void 0:n.tag)===Ot.RevokedSession))}},{key:"apiVersion",get:function(){return"20200115"}}]),n})(R.a),Gt=n(25),Qt=n.n(Gt),Jt=n(28),$t=n.n(Jt);function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach(function(t){en(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tn,nn=Object.freeze([F.a.ActionsExtension,F.a.Component,F.a.Editor,F.a.ExtensionRepo,F.a.FilesafeCredentials,F.a.FilesafeFileMetadata,F.a.FilesafeIntegration,F.a.ServerExtension,F.a.SmartTag,F.a.Tag,F.a.Theme]),rn='org.standardnotes.sn.components';!(function(e){e.Shift="Shift",e.Ctrl="Control",e.Meta="Meta"})(tn||(tn={}));var an=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).componentState={},c.streamObservers=[],c.contextStreamObservers=[],c.permissionDialogs=[],c.handlers=[],c.templateComponents=[],c.detectFocusChange=function(){for(var e,t=function(e){if(document.activeElement===e)return c.timeout(function(){for(var t,n=c.findComponent(e.dataset.componentId),r=S(c.handlers);!(t=r()).done;){var a=t.value;a.focusHandler&&a.focusHandler(n,!0)}}),"break"},n=S(c.allComponentIframes());!(e=n()).done;){if("break"===t(e.value))break}},c.onWindowMessage=function(e){e.data.sessionKey&&(c.log('Component manager received message',e.data),c.handleMessage(c.componentForSessionKey(e.data.sessionKey),e.data))},c.timeout=o||setTimeout.bind(window),c.itemManager=e,c.syncService=r,c.alertService=a,c.environment=i,c.platform=s,c.configureForGeneralUsage(),i!==he.Mobile&&c.configureForNonMobileUsage(),c}return y(n,[{key:"componentsForArea",value:function(e){return this.components.filter(function(t){return t.area===e})}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.streamObservers.length=0,this.contextStreamObservers.length=0,this.permissionDialogs.length=0,this.templateComponents.length=0,this.handlers.length=0,this.itemManager=void 0,this.syncService=void 0,this.alertService=void 0,this.removeItemObserver(),this.removeItemObserver=null,window&&!this.isMobile&&(window.removeEventListener('focus',this.detectFocusChange,!0),window.removeEventListener('blur',this.detectFocusChange,!0),window.removeEventListener('message',this.onWindowMessage))}},{key:"setDesktopManager",value:function(e){this.desktopManager=e,this.configureForDesktop()}},{key:"configureForGeneralUsage",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n,r,a,i,s){var o=Object(_.h)(t,n,r),c=o.filter(function(e){return e.content_type===F.a.Component||e.content_type===F.a.Theme});c.length>0&&i!==ht.a.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(c),c.filter(function(e){return e.isTheme()}).length>0&&e.postActiveThemesToAllComponents();for(var u,l=S(c);!(u=l()).done;){var p=u.value;if(!p.isEditor()){var d=!!e.iframeForComponent(p.uuid);!p.active&&d&&e.deactivateComponent(p.uuid)}}e.notifyStreamObservers(o,i,s)})}},{key:"notifyStreamObservers",value:function(e,t,n){for(var r,a=this,i=function(t){if(n&&n===t.componentUuid)return"continue";var r=e.filter(function(e){return-1!==t.contentTypes.indexOf(e.content_type)});if(0===r.length)return"continue";var i=[{name:E.StreamItems,content_types:t.contentTypes.sort()}];a.runWithPermissions(t.componentUuid,i,function(){a.sendItemsInReply(t.componentUuid,r,t.originalMessage)})},s=S(this.streamObservers);!(r=s()).done;)i(r.value);for(var o,c=[{name:E.StreamContextItem}],u=function(r){if(n&&n===r.componentUuid)return"continue";for(var i,s=S(a.handlers);!(i=s()).done;){var o=i.value;if((o.areas.includes(r.area)||o.areas.includes(L.ComponentArea.Any))&&o.contextRequestHandler){var u=o.contextRequestHandler(r.componentUuid);if(u)if("continue"===(function(){var n=Qt()(e,{uuid:u.uuid});if(n){if(n.deleted)return"continue";a.runWithPermissions(r.componentUuid,c,function(){a.sendContextItemInReply(r.componentUuid,n,r.originalMessage,t)})}})())continue}}},l=S(this.contextStreamObservers);!(o=l()).done;)u(o.value)}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location],n=e.hosted_url,r=e.local_url&&e.local_url.replace("sn://",'');return t.includes(n)||t.includes(r)}},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener('focus',this.detectFocusChange,!0):window.attachEvent('onfocusout',this.detectFocusChange),window.addEventListener?window.addEventListener('blur',this.detectFocusChange,!0):window.attachEvent('onblur',this.detectFocusChange),window.addEventListener('message',this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver(function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()})}},{key:"postActiveThemesToAllComponents",value:function(){for(var e,t=S(this.components);!(e=t()).done;){var n=e.value;this.findOrCreateDataForComponent(n.uuid).window&&this.postActiveThemesToComponent(n)}}},{key:"getActiveThemes",value:function(){if(this.environment===he.Mobile)throw Error('getActiveThemes must be handled separately by mobile');return this.componentsForArea(L.ComponentArea.Themes).filter(function(e){return e.active})}},{key:"urlsForActiveThemes",value:function(){for(var e,t=[],n=S(this.getActiveThemes());!(e=n()).done;){var r=e.value,a=this.urlForComponent(r);a&&t.push(a)}return t}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()},n={action:E.ActivateThemes,data:t};this.sendMessageToComponent(e,n)}},{key:"findComponent",value:function(e){return this.templateComponents.find(function(t){return t.uuid===e})||this.itemManager.findItem(e)}},{key:"addTemporaryTemplateComponent",value:function(e){this.templateComponents.push(e)}},{key:"removeTemporaryTemplateComponent",value:function(e){this.templateComponents=this.templateComponents.filter(function(t){return t.uuid!==e.uuid})}},{key:"contextItemDidChangeInArea",value:function(e){for(var t,n=S(this.handlers);!(t=n()).done;){var r=t.value;if(r.areas.includes(e)||r.areas.includes(L.ComponentArea.Any))for(var a,i=S(this.contextStreamObservers.filter(function(t){return t.area===e}));!(a=i()).done;){var s=a.value;if(r.contextRequestHandler){var o=r.contextRequestHandler(s.componentUuid);o&&this.sendContextItemInReply(s.componentUuid,o,s.originalMessage)}}}}},{key:"isComponentHidden",value:function(e){return!0===this.findOrCreateDataForComponent(e.uuid).hidden}},{key:"setComponentHidden",value:function(e,t){var n=this.findOrCreateDataForComponent(e.uuid);if(t)n.hidden=!0;else if(n.hidden){n.hidden=!1;var r=Qt()(this.contextStreamObservers,{identifier:e.uuid});r&&this.handleStreamContextItemMessage(e,r.originalMessage);var a=Qt()(this.streamObservers,{identifier:e.uuid});a&&this.handleStreamItemsMessage(e,a.originalMessage)}}},{key:"jsonForItem",value:function(e,t,n){var r=n===ht.a.RemoteSaved||n===ht.a.LocalSaved||n===ht.a.PreSyncSave,a=(e.getDomainData(rn)||{})[t.getClientDataKey()]||{},i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.serverUpdatedAt,deleted:e.deleted,isMetadataUpdate:r,content:e.content,clientData:a};return this.responseItemsByRemovingPrivateProperties([i],t)[0]}},{key:"sendItemsInReply",value:function(e,t,n,r){var a=this,i=this.findComponent(e);this.log('Component manager send items in reply',i,t,n);var s={},o=t.map(function(e){return a.jsonForItem(e,i,r)});s.items=o,this.replyToMessage(i,n,s)}},{key:"sendContextItemInReply",value:function(e,t,n,r){var a=this.findComponent(e);this.log('Component manager send context item in reply','component:',a,'item: ',t,'originalMessage: ',n);var i={item:this.jsonForItem(t,a,r)};this.replyToMessage(a,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:E.Reply,original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n,r=[E.ComponentRegistered,E.ActivateThemes],a=this.findOrCreateDataForComponent(e.uuid);if(!a.hidden||r.includes(t.action))if(a.window||t.action!==E.Reply){this.log('Component manager send message to component',e,'message: ',t);var i=this.urlForComponent(e);i&&a.window?(i.startsWith('http')||i.startsWith('file')||(i=window.location.href+i),null===(n=a.window)||void 0===n||n.postMessage(this.isMobile?JSON.stringify(t):t,i)):this.alertService.alert("Standard Notes is trying to communicate with ".concat(e.name,", ")+'but an error is occurring. Please restart this extension and try again.')}else this.log('Component has been deallocated in between message send and reply',e,t);else this.log('Component disabled for current item, ignoring messages.',e.name)}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(!t)return null;if(this.isMobile){var n=this.platform===fe.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter(function(t){return t.hosted_url===e||t.legacy_url===e})[0]}},{key:"sessionKeyForComponent",value:function(e){return this.findOrCreateDataForComponent(e.uuid).sessionKey}},{key:"componentForSessionKey",value:function(e){for(var t,n=this,r=function(r){var a=n.componentState[r];if((null===a||void 0===a?void 0:a.sessionKey)===e)return t=n.components.find(function(e){return e.uuid===r}),"break"},a=0,i=Object.keys(this.componentState);a<i.length;a++){if("break"===r(i[a]))break}if(!t)for(var s,o=S(this.handlers);!(s=o()).done;){var c=s.value;if(c.componentForSessionKeyHandler&&(t=c.componentForSessionKeyHandler(e)))break}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log('Component not defined for message, returning',t),void this.alertService.alert("An extension is trying to communicate with Standard Notes, but there is an error establishing a bridge. Please restart the app and try again.");var r=[E.SaveItems,E.AssociateItem,E.DeassociateItem,E.CreateItem,E.CreateItems,E.DeleteItems,E.SetComponentData];if(this.getReadonlyStateForComponent(e).readonly&&r.includes(t.action))this.alertService.alert("The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes."));else{if(t.action===E.StreamItems)this.handleStreamItemsMessage(e,t);else if(t.action===E.StreamContextItem)this.handleStreamContextItemMessage(e,t);else if(t.action===E.SetComponentData)this.handleSetComponentDataMessage(e,t);else if(t.action===E.DeleteItems)this.handleDeleteItemsMessage(e,t);else if(t.action===E.CreateItems||t.action===E.CreateItem)this.handleCreateItemsMessage(e,t);else if(t.action===E.SaveItems)this.handleSaveItemsMessage(e,t);else if(t.action===E.ToggleActivateComponent){var a=this.itemManager.findItem(t.data.uuid);this.handleToggleComponentMessage(a)}else t.action===E.RequestPermissions?this.handleRequestPermissionsMessage(e,t):t.action===E.InstallLocalComponent?this.handleInstallLocalComponentMessage(e,t):t.action===E.DuplicateItem&&this.handleDuplicateItemMessage(e,t);for(var i,s=function(r){r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes(L.ComponentArea.Any))&&n.timeout(function(){r.actionHandler(e,t.action,t.data)})},o=S(this.handlers);!(i=o()).done;){s(i.value)}}}},{key:"responseItemsByRemovingPrivateProperties",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&this.isNativeExtension(t))return e;var r=['autoupdateDisabled','permissions','active'];return n&&(r=r.concat(['hosted_url','local_url'])),e.map(function(e){var t=r.slice();if(n&&e.content_type!==F.a.ServerExtension&&t.push('url'),!e.content||Object(_.A)(e.content))return e;for(var a={},i=0,s=Object.entries(e.content);i<s.length;i++){var o=s[i],c=l(o,2),u=c[0],p=c[1];t.includes(u)||(a[u]=p)}return Zt(Zt({},e),{},{content:a})})}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=t.data.content_types.filter(function(e){return nn.includes(e)}).sort(),a=[{name:E.StreamItems,content_types:r}];this.runWithPermissions(e.uuid,a,function(){Qt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t,contentTypes:r});for(var a,i=[],s=S(r);!(a=s()).done;){var o=a.value;Object(_.o)(i,n.itemManager.nonErroredItemsForContentType(o))}n.sendItemsInReply(e.uuid,i,t)})}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:E.StreamContextItem}];this.runWithPermissions(e.uuid,r,function(){Qt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t});for(var r,a=S(n.handlersForArea(e.area));!(r=a()).done;){var i=r.value;if(i.contextRequestHandler){var s=i.contextRequestHandler(e.uuid);s&&n.sendContextItemInReply(e.uuid,s,t)}}})}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){for(var t,n=[],r=S(this.handlersForArea(e.area));!(t=r()).done;){var a=t.value;if(a.contextRequestHandler){var i=a.contextRequestHandler(e.uuid);i&&n.push(i.uuid)}}return n}},{key:"handlersForArea",value:function(e){return this.handlers.filter(function(t){return t.areas.includes(e)})}},{key:"handleSaveItemsMessage",value:function(e,t){for(var n,r=this,a=t.data.items,i=[],s=this.itemIdsInContextJurisdictionForComponent(e),o=a.slice(),c=S(a.slice());!(n=c()).done;){var u=n.value;if(s.includes(u.uuid)){i.push({name:E.StreamContextItem}),Object(_.M)(o,u);break}}if(o.length>0){var l=$t()(o.map(function(e){return e.content_type})).sort();i.push({name:E.StreamItems,content_types:l})}this.runWithPermissions(e.uuid,i,function(){var n,i,s,o,c,u,l,p,d,h,f,v,y,g,m;return b.async(function(k){for(;;)switch(k.prev=k.next){case 0:a=r.responseItemsByRemovingPrivateProperties(a,e,!0),n=Object(Ke.b)(a),i=r.itemManager.findItems(n,!0),s=0,o=0,c=S(i);case 6:if((u=c()).done){k.next=13;break}if(l=u.value){k.next=10;break}return k.abrupt("continue",11);case 10:l.locked&&(at()(a,{uuid:l.uuid}),s++,l.content_type===F.a.Note&&o++);case 11:k.next=6;break;case 13:if(1!==o){k.next=18;break}return r.alertService.alert('The note you are attempting to save has editing disabled','Note has Editing Disabled'),k.abrupt("return");case 18:if(!(s>0)){k.next=23;break}return p=1===s?'item':o===s?'notes':'items',d=1===s?'has':'have',r.alertService.alert("".concat(s," ").concat(p," you are attempting to save ").concat(d," editing disabled."),'Items have Editing Disabled'),k.abrupt("return");case 23:h=a.map(function(e){return Object(Ee.f)(e,ht.a.ComponentRetrieved)}),f=S(h);case 25:if((v=f()).done){k.next=38;break}if(y=v.value,g=r.itemManager.findItem(y.uuid)){k.next=34;break}return m=nt(y),k.next=32,b.awrap(r.itemManager.insertItem(m));case 32:k.next=36;break;case 34:if(y.content_type===g.content_type){k.next=36;break}throw Error('Extension is trying to modify content type of item.');case 36:k.next=25;break;case 38:return k.next=40,b.awrap(r.itemManager.changeItems(n,function(t){var n=Object(_.O)(h,{uuid:t.getUuid()});t.mergePayload(n);var r=Object(_.O)(a,{uuid:t.getUuid()});if(r.clientData){var i=Object(_.a)(t.getItem().getDomainData(rn)||{});i[e.getClientDataKey()]=r.clientData,t.setDomainData(i,rn)}},T.c.UserInteraction,ht.a.ComponentRetrieved,e.uuid));case 40:r.syncService.sync().then(function(){var n=w({},t);n.action=E.SaveSuccess,r.replyToMessage(e,t,{}),r.handleMessage(e,n)}).catch(function(){var n=w({},t);n.action=E.SaveError,r.replyToMessage(e,t,{error:E.SaveError}),r.handleMessage(e,n)});case 41:case"end":return k.stop()}},null,null,null,Promise)})}},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,a=this.itemManager.findItem(r.uuid),i=[{name:E.StreamItems,content_types:[a.content_type]}];this.runWithPermissions(e.uuid,i,function(){var r;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(n.itemManager.duplicateItem(a.uuid));case 2:r=i.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(r,e)});case 5:case"end":return i.stop()}},null,null,null,Promise)})}},{key:"handleCreateItemsMessage",value:function(e,t){var n=this,r=t.data.item?[t.data.item]:t.data.items,a=$t()(r.map(function(e){return e.content_type})),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:r=n.responseItemsByRemovingPrivateProperties(r,e),a=[],i=function(t){var r,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(t.uuid){o.next=4;break}return o.next=3,b.awrap(I.GenerateUuid());case 3:t.uuid=o.sent;case 4:return r=Object(Ee.f)(t,ht.a.ComponentCreated),i=nt(r),o.next=8,b.awrap(n.itemManager.insertItem(i));case 8:return s=o.sent,o.next=11,b.awrap(n.itemManager.changeItem(s.uuid,function(n){if(t.clientData){var r=Object(_.a)(s.getDomainData(rn)||{});r[e.getClientDataKey()]=t.clientData,n.setDomainData(r,rn)}},T.c.UserInteraction,ht.a.ComponentCreated,e.uuid));case 11:a.push(s);case 12:case"end":return o.stop()}},null,null,null,Promise)},s=S(r);case 4:if((o=s()).done){l.next=10;break}return c=o.value,l.next=8,b.awrap(i(c));case 8:l.next=4;break;case 10:n.syncService.sync(),u=t.action===E.CreateItem?{item:n.jsonForItem(a[0],e)}:{items:a.map(function(t){return n.jsonForItem(t,e)})},n.replyToMessage(e,t,u);case 13:case"end":return l.stop()}},null,null,null,Promise)})}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=t.data.items.filter(function(e){return nn.includes(e.content_type)}),a=$t()(r.map(function(e){return e.content_type})).sort(),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return i=1===(a=r).length?'item':'items',s=null,p.next=5,b.awrap(n.alertService.confirm("Are you sure you want to delete ".concat(a.length," ").concat(i,"?")));case 5:if(!p.sent){p.next=25;break}o=S(a);case 8:if((c=o()).done){p.next=21;break}if(u=c.value,l=n.itemManager.findItem(u.uuid)){p.next=14;break}return n.alertService.alert('The item you are trying to delete cannot be found.'),p.abrupt("continue",19);case 14:if(![F.a.Component,F.a.Theme].includes(l.content_type)){p.next=17;break}return p.next=17,b.awrap(n.deactivateComponent(l.uuid));case 17:return p.next=19,b.awrap(n.itemManager.setItemToBeDeleted(l.uuid,ht.a.ComponentRetrieved));case 19:p.next=8;break;case 21:n.syncService.sync(),s={deleted:!0},p.next=26;break;case 25:s={deleted:!1};case 26:n.replyToMessage(e,t,s);case 27:case"end":return p.stop()}},null,null,null,Promise)})}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,t.data.permissions,function(){n.replyToMessage(e,t,{approved:!0})})}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,[],function(){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(n.itemManager.changeComponent(e.uuid,function(e){e.componentData=t.data.componentData}));case 2:n.syncService.sync();case 3:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"handleToggleComponentMessage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.toggleComponent(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"toggleComponent",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.area!==L.ComponentArea.Modal){s.next=4;break}this.openModalComponent(e),s.next=29;break;case 4:if(!e.active){s.next=9;break}return s.next=7,b.awrap(this.deactivateComponent(e.uuid));case 7:s.next=29;break;case 9:if(e.content_type!==F.a.Theme){s.next=27;break}return t=e,n=this.getActiveThemes(),s.next=14,b.awrap(this.activateComponent(e.uuid));case 14:if(t.isLayerable()){s.next=25;break}return s.next=17,b.awrap(Object(_.P)(10));case 17:r=S(n);case 18:if((a=r()).done){s.next=25;break}if(!(i=a.value)||i.isLayerable()){s.next=23;break}return s.next=23,b.awrap(this.deactivateComponent(i.uuid));case 23:s.next=18;break;case 25:s.next=29;break;case 27:return s.next=29,b.awrap(this.activateComponent(e.uuid));case 29:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.itemManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){var r=this.findComponent(e);t=Object(_.a)(t);for(var a,i=r.permissions,s=function(e){var n=i.find(function(t){return t.name===e.name});if(!n)return"continue";var r=e.content_types;if(!r)return Object(_.p)(t,e),"continue";for(var a,s=S(n.content_types);!(a=s()).done;){var o=a.value;Object(_.M)(r,o)}0===r.length&&Object(_.p)(t,e)},o=S(t.slice());!(a=o()).done;)s(a.value);t.length>0?this.promptForPermissions(r,t,function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:e&&n();case 1:case"end":return t.stop()}},null,null,null,Promise)}):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,a={component:e,permissions:t,permissionsString:this.permissionsStringForPermissions(t,e),actionBlock:n,callback:function(n){var i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(i=r.findComponent(e.uuid),!n){p.next=9;break}for(r.log('Changing component to expand permissions',e),s=Object(_.a)(i.permissions),o=function(e){var t=s.find(function(t){return t.name===e.name});if(t){var n=t.content_types||[];t.content_types=$t()(n.concat(e.content_types))}else s.push(e)},c=S(t);!(u=c()).done;)l=u.value,o(l);return p.next=8,b.awrap(r.itemManager.changeItem(e.uuid,function(e){e.permissions=s}));case 8:r.syncService.sync();case 9:r.permissionDialogs=r.permissionDialogs.filter(function(r){if(r===a)return r.actionBlock&&r.actionBlock(n),!1;var i;return!!(r.component!==e||r.permissions!==t&&(i=t,r.permissions.some(function(e){return!i.find(function(t){return JSON.stringify(t)===JSON.stringify(e)})})))||(n&&r.actionBlock&&r.actionBlock(n),!1)}),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 11:case"end":return p.stop()}},null,null,null,Promise)}},i=Qt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(a),i?this.log('Existing dialog, not presenting.'):this.presentPermissionsDialog(a)}},{key:"presentPermissionsDialog",value:function(e){throw'Must override SNComponentManager.presentPermissionsDialog'}},{key:"openModalComponent",value:function(e){throw'Must override SNComponentManager.openModalComponent'}},{key:"registerHandler",value:function(e){var t=this;return this.handlers.push(e),function(){var n=Qt()(t.handlers,{identifier:e.identifier});n?Object(_.M)(t.handlers,n):t.log('Attempting to deregister non-existing handler')}}},{key:"findOrCreateDataForComponent",value:function(e){var t=this.componentState[e];return t||(t={},this.componentState[e]=t),t}},{key:"setReadonlyStateForComponent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.findOrCreateDataForComponent(e.uuid);r.readonly=t,r.lockReadonly=n}},{key:"getReadonlyStateForComponent",value:function(e){var t=this.findOrCreateDataForComponent(e.uuid);return{readonly:t.readonly,lockReadonly:t.lockReadonly}}},{key:"registerComponentWindow",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return(n=this.findOrCreateDataForComponent(e.uuid)).window===t&&this.log('Web > componentManager','attempting to re-register same component window.'),this.log('Web > componentManager > registerComponentWindow','component: ',e,'window: ',t),n.window=t,r.next=6,b.awrap(I.GenerateUuid());case 6:n.sessionKey=r.sent,this.sendMessageToComponent(e,{action:E.ComponentRegistered,sessionKey:n.sessionKey,componentData:e.componentData,data:{uuid:e.uuid,environment:(s=this.environment,o=void 0,(g(o={},he.Web,'web'),g(o,he.Desktop,'desktop'),g(o,he.Mobile,'mobile'),o)[s]),platform:(a=this.platform,i=void 0,(g(i={},fe.MacWeb,'mac-web'),g(i,fe.MacDesktop,'mac-desktop'),g(i,fe.LinuxWeb,'linux-web'),g(i,fe.LinuxDesktop,'linux-desktop'),g(i,fe.WindowsWeb,'windows-web'),g(i,fe.WindowsDesktop,'windows-desktop'),g(i,fe.Ios,'ios'),g(i,fe.Android,'android'),i)[a]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(e),this.desktopManager&&this.desktopManager.notifyComponentActivation(e);case 10:case"end":return r.stop()}var a,i,s,o},null,this,null,Promise)}},{key:"activateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Activating component',e),(t=this.findComponent(e)).active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!0}));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"onComponentIframeDestroyed",value:function(e){this.deregisterComponent(e)}},{key:"deregisterComponent",value:function(e){this.log('Degregistering component',e),delete this.componentState[e],this.streamObservers=this.streamObservers.filter(function(t){return t.componentUuid!==e}),this.contextStreamObservers=this.contextStreamObservers.filter(function(t){return t.componentUuid!==e});var t=this.findComponent(e);(null===t||void 0===t?void 0:t.area)===L.ComponentArea.Themes&&this.postActiveThemesToAllComponents()}},{key:"deactivateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Deactivating component',e),null===(t=this.findComponent(e))||void 0===t||!t.active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!1}));case 5:this.findOrCreateDataForComponent(e).sessionKey=void 0,this.deregisterComponent(e);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deleteComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isComponentActive",value:function(e){return e.active}},{key:"allComponentIframes",value:function(){return this.isMobile?[]:Array.from(document.getElementsByTagName('iframe'))}},{key:"iframeForComponent",value:function(e){for(var t,n=S(this.allComponentIframes());!(t=n()).done;){var r=t.value;if(r.dataset.componentId===e)return r}}},{key:"handleSetSizeEvent",value:function(e,t){var n=function(e,n){var r=Object(_.A)(n.width)?n.width:"".concat(t.width,"px"),a=Object(_.A)(n.height)?n.height:"".concat(t.height,"px");e&&e.setAttribute('style',"width:".concat(r,"; height:").concat(a,";"))};if(e.area===L.ComponentArea.Rooms||e.area===L.ComponentArea.Modal){var r=e.area===L.ComponentArea.Rooms?'inner':'outer',a=document.getElementById("component-content-".concat(r,"-").concat(e.uuid));a&&n(a,t)}else{var i=this.iframeForComponent(e.uuid);if(!i)return;if(n(i,t),e.area===L.ComponentArea.EditorStack){var s=i.parentElement;s&&n(s,t)}}}},{key:"editorForNote",value:function(e){for(var t,n,r=S(this.componentsForArea(L.ComponentArea.Editor));!(t=r()).done;){var a=t.value;if(a.isExplicitlyEnabledForItem(e.uuid))return a}return this.isMobile?e.mobilePrefersPlainEditor||(n=this.getDefaultEditor()):e.prefersPlainEditor||(n=this.getDefaultEditor()),n&&!n.isExplicitlyDisabledForItem(e.uuid)?n:void 0}},{key:"getDefaultEditor",value:function(){var e=this.componentsForArea(L.ComponentArea.Editor);return this.isMobile?e.filter(function(e){return e.isMobileDefault})[0]:e.filter(function(e){return e.isDefaultEditor()})[0]}},{key:"permissionsStringForPermissions",value:function(e,t){if(0===e.length)return'.';var n=[],r=[];return e.forEach(function(e){switch(e.name){case E.StreamItems:if(!e.content_types)return;e.content_types.forEach(function(e){var t=Object(F.c)(e);t?n.push("".concat(t,"s")):n.push("items of type ".concat(e))});break;case E.StreamContextItem:var a,i=(g(a={},L.ComponentArea.EditorStack,'working note'),g(a,L.ComponentArea.NoteTags,'working note'),g(a,L.ComponentArea.Editor,'working note'),a);r.push(i[t.area])}}),n=$t()(n),r=$t()(r),0===n.length&&0===r.length?'.':n.concat(r).join(', ')+'.'}},{key:"isDesktop",get:function(){return this.environment===he.Desktop}},{key:"isMobile",get:function(){return this.environment===he.Mobile}},{key:"components",get:function(){var e=this.itemManager.getDisplayableItems(F.a.Component),t=this.itemManager.getDisplayableItems(F.a.Theme);return e.concat(t)}}]),n})(R.a),sn=(function(e){d(n,e);var t=k(n);function n(){var e;return v(this,n),(e=t.call(this)).changeObservers=[],e.emitQueue=[],e.overwriteProtection=[F.a.ItemsKey],e.collection=new mt,e}return y(n,[{key:"getMasterCollection",value:function(){return bt.FromCollection(this.collection)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.changeObservers.length=0,this.resetState()}},{key:"resetState",value:function(){this.collection=new mt}},{key:"find",value:function(e){return this.collection.findAll(e)}},{key:"emitCollection",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.emitPayloads(e.all(),e.source,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"emitPayload",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.emitPayloads([e],t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitPayloads",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return 0===e.length&&console.warn('Attempting to emit 0 payloads.'),a.abrupt("return",new Promise(function(a){r.emitQueue.push({payloads:e,source:t,sourceKey:n,resolve:a}),1===r.emitQueue.length&&r.popQueue()}));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"popQueue",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=this.emitQueue[0],t=this.mergePayloadsOntoMaster(e.payloads),n=t.changed,r=t.inserted,a=t.discarded,i=t.ignored,this.notifyChangeObservers(n,r,a,i,e.source,e.sourceKey),Object(_.M)(this.emitQueue,e),e.resolve(n.concat(r,a)),this.emitQueue.length>0&&this.popQueue();case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"mergePayloadsOntoMaster",value:function(e){for(var t,n=[],r=[],a=[],i=[],s=S(e);!(t=s()).done;){var o=t.value;if(o.uuid&&o.content_type){var c=this.collection.find(o.uuid);if(o.errorDecrypting&&c&&!c.errorDecrypting&&this.overwriteProtection.includes(o.content_type))i.push(o);else{var u=c?Object(Ee.g)(c,o):o;u.discardable?(this.collection.discard(u),a.push(u)):(this.collection.set(u),c?n.push(u):r.push(u))}}else console.error('Payload is corrupt:',o)}return{changed:n,inserted:r,discarded:a,ignored:i}}},{key:"addObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var a={types:e,priority:r,callback:t};return this.changeObservers.push(a),function(){Object(_.M)(n.changeObservers,a)}}},{key:"notifyChangeObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return t.includes(F.a.Any)?e.slice():e.slice().filter(function(e){return t.includes(e.content_type)})},c=S(this.changeObservers.slice().sort(function(e,t){return e.priority<t.priority?-1:1}));!(s=c()).done;){var u=s.value;u.callback(o(e,u.types),o(t,u.types),o(n,u.types),o(r,u.types),a,i)}}},{key:"importPayloads",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new Dt(this.getMasterCollection(),bt.WithPayloads(e,ht.a.FileImport),void 0),r.next=3,b.awrap(t.resultingCollection());case 3:return n=r.sent,r.next=6,b.awrap(this.emitCollection(n));case 6:return r.abrupt("return",Object(Ke.b)(n.payloads));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removePayloadLocally",value:function(e){this.collection.discard(e)}}]),n})(R.a),on=n(9),cn=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).itemManager=e,a.syncService=r,a.resolveQueue=[],a.registeredPredicates=[],a.itemManager=e,a.syncService=r,a.addObservers(),a}return y(n,[{key:"deinit",value:function(){this.syncService=void 0,this.itemManager=void 0,this.resolveQueue.length=0,this.registeredPredicates.length=0,this.removeItemObserver(),this.removeItemObserver=void 0,this.removeSyncObserver(),this.removeSyncObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"popResolveQueue",value:function(){var e=this.resolveQueue.slice();return this.resolveQueue=[],e}},{key:"addObservers",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n){if(t.length>0){var r=t.filter(function(e){return e.errorDecryptingValueChanged});r.length>0&&(e.resolveQueue=e.resolveQueue.concat(r))}n.length>0&&(e.resolveQueue=e.resolveQueue.concat(n))}),this.removeSyncObserver=this.syncService.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==on.a.DownloadFirstSyncCompleted&&t!==on.a.FullSyncCompleted){n.next=3;break}return n.next=3,b.awrap(e.resolveSingletonsForItems(e.popResolveQueue(),t));case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"registerPredicate",value:function(e){this.registeredPredicates.push(e)}},{key:"validItemsMatchingPredicate",value:function(e){return this.itemManager.itemsMatchingPredicate(e).filter(function(e){return!e.errorDecrypting})}},{key:"resolveSingletonsForItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=this;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:n=function(e){for(var t,n=S(p.registeredPredicates);!(t=n()).done;){var r=t.value;if(e.satisfiesPredicate(r))return p.validItemsMatchingPredicate(r)}},r=function(e){return e.isSingleton?p.validItemsMatchingPredicate(e.singletonPredicate):null},a=function(e){var t=r(e);return t&&t.length>0?t:n(e)},i=[],s=S(e);case 5:if((o=s()).done){d.next=17;break}if(c=o.value,!i.includes(c)){d.next=9;break}return d.abrupt("continue",15);case 9:if(u=a(c),Object(_.o)(i,u||[]),u&&!(u.length<=1)){d.next=13;break}return d.abrupt("continue",15);case 13:return d.next=15,b.awrap(this.handleStrategy(u,c.singletonStrategy));case 15:d.next=5;break;case 17:if(!(i.length>0&&t===on.a.FullSyncCompleted)){d.next=20;break}return d.next=20,b.awrap(null===(l=this.syncService)||void 0===l?void 0:l.sync());case 20:case"end":return d.stop()}},null,this,null,Promise)}},{key:"handleStrategy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t===T.e.KeepEarliest){a.next=2;break}throw'Unhandled singleton strategy';case 2:return n=e.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at<t.created_at?-1:1}),r=Object(_.d)(n,0),a.next=6,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(r)));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"findSingleton",value:function(e){var t=this.validItemsMatchingPredicate(e);if(t.length>0)return t[0]}},{key:"findOrCreateSingleton",value:function(e,t,n){var r,a,i,s,o,c,u,l=this;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(r=this.findSingleton(e),Object(_.w)(r)){p.next=3;break}return p.abrupt("return",r);case 3:if(this.syncService.getLastSyncDate()){p.next=13;break}return i=this.itemManager.addObserver(t,function(t,n){if(n.length>0){var r=l.itemManager.subItemsMatchingPredicates(n,[e]);r.length>0&&(a=r[0])}}),p.next=7,b.awrap(this.syncService.sync());case 7:if(i(),!a){p.next=10;break}return p.abrupt("return",a);case 10:if(!((s=this.validItemsMatchingPredicate(e)).length>0)){p.next=13;break}return p.abrupt("return",s[0]);case 13:if(!(o=this.itemManager.itemsMatchingPredicate(e).filter(function(e){return e.errorDecrypting})).length){p.next=17;break}return p.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(o)));case 17:return p.t0=Object(Ee.e),p.next=20,b.awrap(I.GenerateUuid());case 20:return p.t1=p.sent,p.t2=t,p.t3=n,p.t4=new Date,p.t5={uuid:p.t1,content_type:p.t2,content:p.t3,dirty:!0,dirtiedDate:p.t4},c=(0,p.t0)(p.t5),p.next=28,b.awrap(this.itemManager.emitItemFromPayload(c));case 28:return u=p.sent,this.syncService.sync(),p.abrupt("return",u);case 31:case"end":return p.stop()}},null,this,null,Promise)}}]),n})(R.a);function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach(function(t){pn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dn,hn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c){var u;return v(this,n),(u=t.call(this)).itemManager=e,u.alertService=r,u.previousPasswords=[],u.itemManager=e,u.alertService=r,u.deviceInterface=a,u.httpService=i,u.payloadManager=s,u.protocolService=o,u.syncService=c,u.previousPasswords=[],u}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.alertService=void 0,this.deviceInterface=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.syncService=void 0,this.previousPasswords.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"getExtensions",value:function(){return this.itemManager.nonErroredItemsForContentType(F.a.ActionsExtension)}},{key:"extensionsInContextOfItem",value:function(e){return this.getExtensions().filter(function(t){return t.supported_types.includes(e.content_type)||t.actionsWithContextForItem(e).length>0})}},{key:"loadExtensionInContextOfItem",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n={content_type:t.content_type,item_uuid:t.uuid},u.next=3,b.awrap(this.httpService.getAbsolute(e.url,n).catch(function(e){return console.error('Error loading extension',e),null}));case 3:if(r=u.sent){u.next=6;break}return u.abrupt("return");case 6:return a=r.description||e.description,i=r.supported_types||e.supported_types,s=r.actions?r.actions.map(function(e){return new ae(e)}):[],(o=new se(e,T.c.UserInteraction)).deprecation=r.deprecation,o.description=a,o.supported_types=i,o.actions=s,c=o.getResult(),u.abrupt("return",nt(c));case 16:case"end":return u.stop()}},null,this,null,Promise)}},{key:"runAction",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=e.verb,a.next='get'===a.t0?3:'render'===a.t0?7:'show'===a.t0?11:'post'===a.t0?15:19;break;case 3:return a.next=5,b.awrap(this.handleGetAction(e,n));case 5:return r=a.sent,a.abrupt("break",20);case 7:return a.next=9,b.awrap(this.handleRenderAction(e,n));case 9:return r=a.sent,a.abrupt("break",20);case 11:return a.next=13,b.awrap(this.handleShowAction(e));case 13:return r=a.sent,a.abrupt("break",20);case 15:return a.next=17,b.awrap(this.handlePostAction(e,t));case 17:return r=a.sent,a.abrupt("break",20);case 19:return a.abrupt("break",20);case 20:return a.abrupt("return",r);case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleGetAction",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.alertService.confirm("Are you sure you want to replace the current note contents with this action's results?"));case 2:if(!n.sent){n.next=7;break}return n.abrupt("return",this.runConfirmedGetAction(e,t));case 7:return n.abrupt("return",{error:{status:1,message:'Action canceled by user.'}});case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"runConfirmedGetAction",value:function(e,t){var n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.httpService.getAbsolute(e.url).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return a.alertService.alert(t.message),{error:t}}));case 2:if(!(n=i.sent).error){i.next=5;break}return i.abrupt("return",n);case 5:return i.next=7,b.awrap(this.payloadByDecryptingResponse(n,t));case 7:return r=i.sent,i.next=10,b.awrap(this.payloadManager.emitPayload(Object(Ee.b)(r,{dirty:!0,dirtiedDate:new Date}),ht.a.RemoteActionRetrieved));case 10:return this.syncService.sync(),i.abrupt("return",ln(ln({},n),{},{item:n.item}));case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleRenderAction",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.httpService.getAbsolute(e.url).then(function(e){var n,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(r.payloadByDecryptingResponse(e,t));case 2:if(!(n=i.sent)){i.next=6;break}return a=nt(n),i.abrupt("return",ln(ln({},e),{},{item:a}));case 6:case"end":return i.stop()}},null,null,null,Promise)}).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return r.alertService.alert(t.message),{error:t}}));case 2:return n=a.sent,a.abrupt("return",n);case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingResponse",value:function(e,t,n){var r,a,i,s,o,c,u,l,p,d,h,f=arguments;return b.async(function(v){for(;;)switch(v.prev=v.next){case 0:return r=f.length>3&&void 0!==f[3]?f[3]:[],a=Object(Ee.e)(e.item),v.next=4,b.awrap(this.protocolService.payloadByDecryptingPayload(a,n));case 4:if((i=v.sent).errorDecrypting){v.next=7;break}return v.abrupt("return",i);case 7:if(s=e.keyParams||e.auth_params){v.next=11;break}return this.alertService.alert("We were unable to decrypt this revision using your current keys, and this revision is missing metadata that would allow us to try different keys to decrypt it. This can likely be fixed with some manual intervention. Please email hello@standardnotes.org for assistance."),v.abrupt("return",void 0);case 11:o=this.protocolService.createKeyParams(s),c=S(this.previousPasswords);case 13:if((u=c()).done){v.next=30;break}if(l=u.value,!r.includes(l)){v.next=17;break}return v.abrupt("continue",28);case 17:return r.push(l),v.next=20,b.awrap(this.protocolService.computeRootKey(l,o));case 20:if(p=v.sent){v.next=23;break}return v.abrupt("continue",28);case 23:return v.next=25,b.awrap(this.payloadByDecryptingResponse(e,t,p,r));case 25:if(!(d=v.sent)){v.next=28;break}return v.abrupt("return",d);case 28:v.next=13;break;case 30:return v.next=32,b.awrap(t());case 32:if(h=v.sent,!this.previousPasswords.includes(h)){v.next=35;break}return v.abrupt("return",void 0);case 35:return this.previousPasswords.push(h),v.abrupt("return",this.payloadByDecryptingResponse(e,t,n));case 37:case"end":return v.stop()}},null,this,null,Promise)}},{key:"handlePostAction",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=e.access_type===q.Decrypted,s.next=3,b.awrap(this.outgoingPayloadForItem(t,n));case 3:return r=s.sent,a={items:[r]},s.abrupt("return",this.httpService.postAbsolute(e.url,a).then(function(e){return e}).catch(function(e){return console.error('Action error response:',e),i.alertService.alert('An issue occurred while processing this action. Please try again.'),e}));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleShowAction",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.deviceInterface.openUrl(e.url),t.abrupt("return",{});case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"outgoingPayloadForItem",value:function(e){var t,n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=a.length>1&&void 0!==a[1]&&a[1],n=t?Re.b.FileDecrypted:Re.b.FileEncrypted,i.next=4,b.awrap(this.protocolService.payloadByEncryptingPayload(e.payloadRepresentation(),n));case 4:return r=i.sent,i.abrupt("return",r.ejected());case 6:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),fn=(function(){function e(t,n,r){v(this,e),this.deviceInterface=t,this.identifier=n,this.environment=r}return y(e,null,[{key:"version",value:function(){throw Error('Must override')}}]),e})(),vn=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getJsonParsedRawStorageValue(D.AllAccountKeyParamsKey));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getRawKeychainValue());case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getRawStorageValue('mk'));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!!Pe(this.environment)}}],[{key:"version",value:function(){return"1.0.0"}}]),n})(),yn=(function(){function e(t){v(this,e),this.services=t,this.stageHandlers={},this.registerStageHandlers()}return y(e,[{key:"registerStageHandler",value:function(e,t){this.stageHandlers[e]=t}},{key:"markDone",value:function(){var e;null===(e=this.onDoneHandler)||void 0===e||e.call(this),this.onDoneHandler=void 0}},{key:"promptForPasscodeUntilCorrect",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new ye([new ge(te.None)],ne.Migration,!1),r.abrupt("return",new Promise(function(r){n.services.challengeService.addChallengeObserver(t,{onNonvalidatedSubmit:function(a){var i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return i=a.values[0],s=i.value,o.next=4,b.awrap(e(s));case 4:o.sent?(n.services.challengeService.completeChallenge(t),r(s)):n.services.challengeService.setValidationStatusForChallenge(t,i,!1);case 6:case"end":return o.stop()}},null,null,null,Promise)}}),n.services.challengeService.promptForChallengeResponse(t)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}},{key:"onDone",value:function(e){this.onDoneHandler=e}},{key:"handleStage",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t=this.stageHandlers[e])){n.next=4;break}return n.next=4,b.awrap(t());case 4:case"end":return n.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){throw'Must override'}}]),e})();!(function(e){e.CreatedAt="created_at",e.UpdatedAt="userModifiedDate",e.Title="title"})(dn||(dn={}));var gn=(function(e){d(n,mt);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).displaySortBy={},e.displayFilter={},e.filteredMap={},e.sortedMap={},e}return y(n,[{key:"set",value:function(e){e=Object(_.W)(Array.isArray(e)?e:[e],'uuid'),p(f(n.prototype),"set",this).call(this,e),this.filterSortElements(e)}},{key:"discard",value:function(e){e=Array.isArray(e)?e:[e],p(f(n.prototype),"discard",this).call(this,e),this.filterSortElements(e)}},{key:"setDisplayOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn.CreatedAt,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc',r=arguments.length>3?arguments[3]:void 0,a=this.displaySortBy[e],i=this.displayFilter[e];if(!a||a.key!==t||a.dir!==n||i||r){this.displaySortBy[e]=t?{key:t,dir:n}:void 0,this.displayFilter[e]=r,this.filteredMap[e]={},this.sortedMap[e]=[];var s=this.all(e);s.length>0&&this.filterSortElements(s)}}},{key:"displayElements",value:function(e){var t=this.sortedMap[e];if(!t)throw Error("Attempting to access display elements for\n        non-configured content type ".concat(e));return t.slice()}},{key:"filterSortElements",value:function(e){if(0!==Object.keys(this.displaySortBy).length){for(var t,n=new Set,r=S(e);!(t=r()).done;){var a=t.value,i=a.content_type,s=this.displaySortBy[i];if(s){var o=this.displayFilter[i],c=this.filteredMap[i],u=this.sortedMap[i],l=c[a.uuid],p=Object(_.w)(l)?void 0:u[l];if(!(a.deleted||!this.map[a.uuid])&&(!o||o(a)))if(Object(_.w)(p))u.push(a),n.add(i);else{var d=p.errorDecrypting?void 0:p[s.key],h=a[s.key];u[l]=a;var f=p.pinned!==a.pinned;Object(_.g)(d,h)&&!f||n.add(i)}else Object(_.w)(l)||(delete c[a.uuid],u[l]=void 0,n.add(i))}}for(var v,y=S(n.values());!(v=y()).done;){var g=v.value;this.resortContentType(g)}}}},{key:"resortContentType",value:function(e){for(var t,n=this.sortedMap[e],r=this.displaySortBy[e],a=this.filteredMap[e],i=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t)return-1;if(!n)return 1;if(!a){if(t.pinned&&n.pinned)return e(t,n,!0);if(t.pinned)return-1;if(n.pinned)return 1}var i=t[r.key]||'',s=n[r.key]||'',o=1;return'asc'===r.dir&&(o*=-1),r.key===dn.Title?o*i.localeCompare(s,'en',{numeric:!0}):i>s?-1*o:i<s?1*o:0},s=[],o=0,c=S(n.sort(function(e,t){return i(e,t)}));!(t=c()).done;){var u=t.value;u&&(s.push(u),a[u.uuid]=o,o++)}this.sortedMap[e]=s}}]),n})();function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(n),!0).forEach(function(t){wn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=(function(e){d(n,yn);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).legacyReader=new vn(r.services.deviceInterface,r.services.identifier,r.services.environment),r}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Se(e.services.environment)){t.next=5;break}return t.next=3,b.awrap(e.migrateStorageStructureForWebDesktop());case 3:t.next=8;break;case 5:if(!Pe(e.services.environment)){t.next=8;break}return t.next=8,b.awrap(e.migrateStorageStructureForMobile());case 8:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.StorageDecrypted_09,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.migrateArbitraryRawStorageToManagedStorageAllPlatforms());case 2:if(!Pe(e.services.environment)){t.next=5;break}return t.next=5,b.awrap(e.migrateMobilePreferences());case 5:return t.next=7,b.awrap(e.migrateSessionStorage());case 7:return t.next=9,b.awrap(e.deleteLegacyStorageValues());case 9:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.LoadingDatabase_11,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createDefaultItemsKeyForAllPlatforms());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"migrateStorageStructureForWebDesktop",value:function(){var e,t,n,r,a,i,s,c,u,l,p,d,h,f,v,y,m,w,k,x,S;return b.async(function(P){for(;;)switch(P.prev=P.next){case 0:return t=this.services.deviceInterface,g(e={},_e.Wrapped,{}),g(e,_e.Unwrapped,{}),g(e,_e.Nonwrapped,{}),n=e,P.next=4,b.awrap(this.legacyReader.getAccountKeyParams());case 4:return(r=P.sent)&&(n.nonwrapped[o.RootKeyParams]=r),P.next=8,b.awrap(t.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 8:if(!(a=P.sent)){P.next=37;break}return i=Object(Ee.e)(a),P.next=13,b.awrap(this.webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage(i));case 13:if(s=P.sent,c=s.key,u=s.decryptedStoragePayload,l=s.keyParams,n.nonwrapped[o.RootKeyWrapperKeyParams]=l.getPortableValue(),p=Object(_.a)(u.contentObject.storage),d=Object(_.E)(p),h=d[D.AllAccountKeyParamsKey],n.nonwrapped[o.RootKeyParams]=h,f=c,!!Object(_.w)(d.mk)){P.next=32;break}return P.next=27,b.awrap(this.webDesktopHelperExtractAndWrapAccountKeysFromValueStore(c,h,d));case 27:v=P.sent,y=v.accountKey,m=v.wrappedKey,f=y,n.nonwrapped[o.WrappedRootKey]=m;case 32:return P.next=34,b.awrap(this.webDesktopHelperEncryptStorage(f,u,d));case 34:n.wrapped=P.sent,P.next=55;break;case 37:return P.next=39,b.awrap(this.services.deviceInterface.getRawStorageValue('ak'));case 39:return w=P.sent,P.next=42,b.awrap(this.services.deviceInterface.getRawStorageValue('mk'));case 42:if(k=P.sent,!w&&!k){P.next=55;break}if(P.t0=null===r||void 0===r?void 0:r.version,P.t0){P.next=49;break}return P.next=48,b.awrap(this.getFallbackRootKeyVersion());case 48:P.t0=P.sent;case 49:return x=P.t0,P.next=52,b.awrap(Ve.Create({masterKey:k,dataAuthenticationKey:w,version:x,keyParams:r}));case 52:return S=P.sent,P.next=55,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(S.getKeychainValue(),this.services.identifier));case 55:return P.next=57,b.awrap(this.allPlatformHelperSetStorageStructure(n));case 57:case"end":return P.stop()}},null,this,null,Promise)}},{key:"allPlatformHelperSetStorageStructure",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Ie.defaultValuesObject(e.wrapped,e.unwrapped,e.nonwrapped))[_e.Unwrapped]=void 0,n.next=4,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.StorageObject),JSON.stringify(t)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.WebPasscodeParamsKey));case 2:return t=s.sent,n=this.services.protocolService.createKeyParams(t),s.next=6,b.awrap(this.promptForPasscodeUntilCorrect(function(t){return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(i.services.protocolService.computeRootKey(t,n));case 2:return a=s.sent,s.next=5,b.awrap(i.services.protocolService.payloadByDecryptingPayload(e,a));case 5:return r=s.sent,s.abrupt("return",!r.errorDecrypting);case 7:case"end":return s.stop()}},null,null,null,Promise)}));case 6:return s.abrupt("return",{decryptedStoragePayload:r,key:a,keyParams:n});case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperExtractAndWrapAccountKeysFromValueStore",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.t0=null===t||void 0===t?void 0:t.version,c.t0){c.next=5;break}return c.next=4,b.awrap(this.getFallbackRootKeyVersion());case 4:c.t0=c.sent;case 5:return a=c.t0,c.next=8,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:a,keyParams:t}));case 8:if(i=c.sent,delete n.mk,delete n.pw,delete n.ak,s=Object(Ee.e)(i),!e){c.next=17;break}return c.next=16,b.awrap(this.services.protocolService.payloadByEncryptingPayload(s,Re.b.LocalStorageEncrypted,e));case 16:o=c.sent;case 17:return c.abrupt("return",{accountKey:i,wrappedKey:null===(r=o)||void 0===r?void 0:r.ejected()});case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperEncryptStorage",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.services.protocolService.payloadByEncryptingPayload(Object(Ee.b)(t,{content_type:F.a.EncryptedStorage,content:n}),Re.b.LocalStoragePreferEncrypted,e));case 2:return r=a.sent,a.abrupt("return",r.ejected());case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"migrateStorageStructureForMobile",value:function(){var e,t,n,r,a,i,s,u,l,p,d,h,f,v,y,m,w,k,x,S,P,O,C,E,R=this;return b.async(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,b.awrap(this.services.deviceInterface.getRawKeychainValue());case 2:return n=M.sent,M.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileWrappedRootKeyKey));case 5:if(M.t0=M.sent,M.t0){M.next=8;break}M.t0=null===n||void 0===n?void 0:n.encryptedAccountKeys;case 8:return r=M.t0,M.next=11,b.awrap(this.legacyReader.getAccountKeyParams());case 11:return a=M.sent,M.next=14,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 14:return i=M.sent,M.next=17,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(c.MobileFirstRun));case 17:return s=M.sent,g(t={},_e.Nonwrapped,(g(e={},o.WrappedRootKey,r),g(e,o.RootKeyWrapperKeyParams,Object(_.I)(i,['hash'])),g(e,o.RootKeyParams,a),g(e,c.MobileFirstRun,s),e)),g(t,_e.Unwrapped,{}),g(t,_e.Wrapped,{}),u=t,M.next=21,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileBiometricsPrefs));case 21:return(l=M.sent)&&(u.nonwrapped[o.BiometricsState]=l.enabled,u.nonwrapped[o.MobileBiometricsTiming]=l.timing),M.next=25,b.awrap(this.services.deviceInterface.getRawStorageValue(D.MobilePasscodeKeyboardType));case 25:if((p=M.sent)&&(u.nonwrapped[o.MobilePasscodeKeyboardType]=p),!i){M.next=75;break}if(h=this.services.protocolService.createKeyParams(i),f=function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(R.promptForPasscodeUntilCorrect(function(t){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(R.services.protocolService.computeRootKey(t,h));case 2:if(e=u.sent,!(i=null===n||void 0===n?void 0:null===(a=n.offline)||void 0===a?void 0:a.pw)){u.next=8;break}return u.abrupt("return",e.serverPassword===i);case 8:if(!r){u.next=15;break}return u.next=11,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),e));case 11:return s=u.sent,u.abrupt("return",!s.errorDecrypting);case 15:return u.next=17,b.awrap(R.services.deviceInterface.getAllRawDatabasePayloads(R.services.identifier));case 17:if(o=u.sent[0]){u.next=20;break}throw Error('Passcode only migration aborting due to missing keychain.offline.pw');case 20:return u.next=22,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(o),e));case 22:return c=u.sent,u.abrupt("return",!c.errorDecrypting);case 24:case"end":return u.stop()}},null,null,null,Promise)}));case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},null,null,null,Promise)},u.nonwrapped[o.MobilePasscodeTiming]=null===n||void 0===n?void 0:null===(d=n.offline)||void 0===d?void 0:d.timing,!r){M.next=55;break}return M.next=34,b.awrap(f());case 34:return v=M.sent,M.next=37,b.awrap(this.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),v));case 37:if(y=M.sent,m=y.contentObject.accountKeys,M.t1=m.version||(null===a||void 0===a?void 0:a.version),M.t1){M.next=44;break}return M.next=43,b.awrap(this.getFallbackRootKeyVersion());case 43:M.t1=M.sent;case 44:return w=M.t1,k=Object(Ee.b)(y,{content:{masterKey:m.mk,dataAuthenticationKey:m.ak,version:w,keyParams:a,accountKeys:void 0}}),M.next=48,b.awrap(this.services.protocolService.payloadByEncryptingPayload(k,Re.b.LocalStoragePreferEncrypted,v));case 48:return x=M.sent,u.nonwrapped[o.WrappedRootKey]=x.ejected(),m.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",m.jwt),M.next=53,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 53:M.next=73;break;case 55:if(r){M.next=73;break}return M.next=58,b.awrap(f());case 58:return S=M.sent,M.t2=Object(Ee.e),M.next=62,b.awrap(I.GenerateUuid());case 62:return M.t3=M.sent,M.t4=Object(Ke.a)(u.unwrapped),M.t5=F.a.EncryptedStorage,M.t6={uuid:M.t3,content:M.t4,content_type:M.t5},P=(0,M.t2)(M.t6),M.next=69,b.awrap(this.services.protocolService.payloadByEncryptingPayload(P,Re.b.LocalStoragePreferEncrypted,S));case 69:return O=M.sent,u.wrapped=O.ejected(),M.next=73,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 73:M.next=89;break;case 75:if(!!Object(_.w)(null===n||void 0===n?void 0:n.mk)){M.next=89;break}if(M.t7=n.version||(null===a||void 0===a?void 0:a.version),M.t7){M.next=82;break}return M.next=81,b.awrap(this.getFallbackRootKeyVersion());case 81:M.t7=M.sent;case 82:return C=M.t7,M.next=85,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:C,keyParams:a}));case 85:return E=M.sent,M.next=88,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(E.getKeychainValue(),this.services.identifier));case 88:n.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",n.jwt);case 89:return M.next=91,b.awrap(this.allPlatformHelperSetStorageStructure(u));case 91:case"end":return M.stop()}},null,this,null,Promise)}},{key:"getFallbackRootKeyVersion",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.services.deviceInterface.getAllRawDatabasePayloads(this.services.identifier));case 2:if(e=n.sent[0]){n.next=5;break}return n.abrupt("return",Q.a.V002);case 5:return t=Object(Ee.e)(e),n.abrupt("return",t.version||Q.a.V002);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateArbitraryRawStorageToManagedStorageAllPlatforms",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getAllRawStorageKeyValues());case 2:e=p.sent,t=Object(_.H)(D),n=function(e){try{return JSON.parse(e)}catch(t){return e}},r=this.services.identifier,a=S(e);case 7:if((i=a()).done){p.next=20;break}if(s=i.value,o=s.key,c=s.value,u=r&&r.length>0&&o.startsWith(r),!t.includes(o)&&!u){p.next=14;break}return p.abrupt("continue",18);case 14:if(Object(_.w)(c)){p.next=18;break}return l=n(c),p.next=18,b.awrap(this.services.storageService.setValue(o,l));case 18:p.next=7;break;case 20:case"end":return p.stop()}},null,this,null,Promise)}},{key:"deleteLegacyStorageValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e=['mk','ak','pw','encryptionKey','authKey','jwt','ephemeral','cachedThemes'],t=[].concat(m(Object(_.H)(o)),m(Object(_.H)(D)),e),n=S(t);case 3:if((r=n()).done){i.next=9;break}return a=r.value,i.next=7,b.awrap(this.services.deviceInterface.removeRawStorageValue(a));case 7:i.next=3;break;case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"migrateMobilePreferences",value:function(){var e,t,n,r,a,i,s,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileLastExportDate));case 2:return e=p.sent,p.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileDoNotWarnUnsupportedEditors));case 5:return t=p.sent,p.next=8,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileOptionsState));case 8:return n=p.sent,r={},n&&(u=n.sortBy,r={sortBy:'updated_at'===u||'client_updated_at'===u?dn.UpdatedAt:u,sortReverse:null!==(a=n.sortReverse)&&void 0!==a&&a,hideNotePreview:null!==(i=n.hidePreviews)&&void 0!==i&&i,hideDate:null!==(s=n.hideDates)&&void 0!==s&&s,hideTags:null!==(c=n.hideTags)&&void 0!==c&&c}),l=bn(bn({},r),{},{lastExportDate:null!==e&&void 0!==e?e:void 0,doNotShowAgainUnsupportedEditors:null!==t&&void 0!==t&&t}),p.next=14,b.awrap(this.services.storageService.setValue(o.MobilePreferences,l));case 14:case"end":return p.stop()}},null,this,null,Promise)}},{key:"migrateSessionStorage",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return e='user',i.next=3,b.awrap(this.services.storageService.getValue("jwt"));case 3:return t=i.sent,i.next=6,b.awrap(this.services.storageService.getValue(e));case 6:if(n=i.sent,t||n&&(t=n.jwt),t){i.next=15;break}if(!!Object(_.w)(n)){i.next=14;break}t='junk-value',i.next=15;break;case 14:return i.abrupt("return");case 15:return r=new Ae(t),i.next=18,b.awrap(this.services.storageService.setValue(o.Session,r));case 18:if(!Pe(this.services.environment)){i.next=25;break}return i.next=21,b.awrap(this.services.storageService.getValue(e));case 21:if(!(a=i.sent)||!a.server){i.next=25;break}return i.next=25,b.awrap(this.services.storageService.setValue(o.ServerHost,a.server));case 25:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createDefaultItemsKeyForAllPlatforms",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e=this.services.protocolService.getRootKey())){i.next=18;break}return i.next=4,b.awrap(this.services.protocolService.getRootKeyParams());case 4:return t=i.sent,n=Q.a.V001,i.t0=Object(Ee.e),i.next=9,b.awrap(I.GenerateUuid());case 9:return i.t1=i.sent,i.t2=F.a.ItemsKey,i.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t.version||n}),i.t4=new Date,i.t5={uuid:i.t1,content_type:i.t2,content:i.t3,dirty:!0,dirtiedDate:i.t4},r=(0,i.t0)(i.t5),a=nt(r),i.next=18,b.awrap(this.services.itemManager.emitItemFromPayload(a.payloadRepresentation(),ht.a.LocalChanged));case 18:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return"2.0.0"}}]),n})(),xn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createNewDefaultItemsKeyIfNecessary());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"createNewDefaultItemsKeyIfNecessary",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.services.protocolService.needsNewRootKeyBasedItemsKey()){e.next=3;break}return e.next=3,b.awrap(this.services.protocolService.createNewDefaultItemsKey());case 3:case"end":return e.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.0.15'}}]),n})(),Sn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.FullSyncCompleted_13,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteBatchManagerSingleton());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteBatchManagerSingleton",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e='org.standardnotes.batch-manager',t=H.a.CompoundPredicate([new H.a('content_type','=',F.a.Component),new H.a('package_info.identifier','=',e)]),!(n=this.services.singletonManager.findSingleton(t))){r.next=6;break}return r.next=6,b.awrap(this.services.itemManager.setItemToBeDeleted(n.uuid));case 6:case"end":return r.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.7.0'}}]),n})(),Pn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteMfaItems());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteMfaItems",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e='SF|MFA',t=this.services.itemManager.getItems(e),n=S(t);case 3:if((r=n()).done){i.next=10;break}return a=r.value,this.services.itemManager.removeItemLocally(a),i.next=8,b.awrap(this.services.storageService.deletePayloadWithId(a.uuid));case 8:i.next=3;break;case 10:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.20.0'}}]),n})(),On=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getStorage",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=O(this.identifier,s.StorageObject),r.next=3,b.awrap(this.deviceInterface.getRawStorageValue(e));case 3:return t=r.sent,n=t?JSON.parse(t):void 0,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getNonWrappedValue",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getStorage());case 2:if(n=r.sent){r.next=5;break}return r.abrupt("return",void 0);case 5:return r.abrupt("return",null===(t=n[_e.Nonwrapped])||void 0===t?void 0:t[e]);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getNonWrappedValue(o.RootKeyParams));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getNonWrappedValue(o.WrappedRootKey));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!0}}],[{key:"version",value:function(){return"2.0.0"}}]),n})();function Cn(e){for(var t,n=S(Object.values(i).sort(function(e,t){return-1*P(e.version(),t.version())}));!(t=n()).done;){var r=t.value;if(r.version()===e)return r;if(x(r.version(),e))return r}throw Error("Cannot find reader for version ".concat(e))}function Dn(e,t,n,r){return new(Cn(e))(t,n,r)}var _n=(function(e){d(n,yn);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).didPreRun=!1,e}return y(n,[{key:"preRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storeVersionNumber());case 2:this.didPreRun=!0;case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.needsKeychainRepair());case 2:if(!t.sent){t.next=5;break}return t.next=5,b.awrap(e.repairMissingKeychain());case 5:e.markDone();case 6:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"getStoredVersion",value:function(){var e=O(this.services.identifier,s.SnjsVersion);return this.services.deviceInterface.getRawStorageValue(e)}},{key:"storeVersionNumber",value:function(){var e,t,n,r,a,i,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return e=O(this.services.identifier,s.SnjsVersion),c.next=3,b.awrap(this.getStoredVersion());case 3:if(c.sent){c.next=38;break}t=!1,n=0,r=['migrations','ephemeral','user','cachedThemes','syncToken','encryptedStorage'];case 8:if(!(n<r.length)){c.next=19;break}return a=r[n],c.next=12,b.awrap(this.services.deviceInterface.getRawStorageValue(a));case 12:if(!c.sent){c.next=16;break}return t=!0,c.abrupt("break",19);case 16:n++,c.next=8;break;case 19:if(!t){c.next=24;break}return c.next=22,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"1.0.0"));case 22:c.next=38;break;case 24:return i=O(this.services.identifier,"last_migration_timestamp"),c.next=27,b.awrap(this.services.deviceInterface.getRawStorageValue(i));case 27:if(o=c.sent,!!Object(_.w)(o)){c.next=36;break}return c.next=32,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"2.0.0"));case 32:return c.next=34,b.awrap(this.services.deviceInterface.removeRawStorageValue("last_migration_timestamp"));case 34:c.next=38;break;case 36:return c.next=38,b.awrap(this.services.deviceInterface.setRawStorageValue(e,h));case 38:case"end":return c.stop()}},null,this,null,Promise)}},{key:"loadReader",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.reader){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,b.awrap(this.getStoredVersion());case 4:e=t.sent,this.reader=Dn(e,this.services.deviceInterface,this.services.identifier,this.services.environment);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"needsKeychainRepair",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.didPreRun){t.next=2;break}throw Error('Attempting to access specialized function before prerun');case 2:if(this.reader){t.next=5;break}return t.next=5,b.awrap(this.loadReader());case 5:if(this.reader.usesKeychain){t.next=8;break}return t.abrupt("return",!1);case 8:return t.next=10,b.awrap(this.reader.getAccountKeyParams());case 10:if(e=t.sent,!Object(_.w)(e)){t.next=14;break}return t.abrupt("return",!1);case 14:return t.next=16,b.awrap(this.reader.hasPasscode());case 16:if(!t.sent){t.next=19;break}return t.abrupt("return",!1);case 19:return t.next=21,b.awrap(this.reader.hasNonWrappedAccountKeys());case 21:if(!t.sent){t.next=24;break}return t.abrupt("return",!1);case 24:return t.abrupt("return",!0);case 25:case"end":return t.stop()}},null,this,null,Promise)}},{key:"repairMissingKeychain",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getStoredVersion());case 2:return e=a.sent,a.next=5,b.awrap(this.reader.getAccountKeyParams());case 5:return t=a.sent,n=new ye([new ge(te.None,void 0,j.R.PasswordInputPlaceholder,!0)],ne.Custom,!1,j.I.Title,j.I.Text),a.abrupt("return",new Promise(function(a){r.services.challengeService.addChallengeObserver(n,{onNonvalidatedSubmit:function(i){var s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return s=i.values[0].value,o=r.services.protocolService.createKeyParams(t),d.next=4,b.awrap(r.services.protocolService.computeRootKey(s,o));case 4:return c=d.sent,d.next=7,b.awrap(r.services.deviceInterface.getAllRawDatabasePayloads(r.services.identifier));case 7:if(u=d.sent,(l=u.find(function(e){var t=Object(Ee.e)(e);return Object(Re.a)(t.content_type)}))||(l=u[0]),l){d.next=12;break}throw we.a.error(Error('Attempting keychain recovery validation but no items present.'));case 12:return d.next=14,b.awrap(r.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(l),c));case 14:if(!d.sent.errorDecrypting){d.next=19;break}r.services.challengeService.setValidationStatusForChallenge(n,i.values[0],!1),d.next=29;break;case 19:if("1.0.0"!==e){d.next=24;break}return d.next=22,b.awrap(r.services.deviceInterface.legacy_setRawKeychainValue({mk:c.masterKey,ak:c.dataAuthenticationKey,version:o.version}));case 22:d.next=27;break;case 24:return p=c.getKeychainValue(),d.next=27,b.awrap(r.services.deviceInterface.setNamespacedKeychainValue(p,r.services.identifier));case 27:a(),r.services.challengeService.completeChallenge(n);case 29:case"end":return d.stop()}},null,null,null,Promise)}}),r.services.challengeService.promptForChallengeResponse(n)}));case 8:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(),En=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).services=e,r}return y(n,[{key:"deinit",value:function(){this.services=void 0,this.activeMigrations&&(this.activeMigrations.length=0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.runBaseMigrationPreRun());case 2:return r.t0=b,r.t1=n,r.next=6,b.awrap(this.getStoredSnjsVersion());case 6:return r.t2=r.sent,r.t3=r.t1.getRequiredMigrations.call(r.t1,r.t2),r.next=10,r.t0.awrap.call(r.t0,r.t3);case 10:if(e=r.sent,this.activeMigrations=this.instantiateMigrationClasses(e),!(this.activeMigrations.length>0)){r.next=17;break}Object(_.F)(this.activeMigrations).onDone(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(t.markMigrationsAsDone());case 2:case"end":return e.stop()}},null,null,null,Promise)}),r.next=19;break;case 17:return r.next=19,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 19:case"end":return r.stop()}},null,this,null,Promise)}},{key:"markMigrationsAsDone",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"runBaseMigrationPreRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.baseMigration=new _n(this.services),e.next=3,b.awrap(this.baseMigration.preRun());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:return t.next=4,b.awrap(this.handleStage(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleApplicationEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.a.SignedIn){t.next=3;break}return t.next=3,b.awrap(this.handleStage(ve.SignedIn_30));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPendingMigrations",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=n,t.next=4,b.awrap(this.getStoredSnjsVersion());case 4:return t.t2=t.sent,t.t3=t.t1.getRequiredMigrations.call(t.t1,t.t2),t.next=8,t.t0.awrap.call(t.t0,t.t3);case 8:if(e=t.sent,t.t4=e.length>0,t.t4){t.next=14;break}return t.next=13,b.awrap(this.baseMigration.needsKeychainRepair());case 13:t.t4=t.sent;case 14:return t.abrupt("return",t.t4);case 15:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getStoredSnjsVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.services.deviceInterface.getRawStorageValue(O(this.services.identifier,s.SnjsVersion)));case 2:if(e=t.sent){t.next=5;break}throw we.a.error(Error('Snjs version missing from storage, run base migration.'));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"instantiateMigrationClasses",value:function(e){var t=this;return e.map(function(e){return new e(t.services)})}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.baseMigration.handleStage(e));case 2:t=S(this.activeMigrations);case 3:if((n=t()).done){a.next=9;break}return r=n.value,a.next=7,b.awrap(r.handleStage(e));case 7:a.next=3;break;case 9:case"end":return a.stop()}},null,this,null,Promise)}}],[{key:"getRequiredMigrations",value:function(e){var t,n,r,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:t=[],n=Object.keys(a).map(function(e){return a[e]}).sort(function(e,t){return P(e.version(),t.version())}),r=S(n);case 3:if((i=r()).done){c.next=11;break}if(s=i.value,(o=s.version())!==e){c.next=8;break}return c.abrupt("continue",9);case 8:x(e,o)&&t.push(s);case 9:c.next=3;break;case 11:return c.abrupt("return",t);case 12:case"end":return c.stop()}},null,null,null,Promise)}}]),n})(R.a),Rn=n(14),In=(function(){function e(t){v(this,e),this.crypto=t}return y(e,[{key:"firstHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"secondHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"splitKey",value:function(e,t){for(var n=e.length/t,r=[],a=0;a<t;a++){var i=e.slice(n*a,n*(a+1));r.push(i)}return r}},{key:"createItemsKey",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.generateNewItemsKeyContent());case 2:return e=n.sent,n.t0=Object(Ee.e),n.next=6,b.awrap(I.GenerateUuid());case 6:return n.t1=n.sent,n.t2=F.a.ItemsKey,n.t3=Object(Ke.a)(e),n.t4={uuid:n.t1,content_type:n.t2,content:n.t3},t=(0,n.t0)(n.t4),n.abrupt("return",nt(t));case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,n){var r,a,i;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==ue.a.DecryptedBareObject){n.next=4;break}return n.abrupt("return",Object(Ee.c)({content:e.content}));case 4:if(t!==ue.a.DecryptedBase64String){n.next=13;break}return r=JSON.stringify(e.content),n.next=8,b.awrap(this.crypto.base64Encode(r));case 8:return a=n.sent,i=Q.a.V000Base64Decrypted+a,n.abrupt("return",Object(Ee.c)({content:i}));case 13:throw"Must override generateEncryptedParameters to handle format ".concat(t,".");case 14:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var n,r,a,i;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=e.format)!==ue.a.DecryptedBareObject){t.next=5;break}return t.abrupt("return",e);case 5:if(n!==ue.a.DecryptedBase64String){t.next=20;break}return r=e.contentString.substring(Q.a.VersionLength,e.contentString.length),t.prev=7,t.next=10,b.awrap(this.crypto.base64Decode(r));case 10:i=t.sent,a=JSON.parse(i),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),a=e.content;case 17:return t.abrupt("return",Object(Ee.a)(e,{content:a}));case 20:throw Error("Must override generateDecryptedParameters to handle format ".concat(n,"."));case 21:case"end":return t.stop()}},null,this,[[7,14]],Promise)}}]),e})(),Mn='00000000000000000000000000000000',An=(function(e){d(n,In);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'AES-256'}},{key:"generateNewItemsKeyContent",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=Rn.a.EncryptionKeyLength,r.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=r.sent,n={itemsKey:t,version:Q.a.V001},r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Rn.a.PbkdfMinCost,o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.a.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+'SN'+a));case 6:return i=o.sent,s=Object(A.a)({email:e,pw_cost:r,pw_nonce:a,pw_salt:i,version:Q.a.V001,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcDecrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"encryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcEncrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c,u,l;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){d.next=2;break}return d.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){d.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r){d.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return d.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.a.EncryptionKeyLength));case 8:return a=d.sent,d.next=11,b.awrap(this.encryptString(a,r.itemsKey));case 11:return i=d.sent,d.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=d.sent,d.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=d.sent,d.next=20,b.awrap(this.encryptString(JSON.stringify(e.content),s));case 20:return c=d.sent,u=r.keyVersion+c,d.next=24,b.awrap(this.crypto.hmac256(u,o));case 24:return l=d.sent,d.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:u,enc_item_key:i,auth_hash:l}));case 26:case"end":return d.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){l.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:return a=e.enc_item_key,a=this.version+a,i=this.encryptionComponentsFromString(a,t.itemsKey),l.next=11,b.awrap(this.decryptString(i.ciphertext,i.key));case 11:if(s=l.sent){l.next=15;break}return console.error('Error decrypting parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 15:return l.next=17,b.awrap(this.firstHalfOfKey(s));case 17:return o=l.sent,c=this.encryptionComponentsFromString(e.contentString,o),l.next=21,b.awrap(this.decryptString(c.ciphertext,c.key));case 21:if(u=l.sent){l.next=26;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 27:case"end":return l.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString",value:function(e,t){var n=e.substring(0,Q.a.VersionLength);return{ciphertext:e.substring(Q.a.VersionLength,e.length),version:n,key:t}}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content001.pw_salt,t.content001.pw_cost,Rn.a.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,2),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],version:Q.a.V001,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V001}}]),n})();function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach(function(t){Kn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=(function(e){d(n,An);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.b.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V002},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Object(_.F)(Rn.b.PbkdfCostsUsed),o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.b.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+':'+a));case 6:return i=o.sent,s=Object(A.b)({email:e,pw_nonce:a,pw_cost:r,pw_salt:i,version:Q.a.V002,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcDecrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcEncrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptTextParams",value:function(e,t,n,r,a,i){var s,o,c,u,l,p,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,b.awrap(this.crypto.generateRandomKey(Rn.b.EncryptionIvLength));case 2:return s=h.sent,h.next=5,b.awrap(this.encryptString002(e,t,s));case 5:return o=h.sent,c=[a,r,s,o].join(':'),h.next=9,b.awrap(this.crypto.hmac256(c,n));case 9:if(u=h.sent,l=[a,u,r,s,o],!i){h.next=16;break}return h.next=14,b.awrap(this.crypto.base64Encode(JSON.stringify(i.content)));case 14:p=h.sent,l.push(p);case 16:return d=l.join(':'),h.abrupt("return",d);case 18:case"end":return h.stop()}},null,this,null,Promise)}},{key:"decryptTextParams",value:function(e,t,n,r,a,i){var s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n){o.next=2;break}throw'Attempting to decryptTextParams with null encryptionKey';case 2:return o.next=4,b.awrap(this.crypto.hmac256(e,i));case 4:if(s=o.sent,!1!==this.crypto.timingSafeEqual(a,s)){o.next=8;break}return we.a.error(Error('Auth hash does not match.')),o.abrupt("return",null);case 8:return o.abrupt("return",this.decryptString002(t,n,r));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(t=this.encryptionComponentsFromString002(e.enc_item_key),n=t.keyParams){i.next=4;break}return i.abrupt("return",void 0);case 4:return i.t0=JSON,i.next=7,b.awrap(this.crypto.base64Decode(n));case 7:return i.t1=i.sent,r=i.t0.parse.call(i.t0,i.t1),a=Tn({},r),i.abrupt("return",a);case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r&&r.itemsKey){u.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return u.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.b.EncryptionKeyLength));case 8:return a=u.sent,u.next=11,b.awrap(this.encryptTextParams(a,r.itemsKey,r.dataAuthenticationKey,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 11:return i=u.sent,u.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=u.sent,u.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=u.sent,u.next=20,b.awrap(this.encryptTextParams(JSON.stringify(e.content),s,o,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 20:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:c,enc_item_key:i}));case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u,l,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){h.next=3;break}return h.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){h.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:if(t&&t.itemsKey){h.next=8;break}throw Error('Attempting to generateDecryptedParameters with no itemsKey.');case 8:return a=e.enc_item_key,i=this.encryptionComponentsFromString002(a,t.itemsKey,t.dataAuthenticationKey),h.next=12,b.awrap(this.decryptTextParams(i.ciphertextToAuth,i.contentCiphertext,i.encryptionKey,i.iv,i.authHash,i.authKey));case 12:if(s=h.sent){h.next=16;break}return console.error('Error decrypting item_key parameters',e),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 16:return h.next=18,b.awrap(this.firstHalfOfKey(s));case 18:return o=h.sent,h.next=21,b.awrap(this.secondHalfOfKey(s));case 21:return c=h.sent,u=this.encryptionComponentsFromString002(e.contentString,o,c),h.next=25,b.awrap(this.decryptTextParams(u.ciphertextToAuth,u.contentCiphertext,u.encryptionKey,u.iv,u.authHash,u.authKey));case 25:if(l=h.sent){h.next=30;break}return h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 30:return h.prev=30,h.t0=JSON,h.next=34,b.awrap(this.crypto.base64Decode(u.keyParams));case 34:h.t1=h.sent,d=h.t0.parse.call(h.t0,h.t1),h.next=40;break;case 38:h.prev=38,h.t2=h.catch(30);case 40:return h.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(l),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,auth_params:d,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 41:case"end":return h.stop()}},null,this,[[30,38]],Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content002.pw_salt,t.content002.pw_cost,Rn.b.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,3),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],dataAuthenticationKey:r[2],version:Q.a.V002,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString002",value:function(e,t,n){var r=e.split(':');return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],keyParams:r[5],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(':'),encryptionKey:t,authKey:n}}},{key:"version",get:function(){return Q.a.V002}}]),n})(),Ln=(function(e){d(n,Fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.c.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V003},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.generateSalt(t.content003.identifier,Q.a.V003,Rn.c.PbkdfCost,t.content003.pw_nonce));case 2:return n=s.sent,s.next=5,b.awrap(this.crypto.pbkdf2(e,n,Rn.c.PbkdfCost,Rn.c.PbkdfOutputLength));case 5:return r=s.sent,a=this.splitKey(r,3),s.next=9,b.awrap(Ve.Create({serverPassword:a[0],masterKey:a[1],dataAuthenticationKey:a[2],version:Q.a.V003,keyParams:t.getPortableValue()}));case 9:return i=s.sent,s.abrupt("return",i);case 11:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V003,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.c.SaltSeedLength));case 3:return a=s.sent,i=Object(A.c)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"generateSalt",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.sha256([e,'SF',t,n,r].join(':')));case 2:return a=i.sent,i.abrupt("return",a);case 4:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V003}}]),n})();function Un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach(function(t){Vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bn,Wn=(function(e){d(n,Ln);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'XChaCha20-Poly1305'}},{key:"generateNewItemsKeyContent",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 2:return e=n.sent,t={itemsKey:e,version:Q.a.V004},n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateSalt004",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.crypto.sha256([e,t].join(":")));case 2:return n=r.sent,r.abrupt("return",Object(_.T)(n,Rn.d.ArgonSaltLength));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V004,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.d.ArgonSaltSeedLength));case 3:return a=s.sent,i=Object(A.d)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"encryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n){a.next=2;break}throw'encryptString null nonce';case 2:if(t){a.next=4;break}throw'encryptString null rawKey';case 4:return a.t0=this.crypto,a.t1=e,a.t2=n,a.t3=t,a.next=10,b.awrap(this.authenticatedDataToString(r));case 10:return a.t4=a.sent,a.abrupt("return",a.t0.xchacha20Encrypt.call(a.t0,a.t1,a.t2,a.t3,a.t4));case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.crypto.xchacha20Decrypt(e,n,t,r));case 1:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateEncryptedProtocolString",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionNonceLength));case 2:return r=o.sent,a=Q.a.V004,o.next=6,b.awrap(this.encryptString004(e,t,r,n));case 6:return i=o.sent,o.t0=a,o.t1=r,o.t2=i,o.next=12,b.awrap(this.authenticatedDataToString(n));case 12:return o.t3=o.sent,s=[o.t0,o.t1,o.t2,o.t3],o.abrupt("return",s.join(":"));case 15:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.format===ue.a.EncryptedString){a.next=2;break}throw Error('Attempting to get embedded key params of already decrypted item');case 2:return t=this.deconstructEncryptedPayloadString(e.enc_item_key),n=t.rawAuthenticatedData,a.next=6,b.awrap(this.stringToAuthenticatedData(n));case 6:return r=a.sent,a.abrupt("return",r);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateAuthenticatedDataForPayload",value:function(e,t){var n={u:e.uuid,v:Q.a.V004};if(Object(Re.a)(e.content_type))return Nn(Nn({},n),{},{kp:t.keyParams.content});if(!(t instanceof J))throw Error('Attempting to use non-items key for regular item.');return n}},{key:"authenticatedDataToString",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.base64Encode(JSON.stringify(Object(_.Q)(Object(_.K)(e)))));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"stringToAuthenticatedData",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=JSON,r.next=3,b.awrap(this.crypto.base64Decode(e));case 3:return r.t1=r.sent,n=r.t0.parse.call(r.t0,r.t1),r.abrupt("return",Object(_.Q)(Nn(Nn({},n),t)));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(e.uuid){u.next=6;break}throw'payload.uuid cannot be null';case 6:if(r&&r.itemsKey){u.next=8;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 8:return u.next=10,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 10:return a=u.sent,i=JSON.stringify(e.content),s=this.generateAuthenticatedDataForPayload(e,r),u.next=15,b.awrap(this.generateEncryptedProtocolString(i,a,s));case 15:return o=u.sent,u.next=18,b.awrap(this.generateEncryptedProtocolString(a,r.itemsKey,s));case 18:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:o,enc_item_key:c}));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.uuid){l.next=5;break}throw'encryptedParameters.uuid cannot be null';case 5:if(t&&t.itemsKey){l.next=7;break}throw'Attempting to generateDecryptedParameters with no itemsKey.';case 7:return a=this.deconstructEncryptedPayloadString(e.enc_item_key),l.next=10,b.awrap(this.stringToAuthenticatedData(a.rawAuthenticatedData,{u:e.uuid,v:e.version}));case 10:return i=l.sent,l.next=13,b.awrap(this.authenticatedDataToString(i));case 13:return s=l.sent,l.next=16,b.awrap(this.decryptString004(a.ciphertext,t.itemsKey,a.nonce,s));case 16:if(o=l.sent){l.next=20;break}return console.error('Error decrypting itemKey parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 20:return c=this.deconstructEncryptedPayloadString(e.contentString),l.next=23,b.awrap(this.decryptString004(c.ciphertext,o,c.nonce,s));case 23:if(u=l.sent){l.next=28;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 28:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 29:case"end":return l.stop()}},null,this,null,Promise)}},{key:"deconstructEncryptedPayloadString",value:function(e){var t=e.split(":");return{version:t[0],nonce:t[1],ciphertext:t[2],rawAuthenticatedData:t[3]}}},{key:"deriveKey",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.generateSalt004(t.content004.identifier,t.content004.pw_nonce));case 2:return n=o.sent,o.next=5,b.awrap(this.crypto.argon2(e,n,Rn.d.ArgonIterations,Rn.d.ArgonMemLimit,Rn.d.ArgonOutputKeyBytes));case 5:return r=o.sent,a=this.splitKey(r,2),i=a[0],s=a[1],o.abrupt("return",Ve.Create({masterKey:i,serverPassword:s,version:Q.a.V004,keyParams:t.getPortableValue()}));case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V004}}]),n})();function Hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(n),!0).forEach(function(t){qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e[e.RootKeyNone=0]="RootKeyNone",e[e.RootKeyOnly=1]="RootKeyOnly",e[e.RootKeyPlusWrapper=2]="RootKeyPlusWrapper",e[e.WrapperOnly=3]="WrapperOnly"})(Bn||(Bn={}));var Yn=Q.a.V003,Gn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).itemManager=e,c.payloadManager=r,c.storageService=i,c.identifier=s,c.operators={},c.keyMode=Bn.RootKeyNone,c.keyObservers=[],c.itemManager=e,c.payloadManager=r,c.deviceInterface=a,c.storageService=i,c.crypto=o,Object(_.y)()?I.SetGenerators(c.crypto.generateUUID,void 0):I.SetGenerators(c.crypto.generateUUID,c.crypto.generateUUIDSync),Object.defineProperty(u(c),'rootKey',{enumerable:!1,writable:!0}),c.removeItemsObserver=c.itemManager.addObserver([F.a.ItemsKey],function(e,t){e.concat(t).length>0&&c.decryptErroredItems()}),c}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.deviceInterface=void 0,this.storageService=void 0,this.crypto.deinit(),this.crypto=void 0,this.operators={},this.keyObservers.length=0,this.removeItemsObserver(),this.removeItemsObserver=null,this.rootKey=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:return e=a.sent,a.next=5,b.awrap(this.getAccountKeyParams());case 5:return t=a.sent,a.next=8,b.awrap(this.hasRootKeyWrapper());case 8:if(n=a.sent,r=!Object(_.w)(e)||!Object(_.w)(t),!n||!r){a.next=14;break}this.keyMode=Bn.RootKeyPlusWrapper,a.next=27;break;case 14:if(!n||r){a.next=18;break}this.keyMode=Bn.WrapperOnly,a.next=27;break;case 18:if(n||!r){a.next=22;break}this.keyMode=Bn.RootKeyOnly,a.next=27;break;case 22:if(n||r){a.next=26;break}this.keyMode=Bn.RootKeyNone,a.next=27;break;case 26:throw'Invalid key mode condition';case 27:if(this.keyMode!==Bn.RootKeyOnly){a.next=33;break}return a.next=30,b.awrap(this.getRootKeyFromKeychain());case 30:return this.rootKey=a.sent,a.next=33,b.awrap(this.notifyObserversOfKeyChange());case 33:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getEncryptionSourceVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasAccount()){t.next=4;break}return t.abrupt("return",this.getUserVersion());case 4:if(!this.hasPasscode()){t.next=9;break}return t.next=7,b.awrap(this.getRootKeyWrapperKeyParams());case 7:return e=t.sent,t.abrupt("return",e.version);case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getEncryptionDisplayName",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getEncryptionSourceVersion());case 2:if(!(e=t.sent)){t.next=5;break}return t.abrupt("return",this.operatorForVersion(e).getEncryptionDisplayName());case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLatestVersion",value:function(){return Q.a.V004}},{key:"hasAccount",value:function(){switch(this.keyMode){case Bn.RootKeyNone:case Bn.WrapperOnly:return!1;case Bn.RootKeyOnly:case Bn.RootKeyPlusWrapper:return!0;default:throw Error("Unhandled keyMode value '".concat(this.keyMode,"'."))}}},{key:"getUserVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getAccountKeyParams());case 2:return e=t.sent,t.abrupt("return",null===e||void 0===e?void 0:e.version);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"upgradeAvailable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.accountUpgradeAvailable());case 2:return e=n.sent,n.next=5,b.awrap(this.passcodeUpgradeAvailable());case 5:return t=n.sent,n.abrupt("return",e||t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"accountUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"passcodeUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e.version!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"platformSupportsKeyDerivation",value:function(e){return Object(Q.b)(e.version,Q.a.V004)>=0||(!!Object(_.C)()||Object(_.y)())}},{key:"supportedVersions",value:function(){return[Q.a.V001,Q.a.V002,Q.a.V003,Q.a.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.getLatestVersion();return 1===Object(Q.b)(e,t)}},{key:"isProtocolVersionOutdated",value:function(e){var t,n=(g(t={},Q.a.V001,Date.parse('2018-01-01')),g(t,Q.a.V002,Date.parse('2020-01-01')),t)[e];return!!n&&(new Date).getTime()>n}},{key:"costMinimumForVersion",value:function(e){if(Object(Q.b)(e,Q.a.V003)>=0)throw'Cost minimums only apply to versions <= 002';if(e===Q.a.V001)return Rn.a.PbkdfMinCost;if(e===Q.a.V002)return Rn.b.PbkdfMinCost;throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===Q.a.V001)return new An(this.crypto);if(e===Q.a.V002)return new Fn(this.crypto);if(e===Q.a.V003)return new Ln(this.crypto);if(e===Q.a.V004)return new Wn(this.crypto);if(e===Q.a.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw Error("Unable to find operator for version ".concat(e))}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=t.version,r=this.operatorForVersion(n),a.abrupt("return",r.computeRootKey(e,t));case 3:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return a=r?this.operatorForVersion(r):this.defaultOperator(),i.abrupt("return",a.createRootKey(e,t,n));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"payloadContentFormatForIntent",value:function(e,t){if(t){if(e===Re.b.Sync||e===Re.b.FileEncrypted||e===Re.b.FilePreferEncrypted||e===Re.b.LocalStorageEncrypted||e===Re.b.LocalStoragePreferEncrypted)return ue.a.EncryptedString;throw'Unhandled encrypted case in protocolService.payloadContentFormatForIntent.'}if(e===Re.b.LocalStorageDecrypted||e===Re.b.LocalStoragePreferEncrypted||e===Re.b.FileDecrypted||e===Re.b.FilePreferEncrypted)return ue.a.DecryptedBareObject;if(e===Re.b.SyncDecrypted)return ue.a.DecryptedBase64String;throw'Unhandled decrypted case in protocolService.payloadContentFormatForIntent.'}},{key:"payloadByEncryptingPayload",value:function(e,t,n){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(!e.errorDecrypting){l.next=2;break}return l.abrupt("return",e);case 2:if(!e.deleted){l.next=4;break}return l.abrupt("return",e);case 4:if(!Object(_.w)(t)){l.next=6;break}throw Error('Attempting to encrypt payload with null intent');case 6:if(n||Object(Re.d)(t)){l.next=10;break}return l.next=9,b.awrap(this.keyToUseForEncryptionOfPayload(e,t));case 9:n=l.sent;case 10:if(n||!Object(Re.c)(t)){l.next=12;break}throw Error('Attempting to generate encrypted payload with no key.');case 12:if(e.format===ue.a.DecryptedBareObject){l.next=14;break}throw Error('Attempting to encrypt already encrypted payload.');case 14:if(e.content){l.next=16;break}throw Error('Attempting to encrypt payload with no content.');case 16:if(e.uuid){l.next=18;break}throw Error('Attempting to encrypt payload with no uuid.');case 18:if(!(null!==(r=n)&&void 0!==r&&r.errorDecrypting||null!==(a=n)&&void 0!==a&&a.waitingForKey)){l.next=20;break}throw Error('Attempting to encrypt payload with encrypted key.');case 20:return i=n?n.keyVersion:this.getLatestVersion(),s=this.payloadContentFormatForIntent(t,n),o=this.operatorForVersion(i),l.next=25,b.awrap(o.generateEncryptedParameters(e,s,n));case 25:if(c=l.sent){l.next=28;break}throw'Unable to generate encryption parameters';case 28:return u=Object(Ee.d)(e,t,c),l.abrupt("return",u);case 30:case"end":return l.stop()}},null,this,null,Promise)}},{key:"payloadsByEncryptingPayloads",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){u.next=11;break}return s=i.value,o=Object(_.v)(t)?t(s):t,u.next=7,b.awrap(this.payloadByEncryptingPayload(s,o,n));case 7:c=u.sent,r.push(c);case 9:u.next=2;break;case 11:return u.abrupt("return",r);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingPayload",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content){c.next=3;break}return we.a.error(Error('Attempting to decrypt payload that has no content.')),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0}));case 3:if((r=e.format)!==ue.a.DecryptedBareObject){c.next=6;break}return c.abrupt("return",e);case 6:if(t||r!==ue.a.EncryptedString){c.next=10;break}if(t=this.keyToUseForDecryptionOfPayload(e)){c.next=10;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 10:if(null===(n=t)||void 0===n||!n.errorDecrypting){c.next=12;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 12:return a=e.version,i=e.source,s=this.operatorForVersion(a),c.prev=15,c.next=18,b.awrap(s.generateDecryptedParameters(e,t));case 18:return o=c.sent,c.abrupt("return",Object(Ee.e)(e,o,i));case 22:return c.prev=22,c.t0=c.catch(15),console.error('Error decrypting payload',e,c.t0),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:case"end":return c.stop()}},null,this,[[15,22]],Promise)}},{key:"payloadsByDecryptingPayloads",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e){n.next=2;break}return n.abrupt("return",e);case 2:if(!0!==e.deleted||!Object(_.w)(e.content)){n.next=4;break}return n.abrupt("return",e);case 4:if(Object(_.A)(e.content)){n.next=7;break}return n.abrupt("return",e);case 7:return n.abrupt("return",r.payloadByDecryptingPayload(e,t));case 8:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",Promise.all(e.map(function(e){return n(e)})));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"decryptErroredItems",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==(e=this.itemManager.invalidItems.filter(function(e){return e.content_type!==F.a.ItemsKey})).length){r.next=3;break}return r.abrupt("return");case 3:return t=e.map(function(e){return e.payloadRepresentation()}),r.next=6,b.awrap(this.payloadsByDecryptingPayloads(t));case 6:return n=r.sent,r.next=9,b.awrap(this.payloadManager.emitPayloads(n,ht.a.LocalChanged));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsByDecryptingBackupFile",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v=this;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if(n=e.keyParams||e.auth_params,r=e.items,a=r.map(function(e){return Object(Ee.f)(e,ht.a.FileImport)}),i=[],!n){y.next=28;break}return s=this.createKeyParams(n),y.next=8,b.awrap(this.computeRootKey(t,s));case 8:return o=y.sent,c=a.filter(function(e){return e.content_type===F.a.ItemsKey}),y.next=12,b.awrap(this.payloadsByDecryptingPayloads(c,o));case 12:u=y.sent,l=u.map(function(e){return nt(e)}),Object(_.o)(i,u),p=function(e){var t,n,r,a;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content_type!==F.a.ItemsKey){c.next=2;break}return c.abrupt("return","continue");case 2:return c.prev=2,e.items_key_id&&(t=v.itemsKeyForPayload(e)),t||(n=u.find(function(t){return e.items_key_id===t.uuid}),r=e.version,n?t=nt(n):Object(Q.d)(s.version,Q.a.V004)?t=v.defaultItemsKeyForItemVersion(r,l):Object(Q.b)(r,Q.a.V003)<=0&&(t=o)),c.next=7,b.awrap(v.payloadByDecryptingPayload(e,t));case 7:a=c.sent,i.push(a),c.next=15;break;case 11:c.prev=11,c.t0=c.catch(2),i.push(Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting})),console.error('Error decrypting payload',e,c.t0);case 15:case"end":return c.stop()}},null,null,[[2,11]],Promise)},d=S(a);case 17:if((h=d()).done){y.next=26;break}return f=h.value,y.next=21,b.awrap(p(f));case 21:if("continue"!==y.sent){y.next=24;break}return y.abrupt("continue",24);case 24:y.next=17;break;case 26:y.next=29;break;case 28:i=a;case 29:return y.abrupt("return",i);case 30:case"end":return y.stop()}},null,this,null,Promise)}},{key:"createKeyParams",value:function(e){return Object(A.e)(e)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return t=this.itemManager.items,e===Re.b.FileDecrypted&&(t=t.filter(function(e){return e.content_type!==F.a.ItemsKey})),n=Promise.all(t.map(function(t){if(t.errorDecrypting)return t.payload.ejected();var n=Object(Ee.f)(t.payload,ht.a.FileImport);return i.payloadByEncryptingPayload(n,e).then(function(e){return e.ejected()})})),s.t0=this.getLatestVersion(),s.next=6,b.awrap(n);case 6:if(s.t1=s.sent,r={version:s.t0,items:s.t1},e!==Re.b.FileEncrypted){s.next=13;break}return s.next=11,b.awrap(this.getRootKeyParams());case 11:a=s.sent,r.keyParams=null===a||void 0===a?void 0:a.getPortableValue();case 13:return s.abrupt("return",r);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"onKeyStatusChange",value:function(e){var t=this;return this.keyObservers.push(e),function(){Object(_.M)(t.keyObservers,e)}}},{key:"notifyObserversOfKeyChange",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:e=S(this.keyObservers);case 1:if((t=e()).done){r.next=7;break}return n=t.value,r.next=5,b.awrap(n());case 5:r.next=1;break;case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getRootKeyFromKeychain",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:if(e=n.sent,!Object(_.w)(e)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.t0=b,n.t1=Ve,n.t2=zn,n.t3=zn({},e),n.t4={},n.next=12,b.awrap(this.getRootKeyParams());case 12:return n.t5=n.sent,n.t6={keyParams:n.t5},n.t7=(0,n.t2)(n.t3,n.t4,n.t6),n.t8=n.t1.Create.call(n.t1,n.t7),n.next=18,n.t0.awrap.call(n.t0,n.t8);case 18:return t=n.sent,n.abrupt("return",t);case 20:case"end":return n.stop()}},null,this,null,Promise)}},{key:"saveRootKeyToKeychain",value:function(){var e,t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Object(_.w)(this.rootKey)){n.next=2;break}throw'Attempting to non-existent root key to the keychain.';case 2:if(this.keyMode===Bn.RootKeyOnly){n.next=4;break}throw'Should not be persisting wrapped key to keychain.';case 4:return e=this.rootKey.getKeychainValue(),n.abrupt("return",this.executeCriticalFunction(function(){return t.deviceInterface.setNamespacedKeychainValue(e,t.identifier)}));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasRootKeyWrapper",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){return this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper}},{key:"rootKeyNeedsUnwrapping",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.hasRootKeyWrapper());case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}e.t0=Object(_.w)(this.rootKey);case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyWrapperKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getWrappedRootKey",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.WrappedRootKey,De.Nonwrapped));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode!==Bn.WrapperOnly){e.next=4;break}return e.abrupt("return",this.getRootKeyWrapperKeyParams());case 4:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){e.next=8;break}return e.abrupt("return",this.getAccountKeyParams());case 8:if(this.keyMode!==Bn.RootKeyNone){e.next=12;break}return e.abrupt("return",void 0);case 12:throw"Unhandled key mode for getRootKeyParams ".concat(this.keyMode);case 13:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateWrappingKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:if(t=a.sent,this.keyMode!==Bn.WrapperOnly){a.next=7;break}return a.abrupt("return",this.storageService.canDecryptWithKey(e));case 7:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){a.next=15;break}return n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:return r=a.sent,a.abrupt("return",!r.errorDecrypting);case 15:throw'Unhandled case in validateWrappingKey';case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeWrappingKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=r.sent,r.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=r.sent,r.abrupt("return",n);case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"unwrapRootKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.keyMode!==Bn.WrapperOnly){a.next=3;break}return this.rootKey=e,a.abrupt("return");case 3:if(this.keyMode===Bn.RootKeyPlusWrapper){a.next=5;break}throw'Invalid key mode condition for unwrapping.';case 5:return a.next=7,b.awrap(this.getWrappedRootKey());case 7:return t=a.sent,n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:if(!(r=a.sent).errorDecrypting){a.next=16;break}throw Error('Unable to decrypt root key with provided wrapping key.');case 16:return a.next=18,b.awrap(Ve.Create(r.contentObject,r.uuid));case 18:return this.rootKey=a.sent,a.next=21,b.awrap(this.notifyObserversOfKeyChange());case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setNewRootKeyWrapper",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.keyMode!==Bn.RootKeyNone){t.next=4;break}this.keyMode=Bn.WrapperOnly,t.next=9;break;case 4:if(this.keyMode!==Bn.RootKeyOnly){t.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,t.next=9;break;case 8:throw Error('Attempting to set wrapper on already wrapped key.');case 9:return t.next=11,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 11:if(this.keyMode!==Bn.WrapperOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){t.next=26;break}if(this.keyMode!==Bn.WrapperOnly){t.next=18;break}return this.rootKey=e,t.next=16,b.awrap(this.reencryptItemsKeys());case 16:t.next=20;break;case 18:return t.next=20,b.awrap(this.wrapAndPersistRootKey(e));case 20:return t.next=22,b.awrap(this.storageService.setValue(o.RootKeyWrapperKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 22:return t.next=24,b.awrap(this.notifyObserversOfKeyChange());case 24:t.next=27;break;case 26:throw Error('Invalid keyMode on setNewRootKeyWrapper');case 27:case"end":return t.stop()}},null,this,null,Promise)}},{key:"wrapAndPersistRootKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=Object(Ee.e)(this.rootKey,{content:this.rootKey.persistableValueWhenWrapping()}),r.next=3,b.awrap(this.payloadByEncryptingPayload(t,Re.b.LocalStorageEncrypted,e));case 3:return n=r.sent,r.next=6,b.awrap(this.storageService.setValue(o.WrappedRootKey,n.ejected(),De.Nonwrapped));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removeRootKeyWrapper",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper){e.next=2;break}throw Error('Attempting to remove root key wrapper on unwrapped key.');case 2:return this.keyMode===Bn.WrapperOnly?(this.keyMode=Bn.RootKeyNone,this.rootKey=void 0):this.keyMode===Bn.RootKeyPlusWrapper&&(this.keyMode=Bn.RootKeyOnly),e.next=5,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 5:return e.next=7,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 7:if(this.keyMode!==Bn.RootKeyOnly){e.next=10;break}return e.next=10,b.awrap(this.saveRootKeyToKeychain());case 10:return e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.keyParams){n.next=2;break}throw Error('keyParams must be supplied if setting root key.');case 2:if(this.rootKey!==e){n.next=4;break}throw Error('Attempting to set root key as same current value.');case 4:if(this.keyMode!==Bn.WrapperOnly){n.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,n.next=16;break;case 8:if(this.keyMode!==Bn.RootKeyNone){n.next=12;break}this.keyMode=Bn.RootKeyOnly,n.next=16;break;case 12:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){n.next=15;break}n.next=16;break;case 15:throw Error("Unhandled key mode for setNewRootKey ".concat(this.keyMode));case 16:return this.rootKey=e,n.next=19,b.awrap(this.storageService.setValue(o.RootKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 19:if(this.keyMode!==Bn.RootKeyOnly){n.next=24;break}return n.next=22,b.awrap(this.saveRootKeyToKeychain());case 22:n.next=29;break;case 24:if(this.keyMode!==Bn.RootKeyPlusWrapper){n.next=29;break}if(t){n.next=27;break}throw Error('wrappingKey must be supplied');case 27:return n.next=29,b.awrap(this.wrapAndPersistRootKey(t));case 29:return n.next=31,b.awrap(this.notifyObserversOfKeyChange());case 31:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getRootKey",value:function(){return this.rootKey}},{key:"clearLocalKeyState",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 2:return e.next=4,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 6:return e.next=8,b.awrap(this.storageService.removeValue(o.RootKeyParams,De.Nonwrapped));case 8:return this.keyMode=Bn.RootKeyNone,this.rootKey=void 0,e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:if(n=a.sent,!(r=this.rootKey.compare(n))){a.next=11;break}return a.abrupt("return",{valid:r,artifacts:{rootKey:n}});case 11:return a.abrupt("return",{valid:!1});case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"validatePasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=a.sent,a.next=8,b.awrap(this.validateWrappingKey(n));case 8:if(!(r=a.sent)){a.next=13;break}return a.abrupt("return",{valid:r,artifacts:{wrappingKey:n}});case 13:return a.abrupt("return",{valid:!1});case 14:case"end":return a.stop()}},null,this,null,Promise)}},{key:"keyToUseForEncryptionOfPayload",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Object(_.w)(t)){s.next=2;break}throw'Intent must be supplied when looking up key for encryption of item.';case 2:if(!Object(Re.a)(e.content_type)){s.next=13;break}if(n=this.getRootKey()){s.next=10;break}if(!Object(Re.c)(t)){s.next=9;break}throw Error('Root key encryption is required but no root key is available.');case 9:return s.abrupt("return",void 0);case 10:return s.abrupt("return",n);case 13:return r=this.getDefaultItemsKey(),s.next=16,b.awrap(this.getUserVersion());case 16:if(!(a=s.sent)||a===(null===r||void 0===r?void 0:r.keyVersion)){s.next=22;break}return i=this.latestItemsKeys(),s.abrupt("return",i.find(function(e){return e.keyVersion===a}));case 22:return s.abrupt("return",r);case 23:case"end":return s.stop()}},null,this,null,Promise)}},{key:"keyToUseForDecryptionOfPayload",value:function(e){if(Object(Re.a)(e.content_type))return this.getRootKey();if(e.items_key_id)return this.itemsKeyForPayload(e);var t=e.version;if(t!==this.getLatestVersion())return this.defaultItemsKeyForItemVersion(t);we.a.error(Error('No associated key found for item encrypted with latest protocol version.'))}},{key:"onSyncEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.b.FullSyncCompleted){t.next=3;break}return t.next=3,b.awrap(this.handleFullSyncCompletion());case 3:if(e!==At.b.DownloadFirstSyncCompleted){t.next=6;break}return t.next=6,b.awrap(this.handleDownloadFirstSyncCompletion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleDownloadFirstSyncCompletion",value:function(){var e,t,n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.hasAccount()){c.next=2;break}return c.abrupt("return");case 2:if(e=this.latestItemsKeys(),t=e.filter(function(e){return e.neverSynced}),n=e.filter(function(e){return!e.neverSynced}),r=n.find(function(e){return e.isDefault}),!!Object(_.w)(r)){c.next=12;break}return c.next=10,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(t)));case 10:c.next=21;break;case 12:if(!(a=this.getRootKey())){c.next=21;break}if(!((i=t.filter(function(e){return e.keyVersion!==a.keyVersion})).length>0)){c.next=18;break}return c.next=18,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(i)));case 18:if(0!==this.latestItemsKeys().length){c.next=21;break}return c.next=21,b.awrap(this.createNewDefaultItemsKey());case 21:return c.next=23,b.awrap(this.getUserVersion());case 23:if(s=c.sent,o=this.latestItemsKeys().find(function(e){return e.keyVersion===s}),!Object(_.w)(o)){c.next=28;break}return c.next=28,b.awrap(this.createNewDefaultItemsKey());case 28:this.syncUnsycnedItemsKeys();case 29:case"end":return c.stop()}},null,this,null,Promise)}},{key:"handleFullSyncCompletion",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,b.awrap(this.createNewDefaultItemsKey());case 4:if(this.keyMode!==Bn.WrapperOnly){e.next=6;break}return e.abrupt("return",this.repersistAllItems());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"syncUnsycnedItemsKeys",value:function(){if(this.hasAccount()){var e=this.latestItemsKeys().filter(function(e){return e.neverSynced&&!e.dirty&&!e.deleted});e.length>0&&this.itemManager.setItemsDirty(Object(Ke.b)(e))}}},{key:"repersistAllItems",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e)}),n.abrupt("return",this.storageService.savePayloads(t));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"latestItemsKeys",value:function(){return this.itemManager.itemsKeys()}},{key:"itemsKeyForPayload",value:function(e){return this.latestItemsKeys().find(function(t){return t.uuid===e.items_key_id||t.duplicateOf===e.items_key_id})}},{key:"getDefaultItemsKey",value:function(){var e=this.latestItemsKeys();if(1===e.length)return e[0];var t=e.filter(function(e){return e.isDefault});if(t.length>1){var n=t.filter(function(e){return!e.neverSynced});if(n.length,n.length>0)return n[0]}return t[0]}},{key:"getKeyEmbeddedKeyParams",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.payload.format!==ue.a.DecryptedBareObject){s.next=2;break}return s.abrupt("return",void 0);case 2:return t=e.version,n=this.operatorForVersion(t),s.next=6,b.awrap(n.getPayloadAuthenticatedData(e.payload));case 6:if(r=s.sent){s.next=9;break}return s.abrupt("return",void 0);case 9:if(!Object(Q.c)(t,Q.a.V003)){s.next=14;break}return a=r,s.abrupt("return",this.createKeyParams(a));case 14:return i=r.kp,s.abrupt("return",this.createKeyParams(i));case 16:case"end":return s.stop()}},null,this,null,Promise)}},{key:"reencryptItemsKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!((e=this.latestItemsKeys()).length>0)){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"defaultItemsKeyForItemVersion",value:function(e,t){var n=t||this.latestItemsKeys(),r=n.find(function(t){return t.isDefault&&t.keyVersion===e});return r||n.find(function(t){return t.keyVersion===e})}},{key:"needsNewRootKeyBasedItemsKey",value:function(){if(!this.hasAccount())return!1;var e=this.getRootKey();if(!e)return!1;if(Object(Q.b)(e.keyVersion,Yn)>0)return!1;var t=this.getDefaultItemsKey();return!t||t.itemsKey!==e.itemsKey}},{key:"createNewDefaultItemsKey",value:function(){var e,t,n,r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e=this.getRootKey(),t=e?e.keyVersion:this.getLatestVersion(),!(Object(Q.b)(t,Yn)<=0)){l.next=14;break}return l.t0=Object(Ee.e),l.next=6,b.awrap(I.GenerateUuid());case 6:l.t1=l.sent,l.t2=F.a.ItemsKey,l.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t}),l.t4={uuid:l.t1,content_type:l.t2,content:l.t3},r=(0,l.t0)(l.t4),n=nt(r),l.next=17;break;case 14:return l.next=16,b.awrap(this.operatorForVersion(t).createItemsKey());case 16:n=l.sent;case 17:a=this.latestItemsKeys(),i=a.filter(function(e){return e.isDefault}),s=S(i);case 20:if((o=s()).done){l.next=26;break}return c=o.value,l.next=24,b.awrap(this.itemManager.changeItemsKey(c.uuid,function(e){e.isDefault=!1}));case 24:l.next=20;break;case 26:return l.next=28,b.awrap(this.itemManager.insertItem(n));case 28:return u=l.sent,l.next=31,b.awrap(this.itemManager.changeItemsKey(u.uuid,function(e){e.isDefault=!0}));case 31:return l.abrupt("return",u);case 32:case"end":return l.stop()}},null,this,null,Promise)}},{key:"createNewItemsKeyWithRollback",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=this.getDefaultItemsKey(),a.next=3,b.awrap(this.createNewDefaultItemsKey());case 3:return t=a.sent,n=function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(Promise.all([r.itemManager.setItemToBeDeleted(t.uuid),r.itemManager.changeItem(e.uuid,function(e){e.isDefault=!0})]));case 2:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getPasswordCreatedDate",value:function(){var e=this.getRootKey();return e?e.keyParams.createdDate:void 0}}]),n})(R.a),Qn=(function(){function e(t,n){v(this,e),this.defaultContentKeyToDiffOn='text',this.payload=Object(Ee.b)(t),this.previousEntry=n,this.hasPreviousEntry=!Object(_.w)(n);var r=this.payload.content[this.defaultContentKeyToDiffOn];this.textCharDiffLength=r?n?r.length-n.payload.content[this.defaultContentKeyToDiffOn].length:this.payload.content[this.defaultContentKeyToDiffOn].length:0}return y(e,[{key:"itemFromPayload",value:function(){return nt(this.payload)}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=this.itemFromPayload(),n=e.itemFromPayload();return!(t.userModifiedDate.getTime()!==n.userModifiedDate.getTime())&&t.isItemContentEqualWith(n)}},{key:"isDiscardable",value:function(){return!1}},{key:"operationVector",value:function(){return void 0!==this.textCharDiffLength?this.hasPreviousEntry&&0!==this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!==this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}}]),e})(),Jn=(function(e){d(n,Qn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"previewTitle",value:function(){return this.payload.updated_at.getTime()>0?this.payload.updated_at.toLocaleString():this.payload.created_at.toLocaleString()}},{key:"previewSubTitle",value:function(){return this.hasPreviousEntry?this.textCharDiffLength<0?"".concat(-1*this.textCharDiffLength," characters removed"):this.textCharDiffLength>0?"".concat(this.textCharDiffLength," characters added"):'Title or metadata changed':"".concat(this.textCharDiffLength," characters loaded")}},{key:"isDiscardable",value:function(){return Object(_.t)(this.payload.safeContent.text)}}]),n})();function $n(e,t){return new(Xn(e[Je.a.ContentType]))(e,t)}function Xn(e){switch(e){case F.a.Note:return Jn;default:return Qn}}var Zn,er,tr=20,nr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s){var o;return v(this,n),(o=t.call(this)).itemManager=e,o.storageService=r,o.apiService=a,o.protocolService=i,o.deviceInterface=s,o.persistable=!1,o.autoOptimize=!1,o.historyStaging={},o.history={},o.historyTypes=[F.a.Note],o.itemRevisionThreshold=tr,o.removeChangeObserver=o.itemManager.addObserver(o.historyTypes,function(e,t){o.recordNewHistoryForItems(e.concat(t))}),o}return y(n,[{key:"deinit",value:function(){this.cancelPendingPersist(),this.itemManager=void 0,this.storageService=void 0,this.history=void 0,this.removeChangeObserver&&(this.removeChangeObserver(),this.removeChangeObserver=void 0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.SessionHistoryPersistable));case 2:return this.persistable=e.sent,e.next=5,b.awrap(this.getPersistedHistory());case 5:return this.history=e.sent,e.next=8,b.awrap(this.storageService.getValue(o.SessionHistoryOptimize,void 0,!0));case 8:this.autoOptimize=e.sent;case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPersistedHistory",value:function(){var e,t,n,r,a,i,s,c,u,p,d,h,f,v,y,g;return b.async(function(m){for(;;)switch(m.prev=m.next){case 0:return e={},m.next=3,b.awrap(this.storageService.getValue(o.SessionHistoryRevisions));case 3:if(t=m.sent){m.next=6;break}return m.abrupt("return",e);case 6:for(n=0,r=Object.entries(t);n<r.length;n++){for(a=r[n],i=l(a,2),s=i[0],c=i[1],u=c.slice().reverse(),p=[],d=S(u);!(h=d()).done;)f=h.value,v=Object(Ee.f)(f.payload,ht.a.SessionHistory),y=yt(p),g=$n(v,y),p.unshift(g);e[s]=p}return m.abrupt("return",e);case 8:case"end":return m.stop()}},null,this,null,Promise)}},{key:"recordNewHistoryForItems",value:function(e){for(var t,n=!1,r=S(e);!(t=r()).done;){var a=t.value;if(this.historyTypes.includes(a.content_type)){var i=a.payload;if(!a.deleted&&i.format===ue.a.DecryptedBareObject){var s=this.history[a.uuid]||[],o=yt(s),c=$n(Object(Ee.f)(a,ht.a.SessionHistory),o);if(!c.isDiscardable()){var u=this.historyStaging[a.uuid];this.historyStaging[a.uuid]=c,u&&(u.isSameAsEntry(c)||o&&u.isSameAsEntry(o)||(s.unshift(u),this.history[a.uuid]=s,this.autoOptimize&&this.optimizeHistoryForItem(a.uuid),n=!0))}}}}n&&this.saveToDisk()}},{key:"isDiskEnabled",value:function(){return this.persistable}},{key:"isAutoOptimizeEnabled",value:function(){return this.autoOptimize}},{key:"cancelPendingPersist",value:function(){this.saveTimeout&&('cancel'in this.deviceInterface.timeout?this.deviceInterface.timeout.cancel(this.saveTimeout):clearTimeout(this.saveTimeout))}},{key:"saveToDisk",value:function(){var e=this;if(this.persistable){this.cancelPendingPersist();var t=this.persistableHistoryValue();this.saveTimeout=this.deviceInterface.timeout(function(){e.storageService.setValue(o.SessionHistoryRevisions,t)},2e3)}}},{key:"persistableHistoryValue",value:function(){for(var e={},t=0,n=Object.entries(this.history);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1].map(function(e){return{payload:e.payload}});e[i]=s}return e}},{key:"setSessionItemRevisionThreshold",value:function(e){this.itemRevisionThreshold=e}},{key:"sessionHistoryForItem",value:function(e){return this.history[e.uuid]||[]}},{key:"clearHistoryForItem",value:function(e){delete this.history[e.uuid],this.saveToDisk()}},{key:"clearAllHistory",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.history={},e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleDiskSaving",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistable=!this.persistable,!this.persistable){e.next=6;break}this.storageService.setValue(o.SessionHistoryPersistable,!0),this.saveToDisk(),e.next=8;break;case 6:return this.storageService.setValue(o.SessionHistoryPersistable,!1),e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 8:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleAutoOptimize",value:function(){this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageService.setValue(o.SessionHistoryOptimize,!0):this.storageService.setValue(o.SessionHistoryOptimize,!1)}},{key:"getHistoryMapCopy",value:function(){for(var e=w({},this.history),t=0,n=Object.entries(e);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1];e[i]=s.slice()}return Object.freeze(e)}},{key:"remoteHistoryForItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.getItemRevisions(e.uuid));case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.abrupt("return",t.data);case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"fetchRemoteRevision",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.apiService.getRevision(t,e));case 2:if(!(n=o.sent).error&&!Object(_.w)(n.data)){o.next=5;break}return o.abrupt("return",void 0);case 5:return r=n.data,a=Object(Ee.e)(r,{uuid:r.item_uuid}),i=Object(Ee.f)(a,ht.a.RemoteHistory),o.next=10,b.awrap(this.protocolService.payloadByDecryptingPayload(i));case 10:if(!(s=o.sent).errorDecrypting){o.next=13;break}return o.abrupt("return",void 0);case 13:return o.abrupt("return",new Qn(s));case 14:case"end":return o.stop()}},null,this,null,Promise)}},{key:"optimizeHistoryForItem",value:function(e){var t=this.history[e]||[];if(!(t.length<=this.itemRevisionThreshold)){for(var n=function(e){return e.deltaSize()>25},r=[],a=function(e,a,i){if(i){if(r.unshift(e),n(e)&&-1===e.operationVector()){var s=t[a+1];s&&r.unshift(s)}}else Object(_.M)(r,e)},i=t.length-1;i>=0;i--){var s=t[i];a(s,i,0===i||i===t.length-1||n(s))}var o=t.filter(function(e){return r.includes(e)});this.history[e]=o}}}]),n})(R.a);!(function(e){e.SessionExpiryDateChanged="SessionExpiryDateChanged"})(Zn||(Zn={})),(function(e){e[e.None=0]="None",e[e.FiveMinutes=300]="FiveMinutes",e[e.OneHour=3600]="OneHour",e[e.OneWeek=604800]="OneWeek"})(er||(er={}));var rr,ar=[{valueInSeconds:er.None,label:"Don't Remember"},{valueInSeconds:er.FiveMinutes,label:'5 Minutes'},{valueInSeconds:er.OneHour,label:'1 Hour'},{valueInSeconds:er.OneWeek,label:'1 Week'}],ir=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).protocolService=e,s.challengeService=r,s.storageService=a,s.itemManager=i,s.sessionExpiryTimeout=-1,s}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.challengeService=void 0,this.storageService=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return e===ve.LoadedDatabase_12&&this.updateSessionExpiryTimer(this.getSessionExpiryDate()),Promise.resolve()}},{key:"hasProtectionSources",value:function(){return this.protocolService.hasAccount()||this.protocolService.hasPasscode()||this.hasBiometricsEnabled()}},{key:"areProtectionsEnabled",value:function(){return this.hasProtectionSources()&&this.getSessionExpiryDate()<=new Date}},{key:"hasBiometricsEnabled",value:function(){var e=this.storageService.getValue(o.BiometricsState,De.Nonwrapped);return Boolean(e)}},{key:"enableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to enable biometrics when they already are enabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.storageService.setValue(o.BiometricsState,!0,De.Nonwrapped));case 5:return e.abrupt("return",!0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"disableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to disable biometrics when they already are disabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.validateOrRenewSession(ne.DisableBiometrics));case 5:if(!e.sent){e.next=11;break}return e.next=8,b.awrap(this.storageService.setValue(o.BiometricsState,!1,De.Nonwrapped));case 8:return e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"createLaunchChallenge",value:function(){var e=[];return this.hasBiometricsEnabled()&&e.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&e.push(new ge(te.LocalPasscode)),e.length>0?new ye(e,ne.ApplicationUnlock,!1):void 0}},{key:"protectNote",value:function(e){return this.itemManager.changeItem(e.uuid,function(e){e.protected=!0})}},{key:"unprotectNote",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.validateOrRenewSession(ne.UnprotectNote));case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.itemManager.changeItem(e.uuid,function(e){e.protected=!1}));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){c.next=15;break}if(s=i.value,(o=s.protected&&this.areProtectionsEnabled())&&!n&&(n=this.validateOrRenewSession(t)),c.t0=!o,c.t0){c.next=11;break}return c.next=10,b.awrap(n);case 10:c.t0=c.sent;case 11:if(!c.t0){c.next=13;break}r.push(s);case 13:c.next=2;break;case 15:return c.abrupt("return",r);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){return this.itemManager.changeItems(Object(Ke.b)(e),function(e){e.protected=!0})}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.authorizeProtectedActionForNotes(e,ne.UnprotectNote));case 2:return t=n.sent,n.abrupt("return",this.itemManager.changeItems(Object(Ke.b)(t),function(e){e.protected=!1}));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeNoteAccess",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.protected){t.next=2;break}return t.abrupt("return",!0);case 2:return t.abrupt("return",this.validateOrRenewSession(ne.AccessProtectedNote));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeAddingPasscode",value:function(){return this.validateOrRenewSession(ne.AddPasscode)}},{key:"authorizeChangingPasscode",value:function(){return this.validateOrRenewSession(ne.ChangePasscode)}},{key:"authorizeRemovingPasscode",value:function(){return this.validateOrRenewSession(ne.RemovePasscode)}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.validateOrRenewSession(ne.SearchProtectedNotesText)}},{key:"authorizeFileImport",value:function(){return this.validateOrRenewSession(ne.ImportFile)}},{key:"authorizeBackupCreation",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.validateOrRenewSession(ne.ExportBackup,{fallBackToAccountPassword:e}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeMfaDisable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.DisableMfa,{requireAccountPassword:!0}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeAutolockIntervalChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.ChangeAutolockInterval));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeSessionRevoking",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.RevokeSession));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeCloudLinkAccess",value:function(){return this.validateOrRenewSession(ne.AccessCloudLink)}},{key:"validateOrRenewSession",value:function(e){var t,n,r,a,i,s,o,c,u,l=arguments;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>1&&void 0!==l[1]?l[1]:{},n=t.fallBackToAccountPassword,r=void 0===n||n,a=t.requireAccountPassword,i=void 0!==a&&a,!(this.getSessionExpiryDate()>new Date)){p.next=3;break}return p.abrupt("return",!0);case 3:if(s=[],this.hasBiometricsEnabled()&&s.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&s.push(new ge(te.LocalPasscode)),!i){p.next=10;break}if(this.protocolService.hasAccount()){p.next=9;break}throw Error('Requiring account password for challenge with no account');case 9:s.push(new ge(te.AccountPassword));case 10:if(0!==s.length){p.next=16;break}if(!r||!this.protocolService.hasAccount()){p.next=15;break}s.push(new ge(te.AccountPassword)),p.next=16;break;case 15:return p.abrupt("return",!0);case 16:return p.t0=s,p.t1=ge,p.t2=te.ProtectionSessionDuration,p.t3=void 0,p.t4=void 0,p.t5=void 0,p.t6=void 0,p.next=25,b.awrap(this.getSessionLength());case 25:return p.t7=p.sent,p.t8=new p.t1(p.t2,p.t3,p.t4,p.t5,p.t6,p.t7),p.t0.push.call(p.t0,p.t8),p.next=30,b.awrap(this.challengeService.promptForChallengeResponse(new ye(s,e,!0)));case 30:if(!(o=p.sent)){p.next=42;break}if(u=null===(c=o.values.find(function(e){return e.prompt.validation===te.ProtectionSessionDuration}))||void 0===c?void 0:c.value,!Object(_.w)(u)){p.next=37;break}we.a.error(Error('No valid protection session length found. Got '+u)),p.next=39;break;case 37:return p.next=39,b.awrap(this.setSessionLength(u));case 39:return p.abrupt("return",!0);case 42:return p.abrupt("return",!1);case 43:case"end":return p.stop()}},null,this,null,Promise)}},{key:"getSessionExpiryDate",value:function(){var e=this.storageService.getValue(o.ProtectionExpirey);return e?new Date(e):new Date}},{key:"clearSession",value:function(){return this.setSessionExpiryDate(new Date)}},{key:"setSessionExpiryDate",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.ProtectionExpirey,e));case 2:this.notifyEvent(Zn.SessionExpiryDateChanged);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSessionLength",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ProtectionSessionLength));case 2:if(!(e=t.sent)){t.next=7;break}return t.abrupt("return",e);case 7:return t.abrupt("return",er.None);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setSessionLength",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.storageService.setValue(o.ProtectionSessionLength,e));case 2:return(t=new Date).setSeconds(t.getSeconds()+e),n.next=6,b.awrap(this.setSessionExpiryDate(t));case 6:this.updateSessionExpiryTimer(t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSessionExpiryTimer",value:function(e){var t=this,n=e.getTime();if(n>Date.now()){clearTimeout(this.sessionExpiryTimeout),this.sessionExpiryTimeout=setTimeout(function(){t.setSessionExpiryDate(new Date)},n-Date.now())}}}]),n})(R.a),sr=n(45),or=n(19);!(function(e){e.UserRoleMessageReceived="WebSocketMessageReceived"})(rr||(rr={}));var cr,ur,lr=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.webSocketUrl=r,a}return y(n,[{key:"setWebSocketUrl",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.webSocketUrl=e,t.next=3,b.awrap(this.storageService.setValue(o.WebSocketUrl,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadWebSocketUrl",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.WebSocketUrl));case 2:e=t.sent,this.webSocketUrl=e||this.webSocketUrl||window._websocket_url;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"startWebSocketConnection",value:function(e){if(this.webSocketUrl)try{this.webSocket=new WebSocket("".concat(this.webSocketUrl,"?authToken=Bearer+").concat(e)),this.webSocket.onmessage=this.onWebSocketMessage.bind(this),this.webSocket.onclose=this.onWebSocketClose.bind(this)}catch(e){console.error('Error starting WebSocket connection',e)}}},{key:"closeWebSocketConnection",value:function(){var e;null===(e=this.webSocket)||void 0===e||e.close()}},{key:"onWebSocketMessage",value:function(e){var t=JSON.parse(e.data);this.notifyEvent(rr.UserRoleMessageReceived,t)}},{key:"onWebSocketClose",value:function(){this.webSocket=void 0}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.storageService=void 0,this.closeWebSocketConnection()}}]),n})(R.a),pr=n(29);!(function(e){e.UserRolesChanged="UserRolesChanged",e.FeaturesUpdated="FeaturesUpdated"})(cr||(cr={})),(function(e){e.NoUserSubscription="NoUserSubscription",e.NotInCurrentPlan="NotInCurrentPlan",e.InCurrentPlanButExpired="InCurrentPlanButExpired",e.Entitled="Entitled"})(ur||(ur={}));var dr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l,p,d){var h;return v(this,n),(h=t.call(this)).storageService=e,h.apiService=r,h.itemManager=a,h.componentManager=i,h.webSocketsService=s,h.settingsService=o,h.credentialService=c,h.syncService=u,h.alertService=l,h.sessionManager=p,h.crypto=d,h.deinited=!1,h.roles=[],h.features=[],h.needsInitialFeaturesUpdate=!0,h.completedSuccessfulFeaturesRetrieval=!1,h.removeApiServiceObserver=r.addEventObserver(function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==Ht.MetaReceived){a.next=6;break}if(h.syncService.completedOnlineDownloadFirstSync){a.next=3;break}return a.abrupt("return");case 3:return n=t.userUuid,r=t.userRoles,a.next=6,b.awrap(h.updateRoles(n,r.map(function(e){return e.name})));case 6:case"end":return a.stop()}},null,null,null,Promise)}),h.removeWebSocketsServiceObserver=s.addEventObserver(function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e!==rr.UserRoleMessageReceived){i.next=6;break}return n=t.payload,r=n.userUuid,a=n.currentRoles,i.next=4,b.awrap(h.setRoles(a));case 4:return i.next=6,b.awrap(h.updateFeatures(r));case 6:case"end":return i.stop()}},null,null,null,Promise)}),h.removefeatureReposObserver=h.itemManager.addObserver(or.ContentType.ExtensionRepo,function(e,t,n,r,a){var i,s;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=[ht.a.Constructor,ht.a.LocalRetrieved,ht.a.RemoteRetrieved,ht.a.FileImport],!a||!i.includes(a)){n.next=10;break}if(s=[].concat(m(e),m(t)).filter(function(e){return!e.deleted}),!h.sessionManager.isSignedIntoFirstPartyServer()){n.next=8;break}return n.next=6,b.awrap(h.migrateFeatureRepoToUserSetting(s));case 6:n.next=10;break;case 8:return n.next=10,b.awrap(h.migrateFeatureRepoToOfflineEntitlements(s));case 10:case"end":return n.stop()}},null,null,null,Promise)}),h.removeSignInObserver=h.credentialService.addEventObserver(function(e){if(e===Ye.SignedInOrRegistered){var t=h.itemManager.getItems(or.ContentType.ExtensionRepo);h.apiService.isThirdPartyHostUsed()||h.migrateFeatureRepoToUserSetting(t)}}),h}return y(n,[{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.FullSyncCompleted_13&&(t=this.getOfflineRepo())&&this.downloadOfflineFeatures(t);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setOfflineFeaturesCode",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,t=e.replace(/\s/g,''),i.next=4,b.awrap(this.crypto.base64Decode(t));case 4:if(n=i.sent,r=this.parseOfflineEntitlementsCode(n),!Object(_.u)(r)){i.next=8;break}return i.abrupt("return",r);case 8:return i.next=10,b.awrap(this.itemManager.createItem(or.ContentType.ExtensionRepo,Object(Ke.a)({offlineFeaturesUrl:r.featuresUrl,offlineKey:r.extensionKey,migratedToOfflineEntitlements:!0}),!0));case 10:return a=i.sent,this.syncService.sync(),i.abrupt("return",this.downloadOfflineFeatures(a));case 15:return i.prev=15,i.t0=i.catch(0),i.abrupt("return",{error:j.e});case 18:case"end":return i.stop()}},null,this,[[0,15]],Promise)}},{key:"getOfflineRepo",value:function(){return this.itemManager.getItems(or.ContentType.ExtensionRepo).filter(function(e){return e.migratedToOfflineEntitlements})[0]}},{key:"hasOfflineRepo",value:function(){return void 0!=this.getOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this.getOfflineRepo())){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 4:return t.next=6,b.awrap(this.storageService.removeValue(o.UserFeatures));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"parseOfflineEntitlementsCode",value:function(e){try{var t=JSON.parse(e);return{featuresUrl:t.featuresUrl,extensionKey:t.extensionKey}}catch(e){return{error:j.e}}}},{key:"downloadOfflineFeatures",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.downloadOfflineFeaturesFromRepo(e));case 2:if(t=n.sent,!Object(_.u)(t)){n.next=5;break}return n.abrupt("return",t);case 5:return n.next=7,b.awrap(this.didDownloadFeatures(t.features));case 7:return n.next=9,b.awrap(this.mapFeaturesToItems(t.features));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToUserSetting",value:function(){var e,t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:[],t=S(e);case 2:if((n=t()).done){c.next=17;break}if(!(r=n.value).migratedToUserSetting){c.next=6;break}return c.abrupt("continue",15);case 6:if(!r.onlineUrl){c.next=15;break}if(a=r.onlineUrl,!((i=a.match(/\w{32,64}/))&&i.length>0)){c.next=15;break}return s=i[0],c.next=13,b.awrap(this.settingsService.updateSetting(pr.SettingName.ExtensionKey,s,!0));case 13:return c.next=15,b.awrap(this.itemManager.changeFeatureRepo(r.uuid,function(e){e.migratedToUserSetting=!0}));case 15:c.next=2;break;case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToOfflineEntitlements",value:function(){var e,t,n,r,a,i,s,o=this,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=c.length>0&&void 0!==c[0]?c[0]:[],t=S(e);case 2:if((n=t()).done){u.next=17;break}if(!(r=n.value).migratedToOfflineEntitlements){u.next=6;break}return u.abrupt("continue",15);case 6:if(!r.onlineUrl){u.next=15;break}if(a=r.onlineUrl,i=new URL(a),i.origin.includes("https://extensions.standardnotes.org")){u.next=11;break}return u.abrupt("continue",15);case 11:if(!((s=a.match(/\w{32,64}/))&&s.length>0)){u.next=15;break}return u.next=15,b.awrap((function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=s[0],n.next=3,b.awrap(o.itemManager.changeFeatureRepo(r.uuid,function(t){t.offlineFeaturesUrl="https://api.standardnotes.com/v1/offline/features",t.offlineKey=e,t.migratedToOfflineEntitlements=!0}));case 3:return t=n.sent,n.next=6,b.awrap(o.downloadOfflineFeatures(t));case 6:case"end":return n.stop()}},null,null,null,Promise)})());case 15:u.next=2;break;case 17:case"end":return u.stop()}},null,null,null,Promise)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.UserRoles,void 0,[]));case 2:return this.roles=e.sent,e.next=5,b.awrap(this.storageService.getValue(o.UserFeatures,void 0,[]));case 5:this.features=e.sent;case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"updateRoles",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.haveRolesChanged(t)&&!this.needsInitialFeaturesUpdate){n.next=7;break}return this.needsInitialFeaturesUpdate=!1,n.next=5,b.awrap(this.setRoles(t));case 5:return n.next=7,b.awrap(this.updateFeatures(e));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setRoles",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles=e,Object(_.e)(this.roles,e)||this.notifyEvent(cr.UserRolesChanged),t.next=4,b.awrap(this.storageService.setValue(o.UserRoles,this.roles));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"didDownloadFeatures",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.features=e,this.completedSuccessfulFeaturesRetrieval=!0,this.notifyEvent(cr.FeaturesUpdated),t.next=5,b.awrap(this.storageService.setValue(o.UserFeatures,this.features));case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getFeature",value:function(e){return this.features.find(function(t){return t.identifier===e})}},{key:"hasPaidOnlineOrOfflineSubscription",value:function(){if(this.sessionManager.isSignedIntoFirstPartyServer()){var e=this.roles,t=[sr.RoleName.BasicUser];return e.some(function(e){return!t.includes(e)})}return this.hasOfflineRepo()}},{key:"getFeatureStatus",value:function(e){if(void 0==L.Features.find(function(t){return t.identifier===e})){var t=this.itemManager.components.find(function(t){return t.identifier===e});return null!==t&&void 0!==t&&t.isExpired?ur.InCurrentPlanButExpired:ur.Entitled}if(this.hasPaidOnlineOrOfflineSubscription()&&!this.completedSuccessfulFeaturesRetrieval)return ur.Entitled;if(!this.hasPaidOnlineOrOfflineSubscription())return ur.NoUserSubscription;var n=this.features.find(function(t){return t.identifier===e});return n?n.expires_at&&new Date(n.expires_at).getTime()<(new Date).getTime()?this.roles.includes(n.role_name)?ur.InCurrentPlanButExpired:ur.NotInCurrentPlan:ur.Entitled:ur.NotInCurrentPlan}},{key:"haveRolesChanged",value:function(e){var t=this;return e.some(function(e){return!t.roles.includes(e)})||this.roles.some(function(t){return!e.includes(t)})}},{key:"updateFeatures",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.apiService.getUserFeatures(e));case 2:if((t=r.sent).error||!t.data||this.deinited){r.next=10;break}return(n=t.data.features).forEach(function(e){e.expires_at&&(e.expires_at=Object(_.i)(e.expires_at))}),r.next=8,b.awrap(this.didDownloadFeatures(n));case 8:return r.next=10,b.awrap(this.mapFeaturesToItems(n));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"componentContentForFeatureDescription",value:function(e){var t={area:e.area,hosted_url:e.url,name:e.name,package_info:e,valid_until:new Date(e.expires_at||0)};return Object(Ke.a)(t)}},{key:"mapFeaturesToItems",value:function(e){var t,n,r,a,i,s,o,c,u=this;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:t=this.itemManager.getItems([or.ContentType.Component,or.ContentType.Theme]),n=[],r=new Date,a=!1,i=function(e){var i,s,o,c;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e.content_type){l.next=2;break}return l.abrupt("return","continue");case 2:if(!e.url||Object(_.B)(e.url)){l.next=5;break}return l.abrupt("return","continue");case 5:if(i=new Date(e.expires_at||0).getTime()<r.getTime(),s=t.find(function(t){return!!t.safeContent.package_info&&(t.safeContent.package_info.identifier===e.identifier&&!t.deleted)}),o=s,!s){l.next=21;break}if(c=new Date(e.expires_at||0),!(e.url!==s.hosted_url||e.version!==s.package_info.version||c.getTime()!==s.valid_until.getTime())){l.next=18;break}return l.next=14,b.awrap(u.itemManager.changeComponent(s.uuid,function(t){t.hosted_url=e.url,t.package_info=e,t.valid_until=c}));case 14:o=l.sent,a=!0,l.next=19;break;case 18:o=s;case 19:l.next=26;break;case 21:if(i&&e.content_type!==or.ContentType.Component){l.next=26;break}return l.next=24,b.awrap(u.itemManager.createItem(e.content_type,u.componentContentForFeatureDescription(e),!0));case 24:o=l.sent,a=!0;case 26:i&&o&&(e.content_type===or.ContentType.Component?u.componentManager.setReadonlyStateForComponent(o,i):(n.push(o.uuid),a=!0));case 27:case"end":return l.stop()}},null,null,null,Promise)},s=S(e);case 6:if((o=s()).done){l.next=15;break}return c=o.value,l.next=10,b.awrap(i(c));case 10:if("continue"!==l.sent){l.next=13;break}return l.abrupt("continue",13);case 13:l.next=6;break;case 15:return l.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(n));case 17:a&&this.syncService.sync();case 18:case"end":return l.stop()}},null,this,null,Promise)}},{key:"validateAndDownloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=e,i.prev=1,i.next=4,b.awrap(this.crypto.base64Decode(e));case 4:t=i.sent,i.next=9;break;case 7:i.prev=7,i.t0=i.catch(1);case 9:if(i.prev=9,n=[].concat(Ft,Nt),r=new URL(t),a=r.host,n.includes(a)){i.next=20;break}return i.next=15,b.awrap(this.alertService.confirm(j.t,'Install extension from an untrusted source?','Proceed to install',St.Danger,'Cancel'));case 15:if(!i.sent){i.next=18;break}return i.abrupt("return",this.downloadExternalFeature(t));case 18:i.next=21;break;case 20:return i.abrupt("return",this.downloadExternalFeature(t));case 21:i.next=26;break;case 23:i.prev=23,i.t1=i.catch(9),this.alertService.alert(j.C);case 26:case"end":return i.stop()}},null,this,[[1,7],[9,23]],Promise)}},{key:"downloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.apiService.downloadFeatureUrl(e));case 2:if(!(t=i.sent).error){i.next=7;break}return i.next=6,b.awrap(this.alertService.alert(j.c));case 6:return i.abrupt("return",void 0);case 7:if((n=t.data).content_type){i.next=10;break}return i.abrupt("return");case 10:return r=this.componentContentForFeatureDescription(n),i.next=13,b.awrap(this.itemManager.createTemplateItem(n.content_type,r));case 13:return a=i.sent,i.abrupt("return",a);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.removeSignInObserver(),this.removeSignInObserver=void 0,this.removeApiServiceObserver(),this.removeApiServiceObserver=void 0,this.removeWebSocketsServiceObserver(),this.removeWebSocketsServiceObserver=void 0,this.removefeatureReposObserver(),this.removefeatureReposObserver=void 0,this.roles=void 0,this.storageService=void 0,this.apiService=void 0,this.itemManager=void 0,this.componentManager=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.credentialService=void 0,this.syncService=void 0,this.alertService=void 0,this.sessionManager=void 0,this.crypto=void 0,this.deinited=!0}}]),n})(R.a),hr=n(46),fr=(function(){function e(t,n){v(this,e),this.completedUpload=0,this.totalUpload=0,this.downloaded=0,this.databaseLoadCurrent=0,this.databaseLoadTotal=0,this.databaseLoadDone=!1,this.syncing=!1,this.interval=t,this.receiver=n}return y(e,[{key:"deinit",value:function(){this.stopTimingMonitor()}},{key:"setUploadStatus",value:function(e,t){this.completedUpload=e,this.totalUpload=t,this.receiver(on.a.StatusChanged)}},{key:"setDownloadStatus",value:function(e){this.downloaded+=e,this.receiver(on.a.StatusChanged)}},{key:"setDatabaseLoadStatus",value:function(e,t,n){this.databaseLoadCurrent=e,this.databaseLoadTotal=t,this.databaseLoadDone=n,n?this.receiver(on.a.LocalDataLoaded):this.receiver(on.a.LocalDataIncrementalLoad)}},{key:"getStats",value:function(){return{uploadCompletionCount:this.completedUpload,uploadTotalCount:this.totalUpload,downloadCount:this.downloaded,localDataDone:this.databaseLoadDone,localDataCurrent:this.databaseLoadCurrent,localDataTotal:this.databaseLoadTotal}}},{key:"setDidBegin",value:function(){this.syncing=!0,this.syncStart=new Date}},{key:"setDidEnd",value:function(){this.syncing=!1,this.syncEnd=new Date}},{key:"startTimingMonitor",value:function(){var e=this;this.timingMonitor&&this.stopTimingMonitor(),this.timingMonitor=this.interval(function(){e.secondsSinceSyncStart>5&&(e.receiver(on.a.SyncTakingTooLong),e.stopTimingMonitor())},500)}},{key:"stopTimingMonitor",value:function(){Object.prototype.hasOwnProperty.call(this.interval,'cancel')?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return!!this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.syncing=!1,this.error=null,this.stopTimingMonitor(),this.receiver(on.a.StatusChanged)}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return((new Date).getTime()-this.syncStart.getTime())/1e3}}]),e})();function vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mr,br=(function(){function e(){v(this,e),this.tags=[],this.includePinned=!0,this.includeProtected=!0,this.includeTrashed=!1,this.includeArchived=!1}return y(e,[{key:"computeFilters",value:function(e){for(var t,n=this,r=this.tags.filter(function(e){return!e.isSmartTag}),a=this.tags.filter(function(e){return e.isSmartTag}),i=a.filter(function(e){return e.isSystemSmartTag}),s=a.filter(function(e){return!e.isSystemSmartTag}),o=!1,c=!1,u=[],l=S(i);!(t=l()).done;){var p=t.value;p.isArchiveTag?(u.push(function(e){return e.archived&&!e.deleted}),o=!0):p.isTrashTag&&(u.push(function(e){return e.trashed&&!e.deleted}),c=!0)}if(s.length>0){var d=H.a.CompoundPredicate(s.map(function(e){return e.predicate}));u.push(function(t){if(d.keypathIncludesVerb('tags')){var n=yr(yr(yr({},t),t.payload),{},{tags:e.elementsReferencingElement(t,F.a.Tag)});return H.a.ObjectSatisfiesPredicate(n,d)}return H.a.ObjectSatisfiesPredicate(t,d)})}else if(r.length>0)for(var h,f=function(e){u.push(function(t){return e.hasRelationshipWithItem(t)})},v=S(r);!(h=v()).done;){f(h.value)}return this.searchQuery&&u.push(function(t){return xr(t,n.searchQuery,e)}),this.includePinned||u.push(function(e){return!e.pinned}),this.includeProtected||u.push(function(e){return!e.protected}),this.includeTrashed||c||u.push(function(e){return!e.trashed}),this.includeArchived||o||c||u.push(function(e){return!e.archived}),u}}],[{key:"Create",value:function(t){var n=new e;return w(n,t),Object.freeze(n)}},{key:"Copy",value:function(t,n){var r=new e;return w(r,t),w(r,n),Object.freeze(r)}}]),e})();function wr(e,t){var n=e.computeFilters(t);return t.displayElements(F.a.Note).filter(function(e){return kr(e,n)})}function kr(e,t){for(var n,r=S(t);!(n=r()).done;){if(!(0,n.value)(e))return!1}return!0}function xr(e,t,n){var r=n.elementsReferencingElement(e,F.a.Tag).some(function(e){return Pr(e,t.query)!==mr.None});if(e.protected&&!t.includeProtectedNoteText){var a=Sr(e,t.query);return a===mr.Title||a===mr.TitleAndText||r}return Sr(e,t.query)!==mr.None||r}function Sr(e,t){if(0===t.length)return mr.TitleAndText;var n=e.safeTitle().toLowerCase(),r=e.safeText().toLowerCase(),a=t.toLowerCase(),i=a.split(' '),s=Or(a);if(s)return(n.includes(s)?mr.Title:mr.None)+(r.includes(s)?mr.Text:mr.None);if(Cr(a))return e.uuid===a?mr.Uuid:mr.None;var o=i.every(function(e){return n.indexOf(e)>=0}),c=i.every(function(e){return r.indexOf(e)>=0});return(o?mr.Title:0)+(c?mr.Text:0)}function Pr(e,t){if(0===t.length)return mr.None;var n=e.title.toLowerCase(),r=t.toLowerCase(),a=r.split(' '),i=Or(r);return i?n.includes(i)?mr.Title:mr.None:a.every(function(e){return n.indexOf(e)>=0})?mr.Title:mr.None}function Or(e){var t=e.match(/"(.*?)"/);return t?t[1]:null}function Cr(e){return!!e.match(/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)}!(function(e){e[e.None=0]="None",e[e.Title=1]="Title",e[e.Text=2]="Text",e[e.TitleAndText=3]="TitleAndText",e[e.Uuid=5]="Uuid"})(mr||(mr={}));var Dr=(function(){function e(t){v(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:br.Create({});this.collection=t,this.criteria=n,this.displayedNotes=[],this.needsRebuilding=!0}return y(e,[{key:"setCriteria",value:function(e){this.criteria=e,this.collection.setDisplayOptions(F.a.Note,e.sortProperty,e.sortDirection),this.needsRebuilding=!0}},{key:"notesMatchingSmartTag",value:function(e){var t;return wr((t=e,br.Create({tags:[t]})),this.collection)}},{key:"rebuildList",value:function(){var e=this,t=br.Copy(this.criteria,{tags:this.criteria.tags.map(function(t){return t.isSystemSmartTag?t:e.collection.find(t.uuid)})});this.displayedNotes=wr(t,this.collection)}},{key:"setNeedsRebuilding",value:function(){this.needsRebuilding=!0}},{key:"displayElements",value:function(){return this.needsRebuilding&&(this.rebuildList(),this.needsRebuilding=!1),this.displayedNotes.slice()}}]),e})(),_r=(function(e){d(n,e);var t=k(n);function n(e){var r,a,i,s;return v(this,n),(r=t.call(this)).payloadManager=e,r.observers=[],r.payloadManager=e,r.systemSmartTags=(a=Object(Ee.e)({uuid:Er,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'All notes',isSystemTag:!0,isAllTag:!0})}),i=Object(Ee.e)({uuid:Rr,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Archived',isSystemTag:!0,isArchiveTag:!0})}),s=Object(Ee.e)({uuid:Ir,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Trash',isSystemTag:!0,isTrashTag:!0})}),[nt(a),nt(i),nt(s)]),r.createCollection(),r.unsubChangeObserver=r.payloadManager.addObserver(F.a.Any,r.setPayloads.bind(u(r))),r}return y(n,[{key:"createCollection",value:function(){this.collection=new gn,this.collection.setDisplayOptions(F.a.Note,dn.CreatedAt,'dsc'),this.collection.setDisplayOptions(F.a.Tag,dn.Title,'dsc'),this.collection.setDisplayOptions(F.a.ItemsKey,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Component,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Theme,dn.Title,'asc'),this.collection.setDisplayOptions(F.a.SmartTag,dn.Title,'asc'),this.notesView=new Dr(this.collection)}},{key:"setDisplayOptions",value:function(e,t,n,r){e===F.a.Note&&console.warn("Called setDisplayOptions with ContentType.Note. setNotesDisplayCriteria should be used instead."),this.collection.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.notesView.setCriteria(e)}},{key:"getDisplayableItems",value:function(e){return e===F.a.Note?this.notesView.displayElements():this.collection.displayElements(e)}},{key:"deinit",value:function(){this.unsubChangeObserver(),this.unsubChangeObserver=void 0,this.payloadManager=void 0,this.collection=void 0,this.notesView=void 0}},{key:"resetState",value:function(){this.createCollection()}},{key:"findItem",value:function(e){return this.collection.find(e)}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.collection.findAll(e,t)}},{key:"itemsKeys",value:function(){return this.collection.displayElements(F.a.ItemsKey)}},{key:"addObserver",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]);var r={contentType:e,callback:t};return this.observers.push(r),function(){Object(_.M)(n.observers,r)}}},{key:"itemsReferencingItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.collection.uuidsThatReferenceUuid(e);return this.findItems(t)}},{key:"referencesForItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.findItem(e).references.map(function(e){return e.uuid});return this.findItems(t)}},{key:"setPayloads",value:function(e,t,n,r,a,i){var s=e.map(function(e){return nt(e)}),o=t.map(function(e){return nt(e)}),c=r.map(function(e){return nt(e)}),u=s.concat(o);u.length>0&&this.collection.set(u);for(var l,p=n.map(function(e){return nt(e)}),d=S(p);!(l=d()).done;){var h=l.value;this.collection.discard(h)}this.notesView.setNeedsRebuilding(),this.notifyObservers(s,o,p,c,a,i)}},{key:"notifyObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return e.filter(function(e){return t.includes(F.a.Any)||t.includes(e.content_type)})},c=S(this.observers.slice());!(s=c()).done;){var u=s.value,l=o(e,u.contentType),p=o(t,u.contentType),d=o(n,u.contentType),h=o(r,u.contentType);0===l.length&&0===p.length&&0===d.length&&0===h.length||u.callback(l,p,d,h,a,i)}}},{key:"changeItem",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=s.length>2&&void 0!==s[2]?s[2]:T.c.UserInteraction,r=s.length>3&&void 0!==s[3]?s[3]:ht.a.LocalChanged,a=s.length>4?s[4]:void 0,Object(_.A)(e)){o.next=5;break}throw Error('Invalid uuid for changeItem');case 5:return o.next=7,b.awrap(this.changeItems([e],t,n,r,a));case 7:return i=o.sent,o.abrupt("return",i[0]);case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:n=h.length>2&&void 0!==h[2]?h[2]:T.c.UserInteraction,r=h.length>3&&void 0!==h[3]?h[3]:ht.a.LocalChanged,a=h.length>4?h[4]:void 0,i=this.findItems(e,!0),s=[],o=S(i);case 6:if((c=o()).done){f.next=16;break}if(u=c.value){f.next=10;break}throw Error('Attempting to change non-existant item');case 10:l=de(u,n),t&&t(l),p=l.getResult(),s.push(p);case 14:f.next=6;break;case 16:return f.next=18,b.awrap(this.payloadManager.emitPayloads(s,r,a));case 18:return d=this.findItems(s.map(function(e){return e.uuid})),f.abrupt("return",d);case 20:case"end":return f.stop()}},null,this,null,Promise)}},{key:"changeNote",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant note');case 6:return s=new pe(i,n),c.abrupt("return",this.applyTransform(s,t,r,a));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeTag",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant tag');case 6:return s=new ce(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeComponent",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant component');case 6:return s=new V(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeFeatureRepo",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant repo');case 6:return s=new Xe(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeActionsExtension",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant extension');case 6:return s=new se(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeItemsKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant itemsKey');case 6:return s=new $(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"applyTransform",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:ht.a.LocalChanged,r=i.length>3?i[3]:void 0,t(e),a=e.getResult(),s.abrupt("return",this.payloadManager.emitPayload(a,n,r));case 5:case"end":return s.stop()}},null,this,null,Promise)}},{key:"setItemDirty",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]&&r[1],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return a.next=5,b.awrap(this.setItemsDirty([e],t));case 5:return n=a.sent,a.abrupt("return",n[0]);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemsDirty",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=n.length>1&&void 0!==n[1]&&n[1],Object(_.A)(e[0])){r.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return r.abrupt("return",this.changeItems(e,void 0,t?T.c.UserInteraction:T.c.Internal));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getDirtyItems",value:function(){return this.collection.dirtyElements().filter(function(e){return e.isSyncable})}},{key:"duplicateItem",value:function(e){var t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return t=o.length>1&&void 0!==o[1]&&o[1],n=o.length>2?o[2]:void 0,r=this.findItem(e),a=Object(Ee.e)(r),c.next=6,b.awrap(ut(a,this.payloadManager.getMasterCollection(),t,n));case 6:return i=c.sent,c.next=9,b.awrap(this.payloadManager.emitPayloads(i,ht.a.LocalChanged));case 9:return s=this.findItem(i[0].uuid),c.abrupt("return",s);case 11:case"end":return c.stop()}},null,this,null,Promise)}},{key:"createItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=i.length>3?i[3]:void 0,e){s.next=4;break}throw'Attempting to create item with no contentType';case 4:return s.t0=Object(Ee.e),s.next=7,b.awrap(I.GenerateUuid());case 7:return s.t1=s.sent,s.t2=e,s.t3=t?Object(Ke.a)(t):void 0,s.t4=n,s.t5={uuid:s.t1,content_type:s.t2,content:s.t3,dirty:s.t4},s.t6=r,a=(0,s.t0)(s.t5,s.t6),s.next=16,b.awrap(this.payloadManager.emitPayload(a,ht.a.Constructor));case 16:return s.abrupt("return",this.findItem(a.uuid));case 17:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Object(Ee.e),r.next=3,b.awrap(I.GenerateUuid());case 3:return r.t1=r.sent,r.t2=e,r.t3=Object(Ke.a)(t||{}),r.t4={uuid:r.t1,content_type:r.t2,content:r.t3},n=(0,r.t0)(r.t4),r.abrupt("return",nt(n));case 9:case"end":return r.stop()}},null,null,null,Promise)}},{key:"insertItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemFromPayload(e.payload));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"insertItems",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemsFromPayloads(e.map(function(e){return e.payload})));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emitItemFromPayload",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:ht.a.Constructor,r.next=3,b.awrap(this.payloadManager.emitPayload(e,t));case 3:return r.abrupt("return",this.findItem(e.uuid));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitItemsFromPayloads",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:ht.a.Constructor,a.next=3,b.awrap(this.payloadManager.emitPayloads(e,t));case 3:return n=Object(Ke.b)(e),a.abrupt("return",this.findItems(n));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemToBeDeleted",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this.collection.uuidsThatReferenceUuid(e),r=this.findItem(e),u.next=4,b.awrap(this.changeItem(e,function(e){e.setDeleted()},void 0,t));case 4:a=u.sent,i=S(n);case 6:if((s=i()).done){u.next=14;break}if(o=s.value,!(c=this.findItem(o))){u.next=12;break}return u.next=12,b.awrap(this.changeItem(c.uuid,function(e){e.removeItemAsRelationship(r)}));case 12:u.next=6;break;case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}},null,this,null,Promise)}},{key:"setItemsToBeDeleted",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.all(e.map(function(e){return t.setItemToBeDeleted(e)})));case 1:case"end":return n.stop()}},null,null,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.collection.all(e);return t?n.filter(function(e){return!e.errorDecrypting&&!e.waitingForKey}):n}},{key:"nonErroredItemsForContentType",value:function(e){return this.collection.all(e).filter(function(e){return!e.errorDecrypting&&!e.waitingForKey})}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.subItemsMatchingPredicates(this.items,e)}},{key:"subItemsMatchingPredicates",value:function(e,t){return e.filter(function(e){if(e.deleted)return!1;for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!e.satisfiesPredicate(a))return!1}return!0})}},{key:"findTagByTitle",value:function(e){var t=e.toLowerCase();return this.tags.find(function(e){return e.title.toLowerCase()===t})}},{key:"searchTags",value:function(e,t){var n=this;return Object(_.G)(this.tags.filter(function(r){var a=new RegExp("^".concat(e,"|").concat(".").concat(e),'i').test(r.title),i=!!t&&n.itemsReferencingItem(t.uuid).some(function(e){return(null===e||void 0===e?void 0:e.uuid)===r.uuid});return a&&!i}),'title')}},{key:"getTagParent",value:function(e){var t=this.findItem(e).parentId;if(t)return this.findItem(t)}},{key:"getTagParentChain",value:function(e){for(var t=this.findItem(e).parentId,n=[];t;){var r=this.findItem(t);n.unshift(r),t=r.parentId}return n}},{key:"getTagChildren",value:function(e){var t=this.findItem(e);return this.collection.elementsReferencingElement(t)}},{key:"isTagAncestor",value:function(e,t){for(var n=this.findItem(t).parentId;n;){if(n===e)return!0;n=this.findItem(n).parentId}return!1}},{key:"isValidTagParent",value:function(e,t){return e!==t&&!this.isTagAncestor(t,e)}},{key:"setTagParent",value:function(e,t){if(e.uuid===t.uuid)throw new Error('can not set a tag parent of itself');if(this.isTagAncestor(t.uuid,e.uuid))throw new Error('can not set a tag ancestor of itself');return this.changeTag(t.uuid,function(t){t.makeChildOf(e)})}},{key:"unsetTagParent",value:function(e){var t=this.getTagParent(e.uuid);return t?this.changeTag(e.uuid,function(e){e.removeItemAsRelationship(t)}):Promise.resolve(e)}},{key:"addTagToNote",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.changeItem(t.uuid,function(t){t.addItemAsRelationship(e)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getSortedTagsForNote",value:function(e){return Object(_.G)(this.itemsReferencingItem(e.uuid).filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===F.a.Tag}),'title')}},{key:"findOrCreateTagByTitle",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.findTagByTitle(e),n.t0=t,n.t0){n.next=6;break}return n.next=5,b.awrap(this.createItem(F.a.Tag,Object(Ke.a)({title:e}),!0));case 5:n.t0=n.sent;case 6:return n.abrupt("return",n.t0);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"notesMatchingSmartTag",value:function(e){return this.notesView.notesMatchingSmartTag(e)}},{key:"emptyTrash",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.trashedItems,t.abrupt("return",this.setItemsToBeDeleted(Object(Ke.b)(e)));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){var e=this.collection.displayElements(F.a.SmartTag);return this.systemSmartTags.concat(e)}},{key:"removeAllItemsFromMemory",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Object(Ke.b)(this.items),t.next=3,b.awrap(this.changeItems(e,function(e){e.setDeleted()},T.c.NonDirtying));case 3:this.resetState(),this.payloadManager.resetState();case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"removeItemLocally",value:function(e){this.collection.discard(e),this.payloadManager.removePayloadLocally(e.payload)}},{key:"items",get:function(){return this.collection.all()}},{key:"nonDeletedItems",get:function(){return this.collection.nondeletedElements()}},{key:"invalidItems",get:function(){return this.collection.invalidElements()}},{key:"notes",get:function(){return this.notesView.displayElements()}},{key:"tags",get:function(){return this.collection.displayElements(F.a.Tag)}},{key:"components",get:function(){return this.collection.displayElements(F.a.Component)}},{key:"trashSmartTag",get:function(){return this.systemSmartTags.find(function(e){return e.isTrashTag})}},{key:"trashedItems",get:function(){return this.notesMatchingSmartTag(this.trashSmartTag)}},{key:"noteCount",get:function(){return this.collection.all(F.a.Note).length}}]),n})(R.a),Er='all-notes',Rr='archived-notes',Ir='trashed-notes';function Mr(e,t){return e.sort(function(e,n){var r=new Date(n.serverUpdatedAt).getTime()-new Date(e.serverUpdatedAt).getTime(),a=0,i=0;return t&&(a=t.indexOf(e.content_type),i=t.indexOf(n.content_type),-1===a&&(a=t.length),-1===i&&(i=t.length)),a===i?r:a<i?-1:1})}var Ar=(function(){function e(t,n){v(this,e),this.discordance=0,this.outOfSync=!1,this.receiver=t,this.maxDiscordance=n,this.reset()}return y(e,[{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"reset",value:function(){this.lastPreSyncSave=void 0,this.lastSyncDate=void 0,this.discordance=0,this.outOfSync=!1}},{key:"getLastClientIntegrityHash",value:function(){return this.lastClientHash}},{key:"clearIntegrityHashes",value:function(){this.lastClientHash=void 0,this.lastServerHash=void 0}},{key:"setIntegrityHashes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.lastClientHash=e,this.lastServerHash=t,!t||0===t.length||!e||e===t?(this.outOfSync&&(this.outOfSync=!1,this.receiver(on.a.ExitOutOfSync)),this.discordance=0):(this.discordance++,this.discordance>=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(on.a.EnterOutOfSync)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordance<this.maxDiscordance}}]),e})(),jr=Object.freeze([F.a.ServerExtension]);function Tr(e){return e.filter(function(e){var t=![ue.a.DecryptedBareObject,ue.a.DecryptedBase64String].includes(e.format),n=jr.includes(e.content_type),r=t||n;return r||console.error('Filtering disallowed payload',e),r})}var Kr=(function(){function e(t,n,r,a,i){v(this,e),this.apiService=t,this.protocolService=n,this.contentType=r,this.customEvent=a,this.limit=i,this.progress={retrievedPayloads:[]}}return y(e,[{key:"run",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.apiService.sync([],this.progress.lastSyncToken,this.progress.paginationToken,this.limit||500,!1,this.contentType,this.customEvent));case 2:return r=s.sent,a=Tr(r.data.retrieved_items.map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)})),s.next=6,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a));case 6:if(i=s.sent,this.progress.retrievedPayloads=this.progress.retrievedPayloads.concat(i),this.progress.lastSyncToken=null===(e=r.data)||void 0===e?void 0:e.sync_token,this.progress.paginationToken=null===(t=r.data)||void 0===t?void 0:t.cursor_token,null===(n=r.data)||void 0===n||!n.cursor_token){s.next=14;break}return s.abrupt("return",this.run());case 14:return s.abrupt("return",this.progress.retrievedPayloads);case 15:case"end":return s.stop()}},null,this,null,Promise)}}]),e})(),Fr=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}if(r=n.value,a=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient)){s.next=7;break}throw'Unable to find decrypted counterpart for rejected payload.';case 7:i=Object(Ee.f)(a,ht.a.RemoteRejected,{lastSyncEnd:new Date,dirty:!1}),e.push(i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRejected));case 12:case"end":return s.stop()}},null,this,null,Promise)}}]),n})();function Lr(e){if(e===ht.a.RemoteRetrieved)return Rt;if(e===ht.a.RemoteSaved)return It;if(e===ht.a.ConflictData||e===ht.a.ConflictUuid)return Et;if(e===ht.a.RemoteRejected)return Fr;throw"No delta class found for source ".concat(ht.a[e])}var Ur,Nr=(function(){function e(t){v(this,e),this.collections=t,Object.freeze(this)}return y(e,[{key:"collectionForSource",value:function(e){return this.collections.find(function(t){return t.source===e})}}]),e})(),Vr=(function(){function e(t,n,r,a,i){v(this,e),this.response=t,this.baseCollection=r,this.historyMap=i,this.relatedCollectionSet=new Nr([bt.WithPayloads(n,ht.a.DecryptedTransient),bt.WithPayloads(a,ht.a.SavedOrSaving)])}return y(e,[{key:"collectionsByProcessingResponse",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return e=[],s.next=3,b.awrap(this.collectionByProcessingPayloads(this.response.retrievedPayloads,ht.a.RemoteRetrieved));case 3:return(t=s.sent).all().length>0&&e.push(t),s.next=7,b.awrap(this.collectionByProcessingPayloads(this.response.savedPayloads,ht.a.RemoteSaved));case 7:if((n=s.sent).all().length>0&&e.push(n),!(this.response.uuidConflictPayloads.length>0)){s.next=14;break}return s.next=12,b.awrap(this.collectionByProcessingPayloads(this.response.uuidConflictPayloads,ht.a.ConflictUuid));case 12:(r=s.sent).all().length>0&&e.push(r);case 14:if(!(this.response.dataConflictPayloads.length>0)){s.next=19;break}return s.next=17,b.awrap(this.collectionByProcessingPayloads(this.response.dataConflictPayloads,ht.a.ConflictData));case 17:(a=s.sent).all().length>0&&e.push(a);case 19:if(!(this.response.rejectedPayloads.length>0)){s.next=24;break}return s.next=22,b.awrap(this.collectionByProcessingPayloads(this.response.rejectedPayloads,ht.a.RemoteRejected));case 22:(i=s.sent).all().length>0&&e.push(i);case 24:return s.abrupt("return",e);case 25:case"end":return s.stop()}},null,this,null,Promise)}},{key:"collectionByProcessingPayloads",value:function(e,t){var n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=bt.WithPayloads(Tr(e),t),r=Lr(t),a=new r(this.baseCollection,n,this.relatedCollectionSet,this.historyMap),c.next=5,b.awrap(a.resultingCollection());case 5:return i=c.sent,s=i.all().map(function(e){var t=o.finalDirtyStateForPayload(e);return Object(Ee.b)(e,{dirty:t,dirtiedDate:t?new Date:void 0})}),c.abrupt("return",bt.WithPayloads(s,t));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"finalDirtyStateForPayload",value:function(e){var t=this.baseCollection.find(e.uuid);return t?!t.dirtiedDate||e.dirtiedDate&&e.dirtiedDate>t.dirtiedDate?e.dirty:!e.discardable&&t.dirtiedDate>=t.lastSyncBegan:e.dirty}}]),e})(),Br=(function(){function e(t){var n,r;v(this,e),this.rawResponse=t,this.savedPayloads=this.filterRawItemArray(null===(n=t.data)||void 0===n?void 0:n.saved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteSaved)}),this.retrievedPayloads=this.filterRawItemArray(null===(r=t.data)||void 0===r?void 0:r.retrieved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)}),this.dataConflictPayloads=this.filterRawItemArray(this.rawDataConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictData)}),this.uuidConflictPayloads=this.filterRawItemArray(this.rawUuidConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictUuid)}),this.rejectedPayloads=this.filterRawItemArray(this.rawRejectedPayloads).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRejected)}),this.deletedPayloads=this.allProcessedPayloads.filter(function(e){return e.discardable}),Object(_.l)(this)}return y(e,[{key:"filterRawItemArray",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return!!e.uuid})}},{key:"error",get:function(){var e;return this.rawResponse.error||(null===(e=this.rawResponse.data)||void 0===e?void 0:e.error)}},{key:"status",get:function(){return this.rawResponse.status}},{key:"lastSyncToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.LastSyncToken]}},{key:"paginationToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.PaginationToken]}},{key:"integrityHash",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.IntegrityResult]}},{key:"checkIntegrity",get:function(){return this.integrityHash&&!this.paginationToken}},{key:"numberOfItemsInvolved",get:function(){return this.allProcessedPayloads.length}},{key:"allProcessedPayloads",get:function(){return this.savedPayloads.concat(this.retrievedPayloads).concat(this.dataConflictPayloads).concat(this.uuidConflictPayloads).concat(this.rejectedPayloads)}},{key:"rawUuidConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.UuidConflict}).map(function(e){return e.unsaved_item||e.item})}},{key:"rawDataConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ConflictingData}).map(function(e){return e.server_item||e.item})}},{key:"rawRejectedPayloads",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ContentTypeError||e.type===Te.a.ContentError}).map(function(e){return e.unsaved_item})}},{key:"rawConflictObjects",get:function(){var e,t,n=(null===(e=this.rawResponse.data)||void 0===e?void 0:e.conflicts)||[],r=(null===(t=this.rawResponse.data)||void 0===t?void 0:t.unsaved)||[];return n.concat(r)}},{key:"hasError",get:function(){return!Object(_.w)(this.rawResponse.error)}}]),e})();!(function(e){e[e.Response=1]="Response",e[e.StatusChanged=2]="StatusChanged"})(Ur||(Ur={}));var Wr=150,Hr=(function(){function e(t,n,r,a,i,s){v(this,e),this.payloads=t,this.receiver=n,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.id=Math.random(),this.responses=[],this.payloads=t,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.receiver=n,this.pendingPayloads=t.slice()}return y(e,[{key:"popPayloads",value:function(e){var t=this.pendingPayloads.slice(0,e);return Object(_.R)(this.pendingPayloads,t),t}},{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.receiver(Ur.StatusChanged,void 0,{completedUploadCount:this.totalUploadCount-this.pendingUploadCount,totalUploadCount:this.totalUploadCount}));case 2:return e=this.popPayloads(this.upLimit),r.next=5,b.awrap(this.apiService.sync(e,this.lastSyncToken,this.paginationToken,this.downLimit,this.checkIntegrity,void 0,void 0));case 5:return t=r.sent,n=new Br(t),this.responses.push(n),this.lastSyncToken=n.lastSyncToken,this.paginationToken=n.paginationToken,r.next=12,b.awrap(this.receiver(Ur.Response,n));case 12:if(this.done){r.next=14;break}return r.abrupt("return",this.run());case 14:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsSavedOrSaving",get:function(){return Object(_.c)(this.payloads,this.pendingPayloads)}},{key:"done",get:function(){return 0===this.pendingPayloads.length&&!this.paginationToken}},{key:"pendingUploadCount",get:function(){return this.pendingPayloads.length}},{key:"totalUploadCount",get:function(){return this.payloads.length}},{key:"upLimit",get:function(){return Wr}},{key:"downLimit",get:function(){return Wr}},{key:"numberOfItemsInvolved",get:function(){for(var e,t=0,n=S(this.responses);!(e=n()).done;){t+=e.value.numberOfItemsInvolved}return t}}]),e})(),zr=(function(){function e(t,n){v(this,e),this.payloads=t,this.receiver=n}return y(e,[{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=this.payloads.map(function(e){return Object(Ee.f)(e,ht.a.LocalSaved,{dirty:!1,lastSyncEnd:new Date})}),t=Object(_.a)(e),n=new Br({data:{saved_items:t}}),r.next=5,b.awrap(this.receiver(Ur.Response,n));case 5:case"end":return r.stop()}},null,this,null,Promise)}}]),e})();function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Qr,Jr,$r,Xr=5,Zr=15;!(function(e){e[e.ResolveOnNext=1]="ResolveOnNext",e[e.ForceSpawnNew=2]="ForceSpawnNew"})(Qr||(Qr={})),(function(e){e[e.Default=1]="Default",e[e.DownloadFirst=2]="DownloadFirst"})(Jr||(Jr={})),(function(e){e[e.External=1]="External",e[e.SpawnQueue=2]="SpawnQueue",e[e.ResolveQueue=3]="ResolveQueue",e[e.MoreDirtyItems=4]="MoreDirtyItems",e[e.AfterDownloadFirst=5]="AfterDownloadFirst",e[e.IntegrityCheck=6]="IntegrityCheck",e[e.ResolveOutOfSync=7]="ResolveOutOfSync"})($r||($r={}));var ea=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).itemManager=e,l.sessionManager=r,l.protocolService=a,l.storageService=i,l.payloadManager=s,l.apiService=o,l.historyService=c,l.resolveQueue=[],l.spawnQueue=[],l.completedOnlineDownloadFirstSync=!1,l.majorChangeThreshold=Zr,l.maxDiscordance=Xr,l.locked=!1,l.databaseLoaded=!1,l.syncLock=!1,l.dealloced=!1,l.localLoadPriorty=[F.a.ItemsKey,F.a.UserPrefs,F.a.Component,F.a.Theme],l.itemManager=e,l.sessionManager=r,l.protocolService=a,l.payloadManager=s,l.storageService=i,l.apiService=o,l.interval=u,l.initializeStatus(),l.initializeState(),l}return y(n,[{key:"onNewDatabaseCreated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.getLastSyncToken());case 2:if(!e.sent){e.next=5;break}return e.next=5,b.awrap(this.clearSyncPositionTokens());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.dealloced=!0,this.sessionManager=void 0,this.itemManager=void 0,this.protocolService=void 0,this.payloadManager=void 0,this.storageService=void 0,this.apiService=void 0,this.interval=void 0,this.state.reset(),this.opStatus.reset(),this.state=void 0,this.opStatus=void 0,this.resolveQueue.length=0,this.spawnQueue.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeStatus",value:function(){var e=this;this.opStatus=new fr(this.interval,function(t){e.notifyEvent(t)})}},{key:"initializeState",value:function(){var e=this;this.state=new Ar(function(t){t===on.a.EnterOutOfSync?e.notifyEvent(on.a.EnterOutOfSync):t===on.a.ExitOutOfSync&&e.notifyEvent(on.a.ExitOutOfSync)},this.maxDiscordance)}},{key:"lockSyncing",value:function(){this.locked=!0}},{key:"unlockSyncing",value:function(){this.locked=!1}},{key:"isOutOfSync",value:function(){return this.state.isOutOfSync()}},{key:"getLastSyncDate",value:function(){return this.state.lastSyncDate}},{key:"getStatus",value:function(){return this.opStatus}},{key:"resetSyncState",value:function(){this.state.reset()}},{key:"isDatabaseLoaded",value:function(){return this.databaseLoaded}},{key:"getDatabasePayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageService.getAllRawPayloads().catch(function(t){throw e.notifyEvent(on.a.DatabaseReadError,t),t}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadDatabasePayloads",value:function(e){var t,n,r,a,i,s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.databaseLoaded){d.next=2;break}throw'Attempting to initialize already initialized local database.';case 2:if(0!==e.length){d.next=6;break}return this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0),d.abrupt("return");case 6:return t=e.map(function(e){try{return Object(Ee.e)(e)}catch(e){return void console.error('Creating payload failed',e)}}).filter(function(e){return!Object(_.w)(e)}),n=Mr(t,this.localLoadPriorty),r=n.filter(function(e){return e.content_type===F.a.ItemsKey}),Object(_.R)(n,r),d.next=12,b.awrap(this.protocolService.payloadsByDecryptingPayloads(r));case 12:return a=d.sent,d.next=15,b.awrap(this.payloadManager.emitPayloads(a,ht.a.LocalRetrieved));case 15:i=n.length,s=100,o=Math.ceil(i/s),c=0;case 19:if(!(c<o)){d.next=32;break}return u=c*s,l=n.slice(u,u+s),d.next=24,b.awrap(this.protocolService.payloadsByDecryptingPayloads(l));case 24:return p=d.sent,d.next=27,b.awrap(this.payloadManager.emitPayloads(p,ht.a.LocalRetrieved));case 27:this.notifyEvent(on.a.LocalDataIncrementalLoad),this.opStatus.setDatabaseLoadStatus(u,i,!1);case 29:c++,d.next=19;break;case 32:this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0);case 34:case"end":return d.stop()}},null,this,null,Promise)}},{key:"setLastSyncToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.syncToken=e,t.abrupt("return",this.storageService.setValue(o.LastSyncToken,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setPaginationToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cursorToken=e,!e){t.next=5;break}return t.abrupt("return",this.storageService.setValue(o.PaginationToken,e));case 5:return t.abrupt("return",this.storageService.removeValue(o.PaginationToken));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLastSyncToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.syncToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.LastSyncToken));case 3:this.syncToken=e.sent;case 4:return e.abrupt("return",this.syncToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPaginationToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cursorToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.PaginationToken));case 3:this.cursorToken=e.sent;case 4:return e.abrupt("return",this.cursorToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"clearSyncPositionTokens",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.syncToken=void 0,this.cursorToken=void 0,e.next=4,b.awrap(this.storageService.removeValue(o.LastSyncToken));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.PaginationToken));case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"itemsNeedingSync",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.itemManager.getDirtyItems(),t.abrupt("return",e);case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"alternateUuidForItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=this.itemManager.findItem(e),n=Object(Ee.e)(t),a.next=4,b.awrap(lt(n,this.payloadManager.getMasterCollection()));case 4:return r=a.sent,a.next=7,b.awrap(this.payloadManager.emitPayloads(r,ht.a.LocalChanged));case 7:return a.next=9,b.awrap(this.persistPayloads(r));case 9:return a.abrupt("return",this.itemManager.findItem(r[0].uuid));case 10:case"end":return a.stop()}},null,this,null,Promise)}},{key:"markAllItemsAsNeedingSync",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.log('Marking all items as needing sync'),e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e,{dirty:!0,dirtiedDate:new Date})}),n.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 5:return n.next=7,b.awrap(this.persistPayloads(t));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"popPayloadsNeedingPreSyncSave",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.state.lastPreSyncSave){r.next=3;break}return r.abrupt("return",e);case 3:return n=e.filter(function(e){return!e.dirtiedDate||e.dirtiedDate>t}),this.state.lastPreSyncSave=new Date,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"queueStrategyResolveOnNext",value:function(){var e=this;return new Promise(function(t,n){e.resolveQueue.push({resolve:t,reject:n})})}},{key:"queueStrategyForceSpawnNew",value:function(e){var t=this;return new Promise(function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})})}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(_.N)(this.spawnQueue,0),this.log('Syncing again from spawn queue'),this.sync(Yr({queueStrategy:Qr.ForceSpawnNew,source:$r.SpawnQueue},e.options)).then(function(){e.resolve()}).catch(function(){e.reject()})}},{key:"payloadsByPreparingForServer",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.protocolService.payloadsByEncryptingPayloads(e,function(e){return jr.includes(e.content_type)?Re.b.SyncDecrypted:Re.b.Sync}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"downloadFirstSync",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:n=5,r=0;case 2:if(!(r<n)){a.next=14;break}return a.next=5,b.awrap(this.sync(Yr({mode:Jr.DownloadFirst,queueStrategy:Qr.ForceSpawnNew},t)).catch(console.error));case 5:if(!this.completedOnlineDownloadFirstSync){a.next=9;break}return a.abrupt("return");case 9:return a.next=11,b.awrap(Object(_.P)(e));case 11:r++,a.next=2;break;case 14:console.error("Failed downloadFirstSync after ".concat(n," tries"));case 15:case"end":return a.stop()}},null,this,null,Promise)}},{key:"awaitCurrentSyncs",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.lastSyncInvokationPromise);case 2:return e.next=4,b.awrap(this.currentSyncRequestPromise);case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"sync",value:function(){var e,t=arguments;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},this.lastSyncInvokationPromise=this.performSync(e),n.abrupt("return",this.lastSyncInvokationPromise);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"performSync",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P=this,O=arguments;return b.async(function(C){for(;;)switch(C.prev=C.next){case 0:if(e=O.length>0&&void 0!==O[0]?O[0]:{},!this.locked){C.next=4;break}return this.log('Sync Locked'),C.abrupt("return");case 4:return t=function(){return P.syncLock},n=function(){P.syncLock=!0},r=function(){P.syncLock=!1},a=this.opStatus.syncInProgress,i=this.databaseLoaded,(s=!t())&&i&&!a&&n(),e.source||(e.source=$r.External),C.next=14,b.awrap(this.itemsNeedingSync());case 14:return o=C.sent,c=new Date,u=o.filter(function(e){return e.neverSynced&&e.deleted}),Object(_.R)(o,u),l=o.map(function(e){return e.payloadRepresentation()}),C.next=21,b.awrap(this.popPayloadsNeedingPreSyncSave(l));case 21:return p=C.sent,C.next=24,b.awrap(this.persistPayloads(p));case 24:if(d=this.resolveQueue.slice(),h=Object(_.w)(e.queueStrategy)?Qr.ResolveOnNext:e.queueStrategy,!a&&i&&s){C.next=37;break}if(this.log(s?a?'Attempting to sync while existing sync in progress.':'Attempting to sync before local database has loaded.':'Another function call has begun preparing for sync.'),h!==Qr.ResolveOnNext){C.next=32;break}return C.abrupt("return",this.queueStrategyResolveOnNext());case 32:if(h!==Qr.ForceSpawnNew){C.next=36;break}return C.abrupt("return",this.queueStrategyForceSpawnNew({mode:e.mode,checkIntegrity:e.checkIntegrity,source:e.source}));case 36:throw Error("Unhandled timing strategy ".concat(h));case 37:if(!this.dealloced){C.next=39;break}return C.abrupt("return");case 39:return this.opStatus.setDidBegin(),C.next=42,b.awrap(this.notifyEvent(on.a.SyncWillBegin));case 42:if(Object(_.R)(this.resolveQueue,d),!(o.length>0)){C.next=46;break}return C.next=46,b.awrap(this.itemManager.changeItems(Object(Ke.b)(o),function(e){e.lastSyncBegan=c},T.c.NonDirtying,ht.a.PreSyncSave));case 46:if(this.protocolService.hasAccount()!==this.sessionManager.online()&&this.handleInvalidSessionState(),f=this.sessionManager.online(),D=e.mode,v=f&&!P.completedOnlineDownloadFirstSync?Jr.DownloadFirst:Object(_.w)(D)?Jr.Default:D,y=[],v!==Jr.Default){C.next=63;break}if(!f||this.completedOnlineDownloadFirstSync){C.next=54;break}throw Error('Attempting to default mode sync without having completed initial.');case 54:if(!f){C.next=60;break}return C.next=57,b.awrap(this.payloadsByPreparingForServer(l));case 57:y=C.sent,C.next=61;break;case 60:y=l;case 61:C.next=64;break;case 63:v===Jr.DownloadFirst&&(y=[]);case 64:if(!f){C.next=70;break}return C.next=67,b.awrap(this.syncOnlineOperation(y,e.checkIntegrity,e.source,v));case 67:g=C.sent,C.next=73;break;case 70:return C.next=72,b.awrap(this.syncOfflineOperation(y,e.source,v));case 72:g=C.sent;case 73:return this.currentSyncRequestPromise=g.run(),C.next=76,b.awrap(this.currentSyncRequestPromise);case 76:if(!this.dealloced){C.next=78;break}return C.abrupt("return");case 78:if(this.opStatus.setDidEnd(),r(),!this.opStatus.hasError()){C.next=82;break}return C.abrupt("return");case 82:if(this.opStatus.reset(),this.state.lastSyncDate=new Date,g instanceof Hr&&g.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(on.a.MajorDataChange),!(u.length>0)){C.next=88;break}return C.next=88,b.awrap(this.handleNeverSyncedDeleted(u));case 88:if(v===Jr.DownloadFirst){C.next=91;break}return C.next=91,b.awrap(this.notifyEvent(on.a.FullSyncCompleted,{source:e.source}));case 91:if(v!==Jr.DownloadFirst){C.next=99;break}return f&&(this.completedOnlineDownloadFirstSync=!0),C.next=95,b.awrap(this.notifyEvent(on.a.DownloadFirstSyncCompleted));case 95:return C.next=97,b.awrap(this.sync({source:$r.AfterDownloadFirst,checkIntegrity:!0,awaitAll:e.awaitAll}));case 97:C.next=125;break;case 99:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){C.next=107;break}if(this.log('Syncing again from resolve queue'),m=this.sync({source:$r.ResolveQueue,checkIntegrity:e.checkIntegrity}),!e.awaitAll){C.next=105;break}return C.next=105,b.awrap(m);case 105:C.next=125;break;case 107:return C.next=109,b.awrap(this.itemsNeedingSync());case 109:if(C.t0=C.sent.length,!(C.t0>0)){C.next=115;break}return C.next=113,b.awrap(this.sync({source:$r.MoreDirtyItems,checkIntegrity:e.checkIntegrity,awaitAll:e.awaitAll}));case 113:C.next=125;break;case 115:if(!(g instanceof Hr&&g.checkIntegrity)){C.next=124;break}if(!this.state.needsSync||!g.done){C.next=122;break}if(this.log('Syncing again from integrity check'),w=this.sync({checkIntegrity:!0,queueStrategy:Qr.ForceSpawnNew,source:$r.IntegrityCheck,awaitAll:e.awaitAll}),!e.awaitAll){C.next=122;break}return C.next=122,b.awrap(w);case 122:C.next=125;break;case 124:this.state.clearIntegrityHashes();case 125:for(k=S(d);!(x=k()).done;)x.value.resolve();case 126:case"end":return C.stop()}var D},null,this,null,Promise)}},{key:"handleInvalidSessionState",value:function(){we.a.error(Error('Session missing while attempting to sync.')),this.sessionManager.reauthenticateInvalidSession()}},{key:"syncOnlineOperation",value:function(e,t,n,r){var a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.t0=Hr,s.t1=e,s.t2=function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next=r.t0===Ur.Response?3:r.t0===Ur.StatusChanged?13:15;break;case 3:if(!i.dealloced){r.next=5;break}return r.abrupt("return");case 5:if(!t.hasError){r.next=10;break}return r.next=8,b.awrap(i.handleErrorServerResponse(t));case 8:r.next=12;break;case 10:return r.next=12,b.awrap(i.handleSuccessServerResponse(a,t));case 12:return r.abrupt("break",15);case 13:return i.opStatus.setUploadStatus(n.completedUploadCount,n.totalUploadCount),r.abrupt("break",15);case 15:case"end":return r.stop()}},null,null,null,Promise)},s.next=5,b.awrap(this.getLastSyncToken());case 5:return s.t3=s.sent,s.next=8,b.awrap(this.getPaginationToken());case 8:return s.t4=s.sent,s.t5=t,s.t6=this.apiService,a=new s.t0(s.t1,s.t2,s.t3,s.t4,s.t5,s.t6),this.log('Syncing online user','source:',n,'operation id',a.id,'integrity check',t,'mode:',r,'payloads:',e),s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"syncOfflineOperation",value:function(e,t,n){var r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return this.log('Syncing offline user','source:',t,'mode:',n,'payloads:',e),r=new zr(e,function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!a.dealloced){n.next=2;break}return n.abrupt("return");case 2:if(e!==Ur.Response){n.next=5;break}return n.next=5,b.awrap(a.handleOfflineResponse(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}),i.abrupt("return",r);case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleOfflineResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.log('Offline Sync Response',e.rawResponse),!((t=e.savedPayloads).length>0)){a.next=8;break}return a.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalSaved));case 5:return n=this.payloadManager.find(Object(Ke.b)(t)),a.next=8,b.awrap(this.persistPayloads(n));case 8:if(!((r=e.deletedPayloads).length>0)){a.next=12;break}return a.next=12,b.awrap(this.deletePayloads(r));case 12:return this.opStatus.clearError(),this.opStatus.setDownloadStatus(e.retrievedPayloads.length),a.next=16,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,e));case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleErrorServerResponse",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.log('Sync Error',e),401===e.status&&this.notifyEvent(on.a.InvalidSession),null===(t=this.opStatus)||void 0===t||t.setError(e.error),this.notifyEvent(on.a.SyncError,e.error);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleSuccessServerResponse",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k;return b.async(function(x){for(;;)switch(x.prev=x.next){case 0:if(!this._simulate_latency){x.next=3;break}return x.next=3,b.awrap(Object(_.P)(this._simulate_latency.latency));case 3:this.log('Online Sync Response','operation id',e.id,t.rawResponse),this.setLastSyncToken(t.lastSyncToken),this.setPaginationToken(t.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus(t.retrievedPayloads.length),n=[],r=t.allProcessedPayloads,a={},i=S(r);case 12:if((s=i()).done){x.next=25;break}if(!(o=s.value).deleted&&o.fields.includes(Je.a.Content)){x.next=16;break}return x.abrupt("continue",23);case 16:return c=a[o.items_key_id],u=c?nt(c):void 0,x.next=20,b.awrap(this.protocolService.payloadByDecryptingPayload(o,u));case 20:(l=x.sent).content_type===F.a.ItemsKey&&(a[l.uuid]=l),n.push(l);case 23:x.next=12;break;case 25:return p=this.payloadManager.getMasterCollection(),d=this.historyService.getHistoryMapCopy(),h=new Vr(t,n,p,e.payloadsSavedOrSaving,d),x.next=30,b.awrap(h.collectionsByProcessingResponse());case 30:f=x.sent,v=S(f);case 32:if((y=v()).done){x.next=41;break}return g=y.value,x.next=36,b.awrap(this.payloadManager.emitCollection(g));case 36:return m=x.sent,x.next=39,b.awrap(this.persistPayloads(m));case 39:x.next=32;break;case 41:if(!((w=t.deletedPayloads).length>0)){x.next=45;break}return x.next=45,b.awrap(this.deletePayloads(w));case 45:return x.next=47,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,t));case 47:if(!t.checkIntegrity){x.next=53;break}return x.next=50,b.awrap(this.computeDataIntegrityHash());case 50:return k=x.sent,x.next=53,b.awrap(this.state.setIntegrityHashes(k,t.integrityHash));case 53:case"end":return x.stop()}},null,this,null,Promise)}},{key:"handleNeverSyncedDeleted",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e.map(function(e){return e.payloadRepresentation({dirty:!1})}),n.next=3,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.persistPayloads(t));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistPayloads",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(0!==e.length&&!this.dealloced){n.next=2;break}return n.abrupt("return");case 2:return n.abrupt("return",this.storageService.savePayloads(e).catch(function(e){t.notifyEvent(on.a.DatabaseWriteError,e),we.a.error(e)}));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.persistPayloads(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"computeDataIntegrityHash",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:u.prev=0,e=this.itemManager.nonDeletedItems.sort(function(e,t){return t.serverUpdatedAtTimestamp-e.serverUpdatedAtTimestamp}),t=[],n=1e3,r=S(e);case 5:if((a=r()).done){u.next=14;break}if(i=a.value,s=i.serverUpdatedAtTimestamp){u.next=10;break}return u.abrupt("return",void 0);case 10:o=Math.floor(s/n),t.push(o);case 12:u.next=5;break;case 14:return c=t.join(','),u.abrupt("return",this.protocolService.crypto.sha256(c));case 18:return u.prev=18,u.t0=u.catch(0),console.error('Error computing data integrity hash',u.t0),u.abrupt("return",void 0);case 22:case"end":return u.stop()}},null,this,[[0,18]],Promise)}},{key:"resolveOutOfSync",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=new Kr(this.apiService,this.protocolService,void 0,'resolve-out-of-sync'),a.next=3,b.awrap(e.run());case 3:return t=a.sent,n=new _t(this.payloadManager.getMasterCollection(),bt.WithPayloads(t,ht.a.RemoteRetrieved),void 0,this.historyService.getHistoryMapCopy()),a.next=7,b.awrap(n.resultingCollection());case 7:return r=a.sent,a.next=10,b.awrap(this.payloadManager.emitCollection(r));case 10:return a.next=12,b.awrap(this.persistPayloads(r.payloads));case 12:return a.abrupt("return",this.sync({checkIntegrity:!0,source:$r.ResolveOutOfSync}));case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"statelessDownloadAllItems",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=new Kr(this.apiService,this.protocolService,e,t),a.next=3,b.awrap(n.run());case 3:return r=a.sent,a.abrupt("return",r.map(function(e){return nt(e)}));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_clearLastSyncDate",value:function(){this.state.lastSyncDate=void 0}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=void 0}}]),n})(R.a),ta=(function(){function e(t,n,r,a,i,s){v(this,e),this.challenge=t,this.onValidValue=n,this.onInvalidValue=r,this.onNonvalidatedSubmit=a,this.onComplete=i,this.onCancel=s,this.nonvalidatedValues=[],this.validValues=[],this.invalidValues=[],this.artifacts={}}return y(e,[{key:"complete",value:function(e){var t;e||(e=new be(this.challenge,this.validValues,this.artifacts)),null===(t=this.onComplete)||void 0===t||t.call(this,e)}},{key:"nonvalidatedSubmit",value:function(){var e,t=new be(this.challenge,this.nonvalidatedValues.slice(),this.artifacts);null===(e=this.onNonvalidatedSubmit)||void 0===e||e.call(this,t),this.nonvalidatedValues=[]}},{key:"cancel",value:function(){var e;null===(e=this.onCancel)||void 0===e||e.call(this)}},{key:"isFinished",value:function(){return this.validValues.length===this.challenge.prompts.length}},{key:"nonvalidatedPrompts",value:function(){return this.challenge.prompts.filter(function(e){return!e.validates})}},{key:"addNonvalidatedValue",value:function(e){var t=this.nonvalidatedValues,n=t.find(function(t){return t.prompt.id===e.prompt.id});n&&Object(_.M)(t,n),t.push(e),this.nonvalidatedValues.length===this.nonvalidatedPrompts().length&&this.nonvalidatedSubmit()}},{key:"setValueStatus",value:function(e,t,n){var r,a,i=t?this.validValues:this.invalidValues,s=i.find(function(t){return t.prompt.validation===e.prompt.validation});(s&&Object(_.M)(i,s),i.push(e),w(this.artifacts,n),this.isFinished())?this.complete():t?null===(r=this.onValidValue)||void 0===r||r.call(this,e):null===(a=this.onInvalidValue)||void 0===a||a.call(this,e)}}]),e})(),na=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.protocolService=r,a.challengeOperations={},a.challengeObservers={},a}return y(n,[{key:"deinit",value:function(){this.storageService=void 0,this.protocolService=void 0,this.sendChallenge=void 0,this.challengeOperations=void 0,this.challengeObservers=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"promptForChallengeResponse",value:function(e){var t=this;return new Promise(function(n){t.createOrGetChallengeOperation(e,n),t.sendChallenge(e)})}},{key:"validateChallengeValue",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.prompt.validation,t.next=t.t0===te.LocalPasscode?3:t.t0===te.AccountPassword?4:t.t0===te.Biometric?5:t.t0===te.ProtectionSessionDuration?6:7;break;case 3:return t.abrupt("return",this.protocolService.validatePasscode(e.value));case 4:return t.abrupt("return",this.protocolService.validateAccountPassword(e.value));case 5:return t.abrupt("return",{valid:!0===e.value});case 6:return t.abrupt("return",{valid:(n=e.value,'number'==typeof n&&Object.values(er).includes(n))});case 7:throw Error("Unhandled validation mode ".concat(e.prompt.validation));case 8:case"end":return t.stop()}var n},null,this,null,Promise)}},{key:"promptForCorrectPasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=new ye([new ge(te.LocalPasscode)],e,!0),a.next=3,b.awrap(this.promptForChallengeResponse(t));case 3:if(n=a.sent){a.next=6;break}return a.abrupt("return",void 0);case 6:return r=n.getValueForType(te.LocalPasscode),a.abrupt("return",r.value);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",{});case 2:if(e){n.next=8;break}return n.next=5,b.awrap(this.promptForCorrectPasscode(ne.ResaveRootKey));case 5:if(e=n.sent){n.next=8;break}return n.abrupt("return",{canceled:!0});case 8:return n.next=10,b.awrap(this.protocolService.computeWrappingKey(e));case 10:return t=n.sent,n.abrupt("return",{wrappingKey:t});case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"isPasscodeLocked",value:function(){return this.protocolService.rootKeyNeedsUnwrapping()}},{key:"addChallengeObserver",value:function(e,t){var n=this.challengeObservers[e.id]||[];return n.push(t),this.challengeObservers[e.id]=n,function(){Object(_.M)(n,t)}}},{key:"createOrGetChallengeOperation",value:function(e,t){var n=this,r=this.getChallengeOperation(e);return r||(r=new ta(e,function(t){n.onChallengeValidValue(e,t)},function(t){n.onChallengeInvalidValue(e,t)},function(r){n.onChallengeNonvalidatedSubmit(e,r),t(r)},function(r){n.onChallengeComplete(e,r),t(r)},function(){n.onChallengeCancel(e),t(void 0)}),this.challengeOperations[e.id]=r),r}},{key:"performOnObservers",value:function(e,t){for(var n,r=S(this.challengeObservers[e.id]||[]);!(n=r()).done;){t(n.value)}}},{key:"onChallengeValidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onValidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeInvalidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onInvalidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeNonvalidatedSubmit",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onNonvalidatedSubmit)||void 0===n||n.call(e,t)})}},{key:"onChallengeComplete",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onComplete)||void 0===n||n.call(e,t)})}},{key:"onChallengeCancel",value:function(e){this.performOnObservers(e,function(e){var t;null===(t=e.onCancel)||void 0===t||t.call(e)})}},{key:"getChallengeOperation",value:function(e){return this.challengeOperations[e.id]}},{key:"deleteChallengeOperation",value:function(e){delete this.challengeOperations[e.challenge.id]}},{key:"cancelChallenge",value:function(e){var t=this.challengeOperations[e.id];t.cancel(),this.deleteChallengeOperation(t)}},{key:"completeChallenge",value:function(e){var t=this.challengeOperations[e.id];t.complete(),this.deleteChallengeOperation(t)}},{key:"submitValuesForChallenge",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(0!==t.length){c.next=2;break}throw Error('Attempting to submit 0 values for challenge');case 2:n=S(t);case 3:if((r=n()).done){c.next=18;break}if((a=r.value).prompt.validates){c.next=10;break}this.getChallengeOperation(e).addNonvalidatedValue(a),c.next=16;break;case 10:return c.next=12,b.awrap(this.validateChallengeValue(a));case 12:i=c.sent,s=i.valid,o=i.artifacts,this.setValidationStatusForChallenge(e,a,s,o);case 16:c.next=3;break;case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"setValidationStatusForChallenge",value:function(e,t,n,r){var a=this.getChallengeOperation(e);a.setValueStatus(t,n,r),a.isFinished()&&(this.deleteChallengeOperation(a),delete this.challengeObservers[a.challenge.id])}}]),n})(R.a),ra=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).singletonManager=e,i.itemManager=r,i.syncService=a,i.shouldReload=!0,i.reloading=!1,i.removeItemObserver=r.addObserver(F.a.UserPrefs,function(){i.shouldReload=!0}),i.removeSyncObserver=a.addEventObserver(function(e){e===on.a.FullSyncCompleted&&i.reload()}),i}return y(n,[{key:"deinit",value:function(){var e,t;null===(e=this.removeItemObserver)||void 0===e||e.call(this),null===(t=this.removeSyncObserver)||void 0===t||t.call(this),this.singletonManager=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.LoadedDatabase_12&&(this.preferences=this.singletonManager.findSingleton(z.singletonPredicate),this.preferences&&this.notifyEvent("preferencesChanged"));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){var n,r;return null!==(n=null===(r=this.preferences)||void 0===r?void 0:r.getPref(e))&&void 0!==n?n:t}},{key:"setValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.preferences){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,b.awrap(this.itemManager.changeItem(this.preferences.uuid,function(n){n.setPref(e,t)}));case 4:this.preferences=n.sent,this.notifyEvent("preferencesChanged"),this.syncService.sync();case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"reload",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.shouldReload&&!this.reloading){t.next=2;break}return t.abrupt("return");case 2:return this.reloading=!0,t.prev=3,e=this.preferences,t.next=7,b.awrap(this.singletonManager.findOrCreateSingleton(z.singletonPredicate,F.a.UserPrefs,Object(Ke.a)({})));case 7:this.preferences=t.sent,((null===e||void 0===e?void 0:e.uuid)!==this.preferences.uuid||this.preferences.userModifiedDate>e.userModifiedDate)&&this.notifyEvent('preferencesChanged'),this.shouldReload=!1;case 10:return t.prev=10,this.reloading=!1,t.finish(10);case 13:case"end":return t.stop()}},null,this,[[3,,10,13]],Promise)}}]),n})(R.a),aa=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).settingsService=e,i.crypto=r,i.featuresService=a,i}return y(n,[{key:"saveMfaSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.updateSetting(pr.SettingName.MfaSecret,e,!0));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaActivated",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.getSensitiveSetting(pr.SettingName.MfaSecret));case 2:return e=t.sent,t.abrupt("return",null!=e&&0!=e);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.crypto.generateOtpSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.totpToken(e,Date.now(),6,30));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null!=t,!n.t0){n.next=7;break}return n.t1=t,n.next=5,b.awrap(this.getOtpToken(e));case 5:n.t2=n.sent,n.t0=n.t1===n.t2;case 7:if(n.t0){n.next=10;break}throw new Error(j.S.IncorrectMfa);case 10:return n.abrupt("return",this.saveMfaSetting(e));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.settingsService.deleteSetting(pr.SettingName.MfaSecret));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){var e,t=this.featuresService.getFeature(L.FeatureIdentifier.TwoFactorAuth);return void 0!=t&&(!0===t.no_expire||(null!==(e=t.expires_at)&&void 0!==e?e:0)>Date.now())}},{key:"deinit",value:function(){this.settingsService=void 0,this.crypto=void 0,this.featuresService=void 0,p(f(n.prototype),"deinit",this).call(this)}}]),n})(R.a);function ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(n),!0).forEach(function(t){oa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=(function(){function e(t,n,r,a,i,s,o,c,u){v(this,e);var l=arguments.length>9&&void 0!==arguments[9]&&arguments[9],p=arguments.length>10?arguments[10]:void 0;if(this.environment=t,this.platform=n,this.deviceInterface=r,this.crypto=a,this.alertService=i,this.identifier=s,this.swapClasses=o,this.defaultHost=c,this.appVersion=u,this.enableV4=l,this.webSocketUrl=p,this.eventHandlers=[],this.services=[],this.streamRemovers=[],this.serviceObservers=[],this.managedSubscribers=[],this.createdNewDatabase=!1,this.started=!1,this.launched=!1,this.dealloced=!1,this.revokingSession=!1,this.handledFullSyncStage=!1,!we.a.onLog)throw Error('SNLog.onLog must be set.');if(!we.a.onError)throw Error('SNLog.onError must be set.');if(!r)throw Error('Device Interface must be supplied.');if(!t)throw Error('Environment must be supplied when creating an application.');if(!n)throw Error('Platform must be supplied when creating an application.');if(!a)throw Error('Crypto has to be supplied when creating an application.');if(!i)throw Error('AlertService must be supplied when creating an application.');if(!s)throw Error('ApplicationIdentifier must be supplied when creating an application.');if(!o)throw Error('SwapClasses array must be supplied when creating an application.');if(!c)throw Error('defaultHost must be supplied when creating an application.');if(!u)throw Error('appVersion must be supplied when creating an application.');this.constructServices()}return y(e,[{key:"prepareForLaunch",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.setLaunchCallback(e),r.next=3,b.awrap(this.deviceInterface.openDatabase(this.identifier).catch(function(e){n.notifyEvent(At.a.LocalDatabaseReadError,e)}));case 3:return t=r.sent,this.createdNewDatabase=(null===t||void 0===t?void 0:t.isNewDatabase)||!1,r.next=7,b.awrap(this.migrationService.initialize());case 7:return r.next=9,b.awrap(this.notifyEvent(At.a.MigrationsLoaded));case 9:return r.next=11,b.awrap(this.handleStage(ve.PreparingForLaunch_0));case 11:return r.next=13,b.awrap(this.storageService.initializeFromDisk());case 13:return r.next=15,b.awrap(this.notifyEvent(At.a.StorageReady));case 15:return r.next=17,b.awrap(this.protocolService.initialize());case 17:return r.next=19,b.awrap(this.handleStage(ve.ReadyForLaunch_05));case 19:return this.started=!0,r.next=22,b.awrap(this.notifyEvent(At.a.Started));case 22:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setLaunchCallback",value:function(e){this.challengeService.sendChallenge=e.receiveChallenge}},{key:"launch",value:function(){var e,t,n,r,a,i=this,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(e=s.length>0&&void 0!==s[0]&&s[0],this.launched=!1,!(t=this.getLaunchChallenge())){o.next=11;break}return o.next=6,b.awrap(this.challengeService.promptForChallengeResponse(t));case 6:if(n=o.sent){o.next=9;break}throw Error('Launch challenge was cancelled.');case 9:return o.next=11,b.awrap(this.handleLaunchChallengeResponse(n));case 11:if(!this.storageService.isStorageWrapped()){o.next=20;break}return o.prev=12,o.next=15,b.awrap(this.storageService.decryptStorage());case 15:o.next=20;break;case 17:o.prev=17,o.t0=o.catch(12),this.alertService.alert(j.B.StorageDecryptErrorBody,j.B.StorageDecryptErrorTitle);case 20:return o.next=22,b.awrap(this.handleStage(ve.StorageDecrypted_09));case 22:return o.next=24,b.awrap(this.apiService.loadHost());case 24:return o.next=26,b.awrap(this.webSocketsService.loadWebSocketUrl());case 26:return o.next=28,b.awrap(this.sessionManager.initializeFromDisk());case 28:return this.historyManager.initializeFromDisk(),this.settingsService.initializeFromDisk(),o.next=32,b.awrap(this.featuresService.initializeFromDisk());case 32:return this.launched=!0,o.next=35,b.awrap(this.notifyEvent(At.a.Launched));case 35:return o.next=37,b.awrap(this.handleStage(ve.Launched_10));case 37:return o.next=39,b.awrap(this.syncService.getDatabasePayloads());case 39:return r=o.sent,o.next=42,b.awrap(this.handleStage(ve.LoadingDatabase_11));case 42:if(!this.createdNewDatabase){o.next=45;break}return o.next=45,b.awrap(this.syncService.onNewDatabaseCreated());case 45:if(a=this.syncService.loadDatabasePayloads(r).then(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.dealloced){e.next=2;break}throw'Application has been destroyed.';case 2:return e.next=4,b.awrap(i.handleStage(ve.LoadedDatabase_12));case 4:return i.beginAutoSyncTimer(),e.next=7,b.awrap(i.syncService.sync({mode:Jr.DownloadFirst}));case 7:case"end":return e.stop()}},null,null,null,Promise)}),!e){o.next=49;break}return o.next=49,b.awrap(a);case 49:case"end":return o.stop()}},null,this,[[12,17]],Promise)}},{key:"onStart",value:function(){}},{key:"onLaunch",value:function(){}},{key:"getLaunchChallenge",value:function(){return this.protectionService.createLaunchChallenge()}},{key:"handleLaunchChallengeResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!e.challenge.hasPromptForValidationType(te.LocalPasscode)){a.next=9;break}if(n=null===(t=e.artifacts)||void 0===t?void 0:t.wrappingKey){a.next=7;break}return r=e.getValueForType(te.LocalPasscode),a.next=6,b.awrap(this.protocolService.computeWrappingKey(r.value));case 6:n=a.sent;case 7:return a.next=9,b.awrap(this.protocolService.unwrapRootKey(n));case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval(function(){e.syncService.log('Syncing from autosync'),e.sync()},3e4)}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(this.services);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(r.handleApplicationStage(e));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(_.M)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver(function(n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:n===e&&t(e);case 1:case"end":return r.stop()}},null,null,null,Promise)},e)}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e===At.a.Started?this.onStart():e===At.a.Launched&&this.onLaunch(),n=S(this.eventHandlers.slice());case 2:if((r=n()).done){i.next=14;break}if(!(a=r.value).singleEvent||a.singleEvent!==e){i.next=9;break}return i.next=7,b.awrap(a.callback(e,t||{}));case 7:i.next=12;break;case 9:if(a.singleEvent){i.next=12;break}return i.next=12,b.awrap(a.callback(e,t||{}));case 12:i.next=2;break;case 14:this.migrationService.handleApplicationEvent(e);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date}),n.next=3,b.awrap(this.payloadManager.emitPayload(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.syncService.sync());case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"findItem",value:function(e){return this.itemManager.findItem(e)}},{key:"allItems",value:function(){return this.itemManager.items}},{key:"findItems",value:function(e){return this.itemManager.itemsMatchingPredicate(e)}},{key:"getAll",value:function(e){return this.itemManager.findItems(e)}},{key:"mergeItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.emitItemFromPayload(e.payloadRepresentation(),t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createManagedItem",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=a.length>3?a[3]:void 0,i.abrupt("return",this.itemManager.createItem(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.createTemplateItem(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createItemFromPayload",value:function(e){return nt(e)}},{key:"createPayloadFromObject",value:function(e){return Object(Ee.e)(e)}},{key:"getLastSyncDate",value:function(){return this.syncService.getLastSyncDate()}},{key:"getSyncStatus",value:function(){return this.syncService.getStatus()}},{key:"getSessions",value:function(){return this.sessionManager.getSessionsList()}},{key:"revokeSession",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeSessionRevoking());case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.sessionManager.revokeSession(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.revokeAllOtherSessions());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"userCanManageSessions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent,!Object(_.w)(e)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",Object(Q.b)(e,Q.a.V004)>=0);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUserSubscription",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.sessionManager.getSubscription());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data.subscription);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getAvailableSubscriptions());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setItemNeedsSync",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]&&n[1],r.abrupt("return",this.itemManager.setItemDirty(e.uuid,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setItemsNeedsSync",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 2:return t.next=4,b.awrap(this.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emptyTrash",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.itemManager.emptyTrash());case 2:return e.next=4,b.awrap(this.sync());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getTrashedItems",value:function(){return this.itemManager.trashedItems}},{key:"setDisplayOptions",value:function(e,t,n,r){this.itemManager.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.itemManager.setNotesDisplayCriteria(e)}},{key:"getDisplayableItems",value:function(e){return this.itemManager.getDisplayableItems(e)}},{key:"insertItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=de(e,T.c.UserInteraction),n=t.getResult(),a.next=4,b.awrap(this.itemManager.emitItemFromPayload(n));case 4:return r=a.sent,a.abrupt("return",r);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"saveItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.itemManager.findItem(e)){n.next=3;break}throw Error('Attempting to save non-inserted item');case 3:if(t.dirty){n.next=6;break}return n.next=6,b.awrap(this.itemManager.changeItem(e,void 0,T.c.Internal));case 6:return n.next=8,b.awrap(this.syncService.sync());case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,Object(_.A)(e)){s.next=5;break}throw Error('Must use uuid to change item');case 5:return s.next=7,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0,r));case 7:return s.next=9,b.awrap(this.syncService.sync(a));case 9:return s.abrupt("return",this.findItem(e));case 10:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItems",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,s.next=5,b.awrap(this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0,r));case 5:return s.next=7,b.awrap(this.syncService.sync(a));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeItem",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=!(r.length>2&&void 0!==r[2])||r[2],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid to change item');case 3:return a.next=5,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0));case 5:return a.abrupt("return",this.findItem(e));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=!(r.length>2&&void 0!==r[2])||r[2],a.abrupt("return",this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"protectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNote(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNote(e));case 2:return t=n.sent,Object(_.w)(t)||this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.authorizeProtectedActionForNotes(e,t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.itemManager.getItems(e,t)}},{key:"notesMatchingSmartTag",value:function(e){return this.itemManager.notesMatchingSmartTag(e)}},{key:"referencesForItem",value:function(e,t){var n=this.itemManager.referencesForItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"referencingForItem",value:function(e,t){var n=this.itemManager.itemsReferencingItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"duplicateItem",value:function(e,t){var n=this.itemManager.duplicateItem(e.uuid,!1,t);return this.sync(),n}},{key:"findTagByTitle",value:function(e){return this.itemManager.findTagByTitle(e)}},{key:"searchTags",value:function(e,t){return this.itemManager.searchTags(e,t)}},{key:"isValidTagParent",value:function(e,t){return this.itemManager.isValidTagParent(e,t)}},{key:"setTagParent",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.itemManager.setTagParent(e,t));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unsetTagParent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.unsetTagParent(e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getTagParent",value:function(e){return this.itemManager.getTagParent(e.uuid)}},{key:"getTagParentChain",value:function(e){return this.itemManager.getTagParentChain(e.uuid)}},{key:"getTagChildren",value:function(e){return this.itemManager.getTagChildren(e.uuid)}},{key:"getSortedTagsForNote",value:function(e){return this.itemManager.getSortedTagsForNote(e)}},{key:"findOrCreateTag",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.findOrCreateTagByTitle(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){return this.itemManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.itemManager.noteCount}},{key:"streamItems",value:function(e,t){var n=this,r=this.itemManager.addObserver(e,function(e,n,r,a,i){var s=e.concat(n).concat(r);t(s,i)}),a=this.itemManager.getItems(e);return a.length>0&&t(a),this.streamRemovers.push(r),function(){r(),Object(_.M)(n.streamRemovers,r)}}},{key:"toggleComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.componentManager.toggleComponent(e));case 2:return t.next=4,b.awrap(this.syncService.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.apiService.setHost(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.apiService.getHost()}},{key:"setCustomHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.setHost(e));case 2:return t.next=4,b.awrap(this.webSocketsService.setWebSocketUrl(void 0));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUser",value:function(){if(!this.launched)throw Error('Attempting to access user before application unlocked');return this.sessionManager.getUser()}},{key:"getUserPasswordCreationDate",value:function(){return this.protocolService.getPasswordCreatedDate()}},{key:"getProtocolEncryptionDisplayName",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getEncryptionDisplayName());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getUserVersion",value:function(){return this.protocolService.getUserVersion()}},{key:"protocolUpgradeAvailable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isEncryptionAvailable",value:function(){return this.hasAccount()||this.hasPasscode()}},{key:"upgradeProtocolVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.credentialService.performProtocolUpgrade());case 2:return(e=t.sent).success?this.hasAccount()?this.alertService.alert(j.N.SuccessAccount):this.alertService.alert(j.N.SuccessPasscodeOnly):e.error&&this.alertService.alert(j.N.Fail),t.abrupt("return",e);case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"noAccount",value:function(){return!this.hasAccount()}},{key:"hasAccount",value:function(){return this.protocolService.hasAccount()}},{key:"hasProtectionSources",value:function(){return this.protectionService.hasProtectionSources()}},{key:"areProtectionsEnabled",value:function(){return this.protectionService.areProtectionsEnabled()}},{key:"getProtectionSessionExpiryDate",value:function(){return this.protectionService.getSessionExpiryDate()}},{key:"clearProtectionSession",value:function(){return this.protectionService.clearSession()}},{key:"authorizeNoteAccess",value:function(e){return this.protectionService.authorizeNoteAccess(e)}},{key:"authorizeAutolockIntervalChange",value:function(){return this.protectionService.authorizeAutolockIntervalChange()}},{key:"authorizeCloudLinkAccess",value:function(){return this.protectionService.authorizeCloudLinkAccess()}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.protectionService.authorizeSearchingProtectedNotesText()}},{key:"importData",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if(t=d.length>1&&void 0!==d[1]&&d[1],!e.version){h.next=11;break}if(n=e.version,this.protocolService.supportedVersions().includes(n)){h.next=6;break}return h.abrupt("return",{error:j.V});case 6:return h.next=8,b.awrap(this.getUserVersion());case 8:if(!(r=h.sent)||1!==Object(Q.b)(n,r)){h.next=11;break}return h.abrupt("return",{error:j.u});case 11:if(!e.auth_params&&!e.keyParams){h.next=20;break}return i=new ye([new ge(te.None,j.F.FileAccountPassword,void 0,!0)],ne.DecryptEncryptedFile,!0),h.next=15,b.awrap(this.challengeService.promptForChallengeResponse(i));case 15:if(s=h.sent,!Object(_.w)(s)){h.next=18;break}return h.abrupt("return");case 18:this.challengeService.completeChallenge(i),a=s.values[0].value;case 20:return h.next=22,b.awrap(this.protectionService.authorizeFileImport());case 22:if(h.sent){h.next=24;break}return h.abrupt("return");case 24:return h.next=26,b.awrap(this.protocolService.payloadsByDecryptingBackupFile(e,a));case 26:return o=h.sent,c=o.filter(function(e){return!e.errorDecrypting&&e.format!==ue.a.EncryptedString}).map(function(e){return e.content_type===F.a.Component&&e.safeContent.active?Object(Ee.b)(e,{content:sa(sa({},e.safeContent),{},{active:!1})}):e}),h.next=30,b.awrap(this.payloadManager.importPayloads(c));case 30:if(u=h.sent,l=this.sync(),!t){h.next=35;break}return h.next=35,b.awrap(l);case 35:return p=this.getAll(u),h.abrupt("return",{affectedItems:p,errorCount:o.length-c.length});case 37:case"end":return h.stop()}},null,this,null,Promise)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=i.length>1&&void 0!==i[1]&&i[1],n=e===Re.b.FileEncrypted,r=e===Re.b.FileDecrypted,a=n&&t||r,s.t0=a,!s.t0){s.next=9;break}return s.next=8,b.awrap(this.protectionService.authorizeBackupCreation(n));case 8:s.t0=!s.sent;case 9:if(!s.t0){s.next=11;break}return s.abrupt("return");case 11:return s.abrupt("return",this.protocolService.createBackupFile(e));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"sync",value:function(e){return this.syncService.sync(e)}},{key:"isOutOfSync",value:function(){return this.syncService.isOutOfSync()}},{key:"resolveOutOfSync",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.storageService.setValue(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){return this.storageService.getValue(e,t)}},{key:"removeValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.storageService.removeValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getPreference",value:function(e,t){return this.preferencesService.getValue(e,t)}},{key:"setPreference",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.preferencesService.setValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"prepareForDeinit",value:function(){var e,t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e=n.length>0&&void 0!==n[0]?n[0]:0,t=Promise.all(this.services.map(function(e){return e.blockDeinit()})),0!==e){r.next=7;break}return r.next=5,b.awrap(t);case 5:r.next=9;break;case 7:return r.next=9,b.awrap(Promise.race([t,Object(_.P)(e)]));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"promptForCustomChallenge",value:function(e){var t;return null===(t=this.challengeService)||void 0===t?void 0:t.promptForChallengeResponse(e)}},{key:"addChallengeObserver",value:function(e,t){return this.challengeService.addChallengeObserver(e,t)}},{key:"submitValuesForChallenge",value:function(e,t){return this.challengeService.submitValuesForChallenge(e,t)}},{key:"cancelChallenge",value:function(e){this.challengeService.cancelChallenge(e)}},{key:"setOnDeinit",value:function(e){this.onDeinit=e}},{key:"deinit",value:function(e){var t;clearInterval(this.autoSyncInterval);for(var n,r=S(this.serviceObservers);!(n=r()).done;){(0,n.value)()}for(var a,i=S(this.managedSubscribers);!(a=i()).done;){(0,a.value)()}for(var s,o=S(this.services);!(s=o()).done;){s.value.deinit()}null===(t=this.onDeinit)||void 0===t||t.call(this,this,e),this.onDeinit=void 0,this.crypto=void 0,this.createdNewDatabase=!1,this.services.length=0,this.serviceObservers.length=0,this.managedSubscribers.length=0,this.streamRemovers.length=0,this.clearServices(),this.dealloced=!0,this.started=!1}},{key:"register",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=!(a.length>3&&void 0!==a[3])||a[3],i.abrupt("return",this.credentialService.register(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return n=s.length>2&&void 0!==s[2]&&s[2],r=s.length>3&&void 0!==s[3]&&s[3],a=!(s.length>4&&void 0!==s[4])||s[4],i=s.length>5&&void 0!==s[5]&&s[5],o.abrupt("return",this.credentialService.signIn(e,t,n,r,a,i));case 5:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeEmail",value:function(e,t,n){var r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:A.g.EmailChange,i.abrupt("return",this.credentialService.changeCredentials({currentPassword:t,newEmail:e,passcode:n,origination:r,validateNewPasswordStrength:!1}));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"changePassword",value:function(e,t,n){var r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=i.length>3&&void 0!==i[3]?i[3]:A.g.PasswordChange,a=!(i.length>4&&void 0!==i[4])||i[4],s.abrupt("return",this.credentialService.changeCredentials({currentPassword:e,newPassword:t,passcode:n,origination:r,validateNewPasswordStrength:a}));case 3:case"end":return s.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e=i.length>0&&void 0!==i[0]&&i[0],t=function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(a.credentialService.signOut());case 2:return e.next=4,b.awrap(a.notifyEvent(At.a.SignedOut));case 4:return e.next=6,b.awrap(a.prepareForDeinit());case 6:a.deinit(C.SignOut);case 7:case"end":return e.stop()}},null,null,null,Promise)},!e){s.next=6;break}return s.next=5,b.awrap(t());case 5:return s.abrupt("return");case 6:if(!((n=this.itemManager.getDirtyItems()).length>0)){s.next=17;break}return r=1===n.length,s.next=11,b.awrap(this.alertService.confirm("There ".concat(r?'is':'are'," ").concat(n.length," ").concat(r?'item':'items'," with unsynced changes. If you sign out, these changes will be lost forever. Are you sure you want to sign out?")));case 11:if(!s.sent){s.next=15;break}return s.next=15,b.awrap(t());case 15:s.next=19;break;case 17:return s.next=19,b.awrap(t());case 19:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleRevokedSession",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.revokingSession){t.next=2;break}return t.abrupt("return");case 2:return this.revokingSession=!0,e=this.alertService,t.next=6,b.awrap(this.signOut(!0));case 6:e.alert(j.R.CurrentSessionRevoked);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.protocolService.validateAccountPassword(e));case 2:return t=r.sent,n=t.valid,r.abrupt("return",n);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isStarted",value:function(){return this.started}},{key:"isLaunched",value:function(){return this.launched}},{key:"hasBiometrics",value:function(){return this.protectionService.hasBiometricsEnabled()}},{key:"enableBiometrics",value:function(){return this.protectionService.enableBiometrics()}},{key:"disableBiometrics",value:function(){return this.protectionService.disableBiometrics()}},{key:"hasPasscode",value:function(){return this.protocolService.hasPasscode()}},{key:"isLocked",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.challengeService.isPasscodeLocked());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"lock",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=500,t.next=3,b.awrap(this.prepareForDeinit(e));case 3:return t.abrupt("return",this.deinit(C.Lock));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"addPasscode",value:function(e){return this.credentialService.addPasscode(e)}},{key:"removePasscode",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.credentialService.removePasscode());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"changePasscode",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:A.g.PasscodeChange,r.abrupt("return",this.credentialService.changePasscode(e,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.storageService.getStorageEncryptionPolicy()}},{key:"setStorageEncryptionPolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setEncryptionPolicy(e));case 2:return t.abrupt("return",this.protocolService.repersistAllItems());case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableEphemeralPersistencePolicy",value:function(){return this.storageService.setPersistencePolicy(Oe.Ephemeral)}},{key:"hasPendingMigrations",value:function(){return this.migrationService.hasPendingMigrations()}},{key:"generateUuid",value:function(){return I.GenerateUuid()}},{key:"presentKeyRecoveryWizard",value:function(){return this.keyRecoveryService.processPersistedUndecryptables()}},{key:"changeDeviceInterface",value:function(e){this.deviceInterface=e;for(var t,n=S(this.services);!(t=n()).done;){var r=t.value;r.deviceInterface&&(r.deviceInterface=e)}}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.settingsService.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=r.length>2&&void 0!==r[2]&&r[2],a.abrupt("return",this.settingsService.updateSetting(e,t,n));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){return this.mfaService.isMfaFeatureAvailable()}},{key:"isMfaActivated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.isMfaActivated());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.generateMfaSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mfaService.getOtpToken(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.mfaService.enableMfa(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protectionService.authorizeMfaDisable());case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",this.mfaService.disableMfa());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"downloadExternalFeature",value:function(e){return this.featuresService.validateAndDownloadExternalFeature(e)}},{key:"getFeature",value:function(e){return this.featuresService.getFeature(e)}},{key:"getFeatureStatus",value:function(e){return this.featuresService.getFeatureStatus(e)}},{key:"getNewSubscriptionToken",value:function(){return this.apiService.getNewSubscriptionToken()}},{key:"setOfflineFeaturesCode",value:function(e){return this.featuresService.setOfflineFeaturesCode(e)}},{key:"hasOfflineRepo",value:function(){return this.featuresService.hasOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.featuresService.deleteOfflineFeatureRepo());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isThirdPartyHostUsed",value:function(){return this.apiService.isThirdPartyHostUsed()}},{key:"constructServices",value:function(){this.createPayloadManager(),this.createItemManager(),this.createStorageManager(),this.createProtocolService();var e={payloadByEncryptingPayload:this.protocolService.payloadByEncryptingPayload.bind(this.protocolService),payloadByDecryptingPayload:this.protocolService.payloadByDecryptingPayload.bind(this.protocolService)};this.storageService.encryptionDelegate=e,this.createChallengeService(),this.createHttpManager(),this.createApiService(),this.createWebSocketsService(),this.createSessionManager(),this.createHistoryManager(),this.createSyncManager(),this.createProtectionService(),this.createCredentialService(),this.createKeyRecoveryService(),this.createSingletonManager(),this.createComponentManager(),this.createActionsManager(),this.createPreferencesService(),this.createSettingsService(),this.createFeaturesService(),this.createMigrationService(),this.createMfaService()}},{key:"clearServices",value:function(){this.migrationService=void 0,this.alertService=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.sessionManager=void 0,this.syncService=void 0,this.challengeService=void 0,this.singletonManager=void 0,this.componentManager=void 0,this.protectionService=void 0,this.actionsManager=void 0,this.historyManager=void 0,this.itemManager=void 0,this.keyRecoveryService=void 0,this.preferencesService=void 0,this.featuresService=void 0,this.credentialService=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.mfaService=void 0,this.services=[]}},{key:"createFeaturesService",value:function(){var e=this;this.featuresService=new dr(this.storageService,this.apiService,this.itemManager,this.componentManager,this.webSocketsService,this.settingsService,this.credentialService,this.syncService,this.alertService,this.sessionManager,this.crypto),this.serviceObservers.push(this.featuresService.addEventObserver(function(t){switch(t){case cr.UserRolesChanged:e.notifyEvent(At.a.UserRolesChanged);break;case cr.FeaturesUpdated:e.notifyEvent(At.a.FeaturesUpdated);break;default:Object(_.f)(t)}})),this.services.push(this.featuresService)}},{key:"createWebSocketsService",value:function(){this.webSocketsService=new lr(this.storageService,this.webSocketUrl),this.services.push(this.webSocketsService)}},{key:"createMigrationService",value:function(){this.migrationService=new En({protocolService:this.protocolService,deviceInterface:this.deviceInterface,storageService:this.storageService,sessionManager:this.sessionManager,challengeService:this.challengeService,itemManager:this.itemManager,singletonManager:this.singletonManager,featuresService:this.featuresService,environment:this.environment,identifier:this.identifier}),this.services.push(this.migrationService)}},{key:"createCredentialService",value:function(){var e=this;this.credentialService=new Qe(this.sessionManager,this.syncService,this.storageService,this.itemManager,this.protocolService,this.alertService,this.challengeService,this.protectionService),this.serviceObservers.push(this.credentialService.addEventObserver(function(t){switch(t){case Ye.SignedInOrRegistered:e.notifyEvent(At.a.SignedIn);break;default:Object(_.f)(t)}})),this.services.push(this.credentialService)}},{key:"createApiService",value:function(){this.apiService=new Yt(this.httpService,this.storageService,this.defaultHost),this.services.push(this.apiService)}},{key:"createItemManager",value:function(){this.itemManager=new _r(this.payloadManager),this.services.push(this.itemManager)}},{key:"createComponentManager",value:function(){var e=this.getClass(an);this.componentManager=new e(this.itemManager,this.syncService,this.alertService,this.environment,this.platform,this.deviceInterface.timeout),this.services.push(this.componentManager)}},{key:"createHttpManager",value:function(){this.httpService=new jt(this.environment,this.appVersion),this.services.push(this.httpService)}},{key:"createPayloadManager",value:function(){this.payloadManager=new sn,this.services.push(this.payloadManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new cn(this.itemManager,this.syncService),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new Ie(this.deviceInterface,this.alertService,this.identifier,this.environment),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(){var e=this;this.protocolService=new Gn(this.itemManager,this.payloadManager,this.deviceInterface,this.storageService,this.identifier,this.crypto),this.protocolService.onKeyStatusChange(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.notifyEvent(At.a.KeyStatusChanged));case 2:case"end":return t.stop()}},null,null,null,Promise)}),this.services.push(this.protocolService)}},{key:"createKeyRecoveryService",value:function(){this.keyRecoveryService=new Mt(this.itemManager,this.payloadManager,this.apiService,this.protocolService,this.challengeService,this.alertService,this.storageService,this.syncService,this.credentialService),this.services.push(this.keyRecoveryService)}},{key:"createSessionManager",value:function(){var e=this;this.sessionManager=new Ge(this.storageService,this.apiService,this.alertService,this.protocolService,this.challengeService,this.webSocketsService),this.serviceObservers.push(this.sessionManager.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=t,n.next=n.t0===ze.Restored?3:n.t0===ze.Revoked?5:8;break;case 3:return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.sync());case 2:e.protocolService.needsNewRootKeyBasedItemsKey()&&e.protocolService.createNewDefaultItemsKey().then(function(){e.sync()});case 3:case"end":return t.stop()}},null,null,null,Promise),n.abrupt("break",9);case 5:return n.next=7,b.awrap(e.handleRevokedSession());case 7:return n.abrupt("break",9);case 8:Object(_.f)(t);case 9:case"end":return n.stop()}},null,null,null,Promise)})),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new ea(this.itemManager,this.sessionManager,this.protocolService,this.storageService,this.payloadManager,this.apiService,this.historyManager,this.deviceInterface.interval);var t=this.syncService.addEventObserver(function(t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(n=Object(At.c)(t))){r.next=9;break}return r.next=4,b.awrap(e.notifyEvent(n));case 4:if(n!==At.a.CompletedFullSync){r.next=9;break}if(e.handledFullSyncStage){r.next=9;break}return e.handledFullSyncStage=!0,r.next=9,b.awrap(e.handleStage(ve.FullSyncCompleted_13));case 9:return r.next=11,b.awrap(e.protocolService.onSyncEvent(t));case 11:case"end":return r.stop()}},null,null,null,Promise)});this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createChallengeService",value:function(){this.challengeService=new na(this.storageService,this.protocolService),this.services.push(this.challengeService)}},{key:"createProtectionService",value:function(){var e=this;this.protectionService=new ir(this.protocolService,this.challengeService,this.storageService,this.itemManager),this.serviceObservers.push(this.protectionService.addEventObserver(function(t){t===Zn.SessionExpiryDateChanged&&e.notifyEvent(At.a.ProtectionSessionExpiryDateChanged)})),this.services.push(this.protectionService)}},{key:"createHistoryManager",value:function(){this.historyManager=new nr(this.itemManager,this.storageService,this.apiService,this.protocolService,this.deviceInterface),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new hn(this.itemManager,this.alertService,this.deviceInterface,this.httpService,this.payloadManager,this.protocolService,this.syncService),this.services.push(this.actionsManager)}},{key:"createPreferencesService",value:function(){var e=this;this.preferencesService=new ra(this.singletonManager,this.itemManager,this.syncService),this.serviceObservers.push(this.preferencesService.addEventObserver(function(){e.notifyEvent(At.a.PreferencesChanged)})),this.services.push(this.preferencesService)}},{key:"createSettingsService",value:function(){this.settingsService=new hr.SNSettingsService(this.sessionManager,this.apiService),this.services.push(this.settingsService)}},{key:"createMfaService",value:function(){this.mfaService=new aa(this.settingsService,this.crypto,this.featuresService),this.services.push(this.mfaService)}},{key:"getClass",value:function(e){var t=this.swapClasses.find(function(t){return t.swap===e});return t?t.with:e}}]),e})(),ua=(function(){function e(t,n){v(this,e),this.timeout=t||setTimeout.bind(Object(_.r)()),this.interval=n||setInterval.bind(Object(_.r)())}return y(e,[{key:"deinit",value:function(){this.timeout=void 0,this.interval=void 0}},{key:"getJsonParsedRawStorageValue",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getRawStorageValue(e));case 2:if(t=n.sent,!Object(_.w)(t)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.prev=5,n.abrupt("return",JSON.parse(t));case 9:return n.prev=9,n.t0=n.catch(5),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,[[5,9]],Promise)}}]),e})(),la=(function(){function e(t,n,r){var a=this;v(this,e),this.item=n.findItem(t),r&&r(this.item),this.removeObserver=n.streamItems(this.item.content_type,function(e){var n;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:(n=e.find(function(e){return e.uuid===t}))&&(a.item=n,r&&r(a.item));case 2:case"end":return i.stop()}},null,null,null,Promise)})}return y(e,[{key:"deinit",value:function(){this.removeObserver?(this.removeObserver(),this.removeObserver=void 0):console.error('A LiveItem is attempting to be deinited more than once.')}}]),e})(),pa=n(95)}])},'object'==typeof i&&'object'==typeof a?a.exports=c():'function'==typeof define&&define.amd?define("SNLibrary",[],c):'object'==typeof i?i.SNLibrary=c():o.SNLibrary=c()},443,[12,35,22,9,11,13,7,8,249,43,279,6]);^~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:449:9037: warning: the variable "Intl" was not declared in function "me 2#"__d(function(e,t,n,r,a,i,s){var o,c,u=t(s[0]),l=t(s[1]),p=t(s[2]),d=t(s[3]),h=t(s[4]),f=t(s[5]),v=t(s[6]),y=t(s[7]),g=t(s[8]),m=t(s[9]),b=t(s[10]),w=t(s[11]);function k(e){var t=x();return function(){var n,r=f(e);if(t){var a=f(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return h(this,n)}}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=P(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o=window,c=function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=246)})([function(e,t,n){"use strict";(function(e){n.d(t,"r",function(){return y}),n.d(t,"n",function(){return g}),n.d(t,"C",function(){return k}),n.d(t,"y",function(){return x}),n.d(t,"q",function(){return P}),n.d(t,"O",function(){return O}),n.d(t,"h",function(){return C}),n.d(t,"x",function(){return D}),n.d(t,"v",function(){return _}),n.d(t,"w",function(){return E}),n.d(t,"t",function(){return R}),n.d(t,"A",function(){return I}),n.d(t,"s",function(){return M}),n.d(t,"U",function(){return A}),n.d(t,"V",function(){return j}),n.d(t,"W",function(){return T}),n.d(t,"F",function(){return K}),n.d(t,"o",function(){return F}),n.d(t,"R",function(){return L}),n.d(t,"M",function(){return U}),n.d(t,"b",function(){return N}),n.d(t,"p",function(){return V}),n.d(t,"c",function(){return B}),n.d(t,"g",function(){return W}),n.d(t,"N",function(){return H}),n.d(t,"d",function(){return z}),n.d(t,"H",function(){return q}),n.d(t,"Q",function(){return Y}),n.d(t,"K",function(){return G}),n.d(t,"j",function(){return Q}),n.d(t,"S",function(){return J}),n.d(t,"E",function(){return $}),n.d(t,"J",function(){return X}),n.d(t,"I",function(){return Z}),n.d(t,"D",function(){return ee}),n.d(t,"a",function(){return te}),n.d(t,"m",function(){return ne}),n.d(t,"L",function(){return re}),n.d(t,"l",function(){return ae}),n.d(t,"B",function(){return ie}),n.d(t,"T",function(){return se}),n.d(t,"P",function(){return oe}),n.d(t,"f",function(){return ce}),n.d(t,"z",function(){return ue}),n.d(t,"G",function(){return le}),n.d(t,"e",function(){return pe}),n.d(t,"i",function(){return ye}),n.d(t,"u",function(){return ge}),n.d(t,"k",function(){return me});var r=n(27),a=n.n(r),i=n(25),s=n.n(i),o=n(23),c=n.n(o),u=n(97),l=n.n(u),p=n(66),d=n.n(p),h=n(28),f=n.n(h),v='undefined'!=typeof Intl?new Intl.Collator('en',{numeric:!0}):void 0;function y(){return'undefined'!=typeof window?window:void 0!==e?e:null}function g(e){return Object.keys(e).map(function(t){return e[t]})}function k(){return null!==y()&&!x()&&!(document&&document.documentMode)||/Edge/.test(navigator.userAgent)&&window.crypto&&!!window.crypto.subtle}function x(){return'undefined'!=typeof navigator&&'ReactNative'===navigator.product}function P(e,t,n){return e.find(function(e){return e[t]===n})}function O(e,t){return s()(e,t)}function C(){for(var e=[],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var a=0,i=n;a<i.length;a++){var s=i[a];e=e.concat(s)}return e}function D(e){return null!==e&&('function'==typeof e||'object'==typeof e)}function _(e){return null!==e&&'function'==typeof e}function E(e){return null===e||void 0===e}function R(e){return!e||0===e.length}function I(e){return'string'==typeof e||e instanceof String}function M(e,t){return e>t?e:t}function A(e,t,n){return d()(e.concat(t),function(e,t){for(var r,a=S(n);!(r=a()).done;){var i=r.value;if(e[i]!==t[i])return!1}return!0})}function j(e){return f()(e)}function T(e,t){return d()(e,function(e,n){return e[t]===n[t]})}function K(e){return e[e.length-1]}function F(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;e.push(a)}}function L(e,t){for(var n,r=S(t);!(n=r()).done;){U(e,n.value)}}function U(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}function N(e,t){return!e.includes(t)&&(e.push(t),!0)}function V(e,t){a()(e,t)}function B(e,t){return e.filter(function(e){return!t.includes(e)}).concat(t.filter(function(t){return!e.includes(t)}))}function W(e,t){return!(e&&!t||!e&&t)&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof String&&t instanceof String?e===t:J(e,t))}function H(e,t){e.splice(t,1)}function z(e,t){var n=e.slice();return H(n,t),n}function q(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];t.push(e[a])}return t}function Y(e){for(var t,n={},r=S(Object.keys(e).sort());!(t=r()).done;){var a=t.value;n[a]=e[a]}return te(n)}function G(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];E(e[a])||(t[a]=e[a])}return t}function Q(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort(function(e,r){var a=e[t].getTime(),i=r[t].getTime(),s=n?1:-1;return a<i?-1*s:a>i?1*s:0})}function J(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var a=0,i=n;a<i.length;a++){var s=i[a];if(e[s]!==t[s])return!1}return!0}function $(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=void 0;try{i=JSON.parse(e[a])}catch(t){i=e[a]}t[a]=i}return t}function X(e,t){if(e)for(var n,r=S(t);!(n=r()).done;){delete e[n.value]}}function Z(e,t){if(!E(e)){for(var n,r=w({},e),a=S(t);!(n=a()).done;){delete r[n.value]}return r}}function ee(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(function(e,t){return 0===t?e.trim().replace(/[/]*$/g,''):e.trim().replace(/(^[/]*|[/]*$)/g,'')}).filter(function(e){return e.length}).join('/')}function te(e){return e instanceof Date?new Date(e):D(e)?JSON.parse(JSON.stringify(e)):e}function ne(e,t){if(!e||!t)throw'Attempting to deepMerge with null values';return l()(e,t,function(e,t){if(c()(e))return t}),e}function re(e,t){for(var n,r={},a=S(t);!(n=a()).done;){var i=n.value;r[i]=e[i]}return te(r)}function ae(e){for(var t,n=S(Object.getOwnPropertyNames(e));!(t=n()).done;){var r=t.value,a=e[r];a&&'object'==typeof a&&!Object.isFrozen(a)?e[r]=ae(a):e[r]=a}return Object.freeze(e)}function ie(e){try{return new URL(e),!0}catch(e){return!1}}function se(e,t){var n=t/4;return e.substring(0,n)}function oe(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Sleeping for ".concat(e,"ms")),t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},e)}));case 2:case"end":return t.stop()}},null,null,null,Promise)}function ce(e){throw Error('Unchecked case '+e)}function ue(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function le(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc'){case'asc':return m(e).sort(v?function(e,n){return v.compare(e[t],n[t])}:function(e,n){return e[t].localeCompare(n[t],'en',{numeric:!0})});case'desc':return m(e).sort(v?function(e,n){return v.compare(n[t],e[t])}:function(e,n){return n[t].localeCompare(e[t],'en',{numeric:!0})})}}function pe(e,t){return e.length===t.length&&(e.every(function(e){return t.includes(e)})&&t.every(function(t){return e.includes(t)}))}var de,he,fe=1e3,ve=1e3;function ye(e){switch(String(e).length){case de.Seconds:return e*ve;case de.Milliseconds:return e;case de.Microseconds:return Math.floor(e/fe);default:throw"Unhandled timestamp precision: ".concat(e)}}function ge(e){return void 0!==e.error}function me(e){if('undefined'!=typeof Intl&&Intl.DateTimeFormat&&'undefined'!=typeof navigator){if(!he){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;he=new Intl.DateTimeFormat(t,{year:'numeric',month:'short',day:'2-digit',weekday:'long',hour:'2-digit',minute:'2-digit'})}return he.format(e)}return e.toDateString()+' '+e.toLocaleTimeString()}!(function(e){e[e.Seconds=10]="Seconds",e[e.Milliseconds=13]="Milliseconds",e[e.Microseconds=16]="Microseconds"})(de||(de={}))}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"e",function(){return m}),n.d(t,"g",function(){return b}),n.d(t,"d",function(){return w}),n.d(t,"f",function(){return k}),n.d(t,"b",function(){return x}),n.d(t,"c",function(){return O}),n.d(t,"a",function(){return C});var r=n(32),a=n(4),i=n(8),s=n(0),o=n(5),c=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey,o.a.LastSyncBegan,o.a.LastSyncEnd,o.a.DuplicateOf]),u=Object.freeze([o.a.Uuid,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.Legacy003AuthHash,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey]),l=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Legacy003AuthHash,o.a.DuplicateOf]),p=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.WaitingForKey,o.a.DuplicateOf]),d=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.DuplicateOf]),h=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.Content,o.a.ServerUpdatedAt]),f=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),v=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),y=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ServerUpdatedAt,o.a.ServerUpdatedAtTimestamp,o.a.CreatedAtTimestamp,o.a.Deleted,o.a.Dirty,o.a.LastSyncEnd]),g=Object.freeze(d.slice());function m(e,t,n){return P(e,c.slice(),n,t)}function b(e,t,n,r){for(var a,i={},s=S(n||t.fields);!(a=s()).done;){var o=a.value;i[o]=t[o]}if(r)for(var c=0,u=Object.keys(r);c<u.length;c++){var l=u[c];i[l]=r[l]}return x(e,i)}function w(e,t,n){return P(e,D(t),a.a.Constructor,n)}function k(e,t,n){return P(e,_(t),t,n)}function x(e,t){return P(e,e.fields,e.source,t)}function P(e,t,n,i){for(var o,c=Object(s.L)(e,t),u=i instanceof r.a?i.fields.slice():Object.keys(i||[]),l=S(u);!(o=l()).done;){var p=o.value,d=i[p];c[p]=d?Object(s.a)(d):d}var h=Object(s.V)(t.concat(u));return new r.a(c,h,n||a.a.Constructor)}function O(e,t){return P(e,Object.keys(e),t)}function C(e,t){return P(e,u.slice(),void 0,t)}function D(e){if(e===i.b.FileEncrypted||e===i.b.FileDecrypted||e===i.b.FilePreferEncrypted)return l.slice();if(e===i.b.LocalStoragePreferEncrypted||e===i.b.LocalStorageDecrypted||e===i.b.LocalStorageEncrypted)return p.slice();if(e===i.b.Sync||e===i.b.SyncDecrypted)return d.slice();throw"No payload fields found for intent ".concat(e)}function _(e){if(e===a.a.FileImport)return l.slice();if(e===a.a.SessionHistory)return h.slice();if(e===a.a.RemoteHistory)return g.slice();if(e===a.a.ComponentRetrieved)return f.slice();if(e===a.a.ComponentCreated)return v.slice();if(e===a.a.LocalRetrieved||e===a.a.LocalChanged)return p.slice();if(e===a.a.RemoteRetrieved||e===a.a.ConflictData||e===a.a.ConflictUuid||e===a.a.RemoteRejected)return d.slice();if(e===a.a.LocalSaved||e===a.a.RemoteSaved)return y.slice();throw"No payload fields found for source ".concat(e)}},function(e,t,n){"use strict";n.d(t,"k",function(){return a}),n.d(t,"l",function(){return i}),n.d(t,"j",function(){return s}),n.d(t,"m",function(){return o}),n.d(t,"r",function(){return c}),n.d(t,"p",function(){return u}),n.d(t,"a",function(){return l}),n.d(t,"i",function(){return p}),n.d(t,"n",function(){return d}),n.d(t,"s",function(){return h}),n.d(t,"q",function(){return f}),n.d(t,"o",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"h",function(){return g}),n.d(t,"g",function(){return m}),n.d(t,"b",function(){return b}),n.d(t,"f",function(){return w}),n.d(t,"t",function(){return k}),n.d(t,"c",function(){return x}),n.d(t,"e",function(){return S}),n.d(t,"C",function(){return P}),n.d(t,"X",function(){return O}),n.d(t,"A",function(){return C}),n.d(t,"L",function(){return D}),n.d(t,"W",function(){return _}),n.d(t,"E",function(){return E}),n.d(t,"D",function(){return R}),n.d(t,"K",function(){return I}),n.d(t,"J",function(){return M}),n.d(t,"Y",function(){return A}),n.d(t,"Q",function(){return j}),n.d(t,"v",function(){return T}),n.d(t,"O",function(){return K}),n.d(t,"z",function(){return F}),n.d(t,"U",function(){return L}),n.d(t,"G",function(){return U}),n.d(t,"T",function(){return N}),n.d(t,"V",function(){return V}),n.d(t,"u",function(){return B}),n.d(t,"F",function(){return W}),n.d(t,"y",function(){return H}),n.d(t,"P",function(){return z}),n.d(t,"S",function(){return q}),n.d(t,"N",function(){return Y}),n.d(t,"H",function(){return G}),n.d(t,"w",function(){return Q}),n.d(t,"R",function(){return J}),n.d(t,"x",function(){return $}),n.d(t,"M",function(){return X}),n.d(t,"B",function(){return Z}),n.d(t,"I",function(){return ee});var r=n(13),a='A server error occurred while trying to sign in. Please try again.',i='A server error occurred while trying to register. Please try again.',s='Something went wrong while changing your credentials. Your credentials were not changed. Please try again.',o='Could not connect to server.',c='An existing registration request is already in progress.',u='An existing sign in request is already in progress.',l='An existing change credentials request is already in progress.',p='Invalid email or password.',d='A server error occurred while trying to refresh your session. Please try again.',h='Your account session is being renewed with the server. Please try your request again.',f='Too many successive server requests. Please wait a few minutes and try again.',v='Please sign in to an account in order to continue with your request.',y='Failed to get settings.',g='Failed to update settings.',m="Failed to get subscription's information.",b='Failed to access purchase flow.',w='Failed to get offline features.',k="The extension you are attempting to install comes from an \n  untrusted source. Untrusted extensions may lower the security of your data. Do you want to continue?",x="Error downloading package details. Please check the \n  extension link and try again.",S='An unknown issue occurred during offline activation. Please try again.',P='Invalid extension URL.',O='This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.',C='The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.',D='The encryption version for your account is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.com/help/security for more information.',_='Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.',E='Unable to sign in due to insecure password parameters. Please visit standardnotes.com/help/security for more information.',R='Invalid password.',I='Update Recommended',M='Sign In',A="Upgrading your account's encryption version\u2026",j='Setting passcode\u2026',T='Changing passcode\u2026',K='Removing passcode\u2026',F='Do not close the application until this process completes.',L='Unknown error.';function U(e){return"Your password must be at least ".concat(e," characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.")}function N(e,t){return"Strict Sign In has refused the server's sign-in parameters. The latest account version is ".concat(t,", but the server is reporting a version of ").concat(e," for your account. If you'd like to proceed with sign in anyway, please disable Strict Sign In and try again.")}var V='This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.',B="This backup file was created using a newer encryption version than your account's. Please run the available encryption upgrade and try again.",W={FileAccountPassword:'File account password'},H={PasscodeRequired:'Your passcode is required to process your credentials change.',Failed:'Unable to change your credentials due to a sync error. Please try again.'},z={PasscodeRequired:'Your passcode is required in order to register for an account.'},q={PasscodeRequired:'Your passcode is required in order to sign in to your account.',IncorrectMfa:'Incorrect two-factor authentication code. Please try again.',SignInCanceledMissingMfa:'Your sign in request has been canceled.'},Y={SuccessAccount:"Your encryption version has been successfully upgraded. You may be asked to enter your credentials again on other devices you're signed into.",SuccessPasscodeOnly:'Your encryption version has been successfully upgraded.',Fail:'Unable to upgrade encryption version. Please try again.',UpgradingPasscode:'Upgrading local encryption...'},G={KeyRecoveryLoginFlowPrompt:function(e){var t,n=null===(t=e.createdDate)||void 0===t?void 0:t.toLocaleString();switch(e.origination){case r.g.EmailChange:return"Enter your account password as it was when you changed your email on ".concat(n,".");case r.g.PasswordChange:return"Enter your account password after it was changed on ".concat(n,".");case r.g.Registration:return"Enter your account password as it was when you registered ".concat(n,".");case r.g.ProtocolUpgrade:return"Enter your account password as it was when you upgraded your encryption version on ".concat(n,".");case r.g.PasscodeChange:return"Enter your application passcode after it was changed on ".concat(n,".");case r.g.PasscodeCreate:return"Enter your application passcode as it was when you created it on ".concat(n,".");default:throw Error('Unhandled KeyParamsOrigination case for KeyRecoveryLoginFlowPrompt')}},KeyRecoveryLoginFlowReason:'Your account password is required to revalidate your session.',KeyRecoveryLoginFlowInvalidPassword:'Incorrect credentials entered. Please try again.',KeyRecoveryRootKeyReplaced:'Your credentials have successfully been updated.',KeyRecoveryPasscodeRequiredTitle:'Passcode Required',KeyRecoveryPasscodeRequiredText:'You must enter your passcode in order to save your new credentials.',KeyRecoveryPasswordRequired:'Your account password is required to recover an encryption key.',KeyRecoveryKeyRecovered:'Your key has successfully been recovered.',KeyRecoveryUnableToRecover:'Unable to recover your key with the attempted password. Please try again.'},Q={Generic:'Authentication Required',Migration:'Storage Update'},J={EnterEmailAndPassword:'Please enter your account email and password.',RecoverSession:function(e){return e?"Your credentials are needed for ".concat(e," to refresh your session with the server."):'Your credentials are needed to refresh your session with the server.'},SessionRestored:'Your session has been successfully restored.',EnterMfa:'Please enter your two-factor authentication code.',MfaInputPlaceholder:'Two-factor authentication code',EmailInputPlaceholder:'Email',PasswordInputPlaceholder:'Password',KeychainRecoveryErrorTitle:'Invalid Credentials',KeychainRecoveryError:'The email or password you entered is incorrect.\n\nPlease note that this sign-in request is made against the default server. If you are using a custom server, you must uninstall the app then reinstall, and sign back into your account.',RevokeTitle:'Revoke this session?',RevokeConfirmButton:'Revoke',RevokeCancelButton:'Cancel',RevokeText:"The associated app will be signed out and all data removed from the device when it is next launched. You can sign back in on that device at any time.",CurrentSessionRevoked:"Your session has been revoked and all local data has been removed from this device."},$={UnlockApplication:'Authentication is required to unlock the application',NoteAccess:'Authentication is required to view this note',ImportFile:'Authentication is required to import a backup file',AddPasscode:'Authentication is required to add a passcode',RemovePasscode:'Authentication is required to remove your passcode',ChangePasscode:'Authentication is required to change your passcode',ChangeAutolockInterval:'Authentication is required to change autolock timer duration',RevokeSession:'Authentication is required to revoke a session',AccessCloudLink:'Authentication is required to access CloudLink',EnterAccountPassword:'Enter your account password',EnterLocalPasscode:'Enter your application passcode',EnterPasscodeForMigration:'Your application passcode is required to perform an upgrade of your local data storage structure.',EnterPasscodeForRootResave:'Enter your application passcode to continue',EnterCredentialsForProtocolUpgrade:'Enter your credentials to perform encryption upgrade',EnterCredentialsForDecryptedBackupDownload:'Enter your credentials to download a decrypted backup',AccountPasswordPlaceholder:'Account Password',LocalPasscodePlaceholder:'Application Passcode',DecryptEncryptedFile:'Enter the account password associated with the import file',ExportBackup:'Authentication is required to export a backup',DisableBiometrics:'Authentication is required to disable biometrics',UnprotectNote:'Authentication is required to unprotect a note',SearchProtectedNotesText:'Authentication is required to search protected contents',SelectProtectedNote:'Authentication is required to select a protected note',DisableMfa:'Authentication is required to disable two-factor authentication'},X={AccountPassword:'Account Password',LocalPasscode:'Application Passcode',Biometrics:'Biometrics',RememberFor:'Remember For',Mfa:'Two-factor Authentication Code'},Z={MissingSessionTitle:'Missing Session',MissingSessionBody:'We were unable to load your server session. This represents an inconsistency with your application state. Please take an opportunity to backup your data, then sign out and sign back in to resolve this issue.',StorageDecryptErrorTitle:'Storage Error',StorageDecryptErrorBody:"We were unable to decrypt your local storage. Please restart the app and try again. If you're unable to resolve this issue, and you have an account, you may try uninstalling the app then reinstalling, then signing back into your account. Otherwise, please contact help@standardnotes.org for support."},ee={Title:'Restore Keychain',Text:"We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys."}},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i});var r=n(19);n.n(r);n.d(t,"a",function(){return r.ContentType});var a='org.standardnotes.sn';function i(e){var t;return(g(t={},r.ContentType.Note,'note'),g(t,r.ContentType.Tag,'tag'),g(t,r.ContentType.SmartTag,'smart tag'),g(t,r.ContentType.ActionsExtension,'action-based extension'),g(t,r.ContentType.Component,'component'),g(t,r.ContentType.Editor,'editor'),g(t,r.ContentType.Theme,'theme'),g(t,r.ContentType.ServerExtension,'server extension'),g(t,r.ContentType.FilesafeCredentials,'FileSafe credential'),g(t,r.ContentType.FilesafeFileMetadata,'FileSafe file'),g(t,r.ContentType.FilesafeIntegration,'FileSafe integration'),t)[e]}},function(e,t,n){"use strict";var r;function a(e){return[r.RemoteSaved,r.PreSyncSave].includes(e)}function i(e){return[r.RemoteRetrieved,r.ComponentRetrieved,r.RemoteActionRetrieved].includes(e)}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i}),(function(e){e[e.RemoteRetrieved=1]="RemoteRetrieved",e[e.RemoteSaved=2]="RemoteSaved",e[e.LocalSaved=3]="LocalSaved",e[e.LocalRetrieved=4]="LocalRetrieved",e[e.LocalChanged=5]="LocalChanged",e[e.ComponentRetrieved=6]="ComponentRetrieved",e[e.DesktopInstalled=7]="DesktopInstalled",e[e.RemoteActionRetrieved=8]="RemoteActionRetrieved",e[e.FileImport=9]="FileImport",e[e.RemoteConflict=10]="RemoteConflict",e[e.ImportConflict=11]="ImportConflict",e[e.SavedOrSaving=12]="SavedOrSaving",e[e.DecryptedTransient=13]="DecryptedTransient",e[e.ConflictUuid=14]="ConflictUuid",e[e.ConflictData=15]="ConflictData",e[e.SessionHistory=16]="SessionHistory",e[e.Constructor=17]="Constructor",e[e.ComponentCreated=18]="ComponentCreated",e[e.PreSyncSave=19]="PreSyncSave",e[e.RemoteHistory=20]="RemoteHistory",e[e.RemoteRejected=21]="RemoteRejected"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.Uuid="uuid",e.ContentType="content_type",e.ItemsKeyId="items_key_id",e.EncItemKey="enc_item_key",e.Content="content",e.CreatedAt="created_at",e.ServerUpdatedAt="updated_at",e.CreatedAtTimestamp="created_at_timestamp",e.ServerUpdatedAtTimestamp="updated_at_timestamp",e.Deleted="deleted",e.Legacy003AuthHash="auth_hash",e.Legacy003AuthParams="auth_params",e.Dirty="dirty",e.DirtiedDate="dirtiedDate",e.WaitingForKey="waitingForKey",e.ErrorDecrypting="errorDecrypting",e.ErrorDecryptingChanged="errorDecryptingValueChanged",e.LastSyncBegan="lastSyncBegan",e.LastSyncEnd="lastSyncEnd",e.DuplicateOf="duplicate_of"})(r||(r={}))},function(e,t,n){"use strict";var r;function a(e,t){return Number(e)-Number(t)}function i(e,t){return a(e,t)>=0}function s(e,t){return a(e,t)<=0}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"d",function(){return i}),n.d(t,"c",function(){return s}),(function(e){e.V000Base64Decrypted="000",e.V001="001",e.V002="002",e.V003="003",e.V004="004",e[e.VersionLength=3]="VersionLength"})(r||(r={}))},function(e,t,n){"use strict";(function(e){n.d(t,"c",function(){return r}),n.d(t,"a",function(){return a}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return f}),n.d(t,"b",function(){return g});var r,a,i,s=n(16),o=n(12),c=n(18),u=n(1),l=n(0),p=n(21),d=n(3),h=n(4);!(function(e){e[e.UserInteraction=1]="UserInteraction",e[e.Internal=2]="Internal",e[e.NonDirtying=3]="NonDirtying"})(r||(r={})),(function(e){e.Pinned="pinned",e.Archived="archived",e.Locked="locked",e.UserModifiedDate="client_updated_at",e.DefaultEditor="defaultEditor",e.MobileRules="mobileRules",e.NotAvailableOnMobile="notAvailableOnMobile",e.MobileActive="mobileActive",e.LastSize="lastSize",e.PrefersPlainEditor="prefersPlainEditor",e.ComponentInstallError="installError"})(a||(a={})),(function(e){e[e.KeepEarliest=1]="KeepEarliest"})(i||(i={}));var f=(function(){function t(n){var r=this;if(v(this,t),this.protected=!1,this.trashed=!1,this.pinned=!1,this.archived=!1,this.locked=!1,!n.uuid||!n.content_type)throw Error('Cannot create item without both uuid and content_type');n.format===o.a.DecryptedBareObject&&(n.enc_item_key||n.items_key_id||n.auth_hash)&&s.a.error(Error('Creating an item from a decrypted payload should not contain enc params')),this.payload=n,this.conflictOf=n.safeContent.conflict_of,this.duplicateOf=n.duplicate_of,this.createdAtString=this.created_at&&Object(l.k)(this.created_at),n.format===o.a.DecryptedBareObject?(this.userModifiedDate=new Date(this.getAppDomainValue(a.UserModifiedDate)||this.serverUpdatedAt),this.updatedAtString=Object(l.k)(this.userModifiedDate),this.protected=this.payload.safeContent.protected,this.trashed=this.payload.safeContent.trashed,this.pinned=this.getAppDomainValue(a.Pinned),this.archived=this.getAppDomainValue(a.Archived),this.locked=this.getAppDomainValue(a.Locked)):this.userModifiedDate=this.serverUpdatedAt||new Date,e(function(){Object(l.l)(r)})}return y(t,[{key:"payloadRepresentation",value:function(e){return Object(u.b)(this.payload,e)}},{key:"hasRelationshipWithItem",value:function(e){var t;return!!(null===(t=this.payload.safeContent.references)||void 0===t?void 0:t.find(function(t){return t.uuid===e.uuid}))}},{key:"getDomainData",value:function(e){var t=this.payload.safeContent.appData;if(t)return t[e]}},{key:"getAppDomainValue",value:function(e){return this.getDomainData(t.DefaultAppDomain())[e]}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['conflict_of']}},{key:"appDataContentKeysToIgnoreWhenCheckingEquality",value:function(){return[a.UserModifiedDate]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"strategyWhenConflictingWithItem",value:function(e,t){if(this.errorDecrypting)return c.a.KeepLeftDuplicateRight;if(this.isSingleton)return c.a.KeepLeft;if(this.deleted)return c.a.KeepRight;if(e.deleted)return this.payload.source===h.a.FileImport?c.a.KeepLeft:c.a.KeepRight;if(!m(this,e))return c.a.KeepRight;if(m(this,e,['references'])){if(t&&!m(t.itemFromPayload(),e))return c.a.KeepLeft;return e.payload.source===h.a.FileImport||Date.now()-this.userModifiedDate.getTime()<2e4?c.a.KeepLeftDuplicateRight:c.a.DuplicateLeftKeepRight}return c.a.KeepLeftMergeRefs}},{key:"isItemContentEqualWith",value:function(e){return b(this.payload.contentObject,e.payload.contentObject,this.contentKeysToIgnoreWhenCheckingEquality(),this.appDataContentKeysToIgnoreWhenCheckingEquality())}},{key:"satisfiesPredicate",value:function(e){return p.a.ItemSatisfiesPredicate(this,e)}},{key:"uuid",get:function(){return this.payload.uuid}},{key:"content",get:function(){return this.payload.content}},{key:"version",get:function(){if(this.payload.format===o.a.DecryptedBareObject)throw Error('Attempting to access version of decrypted payload');return this.payload.version}},{key:"safeContent",get:function(){return this.payload.safeContent}},{key:"references",get:function(){return this.payload.safeContent.references||[]}},{key:"deleted",get:function(){return this.payload.deleted}},{key:"content_type",get:function(){return this.payload.content_type}},{key:"created_at",get:function(){return this.payload.created_at}},{key:"serverUpdatedAt",get:function(){return this.payload.serverUpdatedAt}},{key:"serverUpdatedAtTimestamp",get:function(){return this.payload.updated_at_timestamp}},{key:"updated_at",get:function(){return this.serverUpdatedAt}},{key:"dirtiedDate",get:function(){return this.payload.dirtiedDate}},{key:"dirty",get:function(){return this.payload.dirty}},{key:"errorDecrypting",get:function(){return this.payload.errorDecrypting}},{key:"waitingForKey",get:function(){return this.payload.waitingForKey}},{key:"errorDecryptingValueChanged",get:function(){return this.payload.errorDecryptingValueChanged}},{key:"lastSyncBegan",get:function(){return this.payload.lastSyncBegan}},{key:"lastSyncEnd",get:function(){return this.payload.lastSyncEnd}},{key:"auth_hash",get:function(){return this.payload.auth_hash}},{key:"auth_params",get:function(){return this.payload.auth_params}},{key:"duplicate_of",get:function(){return this.payload.duplicate_of}},{key:"neverSynced",get:function(){return!this.serverUpdatedAt||0===this.serverUpdatedAt.getTime()}},{key:"isSingleton",get:function(){return!1}},{key:"singletonPredicate",get:function(){throw'Must override SNItem.singletonPredicate'}},{key:"singletonStrategy",get:function(){return i.KeepEarliest}},{key:"isSyncable",get:function(){return!this.errorDecrypting||!0===this.deleted}}],[{key:"DefaultAppDomain",value:function(){return d.b}}]),t})(),g=(function(){function e(t,n){v(this,e),this.item=t,this.type=n,this.payload=t.payload,this.payload.content&&(this.content=Object(l.a)(this.payload.content))}return y(e,[{key:"getUuid",value:function(){return this.payload.uuid}},{key:"getItem",value:function(){return this.item}},{key:"getResult",value:function(){if(this.type===r.NonDirtying)return Object(u.b)(this.payload,{content:this.content});this.payload.deleted||(this.type===r.UserInteraction?this.userModifiedDate=new Date:this.item.userModifiedDate||(this.userModifiedDate=new Date(this.item.serverUpdatedAt)));return Object(u.b)(this.payload,{content:this.content,dirty:!0,dirtiedDate:new Date})}},{key:"mergePayload",value:function(e){this.payload=Object(u.g)(this.payload,e),this.payload.content?this.content=Object(l.a)(this.payload.safeContent):this.content=void 0}},{key:"unsafe_setCustomContent",value:function(e){this.content=Object(l.a)(e)}},{key:"setDeleted",value:function(){this.content=void 0,this.payload=Object(u.b)(this.payload,{content:this.content,deleted:!0})}},{key:"setDomainData",value:function(e,t){this.payload.errorDecrypting||(this.content.appData||(this.content.appData={}),this.content.appData[t]=e)}},{key:"setDomainDataKey",value:function(e,t,n){if(!this.payload.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData;r[n]||(r[n]={}),r[n][e]=t}}},{key:"setAppDataItem",value:function(e,t){this.setDomainDataKey(e,t,f.DefaultAppDomain())}},{key:"addItemAsRelationship",value:function(e){var t=this.content.references||[];t.find(function(t){return t.uuid===e.uuid})||t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}},{key:"removeItemAsRelationship",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!==e.uuid}),this.content.references=t}},{key:"lastSyncBegan",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,lastSyncBegan:e})}},{key:"errorDecrypting",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,errorDecrypting:e})}},{key:"updated_at",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at:e})}},{key:"updated_at_timestamp",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at_timestamp:e})}},{key:"userModifiedDate",set:function(e){this.setAppDataItem(a.UserModifiedDate,e)}},{key:"conflictOf",set:function(e){this.content.conflict_of=e}},{key:"protected",set:function(e){this.content.protected=e}},{key:"trashed",set:function(e){this.content.trashed=e}},{key:"pinned",set:function(e){this.setAppDataItem(a.Pinned,e)}},{key:"archived",set:function(e){this.setAppDataItem(a.Archived,e)}},{key:"locked",set:function(e){this.setAppDataItem(a.Locked,e)}}]),e})();function m(e,t,n){return n||(n=[]),!b(e.content,t.content,e.contentKeysToIgnoreWhenCheckingEquality().concat(n),e.appDataContentKeysToIgnoreWhenCheckingEquality())}function b(e,t,n,r){if((e=Object(l.Q)(e)).appData){var a=e.appData[d.b];Object(l.J)(a,r),a?0===Object.keys(a).length&&delete e.appData:delete e.appData}if(Object(l.J)(e,n),(t=Object(l.Q)(t)).appData){var i=t.appData[d.b];Object(l.J)(i,r),i?0===Object.keys(i).length&&delete t.appData:delete t.appData}return Object(l.J)(t,n),JSON.stringify(e)===JSON.stringify(t)}}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"f",function(){return s}),n.d(t,"e",function(){return o}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return u});var r,a=n(3);function i(e){return e===a.a.RootKey||e===a.a.ItemsKey||e===a.a.EncryptedStorage}function s(e){return e===r.LocalStorageEncrypted||e===r.LocalStorageDecrypted||e===r.LocalStoragePreferEncrypted}function o(e){return e===r.FileEncrypted||e===r.FileDecrypted||e===r.FilePreferEncrypted}function c(e){return e===r.SyncDecrypted||e===r.LocalStorageDecrypted||e===r.FileDecrypted}function u(e){return e===r.Sync||e===r.LocalStorageEncrypted||e===r.FileEncrypted}!(function(e){e[e.Sync=0]="Sync",e[e.SyncDecrypted=1]="SyncDecrypted",e[e.LocalStorageEncrypted=2]="LocalStorageEncrypted",e[e.LocalStorageDecrypted=3]="LocalStorageDecrypted",e[e.LocalStoragePreferEncrypted=4]="LocalStoragePreferEncrypted",e[e.FileEncrypted=5]="FileEncrypted",e[e.FileDecrypted=6]="FileDecrypted",e[e.FilePreferEncrypted=7]="FilePreferEncrypted"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.FullSyncCompleted="sync:full-completed",e.SingleSyncCompleted="sync:single-completed",e.SyncWillBegin="sync:will-begin",e.DownloadFirstSyncCompleted="sync:download-first-completed",e.SyncTakingTooLong="sync:taking-too-long",e.SyncError="sync:error",e.InvalidSession="sync:invalid-session",e.MajorDataChange="major-data-change",e.LocalDataIncrementalLoad="local-data-incremental-load",e.LocalDataLoaded="local-data-loaded",e.EnterOutOfSync="enter-out-of-sync",e.ExitOutOfSync="exit-out-of-sync",e.StatusChanged="status-changed",e.DatabaseWriteError="database-write-error",e.DatabaseReadError="database-read-error"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var r=n(0),a=(function(){function e(){v(this,e),this.eventObservers=[],this.loggingEnabled=!1,this.criticalPromises=[]}return y(e,[{key:"addEventObserver",value:function(e){var t=this;return this.eventObservers.push(e),function(){Object(r.M)(t.eventObservers,e)}}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:n=S(this.eventObservers);case 1:if((r=n()).done){i.next=7;break}return a=r.value,i.next=5,b.awrap(a(e,t));case 5:i.next=1;break;case 7:case"end":return i.stop()}},null,this,null,Promise)}},{key:"blockDeinit",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(Promise.all(this.criticalPromises));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.eventObservers.length=0,this.deviceInterface=void 0}},{key:"executeCriticalFunction",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e(),this.criticalPromises.push(t),n.abrupt("return",t);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"log",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.loggingEnabled){var a,i=new Date,s=i.toLocaleTimeString().replace(' PM','').replace(' AM',''),o="".concat(s,".").concat(i.getMilliseconds());if(n)n=n.map(function(e){return Array.isArray(e)?e.slice():e}),(a=console).log.apply(a,[o,e].concat(m(n)));else console.log(o,e)}}}]),e})()},function(e,t,n){"use strict";n.d(t,"b",function(){return i}),n.d(t,"a",function(){return s});var r=n(7),a=n(3);function i(e){return e.map(function(e){return e.uuid})}function s(e){return e.references||(e.references=[]),e.appData||(e.appData={}),e.appData[a.b]||(e.appData[a.b]={}),e.appData[a.b][r.a.UserModifiedDate]||(e.appData[a.b][r.a.UserModifiedDate]="".concat(new Date)),e}},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.EncryptedString=0]="EncryptedString",e[e.DecryptedBareObject=1]="DecryptedBareObject",e[e.DecryptedBase64String=2]="DecryptedBase64String",e[e.Deleted=3]="Deleted"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"g",function(){return r}),n.d(t,"a",function(){return p}),n.d(t,"b",function(){return d}),n.d(t,"c",function(){return h}),n.d(t,"d",function(){return f}),n.d(t,"e",function(){return g}),n.d(t,"f",function(){return b}),n.d(t,"h",function(){return w});var r,a=n(14),i=n(6),s=n(0);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e.Registration="registration",e.EmailChange="email-change",e.PasswordChange="password-change",e.ProtocolUpgrade="protocol-upgrade",e.PasscodeCreate="passcode-create",e.PasscodeChange="passcode-change"})(r||(r={}));var l=['identifier','pw_cost','pw_nonce','pw_salt','version','origination','created'];function p(e){return g(e)}function d(e){return g(e)}function h(e){return g(e)}function f(e){return g(e)}function g(e){if(e.content)throw Error('Raw key params shouldnt have content; perhaps you passed in a SNRootKeyParams object.');return new w(e)}function m(e){if(e.version)return e.version;var t=e.pw_cost,n=a.a.PbkdfCostsUsed.includes(t),r=a.b.PbkdfCostsUsed.includes(t);return n&&!r?i.a.V001:r&&!n?i.a.V002:r&&n&&e.pw_nonce&&a.b.ImprobablePbkdfCostsUsed.includes(t)?i.a.V001:i.a.V002}function b(e,t){return g({identifier:t||e.data.identifier,pw_cost:e.data.pw_cost,pw_nonce:e.data.pw_nonce,pw_salt:e.data.pw_salt,version:m(e.data),origination:e.data.origination,created:e.data.created})}var w=(function(){function e(t){v(this,e),this.content=c(c({},t),{},{origination:t.origination||r.Registration,version:t.version||m(t)})}return y(e,[{key:"compare",value:function(e){if(this.version!==e.version)return!1;if([i.a.V004,i.a.V003].includes(this.version))return this.identifier===e.identifier&&this.content004.pw_nonce===e.content003.pw_nonce;if([i.a.V002,i.a.V001].includes(this.version))return this.identifier===e.identifier&&this.content002.pw_salt===e.content001.pw_salt;throw Error('Unhandled version in KeyParams.compare')}},{key:"getPortableValue",value:function(){return Object(s.L)(this.content,l)}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"identifier",get:function(){return this.content004.identifier||this.content002.email}},{key:"version",get:function(){return this.content.version}},{key:"origination",get:function(){return this.content.origination}},{key:"content001",get:function(){return this.content}},{key:"content002",get:function(){return this.content}},{key:"content003",get:function(){return this.content}},{key:"content004",get:function(){return this.content}},{key:"createdDate",get:function(){if(this.content004.created)return new Date(Number(this.content004.created))}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return s}),n.d(t,"c",function(){return r}),n.d(t,"d",function(){return a});var r,a,i=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:[3e3,5e3,1e4,6e4],PbkdfOutputLength:512,EncryptionKeyLength:256}),s=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:i.PbkdfCostsUsed.concat([1e5,101e3,102e3,103e3]),ImprobablePbkdfCostsUsed:[3e3,5e3],PbkdfOutputLength:768,EncryptionKeyLength:256,EncryptionIvLength:128});!(function(e){e[e.SaltSeedLength=256]="SaltSeedLength",e[e.PbkdfCost=11e4]="PbkdfCost",e[e.PbkdfOutputLength=768]="PbkdfOutputLength",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionIvLength=128]="EncryptionIvLength"})(r||(r={})),(function(e){e[e.ArgonSaltSeedLength=256]="ArgonSaltSeedLength",e[e.ArgonSaltLength=128]="ArgonSaltLength",e[e.ArgonIterations=5]="ArgonIterations",e[e.ArgonMemLimit=67108864]="ArgonMemLimit",e[e.ArgonOutputKeyBytes=64]="ArgonOutputKeyBytes",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionNonceLength=192]="EncryptionNonceLength"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"c",function(){return i}),n.d(t,"a",function(){return a});var r,a;n(22);function i(e){return e.status===r.HttpStatusExpiredAccessToken}!(function(e){e[e.LocalValidationError=10]="LocalValidationError",e[e.CanceledMfa=11]="CanceledMfa",e[e.UnknownError=12]="UnknownError",e[e.HttpStatusMinSuccess=200]="HttpStatusMinSuccess",e[e.HttpStatusNoContent=204]="HttpStatusNoContent",e[e.HttpStatusMaxSuccess=299]="HttpStatusMaxSuccess",e[e.HttpStatusExpiredAccessToken=498]="HttpStatusExpiredAccessToken",e[e.HttpStatusInvalidSession=401]="HttpStatusInvalidSession",e[e.HttpStatusForbidden=403]="HttpStatusForbidden",e[e.HttpBadRequest=400]="HttpBadRequest"})(r||(r={})),(function(e){e.ConflictingData="sync_conflict",e.UuidConflict="uuid_conflict",e.ContentTypeError="content_type_error",e.ContentError="content_error"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=(function(){function e(){v(this,e)}return y(e,null,[{key:"log",value:function(){this.onLog.apply(this,arguments)}},{key:"error",value:function(e){return this.onError(e),e}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"c",function(){return i});var r,a=n(9);function i(e){var t;return(t={},g(t,a.a.FullSyncCompleted,r.CompletedFullSync),g(t,a.a.SingleSyncCompleted,r.CompletedIncrementalSync),g(t,a.a.SyncError,r.FailedSync),g(t,a.a.SyncTakingTooLong,r.HighLatencySync),g(t,a.a.EnterOutOfSync,r.EnteredOutOfSync),g(t,a.a.ExitOutOfSync,r.ExitedOutOfSync),g(t,a.a.LocalDataLoaded,r.LocalDataLoaded),g(t,a.a.MajorDataChange,r.MajorDataChange),g(t,a.a.LocalDataIncrementalLoad,r.LocalDataIncrementalLoad),g(t,a.a.StatusChanged,r.SyncStatusChanged),g(t,a.a.SyncWillBegin,r.WillSync),g(t,a.a.InvalidSession,r.InvalidSyncSession),g(t,a.a.DatabaseReadError,r.LocalDatabaseReadError),g(t,a.a.DatabaseWriteError,r.LocalDatabaseWriteError),t)[e]}n.d(t,"b",function(){return a.a}),(function(e){e[e.SignedIn=2]="SignedIn",e[e.SignedOut=3]="SignedOut",e[e.CompletedFullSync=5]="CompletedFullSync",e[e.FailedSync=6]="FailedSync",e[e.HighLatencySync=7]="HighLatencySync",e[e.EnteredOutOfSync=8]="EnteredOutOfSync",e[e.ExitedOutOfSync=9]="ExitedOutOfSync",e[e.Started=10]="Started",e[e.Launched=11]="Launched",e[e.LocalDataLoaded=12]="LocalDataLoaded",e[e.KeyStatusChanged=13]="KeyStatusChanged",e[e.MajorDataChange=14]="MajorDataChange",e[e.CompletedRestart=15]="CompletedRestart",e[e.LocalDataIncrementalLoad=16]="LocalDataIncrementalLoad",e[e.SyncStatusChanged=17]="SyncStatusChanged",e[e.WillSync=18]="WillSync",e[e.InvalidSyncSession=19]="InvalidSyncSession",e[e.LocalDatabaseReadError=20]="LocalDatabaseReadError",e[e.LocalDatabaseWriteError=21]="LocalDatabaseWriteError",e[e.CompletedIncrementalSync=22]="CompletedIncrementalSync",e[e.MigrationsLoaded=23]="MigrationsLoaded",e[e.StorageReady=24]="StorageReady",e[e.PreferencesChanged=25]="PreferencesChanged",e[e.ProtectionSessionExpiryDateChanged=26]="ProtectionSessionExpiryDateChanged",e[e.UserRolesChanged=27]="UserRolesChanged",e[e.FeaturesUpdated=28]="FeaturesUpdated"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.KeepLeft=1]="KeepLeft",e[e.KeepRight=2]="KeepRight",e[e.KeepLeftDuplicateRight=3]="KeepLeftDuplicateRight",e[e.DuplicateLeftKeepRight=4]="DuplicateLeftKeepRight",e[e.KeepLeftMergeRefs=5]="KeepLeftMergeRefs"})(r||(r={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(211),t)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(221),t)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(0);function a(e){return e instanceof i?e:Array.isArray(e)?i.FromArray(e):i.FromJson(e)}var i=(function(){function e(t,n,r){if(v(this,e),this.keypath=t,this.operator=n,this.value=r,this.isRecursive()){var i=this.value;this.value=i.map(function(e){return a(e)})}else'true'!==this.value&&'false'!==this.value||(this.value=JSON.parse(this.value))}return y(e,[{key:"isRecursive",value:function(){return['and','or'].includes(this.operator)}},{key:"arrayRepresentation",value:function(){return[this.keypath,this.operator,this.value]}},{key:"valueAsArray",value:function(){return this.value}},{key:"keypathIncludesVerb",value:function(e){if(this.isRecursive()){for(var t,n=S(this.value);!(t=n()).done;){if(t.value.keypathIncludesVerb(e))return!0}return!1}return this.keypath.includes(e)}}],[{key:"FromJson",value:function(t){return new e(t.keypath,t.operator,t.value)}},{key:"FromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"CompoundPredicate",value:function(t){return new e('ignored','and',t)}},{key:"ObjectSatisfiesPredicate",value:function(e,t){if((t=a(t)).isRecursive()){if('and'===t.operator){for(var n,r=S(t.valueAsArray());!(n=r()).done;){var i=n.value;if(!this.ObjectSatisfiesPredicate(e,i))return!1}return!0}if('or'===t.operator){for(var s,o=S(t.valueAsArray());!(s=o()).done;){var c=s.value;if(this.ObjectSatisfiesPredicate(e,c))return!0}return!1}}var u=t.value;if('string'==typeof u&&u.includes('.ago')&&(u=this.DateFromString(u)),'not'===t.operator)return!this.ObjectSatisfiesPredicate(e,u);var l=t.keypath.split('.').reduce(function(e,t){return e&&e[t]},e),p=[!1,'',null,void 0,NaN];return void 0===l?'!='===t.operator?!p.includes(t.value):p.includes(t.value):'='===t.operator?Array.isArray(l)?JSON.stringify(l)===JSON.stringify(u):l===u:'!='===t.operator?Array.isArray(l)?JSON.stringify(l)!==JSON.stringify(u):l!==u:'<'===t.operator?l<u:'>'===t.operator?l>u:'<='===t.operator?l<=u:'>='===t.operator?l>=u:'startsWith'===t.operator?l.startsWith(u):'in'===t.operator?-1!==u.indexOf(l):'includes'===t.operator?this.resolveIncludesPredicate(l,u):'matches'===t.operator&&new RegExp(u).test(l)}},{key:"resolveIncludesPredicate",value:function(t,n){if(Object(r.A)(n))return t.includes(n);var a;a=Array.isArray(n)?e.FromArray(n):n;for(var i,s=S(t);!(i=s()).done;){var o=i.value;if(this.ObjectSatisfiesPredicate(o,a))return!0}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!this.ItemSatisfiesPredicate(e,a))return!1}return!0}},{key:"DateFromString",value:function(e){var t=e.split('.'),n=t[1],r=new Date,a=parseInt(t[0]);return'days'===n?r.setDate(r.getDate()-a):'hours'===n&&r.setHours(r.getHours()-a),r}}]),e})()},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.LastSyncToken="sync_token",e.PaginationToken="cursor_token",e.IntegrityCheck="compute_integrity",e.IntegrityResult="integrity_hash",e.SyncDlLimit="limit",e.SyncPayloads="items",e.ApiVersion="api"})(r||(r={}))},function(e,t,n){"use strict";var r=Array.isArray;e.exports=r},function(e,t,n){"use strict";var r=n(68),a='object'==typeof self&&self&&self.Object===Object&&self,i=r||a||Function('return this')();e.exports=i},function(e,t,n){"use strict";var r=n(173)(n(174));e.exports=r},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(e,t,n){"use strict";var r=n(48),a=n(168);e.exports=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,s=[],o=e.length;for(t=r(t,3);++i<o;){var c=e[i];t(c,i,e)&&(n.push(c),s.push(i))}return a(e,s),n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e){return e&&e.length?r(e):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(241),t)},function(e,t,n){"use strict";var r=n(110),a=n(115);e.exports=function(e,t){var n=a(e,t);return r(n)?n:void 0}},function(e,t,n){"use strict";e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t,n){"use strict";n.d(t,"a",function(){return u});var r=n(11),a=n(5),i=n(4),s=n(6),o=n(0),c=n(12),u=(function(){function e(t,n,u){if(v(this,e),this.fields=n||Object.keys(t),this.source=u||i.a.Constructor,this.uuid=t.uuid,!this.uuid&&this.fields.includes(a.a.Uuid))throw Error("uuid is null, yet this payloads fields indicate it shouldnt be. Content type: ".concat(t.content_type));this.content_type=t.content_type,t.content&&(Object(o.x)(t.content)?this.content=Object(r.a)(t.content):this.content=t.content),this.deleted=t.deleted,this.items_key_id=t.items_key_id,this.enc_item_key=t.enc_item_key,this.created_at=new Date(t.created_at||new Date),this.updated_at=new Date(t.updated_at||0),this.created_at_timestamp=t.created_at_timestamp,this.updated_at_timestamp=t.updated_at_timestamp,t.dirtiedDate&&(this.dirtiedDate=new Date(t.dirtiedDate)),this.dirty=t.dirty,this.errorDecrypting=t.errorDecrypting,this.waitingForKey=t.waitingForKey,this.errorDecryptingValueChanged=t.errorDecryptingValueChanged,this.lastSyncBegan=t.lastSyncBegan?new Date(t.lastSyncBegan):void 0,this.lastSyncEnd=t.lastSyncEnd?new Date(t.lastSyncEnd):void 0,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params,this.duplicate_of=t.duplicate_of,Object(o.A)(this.content)?this.content.startsWith(s.a.V000Base64Decrypted)?this.format=c.a.DecryptedBase64String:this.format=c.a.EncryptedString:Object(o.x)(this.content)?this.format=c.a.DecryptedBareObject:this.format=c.a.Deleted,Object(o.A)(this.content)?this.version=this.content.substring(0,s.a.VersionLength):this.content&&(this.version=this.content.version),Object(o.l)(this)}return y(e,[{key:"ejected",value:function(){for(var e,t=[a.a.Legacy003AuthHash,a.a.Deleted],n=[a.a.DirtiedDate,a.a.ErrorDecrypting,a.a.ErrorDecryptingChanged,a.a.WaitingForKey,a.a.LastSyncBegan,a.a.LastSyncEnd],r={},i=S(this.fields);!(e=i()).done;){var s=e.value;if(!n.includes(s)){var c=this[s];Object(o.w)(c)&&t.includes(s)||(r[s]=c)}}return r}},{key:"safeContent",get:function(){return this.format===c.a.DecryptedBareObject?this.content:{}}},{key:"references",get:function(){return this.safeReferences}},{key:"safeReferences",get:function(){return this.safeContent.references||[]}},{key:"contentObject",get:function(){if(this.format!==c.a.DecryptedBareObject)throw Error('Attempting to access non-object content as object');return this.content}},{key:"contentString",get:function(){if(this.format===c.a.DecryptedBareObject)throw Error('Attempting to access non-string content as string');return this.content}},{key:"discardable",get:function(){return this.deleted&&!this.dirty}},{key:"serverUpdatedAt",get:function(){return this.updated_at}}]),e})()},function(e,t,n){"use strict";var r=n(40),a=n(111),i=n(112),s='[object Null]',o='[object Undefined]',c=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?o:s:c&&c in Object(e)?a(e):i(e)}},function(e,t,n){"use strict";var r;r=(function(){return this})();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,n){"use strict";var r=n(51),a=n(59);e.exports=function(e){return null!=e&&a(e.length)&&!r(e)}},function(e,t,n){"use strict";var r=n(44);e.exports=function(e){if('string'==typeof e||r(e))return e;var t=e+'';return'0'==t&&1/e==-1/0?'-0':t}},function(e,t,n){"use strict";var r=n(100),a=n(101),i=n(102),s=n(103),o=n(104);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(35);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},function(e,t,n){"use strict";var r=n(24).Symbol;e.exports=r},function(e,t,n){"use strict";var r=n(30)(Object,'create');e.exports=r},function(e,t,n){"use strict";var r=n(124);e.exports=function(e,t){var n=e.__data__;return r(t)?n['string'==typeof t?'string':'hash']:n.map}},function(e,t,n){"use strict";var r=9007199254740991,a=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var n=typeof e;return!!(t=null==t?r:t)&&('number'==n||'symbol'!=n&&a.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Symbol]';e.exports=function(e){return'symbol'==typeof e||a(e)&&r(e)==i}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(231),t)},function(e,t,n){"use strict";var r=n(96);n.d(t,"SNSettingsService",function(){return r.a});var a=n(94);n.n(a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n){r(e,t,n)});e.exports=a},function(e,t,n){"use strict";var r=n(98),a=n(154),i=n(64),s=n(23),o=n(165);e.exports=function(e){return'function'==typeof e?e:null==e?i:'object'==typeof e?s(e)?a(e[0],e[1]):r(e):o(e)}},function(e,t,n){"use strict";var r=n(38),a=n(105),i=n(106),s=n(107),o=n(108),c=n(109);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=a,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=c,e.exports=u},function(e,t,n){"use strict";var r=n(30)(n(24),'Map');e.exports=r},function(e,t,n){"use strict";var r=n(33),a=n(26),i='[object AsyncFunction]',s='[object Function]',o='[object GeneratorFunction]',c='[object Proxy]';e.exports=function(e){if(!a(e))return!1;var t=r(e);return t==s||t==o||t==i||t==c}},function(e,t,n){"use strict";var r=n(116),a=n(123),i=n(125),s=n(126),o=n(127);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},function(e,t,n){"use strict";var r=n(75),a=n(147),i=n(36);e.exports=function(e){return i(e)?r(e):a(e)}},function(e,t,n){"use strict";var r=n(142),a=n(31),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,c=r((function(){return arguments})())?r:function(e){return a(e)&&s.call(e,'callee')&&!o.call(e,'callee')};e.exports=c},function(e,t,n){"use strict";(function(e){var r=n(24),a=n(143),i=t&&!t.nodeType&&t,s=i&&'object'==typeof e&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,c=(o?o.isBuffer:void 0)||a;e.exports=c}).call(this,n(57)(e))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";var r=n(144),a=n(145),i=n(146),s=i&&i.isTypedArray,o=s?a(s):r;e.exports=o},function(e,t,n){"use strict";var r=9007199254740991;e.exports=function(e){return'number'==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,n){"use strict";var r=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===('function'==typeof t&&t.prototype||r)}},function(e,t,n){"use strict";var r=n(62),a=n(37);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[a(t[n++])];return n&&n==i?e:void 0}},function(e,t,n){"use strict";var r=n(23),a=n(63),i=n(156),s=n(159);e.exports=function(e,t){return r(e)?e:a(e,t)?[e]:i(s(e))}},function(e,t,n){"use strict";var r=n(23),a=n(44),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!('number'!=n&&'symbol'!=n&&'boolean'!=n&&null!=e&&!a(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},function(e,t,n){"use strict";e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(83);e.exports=function(e,t,n){'__proto__'==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e,t){return t='function'==typeof t?t:void 0,e&&e.length?r(e,void 0,t):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(228),t),a(n(229),t),a(n(230),t)},function(e,t,n){"use strict";(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(34))},function(e,t,n){"use strict";var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+''}catch(e){}}return''}},function(e,t,n){"use strict";var r=n(128),a=n(31);e.exports=function e(t,n,i,s,o){return t===n||(null==t||null==n||!a(t)&&!a(n)?t!=t&&n!=n:r(t,n,i,s,e,o))}},function(e,t,n){"use strict";var r=n(72),a=n(131),i=n(73),s=1,o=2;e.exports=function(e,t,n,c,u,l){var p=n&s,d=e.length,h=t.length;if(d!=h&&!(p&&h>d))return!1;var f=l.get(e),v=l.get(t);if(f&&v)return f==t&&v==e;var y=-1,g=!0,m=n&o?new r:void 0;for(l.set(e,t),l.set(t,e);++y<d;){var b=e[y],w=t[y];if(c)var k=p?c(w,b,y,t,e,l):c(b,w,y,e,t,l);if(void 0!==k){if(k)continue;g=!1;break}if(m){if(!a(t,function(e,t){if(!i(m,t)&&(b===e||u(b,e,n,c,l)))return m.push(t)})){g=!1;break}}else if(b!==w&&!u(b,w,n,c,l)){g=!1;break}}return l.delete(e),l.delete(t),g}},function(e,t,n){"use strict";var r=n(52),a=n(129),i=n(130);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=a,s.prototype.has=i,e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t){return e.has(t)}},function(e,t,n){"use strict";var r=n(24).Uint8Array;e.exports=r},function(e,t,n){"use strict";var r=n(141),a=n(55),i=n(23),s=n(56),o=n(43),c=n(58),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&a(e),p=!n&&!l&&s(e),d=!n&&!l&&!p&&c(e),h=n||l||p||d,f=h?r(e.length,String):[],v=f.length;for(var y in e)!t&&!u.call(e,y)||h&&('length'==y||p&&('offset'==y||'parent'==y)||d&&('buffer'==y||'byteLength'==y||'byteOffset'==y)||o(y,v))||f.push(y);return f}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){"use strict";var r=n(30)(n(24),'Set');e.exports=r},function(e,t,n){"use strict";var r=n(26);e.exports=function(e){return e==e&&!r(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){for(var a=e.length,i=n+(r?1:-1);r?i--:++i<a;)if(t(e[i],i,e))return i;return-1}},function(e,t,n){"use strict";var r=n(49),a=n(82),i=n(178),s=n(180),o=n(26),c=n(86),u=n(85);e.exports=function e(t,n,l,p,d){t!==n&&i(n,function(i,c){if(d||(d=new r),o(i))s(t,n,c,l,e,p,d);else{var h=p?p(u(t,c),i,c+'',t,n,d):void 0;void 0===h&&(h=i),a(t,c,h)}},c)}},function(e,t,n){"use strict";var r=n(65),a=n(35);e.exports=function(e,t,n){(void 0===n||a(e[t],n))&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(30),a=(function(){try{var e=r(Object,'defineProperty');return e({},'',{}),e}catch(e){}})();e.exports=a},function(e,t,n){"use strict";var r=n(76)(Object.getPrototypeOf,Object);e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){if(('constructor'!==t||'function'!=typeof e[t])&&'__proto__'!=t)return e[t]}},function(e,t,n){"use strict";var r=n(75),a=n(192),i=n(36);e.exports=function(e){return i(e)?r(e,!0):a(e)}},function(e,t,n){"use strict";var r=n(194),a=n(201);e.exports=function(e){return r(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(s=e.length>3&&'function'==typeof s?(i--,s):void 0,o&&a(n[0],n[1],o)&&(s=i<3?void 0:s,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,s)}return t})}},function(e,t,n){"use strict";var r=n(72),a=n(202),i=n(206),s=n(73),o=n(207),c=n(53),u=200;e.exports=function(e,t,n){var l=-1,p=a,d=e.length,h=!0,f=[],v=f;if(n)h=!1,p=i;else if(d>=u){var y=t?null:o(e);if(y)return c(y);h=!1,p=s,v=new r}else v=t?[]:f;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=n||0!==g?g:0,h&&m==m){for(var b=v.length;b--;)if(v[b]===m)continue e;t&&v.push(m),f.push(g)}else p(v,m,n)||(v!==f&&v.push(m),f.push(g))}return f}},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(209),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeatureIdentifier=void 0,(function(e){e.AutobiographyTheme="org.standardnotes.theme-autobiography",e.BoldEditor="org.standardnotes.bold-editor",e.CloudLink="org.standardnotes.cloudlink",e.CodeEditor="org.standardnotes.code-editor",e.DailyDropboxBackup="org.standardnotes.daily-dropbox-backup",e.DailyEmailBackup="org.standardnotes.daily-email-backup",e.DailyGDriveBackup="org.standardnotes.daily-gdrive-backup",e.DailyOneDriveBackup="org.standardnotes.daily-onedrive-backup",e.DynamicTheme="org.standardnotes.theme-dynamic",e.Files="org.standardnotes.files",e.Files25GB="org.standardnotes.files-25-gb",e.Files5GB="org.standardnotes.files-5-gb",e.FileSafe="org.standardnotes.file-safe",e.FocusedTheme="org.standardnotes.theme-focus",e.FoldersComponent="org.standardnotes.folders",e.FuturaTheme="org.standardnotes.theme-futura",e.ListedCustomDomain="org.standardnotes.listed-custom-domain",e.MarkdownBasicEditor="org.standardnotes.simple-markdown-editor",e.MarkdownMathEditor="org.standardnotes.fancy-markdown-editor",e.MarkdownMinimistEditor="org.standardnotes.minimal-markdown-editor",e.MarkdownProEditor="org.standardnotes.advanced-markdown-editor",e.MidnightTheme="org.standardnotes.theme-midnight",e.NoDistractionTheme="org.standardnotes.theme-no-distraction",e.NoteHistory30Days="org.standardnotes.note-history-30",e.NoteHistory365Days="org.standardnotes.note-history-365",e.NoteHistoryUnlimited="org.standardnotes.note-history-unlimited",e.PlusEditor="org.standardnotes.plus-editor",e.SheetsEditor="org.standardnotes.standard-sheets",e.SolarizedDarkTheme="org.standardnotes.theme-solarized-dark",e.TagNesting="org.standardnotes.tag-nesting",e.TaskEditor="org.standardnotes.simple-task-editor",e.TitaniumTheme="org.standardnotes.theme-titanium",e.TokenVaultEditor="org.standardnotes.token-vault",e.TwoFactorAuth="org.standardnotes.two-factor-auth",e.TwoFactorAuthManager="org.standardnotes.mfa-link",e.FocusMode="org.standardnotes.focus-mode"})(t.FeatureIdentifier||(t.FeatureIdentifier={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentArea=void 0,(function(e){e.Editor="editor-editor",e.Themes="themes",e.TagsList="tags-list",e.EditorStack="editor-stack",e.NoteTags="note-tags",e.Rooms="rooms",e.Modal="modal",e.Any="*"})(t.ComponentArea||(t.ComponentArea={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentFlag=void 0,(function(e){e.New="New",e.Deprecated="Deprecated"})(t.ComponentFlag||(t.ComponentFlag={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionName=void 0,(function(e){e.AutobiographyTheme="theme:autobiography",e.BoldEditor="editor:bold",e.CloudLink="component:cloud-link",e.CodeEditor="editor:code-editor",e.ComponentFilesafe="component:filesafe",e.ComponentFolders="component:folders",e.DailyDropboxBackup="server:daily-dropbox-backup",e.DailyEmailBackup="server:daily-email-backup",e.DailyGDriveBackup="server:daily-gdrive-backup",e.DailyOneDriveBackup="server:daily-onedrive-backup",e.Files="app:files",e.Files25GB="server:files-25-gb",e.Files5GB="server:files-5-gb",e.FocusedTheme="theme:focused",e.FuturaTheme="theme:futura",e.ListedCustomDomain="listed:custom-domain",e.MarkdownBasicEditor="editor:markdown-basic",e.MarkdownMathEditor="editor:markdown-math",e.MarkdownMinimistEditor="editor:markdown-minimist",e.MarkdownProEditor="editor:markdown-pro",e.MidnightTheme="theme:midnight",e.NoteHistory30Days="server:note-history-30-days",e.NoteHistory365Days="server:note-history-365-days",e.NoteHistoryUnlimited="server:note-history-unlimited",e.PlusEditor="editor:plus",e.SheetsEditor="editor:sheets",e.SolarizedDarkTheme="theme:solarized-dark",e.TagNesting="app:tag-nesting",e.TaskEditor="editor:task-editor",e.ThemeDynamic="theme:dynamic",e.ThemeNoDistraction="theme:no-distraction",e.TitaniumTheme="theme:titanium",e.TokenVaultEditor="editor:token-vault",e.TwoFactorAuth="server:two-factor-auth",e.TwoFactorAuthManager="component:2fa-manager",e.FocusMode="app:focus-mode"})(t.PermissionName||(t.PermissionName={}))},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return i});var r=n(10),a=n(17),i=(function(t){d(r,t);var n=k(r);function r(t){var a;return v(this,r),(a=n.call(this)).application=t,e(function(){a.addAppEventObserver()}),a}return y(r,[{key:"deinit",value:function(){this.application=void 0,this.unsubApp(),this.unsubApp=void 0,p(f(r.prototype),"deinit",this).call(this)}},{key:"addAppEventObserver",value:function(){var e=this;this.application.isStarted()&&this.onAppStart(),this.application.isLaunched()&&this.onAppLaunch(),this.unsubApp=this.application.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(e.onAppEvent(t));case 2:t===a.a.Started?e.onAppStart():t===a.a.Launched?e.onAppLaunch():t===a.a.CompletedFullSync?e.onAppFullSync():t===a.a.CompletedIncrementalSync?e.onAppIncrementalSync():t===a.a.KeyStatusChanged&&e.onAppKeyChange();case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"onAppEvent",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppStart",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppLaunch",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppKeyChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppIncrementalSync",value:function(){}},{key:"onAppFullSync",value:function(){}}]),r})(r.a)}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(10),a=n(2),i=n(15),s=(function(){function e(t,n){v(this,e),this.settingsApi=t,this.userProvider=n}return y(e,[{key:"isReadyForModification",value:function(){return null!=this.getUser()}},{key:"getUser",value:function(){return this.userProvider.getUser()}},{key:"listSettings",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.settingsApi.listSettings(this.userUuid));case 2:if(e=o.sent,t=e.error,n=e.data,null==t){o.next=7;break}throw new Error(t.message);case 7:if(null!=n&&null!=n.settings){o.next=9;break}return o.abrupt("return",{});case 9:for(r={},a=S(n.settings);!(i=a()).done;)s=i.value,r[s.name]=s.value;return o.abrupt("return",r);case 12:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){var t,n,r,a;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((a=s.sent).status!==i.b.HttpBadRequest){s.next=5;break}return s.abrupt("return",null);case 5:if(null==a.error){s.next=7;break}throw new Error(a.error.message);case 7:return s.abrupt("return",null!==(t=null===a||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:null===(r=n.setting)||void 0===r?void 0:r.value)&&void 0!==t?t:null);case 8:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((r=a.sent).status!==i.b.HttpBadRequest){a.next=5;break}return a.abrupt("return",!1);case 5:if(null==r.error){a.next=7;break}throw new Error(r.error.message);case 7:return a.abrupt("return",null!==(t=null===(n=r.data)||void 0===n?void 0:n.success)&&void 0!==t&&t);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){var r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.settingsApi.updateSetting(this.userUuid,e,t,n));case 2:if(r=i.sent,null==(a=r.error)){i.next=6;break}throw new Error(a.message);case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.settingsApi.deleteSetting(this.userUuid,e));case 2:if(t=r.sent,null==(n=t.error)){r.next=6;break}throw new Error(n.message);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.settingsApi=void 0,this.userProvider=void 0}},{key:"userUuid",get:function(){var e=this.getUser();if(null==e||null==e.uuid)throw new Error(a.o);return e.uuid}}]),e})(),o=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).sessionManager=e,a.apiService=r,a}return y(n,[{key:"initializeFromDisk",value:function(){this._provider=new s(this.apiService,this.sessionManager)}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._provider.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this._provider.updateSetting(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){var e;null===(e=this._provider)||void 0===e||e.deinit(),this._provider=void 0,this.sessionManager=void 0,this.apiService=void 0}}]),n})(r.a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n,a){r(e,t,n,a)});e.exports=a},function(e,t,n){"use strict";var r=n(99),a=n(153),i=n(79);e.exports=function(e){var t=a(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){"use strict";var r=n(49),a=n(70);e.exports=function(e,t,n,i){var s=n.length,o=s,c=!i;if(null==e)return!o;for(e=Object(e);s--;){var u=n[s];if(c&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++s<o;){var l=(u=n[s])[0],p=e[l],d=u[1];if(c&&u[2]){if(void 0===p&&!(l in e))return!1}else{var h=new r;if(i)var f=i(p,d,l,e,t,h);if(!(void 0===f?a(d,p,3,i,h):f))return!1}}return!0}},function(e,t,n){"use strict";e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){"use strict";var r=n(39),a=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():a.call(t,n,1),--this.size,0))}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e,t){var n=this.__data__,a=r(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}},function(e,t,n){"use strict";var r=n(38);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.get(e)}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";var r=n(38),a=n(50),i=n(52);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!a||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){"use strict";var r=n(51),a=n(113),i=n(26),s=n(69),o=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,p=u.hasOwnProperty,d=RegExp('^'+l.call(p).replace(/[\\^$.*+?()[\]{}|]/g,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');e.exports=function(e){return!(!i(e)||a(e))&&(r(e)?d:o).test(s(e))}},function(e,t,n){"use strict";var r=n(40),a=Object.prototype,i=a.hasOwnProperty,s=a.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0}catch(e){}var r=s.call(e);return t?e[o]=n:delete e[o],r}},function(e,t,n){"use strict";var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,n){"use strict";var r,a=n(114),i=(r=/[^.]+$/.exec(a&&a.keys&&a.keys.IE_PROTO||''))?'Symbol(src)_1.'+r:'';e.exports=function(e){return!!i&&i in e}},function(e,t,n){"use strict";var r=n(24)['__core-js_shared__'];e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){"use strict";var r=n(117),a=n(38),i=n(50);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||a),string:new r}}},function(e,t,n){"use strict";var r=n(118),a=n(119),i=n(120),s=n(121),o=n(122);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(41);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__',i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===a?void 0:n}return i.call(t,e)?t[e]:void 0}},function(e,t,n){"use strict";var r=n(41),a=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:a.call(t,e)}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__';e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?a:t,this}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return'string'==t||'number'==t||'symbol'==t||'boolean'==t?'__proto__'!==e:null===e}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).get(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).has(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e,t){var n=r(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}},function(e,t,n){"use strict";var r=n(49),a=n(71),i=n(132),s=n(134),o=n(149),c=n(23),u=n(56),l=n(58),p=1,d='[object Arguments]',h='[object Array]',f='[object Object]',v=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,y,g,m){var b=c(e),w=c(t),k=b?h:o(e),x=w?h:o(t),S=(k=k==d?f:k)==f,P=(x=x==d?f:x)==f,O=k==x;if(O&&u(e)){if(!u(t))return!1;b=!0,S=!1}if(O&&!S)return m||(m=new r),b||l(e)?a(e,t,n,y,g,m):i(e,t,k,n,y,g,m);if(!(n&p)){var C=S&&v.call(e,'__wrapped__'),D=P&&v.call(t,'__wrapped__');if(C||D){var _=C?e.value():e,E=D?t.value():t;return m||(m=new r),g(_,E,n,y,m)}}return!!O&&(m||(m=new r),s(e,t,n,y,g,m))}},function(e,t,n){"use strict";var r='__lodash_hash_undefined__';e.exports=function(e){return this.__data__.set(e,r),this}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},function(e,t,n){"use strict";var r=n(40),a=n(74),i=n(35),s=n(71),o=n(133),c=n(53),u=1,l=2,p='[object Boolean]',d='[object Date]',h='[object Error]',f='[object Map]',v='[object Number]',y='[object RegExp]',g='[object Set]',m='[object String]',b='[object Symbol]',w='[object ArrayBuffer]',k='[object DataView]',x=r?r.prototype:void 0,S=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,P,O){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!P(new a(e),new a(t)));case p:case d:case v:return i(+e,+t);case h:return e.name==t.name&&e.message==t.message;case y:case m:return e==t+'';case f:var C=o;case g:var D=r&u;if(C||(C=c),e.size!=t.size&&!D)return!1;var _=O.get(e);if(_)return _==t;r|=l,O.set(e,t);var E=s(C(e),C(t),r,x,P,O);return O.delete(e),E;case b:if(S)return S.call(e)==S.call(t)}return!1}},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},function(e,t,n){"use strict";var r=n(135),a=1,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,s,o,c){var u=n&a,l=r(e),p=l.length;if(p!=r(t).length&&!u)return!1;for(var d=p;d--;){var h=l[d];if(!(u?h in t:i.call(t,h)))return!1}var f=c.get(e),v=c.get(t);if(f&&v)return f==t&&v==e;var y=!0;c.set(e,t),c.set(t,e);for(var g=u;++d<p;){var m=e[h=l[d]],b=t[h];if(s)var w=u?s(b,m,h,t,e,c):s(m,b,h,e,t,c);if(!(void 0===w?m===b||o(m,b,n,s,c):w)){y=!1;break}g||(g='constructor'==h)}if(y&&!g){var k=e.constructor,x=t.constructor;k!=x&&'constructor'in e&&'constructor'in t&&!('function'==typeof k&&k instanceof k&&'function'==typeof x&&x instanceof x)&&(y=!1)}return c.delete(e),c.delete(t),y}},function(e,t,n){"use strict";var r=n(136),a=n(138),i=n(54);e.exports=function(e){return r(e,i,a)}},function(e,t,n){"use strict";var r=n(137),a=n(23);e.exports=function(e,t,n){var i=t(e);return a(e)?i:r(i,n(e))}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}},function(e,t,n){"use strict";var r=n(139),a=n(140),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:a;e.exports=o},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}},function(e,t,n){"use strict";e.exports=function(){return[]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Arguments]';e.exports=function(e){return a(e)&&r(e)==i}},function(e,t,n){"use strict";e.exports=function(){return!1}},function(e,t,n){"use strict";var r=n(33),a=n(59),i=n(31),s={};s['[object Float32Array]']=s['[object Float64Array]']=s['[object Int8Array]']=s['[object Int16Array]']=s['[object Int32Array]']=s['[object Uint8Array]']=s['[object Uint8ClampedArray]']=s['[object Uint16Array]']=s['[object Uint32Array]']=!0,s['[object Arguments]']=s['[object Array]']=s['[object ArrayBuffer]']=s['[object Boolean]']=s['[object DataView]']=s['[object Date]']=s['[object Error]']=s['[object Function]']=s['[object Map]']=s['[object Number]']=s['[object Object]']=s['[object RegExp]']=s['[object Set]']=s['[object String]']=s['[object WeakMap]']=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!s[r(e)]}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){"use strict";(function(e){var r=n(68),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a&&r.process,o=(function(){try{var e=i&&i.require&&i.require('util').types;return e||s&&s.binding&&s.binding('util')}catch(e){}})();e.exports=o}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(60),a=n(148),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return a(e);var t=[];for(var n in Object(e))i.call(e,n)&&'constructor'!=n&&t.push(n);return t}},function(e,t,n){"use strict";var r=n(76)(Object.keys,Object);e.exports=r},function(e,t,n){"use strict";var r=n(150),a=n(50),i=n(151),s=n(77),o=n(152),c=n(33),u=n(69),l=u(r),p=u(a),d=u(i),h=u(s),f=u(o),v=c;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||a&&"[object Map]"!=v(new a)||i&&"[object Promise]"!=v(i.resolve())||s&&"[object Set]"!=v(new s)||o&&"[object WeakMap]"!=v(new o))&&(v=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):'';if(r)switch(r){case l:return"[object DataView]";case p:return"[object Map]";case d:return"[object Promise]";case h:return"[object Set]";case f:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";var r=n(30)(n(24),'DataView');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'Promise');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'WeakMap');e.exports=r},function(e,t,n){"use strict";var r=n(78),a=n(54);e.exports=function(e){for(var t=a(e),n=t.length;n--;){var i=t[n],s=e[i];t[n]=[i,s,r(s)]}return t}},function(e,t,n){"use strict";var r=n(70),a=n(155),i=n(162),s=n(63),o=n(78),c=n(79),u=n(37);e.exports=function(e,t){return s(e)&&o(t)?c(u(e),t):function(n){var s=a(n,e);return void 0===s&&s===t?i(n,e):r(t,s,3)}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e,t,n){var a=null==e?void 0:r(e,t);return void 0===a?n:a}},function(e,t,n){"use strict";var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,i=n(157)(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(''),e.replace(r,function(e,n,r,i){t.push(r?i.replace(a,'$1'):n||e)}),t});e.exports=i},function(e,t,n){"use strict";var r=n(158),a=500;e.exports=function(e){var t=r(e,function(e){return n.size===a&&n.clear(),e}),n=t.cache;return t}},function(e,t,n){"use strict";var r=n(52),a='Expected a function';function i(e,t){if('function'!=typeof e||null!=t&&'function'!=typeof t)throw new TypeError(a);var n=function n(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},function(e,t,n){"use strict";var r=n(160);e.exports=function(e){return null==e?'':r(e)}},function(e,t,n){"use strict";var r=n(40),a=n(161),i=n(23),s=n(44),o=r?r.prototype:void 0,c=o?o.toString:void 0;e.exports=function e(t){if('string'==typeof t)return t;if(i(t))return a(t,e)+'';if(s(t))return c?c.call(t):'';var n=t+'';return'0'==n&&1/t==-1/0?'-0':n}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}},function(e,t,n){"use strict";var r=n(163),a=n(164);e.exports=function(e,t){return null!=e&&a(e,t,r)}},function(e,t,n){"use strict";e.exports=function(e,t){return null!=e&&t in Object(e)}},function(e,t,n){"use strict";var r=n(62),a=n(55),i=n(23),s=n(43),o=n(59),c=n(37);e.exports=function(e,t,n){for(var u=-1,l=(t=r(t,e)).length,p=!1;++u<l;){var d=c(t[u]);if(!(p=null!=e&&n(e,d)))break;e=e[d]}return p||++u!=l?p:!!(l=null==e?0:e.length)&&o(l)&&s(d,l)&&(i(e)||a(e))}},function(e,t,n){"use strict";var r=n(166),a=n(167),i=n(63),s=n(37);e.exports=function(e){return i(e)?r(s(e)):a(e)}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e){return function(t){return r(t,e)}}},function(e,t,n){"use strict";var r=n(169),a=n(43),i=Array.prototype.splice;e.exports=function(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;a(o)?i.call(e,o,1):r(e,o)}}return e}},function(e,t,n){"use strict";var r=n(62),a=n(170),i=n(171),s=n(37);e.exports=function(e,t){return t=r(t,e),null==(e=i(e,t))||delete e[s(a(t))]}},function(e,t,n){"use strict";e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t,n){"use strict";var r=n(61),a=n(172);e.exports=function(e,t){return t.length<2?e:r(e,a(t,0,-1))}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(a);++r<a;)i[r]=e[r+t];return i}},function(e,t,n){"use strict";var r=n(48),a=n(36),i=n(54);e.exports=function(e){return function(t,n,s){var o=Object(t);if(!a(t)){var c=r(n,3);t=i(t),n=function(e){return c(o[e],e,o)}}var u=e(t,n,s);return u>-1?o[c?t[u]:u]:void 0}}},function(e,t,n){"use strict";var r=n(80),a=n(48),i=n(175),s=Math.max;e.exports=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var c=null==n?0:i(n);return c<0&&(c=s(o+c,0)),r(e,a(t,3),c)}},function(e,t,n){"use strict";var r=n(176);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){"use strict";var r=n(177),a=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=r(e))===a||e===-1/0?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,n){"use strict";var r=n(26),a=n(44),i=NaN,s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(a(e))return i;if(r(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=r(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):o.test(e)?i:+e}},function(e,t,n){"use strict";var r=n(179)();e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t,n,r){for(var a=-1,i=Object(t),s=r(t),o=s.length;o--;){var c=s[e?o:++a];if(!1===n(i[c],c,i))break}return t}}},function(e,t,n){"use strict";var r=n(82),a=n(181),i=n(182),s=n(184),o=n(185),c=n(55),u=n(23),l=n(187),p=n(56),d=n(51),h=n(26),f=n(188),v=n(58),y=n(85),g=n(189);e.exports=function(e,t,n,m,b,w,k){var x=y(e,n),S=y(t,n),P=k.get(S);if(P)r(e,n,P);else{var O=w?w(x,S,n+'',e,t,k):void 0,C=void 0===O;if(C){var D=u(S),_=!D&&p(S),E=!D&&!_&&v(S);O=S,D||_||E?u(x)?O=x:l(x)?O=s(x):_?(C=!1,O=a(S,!0)):E?(C=!1,O=i(S,!0)):O=[]:f(S)||c(S)?(O=x,c(x)?O=g(x):h(x)&&!d(x)||(O=o(S))):C=!1}C&&(k.set(S,O),b(O,S,m,w,k),k.delete(S)),r(e,n,O)}}},function(e,t,n){"use strict";(function(e){var r=n(24),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(183);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},function(e,t,n){"use strict";var r=n(74);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t,n){"use strict";e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},function(e,t,n){"use strict";var r=n(186),a=n(84),i=n(60);e.exports=function(e){return'function'!=typeof e.constructor||i(e)?{}:r(a(e))}},function(e,t,n){"use strict";var r=n(26),a=Object.create,i=(function(){function e(){}return function(t){if(!r(t))return{};if(a)return a(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}})();e.exports=i},function(e,t,n){"use strict";var r=n(36),a=n(31);e.exports=function(e){return a(e)&&r(e)}},function(e,t,n){"use strict";var r=n(33),a=n(84),i=n(31),s='[object Object]',o=Function.prototype,c=Object.prototype,u=o.toString,l=c.hasOwnProperty,p=u.call(Object);e.exports=function(e){if(!i(e)||r(e)!=s)return!1;var t=a(e);if(null===t)return!0;var n=l.call(t,'constructor')&&t.constructor;return'function'==typeof n&&n instanceof n&&u.call(n)==p}},function(e,t,n){"use strict";var r=n(190),a=n(86);e.exports=function(e){return r(e,a(e))}},function(e,t,n){"use strict";var r=n(191),a=n(65);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var o=-1,c=t.length;++o<c;){var u=t[o],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?a(n,u,l):r(n,u,l)}return n}},function(e,t,n){"use strict";var r=n(65),a=n(35),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&a(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(26),a=n(60),i=n(193),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=a(e),n=[];for(var o in e)('constructor'!=o||!t&&s.call(e,o))&&n.push(o);return n}},function(e,t,n){"use strict";e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},function(e,t,n){"use strict";var r=n(64),a=n(195),i=n(197);e.exports=function(e,t){return i(a(e,t,r),e+'')}},function(e,t,n){"use strict";var r=n(196),a=Math.max;e.exports=function(e,t,n){return t=a(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=a(i.length-t,0),c=Array(o);++s<o;)c[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(c),r(e,this,u)}}},function(e,t,n){"use strict";e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){"use strict";var r=n(198),a=n(200)(r);e.exports=a},function(e,t,n){"use strict";var r=n(199),a=n(83),i=n(64),s=a?function(e,t){return a(e,'toString',{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},function(e,t,n){"use strict";e.exports=function(e){return function(){return e}}},function(e,t,n){"use strict";var r=800,a=16,i=Date.now;e.exports=function(e){var t=0,n=0;return function(){var s=i(),o=a-(s-n);if(n=s,o>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){"use strict";var r=n(35),a=n(36),i=n(43),s=n(26);e.exports=function(e,t,n){if(!s(n))return!1;var o=typeof t;return!!('number'==o?a(n)&&i(t,n.length):'string'==o&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";var r=n(203);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t,n){"use strict";var r=n(80),a=n(204),i=n(205);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,a,n)}},function(e,t,n){"use strict";e.exports=function(e){return e!=e}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=n-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=-1,a=null==e?0:e.length;++r<a;)if(n(t,e[r]))return!0;return!1}},function(e,t,n){"use strict";var r=n(77),a=n(208),i=n(53),s=r&&1/i(new r([,-0]))[1]==1/0?function(e){return new r(e)}:a;e.exports=s},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";(function(e,t){!(function(e,n){if(!e.setImmediate){var r,a,i,s,o,c=1,u={},l=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){v(e)})}:!(function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}})()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){v(e.data)},r=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(a=p.documentElement,r=function(e){var t=p.createElement("script");t.onreadystatechange=function(){v(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(v,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&v(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return u[c]=a,r(c),c++},d.clearImmediate=h}function h(e){delete u[e]}function f(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}function v(e){if(l)setTimeout(v,0,e);else{var t=u[e];if(t){l=!0;try{f(t)}finally{h(e),l=!1}}}}})("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(34),n(210))},function(e,t,n){"use strict";var r,a,i=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(a===clearTimeout)return clearTimeout(e);if((a===o||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{return a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}!(function(){try{r='function'==typeof setTimeout?setTimeout:s}catch(e){r=s}try{a='function'==typeof clearTimeout?clearTimeout:o}catch(e){a=o}})();var l,p=[],d=!1,h=-1;function f(){d&&l&&(d=!1,l.length?p=l.concat(p):h=-1,p.length&&v())}function v(){if(!d){var e=c(f);d=!0;for(var t=p.length;t;){for(l=p,p=[];++h<t;)l&&l[h].run();h=-1,t=p.length}l=null,d=!1,u(e)}}function y(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new y(e,t)),1!==p.length||d||c(v)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title='browser',i.browser=!0,i.env={},i.argv=[],i.version='',i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error('process.binding is not supported')},i.cwd=function(){return'/'},i.chdir=function(e){throw new Error('process.chdir is not supported')},i.umask=function(){return 0}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(212),t),a(n(213),t),a(n(218),t),a(n(219),t),a(n(220),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentType=void 0,(function(e){e.Any="*",e.Item="SF|Item",e.RootKey="SN|RootKey|NoSync",e.ItemsKey="SN|ItemsKey",e.EncryptedStorage="SN|EncryptedStorage",e.Privileges="SN|Privileges",e.Note="Note",e.Tag="Tag",e.SmartTag="SN|SmartTag",e.Component="SN|Component",e.Editor="SN|Editor",e.ActionsExtension="Extension",e.UserPrefs="SN|UserPreferences",e.HistorySession="SN|HistorySession",e.Theme="SN|Theme",e.ServerExtension="SF|Extension",e.FilesafeCredentials="SN|FileSafe|Credentials",e.FilesafeFileMetadata="SN|FileSafe|FileMetadata",e.FilesafeIntegration="SN|FileSafe|Integration",e.ExtensionRepo="SN|ExtensionRepo",e.Unknown="Unknown"})(t.ContentType||(t.ContentType={}))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.ContentDecoder=void 0;var n=(function(){function t(){v(this,t)}return y(t,[{key:"decode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;try{var r=n>0?t.substring(n):t,a=e.from(r,'base64').toString();return JSON.parse(a)}catch(e){return{}}}},{key:"encode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=JSON.stringify(t),a=e.from(r).toString('base64');return a.padStart(a.length+n,'0')}}]),t})();t.ContentDecoder=n}).call(this,n(214).Buffer)},function(e,t,n){"use strict";(function(e){var r=n(215),a=n(216),i=n(217);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return d(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?v(e,t,n,r):'string'==typeof t?h(e,t,n):y(e,t)}function l(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function p(e,t,n,r){return l(t),t<=0?o(e,t):void 0!==n?'string'==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function d(e,t){if(l(t),e=o(e,t<0?0:0|g(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t,n){if('string'==typeof n&&''!==n||(n='utf8'),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(t,n),a=(e=o(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}function f(e,t){var n=t.length<0?0:0|g(t.length);e=o(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function v(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(r||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t),e}function y(e,t){if(c.isBuffer(t)){var n=0|g(t.length);return 0===(e=o(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||(r=t.length)!=r?o(e,0):f(e,t);if('Buffer'===t.type&&i(t.data))return f(e,t.data)}var r;throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function g(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+' bytes');return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return G(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return $(e).length;default:if(r)return G(e).length;t=(''+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),n<=0)return'';if((n>>>=0)<=(t>>>=0))return'';for(e||(e='utf8');;)switch(e){case'hex':return T(this,t,n);case'utf8':case'utf-8':return R(this,t,n);case'ascii':return A(this,t,n);case'latin1':case'binary':return j(this,t,n);case'base64':return E(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return K(this,t,n);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,a){if(0===e.length)return-1;if('string'==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if('string'==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:x(e,t,n,r,a);if('number'==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):x(e,[t],n,r,a);throw new TypeError('val must be string, number or Buffer')}function x(e,t,n,r,a){var i,s=1,o=e.length,c=t.length;if(void 0!==r&&('ucs2'===(r=String(r).toLowerCase())||'ucs-2'===r||'utf16le'===r||'utf-16le'===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var l=-1;for(i=n;i<o;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>o&&(n=o-c),i=n;i>=0;i--){for(var p=!0,d=0;d<c;d++)if(u(e,i+d)!==u(t,d)){p=!1;break}if(p)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError('Invalid hex string');r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function P(e,t,n,r){return X(G(t,e.length-n),e,n,r)}function O(e,t,n,r){return X(Q(t),e,n,r)}function C(e,t,n,r){return O(e,t,n,r)}function D(e,t,n,r){return X($(t),e,n,r)}function _(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,c,u=e[a],l=null,p=u>239?4:u>223?3:u>191?2:1;if(a+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=p}return M(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:(function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}})(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return p(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('Arguments must be Buffers');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,a),a+=s.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var t=0;t<e;t+=2)w(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?'':0===arguments.length?R(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e='',n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString('hex',0,n).match(/.{2}/g).join(' '),this.length>n&&(e+=' ... ')),'<Buffer '+e+'>'},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError('out of range index');if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,s=n-t,o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),p=0;p<o;++p)if(u[p]!==l[p]){i=u[p],s=l[p];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r='utf8',n=this.length,t=0;else if(void 0===n&&'string'==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');t|=0,isFinite(n)?(n|=0,void 0===r&&(r='utf8')):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return S(this,e,t,n);case'utf8':case'utf-8':return P(this,e,t,n);case'ascii':return O(this,e,t,n);case'latin1':case'binary':return C(this,e,t,n);case'base64':return D(this,e,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return _(this,e,t,n);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var n='',r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function A(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function j(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function T(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a='',i=t;i<n;++i)a+=Y(e[i]);return a}function K(e,t,n){for(var r=e.slice(t,n),a='',i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function L(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError('Index out of range')}function U(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function V(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError('Index out of range');if(n<0)throw new RangeError('Index out of range')}function B(e,t,n,r,i){return i||V(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function W(e,t,n,r,i){return i||V(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var a=t-e;n=new c(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return W(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return W(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError('targetStart out of bounds');if(n<0||n>=this.length)throw new RangeError('sourceStart out of bounds');if(r<0)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if('string'==typeof e){if('string'==typeof t?(r=t,t=0,n=this.length):'string'==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!c.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError('Out of range index');if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),'number'==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:G(new c(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var H=/[^+\/0-9A-Za-z-_]/g;function z(e){if((e=q(e).replace(H,'')).length<2)return'';for(;e.length%4!=0;)e+='=';return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function Y(e){return e<16?'0'+e.toString(16):e.toString(16)}function G(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error('Invalid code point');if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function J(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}function $(e){return r.toByteArray(z(e))}function X(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(34))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],o=r[1],c=new i(l(e,s,o)),p=0,d=o>0?s-4:s;for(n=0;n<d;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=0,o=n-a;s<o;s+=16383)i.push(p(e,s,s+16383>o?o:s+16383));1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+'==')):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+'='));return i.join('')};for(var r=[],a=[],i='undefined'!=typeof Uint8Array?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',o=0,c=s.length;o<c;++o)r[o]=s[o],a[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){return 3*(t+n)/4-n}function p(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join('')}a['-'.charCodeAt(0)]=62,a['_'.charCodeAt(0)]=63},function(e,t,n){"use strict";t.read=function(e,t,n,r,a){var i,s,o=8*a-r-1,c=(1<<o)-1,u=c>>1,l=-7,p=n?a-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=o;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var s,o,c,u=8*i-a-1,l=(1<<u)-1,p=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(o=0,s=l):s+p>=1?(o=(t*c-1)*Math.pow(2,a),s+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+h]=255&o,h+=f,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*v}},function(e,t,n){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==r.call(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTag=void 0,(function(e){e.MfaInvalid="mfa-invalid",e.MfaRequired="mfa-required",e.RefreshTokenInvalid="invalid-refresh-token",e.RefreshTokenExpired="expired-refresh-token",e.AccessTokenExpired="expired-access-token",e.ParametersInvalid="invalid-parameters",e.RevokedSession="revoked-session",e.AuthInvalid="invalid-auth"})(t.ErrorTag||(t.ErrorTag={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(222),t),a(n(90),t),a(n(223),t),a(n(225),t),a(n(93),t),a(n(91),t),a(n(92),t),a(n(226),t),a(n(227),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Features=void 0;for(var a,i=n(19),s=n(91),o=n(92),c=n(93),u=n(90),l=[],p=function(e){var t=e.identifier,n=e.permission_name,r=e.content_type,a=e.area,l=e.flags,p=Object.values(c.PermissionName),d=Object.values(u.FeatureIdentifier),h=Object.values(i.ContentType),f=Object.values(s.ComponentArea),v=Object.values(o.ComponentFlag);if(!d.includes(t))throw Error("Invalid feature identifier ".concat(t));if(!p.includes(n))throw Error("Invalid permission name ".concat(n));if(r&&!h.includes(r))throw Error("Invalid feature content type ".concat(r));if(a&&!f.includes(a))throw Error("Invalid feature area ".concat(a));if(l&&l.some(function(e){return!v.includes(e)}))throw Error("Invalid feature flag ".concat(l))},d=S(r(n(224)).default);!(a=d()).done;){var h=a.value;p(h),l.push(h)}t.Features=l},function(e){e.exports=JSON.parse("[{\"name\":\"Midnight\",\"identifier\":\"org.standardnotes.theme-midnight\",\"permission_name\":\"theme:midnight\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Elegant utilitarianism.\",\"url\":\"#{url_prefix}/themes/midnight\",\"download_url\":\"https://github.com/standardnotes/midnight-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/midnight\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#086DD6\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#086DD6\"}},{\"name\":\"Futura\",\"identifier\":\"org.standardnotes.theme-futura\",\"permission_name\":\"theme:futura\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Calm and relaxed. Take some time off.\",\"url\":\"#{url_prefix}/themes/futura\",\"download_url\":\"https://github.com/standardnotes/futura-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/futura\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#fca429\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#fca429\"}},{\"name\":\"Solarized Dark\",\"identifier\":\"org.standardnotes.theme-solarized-dark\",\"permission_name\":\"theme:solarized-dark\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.3\",\"description\":\"The perfect theme for any time.\",\"url\":\"#{url_prefix}/themes/solarized-dark\",\"download_url\":\"https://github.com/standardnotes/solarized-dark-theme/archive/1.2.3.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/solarized-dark\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#2AA198\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#2AA198\"}},{\"name\":\"Autobiography\",\"identifier\":\"org.standardnotes.theme-autobiography\",\"permission_name\":\"theme:autobiography\",\"content_type\":\"SN|Theme\",\"version\":\"1.0.1\",\"description\":\"A theme for writers and readers.\",\"url\":\"#{url_prefix}/themes/autobiography\",\"download_url\":\"https://github.com/standardnotes/autobiography-theme/archive/1.0.1.zip\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg\",\"flags\":[\"New\"],\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#9D7441\",\"foreground_color\":\"#ECE4DB\",\"border_color\":\"#9D7441\"}},{\"name\":\"Focus\",\"identifier\":\"org.standardnotes.theme-focus\",\"permission_name\":\"theme:focused\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.5\",\"description\":\"For when you need to go in.\",\"url\":\"#{url_prefix}/themes/focus\",\"download_url\":\"https://github.com/standardnotes/focus-theme/archive/1.2.5.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/focused\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#a464c2\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#a464c2\"}},{\"identifier\":\"org.standardnotes.theme-titanium\",\"permission_name\":\"theme:titanium\",\"name\":\"Titanium\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Light on the eyes, heavy on the spirit.\",\"url\":\"#{url_prefix}/themes/titanium\",\"download_url\":\"https://github.com/standardnotes/titanium-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/titanium\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#6e2b9e\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#6e2b9e\"}},{\"identifier\":\"org.standardnotes.theme-dynamic\",\"name\":\"Dynamic\",\"permission_name\":\"theme:dynamic\",\"content_type\":\"SN|Theme\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.0.0\",\"description\":\"A smart theme that minimizes the tags and notes panels when they are not in use.\",\"url\":\"#{url_prefix}/themes/dynamic\",\"download_url\":\"https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/dynamic\"},{\"identifier\":\"org.standardnotes.theme-no-distraction\",\"name\":\"No Distraction\",\"content_type\":\"SN|Theme\",\"permission_name\":\"theme:no-distraction\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.2.2\",\"description\":\"A theme for focusing on your writing.\",\"url\":\"#{url_prefix}/themes/no-distraction\",\"download_url\":\"https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/no-distraction\",\"dock_icon\":{\"type\":\"svg\",\"source\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><path d=\\\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\\\"/></svg>\"}},{\"name\":\"Bold Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.bold-editor\",\"permission_name\":\"editor:bold\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.2.9\",\"description\":\"A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.\",\"url\":\"#{url_prefix}/components/bold-editor\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg\",\"download_url\":\"https://github.com/standardnotes/bold-editor/archive/1.2.9.zip\"},{\"name\":\"Plus Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.plus-editor\",\"permission_name\":\"editor:plus\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.5.0\",\"description\":\"From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.\",\"url\":\"#{url_prefix}/components/plus-editor\",\"download_url\":\"https://github.com/standardnotes/plus-editor/archive/1.5.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/plus-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg\"},{\"name\":\"Markdown Basic\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.simple-markdown-editor\",\"permission_name\":\"editor:markdown-basic\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A Markdown editor with dynamic split-pane preview.\",\"url\":\"#{url_prefix}/components/simple-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg\"},{\"name\":\"Markdown Pro\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.advanced-markdown-editor\",\"permission_name\":\"editor:markdown-pro\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.14\",\"description\":\"A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.\",\"url\":\"#{url_prefix}/components/advanced-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/advanced-markdown-editor/archive/1.3.14.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/advanced-markdown\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg\"},{\"name\":\"Markdown Minimist\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.minimal-markdown-editor\",\"permission_name\":\"editor:markdown-minimist\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F\",\"url\":\"#{url_prefix}/components/minimal-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/minimal-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg\"},{\"name\":\"Markdown Math\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.fancy-markdown-editor\",\"permission_name\":\"editor:markdown-math\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.4\",\"description\":\"A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.\",\"url\":\"#{url_prefix}/components/fancy-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/math-editor/archive/1.3.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/math-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg\"},{\"name\":\"Task Editor\",\"note_type\":\"task\",\"file_type\":\"md\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.simple-task-editor\",\"permission_name\":\"editor:task-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A great way to manage short-term and long-term to-do\\\"s. You can mark tasks as completed, change their order, and edit the text naturally in place.\",\"url\":\"#{url_prefix}/components/simple-task-editor\",\"download_url\":\"https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-task-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg\"},{\"name\":\"Code Editor\",\"note_type\":\"code\",\"file_type\":\"txt\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.code-editor\",\"permission_name\":\"editor:code-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.8\",\"description\":\"Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.\",\"url\":\"#{url_prefix}/components/code-editor\",\"download_url\":\"https://github.com/standardnotes/code-editor/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/code-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg\"},{\"name\":\"TokenVault\",\"note_type\":\"authentication\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.token-vault\",\"permission_name\":\"editor:token-vault\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"2.0.6\",\"description\":\"Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.\",\"url\":\"#{url_prefix}/components/token-vault\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/token-vault/archive/2.0.6.zip\",\"thumbnail_url\":\"https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png\",\"flags\":[\"New\"]},{\"name\":\"Secure Spreadsheets\",\"note_type\":\"spreadsheet\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.standard-sheets\",\"permission_name\":\"editor:sheets\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.\",\"url\":\"#{url_prefix}/components/standard-sheets\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/secure-spreadsheets/archive/1.4.0.zip\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png\"},{\"identifier\":\"org.standardnotes.file-safe\",\"name\":\"FileSafe\",\"permission_name\":\"component:filesafe\",\"content_type\":\"SN|Component\",\"area\":\"editor-stack\",\"version\":\"2.0.10\",\"description\":\"Encrypted attachments for your notes using your Dropbox, Google Drive, or WebDAV server. Limited to 50MB per file.\",\"url\":\"#{url_prefix}/components/filesafe\",\"download_url\":\"https://github.com/standardnotes/filesafe-client/archive/2.0.10.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/filesafe\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/FileSafe-banner.png\"},{\"identifier\":\"org.standardnotes.folders\",\"name\":\"Folders\",\"content_type\":\"SN|Component\",\"permission_name\":\"component:folders\",\"area\":\"tags-list\",\"version\":\"1.3.8\",\"description\":\"Create nested folders with easy drag and drop.\",\"url\":\"#{url_prefix}/components/folders\",\"download_url\":\"https://github.com/standardnotes/folders-component/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/folders\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/components/folders.jpg\"},{\"name\":\"2FA Manager\",\"identifier\":\"org.standardnotes.mfa-link\",\"permission_name\":\"component:2fa-manager\",\"content_type\":\"SN|Component\",\"description\":\"Configure two-factor authentication to add an extra level of security to your account.\",\"version\":\"1.2.4\",\"url\":\"#{url_prefix}/components/mfa-link\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/mfa-link/archive/1.2.4.zip\",\"area\":\"modal\",\"no_expire\":true,\"deletion_warning\":\"Deleting 2FA Manager will not disable 2FA from your account. To disable 2FA, first open 2FA Manager, then follow the prompts.\",\"deprecated\":true},{\"name\":\"\",\"identifier\":\"org.standardnotes.two-factor-auth\",\"permission_name\":\"server:two-factor-auth\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-unlimited\",\"permission_name\":\"server:note-history-unlimited\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-365\",\"permission_name\":\"server:note-history-365-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-30\",\"permission_name\":\"server:note-history-30-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-email-backup\",\"permission_name\":\"server:daily-email-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-dropbox-backup\",\"permission_name\":\"server:daily-dropbox-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-gdrive-backup\",\"permission_name\":\"server:daily-gdrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-onedrive-backup\",\"permission_name\":\"server:daily-onedrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-25-gb\",\"permission_name\":\"server:files-25-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-5-gb\",\"permission_name\":\"server:files-5-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Tag Nesting\",\"identifier\":\"org.standardnotes.tag-nesting\",\"permission_name\":\"app:tag-nesting\",\"description\":\"Create nested tags with easy drag and drop.\",\"version\":\"0.1.0\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files\",\"permission_name\":\"app:files\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"CloudLink\",\"identifier\":\"org.standardnotes.cloudlink\",\"permission_name\":\"component:cloud-link\",\"content_type\":\"SN|Component\",\"description\":\"Manage and install cloud backups, including Note History, Dropbox, Google Drive, OneDrive, and Daily Email Backups.\",\"version\":\"1.2.3\",\"url\":\"#{url_prefix}/components/cloudlink\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Listed Custom Domain\",\"identifier\":\"org.standardnotes.listed-custom-domain\",\"permission_name\":\"listed:custom-domain\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"Focus Mode\",\"identifier\":\"org.standardnotes.focus-mode\",\"permission_name\":\"app:focus-mode\"}]")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoteType=void 0,(function(e){e.Authentication="authentication",e.Code="code",e.Markdown="markdown",e.RichText="rich-text",e.Spreadsheet="spreadsheet",e.Task="task"})(t.NoteType||(t.NoteType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timingSafeEqual=void 0,t.timingSafeEqual=function(e,t){var n=String(e),r=String(t),a=n.length,i=0;a!==r.length&&(r=n,i=1);for(var s=0;s<a;s++)i|=n.charCodeAt(s)^r.charCodeAt(s);return 0===i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(232),t),a(n(233),t),a(n(234),t),a(n(235),t),a(n(236),t),a(n(237),t),a(n(238),t),a(n(239),t),a(n(240),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoleName=void 0,(function(e){e.BasicUser="BASIC_USER",e.CoreUser="CORE_USER",e.PlusUser="PLUS_USER",e.ProUser="PRO_USER"})(t.RoleName||(t.RoleName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionName=void 0,(function(e){e.CorePlan="CORE_PLAN",e.PlusPlan="PLUS_PLAN",e.ProPlan="PRO_PLAN"})(t.SubscriptionName||(t.SubscriptionName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(242),t),a(n(243),t),a(n(244),t),a(n(245),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmailBackupFrequency=void 0,(function(e){e.Daily="daily",e.Weekly="weekly"})(t.EmailBackupFrequency||(t.EmailBackupFrequency={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedBackupsEmailsOption||(t.MuteFailedBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedCloudBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedCloudBackupsEmailsOption||(t.MuteFailedCloudBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingName=void 0,(function(e){e.MfaSecret="MFA_SECRET",e.ExtensionKey="EXTENSION_KEY",e.EmailBackup="EMAIL_BACKUP",e.MuteFailedBackupsEmails="MUTE_FAILED_BACKUPS_EMAILS",e.MuteFailedCloudBackupsEmails="MUTE_FAILED_CLOUD_BACKUPS_EMAILS"})(t.SettingName||(t.SettingName={}))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"SnjsVersion",function(){return h}),n.d(t,"isRightVersionGreaterThanLeft",function(){return x}),n.d(t,"compareSemVersions",function(){return P}),n.d(t,"SNApplicationGroup",function(){return M}),n.d(t,"DeinitSource",function(){return C}),n.d(t,"KeyParamsOrigination",function(){return A.g}),n.d(t,"KeyRecoveryStrings",function(){return j.H}),n.d(t,"SessionStrings",function(){return j.R}),n.d(t,"SNApplication",function(){return ca}),n.d(t,"SNProtocolService",function(){return Gn}),n.d(t,"KeyMode",function(){return Bn}),n.d(t,"SNProtocolOperator001",function(){return An}),n.d(t,"SNProtocolOperator002",function(){return Fn}),n.d(t,"SNProtocolOperator003",function(){return Ln}),n.d(t,"SNProtocolOperator004",function(){return Wn}),n.d(t,"SNRootKey",function(){return Ve}),n.d(t,"SNRootKeyParams",function(){return A.h}),n.d(t,"DeviceInterface",function(){return ua}),n.d(t,"SNItem",function(){return T.d}),n.d(t,"ItemMutator",function(){return T.b}),n.d(t,"AppDataField",function(){return T.a}),n.d(t,"SNItemsKey",function(){return J}),n.d(t,"SNPredicate",function(){return H.a}),n.d(t,"SNNote",function(){return le}),n.d(t,"NoteMutator",function(){return pe}),n.d(t,"SNTag",function(){return oe}),n.d(t,"TagMutator",function(){return ce}),n.d(t,"SNSmartTag",function(){return et}),n.d(t,"SNActionsExtension",function(){return ie}),n.d(t,"ActionsExtensionMutator",function(){return se}),n.d(t,"Action",function(){return ae}),n.d(t,"SNTheme",function(){return B}),n.d(t,"ThemeMutator",function(){return W}),n.d(t,"SNComponent",function(){return N}),n.d(t,"ComponentAction",function(){return E}),n.d(t,"ComponentMutator",function(){return V}),n.d(t,"SNEditor",function(){return Ze}),n.d(t,"SNUserPrefs",function(){return z}),n.d(t,"UserPrefsMutator",function(){return G}),n.d(t,"PrefKey",function(){return U}),n.d(t,"MutationType",function(){return T.c}),n.d(t,"ComponentArea",function(){return L.ComponentArea}),n.d(t,"LiveItem",function(){return la}),n.d(t,"FeatureStatus",function(){return ur}),n.d(t,"SNComponentManager",function(){return an}),n.d(t,"HistoryEntry",function(){return Qn}),n.d(t,"PayloadManager",function(){return sn}),n.d(t,"ItemManager",function(){return _r}),n.d(t,"SNHttpService",function(){return jt}),n.d(t,"ChallengeService",function(){return na}),n.d(t,"PureService",function(){return R.a}),n.d(t,"ApplicationService",function(){return pa.a}),n.d(t,"SNStorageService",function(){return Ie}),n.d(t,"StoragePersistencePolicies",function(){return Oe}),n.d(t,"StorageEncryptionPolicies",function(){return Ce}),n.d(t,"StorageValueModes",function(){return De}),n.d(t,"ValueModesKeys",function(){return _e}),n.d(t,"Challenge",function(){return ye}),n.d(t,"ChallengeReason",function(){return ne}),n.d(t,"ChallengeResponse",function(){return be}),n.d(t,"ChallengeValidation",function(){return te}),n.d(t,"ChallengeValue",function(){return me}),n.d(t,"ChallengePrompt",function(){return ge}),n.d(t,"SNSyncService",function(){return ea}),n.d(t,"SyncSources",function(){return $r}),n.d(t,"SyncModes",function(){return Jr}),n.d(t,"SyncQueueStrategy",function(){return Qr}),n.d(t,"SNCredentialService",function(){return Qe}),n.d(t,"SyncResponse",function(){return Br}),n.d(t,"SyncResponseResolver",function(){return Vr}),n.d(t,"SyncOpStatus",function(){return fr}),n.d(t,"SortPayloadsByRecentAndContentPriority",function(){return Mr}),n.d(t,"SyncUpDownLimit",function(){return Wr}),n.d(t,"SNSessionManager",function(){return Ge}),n.d(t,"SessionEvent",function(){return ze}),n.d(t,"SNMigrationService",function(){return En}),n.d(t,"ButtonType",function(){return St}),n.d(t,"SNHistoryManager",function(){return nr}),n.d(t,"SNProtectionService",function(){return ir}),n.d(t,"SNSingletonManager",function(){return cn}),n.d(t,"SNApiService",function(){return Yt}),n.d(t,"addIfUnique",function(){return _.b}),n.d(t,"arrayByDifference",function(){return _.c}),n.d(t,"Copy",function(){return _.a}),n.d(t,"dateSorted",function(){return _.j}),n.d(t,"deepMerge",function(){return _.m}),n.d(t,"dictToArray",function(){return _.n}),n.d(t,"extendArray",function(){return _.o}),n.d(t,"filterFromArray",function(){return _.p}),n.d(t,"findInArray",function(){return _.q}),n.d(t,"getGlobalScope",function(){return _.r}),n.d(t,"greaterOfTwoDates",function(){return _.s}),n.d(t,"isNullOrUndefined",function(){return _.w}),n.d(t,"isSameDay",function(){return _.z}),n.d(t,"jsonParseEmbeddedKeys",function(){return _.E}),n.d(t,"naturalSort",function(){return _.G}),n.d(t,"omitInPlace",function(){return _.J}),n.d(t,"omitUndefinedCopy",function(){return _.K}),n.d(t,"removeFromArray",function(){return _.M}),n.d(t,"removeFromIndex",function(){return _.N}),n.d(t,"subtractFromArray",function(){return _.R}),n.d(t,"topLevelCompare",function(){return _.S}),n.d(t,"truncateHexString",function(){return _.T}),n.d(t,"uniqueArrayByKey",function(){return _.W}),n.d(t,"uniqCombineObjArrays",function(){return _.U}),n.d(t,"convertTimestampToMilliseconds",function(){return _.i}),n.d(t,"arraysEqual",function(){return _.e}),n.d(t,"isValidUrl",function(){return _.B}),n.d(t,"dateToLocalizedString",function(){return _.k}),n.d(t,"Uuid",function(){return I}),n.d(t,"EncryptionIntent",function(){return Re.b}),n.d(t,"isLocalStorageIntent",function(){return Re.f}),n.d(t,"isFileIntent",function(){return Re.e}),n.d(t,"isDecryptedIntent",function(){return Re.d}),n.d(t,"intentRequiresEncryption",function(){return Re.c}),n.d(t,"ContentTypeUsesRootKeyEncryption",function(){return Re.a}),n.d(t,"ContentType",function(){return F.a}),n.d(t,"displayStringForContentType",function(){return F.c}),n.d(t,"CreateItemFromPayload",function(){return nt}),n.d(t,"Uuids",function(){return Ke.b}),n.d(t,"FillItemContent",function(){return Ke.a}),n.d(t,"ApplicationEvent",function(){return At.a}),n.d(t,"Environment",function(){return he}),n.d(t,"Platform",function(){return fe}),n.d(t,"isEnvironmentWebOrDesktop",function(){return Se}),n.d(t,"isEnvironmentMobile",function(){return Pe}),n.d(t,"platformFromString",function(){return ke}),n.d(t,"environmentFromString",function(){return xe}),n.d(t,"SyncEvent",function(){return on.a}),n.d(t,"MutableCollection",function(){return mt}),n.d(t,"ImmutablePayloadCollection",function(){return bt}),n.d(t,"ItemCollection",function(){return gn}),n.d(t,"CollectionSort",function(){return dn}),n.d(t,"CreateMaxPayloadFromAnyObject",function(){return Ee.e}),n.d(t,"CreateSourcedPayloadFromObject",function(){return Ee.f}),n.d(t,"CreateIntentPayloadFromObject",function(){return Ee.d}),n.d(t,"CreateEncryptionParameters",function(){return Ee.c}),n.d(t,"PayloadByMerging",function(){return Ee.g}),n.d(t,"CopyPayload",function(){return Ee.b}),n.d(t,"PayloadSource",function(){return ht.a}),n.d(t,"isPayloadSourceRetrieved",function(){return ht.c}),n.d(t,"isPayloadSourceInternalChange",function(){return ht.b}),n.d(t,"DeltaOutOfSync",function(){return _t}),n.d(t,"ProtocolVersion",function(){return Q.a}),n.d(t,"PayloadFormat",function(){return ue.a}),n.d(t,"PurePayload",function(){return ft.a}),n.d(t,"PayloadField",function(){return Je.a}),n.d(t,"NotesDisplayCriteria",function(){return br}),n.d(t,"notesMatchingCriteria",function(){return wr}),n.d(t,"StorageKey",function(){return o}),n.d(t,"RawStorageKey",function(){return s}),n.d(t,"NonwrappedStorageKey",function(){return c}),n.d(t,"namespacedKey",function(){return O}),n.d(t,"BaseMigration",function(){return _n}),n.d(t,"ProtectionSessionDurations",function(){return ar}),n.d(t,"SNLog",function(){return we.a}),n.d(t,"Features",function(){return L.Features}),n.d(t,"FeatureIdentifier",function(){return L.FeatureIdentifier}),n.d(t,"RoleName",function(){return sr.RoleName}),n.d(t,"SettingName",function(){return pr.SettingName}),n.d(t,"Migration2_20_0",function(){return Pn}),n.d(t,"ApplicationStage",function(){return ve});var a={};n.r(a),n.d(a,"Migration2_0_0",function(){return kn}),n.d(a,"Migration2_0_15",function(){return xn}),n.d(a,"Migration2_7_0",function(){return Sn}),n.d(a,"Migration2_20_0",function(){return Pn});var i={};n.r(i),n.d(i,"StorageReader2_0_0",function(){return On}),n.d(i,"StorageReader1_0_0",function(){return vn});var s,o,c,h="2.20.3";function x(e,t){return-1===P(e,t)}function P(e,t){for(var n=e.split('.'),r=t.split('.'),a=0;a<r.length;a++){var i=Number(~~r[a]),s=Number(~~n[a]);if(i>s)return-1;if(i<s)return 1}return 0}function O(e,t){return e?"".concat(e,"-").concat(t):t}!(function(e){e.StorageObject="storage",e.DescriptorRecord="descriptors",e.SnjsVersion="snjs_version"})(s||(s={})),(function(e){e.RootKeyParams="ROOT_KEY_PARAMS",e.WrappedRootKey="WRAPPED_ROOT_KEY",e.RootKeyWrapperKeyParams="ROOT_KEY_WRAPPER_KEY_PARAMS",e.Session="session",e.User="user",e.ServerHost="server",e.LegacyUuid="uuid",e.LastSyncToken="syncToken",e.PaginationToken="cursorToken",e.BiometricsState="biometrics_state",e.MobilePasscodeTiming="passcode_timing",e.MobileBiometricsTiming="biometrics_timing",e.MobilePasscodeKeyboardType="passcodeKeyboardType",e.MobilePreferences="preferences",e.MobileScreenshotPrivacyEnabled="screenshotPrivacy_enabled",e.ProtectionExpirey="SessionExpiresAtKey",e.ProtectionSessionLength="SessionLengthKey",e.SessionHistoryPersistable="sessionHistory_persist",e.SessionHistoryRevisions="sessionHistory_revisions",e.SessionHistoryOptimize="sessionHistory_autoOptimize",e.KeyRecoveryUndecryptableItems="key_recovery_undecryptable",e.StorageEncryptionPolicy="storage_policy",e.WebSocketUrl="webSocket_url",e.UserRoles="user_roles",e.UserFeatures="user_features"})(o||(o={})),(function(e){e.MobileFirstRun="first_run"})(c||(c={}));var C,D={WebPasscodeParamsKey:'offlineParams',MobilePasscodeParamsKey:'pc_params',AllAccountKeyParamsKey:'auth_params',WebEncryptedStorageKey:'encryptedStorage',MobileWrappedRootKeyKey:'encrypted_account_keys',MobileBiometricsPrefs:'biometrics_prefs',AllMigrations:'migrations',MobileThemesCache:'ThemePreferencesKey',MobileLightTheme:'lightTheme',MobileDarkTheme:'darkTheme',MobileLastExportDate:'LastExportDateKey',MobileDoNotWarnUnsupportedEditors:'DoNotShowAgainUnsupportedEditorsKey',MobileOptionsState:'options',MobilePasscodeKeyboardType:'passcodeKeyboardType'},_=n(0);!(function(e){e[e.SignOut=1]="SignOut",e[e.Lock=2]="Lock",e[e.AppGroupUnload=3]="AppGroupUnload"})(C||(C={}));var E,R=n(10),I=(function(){function e(){v(this,e)}return y(e,null,[{key:"SetGenerators",value:function(e,t){this.syncUuidFunc=t,this.asyncUuidFunc=e}},{key:"canGenSync",value:function(){return!Object(_.w)(this.syncUuidFunc)}},{key:"GenerateUuid",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.syncUuidFunc){e.next=4;break}return e.abrupt("return",this.syncUuidFunc());case 4:return e.abrupt("return",this.asyncUuidFunc());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"GenerateUuidSynchronously",value:function(){return this.syncUuidFunc()}}]),e})(),M=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).deviceInterface=e,r.changeObservers=[],r.applications=[],r.onApplicationDeinit=function(e,t){var n=t!==C.AppGroupUnload;if(r.primaryApplication===e&&(r.primaryApplication=void 0),Object(_.M)(r.applications,e),t===C.SignOut){if(r.removeDescriptor(r.descriptorForApplication(e)),n){var a=r.getDescriptors();return 0===a.length?r.addNewApplication():r.loadApplicationForDescriptor(a[0])}}else if(t===C.Lock&&n){var i=r.descriptorForApplication(e);return r.loadApplicationForDescriptor(i)}},r}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.deviceInterface.deinit(),this.deviceInterface=void 0}},{key:"initialize",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.callback=e,r.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(s.DescriptorRecord));case 3:if(this.descriptorRecord=r.sent,this.descriptorRecord){r.next=7;break}return r.next=7,b.awrap(this.createDescriptorRecord());case 7:if(t=this.findPrimaryDescriptor()){r.next=10;break}throw Error('No primary application descriptor found. Ensure migrations have been run.');case 10:n=this.buildApplication(t),this.applications.push(n),this.setPrimaryApplication(n,!1);case 13:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createDescriptorRecord",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:t=g({},e='standardnotes',{identifier:e,label:'Main Application',primary:!0}),this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(t)),this.descriptorRecord=t,this.persistDescriptors();case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getApplications",value:function(){return this.applications}},{key:"getDescriptors",value:function(){return Object.values(this.descriptorRecord)}},{key:"findPrimaryDescriptor",value:function(){for(var e,t=S(this.getDescriptors());!(e=t()).done;){var n=e.value;if(n.primary)return n}}},{key:"addApplicationChangeObserver",value:function(e){var t=this;return this.changeObservers.push(e),this.primaryApplication&&e(),function(){Object(_.M)(t.changeObservers,e)}}},{key:"notifyObserversOfAppChange",value:function(){for(var e,t=S(this.changeObservers);!(e=t()).done;){(0,e.value)()}}},{key:"setPrimaryApplication",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=!(r.length>1&&void 0!==r[1])||r[1],this.primaryApplication!==e){a.next=3;break}return a.abrupt("return");case 3:if(this.applications.includes(e)){a.next=5;break}throw Error('Application must be inserted before attempting to switch to it');case 5:if(this.primaryApplication&&this.primaryApplication.deinit(C.AppGroupUnload),this.primaryApplication=e,n=this.descriptorForApplication(e),this.setDescriptorAsPrimary(n),this.notifyObserversOfAppChange(),!t){a.next=13;break}return a.next=13,b.awrap(this.persistDescriptors());case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setDescriptorAsPrimary",value:function(e){for(var t,n=S(this.getDescriptors());!(t=n()).done;){var r=t.value;r.primary=r===e}}},{key:"persistDescriptors",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(this.descriptorRecord));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"renameDescriptor",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e.label=t,n.next=3,b.awrap(this.persistDescriptors());case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"removeDescriptor",value:function(e){return delete this.descriptorRecord[e.identifier],this.persistDescriptors()}},{key:"descriptorForApplication",value:function(e){return this.descriptorRecord[e.identifier]}},{key:"addNewApplication",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(I.GenerateUuid());case 2:return t=i.sent,n=this.getDescriptors().length+1,r={identifier:t,label:e||"Application ".concat(n),primary:!1},a=this.buildApplication(r),this.applications.push(a),this.descriptorRecord[t]=r,i.next=10,b.awrap(this.setPrimaryApplication(a));case 10:return i.next=12,b.awrap(this.persistDescriptors());case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"applicationForDescriptor",value:function(e){return this.applications.find(function(t){return t.identifier===e.identifier})}},{key:"loadApplicationForDescriptor",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=this.applicationForDescriptor(e))||(t=this.buildApplication(e),this.applications.push(t)),n.next=4,b.awrap(this.setPrimaryApplication(t));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"buildApplication",value:function(e){var t=this.callback.applicationCreator(e,this.deviceInterface);return t.setOnDeinit(this.onApplicationDeinit),t}}]),n})(R.a),A=n(13),j=n(2),T=n(7),K=n(18),F=n(3),L=n(20);!(function(e){e.SetSize="set-size",e.StreamItems="stream-items",e.StreamContextItem="stream-context-item",e.SaveItems="save-items",e.SelectItem="select-item",e.AssociateItem="associate-item",e.DeassociateItem="deassociate-item",e.ClearSelection="clear-selection",e.CreateItem="create-item",e.CreateItems="create-items",e.DeleteItems="delete-items",e.SetComponentData="set-component-data",e.InstallLocalComponent="install-local-component",e.ToggleActivateComponent="toggle-activate-component",e.RequestPermissions="request-permissions",e.PresentConflictResolution="present-conflict-resolution",e.DuplicateItem="duplicate-item",e.ComponentRegistered="component-registered",e.ActivateThemes="themes",e.Reply="reply",e.SaveSuccess="save-success",e.SaveError="save-error",e.ThemesActivated="themes-activated",e.KeyDown="key-down",e.KeyUp="key-up",e.Click="click"})(E||(E={}));var U,N=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).permissions=[],r.componentData=r.payload.safeContent.componentData||{},Object(_.B)(r.payload.safeContent.hosted_url)?r.hosted_url=r.payload.safeContent.hosted_url:Object(_.B)(r.payload.safeContent.url)?r.hosted_url=r.payload.safeContent.url:Object(_.B)(r.payload.safeContent.legacy_url)&&(r.hosted_url=r.payload.safeContent.legacy_url),r.local_url=r.payload.safeContent.local_url,r.valid_until=new Date(r.payload.safeContent.valid_until||0),r.offlineOnly=r.payload.safeContent.offlineOnly,r.name=r.payload.safeContent.name,r.area=r.payload.safeContent.area,r.package_info=r.payload.safeContent.package_info||{},r.permissions=r.payload.safeContent.permissions||[],r.active=r.payload.safeContent.active,r.autoupdateDisabled=r.payload.safeContent.autoupdateDisabled,r.disassociatedItemIds=r.payload.safeContent.disassociatedItemIds||[],r.associatedItemIds=r.payload.safeContent.associatedItemIds||[],r.isMobileDefault=r.payload.safeContent.isMobileDefault,r.legacy_url=r.payload.safeContent.hosted_url?void 0:r.payload.safeContent.url,r}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"isEditor",value:function(){return this.area===L.ComponentArea.Editor}},{key:"isTheme",value:function(){return this.content_type===F.a.Theme||this.area===L.ComponentArea.Themes}},{key:"isDefaultEditor",value:function(){return!0===this.getAppDomainValue(T.a.DefaultEditor)}},{key:"getLastSize",value:function(){return this.getAppDomainValue(T.a.LastSize)}},{key:"acceptsThemes",value:function(){var e;return null===(e=this.payload.safeContent.package_info)||void 0===e?void 0:e.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return void 0!=(this.hosted_url||this.legacy_url)}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['active','disassociatedItemIds','associatedItemIds'].concat(p(f(n.prototype),"contentKeysToIgnoreWhenCheckingEquality",this).call(this))}},{key:"isAssociative",value:function(){return n.associativeAreas().includes(this.area)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e)}},{key:"isExpired",get:function(){return this.valid_until.getTime()>0&&this.valid_until<=new Date}},{key:"identifier",get:function(){return this.package_info.identifier}},{key:"isDeprecated",get:function(){var e,t=null!==(e=this.package_info.flags)&&void 0!==e?e:[];return(t=t.map(function(e){return e.toLowerCase()})).includes(L.ComponentFlag.Deprecated)}}],[{key:"associativeAreas",value:function(){return[L.ComponentArea.Editor]}}]),n})(T.d),V=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"associateWithItem",value:function(e){var t=this.typedContent.associatedItemIds||[];Object(_.b)(t,e),this.typedContent.associatedItemIds=t}},{key:"disassociateWithItem",value:function(e){var t=this.typedContent.disassociatedItemIds||[];Object(_.b)(t,e),this.typedContent.disassociatedItemIds=t}},{key:"removeAssociatedItemId",value:function(e){Object(_.M)(this.typedContent.associatedItemIds||[],e)}},{key:"removeDisassociatedItemId",value:function(e){Object(_.M)(this.typedContent.disassociatedItemIds||[],e)}},{key:"setLastSize",value:function(e){this.setAppDataItem(T.a.LastSize,e)}},{key:"typedContent",get:function(){return this.content}},{key:"active",set:function(e){this.typedContent.active=e}},{key:"isMobileDefault",set:function(e){this.typedContent.isMobileDefault=e}},{key:"defaultEditor",set:function(e){this.setAppDataItem(T.a.DefaultEditor,e)}},{key:"componentData",set:function(e){this.typedContent.componentData=e}},{key:"package_info",set:function(e){this.typedContent.package_info=e}},{key:"local_url",set:function(e){this.typedContent.local_url=e}},{key:"hosted_url",set:function(e){this.typedContent.hosted_url=e}},{key:"valid_until",set:function(e){this.typedContent.valid_until=e}},{key:"permissions",set:function(e){this.typedContent.permissions=e}}]),n})(T.b),B=(function(e){d(n,N);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).area=L.ComponentArea.Themes,e}return y(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"getMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDomainValue(T.a.NotAvailableOnMobile)}},{key:"isMobileActive",value:function(){return this.getAppDomainValue(T.a.MobileActive)}}]),n})(),W=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setMobileRules",value:function(e){this.setAppDataItem(T.a.MobileRules,e)}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem(T.a.NotAvailableOnMobile,e)}},{key:"setMobileActive",value:function(e){this.setAppDataItem(T.a.MobileActive,e)}},{key:"local_url",set:function(e){this.content.local_url=e}}]),n})(T.b),H=n(21);!(function(e){e.TagsPanelWidth="tagsPanelWidth",e.NotesPanelWidth="notesPanelWidth",e.EditorWidth="editorWidth",e.EditorLeft="editorLeft",e.EditorMonospaceEnabled="monospaceFont",e.EditorSpellcheck="spellcheck",e.EditorResizersEnabled="marginResizersEnabled",e.SortNotesBy="sortBy",e.SortNotesReverse="sortReverse",e.NotesShowArchived="showArchived",e.NotesShowTrashed="showTrashed",e.NotesHideProtected="hideProtected",e.NotesHidePinned="hidePinned",e.NotesHideNotePreview="hideNotePreview",e.NotesHideDate="hideDate",e.NotesHideTags="hideTags"})(U||(U={}));var z=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getPref",value:function(e){return this.getAppDomainValue(e)}},{key:"isSingleton",get:function(){return!0}},{key:"singletonPredicate",get:function(){return n.singletonPredicate}}]),n})(T.d);z.singletonPredicate=new H.a('content_type','=',F.a.UserPrefs);var q,Y,G=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setPref",value:function(e,t){this.setAppDataItem(e,t)}}]),n})(T.b),Q=n(6),J=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"keyVersion",get:function(){return this.payload.safeContent.version}},{key:"isItemsKey",get:function(){return!0}},{key:"isDefault",get:function(){return this.payload.safeContent.isDefault}},{key:"itemsKey",get:function(){return this.payload.safeContent.itemsKey}},{key:"dataAuthenticationKey",get:function(){if(this.keyVersion===Q.a.V004)throw'Attempting to access legacy data authentication key.';return this.payload.safeContent.dataAuthenticationKey}}]),n})(T.d),$=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"isDefault",set:function(e){this.content.isDefault=e}}]),n})(T.b),X=n(47),Z=n.n(X);!(function(e){e.Encrypted="encrypted",e.Decrypted="decrypted"})(q||(q={})),(function(e){e.Get="get",e.Render="render",e.Show="show",e.Post="post",e.Nested="nested"})(Y||(Y={}));var ee=Number.MIN_SAFE_INTEGER;var te,ne,re,ae=function e(t){var n,r,a;v(this,e),this.id=((ee+=1)===Number.MAX_SAFE_INTEGER&&(ee=Number.MIN_SAFE_INTEGER),ee),Z()(this,t),this.running=null!==(n=t.running)&&void 0!==n&&n,this.error=null!==(r=t.error)&&void 0!==r&&r,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted)),this.subactions=null===(a=t.subactions)||void 0===a?void 0:a.map(function(t){return new e(t)})},ie=(function(e){d(n,N);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).actions=[],r.description=e.safeContent.description,r.url=e.safeContent.hosted_url||e.safeContent.url,r.supported_types=e.safeContent.supported_types,r.deprecation=e.safeContent.deprecation,e.safeContent.actions&&(r.actions=e.safeContent.actions.map(function(e){return new ae(e)})),r}return y(n,[{key:"actionsWithContextForItem",value:function(e){return this.actions.filter(function(t){return t.context===e.content_type||'Item'===t.context})}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}}]),n})(),se=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"description",set:function(e){this.content.description=e}},{key:"supported_types",set:function(e){this.content.supported_types=e}},{key:"actions",set:function(e){this.content.actions=e}},{key:"deprecation",set:function(e){this.content.deprecation=e}}]),n})(T.b),oe=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).title=r.payload.safeContent.title,r}return y(n,[{key:"noteReferences",get:function(){return this.payload.safeReferences.filter(function(e){return e.content_type===F.a.Note})}},{key:"noteCount",get:function(){return this.noteReferences.length}},{key:"isSmartTag",get:function(){return this.content_type===F.a.SmartTag}},{key:"isSystemSmartTag",get:function(){return this.payload.safeContent.isSystemTag}},{key:"isAllTag",get:function(){return this.payload.safeContent.isAllTag}},{key:"isTrashTag",get:function(){return this.payload.safeContent.isTrashTag}},{key:"isArchiveTag",get:function(){return this.payload.safeContent.isArchiveTag}},{key:"parentId",get:function(){var e=this.payload.safeContent.references.find(function(e){return e.content_type===F.a.Tag});return null===e||void 0===e?void 0:e.uuid}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title?1:-1}).map(function(e){return'#'+e.title}).join(' ')}}]),n})(T.d),ce=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"makeChildOf",value:function(e){var t=this.typedContent.references.filter(function(e){return e.content_type!==F.a.Tag});t.push({content_type:F.a.Tag,uuid:e.uuid}),this.typedContent.references=t}},{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}}]),n})(T.b),ue=n(12),le=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).text='',r.hidePreview=!1,r.title=r.payload.safeContent.title,r.text=r.payload.safeContent.text,r.preview_plain=r.payload.safeContent.preview_plain,r.preview_html=r.payload.safeContent.preview_html,r.hidePreview=r.payload.safeContent.hidePreview,e.format===ue.a.DecryptedBareObject&&(r.prefersPlainEditor=r.getAppDomainValue(T.a.PrefersPlainEditor)),Object(_.w)(r.payload.safeContent.mobilePrefersPlainEditor)||(r.mobilePrefersPlainEditor=r.payload.safeContent.mobilePrefersPlainEditor),r}return y(n,[{key:"safeText",value:function(){return this.text||''}},{key:"safeTitle",value:function(){return this.title||''}}]),n})(T.d),pe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}},{key:"text",set:function(e){this.typedContent.text=e}},{key:"hidePreview",set:function(e){this.typedContent.hidePreview=e}},{key:"preview_plain",set:function(e){this.typedContent.preview_plain=e}},{key:"preview_html",set:function(e){this.typedContent.preview_html=e}},{key:"prefersPlainEditor",set:function(e){this.setAppDataItem(T.a.PrefersPlainEditor,e)}}]),n})(T.b);function de(e,t){switch(e.content_type){case F.a.Note:return new pe(e,t);case F.a.Tag:return new ce(e,t);case F.a.Component:return new V(e,t);case F.a.ActionsExtension:return new se(e,t);case F.a.ItemsKey:return new $(e,t);case F.a.UserPrefs:return new G(e,t);case F.a.Theme:return new W(e,t);default:return new T.b(e,t)}}!(function(e){e[e.None=0]="None",e[e.LocalPasscode=1]="LocalPasscode",e[e.AccountPassword=2]="AccountPassword",e[e.Biometric=3]="Biometric",e[e.ProtectionSessionDuration=4]="ProtectionSessionDuration"})(te||(te={})),(function(e){e[e.ApplicationUnlock=1]="ApplicationUnlock",e[e.ResaveRootKey=2]="ResaveRootKey",e[e.ProtocolUpgrade=3]="ProtocolUpgrade",e[e.Migration=4]="Migration",e[e.Custom=5]="Custom",e[e.AccessProtectedNote=6]="AccessProtectedNote",e[e.ImportFile=7]="ImportFile",e[e.AddPasscode=8]="AddPasscode",e[e.RemovePasscode=9]="RemovePasscode",e[e.ChangePasscode=10]="ChangePasscode",e[e.ChangeAutolockInterval=11]="ChangeAutolockInterval",e[e.CreateDecryptedBackupWithProtectedItems=12]="CreateDecryptedBackupWithProtectedItems",e[e.RevokeSession=13]="RevokeSession",e[e.AccessCloudLink=14]="AccessCloudLink",e[e.DecryptEncryptedFile=15]="DecryptEncryptedFile",e[e.ExportBackup=16]="ExportBackup",e[e.DisableBiometrics=17]="DisableBiometrics",e[e.UnprotectNote=18]="UnprotectNote",e[e.SearchProtectedNotesText=19]="SearchProtectedNotesText",e[e.SelectProtectedNote=20]="SelectProtectedNote",e[e.DisableMfa=21]="DisableMfa"})(ne||(ne={})),(function(e){e.Alphanumeric="default",e.Numeric="numeric"})(re||(re={}));var he,fe,ve,ye=(function(){function e(t,n,r,a,i){v(this,e),this.prompts=t,this.reason=n,this.cancelable=r,this._heading=a,this._subheading=i,this.id=Math.random(),Object.freeze(this)}return y(e,[{key:"hasPromptForValidationType",value:function(e){for(var t,n=S(this.prompts);!(t=n()).done;){if(t.value.validation===e)return!0}return!1}},{key:"modalTitle",get:function(){switch(this.reason){case ne.Migration:return j.w.Migration;default:return j.w.Generic}}},{key:"heading",get:function(){if(this._heading)return this._heading;switch(this.reason){case ne.ApplicationUnlock:return j.x.UnlockApplication;case ne.Migration:return j.x.EnterLocalPasscode;case ne.ResaveRootKey:return j.x.EnterPasscodeForRootResave;case ne.ProtocolUpgrade:return j.x.EnterCredentialsForProtocolUpgrade;case ne.AccessProtectedNote:return j.x.NoteAccess;case ne.ImportFile:return j.x.ImportFile;case ne.AddPasscode:return j.x.AddPasscode;case ne.RemovePasscode:return j.x.RemovePasscode;case ne.ChangePasscode:return j.x.ChangePasscode;case ne.ChangeAutolockInterval:return j.x.ChangeAutolockInterval;case ne.CreateDecryptedBackupWithProtectedItems:return j.x.EnterCredentialsForDecryptedBackupDownload;case ne.RevokeSession:return j.x.RevokeSession;case ne.AccessCloudLink:return j.x.AccessCloudLink;case ne.DecryptEncryptedFile:return j.x.DecryptEncryptedFile;case ne.ExportBackup:return j.x.ExportBackup;case ne.DisableBiometrics:return j.x.DisableBiometrics;case ne.UnprotectNote:return j.x.UnprotectNote;case ne.SearchProtectedNotesText:return j.x.SearchProtectedNotesText;case ne.SelectProtectedNote:return j.x.SelectProtectedNote;case ne.DisableMfa:return j.x.DisableMfa;case ne.Custom:return'';default:return Object(_.f)(this.reason)}}},{key:"subheading",get:function(){if(this._subheading)return this._subheading;switch(this.reason){case ne.Migration:return j.x.EnterPasscodeForMigration;default:return}}}]),e})(),ge=function e(t,n,r){v(this,e);var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;switch(this.validation=t,this.secureTextEntry=a,this.keyboardType=i,this.initialValue=s,this.id=Math.random(),this.validation){case te.AccountPassword:this.title=null!==n&&void 0!==n?n:j.M.AccountPassword,this.placeholder=null!==r&&void 0!==r?r:j.M.AccountPassword,this.validates=!0;break;case te.LocalPasscode:this.title=null!==n&&void 0!==n?n:j.M.LocalPasscode,this.placeholder=null!==r&&void 0!==r?r:j.M.LocalPasscode,this.validates=!0;break;case te.Biometric:this.title=null!==n&&void 0!==n?n:j.M.Biometrics,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.ProtectionSessionDuration:this.title=null!==n&&void 0!==n?n:j.M.RememberFor,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.None:this.title=null!==n&&void 0!==n?n:'',this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!1;break;default:Object(_.f)(this.validation)}Object.freeze(this)},me=function e(t,n){v(this,e),this.prompt=t,this.value=n,Object.freeze(this)},be=(function(){function e(t,n,r){v(this,e),this.challenge=t,this.values=n,this.artifacts=r,Object.freeze(this)}return y(e,[{key:"getValueForType",value:function(e){var t=this.values.find(function(t){return t.prompt.validation===e});if(Object(_.w)(t))throw Error('Could not find value for validation type '+e);return t}},{key:"getDefaultValue",value:function(){if(this.values.length>1)throw Error('Attempting to retrieve default response value when more than one value exists');return this.values[0]}}]),e})(),we=n(16);function ke(e){return{'mac-web':fe.MacWeb,'mac-desktop':fe.MacDesktop,'linux-web':fe.LinuxWeb,'linux-desktop':fe.LinuxDesktop,'windows-web':fe.WindowsWeb,'windows-desktop':fe.WindowsDesktop,ios:fe.Ios,android:fe.Android}[e]}function xe(e){return{web:he.Web,desktop:he.Desktop,mobile:he.Mobile}[e]}function Se(e){return e===he.Web||e===he.Desktop}function Pe(e){return e===he.Mobile}!(function(e){e[e.Web=1]="Web",e[e.Desktop=2]="Desktop",e[e.Mobile=3]="Mobile"})(he||(he={})),(function(e){e[e.Ios=1]="Ios",e[e.Android=2]="Android",e[e.MacWeb=3]="MacWeb",e[e.MacDesktop=4]="MacDesktop",e[e.WindowsWeb=5]="WindowsWeb",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.LinuxWeb=7]="LinuxWeb",e[e.LinuxDesktop=8]="LinuxDesktop"})(fe||(fe={})),(function(e){e[e.PreparingForLaunch_0=0]="PreparingForLaunch_0",e[e.ReadyForLaunch_05=.5]="ReadyForLaunch_05",e[e.StorageDecrypted_09=.9]="StorageDecrypted_09",e[e.Launched_10=1]="Launched_10",e[e.LoadingDatabase_11=1.1]="LoadingDatabase_11",e[e.LoadedDatabase_12=1.2]="LoadedDatabase_12",e[e.FullSyncCompleted_13=1.3]="FullSyncCompleted_13",e[e.SignedIn_30=3]="SignedIn_30"})(ve||(ve={}));var Oe,Ce,De,_e,Ee=n(1),Re=n(8);!(function(e){e[e.Default=1]="Default",e[e.Ephemeral=2]="Ephemeral"})(Oe||(Oe={})),(function(e){e[e.Default=1]="Default",e[e.Disabled=2]="Disabled"})(Ce||(Ce={})),(function(e){e[e.Default=1]="Default",e[e.Nonwrapped=2]="Nonwrapped"})(De||(De={})),(function(e){e.Wrapped="wrapped",e.Unwrapped="unwrapped",e.Nonwrapped="nonwrapped"})(_e||(_e={}));var Ie=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).alertService=r,s.identifier=a,s.environment=i,s.storagePersistable=!1,s.needsPersist=!1,s.deviceInterface=e,s.setPersistencePolicy(Oe.Default),s.setEncryptionPolicy(Ce.Default,!1),s}return y(n,[{key:"deinit",value:function(){this.deviceInterface=void 0,this.encryptionDelegate=void 0,this.storagePersistable=!1,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:if(e!==ve.Launched_10){r.next=7;break}this.storagePersistable=!0,this.needsPersist&&this.persistValuesToDisk(),r.next=12;break;case 7:if(e!==ve.StorageDecrypted_09){r.next=12;break}return r.next=10,b.awrap(this.getValue(o.StorageEncryptionPolicy));case 10:(t=r.sent)&&this.setEncryptionPolicy(t,!1);case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setPersistencePolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.persistencePolicy=e,this.persistencePolicy!==Oe.Ephemeral){t.next=6;break}return t.next=4,b.awrap(this.deviceInterface.removeAllRawStorageValues());case 4:return t.next=6,b.awrap(this.clearAllPayloads());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setEncryptionPolicy",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],e!==Ce.Disabled||this.environment===he.Mobile){r.next=3;break}throw Error('Disabling storage encryption is only available on mobile.');case 3:if(this.encryptionPolicy=e,!t){r.next=7;break}return r.next=7,b.awrap(this.setValue(o.StorageEncryptionPolicy,e));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.persistencePolicy===Oe.Ephemeral}},{key:"initializeFromDisk",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getRawStorageValue(this.getPersistenceKey()));case 2:e=n.sent,t=e?JSON.parse(e):void 0,this.setInitialValues(t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){e||(e=this.defaultValuesObject()),e[_e.Unwrapped]||(e[_e.Unwrapped]={}),this.values=e}},{key:"isStorageWrapped",value:function(){var e=this.values[_e.Wrapped];return!Object(_.w)(e)&&Object.keys(e).length>0}},{key:"canDecryptWithKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.values[_e.Wrapped],r.next=3,b.awrap(this.decryptWrappedValue(t,e));case 3:return n=r.sent,r.abrupt("return",!n.errorDecrypting);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"decryptWrappedValue",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!==e&&void 0!==e&&e.content_type){a.next=2;break}throw Error('Attempting to decrypt nonexistent wrapped value');case 2:return n=Object(Ee.e)(e,{content_type:F.a.EncryptedStorage}),a.next=5,b.awrap(this.encryptionDelegate.payloadByDecryptingPayload(n,t));case 5:return r=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptStorage",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.values[_e.Wrapped],n.next=3,b.awrap(this.decryptWrappedValue(e));case 3:if(!(t=n.sent).errorDecrypting){n.next=6;break}throw we.a.error(Error('Unable to decrypt storage.'));case 6:this.values[_e.Unwrapped]=Object(_.a)(t.contentObject);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistValuesToDisk",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.storagePersistable){t.next=3;break}return this.needsPersist=!0,t.abrupt("return");case 3:if(this.persistencePolicy!==Oe.Ephemeral){t.next=5;break}return t.abrupt("return");case 5:return this.needsPersist=!1,t.next=8,b.awrap(this.immediatelyPersistValuesToDisk());case 8:e=t.sent,this.values[_e.Wrapped]=e[_e.Wrapped];case 10:case"end":return t.stop()}},null,this,null,Promise)}},{key:"immediatelyPersistValuesToDisk",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(e.generatePersistableValues());case 2:return n=r.sent,r.next=5,b.awrap(null===(t=e.deviceInterface)||void 0===t?void 0:t.setRawStorageValue(e.getPersistenceKey(),JSON.stringify(n)));case 5:return r.abrupt("return",n);case 6:case"end":return r.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generatePersistableValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=w({},this.values),n=t[_e.Unwrapped],i.t0=Object(Ee.e),i.next=5,b.awrap(I.GenerateUuid());case 5:return i.t1=i.sent,i.t2=n,i.t3=F.a.EncryptedStorage,i.t4={uuid:i.t1,content:i.t2,content_type:i.t3},r=(0,i.t0)(i.t4),i.next=12,b.awrap(null===(e=this.encryptionDelegate)||void 0===e?void 0:e.payloadByEncryptingPayload(r,Re.b.LocalStoragePreferEncrypted));case 12:return(a=i.sent)&&(t[_e.Wrapped]=a.ejected(),t[_e.Unwrapped]=void 0),i.abrupt("return",t);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=r.length>2&&void 0!==r[2]?r[2]:De.Default,this.values){a.next=3;break}throw Error("Attempting to set storage key ".concat(e," before loading local storage."));case 3:return this.values[this.domainKeyForMode(n)][e]=t,a.abrupt("return",this.persistValuesToDisk());case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De.Default,n=arguments.length>2?arguments[2]:void 0;if(!this.values)throw Error("Attempting to get storage key ".concat(e," before loading local storage."));if(!this.values[this.domainKeyForMode(t)])throw Error("Storage domain mode not available ".concat(t," for key ").concat(e));var r=this.values[this.domainKeyForMode(t)][e];return Object(_.w)(r)?n:r}},{key:"removeValue",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:De.Default,this.values){a.next=3;break}throw Error("Attempting to remove storage key ".concat(e," before loading local storage."));case 3:if(null===(n=this.values[this.domainKeyForMode(t)])||void 0===n||!n[e]){a.next=7;break}return delete n[e],a.abrupt("return",this.persistValuesToDisk());case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.encryptionPolicy}},{key:"getPersistenceKey",value:function(){return O(this.identifier,s.StorageObject)}},{key:"defaultValuesObject",value:function(e,t,r){return n.defaultValuesObject(e,t,r)}},{key:"domainKeyForMode",value:function(e){if(e===De.Default)return _e.Unwrapped;if(e===De.Nonwrapped)return _e.Nonwrapped;throw Error('Invalid mode')}},{key:"clearValues",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,b.awrap(this.immediatelyPersistValuesToDisk());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAllRawPayloads",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads(this.identifier));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"savePayload",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.savePayloads([e]));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"savePayloads",value:function(e){var t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.persistencePolicy!==Oe.Ephemeral){o.next=2;break}return o.abrupt("return");case 2:t=[],n=S(e);case 4:if((r=n()).done){o.next=19;break}if(!(a=r.value).discardable){o.next=11;break}return o.next=9,b.awrap(this.deletePayloadWithId(a.uuid));case 9:o.next=17;break;case 11:if(a.uuid){o.next=13;break}throw Error('Attempting to persist payload with no uuid');case 13:return o.next=15,b.awrap(this.encryptionDelegate.payloadByEncryptingPayload(a,this.encryptionPolicy===Ce.Default?Re.b.LocalStoragePreferEncrypted:Re.b.LocalStorageDecrypted));case 15:i=o.sent,t.push(i.ejected());case 17:o.next=4;break;case 19:return o.abrupt("return",this.executeCriticalFunction(function(){var e;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null===(e=s.deviceInterface)||void 0===e?void 0:e.saveRawDatabasePayloads(t,s.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 20:case"end":return o.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(e);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(this.deletePayloadWithId(r.uuid));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deletePayloadWithId",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.deviceInterface.removeRawDatabasePayloadWithId(e,t.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"clearAllPayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.deviceInterface.removeAllRawDatabasePayloads(e.identifier));case 1:case"end":return t.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"clearAllData",value:function(){var e=this;return this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.clearValues());case 2:return t.next=4,b.awrap(e.clearAllPayloads());case 4:return t.next=6,b.awrap(e.deviceInterface.removeRawStorageValue(O(e.identifier,s.SnjsVersion)));case 6:return t.next=8,b.awrap(e.deviceInterface.removeRawStorageValue(e.getPersistenceKey()));case 8:case"end":return t.stop()}},null,null,null,Promise)})}}],[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return g(e={},_e.Wrapped,t),g(e,_e.Unwrapped,n),g(e,_e.Nonwrapped,r),e}}]),n})(R.a),Me=(function(){function e(){v(this,e)}return y(e,null,[{key:"FromRawStorageValue",value:function(e){if(e.jwt)return new Ae(e.jwt);var t=e;return new je(t.accessToken,t.accessExpiration,t.refreshToken,t.refreshExpiration)}}]),e})(),Ae=(function(e){d(n,Me);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).jwt=e,r}return y(n,[{key:"canExpire",value:function(){return!1}},{key:"authorizationValue",get:function(){return this.jwt}}]),n})(),je=(function(e){d(n,Me);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).accessToken=e,s.accessExpiration=r,s.refreshToken=a,s.refreshExpiration=i,s}return y(n,[{key:"getExpireAt",value:function(){return this.accessExpiration||0}},{key:"canExpire",value:function(){return!0}},{key:"isExpired",value:function(){return this.getExpireAt()<Date.now()}},{key:"authorizationValue",get:function(){return this.accessToken}}],[{key:"FromApiResponse",value:function(e){var t=e.data.session.access_token,r=e.data.session.refresh_token;return new n(t,e.data.session.access_expiration,r,e.data.session.refresh_expiration)}}]),n})(),Te=n(15),Ke=n(11),Fe=n(67);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this,e)).keyParams=r,a}return y(n,[{key:"compare",value:function(e){if(this.keyVersion!==e.keyVersion)return!1;var t=!(!this.serverPassword||!e.serverPassword);return Object(Fe.timingSafeEqual)(this.masterKey,e.masterKey)&&(!t||Object(Fe.timingSafeEqual)(this.serverPassword,e.serverPassword))}},{key:"persistableValueWhenWrapping",value:function(){var e=this.getKeychainValue();return e.keyParams=this.keyParams.getPortableValue(),e}},{key:"getKeychainValue",value:function(){var e={version:this.keyVersion};return this.masterKey&&(e.masterKey=this.masterKey),this.dataAuthenticationKey&&(e.dataAuthenticationKey=this.dataAuthenticationKey),e}},{key:"typedContent",get:function(){return this.safeContent}},{key:"keyVersion",get:function(){if(!this.payload.safeContent.version)throw'Attempting to create key without version.';return this.payload.safeContent.version}},{key:"isRootKey",get:function(){return!0}},{key:"itemsKey",get:function(){return this.masterKey}},{key:"masterKey",get:function(){return this.payload.safeContent.masterKey}},{key:"serverPassword",get:function(){return this.payload.safeContent.serverPassword}},{key:"dataAuthenticationKey",get:function(){return this.payload.safeContent.dataAuthenticationKey}}],[{key:"Create",value:function(e,t){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t){s.next=4;break}return s.next=3,b.awrap(I.GenerateUuid());case 3:t=s.sent;case 4:if(e.version||(e.dataAuthenticationKey?e.version=Q.a.V002:e.version=Q.a.V001),r=Object(Ee.e)({uuid:t,content_type:F.a.RootKey,content:Object(Ke.a)(e)}),a=e.keyParams){s.next=9;break}throw Error('Attempting to create root key without key params');case 9:return i=a instanceof A.h?a:new A.h(a),s.abrupt("return",new n(r,i));case 11:case"end":return s.stop()}},null,null,null,Promise)}},{key:"ExpandedCopy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=e.typedContent,a.next=3,b.awrap(this.Create(Ue(Ue({},n),{},{keyParams:t||n.keyParams})));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(T.d);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){He(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ze,qe=function(e){return e.trim().toLowerCase()};!(function(e){e.Restored="SessionRestored",e.Revoked="SessionRevoked"})(ze||(ze={}));var Ye,Ge=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).storageService=e,c.apiService=r,c.alertService=a,c.protocolService=i,c.challengeService=s,c.webSocketsService=o,c.isSessionRenewChallengePresented=!1,r.setInvalidSessionObserver(function(e){e?c.notifyEvent(ze.Revoked):c.reauthenticateInvalidSession()}),c}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.alertService=void 0,this.challengeService=void 0,this.webSocketsService=void 0,this.user=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.storageService.getValue(o.User));case 2:if(this.user=r.sent,this.user){r.next=8;break}return r.next=6,b.awrap(this.storageService.getValue(o.LegacyUuid));case 6:(e=r.sent)&&(this.user={uuid:e,email:e});case 8:return r.next=10,b.awrap(this.storageService.getValue(o.Session));case 10:if(!(t=r.sent)){r.next=16;break}return n=Me.FromRawStorageValue(t),r.next=15,b.awrap(this.setSession(n,!1));case 15:this.webSocketsService.startWebSocketConnection(n.authorizationValue);case 16:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=!(n.length>1&&void 0!==n[1])||n[1],r.next=3,b.awrap(this.apiService.setSession(e,t));case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"online",value:function(){return!this.offline()}},{key:"offline",value:function(){return Object(_.w)(this.apiService.getSession())}},{key:"getUser",value:function(){return this.user}},{key:"getSession",value:function(){return this.apiService.getSession()}},{key:"signOut",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.user=void 0,!(e=this.apiService.getSession())||!e.canExpire()){t.next=6;break}return t.next=5,b.awrap(this.apiService.signOut());case 5:this.webSocketsService.closeWebSocketConnection();case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isSignedIn",value:function(){return void 0!=this.getUser()}},{key:"isSignedIntoFirstPartyServer",value:function(){return this.isSignedIn()&&!this.apiService.isThirdPartyHostUsed()}},{key:"reauthenticateInvalidSession",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=!(i.length>0&&void 0!==i[0])||i[0],n=i.length>1?i[1]:void 0,!this.isSessionRenewChallengePresented){s.next=4;break}return s.abrupt("return");case 4:return this.isSessionRenewChallengePresented=!0,r=new ye([new ge(te.None,void 0,j.R.EmailInputPlaceholder,!1),new ge(te.None,void 0,j.R.PasswordInputPlaceholder)],ne.Custom,t,j.R.EnterEmailAndPassword,j.R.RecoverSession(null===(e=this.getUser())||void 0===e?void 0:e.email)),s.abrupt("return",new Promise(function(e){a.challengeService.addChallengeObserver(r,{onCancel:function(){a.isSessionRenewChallengePresented=!1},onComplete:function(){a.isSessionRenewChallengePresented=!1},onNonvalidatedSubmit:function(t){var i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=t.values[0].value,s=t.values[1].value,u.next=4,b.awrap(a.protocolService.getAccountKeyParams());case 4:return o=u.sent,u.next=7,b.awrap(a.signIn(i,s,!1,a.storageService.isEphemeralSession(),null===o||void 0===o?void 0:o.version));case 7:(c=u.sent).response.error?(a.challengeService.setValidationStatusForChallenge(r,t.values[1],!1),null===n||void 0===n||n(c.response)):(e(),a.challengeService.completeChallenge(r),a.notifyEvent(ze.Restored),a.alertService.alert(j.R.SessionRestored));case 9:case"end":return u.stop()}},null,null,null,Promise)}}),a.challengeService.promptForChallengeResponse(r)}));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSubscription",value:function(){return this.apiService.getSubscription(this.user.uuid)}},{key:"promptForMfaValue",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=new ye([new ge(te.None,j.M.Mfa,j.R.MfaInputPlaceholder,!1,re.Numeric)],ne.Custom,!0,j.R.EnterMfa),n.next=3,b.awrap(this.challengeService.promptForChallengeResponse(e));case 3:if(!(t=n.sent)){n.next=7;break}return this.challengeService.completeChallenge(e),n.abrupt("return",t.values[0].value);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"register",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(t.length<8)){u.next=2;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.G(8))});case 2:return u.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(r=u.sent,a=r.wrappingKey,!r.canceled){u.next=9;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.P.PasscodeRequired,Te.b.LocalValidationError)});case 9:return e=qe(e),u.next=12,b.awrap(this.protocolService.createRootKey(e,t,A.g.Registration));case 12:return i=u.sent,s=i.serverPassword,o=i.keyParams,u.next=17,b.awrap(this.apiService.register(e,s,o,n));case 17:if((c=u.sent).error||!c.data){u.next=21;break}return u.next=21,b.awrap(this.handleSuccessAuthResponse(c,i,a));case 21:return u.abrupt("return",{response:c,rootKey:i});case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"retrieveKeyParams",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.apiService.getAccountKeyParams(e,t,n));case 2:if(!(r=c.sent).error&&!Object(_.w)(r.data)){c.next=17;break}if(!n){c.next=7;break}return c.next=7,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 7:if(null===(a=r.error)||void 0===a||null===(i=a.payload)||void 0===i||!i.mfa_key){c.next=16;break}return c.next=10,b.awrap(this.promptForMfaValue());case 10:if(s=c.sent){c.next=13;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa)});case 13:return c.abrupt("return",this.retrieveKeyParams(e,r.error.payload.mfa_key,s));case 16:return c.abrupt("return",{response:r});case 17:if((o=Object(A.f)(r,e))&&o.version){c.next=20;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 20:return c.abrupt("return",{keyParams:o,response:r,mfaKeyPath:t,mfaCode:n});case 21:case"end":return c.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=o.length>2&&void 0!==o[2]&&o[2],r=o.length>3&&void 0!==o[3]&&o[3],a=o.length>4?o[4]:void 0,c.next=5,b.awrap(this.performSignIn(e,t,n,r,a));case 5:if(!(i=c.sent).response.error||i.response.error.status===Te.b.LocalValidationError||i.response.error.status===Te.b.CanceledMfa){c.next=15;break}if((s=qe(e))===e){c.next=12;break}return c.abrupt("return",this.performSignIn(s,t,n,r,a));case 12:return c.abrupt("return",i);case 13:c.next=16;break;case 15:return c.abrupt("return",i);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"performSignIn",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=arguments;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return n=p.length>2&&void 0!==p[2]&&p[2],r=p.length>3&&void 0!==p[3]&&p[3],a=p.length>4?p[4]:void 0,d.next=5,b.awrap(this.retrieveKeyParams(e));case 5:if(!(i=d.sent).response.error){d.next=8;break}return d.abrupt("return",{response:i.response});case 8:if(s=i.keyParams,this.protocolService.supportedVersions().includes(s.version)){d.next=15;break}if(!this.protocolService.isVersionNewerThanLibraryVersion(s.version)){d.next=14;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.X)});case 14:return d.abrupt("return",{response:this.apiService.createErrorResponse(j.A)});case 15:if(!this.protocolService.isProtocolVersionOutdated(s.version)){d.next=25;break}if(o=this.protocolService.costMinimumForVersion(s.version),!(s.content002.pw_cost<o)){d.next=19;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.E)});case 19:return c=j.L,d.next=22,b.awrap(this.alertService.confirm(c,j.K,j.J));case 22:if(d.sent){d.next=25;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 25:if(this.protocolService.platformSupportsKeyDerivation(s)){d.next=27;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.W)});case 27:if(n&&(a=this.protocolService.getLatestVersion()),Object(_.w)(a)){d.next=31;break}if(Object(Q.d)(s.version,a)){d.next=31;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.T(s.version,a))});case 31:return d.next=33,b.awrap(this.protocolService.computeRootKey(t,s));case 33:return u=d.sent,d.next=36,b.awrap(this.bypassChecksAndSignInWithRootKey(e,u,i.mfaKeyPath,i.mfaCode,r));case 36:return l=d.sent,d.abrupt("return",{response:l});case 38:case"end":return d.stop()}},null,this,null,Promise)}},{key:"bypassChecksAndSignInWithRootKey",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return a=d.length>4&&void 0!==d[4]&&d[4],h.next=3,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 3:if(i=h.sent,s=i.wrappingKey,!i.canceled){h.next=8;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.PasscodeRequired,Te.b.LocalValidationError));case 8:return h.next=10,b.awrap(this.apiService.signIn(e,t.serverPassword,n,r,a));case 10:if((o=h.sent).error||!o.data){h.next=20;break}return h.next=14,b.awrap(Ve.ExpandedCopy(t,o.data.key_params));case 14:return c=h.sent,h.next=17,b.awrap(this.handleSuccessAuthResponse(o,c,s));case 17:return h.abrupt("return",o);case 20:if(null===(u=o.error)||void 0===u||null===(l=u.payload)||void 0===l||!l.mfa_key){h.next=32;break}if(!r){h.next=24;break}return h.next=24,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 24:return h.next=26,b.awrap(this.promptForMfaValue());case 26:if(p=h.sent){h.next=29;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa));case 29:return h.abrupt("return",this.bypassChecksAndSignInWithRootKey(e,t,o.error.payload.mfa_key,p));case 32:return h.abrupt("return",o);case 33:case"end":return h.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.user.uuid,r.next=3,b.awrap(this.apiService.changeCredentials({userUuid:t,currentServerPassword:e.currentServerPassword,newServerPassword:e.newRootKey.serverPassword,newKeyParams:e.newRootKey.keyParams,newEmail:e.newEmail}));case 3:return n=r.sent,r.abrupt("return",this.processChangeCredentialsResponse(n,e.newRootKey,e.wrappingKey));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getSessionsList());case 2:if(!(e=t.sent).error&&!Object(_.w)(e.data)){t.next=5;break}return t.abrupt("return",e);case 5:return e.data=e.data.map(function(e){return We(We({},e),{},{updated_at:new Date(e.updated_at)})}).sort(function(e,t){return e.updated_at<t.updated_at?1:-1}),t.abrupt("return",e);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeSession",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.deleteSession(e));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.getSessionsList());case 2:if(void 0==(e=s.sent).error&&void 0!=e.data){s.next=5;break}throw new Error(null!==(t=null===(n=e.error)||void 0===n?void 0:n.message)&&void 0!==t?t:j.m);case 5:return r=e.data,a=r.filter(function(e){return!e.current}),s.next=9,b.awrap(Promise.all(a.map(function(e){return i.revokeSession(e.uuid)})));case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"processChangeCredentialsResponse",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.error||!e.data){a.next=3;break}return a.next=3,b.awrap(this.handleSuccessAuthResponse(e,t,n));case 3:return a.abrupt("return",{response:e,keyParams:null===(r=e.data)||void 0===r?void 0:r.key_params});case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleSuccessAuthResponse",value:function(e,t,n){var r,a,i,s;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.protocolService.setRootKey(t,n));case 2:return r=e.data,a=r.user,this.user=a,c.next=7,b.awrap(this.storageService.setValue(o.User,a));case 7:if(this.apiService.setHost(this.apiService.getHost()),!r.token){c.next=15;break}return i=new Ae(r.token),c.next=12,b.awrap(this.setSession(i));case 12:this.webSocketsService.startWebSocketConnection(i.authorizationValue),c.next=20;break;case 15:if(!r.session){c.next=20;break}return s=je.FromApiResponse(e),c.next=19,b.awrap(this.setSession(s));case 19:this.webSocketsService.startWebSocketConnection(s.authorizationValue);case 20:case"end":return c.stop()}},null,this,null,Promise)}}]),n})(R.a);!(function(e){e.SignedInOrRegistered="SignedInOrRegistered"})(Ye||(Ye={}));var Qe=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).sessionManager=e,l.syncService=r,l.storageService=a,l.itemManager=i,l.protocolService=s,l.alertService=o,l.challengeService=c,l.protectionService=u,l.signingIn=!1,l.registering=!1,l}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.sessionManager=void 0,this.syncService=void 0,this.storageService=void 0,this.itemManager=void 0,this.protocolService=void 0,this.alertService=void 0,this.challengeService=void 0,this.protectionService=void 0}},{key:"register",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=!(i.length>3&&void 0!==i[3])||i[3],!this.protocolService.hasAccount()){s.next=4;break}throw Error('Tried to register when an account already exists.');case 4:if(!this.registering){s.next=6;break}throw Error('Already registering.');case 6:return this.registering=!0,s.prev=7,this.lockSyncing(),s.next=11,b.awrap(this.sessionManager.register(e,t,n));case 11:if((a=s.sent).response.error){s.next=32;break}return this.syncService.resetSyncState(),s.next=16,b.awrap(this.storageService.setPersistencePolicy(n?Oe.Ephemeral:Oe.Default));case 16:if(!r){s.next=21;break}return s.next=19,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 19:s.next=24;break;case 21:return this.itemManager.removeAllItemsFromMemory(),s.next=24,b.awrap(this.clearDatabase());case 24:return s.next=26,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 26:return this.unlockSyncing(),s.next=29,b.awrap(this.syncService.downloadFirstSync(300));case 29:this.protocolService.decryptErroredItems(),s.next=33;break;case 32:this.unlockSyncing();case 33:return s.abrupt("return",a.response);case 34:return s.prev=34,this.registering=!1,s.finish(34);case 37:case"end":return s.stop()}},null,this,[[7,,34,37]],Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o,c=this,u=arguments;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],r=u.length>3&&void 0!==u[3]&&u[3],a=!(u.length>4&&void 0!==u[4])||u[4],i=u.length>5&&void 0!==u[5]&&u[5],!this.protocolService.hasAccount()){l.next=6;break}throw Error('Tried to sign in when an account already exists.');case 6:if(!this.signingIn){l.next=8;break}throw Error('Already signing in.');case 8:return this.signingIn=!0,l.prev=9,this.lockSyncing(),l.next=13,b.awrap(this.sessionManager.signIn(e,t,n,r));case 13:if((s=l.sent).response.error){l.next=37;break}return this.syncService.resetSyncState(),l.next=18,b.awrap(this.storageService.setPersistencePolicy(r?Oe.Ephemeral:Oe.Default));case 18:if(!a){l.next=23;break}return l.next=21,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 21:l.next=26;break;case 23:return this.itemManager.removeAllItemsFromMemory(),l.next=26,b.awrap(this.clearDatabase());case 26:return l.next=28,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 28:if(this.unlockSyncing(),o=this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0,awaitAll:i}).then(function(){i||c.protocolService.decryptErroredItems()}),!i){l.next=35;break}return l.next=33,b.awrap(o);case 33:return l.next=35,b.awrap(this.protocolService.decryptErroredItems());case 35:l.next=38;break;case 37:this.unlockSyncing();case 38:return l.abrupt("return",s.response);case 39:return l.prev=39,this.signingIn=!1,l.finish(39);case 42:case"end":return l.stop()}},null,this,[[9,,39,42]],Promise)}},{key:"correctiveSignIn",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.lockSyncing(),n.next=3,b.awrap(this.sessionManager.bypassChecksAndSignInWithRootKey(e.keyParams.identifier,e));case 3:if((t=n.sent).error){n.next=10;break}return n.next=7,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 7:this.unlockSyncing(),this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0}),this.protocolService.decryptErroredItems();case 10:return this.unlockSyncing(),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.performCredentialsChange(e));case 2:return(t=n.sent).error&&this.alertService.alert(t.error.message),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.sessionManager.signOut());case 2:return e.next=4,b.awrap(this.protocolService.clearLocalKeyState());case 4:return e.next=6,b.awrap(this.storageService.clearAllData());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performProtocolUpgrade",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return e=this.protocolService.hasPasscode(),t=this.protocolService.hasAccount(),n=[],e&&n.push(new ge(te.LocalPasscode,void 0,j.x.LocalPasscodePlaceholder)),t&&n.push(new ge(te.AccountPassword,void 0,j.x.AccountPasswordPlaceholder)),r=new ye(n,ne.ProtocolUpgrade,!0),p.next=8,b.awrap(this.challengeService.promptForChallengeResponse(r));case 8:if(a=p.sent){p.next=11;break}return p.abrupt("return",{canceled:!0});case 11:return p.next=13,b.awrap(this.alertService.blockingDialog(j.z,j.Y));case 13:if(i=p.sent,p.prev=14,e&&(o=a.getValueForType(te.LocalPasscode),s=o.value),!t){p.next=24;break}return c=a.getValueForType(te.AccountPassword),u=c.value,p.next=21,b.awrap(this.changeCredentials({currentPassword:u,newPassword:u,passcode:s,origination:A.g.ProtocolUpgrade,validateNewPasswordStrength:!1}));case 21:if(null===(l=p.sent)||void 0===l||!l.error){p.next=24;break}return p.abrupt("return",{error:l.error});case 24:if(!e){p.next=29;break}return p.next=27,b.awrap(this.removePasscodeWithoutWarning());case 27:return p.next=29,b.awrap(this.setPasscodeWithoutWarning(s,A.g.ProtocolUpgrade));case 29:return p.abrupt("return",{success:!0});case 32:return p.prev=32,p.t0=p.catch(14),p.abrupt("return",{error:p.t0});case 35:return p.prev=35,i(),p.finish(35);case 38:case"end":return p.stop()}},null,this,[[14,32,35,38]],Promise)}},{key:"addPasscode",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e.length<1)){n.next=2;break}return n.abrupt("return",!1);case 2:return n.next=4,b.awrap(this.protectionService.authorizeAddingPasscode());case 4:if(n.sent){n.next=6;break}return n.abrupt("return",!1);case 6:return n.next=8,b.awrap(this.alertService.blockingDialog(j.z,j.Q));case 8:return t=n.sent,n.prev=9,n.next=12,b.awrap(this.setPasscodeWithoutWarning(e,A.g.PasscodeCreate));case 12:return n.abrupt("return",!0);case 13:return n.prev=13,t(),n.finish(13);case 16:case"end":return n.stop()}},null,this,[[9,,13,16]],Promise)}},{key:"removePasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeRemovingPasscode());case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,b.awrap(this.alertService.blockingDialog(j.z,j.O));case 6:return e=t.sent,t.prev=7,t.next=10,b.awrap(this.removePasscodeWithoutWarning());case 10:return t.abrupt("return",!0);case 11:return t.prev=11,e(),t.finish(11);case 14:case"end":return t.stop()}},null,this,[[7,,11,14]],Promise)}},{key:"changePasscode",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:A.g.PasscodeChange,!(e.length<1)){a.next=3;break}return a.abrupt("return",!1);case 3:return a.next=5,b.awrap(this.protectionService.authorizeChangingPasscode());case 5:if(a.sent){a.next=7;break}return a.abrupt("return",!1);case 7:return a.next=9,b.awrap(this.alertService.blockingDialog(j.z,t===A.g.ProtocolUpgrade?j.N.UpgradingPasscode:j.v));case 9:return n=a.sent,a.prev=10,a.next=13,b.awrap(this.removePasscodeWithoutWarning());case 13:return a.next=15,b.awrap(this.setPasscodeWithoutWarning(e,t));case 15:return a.abrupt("return",!0);case 16:return a.prev=16,n(),a.finish(16);case 19:case"end":return a.stop()}},null,this,[[10,,16,19]],Promise)}},{key:"setPasscodeWithoutWarning",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(I.GenerateUuid());case 2:return n=a.sent,a.next=5,b.awrap(this.protocolService.createRootKey(n,e,t));case 5:return r=a.sent,a.next=8,b.awrap(this.protocolService.setNewRootKeyWrapper(r));case 8:return a.next=10,b.awrap(this.rewriteItemsKeys());case 10:return a.next=12,b.awrap(this.syncService.sync());case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"removePasscodeWithoutWarning",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protocolService.removeRootKeyWrapper());case 2:return e.next=4,b.awrap(this.rewriteItemsKeys());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"rewriteItemsKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.itemsKeys(),t=e.map(function(e){return e.payloadRepresentation()}),n.next=4,b.awrap(this.storageService.deletePayloads(t));case 4:return n.next=6,b.awrap(this.syncService.persistPayloads(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"clearDatabase",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performCredentialsChange",value:function(e){var t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(this.challengeService.getWrappingKeyIfApplicable(e.passcode));case 2:if(t=u.sent,n=t.wrappingKey,!t.canceled){u.next=7;break}return u.abrupt("return",{error:Error(j.y.PasscodeRequired)});case 7:if(void 0===e.newPassword||!e.validateNewPasswordStrength){u.next=10;break}if(!(e.newPassword.length<8)){u.next=10;break}return u.abrupt("return",{error:Error(Object(j.G)(8))});case 10:return u.next=12,b.awrap(this.protocolService.validateAccountPassword(e.currentPassword));case 12:if(u.sent.valid){u.next=15;break}return u.abrupt("return",{error:Error(j.D)});case 15:return r=this.sessionManager.getUser(),a=r.email,u.next=19,b.awrap(this.recomputeRootKeysForCredentialChange({currentPassword:e.currentPassword,currentEmail:a,origination:e.origination,newEmail:e.newEmail,newPassword:e.newPassword}));case 19:return i=u.sent,this.lockSyncing(),u.next=23,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.currentRootKey.serverPassword,newRootKey:i.newRootKey,wrappingKey:n,newEmail:e.newEmail}));case 23:if(s=u.sent,this.unlockSyncing(),s.response.error){u.next=45;break}return u.next=28,b.awrap(this.protocolService.createNewItemsKeyWithRollback());case 28:return o=u.sent,u.next=31,b.awrap(this.protocolService.reencryptItemsKeys());case 31:return u.next=33,b.awrap(this.syncService.sync({awaitAll:!0}));case 33:if(c=this.protocolService.getDefaultItemsKey(),!c.neverSynced){u.next=45;break}return u.next=38,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.newRootKey.serverPassword,newRootKey:i.currentRootKey,wrappingKey:n}));case 38:return u.next=40,b.awrap(this.protocolService.reencryptItemsKeys());case 40:return u.next=42,b.awrap(o());case 42:return u.next=44,b.awrap(this.syncService.sync({awaitAll:!0}));case 44:return u.abrupt("return",{error:Error(j.y.Failed)});case 45:return u.abrupt("return",s.response);case 46:case"end":return u.stop()}},null,this,null,Promise)}},{key:"recomputeRootKeysForCredentialChange",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=b,i.t1=this.protocolService,i.t2=e.currentPassword,i.next=5,b.awrap(this.protocolService.getRootKeyParams());case 5:return i.t3=i.sent,i.t4=i.t1.computeRootKey.call(i.t1,i.t2,i.t3),i.next=9,i.t0.awrap.call(i.t0,i.t4);case 9:return r=i.sent,i.next=12,b.awrap(this.protocolService.createRootKey(null!==(t=e.newEmail)&&void 0!==t?t:e.currentEmail,null!==(n=e.newPassword)&&void 0!==n?n:e.currentPassword,e.origination));case 12:return a=i.sent,i.abrupt("return",{currentRootKey:r,newRootKey:a});case 14:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),Je=n(5),$e=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",get:function(){return this.payload.safeContent.migratedToUserSetting}},{key:"migratedToOfflineEntitlements",get:function(){return this.payload.safeContent.migratedToOfflineEntitlements}},{key:"onlineUrl",get:function(){return this.payload.safeContent.url}},{key:"offlineFeaturesUrl",get:function(){return this.payload.safeContent.offlineFeaturesUrl}},{key:"offlineKey",get:function(){return this.payload.safeContent.offlineKey}}]),n})(T.d),Xe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",set:function(e){this.content.migratedToUserSetting=e}},{key:"migratedToOfflineEntitlements",set:function(e){this.content.migratedToOfflineEntitlements=e}},{key:"offlineFeaturesUrl",set:function(e){this.content.offlineFeaturesUrl=e}},{key:"offlineKey",set:function(e){this.content.offlineKey=e}}]),n})(T.b),Ze=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).notes=[],r.data={},r.url=e.safeContent.url,r.name=e.safeContent.name,r.data=e.safeContent.data||{},r.isDefault=e.safeContent.default,r.systemEditor=e.safeContent.systemEditor,r}return n})(T.d),et=(function(e){d(n,oe);var t=k(n);function n(e){var r;return v(this,n),r=t.call(this,e),e.safeContent.predicate&&(r.predicate=H.a.FromJson(e.safeContent.predicate)),r}return n})(),tt=(g(r={},F.a.Note,le),g(r,F.a.Tag,oe),g(r,F.a.ItemsKey,J),g(r,F.a.SmartTag,et),g(r,F.a.ActionsExtension,ie),g(r,F.a.Editor,Ze),g(r,F.a.Theme,B),g(r,F.a.Component,N),g(r,F.a.UserPrefs,z),g(r,F.a.ExtensionRepo,$e),r);function nt(e){return new(tt[e.content_type]||T.d)(e)}var rt=n(27),at=n.n(rt);function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){ot(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ct=g({},F.a.Note,function(e,t,n){var r=n.all(F.a.Component).map(function(e){return nt(e)}).filter(function(e){return e.area===L.ComponentArea.Editor}).find(function(t){return t.isExplicitlyEnabledForItem(e.uuid)});if(r){var a=new V(r,T.c.Internal);return a.associateWithItem(t.uuid),[a.getResult()]}});function ut(e,t,n,r){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(!e.errorDecrypting){p.next=2;break}throw Error('Attempting to duplicate errored payload');case 2:return a=[],p.next=5,b.awrap(I.GenerateUuid());case 5:return p.t0=p.sent,p.t1=new Date,p.t2=e.uuid,(i={uuid:p.t0,dirty:!0,dirtiedDate:p.t1,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:p.t2}).content=st(st({},e.safeContent),r),n&&(i.content.conflict_of=e.uuid),s=Object(Ee.b)(e,i),a.push(s),o=t.elementsReferencingElement(e),c=pt(o,[{uuid:s.uuid,content_type:s.content_type}]),Object(_.o)(a,c),(u=ct[e.content_type])&&(l=u(e,s,t))&&Object(_.o)(a,l),p.abrupt("return",a);case 19:case"end":return p.stop()}},null,null,null,Promise)}function lt(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=[],u.t0=Object(Ee.b),u.t1=e,u.next=5,b.awrap(I.GenerateUuid());case 5:return u.t2=u.sent,u.t3=new Date,u.t4=e.uuid,u.t5={uuid:u.t2,dirty:!0,dirtiedDate:u.t3,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:u.t4},r=(0,u.t0)(u.t1,u.t5),n.push(r),a=t.elementsReferencingElement(e),i=pt(a,[{uuid:r.uuid,content_type:r.content_type}],[e.uuid]),Object(_.o)(n,i),e.content_type===F.a.ItemsKey&&(s=t.all().filter(function(t){return t.items_key_id===e.uuid}),(o=s.map(function(e){return Object(Ee.b)(e,{items_key_id:r.uuid})})).length>0&&Object(_.o)(n,o)),c=Object(Ee.b)(e,{deleted:!0,dirty:!1,content:void 0}),n.push(c),u.abrupt("return",n);case 18:case"end":return u.stop()}},null,null,null,Promise)}function pt(e,t,n){for(var r,a=[],i=S(e);!(r=i()).done;){var s=r.value,o=s.contentObject.references.slice();if(t)for(var c,u=S(t);!(c=u()).done;){var l=c.value;o.push(l)}if(n)for(var p,d=S(n);!(p=d()).done;){var h=p.value;at()(o,{uuid:h})}var f=Object(Ee.b)(s,{dirty:!0,dirtiedDate:new Date,content:st(st({},s.safeContent),{},{references:o})});a.push(f)}return a}function dt(e,t){var n=nt(e),r=nt(t);return n.isItemContentEqualWith(r)}var ht=n(4),ft=n(32),vt=(function(){function e(t,n,r,a){v(this,e),this.baseCollection=t,this.applyCollection=n,this.relatedCollectionSet=r,this.historyMap=a}return y(e,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:throw'Must override PayloadDelta.resultingCollection.';case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"findBasePayload",value:function(e){return this.baseCollection.find(e)}},{key:"findRelatedPayload",value:function(e,t){var n,r=null===(n=this.relatedCollectionSet)||void 0===n?void 0:n.collectionForSource(t);return null===r||void 0===r?void 0:r.find(e)}}]),e})(),yt=function(e){return e[0]},gt=(function(){function e(){v(this,e),this.directMap={},this.inverseMap={}}return y(e,[{key:"makeCopy",value:function(){var t=new e;return t.directMap=w({},this.directMap),t.inverseMap=w({},this.inverseMap),t}},{key:"getDirectRelationships",value:function(e){return this.directMap[e]||[]}},{key:"getInverseRelationships",value:function(e){return this.inverseMap[e]||[]}},{key:"establishRelationship",value:function(e,t){this.establishDirectRelationship(e,t),this.establishInverseRelationship(e,t)}},{key:"deestablishRelationship",value:function(e,t){this.deestablishDirectRelationship(e,t),this.deestablishInverseRelationship(e,t)}},{key:"setAllRelationships",value:function(e,t){var n=this.directMap[e]||[];this.directMap[e]=t;for(var r,a=S(n);!(r=a()).done;){var i=r.value;this.deestablishInverseRelationship(e,i)}for(var s,o=S(t);!(s=o()).done;){var c=s.value;this.establishInverseRelationship(e,c)}}},{key:"removeFromMap",value:function(e){for(var t,n=S(this.directMap[e]||[]);!(t=n()).done;){var r=t.value;Object(_.M)(this.inverseMap[r]||[],e)}delete this.directMap[e];for(var a,i=S(this.inverseMap[e]||[]);!(a=i()).done;){var s=a.value;Object(_.M)(this.directMap[s]||[],e)}delete this.inverseMap[e]}},{key:"establishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.b)(n,t),this.directMap[e]=n}},{key:"establishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.b)(n,e),this.inverseMap[t]=n}},{key:"deestablishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.M)(n,t),this.directMap[e]=n}},{key:"deestablishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.M)(n,e),this.inverseMap[t]=n}}]),e})(),mt=(function(){function e(){v(this,e);var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.map={},this.typedMap={},this.dirtyIndex=new Set,this.invalidsIndex=new Set,this.nondeletedIndex=new Set,t?(this.map=n,this.typedMap=r,this.referenceMap=a,this.conflictMap=i):(this.referenceMap=new gt,this.conflictMap=new gt)}return y(e,[{key:"uuids",value:function(){return Object.keys(this.map)}},{key:"all",value:function(e){var t=this;if(e){if(Array.isArray(e)){for(var n,r=[],a=S(e);!(n=a()).done;){var i=n.value;Object(_.o)(r,this.typedMap[i]||[])}return r}var s;return(null===(s=this.typedMap[e])||void 0===s?void 0:s.slice())||[]}return Object.keys(this.map).map(function(e){return t.map[e]})}},{key:"find",value:function(e){return this.map[e]}},{key:"dirtyElements",value:function(){var e=Array.from(this.dirtyIndex);return this.findAll(e)}},{key:"invalidElements",value:function(){var e=Array.from(this.invalidsIndex);return this.findAll(e)}},{key:"nondeletedElements",value:function(){var e=Array.from(this.nondeletedIndex);return this.findAll(e)}},{key:"findAll",value:function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],a=S(e);!(t=a()).done;){var i=t.value,s=this.map[i];(s||n)&&r.push(s)}return r}},{key:"set",value:function(e){if(0!==(e=Array.isArray(e)?e:[e]).length)for(var t,n=S(e);!(t=n()).done;){var r=t.value;if(this.map[r.uuid]=r,this.setToTypedMap(r),r.dirty?this.dirtyIndex.add(r.uuid):this.dirtyIndex.delete(r.uuid),r.errorDecrypting||r.waitingForKey?this.invalidsIndex.add(r.uuid):this.invalidsIndex.delete(r.uuid),r.deleted)this.referenceMap.removeFromMap(r.uuid),this.nondeletedIndex.delete(r.uuid);else{this.nondeletedIndex.add(r.uuid);var a=r.safeContent.conflict_of;a&&this.conflictMap.establishRelationship(a,r.uuid),this.referenceMap.setAllRelationships(r.uuid,r.references.map(function(e){return e.uuid}))}}else console.warn('Attempting to set 0 elements onto collection')}},{key:"discard",value:function(e){for(var t,n=S(e=Array.isArray(e)?e:[e]);!(t=n()).done;){var r=t.value;this.conflictMap.removeFromMap(r.uuid),this.referenceMap.removeFromMap(r.uuid),this.deleteFromTypedMap(r),delete this.map[r.uuid]}}},{key:"setToTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),t.push(e),this.typedMap[e.content_type]=t}},{key:"deleteFromTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),this.typedMap[e.content_type]=t}},{key:"uuidsThatReferenceUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getInverseRelationships(e)}},{key:"elementsReferencingElement",value:function(e,t){var n=this.uuidsThatReferenceUuid(e.uuid),r=this.findAll(n);return t?r.filter(function(e){return e.content_type===t}):r}},{key:"uuidReferencesForUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getDirectRelationships(e)}},{key:"referencesForElement",value:function(e){var t=this.referenceMap.getDirectRelationships(e.uuid);return this.findAll(t)}},{key:"conflictsOf",value:function(e){var t=this.conflictMap.getDirectRelationships(e);return this.findAll(t)}}]),e})(),bt=(function(e){d(n,mt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"mutableCopy",value:function(){var e=w({},this.map),t=w({},this.typedMap),n=this.referenceMap.makeCopy(),r=this.conflictMap.makeCopy();return new mt(!0,e,t,n,r)}},{key:"payloads",get:function(){return this.all()}}],[{key:"WithPayloads",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=new n;return r.source=t,e.length>0&&r.set(e),Object.freeze(r),r}},{key:"FromCollection",value:function(e){var t=new n(!0,Object.freeze(w({},e.map)),Object.freeze(w({},e.typedMap)),Object.freeze(e.referenceMap.makeCopy()),Object.freeze(e.conflictMap.makeCopy()));return Object.freeze(t),t}}]),n})();function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach(function(t){xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var St,Pt,Ot,Ct=(function(){function e(t,n,r,a,i){v(this,e),this.baseCollection=t,this.basePayload=n,this.applyPayload=r,this.source=a,this.historyMap=i}return y(e,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return t=nt(this.basePayload),n=nt(this.applyPayload),r=(null===(e=this.historyMap)||void 0===e?void 0:e[this.basePayload.uuid])||[],a=yt(r),i=t.strategyWhenConflictingWithItem(n,a),o.next=7,b.awrap(this.payloadsByHandlingStrategy(i));case 7:return s=o.sent,o.abrupt("return",bt.WithPayloads(s,this.source));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingStrategy",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if((t=this.baseCollection.conflictsOf(this.applyPayload.uuid)[0])&&dt(t,this.applyPayload)&&(e=K.a.KeepLeft),e!==K.a.KeepLeft){y.next=7;break}return n=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),r=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),a=Object(Ee.b)(this.basePayload,{updated_at:n,updated_at_timestamp:r,dirty:!0,dirtiedDate:new Date}),y.abrupt("return",[a]);case 7:if(e!==K.a.KeepRight){y.next=10;break}return i=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",[i]);case 10:if(e!==K.a.KeepLeftDuplicateRight){y.next=18;break}return s=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),o=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),c=Object(Ee.b)(this.basePayload,{updated_at:s,updated_at_timestamp:o,dirty:!0,dirtiedDate:new Date}),y.next=16,b.awrap(ut(this.applyPayload,this.baseCollection,!0));case 16:return u=y.sent,y.abrupt("return",[c].concat(u));case 18:if(e!==K.a.DuplicateLeftKeepRight){y.next=24;break}return y.next=21,b.awrap(ut(this.basePayload,this.baseCollection,!0));case 21:return l=y.sent,p=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",l.concat([p]));case 24:if(e!==K.a.KeepLeftMergeRefs){y.next=30;break}return d=Object(_.U)(this.basePayload.contentObject.references,this.applyPayload.contentObject.references,['uuid','content_type']),h=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),f=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),v=Object(Ee.b)(this.basePayload,{updated_at:h,updated_at_timestamp:f,dirty:!0,dirtiedDate:new Date,content:kt(kt({},this.basePayload.safeContent),{},{references:d})}),y.abrupt("return",[v]);case 30:throw Error('Unhandled strategy');case 31:case"end":return y.stop()}},null,this,null,Promise)}}]),e})(),Dt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}return r=n.value,s.next=6,b.awrap(this.payloadsByHandlingPayload(r,e));case 6:a=s.sent,i=a.map(function(e){return Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date,deleted:!1})}),Object(_.o)(e,i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.FileImport));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingPayload",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=t.find(function(t){return t.contentObject.conflict_of===e.uuid}))||(n=t.find(function(t){return t.uuid===e.uuid})),n||(n=this.findBasePayload(e.uuid)),n){i.next=5;break}return i.abrupt("return",[e]);case 5:return r=new Ct(this.baseCollection,n,e,ht.a.FileImport),i.next=8,b.awrap(r.resultingCollection());case 8:return a=i.sent,i.abrupt("return",a.all());case 10:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(),_t=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=17;break}if(r=n.value,e.push(r),a=this.findBasePayload(r.uuid)){s.next=8;break}return s.abrupt("continue",15);case 8:if(!dt(r,a)){s.next=11;break}return s.abrupt("continue",15);case 11:return s.next=13,b.awrap(ut(a,this.baseCollection,!0));case 13:i=s.sent,Object(_.o)(e,i);case 15:s.next=2;break;case 17:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 18:case"end":return s.stop()}},null,this,null,Promise)}}]),n})(),Et=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.applyCollection.source!==ht.a.ConflictUuid){e.next=4;break}return e.abrupt("return",this.collectionsByHandlingUuidConflicts());case 4:if(this.applyCollection.source!==ht.a.ConflictData){e.next=8;break}return e.abrupt("return",this.collectionsByHandlingDataConflicts());case 8:throw"Unhandled conflict type ".concat(this.applyCollection.source);case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingDataConflicts",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){u.next=19;break}if(r=n.value,a=this.findBasePayload(r.uuid)){u.next=8;break}return e.push(r),u.abrupt("continue",17);case 8:if((i=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient))||r.deleted){u.next=11;break}throw'Unable to find decrypted counterpart for data conflict.';case 11:return s=new Ct(this.baseCollection,a,i||r,ht.a.ConflictData,this.historyMap),u.next=14,b.awrap(s.resultingCollection());case 14:o=u.sent,c=o.all(),Object(_.o)(e,c);case 17:u.next=2;break;case 19:return u.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingUuidConflicts",value:function(){var e,t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:e=[],t=this.baseCollection.mutableCopy(),n=function(n){var r,a,i;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=e.find(function(e){return e.uuid===n.uuid}),a=r||s.findRelatedPayload(n.uuid,ht.a.DecryptedTransient)){o.next=6;break}return we.a.error(Error('Cannot find decrypted payload in conflict handling')),console.error('Unable to find decrypted counterpart for payload',n),o.abrupt("return","continue");case 6:return o.next=8,b.awrap(lt(a,bt.FromCollection(t)));case 8:i=o.sent,t.set(i),Object(_.p)(e,function(e){return Object(Ke.b)(i).includes(e.uuid)}),Object(_.o)(e,i);case 12:case"end":return o.stop()}},null,null,null,Promise)},r=S(this.applyCollection.all());case 4:if((a=r()).done){o.next=13;break}return i=a.value,o.next=8,b.awrap(n(i));case 8:if("continue"!==o.sent){o.next=11;break}return o.abrupt("continue",11);case 11:o.next=4;break;case 13:return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 14:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Rt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y;return b.async(function(g){for(;;)switch(g.prev=g.next){case 0:e=[],t=[],n=S(this.applyCollection.all());case 3:if((r=n()).done){g.next=22;break}if(a=r.value,i=this.findRelatedPayload(a.uuid,ht.a.SavedOrSaving),s=this.findRelatedPayload(a.uuid,ht.a.DecryptedTransient)){g.next=12;break}if(a.deleted){g.next=10;break}throw'Cannot find decrypted for non-deleted payload.';case 10:return e.push(a),g.abrupt("continue",20);case 12:if(!i){g.next=15;break}return t.push(s),g.abrupt("continue",20);case 15:if(null===(o=this.findBasePayload(a.uuid))||void 0===o||!o.dirty||o.errorDecrypting){g.next=19;break}return t.push(s),g.abrupt("continue",20);case 19:e.push(s);case 20:g.next=3;break;case 22:c=[],u=0,l=t;case 24:if(!(u<l.length)){g.next=41;break}if(p=l[u],d=this.findRelatedPayload(p.uuid,ht.a.DecryptedTransient)){g.next=29;break}return g.abrupt("continue",38);case 29:if(h=this.findBasePayload(p.uuid)){g.next=32;break}return g.abrupt("continue",38);case 32:return f=new Ct(this.baseCollection,h,d,ht.a.ConflictData),g.next=35,b.awrap(f.resultingCollection());case 35:v=g.sent,y=v.all(),Object(_.o)(c,y);case 38:u++,g.next=24;break;case 41:return g.abrupt("return",bt.WithPayloads(e.concat(c),ht.a.RemoteRetrieved));case 42:case"end":return g.stop()}},null,this,null,Promise)}}]),n})(),It=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:for(e=[],t=S(this.applyCollection.all());!(n=t()).done;)r=n.value,a=this.findBasePayload(r.uuid),i=a?a.deleted:r.deleted,s=Object(Ee.f)(r,ht.a.RemoteSaved,{lastSyncEnd:new Date,deleted:i,dirty:i}),e.push(s);return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteSaved));case 3:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Mt=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l){var p;return v(this,n),(p=t.call(this)).itemManager=e,p.payloadManager=r,p.apiService=a,p.protocolService=i,p.challengeService=s,p.alertService=o,p.storageService=c,p.syncService=u,p.credentialService=l,p.decryptionQueue=[],p.isProcessingQueue=!1,p.removeItemObserver=p.itemManager.addObserver([F.a.ItemsKey],function(e,t,n,r,a){if(a!==ht.a.LocalChanged){var i=e.concat(t).filter(function(e){return e.errorDecrypting});i.length>0&&p.handleUndecryptableItemsKeys(i),r.length>0&&p.handleIgnoredItemsKeys(r)}}),p}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.apiService=void 0,this.protocolService=void 0,this.challengeService=void 0,this.alertService=void 0,this.credentialService=void 0,this.syncService=void 0,this.storageService=void 0,this.removeItemObserver(),this.removeItemObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:p(f(n.prototype),"handleApplicationStage",this).call(this,e),e===ve.LoadedDatabase_12&&this.processPersistedUndecryptables();case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleIgnoredItemsKeys",value:function(e){var t=this,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(!(n.length>1&&void 0!==n[1])||n[1])){r.next=4;break}return r.next=4,b.awrap(this.saveToUndecryptables(e));case 4:return r.next=6,b.awrap(this.addKeysToQueue(e,function(e,n){n.success&&t.removeFromUndecryptables(e)}));case 6:return r.next=8,b.awrap(this.beginProcessingQueue());case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"handleUndecryptableItemsKeys",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.addKeysToQueue(e));case 2:return t.next=4,b.awrap(this.beginProcessingQueue());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"processPersistedUndecryptables",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getUndecryptables());case 2:if(e=r.sent,0!==(t=Object.values(e)).length){r.next=6;break}return r.abrupt("return");case 6:return n=t.map(function(e){return Object(Ee.e)(e)}).map(function(e){return nt(e)}),r.abrupt("return",this.handleIgnoredItemsKeys(n,!1));case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getUndecryptables",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.KeyRecoveryUndecryptableItems,De.Default,{}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"persistUndecryptables",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.KeyRecoveryUndecryptableItems,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"saveToUndecryptables",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.getUndecryptables());case 2:for(t=i.sent,n=S(e);!(r=n()).done;)a=r.value,t[a.uuid]=a.payload.ejected();return i.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"removeFromUndecryptables",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getUndecryptables());case 2:return delete(t=n.sent)[e.uuid],n.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getClientKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getAccountKeyParams());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"serverKeyParamsAreSafe",value:function(e){return Object(Q.d)(this.serverParams.version,e.version)}},{key:"performServerSignIn",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(e),j.H.KeyRecoveryLoginFlowReason),i.next=3,b.awrap(this.challengeService.promptForChallengeResponse(t));case 3:if(n=i.sent){i.next=6;break}return i.abrupt("return",void 0);case 6:return this.challengeService.completeChallenge(t),r=n.values[0].value,i.next=10,b.awrap(this.protocolService.computeRootKey(r,e));case 10:return a=i.sent,i.next=13,b.awrap(this.credentialService.correctiveSignIn(a));case 13:if(i.sent.error){i.next=19;break}return this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced),i.abrupt("return",a);case 19:return i.next=21,b.awrap(this.alertService.alert(j.H.KeyRecoveryLoginFlowInvalidPassword));case 21:return i.abrupt("return",this.performServerSignIn(e));case 22:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",void 0);case 2:return n.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(e=n.sent,t=e.wrappingKey,!e.canceled){n.next=11;break}return n.next=10,b.awrap(this.alertService.alert(j.H.KeyRecoveryPasscodeRequiredText,j.H.KeyRecoveryPasscodeRequiredTitle));case 10:return n.abrupt("return",this.getWrappingKeyIfApplicable());case 11:return n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"addKeysToQueue",value:function(e,t){var n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:n=function(e){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(s.protocolService.getKeyEmbeddedKeyParams(e));case 2:if(n=i.sent){i.next=5;break}return i.abrupt("return","continue");case 5:r={key:e,keyParams:n,callback:t},a=new Promise(function(e){r.resolve=e}),r.promise=a,s.decryptionQueue.push(r);case 9:case"end":return i.stop()}},null,null,null,Promise)},r=S(e);case 2:if((a=r()).done){o.next=11;break}return i=a.value,o.next=6,b.awrap(n(i));case 6:if("continue"!==o.sent){o.next=9;break}return o.abrupt("continue",9);case 9:o.next=2;break;case 11:case"end":return o.stop()}},null,null,null,Promise)}},{key:"readdQueueItem",value:function(e){var t=new Promise(function(t){e.resolve=t});e.promise=t,this.decryptionQueue.unshift(e)}},{key:"beginProcessingQueue",value:function(){var e,t,n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.isProcessingQueue){c.next=2;break}return c.abrupt("return");case 2:return this.isProcessingQueue=!0,c.next=5,b.awrap(this.getClientKeyParams());case 5:if(e=c.sent,this.serverParams||!e){c.next=11;break}return c.next=9,b.awrap(this.apiService.getAccountKeyParams(e.identifier));case 9:!(t=c.sent).error&&t.data&&(this.serverParams=Object(A.f)(t));case 11:if(n=this.protocolService.hasAccount(),r=this.protocolService.hasPasscode(),a=!n&&!r,i=this.decryptionQueue[0],!a){c.next=24;break}return c.next=18,b.awrap(this.performServerSignIn(i.keyParams));case 18:if(!(s=c.sent)){c.next=24;break}return c.next=22,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(s,!0));case 22:Object(_.M)(this.decryptionQueue,i),i=this.decryptionQueue[0];case 24:if(!i){c.next=31;break}return this.popQueueItem(i),c.next=28,b.awrap(i.promise);case 28:i=this.decryptionQueue[0],c.next=24;break;case 31:this.queuePromise.then(function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(o.isProcessingQueue=!1,!o.serverParams){n.next=9;break}return n.next=4,b.awrap(o.getClientKeyParams());case 4:if(e=n.sent,t=e&&!o.serverParams.compare(e),!o.serverKeyParamsAreSafe(e)||!t){n.next=9;break}return n.next=9,b.awrap(o.performServerSignIn(o.serverParams));case 9:o.syncService.isOutOfSync()&&o.syncService.sync({checkIntegrity:!0});case 10:case"end":return n.stop()}},null,null,null,Promise)});case 32:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueItem",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P;return b.async(function(O){for(;;)switch(O.prev=O.next){case 0:if(e.resolve){O.next=2;break}throw Error('Attempting to pop queue element with no resolve function');case 2:return Object(_.M)(this.decryptionQueue,e),t=e.keyParams,n=e.key,r=e.resolve,a=!1,O.next=9,b.awrap(this.getClientKeyParams());case 9:return i=O.sent,this.serverParams&&i&&!i.compare(this.serverParams)&&t.compare(this.serverParams)&&this.serverKeyParamsAreSafe(this.serverParams)&&(s=Object(_.j)(this.itemManager.nonErroredItemsForContentType(F.a.ItemsKey),Je.a.CreatedAt,!1)[0],o=!Object(_.w)(s),c=n.created_at>(null===s||void 0===s?void 0:s.created_at),a=!o||c),u=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(t),j.H.KeyRecoveryPasswordRequired),O.next=14,b.awrap(this.challengeService.promptForChallengeResponse(u));case 14:if(l=O.sent){O.next=20;break}return r(d={success:!1}),null===(p=e.callback)||void 0===p||p.call(e,n,d),O.abrupt("return");case 20:return h=l.values[0].value,O.next=23,b.awrap(this.protocolService.computeRootKey(h,t));case 23:return f=O.sent,O.next=26,b.awrap(this.protocolService.payloadByDecryptingPayload(n.payload,f));case 26:if(v=O.sent,this.challengeService.completeChallenge(u),v.errorDecrypting){O.next=38;break}return O.next=31,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(f,a,[v]));case 31:for(g=O.sent,r(m={success:!0}),null===(y=e.callback)||void 0===y||y.call(e,n,m),w=S(g);!(k=w()).done;)(x=k.value).resolve(m),null===(P=x.callback)||void 0===P||P.call(x,x.key,m);O.next=42;break;case 38:return O.next=40,b.awrap(this.alertService.alert(j.H.KeyRecoveryUnableToRecover));case 40:this.readdQueueItem(e),r({success:!1});case 42:case"end":return O.stop()}},null,this,null,Promise)}},{key:"handleDecryptionOfAllKeysMatchingCorrectRootKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:[],!t){c.next=7;break}return c.next=4,b.awrap(this.getWrappingKeyIfApplicable());case 4:return r=c.sent,c.next=7,b.awrap(this.protocolService.setRootKey(e,r));case 7:return a=this.popQueueForKeyParams(e.keyParams),c.next=10,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a.map(function(e){return e.key.payload}),e));case 10:return i=c.sent,s=n.concat(i),this.payloadManager.emitPayloads(s,ht.a.DecryptedTransient),c.next=15,b.awrap(this.storageService.savePayloads(s));case 15:return t?this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced):this.alertService.alert(j.H.KeyRecoveryKeyRecovered),c.abrupt("return",a);case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueForKeyParams",value:function(e){for(var t,n=[],r=[],a=S(this.decryptionQueue);!(t=a()).done;){var i=t.value;i.keyParams.compare(e)?n.push(i):r.push(i)}return this.decryptionQueue=r,n}},{key:"queuePromise",get:function(){return Promise.all(this.decryptionQueue.map(function(e){return e.promise}))}}]),n})(R.a),At=n(17);!(function(e){e[e.Info=0]="Info",e[e.Danger=1]="Danger"})(St||(St={})),(function(e){e.Get="GET",e.Post="POST",e.Put="PUT",e.Patch="PATCH",e.Delete="DELETE"})(Pt||(Pt={})),(function(e){e.RevokedSession="revoked-session"})(Ot||(Ot={}));var jt=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).environment=e,a.appVersion=r,a}return y(n,[{key:"getAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Get,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"postAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Post,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"putAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Put,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"patchAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Patch,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Delete,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"runHttp",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.createXmlRequest(e),n.abrupt("return",this.runRequest(t,e.verb,e.params));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createXmlRequest",value:function(e){var t=new XMLHttpRequest;e.params&&e.verb===Pt.Get&&Object.keys(e.params).length>0&&(e.url=this.urlForUrlAndParams(e.url,e.params)),t.open(e.verb,e.url,!0),t.setRequestHeader('Content-type','application/json'),t.setRequestHeader('X-SNJS-Version',h);var n="".concat(he[this.environment],"-").concat(this.appVersion);return t.setRequestHeader('X-Application-Version',n),e.authentication&&t.setRequestHeader('Authorization','Bearer '+e.authentication),e.customHeaders&&e.customHeaders.length>0&&e.customHeaders.forEach(function(e){var n=e.key,r=e.value;t.setRequestHeader(n,r)}),t}},{key:"runRequest",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,i){e.onreadystatechange=function(){r.stateChangeHandlerForRequest(e,a,i)},t===Pt.Post||t===Pt.Put||t===Pt.Patch||t===Pt.Delete?e.send(JSON.stringify(n)):e.send()}));case 1:case"end":return a.stop()}},null,null,null,Promise)}},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.status,a={status:r};try{if(r!==Te.b.HttpStatusNoContent){var i=JSON.parse(e.responseText);i.data||(a.data=i),w(a,i)}}catch(e){console.error(e)}r>=Te.b.HttpStatusMinSuccess&&r<=Te.b.HttpStatusMaxSuccess?t(a):(r===Te.b.HttpStatusForbidden?a.error={message:j.q,status:r}:Object(_.w)(a.error)&&(Object(_.w)(a.data)||Object(_.w)(a.data.error)?a.error={message:j.U,status:r}:a.error=a.data.error),n(a))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map(function(e){return e+'='+encodeURIComponent(t[e])}).join('&');return e.includes('?')?e+'&'+n:e+'?'+n}}]),n})(R.a),Tt=n(22),Kt=['api.standardnotes.com','api-dev.standardnotes.com','sync.standardnotes.org'],Ft=['api-dev.standardnotes.com','api.standardnotes.com','extensions.standardnotes.com','extensions.standardnotes.org','features.standardnotes.com'],Lt='localhost';function Ut(e){try{var t=new URL(e).host;return t.startsWith(Lt)||Kt.includes(t)}catch(e){return!1}}var Nt=['listed.to'];function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(n),!0).forEach(function(t){Wt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ht,zt={keyParams:'/v1/login-params',register:'/v1/users',signIn:'/v1/login',changeCredentials:function(e){return"/v1/users/".concat(e,"/attributes/credentials")},sync:'/v1/items',signOut:'/v1/logout',refreshSession:'/v1/sessions/refresh',sessions:'/v1/sessions',session:function(e){return"/v1/sessions/".concat(e)},itemRevisions:function(e){return"/v1/items/".concat(e,"/revisions")},itemRevision:function(e,t){return"/v1/items/".concat(e,"/revisions/").concat(t)},userFeatures:function(e){return"/v1/users/".concat(e,"/features")},settings:function(e){return"/v1/users/".concat(e,"/settings")},setting:function(e,t){return"/v1/users/".concat(e,"/settings/").concat(t)},subscription:function(e){return"/v1/users/".concat(e,"/subscription")},purchase:'/v1/purchase',subscriptionTokens:'/v1/subscription-tokens',offlineFeatures:'/v1/offline/features'},qt={subscriptions:'/v2/subscriptions'};!(function(e){e.MetaReceived="MetaReceived"})(Ht||(Ht={}));var Yt=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).httpService=e,i.storageService=r,i.host=a,i.registering=!1,i.authenticating=!1,i.changing=!1,i.refreshingSession=!1,i}return y(n,[{key:"deinit",value:function(){this.httpService=void 0,this.storageService=void 0,this.invalidSessionObserver=void 0,this.session=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"setInvalidSessionObserver",value:function(e){this.invalidSessionObserver=e}},{key:"loadHost",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ServerHost));case 2:e=t.sent,this.host=e||this.host||window._default_sync_server;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.host=e,t.next=3,b.awrap(this.storageService.setValue(o.ServerHost,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.host}},{key:"isThirdPartyHostUsed",value:function(){return!Ut(this.getHost()||'')}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],this.session=e,!t){r.next=5;break}return r.next=5,b.awrap(this.storageService.setValue(o.Session,e));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSession",value:function(){return this.session}},{key:"params",value:function(e){var t=Z()(e,g({},Tt.a.ApiVersion,this.apiVersion));return t}},{key:"createErrorResponse",value:function(e,t){return{error:{message:e,status:t}}}},{key:"errorResponseWithFallbackMessage",value:function(e,t){var n,r,a;null!==(n=e.error)&&void 0!==n&&n.message||(e.error=Bt(Bt({},e.error),{},{status:null!==(r=null===(a=e.error)||void 0===a?void 0:a.status)&&void 0!==r?r:Te.b.UnknownError,message:t}));return e}},{key:"processMetaObject",value:function(e){e.auth&&e.auth.userUuid&&e.auth.roles&&this.notifyEvent(Ht.MetaReceived,{userUuid:e.auth.userUuid,userRoles:e.auth.roles})}},{key:"processResponse",value:function(e){e.meta&&this.processMetaObject(e.meta)}},{key:"request",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.awrap(this.httpService.runHttp(e));case 3:return t=n.sent,this.processResponse(t),n.abrupt("return",t);case 8:return n.prev=8,n.t0=n.catch(0),n.abrupt("return",this.errorResponseWithFallbackMessage(n.t0,e.fallbackErrorMessage));case 11:case"end":return n.stop()}},null,this,[[0,8]],Promise)}},{key:"getAccountKeyParams",value:function(e,t,n){var r,a=this.params({email:e});return t&&n&&(a[t]=n),this.request({verb:Pt.Get,url:Object(_.D)(this.host,zt.keyParams),fallbackErrorMessage:j.k,params:a,authentication:null===(r=this.session)||void 0===r?void 0:r.authorizationValue})}},{key:"register",value:function(e,t,n,r){var a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.registering){o.next=2;break}return o.abrupt("return",this.createErrorResponse(j.r));case 2:return this.registering=!0,a=Object(_.D)(this.host,zt.register),i=this.params(Bt({password:t,email:e,ephemeral:r},n.getPortableValue())),o.next=7,b.awrap(this.request({verb:Pt.Post,url:a,fallbackErrorMessage:j.l,params:i}));case 7:return s=o.sent,this.registering=!1,o.abrupt("return",s);case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t,n,r){var a,i,s,o,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>4&&void 0!==c[4]&&c[4],!this.authenticating){u.next=3;break}return u.abrupt("return",this.createErrorResponse(j.p));case 3:return this.authenticating=!0,i=Object(_.D)(this.host,zt.signIn),s=this.params({email:e,password:t,ephemeral:a}),n&&r&&(s[n]=r),u.next=9,b.awrap(this.request({verb:Pt.Post,url:i,params:s,fallbackErrorMessage:j.k}));case 9:return o=u.sent,this.authenticating=!1,u.abrupt("return",o);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e=Object(_.D)(this.host,zt.signOut);return this.httpService.postAbsolute(e,void 0,this.session.authorizationValue).catch(function(e){return e})}},{key:"changeCredentials",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.changing){s.next=2;break}return s.abrupt("return",this.createErrorResponse(j.a));case 2:if(!(t=this.preprocessingError())){s.next=5;break}return s.abrupt("return",t);case 5:return this.changing=!0,n=Object(_.D)(this.host,zt.changeCredentials(e.userUuid)),r=this.params(Bt({current_password:e.currentServerPassword,new_password:e.newServerPassword,new_email:e.newEmail},e.newKeyParams.getPortableValue())),s.next=10,b.awrap(this.httpService.putAbsolute(n,r,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Object(Te.c)(e)){t.next=2;break}return t.abrupt("return",i.refreshSessionThenRetryRequest({verb:Pt.Put,url:n,params:r}));case 2:return t.abrupt("return",i.errorResponseWithFallbackMessage(e,j.j));case 3:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return a=s.sent,this.processResponse(a),this.changing=!1,s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"sync",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=this,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:if(i=h.length>4&&void 0!==h[4]&&h[4],s=h.length>5?h[5]:void 0,o=h.length>6?h[6]:void 0,!(c=this.preprocessingError())){f.next=6;break}return f.abrupt("return",c);case 6:return u=Object(_.D)(this.host,zt.sync),l=this.params((g(a={},Tt.a.SyncPayloads,e.map(function(e){return e.ejected()})),g(a,Tt.a.LastSyncToken,t),g(a,Tt.a.PaginationToken,n),g(a,Tt.a.IntegrityCheck,i),g(a,Tt.a.SyncDlLimit,r),g(a,"content_type",s),g(a,"event",o),a)),f.next=10,b.awrap(this.httpService.postAbsolute(u,l,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(d.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){t.next=3;break}return t.abrupt("return",d.refreshSessionThenRetryRequest({verb:Pt.Post,url:u,params:l}));case 3:return t.abrupt("return",d.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return p=f.sent,this.processResponse(p),f.abrupt("return",p);case 13:case"end":return f.stop()}},null,this,null,Promise)}},{key:"refreshSessionThenRetryRequest",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.refreshSession());case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=7;break}return n.abrupt("return",t);case 7:return n.abrupt("return",this.httpService.runHttp(Bt(Bt({},e),{},{authentication:this.session.authorizationValue})).catch(function(e){return e}));case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"refreshSession",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(e=this.preprocessingError())){s.next=3;break}return s.abrupt("return",e);case 3:return this.refreshingSession=!0,t=Object(_.D)(this.host,zt.refreshSession),n=this.session,r=this.params({access_token:n.accessToken,refresh_token:n.refreshToken}),s.next=9,b.awrap(this.httpService.postAbsolute(t,r).then(function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=je.FromApiResponse(e),n.next=3,b.awrap(i.setSession(t));case 3:return i.processResponse(e),n.abrupt("return",e);case 5:case"end":return n.stop()}},null,null,null,Promise)}).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),i.errorResponseWithFallbackMessage(e,j.n)}));case 9:return a=s.sent,this.refreshingSession=!1,s.abrupt("return",a);case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e=this.preprocessingError())){a.next=3;break}return a.abrupt("return",e);case 3:return t=Object(_.D)(this.host,zt.sessions),a.next=6,b.awrap(this.httpService.getAbsolute(t,{},this.session.authorizationValue).catch(function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){n.next=3;break}return n.abrupt("return",r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}));case 3:return n.abrupt("return",r.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return n.stop()}},null,null,null,Promise)}));case 6:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSession",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.session(e)),i.next=6,b.awrap(this.httpService.deleteAbsolute(n,{uuid:e},this.session.authorizationValue).catch(function(e){var t=e;return a.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?a.refreshSessionThenRetryRequest({verb:Pt.Delete,url:n}):a.errorResponseWithFallbackMessage(t,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getItemRevisions",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.itemRevisions(e)),i.next=6,b.awrap(this.httpService.getAbsolute(n,void 0,this.session.authorizationValue).catch(function(e){return a.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?a.refreshSessionThenRetryRequest({verb:Pt.Get,url:n}):a.errorResponseWithFallbackMessage(e,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getRevision",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(n=this.preprocessingError())){s.next=3;break}return s.abrupt("return",n);case 3:return r=Object(_.D)(this.host,zt.itemRevision(t,e.uuid)),s.next=6,b.awrap(this.httpService.getAbsolute(r,void 0,this.session.authorizationValue).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?i.refreshSessionThenRetryRequest({verb:Pt.Get,url:r}):i.errorResponseWithFallbackMessage(e,j.m)}));case 6:return a=s.sent,this.processResponse(a),s.abrupt("return",a);case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getUserFeatures",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=Object(_.D)(this.host,zt.userFeatures(e)),a.next=3,b.awrap(this.httpService.getAbsolute(t,void 0,this.session.authorizationValue).catch(function(e){return r.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}):r.errorResponseWithFallbackMessage(e,j.m)}));case 3:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"tokenRefreshableRequest",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(t=this.preprocessingError())){a.next=3;break}return a.abrupt("return",t);case 3:return a.next=5,b.awrap(this.httpService.runHttp(e).catch(function(t){return r.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?r.refreshSessionThenRetryRequest(e):r.errorResponseWithFallbackMessage(t,e.fallbackErrorMessage)}));case 5:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"listSettings",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.settings(e)),fallbackErrorMessage:j.d,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n,r){var a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return i={name:t,value:n,sensitive:r},s.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Put,url:Object(_.D)(this.host,zt.settings(e)),authentication:null===(a=this.session)||void 0===a?void 0:a.authorizationValue,fallbackErrorMessage:j.h,params:i}));case 2:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.setting(e,t.toLowerCase())),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.d}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Delete,url:Object(_.D)(this.host,zt.setting(e,t)),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.h}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"downloadFeatureUrl",value:function(e){return this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.k})}},{key:"getSubscription",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscription(e)),a.next=3,b.awrap(this.request({verb:Pt.Get,url:n,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue,fallbackErrorMessage:j.g}));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=Object(_.D)(this.host,qt.subscriptions),n.next=3,b.awrap(this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.g}));case 3:return t=n.sent,n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getNewSubscriptionToken",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscriptionTokens),a.next=3,b.awrap(this.request({verb:Pt.Post,url:n,authentication:null===(e=this.session)||void 0===e?void 0:e.authorizationValue,fallbackErrorMessage:j.b}));case 3:return r=a.sent,a.abrupt("return",null===(t=r.data)||void 0===t?void 0:t.token);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"downloadOfflineFeaturesFromRepo",value:function(e){var t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,n=e.offlineFeaturesUrl,r=e.offlineKey,a=new URL(n),i=a.host,Ft.includes(i)){o.next=6;break}return o.abrupt("return",{error:'This offline features host is not in the trusted allowlist.'});case 6:return o.next=8,b.awrap(this.request({verb:Pt.Get,url:n,fallbackErrorMessage:j.f,customHeaders:[{key:'x-offline-token',value:r}]}));case 8:return s=o.sent,o.abrupt("return",{features:(null===(t=s.data)||void 0===t?void 0:t.features)||[]});case 12:return o.prev=12,o.t0=o.catch(0),o.abrupt("return",{error:j.e});case 15:case"end":return o.stop()}},null,this,[[0,12]],Promise)}},{key:"preprocessingError",value:function(){return this.refreshingSession?this.createErrorResponse(j.s):this.session?void 0:this.createErrorResponse(j.o)}},{key:"preprocessAuthenticatedErrorResponse",value:function(e){var t,n;e.status===Te.b.HttpStatusInvalidSession&&this.session&&(null===(t=this.invalidSessionObserver)||void 0===t||t.call(this,(null===(n=e.error)||void 0===n?void 0:n.tag)===Ot.RevokedSession))}},{key:"apiVersion",get:function(){return"20200115"}}]),n})(R.a),Gt=n(25),Qt=n.n(Gt),Jt=n(28),$t=n.n(Jt);function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach(function(t){en(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tn,nn=Object.freeze([F.a.ActionsExtension,F.a.Component,F.a.Editor,F.a.ExtensionRepo,F.a.FilesafeCredentials,F.a.FilesafeFileMetadata,F.a.FilesafeIntegration,F.a.ServerExtension,F.a.SmartTag,F.a.Tag,F.a.Theme]),rn='org.standardnotes.sn.components';!(function(e){e.Shift="Shift",e.Ctrl="Control",e.Meta="Meta"})(tn||(tn={}));var an=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).componentState={},c.streamObservers=[],c.contextStreamObservers=[],c.permissionDialogs=[],c.handlers=[],c.templateComponents=[],c.detectFocusChange=function(){for(var e,t=function(e){if(document.activeElement===e)return c.timeout(function(){for(var t,n=c.findComponent(e.dataset.componentId),r=S(c.handlers);!(t=r()).done;){var a=t.value;a.focusHandler&&a.focusHandler(n,!0)}}),"break"},n=S(c.allComponentIframes());!(e=n()).done;){if("break"===t(e.value))break}},c.onWindowMessage=function(e){e.data.sessionKey&&(c.log('Component manager received message',e.data),c.handleMessage(c.componentForSessionKey(e.data.sessionKey),e.data))},c.timeout=o||setTimeout.bind(window),c.itemManager=e,c.syncService=r,c.alertService=a,c.environment=i,c.platform=s,c.configureForGeneralUsage(),i!==he.Mobile&&c.configureForNonMobileUsage(),c}return y(n,[{key:"componentsForArea",value:function(e){return this.components.filter(function(t){return t.area===e})}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.streamObservers.length=0,this.contextStreamObservers.length=0,this.permissionDialogs.length=0,this.templateComponents.length=0,this.handlers.length=0,this.itemManager=void 0,this.syncService=void 0,this.alertService=void 0,this.removeItemObserver(),this.removeItemObserver=null,window&&!this.isMobile&&(window.removeEventListener('focus',this.detectFocusChange,!0),window.removeEventListener('blur',this.detectFocusChange,!0),window.removeEventListener('message',this.onWindowMessage))}},{key:"setDesktopManager",value:function(e){this.desktopManager=e,this.configureForDesktop()}},{key:"configureForGeneralUsage",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n,r,a,i,s){var o=Object(_.h)(t,n,r),c=o.filter(function(e){return e.content_type===F.a.Component||e.content_type===F.a.Theme});c.length>0&&i!==ht.a.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(c),c.filter(function(e){return e.isTheme()}).length>0&&e.postActiveThemesToAllComponents();for(var u,l=S(c);!(u=l()).done;){var p=u.value;if(!p.isEditor()){var d=!!e.iframeForComponent(p.uuid);!p.active&&d&&e.deactivateComponent(p.uuid)}}e.notifyStreamObservers(o,i,s)})}},{key:"notifyStreamObservers",value:function(e,t,n){for(var r,a=this,i=function(t){if(n&&n===t.componentUuid)return"continue";var r=e.filter(function(e){return-1!==t.contentTypes.indexOf(e.content_type)});if(0===r.length)return"continue";var i=[{name:E.StreamItems,content_types:t.contentTypes.sort()}];a.runWithPermissions(t.componentUuid,i,function(){a.sendItemsInReply(t.componentUuid,r,t.originalMessage)})},s=S(this.streamObservers);!(r=s()).done;)i(r.value);for(var o,c=[{name:E.StreamContextItem}],u=function(r){if(n&&n===r.componentUuid)return"continue";for(var i,s=S(a.handlers);!(i=s()).done;){var o=i.value;if((o.areas.includes(r.area)||o.areas.includes(L.ComponentArea.Any))&&o.contextRequestHandler){var u=o.contextRequestHandler(r.componentUuid);if(u)if("continue"===(function(){var n=Qt()(e,{uuid:u.uuid});if(n){if(n.deleted)return"continue";a.runWithPermissions(r.componentUuid,c,function(){a.sendContextItemInReply(r.componentUuid,n,r.originalMessage,t)})}})())continue}}},l=S(this.contextStreamObservers);!(o=l()).done;)u(o.value)}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location],n=e.hosted_url,r=e.local_url&&e.local_url.replace("sn://",'');return t.includes(n)||t.includes(r)}},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener('focus',this.detectFocusChange,!0):window.attachEvent('onfocusout',this.detectFocusChange),window.addEventListener?window.addEventListener('blur',this.detectFocusChange,!0):window.attachEvent('onblur',this.detectFocusChange),window.addEventListener('message',this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver(function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()})}},{key:"postActiveThemesToAllComponents",value:function(){for(var e,t=S(this.components);!(e=t()).done;){var n=e.value;this.findOrCreateDataForComponent(n.uuid).window&&this.postActiveThemesToComponent(n)}}},{key:"getActiveThemes",value:function(){if(this.environment===he.Mobile)throw Error('getActiveThemes must be handled separately by mobile');return this.componentsForArea(L.ComponentArea.Themes).filter(function(e){return e.active})}},{key:"urlsForActiveThemes",value:function(){for(var e,t=[],n=S(this.getActiveThemes());!(e=n()).done;){var r=e.value,a=this.urlForComponent(r);a&&t.push(a)}return t}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()},n={action:E.ActivateThemes,data:t};this.sendMessageToComponent(e,n)}},{key:"findComponent",value:function(e){return this.templateComponents.find(function(t){return t.uuid===e})||this.itemManager.findItem(e)}},{key:"addTemporaryTemplateComponent",value:function(e){this.templateComponents.push(e)}},{key:"removeTemporaryTemplateComponent",value:function(e){this.templateComponents=this.templateComponents.filter(function(t){return t.uuid!==e.uuid})}},{key:"contextItemDidChangeInArea",value:function(e){for(var t,n=S(this.handlers);!(t=n()).done;){var r=t.value;if(r.areas.includes(e)||r.areas.includes(L.ComponentArea.Any))for(var a,i=S(this.contextStreamObservers.filter(function(t){return t.area===e}));!(a=i()).done;){var s=a.value;if(r.contextRequestHandler){var o=r.contextRequestHandler(s.componentUuid);o&&this.sendContextItemInReply(s.componentUuid,o,s.originalMessage)}}}}},{key:"isComponentHidden",value:function(e){return!0===this.findOrCreateDataForComponent(e.uuid).hidden}},{key:"setComponentHidden",value:function(e,t){var n=this.findOrCreateDataForComponent(e.uuid);if(t)n.hidden=!0;else if(n.hidden){n.hidden=!1;var r=Qt()(this.contextStreamObservers,{identifier:e.uuid});r&&this.handleStreamContextItemMessage(e,r.originalMessage);var a=Qt()(this.streamObservers,{identifier:e.uuid});a&&this.handleStreamItemsMessage(e,a.originalMessage)}}},{key:"jsonForItem",value:function(e,t,n){var r=n===ht.a.RemoteSaved||n===ht.a.LocalSaved||n===ht.a.PreSyncSave,a=(e.getDomainData(rn)||{})[t.getClientDataKey()]||{},i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.serverUpdatedAt,deleted:e.deleted,isMetadataUpdate:r,content:e.content,clientData:a};return this.responseItemsByRemovingPrivateProperties([i],t)[0]}},{key:"sendItemsInReply",value:function(e,t,n,r){var a=this,i=this.findComponent(e);this.log('Component manager send items in reply',i,t,n);var s={},o=t.map(function(e){return a.jsonForItem(e,i,r)});s.items=o,this.replyToMessage(i,n,s)}},{key:"sendContextItemInReply",value:function(e,t,n,r){var a=this.findComponent(e);this.log('Component manager send context item in reply','component:',a,'item: ',t,'originalMessage: ',n);var i={item:this.jsonForItem(t,a,r)};this.replyToMessage(a,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:E.Reply,original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n,r=[E.ComponentRegistered,E.ActivateThemes],a=this.findOrCreateDataForComponent(e.uuid);if(!a.hidden||r.includes(t.action))if(a.window||t.action!==E.Reply){this.log('Component manager send message to component',e,'message: ',t);var i=this.urlForComponent(e);i&&a.window?(i.startsWith('http')||i.startsWith('file')||(i=window.location.href+i),null===(n=a.window)||void 0===n||n.postMessage(this.isMobile?JSON.stringify(t):t,i)):this.alertService.alert("Standard Notes is trying to communicate with ".concat(e.name,", ")+'but an error is occurring. Please restart this extension and try again.')}else this.log('Component has been deallocated in between message send and reply',e,t);else this.log('Component disabled for current item, ignoring messages.',e.name)}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(!t)return null;if(this.isMobile){var n=this.platform===fe.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter(function(t){return t.hosted_url===e||t.legacy_url===e})[0]}},{key:"sessionKeyForComponent",value:function(e){return this.findOrCreateDataForComponent(e.uuid).sessionKey}},{key:"componentForSessionKey",value:function(e){for(var t,n=this,r=function(r){var a=n.componentState[r];if((null===a||void 0===a?void 0:a.sessionKey)===e)return t=n.components.find(function(e){return e.uuid===r}),"break"},a=0,i=Object.keys(this.componentState);a<i.length;a++){if("break"===r(i[a]))break}if(!t)for(var s,o=S(this.handlers);!(s=o()).done;){var c=s.value;if(c.componentForSessionKeyHandler&&(t=c.componentForSessionKeyHandler(e)))break}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log('Component not defined for message, returning',t),void this.alertService.alert("An extension is trying to communicate with Standard Notes, but there is an error establishing a bridge. Please restart the app and try again.");var r=[E.SaveItems,E.AssociateItem,E.DeassociateItem,E.CreateItem,E.CreateItems,E.DeleteItems,E.SetComponentData];if(this.getReadonlyStateForComponent(e).readonly&&r.includes(t.action))this.alertService.alert("The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes."));else{if(t.action===E.StreamItems)this.handleStreamItemsMessage(e,t);else if(t.action===E.StreamContextItem)this.handleStreamContextItemMessage(e,t);else if(t.action===E.SetComponentData)this.handleSetComponentDataMessage(e,t);else if(t.action===E.DeleteItems)this.handleDeleteItemsMessage(e,t);else if(t.action===E.CreateItems||t.action===E.CreateItem)this.handleCreateItemsMessage(e,t);else if(t.action===E.SaveItems)this.handleSaveItemsMessage(e,t);else if(t.action===E.ToggleActivateComponent){var a=this.itemManager.findItem(t.data.uuid);this.handleToggleComponentMessage(a)}else t.action===E.RequestPermissions?this.handleRequestPermissionsMessage(e,t):t.action===E.InstallLocalComponent?this.handleInstallLocalComponentMessage(e,t):t.action===E.DuplicateItem&&this.handleDuplicateItemMessage(e,t);for(var i,s=function(r){r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes(L.ComponentArea.Any))&&n.timeout(function(){r.actionHandler(e,t.action,t.data)})},o=S(this.handlers);!(i=o()).done;){s(i.value)}}}},{key:"responseItemsByRemovingPrivateProperties",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&this.isNativeExtension(t))return e;var r=['autoupdateDisabled','permissions','active'];return n&&(r=r.concat(['hosted_url','local_url'])),e.map(function(e){var t=r.slice();if(n&&e.content_type!==F.a.ServerExtension&&t.push('url'),!e.content||Object(_.A)(e.content))return e;for(var a={},i=0,s=Object.entries(e.content);i<s.length;i++){var o=s[i],c=l(o,2),u=c[0],p=c[1];t.includes(u)||(a[u]=p)}return Zt(Zt({},e),{},{content:a})})}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=t.data.content_types.filter(function(e){return nn.includes(e)}).sort(),a=[{name:E.StreamItems,content_types:r}];this.runWithPermissions(e.uuid,a,function(){Qt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t,contentTypes:r});for(var a,i=[],s=S(r);!(a=s()).done;){var o=a.value;Object(_.o)(i,n.itemManager.nonErroredItemsForContentType(o))}n.sendItemsInReply(e.uuid,i,t)})}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:E.StreamContextItem}];this.runWithPermissions(e.uuid,r,function(){Qt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t});for(var r,a=S(n.handlersForArea(e.area));!(r=a()).done;){var i=r.value;if(i.contextRequestHandler){var s=i.contextRequestHandler(e.uuid);s&&n.sendContextItemInReply(e.uuid,s,t)}}})}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){for(var t,n=[],r=S(this.handlersForArea(e.area));!(t=r()).done;){var a=t.value;if(a.contextRequestHandler){var i=a.contextRequestHandler(e.uuid);i&&n.push(i.uuid)}}return n}},{key:"handlersForArea",value:function(e){return this.handlers.filter(function(t){return t.areas.includes(e)})}},{key:"handleSaveItemsMessage",value:function(e,t){for(var n,r=this,a=t.data.items,i=[],s=this.itemIdsInContextJurisdictionForComponent(e),o=a.slice(),c=S(a.slice());!(n=c()).done;){var u=n.value;if(s.includes(u.uuid)){i.push({name:E.StreamContextItem}),Object(_.M)(o,u);break}}if(o.length>0){var l=$t()(o.map(function(e){return e.content_type})).sort();i.push({name:E.StreamItems,content_types:l})}this.runWithPermissions(e.uuid,i,function(){var n,i,s,o,c,u,l,p,d,h,f,v,y,g,m;return b.async(function(k){for(;;)switch(k.prev=k.next){case 0:a=r.responseItemsByRemovingPrivateProperties(a,e,!0),n=Object(Ke.b)(a),i=r.itemManager.findItems(n,!0),s=0,o=0,c=S(i);case 6:if((u=c()).done){k.next=13;break}if(l=u.value){k.next=10;break}return k.abrupt("continue",11);case 10:l.locked&&(at()(a,{uuid:l.uuid}),s++,l.content_type===F.a.Note&&o++);case 11:k.next=6;break;case 13:if(1!==o){k.next=18;break}return r.alertService.alert('The note you are attempting to save has editing disabled','Note has Editing Disabled'),k.abrupt("return");case 18:if(!(s>0)){k.next=23;break}return p=1===s?'item':o===s?'notes':'items',d=1===s?'has':'have',r.alertService.alert("".concat(s," ").concat(p," you are attempting to save ").concat(d," editing disabled."),'Items have Editing Disabled'),k.abrupt("return");case 23:h=a.map(function(e){return Object(Ee.f)(e,ht.a.ComponentRetrieved)}),f=S(h);case 25:if((v=f()).done){k.next=38;break}if(y=v.value,g=r.itemManager.findItem(y.uuid)){k.next=34;break}return m=nt(y),k.next=32,b.awrap(r.itemManager.insertItem(m));case 32:k.next=36;break;case 34:if(y.content_type===g.content_type){k.next=36;break}throw Error('Extension is trying to modify content type of item.');case 36:k.next=25;break;case 38:return k.next=40,b.awrap(r.itemManager.changeItems(n,function(t){var n=Object(_.O)(h,{uuid:t.getUuid()});t.mergePayload(n);var r=Object(_.O)(a,{uuid:t.getUuid()});if(r.clientData){var i=Object(_.a)(t.getItem().getDomainData(rn)||{});i[e.getClientDataKey()]=r.clientData,t.setDomainData(i,rn)}},T.c.UserInteraction,ht.a.ComponentRetrieved,e.uuid));case 40:r.syncService.sync().then(function(){var n=w({},t);n.action=E.SaveSuccess,r.replyToMessage(e,t,{}),r.handleMessage(e,n)}).catch(function(){var n=w({},t);n.action=E.SaveError,r.replyToMessage(e,t,{error:E.SaveError}),r.handleMessage(e,n)});case 41:case"end":return k.stop()}},null,null,null,Promise)})}},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,a=this.itemManager.findItem(r.uuid),i=[{name:E.StreamItems,content_types:[a.content_type]}];this.runWithPermissions(e.uuid,i,function(){var r;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(n.itemManager.duplicateItem(a.uuid));case 2:r=i.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(r,e)});case 5:case"end":return i.stop()}},null,null,null,Promise)})}},{key:"handleCreateItemsMessage",value:function(e,t){var n=this,r=t.data.item?[t.data.item]:t.data.items,a=$t()(r.map(function(e){return e.content_type})),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:r=n.responseItemsByRemovingPrivateProperties(r,e),a=[],i=function(t){var r,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(t.uuid){o.next=4;break}return o.next=3,b.awrap(I.GenerateUuid());case 3:t.uuid=o.sent;case 4:return r=Object(Ee.f)(t,ht.a.ComponentCreated),i=nt(r),o.next=8,b.awrap(n.itemManager.insertItem(i));case 8:return s=o.sent,o.next=11,b.awrap(n.itemManager.changeItem(s.uuid,function(n){if(t.clientData){var r=Object(_.a)(s.getDomainData(rn)||{});r[e.getClientDataKey()]=t.clientData,n.setDomainData(r,rn)}},T.c.UserInteraction,ht.a.ComponentCreated,e.uuid));case 11:a.push(s);case 12:case"end":return o.stop()}},null,null,null,Promise)},s=S(r);case 4:if((o=s()).done){l.next=10;break}return c=o.value,l.next=8,b.awrap(i(c));case 8:l.next=4;break;case 10:n.syncService.sync(),u=t.action===E.CreateItem?{item:n.jsonForItem(a[0],e)}:{items:a.map(function(t){return n.jsonForItem(t,e)})},n.replyToMessage(e,t,u);case 13:case"end":return l.stop()}},null,null,null,Promise)})}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=t.data.items.filter(function(e){return nn.includes(e.content_type)}),a=$t()(r.map(function(e){return e.content_type})).sort(),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return i=1===(a=r).length?'item':'items',s=null,p.next=5,b.awrap(n.alertService.confirm("Are you sure you want to delete ".concat(a.length," ").concat(i,"?")));case 5:if(!p.sent){p.next=25;break}o=S(a);case 8:if((c=o()).done){p.next=21;break}if(u=c.value,l=n.itemManager.findItem(u.uuid)){p.next=14;break}return n.alertService.alert('The item you are trying to delete cannot be found.'),p.abrupt("continue",19);case 14:if(![F.a.Component,F.a.Theme].includes(l.content_type)){p.next=17;break}return p.next=17,b.awrap(n.deactivateComponent(l.uuid));case 17:return p.next=19,b.awrap(n.itemManager.setItemToBeDeleted(l.uuid,ht.a.ComponentRetrieved));case 19:p.next=8;break;case 21:n.syncService.sync(),s={deleted:!0},p.next=26;break;case 25:s={deleted:!1};case 26:n.replyToMessage(e,t,s);case 27:case"end":return p.stop()}},null,null,null,Promise)})}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,t.data.permissions,function(){n.replyToMessage(e,t,{approved:!0})})}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,[],function(){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(n.itemManager.changeComponent(e.uuid,function(e){e.componentData=t.data.componentData}));case 2:n.syncService.sync();case 3:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"handleToggleComponentMessage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.toggleComponent(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"toggleComponent",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.area!==L.ComponentArea.Modal){s.next=4;break}this.openModalComponent(e),s.next=29;break;case 4:if(!e.active){s.next=9;break}return s.next=7,b.awrap(this.deactivateComponent(e.uuid));case 7:s.next=29;break;case 9:if(e.content_type!==F.a.Theme){s.next=27;break}return t=e,n=this.getActiveThemes(),s.next=14,b.awrap(this.activateComponent(e.uuid));case 14:if(t.isLayerable()){s.next=25;break}return s.next=17,b.awrap(Object(_.P)(10));case 17:r=S(n);case 18:if((a=r()).done){s.next=25;break}if(!(i=a.value)||i.isLayerable()){s.next=23;break}return s.next=23,b.awrap(this.deactivateComponent(i.uuid));case 23:s.next=18;break;case 25:s.next=29;break;case 27:return s.next=29,b.awrap(this.activateComponent(e.uuid));case 29:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.itemManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){var r=this.findComponent(e);t=Object(_.a)(t);for(var a,i=r.permissions,s=function(e){var n=i.find(function(t){return t.name===e.name});if(!n)return"continue";var r=e.content_types;if(!r)return Object(_.p)(t,e),"continue";for(var a,s=S(n.content_types);!(a=s()).done;){var o=a.value;Object(_.M)(r,o)}0===r.length&&Object(_.p)(t,e)},o=S(t.slice());!(a=o()).done;)s(a.value);t.length>0?this.promptForPermissions(r,t,function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:e&&n();case 1:case"end":return t.stop()}},null,null,null,Promise)}):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,a={component:e,permissions:t,permissionsString:this.permissionsStringForPermissions(t,e),actionBlock:n,callback:function(n){var i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(i=r.findComponent(e.uuid),!n){p.next=9;break}for(r.log('Changing component to expand permissions',e),s=Object(_.a)(i.permissions),o=function(e){var t=s.find(function(t){return t.name===e.name});if(t){var n=t.content_types||[];t.content_types=$t()(n.concat(e.content_types))}else s.push(e)},c=S(t);!(u=c()).done;)l=u.value,o(l);return p.next=8,b.awrap(r.itemManager.changeItem(e.uuid,function(e){e.permissions=s}));case 8:r.syncService.sync();case 9:r.permissionDialogs=r.permissionDialogs.filter(function(r){if(r===a)return r.actionBlock&&r.actionBlock(n),!1;var i;return!!(r.component!==e||r.permissions!==t&&(i=t,r.permissions.some(function(e){return!i.find(function(t){return JSON.stringify(t)===JSON.stringify(e)})})))||(n&&r.actionBlock&&r.actionBlock(n),!1)}),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 11:case"end":return p.stop()}},null,null,null,Promise)}},i=Qt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(a),i?this.log('Existing dialog, not presenting.'):this.presentPermissionsDialog(a)}},{key:"presentPermissionsDialog",value:function(e){throw'Must override SNComponentManager.presentPermissionsDialog'}},{key:"openModalComponent",value:function(e){throw'Must override SNComponentManager.openModalComponent'}},{key:"registerHandler",value:function(e){var t=this;return this.handlers.push(e),function(){var n=Qt()(t.handlers,{identifier:e.identifier});n?Object(_.M)(t.handlers,n):t.log('Attempting to deregister non-existing handler')}}},{key:"findOrCreateDataForComponent",value:function(e){var t=this.componentState[e];return t||(t={},this.componentState[e]=t),t}},{key:"setReadonlyStateForComponent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.findOrCreateDataForComponent(e.uuid);r.readonly=t,r.lockReadonly=n}},{key:"getReadonlyStateForComponent",value:function(e){var t=this.findOrCreateDataForComponent(e.uuid);return{readonly:t.readonly,lockReadonly:t.lockReadonly}}},{key:"registerComponentWindow",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return(n=this.findOrCreateDataForComponent(e.uuid)).window===t&&this.log('Web > componentManager','attempting to re-register same component window.'),this.log('Web > componentManager > registerComponentWindow','component: ',e,'window: ',t),n.window=t,r.next=6,b.awrap(I.GenerateUuid());case 6:n.sessionKey=r.sent,this.sendMessageToComponent(e,{action:E.ComponentRegistered,sessionKey:n.sessionKey,componentData:e.componentData,data:{uuid:e.uuid,environment:(s=this.environment,o=void 0,(g(o={},he.Web,'web'),g(o,he.Desktop,'desktop'),g(o,he.Mobile,'mobile'),o)[s]),platform:(a=this.platform,i=void 0,(g(i={},fe.MacWeb,'mac-web'),g(i,fe.MacDesktop,'mac-desktop'),g(i,fe.LinuxWeb,'linux-web'),g(i,fe.LinuxDesktop,'linux-desktop'),g(i,fe.WindowsWeb,'windows-web'),g(i,fe.WindowsDesktop,'windows-desktop'),g(i,fe.Ios,'ios'),g(i,fe.Android,'android'),i)[a]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(e),this.desktopManager&&this.desktopManager.notifyComponentActivation(e);case 10:case"end":return r.stop()}var a,i,s,o},null,this,null,Promise)}},{key:"activateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Activating component',e),(t=this.findComponent(e)).active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!0}));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"onComponentIframeDestroyed",value:function(e){this.deregisterComponent(e)}},{key:"deregisterComponent",value:function(e){this.log('Degregistering component',e),delete this.componentState[e],this.streamObservers=this.streamObservers.filter(function(t){return t.componentUuid!==e}),this.contextStreamObservers=this.contextStreamObservers.filter(function(t){return t.componentUuid!==e});var t=this.findComponent(e);(null===t||void 0===t?void 0:t.area)===L.ComponentArea.Themes&&this.postActiveThemesToAllComponents()}},{key:"deactivateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Deactivating component',e),null===(t=this.findComponent(e))||void 0===t||!t.active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!1}));case 5:this.findOrCreateDataForComponent(e).sessionKey=void 0,this.deregisterComponent(e);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deleteComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isComponentActive",value:function(e){return e.active}},{key:"allComponentIframes",value:function(){return this.isMobile?[]:Array.from(document.getElementsByTagName('iframe'))}},{key:"iframeForComponent",value:function(e){for(var t,n=S(this.allComponentIframes());!(t=n()).done;){var r=t.value;if(r.dataset.componentId===e)return r}}},{key:"handleSetSizeEvent",value:function(e,t){var n=function(e,n){var r=Object(_.A)(n.width)?n.width:"".concat(t.width,"px"),a=Object(_.A)(n.height)?n.height:"".concat(t.height,"px");e&&e.setAttribute('style',"width:".concat(r,"; height:").concat(a,";"))};if(e.area===L.ComponentArea.Rooms||e.area===L.ComponentArea.Modal){var r=e.area===L.ComponentArea.Rooms?'inner':'outer',a=document.getElementById("component-content-".concat(r,"-").concat(e.uuid));a&&n(a,t)}else{var i=this.iframeForComponent(e.uuid);if(!i)return;if(n(i,t),e.area===L.ComponentArea.EditorStack){var s=i.parentElement;s&&n(s,t)}}}},{key:"editorForNote",value:function(e){for(var t,n,r=S(this.componentsForArea(L.ComponentArea.Editor));!(t=r()).done;){var a=t.value;if(a.isExplicitlyEnabledForItem(e.uuid))return a}return this.isMobile?e.mobilePrefersPlainEditor||(n=this.getDefaultEditor()):e.prefersPlainEditor||(n=this.getDefaultEditor()),n&&!n.isExplicitlyDisabledForItem(e.uuid)?n:void 0}},{key:"getDefaultEditor",value:function(){var e=this.componentsForArea(L.ComponentArea.Editor);return this.isMobile?e.filter(function(e){return e.isMobileDefault})[0]:e.filter(function(e){return e.isDefaultEditor()})[0]}},{key:"permissionsStringForPermissions",value:function(e,t){if(0===e.length)return'.';var n=[],r=[];return e.forEach(function(e){switch(e.name){case E.StreamItems:if(!e.content_types)return;e.content_types.forEach(function(e){var t=Object(F.c)(e);t?n.push("".concat(t,"s")):n.push("items of type ".concat(e))});break;case E.StreamContextItem:var a,i=(g(a={},L.ComponentArea.EditorStack,'working note'),g(a,L.ComponentArea.NoteTags,'working note'),g(a,L.ComponentArea.Editor,'working note'),a);r.push(i[t.area])}}),n=$t()(n),r=$t()(r),0===n.length&&0===r.length?'.':n.concat(r).join(', ')+'.'}},{key:"isDesktop",get:function(){return this.environment===he.Desktop}},{key:"isMobile",get:function(){return this.environment===he.Mobile}},{key:"components",get:function(){var e=this.itemManager.getDisplayableItems(F.a.Component),t=this.itemManager.getDisplayableItems(F.a.Theme);return e.concat(t)}}]),n})(R.a),sn=(function(e){d(n,e);var t=k(n);function n(){var e;return v(this,n),(e=t.call(this)).changeObservers=[],e.emitQueue=[],e.overwriteProtection=[F.a.ItemsKey],e.collection=new mt,e}return y(n,[{key:"getMasterCollection",value:function(){return bt.FromCollection(this.collection)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.changeObservers.length=0,this.resetState()}},{key:"resetState",value:function(){this.collection=new mt}},{key:"find",value:function(e){return this.collection.findAll(e)}},{key:"emitCollection",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.emitPayloads(e.all(),e.source,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"emitPayload",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.emitPayloads([e],t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitPayloads",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return 0===e.length&&console.warn('Attempting to emit 0 payloads.'),a.abrupt("return",new Promise(function(a){r.emitQueue.push({payloads:e,source:t,sourceKey:n,resolve:a}),1===r.emitQueue.length&&r.popQueue()}));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"popQueue",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=this.emitQueue[0],t=this.mergePayloadsOntoMaster(e.payloads),n=t.changed,r=t.inserted,a=t.discarded,i=t.ignored,this.notifyChangeObservers(n,r,a,i,e.source,e.sourceKey),Object(_.M)(this.emitQueue,e),e.resolve(n.concat(r,a)),this.emitQueue.length>0&&this.popQueue();case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"mergePayloadsOntoMaster",value:function(e){for(var t,n=[],r=[],a=[],i=[],s=S(e);!(t=s()).done;){var o=t.value;if(o.uuid&&o.content_type){var c=this.collection.find(o.uuid);if(o.errorDecrypting&&c&&!c.errorDecrypting&&this.overwriteProtection.includes(o.content_type))i.push(o);else{var u=c?Object(Ee.g)(c,o):o;u.discardable?(this.collection.discard(u),a.push(u)):(this.collection.set(u),c?n.push(u):r.push(u))}}else console.error('Payload is corrupt:',o)}return{changed:n,inserted:r,discarded:a,ignored:i}}},{key:"addObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var a={types:e,priority:r,callback:t};return this.changeObservers.push(a),function(){Object(_.M)(n.changeObservers,a)}}},{key:"notifyChangeObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return t.includes(F.a.Any)?e.slice():e.slice().filter(function(e){return t.includes(e.content_type)})},c=S(this.changeObservers.slice().sort(function(e,t){return e.priority<t.priority?-1:1}));!(s=c()).done;){var u=s.value;u.callback(o(e,u.types),o(t,u.types),o(n,u.types),o(r,u.types),a,i)}}},{key:"importPayloads",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new Dt(this.getMasterCollection(),bt.WithPayloads(e,ht.a.FileImport),void 0),r.next=3,b.awrap(t.resultingCollection());case 3:return n=r.sent,r.next=6,b.awrap(this.emitCollection(n));case 6:return r.abrupt("return",Object(Ke.b)(n.payloads));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removePayloadLocally",value:function(e){this.collection.discard(e)}}]),n})(R.a),on=n(9),cn=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).itemManager=e,a.syncService=r,a.resolveQueue=[],a.registeredPredicates=[],a.itemManager=e,a.syncService=r,a.addObservers(),a}return y(n,[{key:"deinit",value:function(){this.syncService=void 0,this.itemManager=void 0,this.resolveQueue.length=0,this.registeredPredicates.length=0,this.removeItemObserver(),this.removeItemObserver=void 0,this.removeSyncObserver(),this.removeSyncObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"popResolveQueue",value:function(){var e=this.resolveQueue.slice();return this.resolveQueue=[],e}},{key:"addObservers",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n){if(t.length>0){var r=t.filter(function(e){return e.errorDecryptingValueChanged});r.length>0&&(e.resolveQueue=e.resolveQueue.concat(r))}n.length>0&&(e.resolveQueue=e.resolveQueue.concat(n))}),this.removeSyncObserver=this.syncService.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==on.a.DownloadFirstSyncCompleted&&t!==on.a.FullSyncCompleted){n.next=3;break}return n.next=3,b.awrap(e.resolveSingletonsForItems(e.popResolveQueue(),t));case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"registerPredicate",value:function(e){this.registeredPredicates.push(e)}},{key:"validItemsMatchingPredicate",value:function(e){return this.itemManager.itemsMatchingPredicate(e).filter(function(e){return!e.errorDecrypting})}},{key:"resolveSingletonsForItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=this;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:n=function(e){for(var t,n=S(p.registeredPredicates);!(t=n()).done;){var r=t.value;if(e.satisfiesPredicate(r))return p.validItemsMatchingPredicate(r)}},r=function(e){return e.isSingleton?p.validItemsMatchingPredicate(e.singletonPredicate):null},a=function(e){var t=r(e);return t&&t.length>0?t:n(e)},i=[],s=S(e);case 5:if((o=s()).done){d.next=17;break}if(c=o.value,!i.includes(c)){d.next=9;break}return d.abrupt("continue",15);case 9:if(u=a(c),Object(_.o)(i,u||[]),u&&!(u.length<=1)){d.next=13;break}return d.abrupt("continue",15);case 13:return d.next=15,b.awrap(this.handleStrategy(u,c.singletonStrategy));case 15:d.next=5;break;case 17:if(!(i.length>0&&t===on.a.FullSyncCompleted)){d.next=20;break}return d.next=20,b.awrap(null===(l=this.syncService)||void 0===l?void 0:l.sync());case 20:case"end":return d.stop()}},null,this,null,Promise)}},{key:"handleStrategy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t===T.e.KeepEarliest){a.next=2;break}throw'Unhandled singleton strategy';case 2:return n=e.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at<t.created_at?-1:1}),r=Object(_.d)(n,0),a.next=6,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(r)));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"findSingleton",value:function(e){var t=this.validItemsMatchingPredicate(e);if(t.length>0)return t[0]}},{key:"findOrCreateSingleton",value:function(e,t,n){var r,a,i,s,o,c,u,l=this;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(r=this.findSingleton(e),Object(_.w)(r)){p.next=3;break}return p.abrupt("return",r);case 3:if(this.syncService.getLastSyncDate()){p.next=13;break}return i=this.itemManager.addObserver(t,function(t,n){if(n.length>0){var r=l.itemManager.subItemsMatchingPredicates(n,[e]);r.length>0&&(a=r[0])}}),p.next=7,b.awrap(this.syncService.sync());case 7:if(i(),!a){p.next=10;break}return p.abrupt("return",a);case 10:if(!((s=this.validItemsMatchingPredicate(e)).length>0)){p.next=13;break}return p.abrupt("return",s[0]);case 13:if(!(o=this.itemManager.itemsMatchingPredicate(e).filter(function(e){return e.errorDecrypting})).length){p.next=17;break}return p.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(o)));case 17:return p.t0=Object(Ee.e),p.next=20,b.awrap(I.GenerateUuid());case 20:return p.t1=p.sent,p.t2=t,p.t3=n,p.t4=new Date,p.t5={uuid:p.t1,content_type:p.t2,content:p.t3,dirty:!0,dirtiedDate:p.t4},c=(0,p.t0)(p.t5),p.next=28,b.awrap(this.itemManager.emitItemFromPayload(c));case 28:return u=p.sent,this.syncService.sync(),p.abrupt("return",u);case 31:case"end":return p.stop()}},null,this,null,Promise)}}]),n})(R.a);function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach(function(t){pn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dn,hn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c){var u;return v(this,n),(u=t.call(this)).itemManager=e,u.alertService=r,u.previousPasswords=[],u.itemManager=e,u.alertService=r,u.deviceInterface=a,u.httpService=i,u.payloadManager=s,u.protocolService=o,u.syncService=c,u.previousPasswords=[],u}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.alertService=void 0,this.deviceInterface=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.syncService=void 0,this.previousPasswords.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"getExtensions",value:function(){return this.itemManager.nonErroredItemsForContentType(F.a.ActionsExtension)}},{key:"extensionsInContextOfItem",value:function(e){return this.getExtensions().filter(function(t){return t.supported_types.includes(e.content_type)||t.actionsWithContextForItem(e).length>0})}},{key:"loadExtensionInContextOfItem",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n={content_type:t.content_type,item_uuid:t.uuid},u.next=3,b.awrap(this.httpService.getAbsolute(e.url,n).catch(function(e){return console.error('Error loading extension',e),null}));case 3:if(r=u.sent){u.next=6;break}return u.abrupt("return");case 6:return a=r.description||e.description,i=r.supported_types||e.supported_types,s=r.actions?r.actions.map(function(e){return new ae(e)}):[],(o=new se(e,T.c.UserInteraction)).deprecation=r.deprecation,o.description=a,o.supported_types=i,o.actions=s,c=o.getResult(),u.abrupt("return",nt(c));case 16:case"end":return u.stop()}},null,this,null,Promise)}},{key:"runAction",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=e.verb,a.next='get'===a.t0?3:'render'===a.t0?7:'show'===a.t0?11:'post'===a.t0?15:19;break;case 3:return a.next=5,b.awrap(this.handleGetAction(e,n));case 5:return r=a.sent,a.abrupt("break",20);case 7:return a.next=9,b.awrap(this.handleRenderAction(e,n));case 9:return r=a.sent,a.abrupt("break",20);case 11:return a.next=13,b.awrap(this.handleShowAction(e));case 13:return r=a.sent,a.abrupt("break",20);case 15:return a.next=17,b.awrap(this.handlePostAction(e,t));case 17:return r=a.sent,a.abrupt("break",20);case 19:return a.abrupt("break",20);case 20:return a.abrupt("return",r);case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleGetAction",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.alertService.confirm("Are you sure you want to replace the current note contents with this action's results?"));case 2:if(!n.sent){n.next=7;break}return n.abrupt("return",this.runConfirmedGetAction(e,t));case 7:return n.abrupt("return",{error:{status:1,message:'Action canceled by user.'}});case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"runConfirmedGetAction",value:function(e,t){var n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.httpService.getAbsolute(e.url).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return a.alertService.alert(t.message),{error:t}}));case 2:if(!(n=i.sent).error){i.next=5;break}return i.abrupt("return",n);case 5:return i.next=7,b.awrap(this.payloadByDecryptingResponse(n,t));case 7:return r=i.sent,i.next=10,b.awrap(this.payloadManager.emitPayload(Object(Ee.b)(r,{dirty:!0,dirtiedDate:new Date}),ht.a.RemoteActionRetrieved));case 10:return this.syncService.sync(),i.abrupt("return",ln(ln({},n),{},{item:n.item}));case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleRenderAction",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.httpService.getAbsolute(e.url).then(function(e){var n,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(r.payloadByDecryptingResponse(e,t));case 2:if(!(n=i.sent)){i.next=6;break}return a=nt(n),i.abrupt("return",ln(ln({},e),{},{item:a}));case 6:case"end":return i.stop()}},null,null,null,Promise)}).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return r.alertService.alert(t.message),{error:t}}));case 2:return n=a.sent,a.abrupt("return",n);case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingResponse",value:function(e,t,n){var r,a,i,s,o,c,u,l,p,d,h,f=arguments;return b.async(function(v){for(;;)switch(v.prev=v.next){case 0:return r=f.length>3&&void 0!==f[3]?f[3]:[],a=Object(Ee.e)(e.item),v.next=4,b.awrap(this.protocolService.payloadByDecryptingPayload(a,n));case 4:if((i=v.sent).errorDecrypting){v.next=7;break}return v.abrupt("return",i);case 7:if(s=e.keyParams||e.auth_params){v.next=11;break}return this.alertService.alert("We were unable to decrypt this revision using your current keys, and this revision is missing metadata that would allow us to try different keys to decrypt it. This can likely be fixed with some manual intervention. Please email hello@standardnotes.org for assistance."),v.abrupt("return",void 0);case 11:o=this.protocolService.createKeyParams(s),c=S(this.previousPasswords);case 13:if((u=c()).done){v.next=30;break}if(l=u.value,!r.includes(l)){v.next=17;break}return v.abrupt("continue",28);case 17:return r.push(l),v.next=20,b.awrap(this.protocolService.computeRootKey(l,o));case 20:if(p=v.sent){v.next=23;break}return v.abrupt("continue",28);case 23:return v.next=25,b.awrap(this.payloadByDecryptingResponse(e,t,p,r));case 25:if(!(d=v.sent)){v.next=28;break}return v.abrupt("return",d);case 28:v.next=13;break;case 30:return v.next=32,b.awrap(t());case 32:if(h=v.sent,!this.previousPasswords.includes(h)){v.next=35;break}return v.abrupt("return",void 0);case 35:return this.previousPasswords.push(h),v.abrupt("return",this.payloadByDecryptingResponse(e,t,n));case 37:case"end":return v.stop()}},null,this,null,Promise)}},{key:"handlePostAction",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=e.access_type===q.Decrypted,s.next=3,b.awrap(this.outgoingPayloadForItem(t,n));case 3:return r=s.sent,a={items:[r]},s.abrupt("return",this.httpService.postAbsolute(e.url,a).then(function(e){return e}).catch(function(e){return console.error('Action error response:',e),i.alertService.alert('An issue occurred while processing this action. Please try again.'),e}));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleShowAction",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.deviceInterface.openUrl(e.url),t.abrupt("return",{});case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"outgoingPayloadForItem",value:function(e){var t,n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=a.length>1&&void 0!==a[1]&&a[1],n=t?Re.b.FileDecrypted:Re.b.FileEncrypted,i.next=4,b.awrap(this.protocolService.payloadByEncryptingPayload(e.payloadRepresentation(),n));case 4:return r=i.sent,i.abrupt("return",r.ejected());case 6:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),fn=(function(){function e(t,n,r){v(this,e),this.deviceInterface=t,this.identifier=n,this.environment=r}return y(e,null,[{key:"version",value:function(){throw Error('Must override')}}]),e})(),vn=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getJsonParsedRawStorageValue(D.AllAccountKeyParamsKey));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getRawKeychainValue());case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getRawStorageValue('mk'));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!!Pe(this.environment)}}],[{key:"version",value:function(){return"1.0.0"}}]),n})(),yn=(function(){function e(t){v(this,e),this.services=t,this.stageHandlers={},this.registerStageHandlers()}return y(e,[{key:"registerStageHandler",value:function(e,t){this.stageHandlers[e]=t}},{key:"markDone",value:function(){var e;null===(e=this.onDoneHandler)||void 0===e||e.call(this),this.onDoneHandler=void 0}},{key:"promptForPasscodeUntilCorrect",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new ye([new ge(te.None)],ne.Migration,!1),r.abrupt("return",new Promise(function(r){n.services.challengeService.addChallengeObserver(t,{onNonvalidatedSubmit:function(a){var i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return i=a.values[0],s=i.value,o.next=4,b.awrap(e(s));case 4:o.sent?(n.services.challengeService.completeChallenge(t),r(s)):n.services.challengeService.setValidationStatusForChallenge(t,i,!1);case 6:case"end":return o.stop()}},null,null,null,Promise)}}),n.services.challengeService.promptForChallengeResponse(t)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}},{key:"onDone",value:function(e){this.onDoneHandler=e}},{key:"handleStage",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t=this.stageHandlers[e])){n.next=4;break}return n.next=4,b.awrap(t());case 4:case"end":return n.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){throw'Must override'}}]),e})();!(function(e){e.CreatedAt="created_at",e.UpdatedAt="userModifiedDate",e.Title="title"})(dn||(dn={}));var gn=(function(e){d(n,mt);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).displaySortBy={},e.displayFilter={},e.filteredMap={},e.sortedMap={},e}return y(n,[{key:"set",value:function(e){e=Object(_.W)(Array.isArray(e)?e:[e],'uuid'),p(f(n.prototype),"set",this).call(this,e),this.filterSortElements(e)}},{key:"discard",value:function(e){e=Array.isArray(e)?e:[e],p(f(n.prototype),"discard",this).call(this,e),this.filterSortElements(e)}},{key:"setDisplayOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn.CreatedAt,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc',r=arguments.length>3?arguments[3]:void 0,a=this.displaySortBy[e],i=this.displayFilter[e];if(!a||a.key!==t||a.dir!==n||i||r){this.displaySortBy[e]=t?{key:t,dir:n}:void 0,this.displayFilter[e]=r,this.filteredMap[e]={},this.sortedMap[e]=[];var s=this.all(e);s.length>0&&this.filterSortElements(s)}}},{key:"displayElements",value:function(e){var t=this.sortedMap[e];if(!t)throw Error("Attempting to access display elements for\n        non-configured content type ".concat(e));return t.slice()}},{key:"filterSortElements",value:function(e){if(0!==Object.keys(this.displaySortBy).length){for(var t,n=new Set,r=S(e);!(t=r()).done;){var a=t.value,i=a.content_type,s=this.displaySortBy[i];if(s){var o=this.displayFilter[i],c=this.filteredMap[i],u=this.sortedMap[i],l=c[a.uuid],p=Object(_.w)(l)?void 0:u[l];if(!(a.deleted||!this.map[a.uuid])&&(!o||o(a)))if(Object(_.w)(p))u.push(a),n.add(i);else{var d=p.errorDecrypting?void 0:p[s.key],h=a[s.key];u[l]=a;var f=p.pinned!==a.pinned;Object(_.g)(d,h)&&!f||n.add(i)}else Object(_.w)(l)||(delete c[a.uuid],u[l]=void 0,n.add(i))}}for(var v,y=S(n.values());!(v=y()).done;){var g=v.value;this.resortContentType(g)}}}},{key:"resortContentType",value:function(e){for(var t,n=this.sortedMap[e],r=this.displaySortBy[e],a=this.filteredMap[e],i=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t)return-1;if(!n)return 1;if(!a){if(t.pinned&&n.pinned)return e(t,n,!0);if(t.pinned)return-1;if(n.pinned)return 1}var i=t[r.key]||'',s=n[r.key]||'',o=1;return'asc'===r.dir&&(o*=-1),r.key===dn.Title?o*i.localeCompare(s,'en',{numeric:!0}):i>s?-1*o:i<s?1*o:0},s=[],o=0,c=S(n.sort(function(e,t){return i(e,t)}));!(t=c()).done;){var u=t.value;u&&(s.push(u),a[u.uuid]=o,o++)}this.sortedMap[e]=s}}]),n})();function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(n),!0).forEach(function(t){wn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=(function(e){d(n,yn);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).legacyReader=new vn(r.services.deviceInterface,r.services.identifier,r.services.environment),r}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Se(e.services.environment)){t.next=5;break}return t.next=3,b.awrap(e.migrateStorageStructureForWebDesktop());case 3:t.next=8;break;case 5:if(!Pe(e.services.environment)){t.next=8;break}return t.next=8,b.awrap(e.migrateStorageStructureForMobile());case 8:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.StorageDecrypted_09,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.migrateArbitraryRawStorageToManagedStorageAllPlatforms());case 2:if(!Pe(e.services.environment)){t.next=5;break}return t.next=5,b.awrap(e.migrateMobilePreferences());case 5:return t.next=7,b.awrap(e.migrateSessionStorage());case 7:return t.next=9,b.awrap(e.deleteLegacyStorageValues());case 9:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.LoadingDatabase_11,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createDefaultItemsKeyForAllPlatforms());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"migrateStorageStructureForWebDesktop",value:function(){var e,t,n,r,a,i,s,c,u,l,p,d,h,f,v,y,m,w,k,x,S;return b.async(function(P){for(;;)switch(P.prev=P.next){case 0:return t=this.services.deviceInterface,g(e={},_e.Wrapped,{}),g(e,_e.Unwrapped,{}),g(e,_e.Nonwrapped,{}),n=e,P.next=4,b.awrap(this.legacyReader.getAccountKeyParams());case 4:return(r=P.sent)&&(n.nonwrapped[o.RootKeyParams]=r),P.next=8,b.awrap(t.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 8:if(!(a=P.sent)){P.next=37;break}return i=Object(Ee.e)(a),P.next=13,b.awrap(this.webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage(i));case 13:if(s=P.sent,c=s.key,u=s.decryptedStoragePayload,l=s.keyParams,n.nonwrapped[o.RootKeyWrapperKeyParams]=l.getPortableValue(),p=Object(_.a)(u.contentObject.storage),d=Object(_.E)(p),h=d[D.AllAccountKeyParamsKey],n.nonwrapped[o.RootKeyParams]=h,f=c,!!Object(_.w)(d.mk)){P.next=32;break}return P.next=27,b.awrap(this.webDesktopHelperExtractAndWrapAccountKeysFromValueStore(c,h,d));case 27:v=P.sent,y=v.accountKey,m=v.wrappedKey,f=y,n.nonwrapped[o.WrappedRootKey]=m;case 32:return P.next=34,b.awrap(this.webDesktopHelperEncryptStorage(f,u,d));case 34:n.wrapped=P.sent,P.next=55;break;case 37:return P.next=39,b.awrap(this.services.deviceInterface.getRawStorageValue('ak'));case 39:return w=P.sent,P.next=42,b.awrap(this.services.deviceInterface.getRawStorageValue('mk'));case 42:if(k=P.sent,!w&&!k){P.next=55;break}if(P.t0=null===r||void 0===r?void 0:r.version,P.t0){P.next=49;break}return P.next=48,b.awrap(this.getFallbackRootKeyVersion());case 48:P.t0=P.sent;case 49:return x=P.t0,P.next=52,b.awrap(Ve.Create({masterKey:k,dataAuthenticationKey:w,version:x,keyParams:r}));case 52:return S=P.sent,P.next=55,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(S.getKeychainValue(),this.services.identifier));case 55:return P.next=57,b.awrap(this.allPlatformHelperSetStorageStructure(n));case 57:case"end":return P.stop()}},null,this,null,Promise)}},{key:"allPlatformHelperSetStorageStructure",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Ie.defaultValuesObject(e.wrapped,e.unwrapped,e.nonwrapped))[_e.Unwrapped]=void 0,n.next=4,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.StorageObject),JSON.stringify(t)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.WebPasscodeParamsKey));case 2:return t=s.sent,n=this.services.protocolService.createKeyParams(t),s.next=6,b.awrap(this.promptForPasscodeUntilCorrect(function(t){return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(i.services.protocolService.computeRootKey(t,n));case 2:return a=s.sent,s.next=5,b.awrap(i.services.protocolService.payloadByDecryptingPayload(e,a));case 5:return r=s.sent,s.abrupt("return",!r.errorDecrypting);case 7:case"end":return s.stop()}},null,null,null,Promise)}));case 6:return s.abrupt("return",{decryptedStoragePayload:r,key:a,keyParams:n});case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperExtractAndWrapAccountKeysFromValueStore",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.t0=null===t||void 0===t?void 0:t.version,c.t0){c.next=5;break}return c.next=4,b.awrap(this.getFallbackRootKeyVersion());case 4:c.t0=c.sent;case 5:return a=c.t0,c.next=8,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:a,keyParams:t}));case 8:if(i=c.sent,delete n.mk,delete n.pw,delete n.ak,s=Object(Ee.e)(i),!e){c.next=17;break}return c.next=16,b.awrap(this.services.protocolService.payloadByEncryptingPayload(s,Re.b.LocalStorageEncrypted,e));case 16:o=c.sent;case 17:return c.abrupt("return",{accountKey:i,wrappedKey:null===(r=o)||void 0===r?void 0:r.ejected()});case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperEncryptStorage",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.services.protocolService.payloadByEncryptingPayload(Object(Ee.b)(t,{content_type:F.a.EncryptedStorage,content:n}),Re.b.LocalStoragePreferEncrypted,e));case 2:return r=a.sent,a.abrupt("return",r.ejected());case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"migrateStorageStructureForMobile",value:function(){var e,t,n,r,a,i,s,u,l,p,d,h,f,v,y,m,w,k,x,S,P,O,C,E,R=this;return b.async(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,b.awrap(this.services.deviceInterface.getRawKeychainValue());case 2:return n=M.sent,M.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileWrappedRootKeyKey));case 5:if(M.t0=M.sent,M.t0){M.next=8;break}M.t0=null===n||void 0===n?void 0:n.encryptedAccountKeys;case 8:return r=M.t0,M.next=11,b.awrap(this.legacyReader.getAccountKeyParams());case 11:return a=M.sent,M.next=14,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 14:return i=M.sent,M.next=17,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(c.MobileFirstRun));case 17:return s=M.sent,g(t={},_e.Nonwrapped,(g(e={},o.WrappedRootKey,r),g(e,o.RootKeyWrapperKeyParams,Object(_.I)(i,['hash'])),g(e,o.RootKeyParams,a),g(e,c.MobileFirstRun,s),e)),g(t,_e.Unwrapped,{}),g(t,_e.Wrapped,{}),u=t,M.next=21,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileBiometricsPrefs));case 21:return(l=M.sent)&&(u.nonwrapped[o.BiometricsState]=l.enabled,u.nonwrapped[o.MobileBiometricsTiming]=l.timing),M.next=25,b.awrap(this.services.deviceInterface.getRawStorageValue(D.MobilePasscodeKeyboardType));case 25:if((p=M.sent)&&(u.nonwrapped[o.MobilePasscodeKeyboardType]=p),!i){M.next=75;break}if(h=this.services.protocolService.createKeyParams(i),f=function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(R.promptForPasscodeUntilCorrect(function(t){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(R.services.protocolService.computeRootKey(t,h));case 2:if(e=u.sent,!(i=null===n||void 0===n?void 0:null===(a=n.offline)||void 0===a?void 0:a.pw)){u.next=8;break}return u.abrupt("return",e.serverPassword===i);case 8:if(!r){u.next=15;break}return u.next=11,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),e));case 11:return s=u.sent,u.abrupt("return",!s.errorDecrypting);case 15:return u.next=17,b.awrap(R.services.deviceInterface.getAllRawDatabasePayloads(R.services.identifier));case 17:if(o=u.sent[0]){u.next=20;break}throw Error('Passcode only migration aborting due to missing keychain.offline.pw');case 20:return u.next=22,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(o),e));case 22:return c=u.sent,u.abrupt("return",!c.errorDecrypting);case 24:case"end":return u.stop()}},null,null,null,Promise)}));case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},null,null,null,Promise)},u.nonwrapped[o.MobilePasscodeTiming]=null===n||void 0===n?void 0:null===(d=n.offline)||void 0===d?void 0:d.timing,!r){M.next=55;break}return M.next=34,b.awrap(f());case 34:return v=M.sent,M.next=37,b.awrap(this.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),v));case 37:if(y=M.sent,m=y.contentObject.accountKeys,M.t1=m.version||(null===a||void 0===a?void 0:a.version),M.t1){M.next=44;break}return M.next=43,b.awrap(this.getFallbackRootKeyVersion());case 43:M.t1=M.sent;case 44:return w=M.t1,k=Object(Ee.b)(y,{content:{masterKey:m.mk,dataAuthenticationKey:m.ak,version:w,keyParams:a,accountKeys:void 0}}),M.next=48,b.awrap(this.services.protocolService.payloadByEncryptingPayload(k,Re.b.LocalStoragePreferEncrypted,v));case 48:return x=M.sent,u.nonwrapped[o.WrappedRootKey]=x.ejected(),m.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",m.jwt),M.next=53,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 53:M.next=73;break;case 55:if(r){M.next=73;break}return M.next=58,b.awrap(f());case 58:return S=M.sent,M.t2=Object(Ee.e),M.next=62,b.awrap(I.GenerateUuid());case 62:return M.t3=M.sent,M.t4=Object(Ke.a)(u.unwrapped),M.t5=F.a.EncryptedStorage,M.t6={uuid:M.t3,content:M.t4,content_type:M.t5},P=(0,M.t2)(M.t6),M.next=69,b.awrap(this.services.protocolService.payloadByEncryptingPayload(P,Re.b.LocalStoragePreferEncrypted,S));case 69:return O=M.sent,u.wrapped=O.ejected(),M.next=73,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 73:M.next=89;break;case 75:if(!!Object(_.w)(null===n||void 0===n?void 0:n.mk)){M.next=89;break}if(M.t7=n.version||(null===a||void 0===a?void 0:a.version),M.t7){M.next=82;break}return M.next=81,b.awrap(this.getFallbackRootKeyVersion());case 81:M.t7=M.sent;case 82:return C=M.t7,M.next=85,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:C,keyParams:a}));case 85:return E=M.sent,M.next=88,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(E.getKeychainValue(),this.services.identifier));case 88:n.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",n.jwt);case 89:return M.next=91,b.awrap(this.allPlatformHelperSetStorageStructure(u));case 91:case"end":return M.stop()}},null,this,null,Promise)}},{key:"getFallbackRootKeyVersion",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.services.deviceInterface.getAllRawDatabasePayloads(this.services.identifier));case 2:if(e=n.sent[0]){n.next=5;break}return n.abrupt("return",Q.a.V002);case 5:return t=Object(Ee.e)(e),n.abrupt("return",t.version||Q.a.V002);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateArbitraryRawStorageToManagedStorageAllPlatforms",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getAllRawStorageKeyValues());case 2:e=p.sent,t=Object(_.H)(D),n=function(e){try{return JSON.parse(e)}catch(t){return e}},r=this.services.identifier,a=S(e);case 7:if((i=a()).done){p.next=20;break}if(s=i.value,o=s.key,c=s.value,u=r&&r.length>0&&o.startsWith(r),!t.includes(o)&&!u){p.next=14;break}return p.abrupt("continue",18);case 14:if(Object(_.w)(c)){p.next=18;break}return l=n(c),p.next=18,b.awrap(this.services.storageService.setValue(o,l));case 18:p.next=7;break;case 20:case"end":return p.stop()}},null,this,null,Promise)}},{key:"deleteLegacyStorageValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e=['mk','ak','pw','encryptionKey','authKey','jwt','ephemeral','cachedThemes'],t=[].concat(m(Object(_.H)(o)),m(Object(_.H)(D)),e),n=S(t);case 3:if((r=n()).done){i.next=9;break}return a=r.value,i.next=7,b.awrap(this.services.deviceInterface.removeRawStorageValue(a));case 7:i.next=3;break;case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"migrateMobilePreferences",value:function(){var e,t,n,r,a,i,s,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileLastExportDate));case 2:return e=p.sent,p.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileDoNotWarnUnsupportedEditors));case 5:return t=p.sent,p.next=8,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileOptionsState));case 8:return n=p.sent,r={},n&&(u=n.sortBy,r={sortBy:'updated_at'===u||'client_updated_at'===u?dn.UpdatedAt:u,sortReverse:null!==(a=n.sortReverse)&&void 0!==a&&a,hideNotePreview:null!==(i=n.hidePreviews)&&void 0!==i&&i,hideDate:null!==(s=n.hideDates)&&void 0!==s&&s,hideTags:null!==(c=n.hideTags)&&void 0!==c&&c}),l=bn(bn({},r),{},{lastExportDate:null!==e&&void 0!==e?e:void 0,doNotShowAgainUnsupportedEditors:null!==t&&void 0!==t&&t}),p.next=14,b.awrap(this.services.storageService.setValue(o.MobilePreferences,l));case 14:case"end":return p.stop()}},null,this,null,Promise)}},{key:"migrateSessionStorage",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return e='user',i.next=3,b.awrap(this.services.storageService.getValue("jwt"));case 3:return t=i.sent,i.next=6,b.awrap(this.services.storageService.getValue(e));case 6:if(n=i.sent,t||n&&(t=n.jwt),t){i.next=15;break}if(!!Object(_.w)(n)){i.next=14;break}t='junk-value',i.next=15;break;case 14:return i.abrupt("return");case 15:return r=new Ae(t),i.next=18,b.awrap(this.services.storageService.setValue(o.Session,r));case 18:if(!Pe(this.services.environment)){i.next=25;break}return i.next=21,b.awrap(this.services.storageService.getValue(e));case 21:if(!(a=i.sent)||!a.server){i.next=25;break}return i.next=25,b.awrap(this.services.storageService.setValue(o.ServerHost,a.server));case 25:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createDefaultItemsKeyForAllPlatforms",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e=this.services.protocolService.getRootKey())){i.next=18;break}return i.next=4,b.awrap(this.services.protocolService.getRootKeyParams());case 4:return t=i.sent,n=Q.a.V001,i.t0=Object(Ee.e),i.next=9,b.awrap(I.GenerateUuid());case 9:return i.t1=i.sent,i.t2=F.a.ItemsKey,i.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t.version||n}),i.t4=new Date,i.t5={uuid:i.t1,content_type:i.t2,content:i.t3,dirty:!0,dirtiedDate:i.t4},r=(0,i.t0)(i.t5),a=nt(r),i.next=18,b.awrap(this.services.itemManager.emitItemFromPayload(a.payloadRepresentation(),ht.a.LocalChanged));case 18:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return"2.0.0"}}]),n})(),xn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createNewDefaultItemsKeyIfNecessary());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"createNewDefaultItemsKeyIfNecessary",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.services.protocolService.needsNewRootKeyBasedItemsKey()){e.next=3;break}return e.next=3,b.awrap(this.services.protocolService.createNewDefaultItemsKey());case 3:case"end":return e.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.0.15'}}]),n})(),Sn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.FullSyncCompleted_13,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteBatchManagerSingleton());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteBatchManagerSingleton",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e='org.standardnotes.batch-manager',t=H.a.CompoundPredicate([new H.a('content_type','=',F.a.Component),new H.a('package_info.identifier','=',e)]),!(n=this.services.singletonManager.findSingleton(t))){r.next=6;break}return r.next=6,b.awrap(this.services.itemManager.setItemToBeDeleted(n.uuid));case 6:case"end":return r.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.7.0'}}]),n})(),Pn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteMfaItems());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteMfaItems",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e='SF|MFA',t=this.services.itemManager.getItems(e),n=S(t);case 3:if((r=n()).done){i.next=10;break}return a=r.value,this.services.itemManager.removeItemLocally(a),i.next=8,b.awrap(this.services.storageService.deletePayloadWithId(a.uuid));case 8:i.next=3;break;case 10:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.20.0'}}]),n})(),On=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getStorage",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=O(this.identifier,s.StorageObject),r.next=3,b.awrap(this.deviceInterface.getRawStorageValue(e));case 3:return t=r.sent,n=t?JSON.parse(t):void 0,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getNonWrappedValue",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getStorage());case 2:if(n=r.sent){r.next=5;break}return r.abrupt("return",void 0);case 5:return r.abrupt("return",null===(t=n[_e.Nonwrapped])||void 0===t?void 0:t[e]);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getNonWrappedValue(o.RootKeyParams));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getNonWrappedValue(o.WrappedRootKey));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!0}}],[{key:"version",value:function(){return"2.0.0"}}]),n})();function Cn(e){for(var t,n=S(Object.values(i).sort(function(e,t){return-1*P(e.version(),t.version())}));!(t=n()).done;){var r=t.value;if(r.version()===e)return r;if(x(r.version(),e))return r}throw Error("Cannot find reader for version ".concat(e))}function Dn(e,t,n,r){return new(Cn(e))(t,n,r)}var _n=(function(e){d(n,yn);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).didPreRun=!1,e}return y(n,[{key:"preRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storeVersionNumber());case 2:this.didPreRun=!0;case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.needsKeychainRepair());case 2:if(!t.sent){t.next=5;break}return t.next=5,b.awrap(e.repairMissingKeychain());case 5:e.markDone();case 6:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"getStoredVersion",value:function(){var e=O(this.services.identifier,s.SnjsVersion);return this.services.deviceInterface.getRawStorageValue(e)}},{key:"storeVersionNumber",value:function(){var e,t,n,r,a,i,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return e=O(this.services.identifier,s.SnjsVersion),c.next=3,b.awrap(this.getStoredVersion());case 3:if(c.sent){c.next=38;break}t=!1,n=0,r=['migrations','ephemeral','user','cachedThemes','syncToken','encryptedStorage'];case 8:if(!(n<r.length)){c.next=19;break}return a=r[n],c.next=12,b.awrap(this.services.deviceInterface.getRawStorageValue(a));case 12:if(!c.sent){c.next=16;break}return t=!0,c.abrupt("break",19);case 16:n++,c.next=8;break;case 19:if(!t){c.next=24;break}return c.next=22,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"1.0.0"));case 22:c.next=38;break;case 24:return i=O(this.services.identifier,"last_migration_timestamp"),c.next=27,b.awrap(this.services.deviceInterface.getRawStorageValue(i));case 27:if(o=c.sent,!!Object(_.w)(o)){c.next=36;break}return c.next=32,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"2.0.0"));case 32:return c.next=34,b.awrap(this.services.deviceInterface.removeRawStorageValue("last_migration_timestamp"));case 34:c.next=38;break;case 36:return c.next=38,b.awrap(this.services.deviceInterface.setRawStorageValue(e,h));case 38:case"end":return c.stop()}},null,this,null,Promise)}},{key:"loadReader",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.reader){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,b.awrap(this.getStoredVersion());case 4:e=t.sent,this.reader=Dn(e,this.services.deviceInterface,this.services.identifier,this.services.environment);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"needsKeychainRepair",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.didPreRun){t.next=2;break}throw Error('Attempting to access specialized function before prerun');case 2:if(this.reader){t.next=5;break}return t.next=5,b.awrap(this.loadReader());case 5:if(this.reader.usesKeychain){t.next=8;break}return t.abrupt("return",!1);case 8:return t.next=10,b.awrap(this.reader.getAccountKeyParams());case 10:if(e=t.sent,!Object(_.w)(e)){t.next=14;break}return t.abrupt("return",!1);case 14:return t.next=16,b.awrap(this.reader.hasPasscode());case 16:if(!t.sent){t.next=19;break}return t.abrupt("return",!1);case 19:return t.next=21,b.awrap(this.reader.hasNonWrappedAccountKeys());case 21:if(!t.sent){t.next=24;break}return t.abrupt("return",!1);case 24:return t.abrupt("return",!0);case 25:case"end":return t.stop()}},null,this,null,Promise)}},{key:"repairMissingKeychain",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getStoredVersion());case 2:return e=a.sent,a.next=5,b.awrap(this.reader.getAccountKeyParams());case 5:return t=a.sent,n=new ye([new ge(te.None,void 0,j.R.PasswordInputPlaceholder,!0)],ne.Custom,!1,j.I.Title,j.I.Text),a.abrupt("return",new Promise(function(a){r.services.challengeService.addChallengeObserver(n,{onNonvalidatedSubmit:function(i){var s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return s=i.values[0].value,o=r.services.protocolService.createKeyParams(t),d.next=4,b.awrap(r.services.protocolService.computeRootKey(s,o));case 4:return c=d.sent,d.next=7,b.awrap(r.services.deviceInterface.getAllRawDatabasePayloads(r.services.identifier));case 7:if(u=d.sent,(l=u.find(function(e){var t=Object(Ee.e)(e);return Object(Re.a)(t.content_type)}))||(l=u[0]),l){d.next=12;break}throw we.a.error(Error('Attempting keychain recovery validation but no items present.'));case 12:return d.next=14,b.awrap(r.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(l),c));case 14:if(!d.sent.errorDecrypting){d.next=19;break}r.services.challengeService.setValidationStatusForChallenge(n,i.values[0],!1),d.next=29;break;case 19:if("1.0.0"!==e){d.next=24;break}return d.next=22,b.awrap(r.services.deviceInterface.legacy_setRawKeychainValue({mk:c.masterKey,ak:c.dataAuthenticationKey,version:o.version}));case 22:d.next=27;break;case 24:return p=c.getKeychainValue(),d.next=27,b.awrap(r.services.deviceInterface.setNamespacedKeychainValue(p,r.services.identifier));case 27:a(),r.services.challengeService.completeChallenge(n);case 29:case"end":return d.stop()}},null,null,null,Promise)}}),r.services.challengeService.promptForChallengeResponse(n)}));case 8:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(),En=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).services=e,r}return y(n,[{key:"deinit",value:function(){this.services=void 0,this.activeMigrations&&(this.activeMigrations.length=0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.runBaseMigrationPreRun());case 2:return r.t0=b,r.t1=n,r.next=6,b.awrap(this.getStoredSnjsVersion());case 6:return r.t2=r.sent,r.t3=r.t1.getRequiredMigrations.call(r.t1,r.t2),r.next=10,r.t0.awrap.call(r.t0,r.t3);case 10:if(e=r.sent,this.activeMigrations=this.instantiateMigrationClasses(e),!(this.activeMigrations.length>0)){r.next=17;break}Object(_.F)(this.activeMigrations).onDone(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(t.markMigrationsAsDone());case 2:case"end":return e.stop()}},null,null,null,Promise)}),r.next=19;break;case 17:return r.next=19,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 19:case"end":return r.stop()}},null,this,null,Promise)}},{key:"markMigrationsAsDone",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"runBaseMigrationPreRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.baseMigration=new _n(this.services),e.next=3,b.awrap(this.baseMigration.preRun());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:return t.next=4,b.awrap(this.handleStage(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleApplicationEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.a.SignedIn){t.next=3;break}return t.next=3,b.awrap(this.handleStage(ve.SignedIn_30));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPendingMigrations",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=n,t.next=4,b.awrap(this.getStoredSnjsVersion());case 4:return t.t2=t.sent,t.t3=t.t1.getRequiredMigrations.call(t.t1,t.t2),t.next=8,t.t0.awrap.call(t.t0,t.t3);case 8:if(e=t.sent,t.t4=e.length>0,t.t4){t.next=14;break}return t.next=13,b.awrap(this.baseMigration.needsKeychainRepair());case 13:t.t4=t.sent;case 14:return t.abrupt("return",t.t4);case 15:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getStoredSnjsVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.services.deviceInterface.getRawStorageValue(O(this.services.identifier,s.SnjsVersion)));case 2:if(e=t.sent){t.next=5;break}throw we.a.error(Error('Snjs version missing from storage, run base migration.'));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"instantiateMigrationClasses",value:function(e){var t=this;return e.map(function(e){return new e(t.services)})}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.baseMigration.handleStage(e));case 2:t=S(this.activeMigrations);case 3:if((n=t()).done){a.next=9;break}return r=n.value,a.next=7,b.awrap(r.handleStage(e));case 7:a.next=3;break;case 9:case"end":return a.stop()}},null,this,null,Promise)}}],[{key:"getRequiredMigrations",value:function(e){var t,n,r,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:t=[],n=Object.keys(a).map(function(e){return a[e]}).sort(function(e,t){return P(e.version(),t.version())}),r=S(n);case 3:if((i=r()).done){c.next=11;break}if(s=i.value,(o=s.version())!==e){c.next=8;break}return c.abrupt("continue",9);case 8:x(e,o)&&t.push(s);case 9:c.next=3;break;case 11:return c.abrupt("return",t);case 12:case"end":return c.stop()}},null,null,null,Promise)}}]),n})(R.a),Rn=n(14),In=(function(){function e(t){v(this,e),this.crypto=t}return y(e,[{key:"firstHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"secondHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"splitKey",value:function(e,t){for(var n=e.length/t,r=[],a=0;a<t;a++){var i=e.slice(n*a,n*(a+1));r.push(i)}return r}},{key:"createItemsKey",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.generateNewItemsKeyContent());case 2:return e=n.sent,n.t0=Object(Ee.e),n.next=6,b.awrap(I.GenerateUuid());case 6:return n.t1=n.sent,n.t2=F.a.ItemsKey,n.t3=Object(Ke.a)(e),n.t4={uuid:n.t1,content_type:n.t2,content:n.t3},t=(0,n.t0)(n.t4),n.abrupt("return",nt(t));case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,n){var r,a,i;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==ue.a.DecryptedBareObject){n.next=4;break}return n.abrupt("return",Object(Ee.c)({content:e.content}));case 4:if(t!==ue.a.DecryptedBase64String){n.next=13;break}return r=JSON.stringify(e.content),n.next=8,b.awrap(this.crypto.base64Encode(r));case 8:return a=n.sent,i=Q.a.V000Base64Decrypted+a,n.abrupt("return",Object(Ee.c)({content:i}));case 13:throw"Must override generateEncryptedParameters to handle format ".concat(t,".");case 14:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var n,r,a,i;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=e.format)!==ue.a.DecryptedBareObject){t.next=5;break}return t.abrupt("return",e);case 5:if(n!==ue.a.DecryptedBase64String){t.next=20;break}return r=e.contentString.substring(Q.a.VersionLength,e.contentString.length),t.prev=7,t.next=10,b.awrap(this.crypto.base64Decode(r));case 10:i=t.sent,a=JSON.parse(i),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),a=e.content;case 17:return t.abrupt("return",Object(Ee.a)(e,{content:a}));case 20:throw Error("Must override generateDecryptedParameters to handle format ".concat(n,"."));case 21:case"end":return t.stop()}},null,this,[[7,14]],Promise)}}]),e})(),Mn='00000000000000000000000000000000',An=(function(e){d(n,In);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'AES-256'}},{key:"generateNewItemsKeyContent",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=Rn.a.EncryptionKeyLength,r.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=r.sent,n={itemsKey:t,version:Q.a.V001},r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Rn.a.PbkdfMinCost,o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.a.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+'SN'+a));case 6:return i=o.sent,s=Object(A.a)({email:e,pw_cost:r,pw_nonce:a,pw_salt:i,version:Q.a.V001,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcDecrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"encryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcEncrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c,u,l;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){d.next=2;break}return d.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){d.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r){d.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return d.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.a.EncryptionKeyLength));case 8:return a=d.sent,d.next=11,b.awrap(this.encryptString(a,r.itemsKey));case 11:return i=d.sent,d.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=d.sent,d.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=d.sent,d.next=20,b.awrap(this.encryptString(JSON.stringify(e.content),s));case 20:return c=d.sent,u=r.keyVersion+c,d.next=24,b.awrap(this.crypto.hmac256(u,o));case 24:return l=d.sent,d.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:u,enc_item_key:i,auth_hash:l}));case 26:case"end":return d.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){l.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:return a=e.enc_item_key,a=this.version+a,i=this.encryptionComponentsFromString(a,t.itemsKey),l.next=11,b.awrap(this.decryptString(i.ciphertext,i.key));case 11:if(s=l.sent){l.next=15;break}return console.error('Error decrypting parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 15:return l.next=17,b.awrap(this.firstHalfOfKey(s));case 17:return o=l.sent,c=this.encryptionComponentsFromString(e.contentString,o),l.next=21,b.awrap(this.decryptString(c.ciphertext,c.key));case 21:if(u=l.sent){l.next=26;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 27:case"end":return l.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString",value:function(e,t){var n=e.substring(0,Q.a.VersionLength);return{ciphertext:e.substring(Q.a.VersionLength,e.length),version:n,key:t}}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content001.pw_salt,t.content001.pw_cost,Rn.a.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,2),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],version:Q.a.V001,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V001}}]),n})();function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach(function(t){Kn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=(function(e){d(n,An);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.b.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V002},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Object(_.F)(Rn.b.PbkdfCostsUsed),o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.b.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+':'+a));case 6:return i=o.sent,s=Object(A.b)({email:e,pw_nonce:a,pw_cost:r,pw_salt:i,version:Q.a.V002,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcDecrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcEncrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptTextParams",value:function(e,t,n,r,a,i){var s,o,c,u,l,p,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,b.awrap(this.crypto.generateRandomKey(Rn.b.EncryptionIvLength));case 2:return s=h.sent,h.next=5,b.awrap(this.encryptString002(e,t,s));case 5:return o=h.sent,c=[a,r,s,o].join(':'),h.next=9,b.awrap(this.crypto.hmac256(c,n));case 9:if(u=h.sent,l=[a,u,r,s,o],!i){h.next=16;break}return h.next=14,b.awrap(this.crypto.base64Encode(JSON.stringify(i.content)));case 14:p=h.sent,l.push(p);case 16:return d=l.join(':'),h.abrupt("return",d);case 18:case"end":return h.stop()}},null,this,null,Promise)}},{key:"decryptTextParams",value:function(e,t,n,r,a,i){var s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n){o.next=2;break}throw'Attempting to decryptTextParams with null encryptionKey';case 2:return o.next=4,b.awrap(this.crypto.hmac256(e,i));case 4:if(s=o.sent,!1!==this.crypto.timingSafeEqual(a,s)){o.next=8;break}return we.a.error(Error('Auth hash does not match.')),o.abrupt("return",null);case 8:return o.abrupt("return",this.decryptString002(t,n,r));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(t=this.encryptionComponentsFromString002(e.enc_item_key),n=t.keyParams){i.next=4;break}return i.abrupt("return",void 0);case 4:return i.t0=JSON,i.next=7,b.awrap(this.crypto.base64Decode(n));case 7:return i.t1=i.sent,r=i.t0.parse.call(i.t0,i.t1),a=Tn({},r),i.abrupt("return",a);case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r&&r.itemsKey){u.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return u.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.b.EncryptionKeyLength));case 8:return a=u.sent,u.next=11,b.awrap(this.encryptTextParams(a,r.itemsKey,r.dataAuthenticationKey,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 11:return i=u.sent,u.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=u.sent,u.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=u.sent,u.next=20,b.awrap(this.encryptTextParams(JSON.stringify(e.content),s,o,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 20:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:c,enc_item_key:i}));case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u,l,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){h.next=3;break}return h.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){h.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:if(t&&t.itemsKey){h.next=8;break}throw Error('Attempting to generateDecryptedParameters with no itemsKey.');case 8:return a=e.enc_item_key,i=this.encryptionComponentsFromString002(a,t.itemsKey,t.dataAuthenticationKey),h.next=12,b.awrap(this.decryptTextParams(i.ciphertextToAuth,i.contentCiphertext,i.encryptionKey,i.iv,i.authHash,i.authKey));case 12:if(s=h.sent){h.next=16;break}return console.error('Error decrypting item_key parameters',e),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 16:return h.next=18,b.awrap(this.firstHalfOfKey(s));case 18:return o=h.sent,h.next=21,b.awrap(this.secondHalfOfKey(s));case 21:return c=h.sent,u=this.encryptionComponentsFromString002(e.contentString,o,c),h.next=25,b.awrap(this.decryptTextParams(u.ciphertextToAuth,u.contentCiphertext,u.encryptionKey,u.iv,u.authHash,u.authKey));case 25:if(l=h.sent){h.next=30;break}return h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 30:return h.prev=30,h.t0=JSON,h.next=34,b.awrap(this.crypto.base64Decode(u.keyParams));case 34:h.t1=h.sent,d=h.t0.parse.call(h.t0,h.t1),h.next=40;break;case 38:h.prev=38,h.t2=h.catch(30);case 40:return h.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(l),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,auth_params:d,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 41:case"end":return h.stop()}},null,this,[[30,38]],Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content002.pw_salt,t.content002.pw_cost,Rn.b.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,3),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],dataAuthenticationKey:r[2],version:Q.a.V002,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString002",value:function(e,t,n){var r=e.split(':');return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],keyParams:r[5],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(':'),encryptionKey:t,authKey:n}}},{key:"version",get:function(){return Q.a.V002}}]),n})(),Ln=(function(e){d(n,Fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.c.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V003},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.generateSalt(t.content003.identifier,Q.a.V003,Rn.c.PbkdfCost,t.content003.pw_nonce));case 2:return n=s.sent,s.next=5,b.awrap(this.crypto.pbkdf2(e,n,Rn.c.PbkdfCost,Rn.c.PbkdfOutputLength));case 5:return r=s.sent,a=this.splitKey(r,3),s.next=9,b.awrap(Ve.Create({serverPassword:a[0],masterKey:a[1],dataAuthenticationKey:a[2],version:Q.a.V003,keyParams:t.getPortableValue()}));case 9:return i=s.sent,s.abrupt("return",i);case 11:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V003,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.c.SaltSeedLength));case 3:return a=s.sent,i=Object(A.c)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"generateSalt",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.sha256([e,'SF',t,n,r].join(':')));case 2:return a=i.sent,i.abrupt("return",a);case 4:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V003}}]),n})();function Un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach(function(t){Vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bn,Wn=(function(e){d(n,Ln);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'XChaCha20-Poly1305'}},{key:"generateNewItemsKeyContent",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 2:return e=n.sent,t={itemsKey:e,version:Q.a.V004},n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateSalt004",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.crypto.sha256([e,t].join(":")));case 2:return n=r.sent,r.abrupt("return",Object(_.T)(n,Rn.d.ArgonSaltLength));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V004,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.d.ArgonSaltSeedLength));case 3:return a=s.sent,i=Object(A.d)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"encryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n){a.next=2;break}throw'encryptString null nonce';case 2:if(t){a.next=4;break}throw'encryptString null rawKey';case 4:return a.t0=this.crypto,a.t1=e,a.t2=n,a.t3=t,a.next=10,b.awrap(this.authenticatedDataToString(r));case 10:return a.t4=a.sent,a.abrupt("return",a.t0.xchacha20Encrypt.call(a.t0,a.t1,a.t2,a.t3,a.t4));case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.crypto.xchacha20Decrypt(e,n,t,r));case 1:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateEncryptedProtocolString",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionNonceLength));case 2:return r=o.sent,a=Q.a.V004,o.next=6,b.awrap(this.encryptString004(e,t,r,n));case 6:return i=o.sent,o.t0=a,o.t1=r,o.t2=i,o.next=12,b.awrap(this.authenticatedDataToString(n));case 12:return o.t3=o.sent,s=[o.t0,o.t1,o.t2,o.t3],o.abrupt("return",s.join(":"));case 15:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.format===ue.a.EncryptedString){a.next=2;break}throw Error('Attempting to get embedded key params of already decrypted item');case 2:return t=this.deconstructEncryptedPayloadString(e.enc_item_key),n=t.rawAuthenticatedData,a.next=6,b.awrap(this.stringToAuthenticatedData(n));case 6:return r=a.sent,a.abrupt("return",r);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateAuthenticatedDataForPayload",value:function(e,t){var n={u:e.uuid,v:Q.a.V004};if(Object(Re.a)(e.content_type))return Nn(Nn({},n),{},{kp:t.keyParams.content});if(!(t instanceof J))throw Error('Attempting to use non-items key for regular item.');return n}},{key:"authenticatedDataToString",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.base64Encode(JSON.stringify(Object(_.Q)(Object(_.K)(e)))));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"stringToAuthenticatedData",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=JSON,r.next=3,b.awrap(this.crypto.base64Decode(e));case 3:return r.t1=r.sent,n=r.t0.parse.call(r.t0,r.t1),r.abrupt("return",Object(_.Q)(Nn(Nn({},n),t)));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(e.uuid){u.next=6;break}throw'payload.uuid cannot be null';case 6:if(r&&r.itemsKey){u.next=8;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 8:return u.next=10,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 10:return a=u.sent,i=JSON.stringify(e.content),s=this.generateAuthenticatedDataForPayload(e,r),u.next=15,b.awrap(this.generateEncryptedProtocolString(i,a,s));case 15:return o=u.sent,u.next=18,b.awrap(this.generateEncryptedProtocolString(a,r.itemsKey,s));case 18:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:o,enc_item_key:c}));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.uuid){l.next=5;break}throw'encryptedParameters.uuid cannot be null';case 5:if(t&&t.itemsKey){l.next=7;break}throw'Attempting to generateDecryptedParameters with no itemsKey.';case 7:return a=this.deconstructEncryptedPayloadString(e.enc_item_key),l.next=10,b.awrap(this.stringToAuthenticatedData(a.rawAuthenticatedData,{u:e.uuid,v:e.version}));case 10:return i=l.sent,l.next=13,b.awrap(this.authenticatedDataToString(i));case 13:return s=l.sent,l.next=16,b.awrap(this.decryptString004(a.ciphertext,t.itemsKey,a.nonce,s));case 16:if(o=l.sent){l.next=20;break}return console.error('Error decrypting itemKey parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 20:return c=this.deconstructEncryptedPayloadString(e.contentString),l.next=23,b.awrap(this.decryptString004(c.ciphertext,o,c.nonce,s));case 23:if(u=l.sent){l.next=28;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 28:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 29:case"end":return l.stop()}},null,this,null,Promise)}},{key:"deconstructEncryptedPayloadString",value:function(e){var t=e.split(":");return{version:t[0],nonce:t[1],ciphertext:t[2],rawAuthenticatedData:t[3]}}},{key:"deriveKey",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.generateSalt004(t.content004.identifier,t.content004.pw_nonce));case 2:return n=o.sent,o.next=5,b.awrap(this.crypto.argon2(e,n,Rn.d.ArgonIterations,Rn.d.ArgonMemLimit,Rn.d.ArgonOutputKeyBytes));case 5:return r=o.sent,a=this.splitKey(r,2),i=a[0],s=a[1],o.abrupt("return",Ve.Create({masterKey:i,serverPassword:s,version:Q.a.V004,keyParams:t.getPortableValue()}));case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V004}}]),n})();function Hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(n),!0).forEach(function(t){qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e[e.RootKeyNone=0]="RootKeyNone",e[e.RootKeyOnly=1]="RootKeyOnly",e[e.RootKeyPlusWrapper=2]="RootKeyPlusWrapper",e[e.WrapperOnly=3]="WrapperOnly"})(Bn||(Bn={}));var Yn=Q.a.V003,Gn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).itemManager=e,c.payloadManager=r,c.storageService=i,c.identifier=s,c.operators={},c.keyMode=Bn.RootKeyNone,c.keyObservers=[],c.itemManager=e,c.payloadManager=r,c.deviceInterface=a,c.storageService=i,c.crypto=o,Object(_.y)()?I.SetGenerators(c.crypto.generateUUID,void 0):I.SetGenerators(c.crypto.generateUUID,c.crypto.generateUUIDSync),Object.defineProperty(u(c),'rootKey',{enumerable:!1,writable:!0}),c.removeItemsObserver=c.itemManager.addObserver([F.a.ItemsKey],function(e,t){e.concat(t).length>0&&c.decryptErroredItems()}),c}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.deviceInterface=void 0,this.storageService=void 0,this.crypto.deinit(),this.crypto=void 0,this.operators={},this.keyObservers.length=0,this.removeItemsObserver(),this.removeItemsObserver=null,this.rootKey=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:return e=a.sent,a.next=5,b.awrap(this.getAccountKeyParams());case 5:return t=a.sent,a.next=8,b.awrap(this.hasRootKeyWrapper());case 8:if(n=a.sent,r=!Object(_.w)(e)||!Object(_.w)(t),!n||!r){a.next=14;break}this.keyMode=Bn.RootKeyPlusWrapper,a.next=27;break;case 14:if(!n||r){a.next=18;break}this.keyMode=Bn.WrapperOnly,a.next=27;break;case 18:if(n||!r){a.next=22;break}this.keyMode=Bn.RootKeyOnly,a.next=27;break;case 22:if(n||r){a.next=26;break}this.keyMode=Bn.RootKeyNone,a.next=27;break;case 26:throw'Invalid key mode condition';case 27:if(this.keyMode!==Bn.RootKeyOnly){a.next=33;break}return a.next=30,b.awrap(this.getRootKeyFromKeychain());case 30:return this.rootKey=a.sent,a.next=33,b.awrap(this.notifyObserversOfKeyChange());case 33:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getEncryptionSourceVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasAccount()){t.next=4;break}return t.abrupt("return",this.getUserVersion());case 4:if(!this.hasPasscode()){t.next=9;break}return t.next=7,b.awrap(this.getRootKeyWrapperKeyParams());case 7:return e=t.sent,t.abrupt("return",e.version);case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getEncryptionDisplayName",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getEncryptionSourceVersion());case 2:if(!(e=t.sent)){t.next=5;break}return t.abrupt("return",this.operatorForVersion(e).getEncryptionDisplayName());case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLatestVersion",value:function(){return Q.a.V004}},{key:"hasAccount",value:function(){switch(this.keyMode){case Bn.RootKeyNone:case Bn.WrapperOnly:return!1;case Bn.RootKeyOnly:case Bn.RootKeyPlusWrapper:return!0;default:throw Error("Unhandled keyMode value '".concat(this.keyMode,"'."))}}},{key:"getUserVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getAccountKeyParams());case 2:return e=t.sent,t.abrupt("return",null===e||void 0===e?void 0:e.version);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"upgradeAvailable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.accountUpgradeAvailable());case 2:return e=n.sent,n.next=5,b.awrap(this.passcodeUpgradeAvailable());case 5:return t=n.sent,n.abrupt("return",e||t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"accountUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"passcodeUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e.version!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"platformSupportsKeyDerivation",value:function(e){return Object(Q.b)(e.version,Q.a.V004)>=0||(!!Object(_.C)()||Object(_.y)())}},{key:"supportedVersions",value:function(){return[Q.a.V001,Q.a.V002,Q.a.V003,Q.a.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.getLatestVersion();return 1===Object(Q.b)(e,t)}},{key:"isProtocolVersionOutdated",value:function(e){var t,n=(g(t={},Q.a.V001,Date.parse('2018-01-01')),g(t,Q.a.V002,Date.parse('2020-01-01')),t)[e];return!!n&&(new Date).getTime()>n}},{key:"costMinimumForVersion",value:function(e){if(Object(Q.b)(e,Q.a.V003)>=0)throw'Cost minimums only apply to versions <= 002';if(e===Q.a.V001)return Rn.a.PbkdfMinCost;if(e===Q.a.V002)return Rn.b.PbkdfMinCost;throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===Q.a.V001)return new An(this.crypto);if(e===Q.a.V002)return new Fn(this.crypto);if(e===Q.a.V003)return new Ln(this.crypto);if(e===Q.a.V004)return new Wn(this.crypto);if(e===Q.a.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw Error("Unable to find operator for version ".concat(e))}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=t.version,r=this.operatorForVersion(n),a.abrupt("return",r.computeRootKey(e,t));case 3:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return a=r?this.operatorForVersion(r):this.defaultOperator(),i.abrupt("return",a.createRootKey(e,t,n));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"payloadContentFormatForIntent",value:function(e,t){if(t){if(e===Re.b.Sync||e===Re.b.FileEncrypted||e===Re.b.FilePreferEncrypted||e===Re.b.LocalStorageEncrypted||e===Re.b.LocalStoragePreferEncrypted)return ue.a.EncryptedString;throw'Unhandled encrypted case in protocolService.payloadContentFormatForIntent.'}if(e===Re.b.LocalStorageDecrypted||e===Re.b.LocalStoragePreferEncrypted||e===Re.b.FileDecrypted||e===Re.b.FilePreferEncrypted)return ue.a.DecryptedBareObject;if(e===Re.b.SyncDecrypted)return ue.a.DecryptedBase64String;throw'Unhandled decrypted case in protocolService.payloadContentFormatForIntent.'}},{key:"payloadByEncryptingPayload",value:function(e,t,n){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(!e.errorDecrypting){l.next=2;break}return l.abrupt("return",e);case 2:if(!e.deleted){l.next=4;break}return l.abrupt("return",e);case 4:if(!Object(_.w)(t)){l.next=6;break}throw Error('Attempting to encrypt payload with null intent');case 6:if(n||Object(Re.d)(t)){l.next=10;break}return l.next=9,b.awrap(this.keyToUseForEncryptionOfPayload(e,t));case 9:n=l.sent;case 10:if(n||!Object(Re.c)(t)){l.next=12;break}throw Error('Attempting to generate encrypted payload with no key.');case 12:if(e.format===ue.a.DecryptedBareObject){l.next=14;break}throw Error('Attempting to encrypt already encrypted payload.');case 14:if(e.content){l.next=16;break}throw Error('Attempting to encrypt payload with no content.');case 16:if(e.uuid){l.next=18;break}throw Error('Attempting to encrypt payload with no uuid.');case 18:if(!(null!==(r=n)&&void 0!==r&&r.errorDecrypting||null!==(a=n)&&void 0!==a&&a.waitingForKey)){l.next=20;break}throw Error('Attempting to encrypt payload with encrypted key.');case 20:return i=n?n.keyVersion:this.getLatestVersion(),s=this.payloadContentFormatForIntent(t,n),o=this.operatorForVersion(i),l.next=25,b.awrap(o.generateEncryptedParameters(e,s,n));case 25:if(c=l.sent){l.next=28;break}throw'Unable to generate encryption parameters';case 28:return u=Object(Ee.d)(e,t,c),l.abrupt("return",u);case 30:case"end":return l.stop()}},null,this,null,Promise)}},{key:"payloadsByEncryptingPayloads",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){u.next=11;break}return s=i.value,o=Object(_.v)(t)?t(s):t,u.next=7,b.awrap(this.payloadByEncryptingPayload(s,o,n));case 7:c=u.sent,r.push(c);case 9:u.next=2;break;case 11:return u.abrupt("return",r);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingPayload",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content){c.next=3;break}return we.a.error(Error('Attempting to decrypt payload that has no content.')),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0}));case 3:if((r=e.format)!==ue.a.DecryptedBareObject){c.next=6;break}return c.abrupt("return",e);case 6:if(t||r!==ue.a.EncryptedString){c.next=10;break}if(t=this.keyToUseForDecryptionOfPayload(e)){c.next=10;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 10:if(null===(n=t)||void 0===n||!n.errorDecrypting){c.next=12;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 12:return a=e.version,i=e.source,s=this.operatorForVersion(a),c.prev=15,c.next=18,b.awrap(s.generateDecryptedParameters(e,t));case 18:return o=c.sent,c.abrupt("return",Object(Ee.e)(e,o,i));case 22:return c.prev=22,c.t0=c.catch(15),console.error('Error decrypting payload',e,c.t0),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:case"end":return c.stop()}},null,this,[[15,22]],Promise)}},{key:"payloadsByDecryptingPayloads",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e){n.next=2;break}return n.abrupt("return",e);case 2:if(!0!==e.deleted||!Object(_.w)(e.content)){n.next=4;break}return n.abrupt("return",e);case 4:if(Object(_.A)(e.content)){n.next=7;break}return n.abrupt("return",e);case 7:return n.abrupt("return",r.payloadByDecryptingPayload(e,t));case 8:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",Promise.all(e.map(function(e){return n(e)})));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"decryptErroredItems",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==(e=this.itemManager.invalidItems.filter(function(e){return e.content_type!==F.a.ItemsKey})).length){r.next=3;break}return r.abrupt("return");case 3:return t=e.map(function(e){return e.payloadRepresentation()}),r.next=6,b.awrap(this.payloadsByDecryptingPayloads(t));case 6:return n=r.sent,r.next=9,b.awrap(this.payloadManager.emitPayloads(n,ht.a.LocalChanged));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsByDecryptingBackupFile",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v=this;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if(n=e.keyParams||e.auth_params,r=e.items,a=r.map(function(e){return Object(Ee.f)(e,ht.a.FileImport)}),i=[],!n){y.next=28;break}return s=this.createKeyParams(n),y.next=8,b.awrap(this.computeRootKey(t,s));case 8:return o=y.sent,c=a.filter(function(e){return e.content_type===F.a.ItemsKey}),y.next=12,b.awrap(this.payloadsByDecryptingPayloads(c,o));case 12:u=y.sent,l=u.map(function(e){return nt(e)}),Object(_.o)(i,u),p=function(e){var t,n,r,a;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content_type!==F.a.ItemsKey){c.next=2;break}return c.abrupt("return","continue");case 2:return c.prev=2,e.items_key_id&&(t=v.itemsKeyForPayload(e)),t||(n=u.find(function(t){return e.items_key_id===t.uuid}),r=e.version,n?t=nt(n):Object(Q.d)(s.version,Q.a.V004)?t=v.defaultItemsKeyForItemVersion(r,l):Object(Q.b)(r,Q.a.V003)<=0&&(t=o)),c.next=7,b.awrap(v.payloadByDecryptingPayload(e,t));case 7:a=c.sent,i.push(a),c.next=15;break;case 11:c.prev=11,c.t0=c.catch(2),i.push(Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting})),console.error('Error decrypting payload',e,c.t0);case 15:case"end":return c.stop()}},null,null,[[2,11]],Promise)},d=S(a);case 17:if((h=d()).done){y.next=26;break}return f=h.value,y.next=21,b.awrap(p(f));case 21:if("continue"!==y.sent){y.next=24;break}return y.abrupt("continue",24);case 24:y.next=17;break;case 26:y.next=29;break;case 28:i=a;case 29:return y.abrupt("return",i);case 30:case"end":return y.stop()}},null,this,null,Promise)}},{key:"createKeyParams",value:function(e){return Object(A.e)(e)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return t=this.itemManager.items,e===Re.b.FileDecrypted&&(t=t.filter(function(e){return e.content_type!==F.a.ItemsKey})),n=Promise.all(t.map(function(t){if(t.errorDecrypting)return t.payload.ejected();var n=Object(Ee.f)(t.payload,ht.a.FileImport);return i.payloadByEncryptingPayload(n,e).then(function(e){return e.ejected()})})),s.t0=this.getLatestVersion(),s.next=6,b.awrap(n);case 6:if(s.t1=s.sent,r={version:s.t0,items:s.t1},e!==Re.b.FileEncrypted){s.next=13;break}return s.next=11,b.awrap(this.getRootKeyParams());case 11:a=s.sent,r.keyParams=null===a||void 0===a?void 0:a.getPortableValue();case 13:return s.abrupt("return",r);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"onKeyStatusChange",value:function(e){var t=this;return this.keyObservers.push(e),function(){Object(_.M)(t.keyObservers,e)}}},{key:"notifyObserversOfKeyChange",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:e=S(this.keyObservers);case 1:if((t=e()).done){r.next=7;break}return n=t.value,r.next=5,b.awrap(n());case 5:r.next=1;break;case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getRootKeyFromKeychain",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:if(e=n.sent,!Object(_.w)(e)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.t0=b,n.t1=Ve,n.t2=zn,n.t3=zn({},e),n.t4={},n.next=12,b.awrap(this.getRootKeyParams());case 12:return n.t5=n.sent,n.t6={keyParams:n.t5},n.t7=(0,n.t2)(n.t3,n.t4,n.t6),n.t8=n.t1.Create.call(n.t1,n.t7),n.next=18,n.t0.awrap.call(n.t0,n.t8);case 18:return t=n.sent,n.abrupt("return",t);case 20:case"end":return n.stop()}},null,this,null,Promise)}},{key:"saveRootKeyToKeychain",value:function(){var e,t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Object(_.w)(this.rootKey)){n.next=2;break}throw'Attempting to non-existent root key to the keychain.';case 2:if(this.keyMode===Bn.RootKeyOnly){n.next=4;break}throw'Should not be persisting wrapped key to keychain.';case 4:return e=this.rootKey.getKeychainValue(),n.abrupt("return",this.executeCriticalFunction(function(){return t.deviceInterface.setNamespacedKeychainValue(e,t.identifier)}));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasRootKeyWrapper",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){return this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper}},{key:"rootKeyNeedsUnwrapping",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.hasRootKeyWrapper());case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}e.t0=Object(_.w)(this.rootKey);case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyWrapperKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getWrappedRootKey",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.WrappedRootKey,De.Nonwrapped));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode!==Bn.WrapperOnly){e.next=4;break}return e.abrupt("return",this.getRootKeyWrapperKeyParams());case 4:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){e.next=8;break}return e.abrupt("return",this.getAccountKeyParams());case 8:if(this.keyMode!==Bn.RootKeyNone){e.next=12;break}return e.abrupt("return",void 0);case 12:throw"Unhandled key mode for getRootKeyParams ".concat(this.keyMode);case 13:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateWrappingKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:if(t=a.sent,this.keyMode!==Bn.WrapperOnly){a.next=7;break}return a.abrupt("return",this.storageService.canDecryptWithKey(e));case 7:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){a.next=15;break}return n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:return r=a.sent,a.abrupt("return",!r.errorDecrypting);case 15:throw'Unhandled case in validateWrappingKey';case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeWrappingKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=r.sent,r.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=r.sent,r.abrupt("return",n);case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"unwrapRootKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.keyMode!==Bn.WrapperOnly){a.next=3;break}return this.rootKey=e,a.abrupt("return");case 3:if(this.keyMode===Bn.RootKeyPlusWrapper){a.next=5;break}throw'Invalid key mode condition for unwrapping.';case 5:return a.next=7,b.awrap(this.getWrappedRootKey());case 7:return t=a.sent,n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:if(!(r=a.sent).errorDecrypting){a.next=16;break}throw Error('Unable to decrypt root key with provided wrapping key.');case 16:return a.next=18,b.awrap(Ve.Create(r.contentObject,r.uuid));case 18:return this.rootKey=a.sent,a.next=21,b.awrap(this.notifyObserversOfKeyChange());case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setNewRootKeyWrapper",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.keyMode!==Bn.RootKeyNone){t.next=4;break}this.keyMode=Bn.WrapperOnly,t.next=9;break;case 4:if(this.keyMode!==Bn.RootKeyOnly){t.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,t.next=9;break;case 8:throw Error('Attempting to set wrapper on already wrapped key.');case 9:return t.next=11,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 11:if(this.keyMode!==Bn.WrapperOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){t.next=26;break}if(this.keyMode!==Bn.WrapperOnly){t.next=18;break}return this.rootKey=e,t.next=16,b.awrap(this.reencryptItemsKeys());case 16:t.next=20;break;case 18:return t.next=20,b.awrap(this.wrapAndPersistRootKey(e));case 20:return t.next=22,b.awrap(this.storageService.setValue(o.RootKeyWrapperKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 22:return t.next=24,b.awrap(this.notifyObserversOfKeyChange());case 24:t.next=27;break;case 26:throw Error('Invalid keyMode on setNewRootKeyWrapper');case 27:case"end":return t.stop()}},null,this,null,Promise)}},{key:"wrapAndPersistRootKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=Object(Ee.e)(this.rootKey,{content:this.rootKey.persistableValueWhenWrapping()}),r.next=3,b.awrap(this.payloadByEncryptingPayload(t,Re.b.LocalStorageEncrypted,e));case 3:return n=r.sent,r.next=6,b.awrap(this.storageService.setValue(o.WrappedRootKey,n.ejected(),De.Nonwrapped));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removeRootKeyWrapper",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper){e.next=2;break}throw Error('Attempting to remove root key wrapper on unwrapped key.');case 2:return this.keyMode===Bn.WrapperOnly?(this.keyMode=Bn.RootKeyNone,this.rootKey=void 0):this.keyMode===Bn.RootKeyPlusWrapper&&(this.keyMode=Bn.RootKeyOnly),e.next=5,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 5:return e.next=7,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 7:if(this.keyMode!==Bn.RootKeyOnly){e.next=10;break}return e.next=10,b.awrap(this.saveRootKeyToKeychain());case 10:return e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.keyParams){n.next=2;break}throw Error('keyParams must be supplied if setting root key.');case 2:if(this.rootKey!==e){n.next=4;break}throw Error('Attempting to set root key as same current value.');case 4:if(this.keyMode!==Bn.WrapperOnly){n.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,n.next=16;break;case 8:if(this.keyMode!==Bn.RootKeyNone){n.next=12;break}this.keyMode=Bn.RootKeyOnly,n.next=16;break;case 12:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){n.next=15;break}n.next=16;break;case 15:throw Error("Unhandled key mode for setNewRootKey ".concat(this.keyMode));case 16:return this.rootKey=e,n.next=19,b.awrap(this.storageService.setValue(o.RootKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 19:if(this.keyMode!==Bn.RootKeyOnly){n.next=24;break}return n.next=22,b.awrap(this.saveRootKeyToKeychain());case 22:n.next=29;break;case 24:if(this.keyMode!==Bn.RootKeyPlusWrapper){n.next=29;break}if(t){n.next=27;break}throw Error('wrappingKey must be supplied');case 27:return n.next=29,b.awrap(this.wrapAndPersistRootKey(t));case 29:return n.next=31,b.awrap(this.notifyObserversOfKeyChange());case 31:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getRootKey",value:function(){return this.rootKey}},{key:"clearLocalKeyState",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 2:return e.next=4,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 6:return e.next=8,b.awrap(this.storageService.removeValue(o.RootKeyParams,De.Nonwrapped));case 8:return this.keyMode=Bn.RootKeyNone,this.rootKey=void 0,e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:if(n=a.sent,!(r=this.rootKey.compare(n))){a.next=11;break}return a.abrupt("return",{valid:r,artifacts:{rootKey:n}});case 11:return a.abrupt("return",{valid:!1});case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"validatePasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=a.sent,a.next=8,b.awrap(this.validateWrappingKey(n));case 8:if(!(r=a.sent)){a.next=13;break}return a.abrupt("return",{valid:r,artifacts:{wrappingKey:n}});case 13:return a.abrupt("return",{valid:!1});case 14:case"end":return a.stop()}},null,this,null,Promise)}},{key:"keyToUseForEncryptionOfPayload",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Object(_.w)(t)){s.next=2;break}throw'Intent must be supplied when looking up key for encryption of item.';case 2:if(!Object(Re.a)(e.content_type)){s.next=13;break}if(n=this.getRootKey()){s.next=10;break}if(!Object(Re.c)(t)){s.next=9;break}throw Error('Root key encryption is required but no root key is available.');case 9:return s.abrupt("return",void 0);case 10:return s.abrupt("return",n);case 13:return r=this.getDefaultItemsKey(),s.next=16,b.awrap(this.getUserVersion());case 16:if(!(a=s.sent)||a===(null===r||void 0===r?void 0:r.keyVersion)){s.next=22;break}return i=this.latestItemsKeys(),s.abrupt("return",i.find(function(e){return e.keyVersion===a}));case 22:return s.abrupt("return",r);case 23:case"end":return s.stop()}},null,this,null,Promise)}},{key:"keyToUseForDecryptionOfPayload",value:function(e){if(Object(Re.a)(e.content_type))return this.getRootKey();if(e.items_key_id)return this.itemsKeyForPayload(e);var t=e.version;if(t!==this.getLatestVersion())return this.defaultItemsKeyForItemVersion(t);we.a.error(Error('No associated key found for item encrypted with latest protocol version.'))}},{key:"onSyncEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.b.FullSyncCompleted){t.next=3;break}return t.next=3,b.awrap(this.handleFullSyncCompletion());case 3:if(e!==At.b.DownloadFirstSyncCompleted){t.next=6;break}return t.next=6,b.awrap(this.handleDownloadFirstSyncCompletion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleDownloadFirstSyncCompletion",value:function(){var e,t,n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.hasAccount()){c.next=2;break}return c.abrupt("return");case 2:if(e=this.latestItemsKeys(),t=e.filter(function(e){return e.neverSynced}),n=e.filter(function(e){return!e.neverSynced}),r=n.find(function(e){return e.isDefault}),!!Object(_.w)(r)){c.next=12;break}return c.next=10,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(t)));case 10:c.next=21;break;case 12:if(!(a=this.getRootKey())){c.next=21;break}if(!((i=t.filter(function(e){return e.keyVersion!==a.keyVersion})).length>0)){c.next=18;break}return c.next=18,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(i)));case 18:if(0!==this.latestItemsKeys().length){c.next=21;break}return c.next=21,b.awrap(this.createNewDefaultItemsKey());case 21:return c.next=23,b.awrap(this.getUserVersion());case 23:if(s=c.sent,o=this.latestItemsKeys().find(function(e){return e.keyVersion===s}),!Object(_.w)(o)){c.next=28;break}return c.next=28,b.awrap(this.createNewDefaultItemsKey());case 28:this.syncUnsycnedItemsKeys();case 29:case"end":return c.stop()}},null,this,null,Promise)}},{key:"handleFullSyncCompletion",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,b.awrap(this.createNewDefaultItemsKey());case 4:if(this.keyMode!==Bn.WrapperOnly){e.next=6;break}return e.abrupt("return",this.repersistAllItems());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"syncUnsycnedItemsKeys",value:function(){if(this.hasAccount()){var e=this.latestItemsKeys().filter(function(e){return e.neverSynced&&!e.dirty&&!e.deleted});e.length>0&&this.itemManager.setItemsDirty(Object(Ke.b)(e))}}},{key:"repersistAllItems",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e)}),n.abrupt("return",this.storageService.savePayloads(t));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"latestItemsKeys",value:function(){return this.itemManager.itemsKeys()}},{key:"itemsKeyForPayload",value:function(e){return this.latestItemsKeys().find(function(t){return t.uuid===e.items_key_id||t.duplicateOf===e.items_key_id})}},{key:"getDefaultItemsKey",value:function(){var e=this.latestItemsKeys();if(1===e.length)return e[0];var t=e.filter(function(e){return e.isDefault});if(t.length>1){var n=t.filter(function(e){return!e.neverSynced});if(n.length,n.length>0)return n[0]}return t[0]}},{key:"getKeyEmbeddedKeyParams",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.payload.format!==ue.a.DecryptedBareObject){s.next=2;break}return s.abrupt("return",void 0);case 2:return t=e.version,n=this.operatorForVersion(t),s.next=6,b.awrap(n.getPayloadAuthenticatedData(e.payload));case 6:if(r=s.sent){s.next=9;break}return s.abrupt("return",void 0);case 9:if(!Object(Q.c)(t,Q.a.V003)){s.next=14;break}return a=r,s.abrupt("return",this.createKeyParams(a));case 14:return i=r.kp,s.abrupt("return",this.createKeyParams(i));case 16:case"end":return s.stop()}},null,this,null,Promise)}},{key:"reencryptItemsKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!((e=this.latestItemsKeys()).length>0)){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"defaultItemsKeyForItemVersion",value:function(e,t){var n=t||this.latestItemsKeys(),r=n.find(function(t){return t.isDefault&&t.keyVersion===e});return r||n.find(function(t){return t.keyVersion===e})}},{key:"needsNewRootKeyBasedItemsKey",value:function(){if(!this.hasAccount())return!1;var e=this.getRootKey();if(!e)return!1;if(Object(Q.b)(e.keyVersion,Yn)>0)return!1;var t=this.getDefaultItemsKey();return!t||t.itemsKey!==e.itemsKey}},{key:"createNewDefaultItemsKey",value:function(){var e,t,n,r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e=this.getRootKey(),t=e?e.keyVersion:this.getLatestVersion(),!(Object(Q.b)(t,Yn)<=0)){l.next=14;break}return l.t0=Object(Ee.e),l.next=6,b.awrap(I.GenerateUuid());case 6:l.t1=l.sent,l.t2=F.a.ItemsKey,l.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t}),l.t4={uuid:l.t1,content_type:l.t2,content:l.t3},r=(0,l.t0)(l.t4),n=nt(r),l.next=17;break;case 14:return l.next=16,b.awrap(this.operatorForVersion(t).createItemsKey());case 16:n=l.sent;case 17:a=this.latestItemsKeys(),i=a.filter(function(e){return e.isDefault}),s=S(i);case 20:if((o=s()).done){l.next=26;break}return c=o.value,l.next=24,b.awrap(this.itemManager.changeItemsKey(c.uuid,function(e){e.isDefault=!1}));case 24:l.next=20;break;case 26:return l.next=28,b.awrap(this.itemManager.insertItem(n));case 28:return u=l.sent,l.next=31,b.awrap(this.itemManager.changeItemsKey(u.uuid,function(e){e.isDefault=!0}));case 31:return l.abrupt("return",u);case 32:case"end":return l.stop()}},null,this,null,Promise)}},{key:"createNewItemsKeyWithRollback",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=this.getDefaultItemsKey(),a.next=3,b.awrap(this.createNewDefaultItemsKey());case 3:return t=a.sent,n=function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(Promise.all([r.itemManager.setItemToBeDeleted(t.uuid),r.itemManager.changeItem(e.uuid,function(e){e.isDefault=!0})]));case 2:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getPasswordCreatedDate",value:function(){var e=this.getRootKey();return e?e.keyParams.createdDate:void 0}}]),n})(R.a),Qn=(function(){function e(t,n){v(this,e),this.defaultContentKeyToDiffOn='text',this.payload=Object(Ee.b)(t),this.previousEntry=n,this.hasPreviousEntry=!Object(_.w)(n);var r=this.payload.content[this.defaultContentKeyToDiffOn];this.textCharDiffLength=r?n?r.length-n.payload.content[this.defaultContentKeyToDiffOn].length:this.payload.content[this.defaultContentKeyToDiffOn].length:0}return y(e,[{key:"itemFromPayload",value:function(){return nt(this.payload)}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=this.itemFromPayload(),n=e.itemFromPayload();return!(t.userModifiedDate.getTime()!==n.userModifiedDate.getTime())&&t.isItemContentEqualWith(n)}},{key:"isDiscardable",value:function(){return!1}},{key:"operationVector",value:function(){return void 0!==this.textCharDiffLength?this.hasPreviousEntry&&0!==this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!==this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}}]),e})(),Jn=(function(e){d(n,Qn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"previewTitle",value:function(){return this.payload.updated_at.getTime()>0?this.payload.updated_at.toLocaleString():this.payload.created_at.toLocaleString()}},{key:"previewSubTitle",value:function(){return this.hasPreviousEntry?this.textCharDiffLength<0?"".concat(-1*this.textCharDiffLength," characters removed"):this.textCharDiffLength>0?"".concat(this.textCharDiffLength," characters added"):'Title or metadata changed':"".concat(this.textCharDiffLength," characters loaded")}},{key:"isDiscardable",value:function(){return Object(_.t)(this.payload.safeContent.text)}}]),n})();function $n(e,t){return new(Xn(e[Je.a.ContentType]))(e,t)}function Xn(e){switch(e){case F.a.Note:return Jn;default:return Qn}}var Zn,er,tr=20,nr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s){var o;return v(this,n),(o=t.call(this)).itemManager=e,o.storageService=r,o.apiService=a,o.protocolService=i,o.deviceInterface=s,o.persistable=!1,o.autoOptimize=!1,o.historyStaging={},o.history={},o.historyTypes=[F.a.Note],o.itemRevisionThreshold=tr,o.removeChangeObserver=o.itemManager.addObserver(o.historyTypes,function(e,t){o.recordNewHistoryForItems(e.concat(t))}),o}return y(n,[{key:"deinit",value:function(){this.cancelPendingPersist(),this.itemManager=void 0,this.storageService=void 0,this.history=void 0,this.removeChangeObserver&&(this.removeChangeObserver(),this.removeChangeObserver=void 0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.SessionHistoryPersistable));case 2:return this.persistable=e.sent,e.next=5,b.awrap(this.getPersistedHistory());case 5:return this.history=e.sent,e.next=8,b.awrap(this.storageService.getValue(o.SessionHistoryOptimize,void 0,!0));case 8:this.autoOptimize=e.sent;case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPersistedHistory",value:function(){var e,t,n,r,a,i,s,c,u,p,d,h,f,v,y,g;return b.async(function(m){for(;;)switch(m.prev=m.next){case 0:return e={},m.next=3,b.awrap(this.storageService.getValue(o.SessionHistoryRevisions));case 3:if(t=m.sent){m.next=6;break}return m.abrupt("return",e);case 6:for(n=0,r=Object.entries(t);n<r.length;n++){for(a=r[n],i=l(a,2),s=i[0],c=i[1],u=c.slice().reverse(),p=[],d=S(u);!(h=d()).done;)f=h.value,v=Object(Ee.f)(f.payload,ht.a.SessionHistory),y=yt(p),g=$n(v,y),p.unshift(g);e[s]=p}return m.abrupt("return",e);case 8:case"end":return m.stop()}},null,this,null,Promise)}},{key:"recordNewHistoryForItems",value:function(e){for(var t,n=!1,r=S(e);!(t=r()).done;){var a=t.value;if(this.historyTypes.includes(a.content_type)){var i=a.payload;if(!a.deleted&&i.format===ue.a.DecryptedBareObject){var s=this.history[a.uuid]||[],o=yt(s),c=$n(Object(Ee.f)(a,ht.a.SessionHistory),o);if(!c.isDiscardable()){var u=this.historyStaging[a.uuid];this.historyStaging[a.uuid]=c,u&&(u.isSameAsEntry(c)||o&&u.isSameAsEntry(o)||(s.unshift(u),this.history[a.uuid]=s,this.autoOptimize&&this.optimizeHistoryForItem(a.uuid),n=!0))}}}}n&&this.saveToDisk()}},{key:"isDiskEnabled",value:function(){return this.persistable}},{key:"isAutoOptimizeEnabled",value:function(){return this.autoOptimize}},{key:"cancelPendingPersist",value:function(){this.saveTimeout&&('cancel'in this.deviceInterface.timeout?this.deviceInterface.timeout.cancel(this.saveTimeout):clearTimeout(this.saveTimeout))}},{key:"saveToDisk",value:function(){var e=this;if(this.persistable){this.cancelPendingPersist();var t=this.persistableHistoryValue();this.saveTimeout=this.deviceInterface.timeout(function(){e.storageService.setValue(o.SessionHistoryRevisions,t)},2e3)}}},{key:"persistableHistoryValue",value:function(){for(var e={},t=0,n=Object.entries(this.history);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1].map(function(e){return{payload:e.payload}});e[i]=s}return e}},{key:"setSessionItemRevisionThreshold",value:function(e){this.itemRevisionThreshold=e}},{key:"sessionHistoryForItem",value:function(e){return this.history[e.uuid]||[]}},{key:"clearHistoryForItem",value:function(e){delete this.history[e.uuid],this.saveToDisk()}},{key:"clearAllHistory",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.history={},e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleDiskSaving",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistable=!this.persistable,!this.persistable){e.next=6;break}this.storageService.setValue(o.SessionHistoryPersistable,!0),this.saveToDisk(),e.next=8;break;case 6:return this.storageService.setValue(o.SessionHistoryPersistable,!1),e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 8:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleAutoOptimize",value:function(){this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageService.setValue(o.SessionHistoryOptimize,!0):this.storageService.setValue(o.SessionHistoryOptimize,!1)}},{key:"getHistoryMapCopy",value:function(){for(var e=w({},this.history),t=0,n=Object.entries(e);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1];e[i]=s.slice()}return Object.freeze(e)}},{key:"remoteHistoryForItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.getItemRevisions(e.uuid));case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.abrupt("return",t.data);case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"fetchRemoteRevision",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.apiService.getRevision(t,e));case 2:if(!(n=o.sent).error&&!Object(_.w)(n.data)){o.next=5;break}return o.abrupt("return",void 0);case 5:return r=n.data,a=Object(Ee.e)(r,{uuid:r.item_uuid}),i=Object(Ee.f)(a,ht.a.RemoteHistory),o.next=10,b.awrap(this.protocolService.payloadByDecryptingPayload(i));case 10:if(!(s=o.sent).errorDecrypting){o.next=13;break}return o.abrupt("return",void 0);case 13:return o.abrupt("return",new Qn(s));case 14:case"end":return o.stop()}},null,this,null,Promise)}},{key:"optimizeHistoryForItem",value:function(e){var t=this.history[e]||[];if(!(t.length<=this.itemRevisionThreshold)){for(var n=function(e){return e.deltaSize()>25},r=[],a=function(e,a,i){if(i){if(r.unshift(e),n(e)&&-1===e.operationVector()){var s=t[a+1];s&&r.unshift(s)}}else Object(_.M)(r,e)},i=t.length-1;i>=0;i--){var s=t[i];a(s,i,0===i||i===t.length-1||n(s))}var o=t.filter(function(e){return r.includes(e)});this.history[e]=o}}}]),n})(R.a);!(function(e){e.SessionExpiryDateChanged="SessionExpiryDateChanged"})(Zn||(Zn={})),(function(e){e[e.None=0]="None",e[e.FiveMinutes=300]="FiveMinutes",e[e.OneHour=3600]="OneHour",e[e.OneWeek=604800]="OneWeek"})(er||(er={}));var rr,ar=[{valueInSeconds:er.None,label:"Don't Remember"},{valueInSeconds:er.FiveMinutes,label:'5 Minutes'},{valueInSeconds:er.OneHour,label:'1 Hour'},{valueInSeconds:er.OneWeek,label:'1 Week'}],ir=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).protocolService=e,s.challengeService=r,s.storageService=a,s.itemManager=i,s.sessionExpiryTimeout=-1,s}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.challengeService=void 0,this.storageService=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return e===ve.LoadedDatabase_12&&this.updateSessionExpiryTimer(this.getSessionExpiryDate()),Promise.resolve()}},{key:"hasProtectionSources",value:function(){return this.protocolService.hasAccount()||this.protocolService.hasPasscode()||this.hasBiometricsEnabled()}},{key:"areProtectionsEnabled",value:function(){return this.hasProtectionSources()&&this.getSessionExpiryDate()<=new Date}},{key:"hasBiometricsEnabled",value:function(){var e=this.storageService.getValue(o.BiometricsState,De.Nonwrapped);return Boolean(e)}},{key:"enableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to enable biometrics when they already are enabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.storageService.setValue(o.BiometricsState,!0,De.Nonwrapped));case 5:return e.abrupt("return",!0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"disableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to disable biometrics when they already are disabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.validateOrRenewSession(ne.DisableBiometrics));case 5:if(!e.sent){e.next=11;break}return e.next=8,b.awrap(this.storageService.setValue(o.BiometricsState,!1,De.Nonwrapped));case 8:return e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"createLaunchChallenge",value:function(){var e=[];return this.hasBiometricsEnabled()&&e.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&e.push(new ge(te.LocalPasscode)),e.length>0?new ye(e,ne.ApplicationUnlock,!1):void 0}},{key:"protectNote",value:function(e){return this.itemManager.changeItem(e.uuid,function(e){e.protected=!0})}},{key:"unprotectNote",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.validateOrRenewSession(ne.UnprotectNote));case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.itemManager.changeItem(e.uuid,function(e){e.protected=!1}));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){c.next=15;break}if(s=i.value,(o=s.protected&&this.areProtectionsEnabled())&&!n&&(n=this.validateOrRenewSession(t)),c.t0=!o,c.t0){c.next=11;break}return c.next=10,b.awrap(n);case 10:c.t0=c.sent;case 11:if(!c.t0){c.next=13;break}r.push(s);case 13:c.next=2;break;case 15:return c.abrupt("return",r);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){return this.itemManager.changeItems(Object(Ke.b)(e),function(e){e.protected=!0})}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.authorizeProtectedActionForNotes(e,ne.UnprotectNote));case 2:return t=n.sent,n.abrupt("return",this.itemManager.changeItems(Object(Ke.b)(t),function(e){e.protected=!1}));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeNoteAccess",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.protected){t.next=2;break}return t.abrupt("return",!0);case 2:return t.abrupt("return",this.validateOrRenewSession(ne.AccessProtectedNote));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeAddingPasscode",value:function(){return this.validateOrRenewSession(ne.AddPasscode)}},{key:"authorizeChangingPasscode",value:function(){return this.validateOrRenewSession(ne.ChangePasscode)}},{key:"authorizeRemovingPasscode",value:function(){return this.validateOrRenewSession(ne.RemovePasscode)}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.validateOrRenewSession(ne.SearchProtectedNotesText)}},{key:"authorizeFileImport",value:function(){return this.validateOrRenewSession(ne.ImportFile)}},{key:"authorizeBackupCreation",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.validateOrRenewSession(ne.ExportBackup,{fallBackToAccountPassword:e}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeMfaDisable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.DisableMfa,{requireAccountPassword:!0}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeAutolockIntervalChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.ChangeAutolockInterval));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeSessionRevoking",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.RevokeSession));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeCloudLinkAccess",value:function(){return this.validateOrRenewSession(ne.AccessCloudLink)}},{key:"validateOrRenewSession",value:function(e){var t,n,r,a,i,s,o,c,u,l=arguments;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>1&&void 0!==l[1]?l[1]:{},n=t.fallBackToAccountPassword,r=void 0===n||n,a=t.requireAccountPassword,i=void 0!==a&&a,!(this.getSessionExpiryDate()>new Date)){p.next=3;break}return p.abrupt("return",!0);case 3:if(s=[],this.hasBiometricsEnabled()&&s.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&s.push(new ge(te.LocalPasscode)),!i){p.next=10;break}if(this.protocolService.hasAccount()){p.next=9;break}throw Error('Requiring account password for challenge with no account');case 9:s.push(new ge(te.AccountPassword));case 10:if(0!==s.length){p.next=16;break}if(!r||!this.protocolService.hasAccount()){p.next=15;break}s.push(new ge(te.AccountPassword)),p.next=16;break;case 15:return p.abrupt("return",!0);case 16:return p.t0=s,p.t1=ge,p.t2=te.ProtectionSessionDuration,p.t3=void 0,p.t4=void 0,p.t5=void 0,p.t6=void 0,p.next=25,b.awrap(this.getSessionLength());case 25:return p.t7=p.sent,p.t8=new p.t1(p.t2,p.t3,p.t4,p.t5,p.t6,p.t7),p.t0.push.call(p.t0,p.t8),p.next=30,b.awrap(this.challengeService.promptForChallengeResponse(new ye(s,e,!0)));case 30:if(!(o=p.sent)){p.next=42;break}if(u=null===(c=o.values.find(function(e){return e.prompt.validation===te.ProtectionSessionDuration}))||void 0===c?void 0:c.value,!Object(_.w)(u)){p.next=37;break}we.a.error(Error('No valid protection session length found. Got '+u)),p.next=39;break;case 37:return p.next=39,b.awrap(this.setSessionLength(u));case 39:return p.abrupt("return",!0);case 42:return p.abrupt("return",!1);case 43:case"end":return p.stop()}},null,this,null,Promise)}},{key:"getSessionExpiryDate",value:function(){var e=this.storageService.getValue(o.ProtectionExpirey);return e?new Date(e):new Date}},{key:"clearSession",value:function(){return this.setSessionExpiryDate(new Date)}},{key:"setSessionExpiryDate",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.ProtectionExpirey,e));case 2:this.notifyEvent(Zn.SessionExpiryDateChanged);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSessionLength",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ProtectionSessionLength));case 2:if(!(e=t.sent)){t.next=7;break}return t.abrupt("return",e);case 7:return t.abrupt("return",er.None);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setSessionLength",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.storageService.setValue(o.ProtectionSessionLength,e));case 2:return(t=new Date).setSeconds(t.getSeconds()+e),n.next=6,b.awrap(this.setSessionExpiryDate(t));case 6:this.updateSessionExpiryTimer(t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSessionExpiryTimer",value:function(e){var t=this,n=e.getTime();if(n>Date.now()){clearTimeout(this.sessionExpiryTimeout),this.sessionExpiryTimeout=setTimeout(function(){t.setSessionExpiryDate(new Date)},n-Date.now())}}}]),n})(R.a),sr=n(45),or=n(19);!(function(e){e.UserRoleMessageReceived="WebSocketMessageReceived"})(rr||(rr={}));var cr,ur,lr=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.webSocketUrl=r,a}return y(n,[{key:"setWebSocketUrl",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.webSocketUrl=e,t.next=3,b.awrap(this.storageService.setValue(o.WebSocketUrl,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadWebSocketUrl",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.WebSocketUrl));case 2:e=t.sent,this.webSocketUrl=e||this.webSocketUrl||window._websocket_url;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"startWebSocketConnection",value:function(e){if(this.webSocketUrl)try{this.webSocket=new WebSocket("".concat(this.webSocketUrl,"?authToken=Bearer+").concat(e)),this.webSocket.onmessage=this.onWebSocketMessage.bind(this),this.webSocket.onclose=this.onWebSocketClose.bind(this)}catch(e){console.error('Error starting WebSocket connection',e)}}},{key:"closeWebSocketConnection",value:function(){var e;null===(e=this.webSocket)||void 0===e||e.close()}},{key:"onWebSocketMessage",value:function(e){var t=JSON.parse(e.data);this.notifyEvent(rr.UserRoleMessageReceived,t)}},{key:"onWebSocketClose",value:function(){this.webSocket=void 0}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.storageService=void 0,this.closeWebSocketConnection()}}]),n})(R.a),pr=n(29);!(function(e){e.UserRolesChanged="UserRolesChanged",e.FeaturesUpdated="FeaturesUpdated"})(cr||(cr={})),(function(e){e.NoUserSubscription="NoUserSubscription",e.NotInCurrentPlan="NotInCurrentPlan",e.InCurrentPlanButExpired="InCurrentPlanButExpired",e.Entitled="Entitled"})(ur||(ur={}));var dr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l,p,d){var h;return v(this,n),(h=t.call(this)).storageService=e,h.apiService=r,h.itemManager=a,h.componentManager=i,h.webSocketsService=s,h.settingsService=o,h.credentialService=c,h.syncService=u,h.alertService=l,h.sessionManager=p,h.crypto=d,h.deinited=!1,h.roles=[],h.features=[],h.needsInitialFeaturesUpdate=!0,h.completedSuccessfulFeaturesRetrieval=!1,h.removeApiServiceObserver=r.addEventObserver(function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==Ht.MetaReceived){a.next=6;break}if(h.syncService.completedOnlineDownloadFirstSync){a.next=3;break}return a.abrupt("return");case 3:return n=t.userUuid,r=t.userRoles,a.next=6,b.awrap(h.updateRoles(n,r.map(function(e){return e.name})));case 6:case"end":return a.stop()}},null,null,null,Promise)}),h.removeWebSocketsServiceObserver=s.addEventObserver(function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e!==rr.UserRoleMessageReceived){i.next=6;break}return n=t.payload,r=n.userUuid,a=n.currentRoles,i.next=4,b.awrap(h.setRoles(a));case 4:return i.next=6,b.awrap(h.updateFeatures(r));case 6:case"end":return i.stop()}},null,null,null,Promise)}),h.removefeatureReposObserver=h.itemManager.addObserver(or.ContentType.ExtensionRepo,function(e,t,n,r,a){var i,s;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=[ht.a.Constructor,ht.a.LocalRetrieved,ht.a.RemoteRetrieved,ht.a.FileImport],!a||!i.includes(a)){n.next=10;break}if(s=[].concat(m(e),m(t)).filter(function(e){return!e.deleted}),!h.sessionManager.isSignedIntoFirstPartyServer()){n.next=8;break}return n.next=6,b.awrap(h.migrateFeatureRepoToUserSetting(s));case 6:n.next=10;break;case 8:return n.next=10,b.awrap(h.migrateFeatureRepoToOfflineEntitlements(s));case 10:case"end":return n.stop()}},null,null,null,Promise)}),h.removeSignInObserver=h.credentialService.addEventObserver(function(e){if(e===Ye.SignedInOrRegistered){var t=h.itemManager.getItems(or.ContentType.ExtensionRepo);h.apiService.isThirdPartyHostUsed()||h.migrateFeatureRepoToUserSetting(t)}}),h}return y(n,[{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.FullSyncCompleted_13&&(t=this.getOfflineRepo())&&this.downloadOfflineFeatures(t);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setOfflineFeaturesCode",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,t=e.replace(/\s/g,''),i.next=4,b.awrap(this.crypto.base64Decode(t));case 4:if(n=i.sent,r=this.parseOfflineEntitlementsCode(n),!Object(_.u)(r)){i.next=8;break}return i.abrupt("return",r);case 8:return i.next=10,b.awrap(this.itemManager.createItem(or.ContentType.ExtensionRepo,Object(Ke.a)({offlineFeaturesUrl:r.featuresUrl,offlineKey:r.extensionKey,migratedToOfflineEntitlements:!0}),!0));case 10:return a=i.sent,this.syncService.sync(),i.abrupt("return",this.downloadOfflineFeatures(a));case 15:return i.prev=15,i.t0=i.catch(0),i.abrupt("return",{error:j.e});case 18:case"end":return i.stop()}},null,this,[[0,15]],Promise)}},{key:"getOfflineRepo",value:function(){return this.itemManager.getItems(or.ContentType.ExtensionRepo).filter(function(e){return e.migratedToOfflineEntitlements})[0]}},{key:"hasOfflineRepo",value:function(){return void 0!=this.getOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this.getOfflineRepo())){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 4:return t.next=6,b.awrap(this.storageService.removeValue(o.UserFeatures));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"parseOfflineEntitlementsCode",value:function(e){try{var t=JSON.parse(e);return{featuresUrl:t.featuresUrl,extensionKey:t.extensionKey}}catch(e){return{error:j.e}}}},{key:"downloadOfflineFeatures",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.downloadOfflineFeaturesFromRepo(e));case 2:if(t=n.sent,!Object(_.u)(t)){n.next=5;break}return n.abrupt("return",t);case 5:return n.next=7,b.awrap(this.didDownloadFeatures(t.features));case 7:return n.next=9,b.awrap(this.mapFeaturesToItems(t.features));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToUserSetting",value:function(){var e,t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:[],t=S(e);case 2:if((n=t()).done){c.next=17;break}if(!(r=n.value).migratedToUserSetting){c.next=6;break}return c.abrupt("continue",15);case 6:if(!r.onlineUrl){c.next=15;break}if(a=r.onlineUrl,!((i=a.match(/\w{32,64}/))&&i.length>0)){c.next=15;break}return s=i[0],c.next=13,b.awrap(this.settingsService.updateSetting(pr.SettingName.ExtensionKey,s,!0));case 13:return c.next=15,b.awrap(this.itemManager.changeFeatureRepo(r.uuid,function(e){e.migratedToUserSetting=!0}));case 15:c.next=2;break;case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToOfflineEntitlements",value:function(){var e,t,n,r,a,i,s,o=this,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=c.length>0&&void 0!==c[0]?c[0]:[],t=S(e);case 2:if((n=t()).done){u.next=17;break}if(!(r=n.value).migratedToOfflineEntitlements){u.next=6;break}return u.abrupt("continue",15);case 6:if(!r.onlineUrl){u.next=15;break}if(a=r.onlineUrl,i=new URL(a),i.origin.includes("https://extensions.standardnotes.org")){u.next=11;break}return u.abrupt("continue",15);case 11:if(!((s=a.match(/\w{32,64}/))&&s.length>0)){u.next=15;break}return u.next=15,b.awrap((function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=s[0],n.next=3,b.awrap(o.itemManager.changeFeatureRepo(r.uuid,function(t){t.offlineFeaturesUrl="https://api.standardnotes.com/v1/offline/features",t.offlineKey=e,t.migratedToOfflineEntitlements=!0}));case 3:return t=n.sent,n.next=6,b.awrap(o.downloadOfflineFeatures(t));case 6:case"end":return n.stop()}},null,null,null,Promise)})());case 15:u.next=2;break;case 17:case"end":return u.stop()}},null,null,null,Promise)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.UserRoles,void 0,[]));case 2:return this.roles=e.sent,e.next=5,b.awrap(this.storageService.getValue(o.UserFeatures,void 0,[]));case 5:this.features=e.sent;case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"updateRoles",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.haveRolesChanged(t)&&!this.needsInitialFeaturesUpdate){n.next=7;break}return this.needsInitialFeaturesUpdate=!1,n.next=5,b.awrap(this.setRoles(t));case 5:return n.next=7,b.awrap(this.updateFeatures(e));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setRoles",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles=e,Object(_.e)(this.roles,e)||this.notifyEvent(cr.UserRolesChanged),t.next=4,b.awrap(this.storageService.setValue(o.UserRoles,this.roles));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"didDownloadFeatures",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.features=e,this.completedSuccessfulFeaturesRetrieval=!0,this.notifyEvent(cr.FeaturesUpdated),t.next=5,b.awrap(this.storageService.setValue(o.UserFeatures,this.features));case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getFeature",value:function(e){return this.features.find(function(t){return t.identifier===e})}},{key:"hasPaidOnlineOrOfflineSubscription",value:function(){if(this.sessionManager.isSignedIntoFirstPartyServer()){var e=this.roles,t=[sr.RoleName.BasicUser];return e.some(function(e){return!t.includes(e)})}return this.hasOfflineRepo()}},{key:"getFeatureStatus",value:function(e){if(void 0==L.Features.find(function(t){return t.identifier===e})){var t=this.itemManager.components.find(function(t){return t.identifier===e});return null!==t&&void 0!==t&&t.isExpired?ur.InCurrentPlanButExpired:ur.Entitled}if(this.hasPaidOnlineOrOfflineSubscription()&&!this.completedSuccessfulFeaturesRetrieval)return ur.Entitled;if(!this.hasPaidOnlineOrOfflineSubscription())return ur.NoUserSubscription;var n=this.features.find(function(t){return t.identifier===e});return n?n.expires_at&&new Date(n.expires_at).getTime()<(new Date).getTime()?this.roles.includes(n.role_name)?ur.InCurrentPlanButExpired:ur.NotInCurrentPlan:ur.Entitled:ur.NotInCurrentPlan}},{key:"haveRolesChanged",value:function(e){var t=this;return e.some(function(e){return!t.roles.includes(e)})||this.roles.some(function(t){return!e.includes(t)})}},{key:"updateFeatures",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.apiService.getUserFeatures(e));case 2:if((t=r.sent).error||!t.data||this.deinited){r.next=10;break}return(n=t.data.features).forEach(function(e){e.expires_at&&(e.expires_at=Object(_.i)(e.expires_at))}),r.next=8,b.awrap(this.didDownloadFeatures(n));case 8:return r.next=10,b.awrap(this.mapFeaturesToItems(n));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"componentContentForFeatureDescription",value:function(e){var t={area:e.area,hosted_url:e.url,name:e.name,package_info:e,valid_until:new Date(e.expires_at||0)};return Object(Ke.a)(t)}},{key:"mapFeaturesToItems",value:function(e){var t,n,r,a,i,s,o,c,u=this;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:t=this.itemManager.getItems([or.ContentType.Component,or.ContentType.Theme]),n=[],r=new Date,a=!1,i=function(e){var i,s,o,c;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e.content_type){l.next=2;break}return l.abrupt("return","continue");case 2:if(!e.url||Object(_.B)(e.url)){l.next=5;break}return l.abrupt("return","continue");case 5:if(i=new Date(e.expires_at||0).getTime()<r.getTime(),s=t.find(function(t){return!!t.safeContent.package_info&&(t.safeContent.package_info.identifier===e.identifier&&!t.deleted)}),o=s,!s){l.next=21;break}if(c=new Date(e.expires_at||0),!(e.url!==s.hosted_url||e.version!==s.package_info.version||c.getTime()!==s.valid_until.getTime())){l.next=18;break}return l.next=14,b.awrap(u.itemManager.changeComponent(s.uuid,function(t){t.hosted_url=e.url,t.package_info=e,t.valid_until=c}));case 14:o=l.sent,a=!0,l.next=19;break;case 18:o=s;case 19:l.next=26;break;case 21:if(i&&e.content_type!==or.ContentType.Component){l.next=26;break}return l.next=24,b.awrap(u.itemManager.createItem(e.content_type,u.componentContentForFeatureDescription(e),!0));case 24:o=l.sent,a=!0;case 26:i&&o&&(e.content_type===or.ContentType.Component?u.componentManager.setReadonlyStateForComponent(o,i):(n.push(o.uuid),a=!0));case 27:case"end":return l.stop()}},null,null,null,Promise)},s=S(e);case 6:if((o=s()).done){l.next=15;break}return c=o.value,l.next=10,b.awrap(i(c));case 10:if("continue"!==l.sent){l.next=13;break}return l.abrupt("continue",13);case 13:l.next=6;break;case 15:return l.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(n));case 17:a&&this.syncService.sync();case 18:case"end":return l.stop()}},null,this,null,Promise)}},{key:"validateAndDownloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=e,i.prev=1,i.next=4,b.awrap(this.crypto.base64Decode(e));case 4:t=i.sent,i.next=9;break;case 7:i.prev=7,i.t0=i.catch(1);case 9:if(i.prev=9,n=[].concat(Ft,Nt),r=new URL(t),a=r.host,n.includes(a)){i.next=20;break}return i.next=15,b.awrap(this.alertService.confirm(j.t,'Install extension from an untrusted source?','Proceed to install',St.Danger,'Cancel'));case 15:if(!i.sent){i.next=18;break}return i.abrupt("return",this.downloadExternalFeature(t));case 18:i.next=21;break;case 20:return i.abrupt("return",this.downloadExternalFeature(t));case 21:i.next=26;break;case 23:i.prev=23,i.t1=i.catch(9),this.alertService.alert(j.C);case 26:case"end":return i.stop()}},null,this,[[1,7],[9,23]],Promise)}},{key:"downloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.apiService.downloadFeatureUrl(e));case 2:if(!(t=i.sent).error){i.next=7;break}return i.next=6,b.awrap(this.alertService.alert(j.c));case 6:return i.abrupt("return",void 0);case 7:if((n=t.data).content_type){i.next=10;break}return i.abrupt("return");case 10:return r=this.componentContentForFeatureDescription(n),i.next=13,b.awrap(this.itemManager.createTemplateItem(n.content_type,r));case 13:return a=i.sent,i.abrupt("return",a);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.removeSignInObserver(),this.removeSignInObserver=void 0,this.removeApiServiceObserver(),this.removeApiServiceObserver=void 0,this.removeWebSocketsServiceObserver(),this.removeWebSocketsServiceObserver=void 0,this.removefeatureReposObserver(),this.removefeatureReposObserver=void 0,this.roles=void 0,this.storageService=void 0,this.apiService=void 0,this.itemManager=void 0,this.componentManager=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.credentialService=void 0,this.syncService=void 0,this.alertService=void 0,this.sessionManager=void 0,this.crypto=void 0,this.deinited=!0}}]),n})(R.a),hr=n(46),fr=(function(){function e(t,n){v(this,e),this.completedUpload=0,this.totalUpload=0,this.downloaded=0,this.databaseLoadCurrent=0,this.databaseLoadTotal=0,this.databaseLoadDone=!1,this.syncing=!1,this.interval=t,this.receiver=n}return y(e,[{key:"deinit",value:function(){this.stopTimingMonitor()}},{key:"setUploadStatus",value:function(e,t){this.completedUpload=e,this.totalUpload=t,this.receiver(on.a.StatusChanged)}},{key:"setDownloadStatus",value:function(e){this.downloaded+=e,this.receiver(on.a.StatusChanged)}},{key:"setDatabaseLoadStatus",value:function(e,t,n){this.databaseLoadCurrent=e,this.databaseLoadTotal=t,this.databaseLoadDone=n,n?this.receiver(on.a.LocalDataLoaded):this.receiver(on.a.LocalDataIncrementalLoad)}},{key:"getStats",value:function(){return{uploadCompletionCount:this.completedUpload,uploadTotalCount:this.totalUpload,downloadCount:this.downloaded,localDataDone:this.databaseLoadDone,localDataCurrent:this.databaseLoadCurrent,localDataTotal:this.databaseLoadTotal}}},{key:"setDidBegin",value:function(){this.syncing=!0,this.syncStart=new Date}},{key:"setDidEnd",value:function(){this.syncing=!1,this.syncEnd=new Date}},{key:"startTimingMonitor",value:function(){var e=this;this.timingMonitor&&this.stopTimingMonitor(),this.timingMonitor=this.interval(function(){e.secondsSinceSyncStart>5&&(e.receiver(on.a.SyncTakingTooLong),e.stopTimingMonitor())},500)}},{key:"stopTimingMonitor",value:function(){Object.prototype.hasOwnProperty.call(this.interval,'cancel')?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return!!this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.syncing=!1,this.error=null,this.stopTimingMonitor(),this.receiver(on.a.StatusChanged)}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return((new Date).getTime()-this.syncStart.getTime())/1e3}}]),e})();function vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mr,br=(function(){function e(){v(this,e),this.tags=[],this.includePinned=!0,this.includeProtected=!0,this.includeTrashed=!1,this.includeArchived=!1}return y(e,[{key:"computeFilters",value:function(e){for(var t,n=this,r=this.tags.filter(function(e){return!e.isSmartTag}),a=this.tags.filter(function(e){return e.isSmartTag}),i=a.filter(function(e){return e.isSystemSmartTag}),s=a.filter(function(e){return!e.isSystemSmartTag}),o=!1,c=!1,u=[],l=S(i);!(t=l()).done;){var p=t.value;p.isArchiveTag?(u.push(function(e){return e.archived&&!e.deleted}),o=!0):p.isTrashTag&&(u.push(function(e){return e.trashed&&!e.deleted}),c=!0)}if(s.length>0){var d=H.a.CompoundPredicate(s.map(function(e){return e.predicate}));u.push(function(t){if(d.keypathIncludesVerb('tags')){var n=yr(yr(yr({},t),t.payload),{},{tags:e.elementsReferencingElement(t,F.a.Tag)});return H.a.ObjectSatisfiesPredicate(n,d)}return H.a.ObjectSatisfiesPredicate(t,d)})}else if(r.length>0)for(var h,f=function(e){u.push(function(t){return e.hasRelationshipWithItem(t)})},v=S(r);!(h=v()).done;){f(h.value)}return this.searchQuery&&u.push(function(t){return xr(t,n.searchQuery,e)}),this.includePinned||u.push(function(e){return!e.pinned}),this.includeProtected||u.push(function(e){return!e.protected}),this.includeTrashed||c||u.push(function(e){return!e.trashed}),this.includeArchived||o||c||u.push(function(e){return!e.archived}),u}}],[{key:"Create",value:function(t){var n=new e;return w(n,t),Object.freeze(n)}},{key:"Copy",value:function(t,n){var r=new e;return w(r,t),w(r,n),Object.freeze(r)}}]),e})();function wr(e,t){var n=e.computeFilters(t);return t.displayElements(F.a.Note).filter(function(e){return kr(e,n)})}function kr(e,t){for(var n,r=S(t);!(n=r()).done;){if(!(0,n.value)(e))return!1}return!0}function xr(e,t,n){var r=n.elementsReferencingElement(e,F.a.Tag).some(function(e){return Pr(e,t.query)!==mr.None});if(e.protected&&!t.includeProtectedNoteText){var a=Sr(e,t.query);return a===mr.Title||a===mr.TitleAndText||r}return Sr(e,t.query)!==mr.None||r}function Sr(e,t){if(0===t.length)return mr.TitleAndText;var n=e.safeTitle().toLowerCase(),r=e.safeText().toLowerCase(),a=t.toLowerCase(),i=a.split(' '),s=Or(a);if(s)return(n.includes(s)?mr.Title:mr.None)+(r.includes(s)?mr.Text:mr.None);if(Cr(a))return e.uuid===a?mr.Uuid:mr.None;var o=i.every(function(e){return n.indexOf(e)>=0}),c=i.every(function(e){return r.indexOf(e)>=0});return(o?mr.Title:0)+(c?mr.Text:0)}function Pr(e,t){if(0===t.length)return mr.None;var n=e.title.toLowerCase(),r=t.toLowerCase(),a=r.split(' '),i=Or(r);return i?n.includes(i)?mr.Title:mr.None:a.every(function(e){return n.indexOf(e)>=0})?mr.Title:mr.None}function Or(e){var t=e.match(/"(.*?)"/);return t?t[1]:null}function Cr(e){return!!e.match(/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)}!(function(e){e[e.None=0]="None",e[e.Title=1]="Title",e[e.Text=2]="Text",e[e.TitleAndText=3]="TitleAndText",e[e.Uuid=5]="Uuid"})(mr||(mr={}));var Dr=(function(){function e(t){v(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:br.Create({});this.collection=t,this.criteria=n,this.displayedNotes=[],this.needsRebuilding=!0}return y(e,[{key:"setCriteria",value:function(e){this.criteria=e,this.collection.setDisplayOptions(F.a.Note,e.sortProperty,e.sortDirection),this.needsRebuilding=!0}},{key:"notesMatchingSmartTag",value:function(e){var t;return wr((t=e,br.Create({tags:[t]})),this.collection)}},{key:"rebuildList",value:function(){var e=this,t=br.Copy(this.criteria,{tags:this.criteria.tags.map(function(t){return t.isSystemSmartTag?t:e.collection.find(t.uuid)})});this.displayedNotes=wr(t,this.collection)}},{key:"setNeedsRebuilding",value:function(){this.needsRebuilding=!0}},{key:"displayElements",value:function(){return this.needsRebuilding&&(this.rebuildList(),this.needsRebuilding=!1),this.displayedNotes.slice()}}]),e})(),_r=(function(e){d(n,e);var t=k(n);function n(e){var r,a,i,s;return v(this,n),(r=t.call(this)).payloadManager=e,r.observers=[],r.payloadManager=e,r.systemSmartTags=(a=Object(Ee.e)({uuid:Er,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'All notes',isSystemTag:!0,isAllTag:!0})}),i=Object(Ee.e)({uuid:Rr,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Archived',isSystemTag:!0,isArchiveTag:!0})}),s=Object(Ee.e)({uuid:Ir,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Trash',isSystemTag:!0,isTrashTag:!0})}),[nt(a),nt(i),nt(s)]),r.createCollection(),r.unsubChangeObserver=r.payloadManager.addObserver(F.a.Any,r.setPayloads.bind(u(r))),r}return y(n,[{key:"createCollection",value:function(){this.collection=new gn,this.collection.setDisplayOptions(F.a.Note,dn.CreatedAt,'dsc'),this.collection.setDisplayOptions(F.a.Tag,dn.Title,'dsc'),this.collection.setDisplayOptions(F.a.ItemsKey,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Component,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Theme,dn.Title,'asc'),this.collection.setDisplayOptions(F.a.SmartTag,dn.Title,'asc'),this.notesView=new Dr(this.collection)}},{key:"setDisplayOptions",value:function(e,t,n,r){e===F.a.Note&&console.warn("Called setDisplayOptions with ContentType.Note. setNotesDisplayCriteria should be used instead."),this.collection.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.notesView.setCriteria(e)}},{key:"getDisplayableItems",value:function(e){return e===F.a.Note?this.notesView.displayElements():this.collection.displayElements(e)}},{key:"deinit",value:function(){this.unsubChangeObserver(),this.unsubChangeObserver=void 0,this.payloadManager=void 0,this.collection=void 0,this.notesView=void 0}},{key:"resetState",value:function(){this.createCollection()}},{key:"findItem",value:function(e){return this.collection.find(e)}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.collection.findAll(e,t)}},{key:"itemsKeys",value:function(){return this.collection.displayElements(F.a.ItemsKey)}},{key:"addObserver",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]);var r={contentType:e,callback:t};return this.observers.push(r),function(){Object(_.M)(n.observers,r)}}},{key:"itemsReferencingItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.collection.uuidsThatReferenceUuid(e);return this.findItems(t)}},{key:"referencesForItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.findItem(e).references.map(function(e){return e.uuid});return this.findItems(t)}},{key:"setPayloads",value:function(e,t,n,r,a,i){var s=e.map(function(e){return nt(e)}),o=t.map(function(e){return nt(e)}),c=r.map(function(e){return nt(e)}),u=s.concat(o);u.length>0&&this.collection.set(u);for(var l,p=n.map(function(e){return nt(e)}),d=S(p);!(l=d()).done;){var h=l.value;this.collection.discard(h)}this.notesView.setNeedsRebuilding(),this.notifyObservers(s,o,p,c,a,i)}},{key:"notifyObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return e.filter(function(e){return t.includes(F.a.Any)||t.includes(e.content_type)})},c=S(this.observers.slice());!(s=c()).done;){var u=s.value,l=o(e,u.contentType),p=o(t,u.contentType),d=o(n,u.contentType),h=o(r,u.contentType);0===l.length&&0===p.length&&0===d.length&&0===h.length||u.callback(l,p,d,h,a,i)}}},{key:"changeItem",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=s.length>2&&void 0!==s[2]?s[2]:T.c.UserInteraction,r=s.length>3&&void 0!==s[3]?s[3]:ht.a.LocalChanged,a=s.length>4?s[4]:void 0,Object(_.A)(e)){o.next=5;break}throw Error('Invalid uuid for changeItem');case 5:return o.next=7,b.awrap(this.changeItems([e],t,n,r,a));case 7:return i=o.sent,o.abrupt("return",i[0]);case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:n=h.length>2&&void 0!==h[2]?h[2]:T.c.UserInteraction,r=h.length>3&&void 0!==h[3]?h[3]:ht.a.LocalChanged,a=h.length>4?h[4]:void 0,i=this.findItems(e,!0),s=[],o=S(i);case 6:if((c=o()).done){f.next=16;break}if(u=c.value){f.next=10;break}throw Error('Attempting to change non-existant item');case 10:l=de(u,n),t&&t(l),p=l.getResult(),s.push(p);case 14:f.next=6;break;case 16:return f.next=18,b.awrap(this.payloadManager.emitPayloads(s,r,a));case 18:return d=this.findItems(s.map(function(e){return e.uuid})),f.abrupt("return",d);case 20:case"end":return f.stop()}},null,this,null,Promise)}},{key:"changeNote",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant note');case 6:return s=new pe(i,n),c.abrupt("return",this.applyTransform(s,t,r,a));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeTag",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant tag');case 6:return s=new ce(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeComponent",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant component');case 6:return s=new V(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeFeatureRepo",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant repo');case 6:return s=new Xe(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeActionsExtension",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant extension');case 6:return s=new se(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeItemsKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant itemsKey');case 6:return s=new $(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"applyTransform",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:ht.a.LocalChanged,r=i.length>3?i[3]:void 0,t(e),a=e.getResult(),s.abrupt("return",this.payloadManager.emitPayload(a,n,r));case 5:case"end":return s.stop()}},null,this,null,Promise)}},{key:"setItemDirty",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]&&r[1],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return a.next=5,b.awrap(this.setItemsDirty([e],t));case 5:return n=a.sent,a.abrupt("return",n[0]);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemsDirty",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=n.length>1&&void 0!==n[1]&&n[1],Object(_.A)(e[0])){r.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return r.abrupt("return",this.changeItems(e,void 0,t?T.c.UserInteraction:T.c.Internal));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getDirtyItems",value:function(){return this.collection.dirtyElements().filter(function(e){return e.isSyncable})}},{key:"duplicateItem",value:function(e){var t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return t=o.length>1&&void 0!==o[1]&&o[1],n=o.length>2?o[2]:void 0,r=this.findItem(e),a=Object(Ee.e)(r),c.next=6,b.awrap(ut(a,this.payloadManager.getMasterCollection(),t,n));case 6:return i=c.sent,c.next=9,b.awrap(this.payloadManager.emitPayloads(i,ht.a.LocalChanged));case 9:return s=this.findItem(i[0].uuid),c.abrupt("return",s);case 11:case"end":return c.stop()}},null,this,null,Promise)}},{key:"createItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=i.length>3?i[3]:void 0,e){s.next=4;break}throw'Attempting to create item with no contentType';case 4:return s.t0=Object(Ee.e),s.next=7,b.awrap(I.GenerateUuid());case 7:return s.t1=s.sent,s.t2=e,s.t3=t?Object(Ke.a)(t):void 0,s.t4=n,s.t5={uuid:s.t1,content_type:s.t2,content:s.t3,dirty:s.t4},s.t6=r,a=(0,s.t0)(s.t5,s.t6),s.next=16,b.awrap(this.payloadManager.emitPayload(a,ht.a.Constructor));case 16:return s.abrupt("return",this.findItem(a.uuid));case 17:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Object(Ee.e),r.next=3,b.awrap(I.GenerateUuid());case 3:return r.t1=r.sent,r.t2=e,r.t3=Object(Ke.a)(t||{}),r.t4={uuid:r.t1,content_type:r.t2,content:r.t3},n=(0,r.t0)(r.t4),r.abrupt("return",nt(n));case 9:case"end":return r.stop()}},null,null,null,Promise)}},{key:"insertItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemFromPayload(e.payload));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"insertItems",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemsFromPayloads(e.map(function(e){return e.payload})));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emitItemFromPayload",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:ht.a.Constructor,r.next=3,b.awrap(this.payloadManager.emitPayload(e,t));case 3:return r.abrupt("return",this.findItem(e.uuid));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitItemsFromPayloads",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:ht.a.Constructor,a.next=3,b.awrap(this.payloadManager.emitPayloads(e,t));case 3:return n=Object(Ke.b)(e),a.abrupt("return",this.findItems(n));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemToBeDeleted",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this.collection.uuidsThatReferenceUuid(e),r=this.findItem(e),u.next=4,b.awrap(this.changeItem(e,function(e){e.setDeleted()},void 0,t));case 4:a=u.sent,i=S(n);case 6:if((s=i()).done){u.next=14;break}if(o=s.value,!(c=this.findItem(o))){u.next=12;break}return u.next=12,b.awrap(this.changeItem(c.uuid,function(e){e.removeItemAsRelationship(r)}));case 12:u.next=6;break;case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}},null,this,null,Promise)}},{key:"setItemsToBeDeleted",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.all(e.map(function(e){return t.setItemToBeDeleted(e)})));case 1:case"end":return n.stop()}},null,null,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.collection.all(e);return t?n.filter(function(e){return!e.errorDecrypting&&!e.waitingForKey}):n}},{key:"nonErroredItemsForContentType",value:function(e){return this.collection.all(e).filter(function(e){return!e.errorDecrypting&&!e.waitingForKey})}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.subItemsMatchingPredicates(this.items,e)}},{key:"subItemsMatchingPredicates",value:function(e,t){return e.filter(function(e){if(e.deleted)return!1;for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!e.satisfiesPredicate(a))return!1}return!0})}},{key:"findTagByTitle",value:function(e){var t=e.toLowerCase();return this.tags.find(function(e){return e.title.toLowerCase()===t})}},{key:"searchTags",value:function(e,t){var n=this;return Object(_.G)(this.tags.filter(function(r){var a=new RegExp("^".concat(e,"|").concat(".").concat(e),'i').test(r.title),i=!!t&&n.itemsReferencingItem(t.uuid).some(function(e){return(null===e||void 0===e?void 0:e.uuid)===r.uuid});return a&&!i}),'title')}},{key:"getTagParent",value:function(e){var t=this.findItem(e).parentId;if(t)return this.findItem(t)}},{key:"getTagParentChain",value:function(e){for(var t=this.findItem(e).parentId,n=[];t;){var r=this.findItem(t);n.unshift(r),t=r.parentId}return n}},{key:"getTagChildren",value:function(e){var t=this.findItem(e);return this.collection.elementsReferencingElement(t)}},{key:"isTagAncestor",value:function(e,t){for(var n=this.findItem(t).parentId;n;){if(n===e)return!0;n=this.findItem(n).parentId}return!1}},{key:"isValidTagParent",value:function(e,t){return e!==t&&!this.isTagAncestor(t,e)}},{key:"setTagParent",value:function(e,t){if(e.uuid===t.uuid)throw new Error('can not set a tag parent of itself');if(this.isTagAncestor(t.uuid,e.uuid))throw new Error('can not set a tag ancestor of itself');return this.changeTag(t.uuid,function(t){t.makeChildOf(e)})}},{key:"unsetTagParent",value:function(e){var t=this.getTagParent(e.uuid);return t?this.changeTag(e.uuid,function(e){e.removeItemAsRelationship(t)}):Promise.resolve(e)}},{key:"addTagToNote",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.changeItem(t.uuid,function(t){t.addItemAsRelationship(e)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getSortedTagsForNote",value:function(e){return Object(_.G)(this.itemsReferencingItem(e.uuid).filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===F.a.Tag}),'title')}},{key:"findOrCreateTagByTitle",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.findTagByTitle(e),n.t0=t,n.t0){n.next=6;break}return n.next=5,b.awrap(this.createItem(F.a.Tag,Object(Ke.a)({title:e}),!0));case 5:n.t0=n.sent;case 6:return n.abrupt("return",n.t0);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"notesMatchingSmartTag",value:function(e){return this.notesView.notesMatchingSmartTag(e)}},{key:"emptyTrash",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.trashedItems,t.abrupt("return",this.setItemsToBeDeleted(Object(Ke.b)(e)));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){var e=this.collection.displayElements(F.a.SmartTag);return this.systemSmartTags.concat(e)}},{key:"removeAllItemsFromMemory",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Object(Ke.b)(this.items),t.next=3,b.awrap(this.changeItems(e,function(e){e.setDeleted()},T.c.NonDirtying));case 3:this.resetState(),this.payloadManager.resetState();case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"removeItemLocally",value:function(e){this.collection.discard(e),this.payloadManager.removePayloadLocally(e.payload)}},{key:"items",get:function(){return this.collection.all()}},{key:"nonDeletedItems",get:function(){return this.collection.nondeletedElements()}},{key:"invalidItems",get:function(){return this.collection.invalidElements()}},{key:"notes",get:function(){return this.notesView.displayElements()}},{key:"tags",get:function(){return this.collection.displayElements(F.a.Tag)}},{key:"components",get:function(){return this.collection.displayElements(F.a.Component)}},{key:"trashSmartTag",get:function(){return this.systemSmartTags.find(function(e){return e.isTrashTag})}},{key:"trashedItems",get:function(){return this.notesMatchingSmartTag(this.trashSmartTag)}},{key:"noteCount",get:function(){return this.collection.all(F.a.Note).length}}]),n})(R.a),Er='all-notes',Rr='archived-notes',Ir='trashed-notes';function Mr(e,t){return e.sort(function(e,n){var r=new Date(n.serverUpdatedAt).getTime()-new Date(e.serverUpdatedAt).getTime(),a=0,i=0;return t&&(a=t.indexOf(e.content_type),i=t.indexOf(n.content_type),-1===a&&(a=t.length),-1===i&&(i=t.length)),a===i?r:a<i?-1:1})}var Ar=(function(){function e(t,n){v(this,e),this.discordance=0,this.outOfSync=!1,this.receiver=t,this.maxDiscordance=n,this.reset()}return y(e,[{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"reset",value:function(){this.lastPreSyncSave=void 0,this.lastSyncDate=void 0,this.discordance=0,this.outOfSync=!1}},{key:"getLastClientIntegrityHash",value:function(){return this.lastClientHash}},{key:"clearIntegrityHashes",value:function(){this.lastClientHash=void 0,this.lastServerHash=void 0}},{key:"setIntegrityHashes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.lastClientHash=e,this.lastServerHash=t,!t||0===t.length||!e||e===t?(this.outOfSync&&(this.outOfSync=!1,this.receiver(on.a.ExitOutOfSync)),this.discordance=0):(this.discordance++,this.discordance>=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(on.a.EnterOutOfSync)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordance<this.maxDiscordance}}]),e})(),jr=Object.freeze([F.a.ServerExtension]);function Tr(e){return e.filter(function(e){var t=![ue.a.DecryptedBareObject,ue.a.DecryptedBase64String].includes(e.format),n=jr.includes(e.content_type),r=t||n;return r||console.error('Filtering disallowed payload',e),r})}var Kr=(function(){function e(t,n,r,a,i){v(this,e),this.apiService=t,this.protocolService=n,this.contentType=r,this.customEvent=a,this.limit=i,this.progress={retrievedPayloads:[]}}return y(e,[{key:"run",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.apiService.sync([],this.progress.lastSyncToken,this.progress.paginationToken,this.limit||500,!1,this.contentType,this.customEvent));case 2:return r=s.sent,a=Tr(r.data.retrieved_items.map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)})),s.next=6,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a));case 6:if(i=s.sent,this.progress.retrievedPayloads=this.progress.retrievedPayloads.concat(i),this.progress.lastSyncToken=null===(e=r.data)||void 0===e?void 0:e.sync_token,this.progress.paginationToken=null===(t=r.data)||void 0===t?void 0:t.cursor_token,null===(n=r.data)||void 0===n||!n.cursor_token){s.next=14;break}return s.abrupt("return",this.run());case 14:return s.abrupt("return",this.progress.retrievedPayloads);case 15:case"end":return s.stop()}},null,this,null,Promise)}}]),e})(),Fr=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}if(r=n.value,a=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient)){s.next=7;break}throw'Unable to find decrypted counterpart for rejected payload.';case 7:i=Object(Ee.f)(a,ht.a.RemoteRejected,{lastSyncEnd:new Date,dirty:!1}),e.push(i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRejected));case 12:case"end":return s.stop()}},null,this,null,Promise)}}]),n})();function Lr(e){if(e===ht.a.RemoteRetrieved)return Rt;if(e===ht.a.RemoteSaved)return It;if(e===ht.a.ConflictData||e===ht.a.ConflictUuid)return Et;if(e===ht.a.RemoteRejected)return Fr;throw"No delta class found for source ".concat(ht.a[e])}var Ur,Nr=(function(){function e(t){v(this,e),this.collections=t,Object.freeze(this)}return y(e,[{key:"collectionForSource",value:function(e){return this.collections.find(function(t){return t.source===e})}}]),e})(),Vr=(function(){function e(t,n,r,a,i){v(this,e),this.response=t,this.baseCollection=r,this.historyMap=i,this.relatedCollectionSet=new Nr([bt.WithPayloads(n,ht.a.DecryptedTransient),bt.WithPayloads(a,ht.a.SavedOrSaving)])}return y(e,[{key:"collectionsByProcessingResponse",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return e=[],s.next=3,b.awrap(this.collectionByProcessingPayloads(this.response.retrievedPayloads,ht.a.RemoteRetrieved));case 3:return(t=s.sent).all().length>0&&e.push(t),s.next=7,b.awrap(this.collectionByProcessingPayloads(this.response.savedPayloads,ht.a.RemoteSaved));case 7:if((n=s.sent).all().length>0&&e.push(n),!(this.response.uuidConflictPayloads.length>0)){s.next=14;break}return s.next=12,b.awrap(this.collectionByProcessingPayloads(this.response.uuidConflictPayloads,ht.a.ConflictUuid));case 12:(r=s.sent).all().length>0&&e.push(r);case 14:if(!(this.response.dataConflictPayloads.length>0)){s.next=19;break}return s.next=17,b.awrap(this.collectionByProcessingPayloads(this.response.dataConflictPayloads,ht.a.ConflictData));case 17:(a=s.sent).all().length>0&&e.push(a);case 19:if(!(this.response.rejectedPayloads.length>0)){s.next=24;break}return s.next=22,b.awrap(this.collectionByProcessingPayloads(this.response.rejectedPayloads,ht.a.RemoteRejected));case 22:(i=s.sent).all().length>0&&e.push(i);case 24:return s.abrupt("return",e);case 25:case"end":return s.stop()}},null,this,null,Promise)}},{key:"collectionByProcessingPayloads",value:function(e,t){var n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=bt.WithPayloads(Tr(e),t),r=Lr(t),a=new r(this.baseCollection,n,this.relatedCollectionSet,this.historyMap),c.next=5,b.awrap(a.resultingCollection());case 5:return i=c.sent,s=i.all().map(function(e){var t=o.finalDirtyStateForPayload(e);return Object(Ee.b)(e,{dirty:t,dirtiedDate:t?new Date:void 0})}),c.abrupt("return",bt.WithPayloads(s,t));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"finalDirtyStateForPayload",value:function(e){var t=this.baseCollection.find(e.uuid);return t?!t.dirtiedDate||e.dirtiedDate&&e.dirtiedDate>t.dirtiedDate?e.dirty:!e.discardable&&t.dirtiedDate>=t.lastSyncBegan:e.dirty}}]),e})(),Br=(function(){function e(t){var n,r;v(this,e),this.rawResponse=t,this.savedPayloads=this.filterRawItemArray(null===(n=t.data)||void 0===n?void 0:n.saved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteSaved)}),this.retrievedPayloads=this.filterRawItemArray(null===(r=t.data)||void 0===r?void 0:r.retrieved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)}),this.dataConflictPayloads=this.filterRawItemArray(this.rawDataConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictData)}),this.uuidConflictPayloads=this.filterRawItemArray(this.rawUuidConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictUuid)}),this.rejectedPayloads=this.filterRawItemArray(this.rawRejectedPayloads).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRejected)}),this.deletedPayloads=this.allProcessedPayloads.filter(function(e){return e.discardable}),Object(_.l)(this)}return y(e,[{key:"filterRawItemArray",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return!!e.uuid})}},{key:"error",get:function(){var e;return this.rawResponse.error||(null===(e=this.rawResponse.data)||void 0===e?void 0:e.error)}},{key:"status",get:function(){return this.rawResponse.status}},{key:"lastSyncToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.LastSyncToken]}},{key:"paginationToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.PaginationToken]}},{key:"integrityHash",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.IntegrityResult]}},{key:"checkIntegrity",get:function(){return this.integrityHash&&!this.paginationToken}},{key:"numberOfItemsInvolved",get:function(){return this.allProcessedPayloads.length}},{key:"allProcessedPayloads",get:function(){return this.savedPayloads.concat(this.retrievedPayloads).concat(this.dataConflictPayloads).concat(this.uuidConflictPayloads).concat(this.rejectedPayloads)}},{key:"rawUuidConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.UuidConflict}).map(function(e){return e.unsaved_item||e.item})}},{key:"rawDataConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ConflictingData}).map(function(e){return e.server_item||e.item})}},{key:"rawRejectedPayloads",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ContentTypeError||e.type===Te.a.ContentError}).map(function(e){return e.unsaved_item})}},{key:"rawConflictObjects",get:function(){var e,t,n=(null===(e=this.rawResponse.data)||void 0===e?void 0:e.conflicts)||[],r=(null===(t=this.rawResponse.data)||void 0===t?void 0:t.unsaved)||[];return n.concat(r)}},{key:"hasError",get:function(){return!Object(_.w)(this.rawResponse.error)}}]),e})();!(function(e){e[e.Response=1]="Response",e[e.StatusChanged=2]="StatusChanged"})(Ur||(Ur={}));var Wr=150,Hr=(function(){function e(t,n,r,a,i,s){v(this,e),this.payloads=t,this.receiver=n,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.id=Math.random(),this.responses=[],this.payloads=t,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.receiver=n,this.pendingPayloads=t.slice()}return y(e,[{key:"popPayloads",value:function(e){var t=this.pendingPayloads.slice(0,e);return Object(_.R)(this.pendingPayloads,t),t}},{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.receiver(Ur.StatusChanged,void 0,{completedUploadCount:this.totalUploadCount-this.pendingUploadCount,totalUploadCount:this.totalUploadCount}));case 2:return e=this.popPayloads(this.upLimit),r.next=5,b.awrap(this.apiService.sync(e,this.lastSyncToken,this.paginationToken,this.downLimit,this.checkIntegrity,void 0,void 0));case 5:return t=r.sent,n=new Br(t),this.responses.push(n),this.lastSyncToken=n.lastSyncToken,this.paginationToken=n.paginationToken,r.next=12,b.awrap(this.receiver(Ur.Response,n));case 12:if(this.done){r.next=14;break}return r.abrupt("return",this.run());case 14:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsSavedOrSaving",get:function(){return Object(_.c)(this.payloads,this.pendingPayloads)}},{key:"done",get:function(){return 0===this.pendingPayloads.length&&!this.paginationToken}},{key:"pendingUploadCount",get:function(){return this.pendingPayloads.length}},{key:"totalUploadCount",get:function(){return this.payloads.length}},{key:"upLimit",get:function(){return Wr}},{key:"downLimit",get:function(){return Wr}},{key:"numberOfItemsInvolved",get:function(){for(var e,t=0,n=S(this.responses);!(e=n()).done;){t+=e.value.numberOfItemsInvolved}return t}}]),e})(),zr=(function(){function e(t,n){v(this,e),this.payloads=t,this.receiver=n}return y(e,[{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=this.payloads.map(function(e){return Object(Ee.f)(e,ht.a.LocalSaved,{dirty:!1,lastSyncEnd:new Date})}),t=Object(_.a)(e),n=new Br({data:{saved_items:t}}),r.next=5,b.awrap(this.receiver(Ur.Response,n));case 5:case"end":return r.stop()}},null,this,null,Promise)}}]),e})();function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Qr,Jr,$r,Xr=5,Zr=15;!(function(e){e[e.ResolveOnNext=1]="ResolveOnNext",e[e.ForceSpawnNew=2]="ForceSpawnNew"})(Qr||(Qr={})),(function(e){e[e.Default=1]="Default",e[e.DownloadFirst=2]="DownloadFirst"})(Jr||(Jr={})),(function(e){e[e.External=1]="External",e[e.SpawnQueue=2]="SpawnQueue",e[e.ResolveQueue=3]="ResolveQueue",e[e.MoreDirtyItems=4]="MoreDirtyItems",e[e.AfterDownloadFirst=5]="AfterDownloadFirst",e[e.IntegrityCheck=6]="IntegrityCheck",e[e.ResolveOutOfSync=7]="ResolveOutOfSync"})($r||($r={}));var ea=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).itemManager=e,l.sessionManager=r,l.protocolService=a,l.storageService=i,l.payloadManager=s,l.apiService=o,l.historyService=c,l.resolveQueue=[],l.spawnQueue=[],l.completedOnlineDownloadFirstSync=!1,l.majorChangeThreshold=Zr,l.maxDiscordance=Xr,l.locked=!1,l.databaseLoaded=!1,l.syncLock=!1,l.dealloced=!1,l.localLoadPriorty=[F.a.ItemsKey,F.a.UserPrefs,F.a.Component,F.a.Theme],l.itemManager=e,l.sessionManager=r,l.protocolService=a,l.payloadManager=s,l.storageService=i,l.apiService=o,l.interval=u,l.initializeStatus(),l.initializeState(),l}return y(n,[{key:"onNewDatabaseCreated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.getLastSyncToken());case 2:if(!e.sent){e.next=5;break}return e.next=5,b.awrap(this.clearSyncPositionTokens());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.dealloced=!0,this.sessionManager=void 0,this.itemManager=void 0,this.protocolService=void 0,this.payloadManager=void 0,this.storageService=void 0,this.apiService=void 0,this.interval=void 0,this.state.reset(),this.opStatus.reset(),this.state=void 0,this.opStatus=void 0,this.resolveQueue.length=0,this.spawnQueue.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeStatus",value:function(){var e=this;this.opStatus=new fr(this.interval,function(t){e.notifyEvent(t)})}},{key:"initializeState",value:function(){var e=this;this.state=new Ar(function(t){t===on.a.EnterOutOfSync?e.notifyEvent(on.a.EnterOutOfSync):t===on.a.ExitOutOfSync&&e.notifyEvent(on.a.ExitOutOfSync)},this.maxDiscordance)}},{key:"lockSyncing",value:function(){this.locked=!0}},{key:"unlockSyncing",value:function(){this.locked=!1}},{key:"isOutOfSync",value:function(){return this.state.isOutOfSync()}},{key:"getLastSyncDate",value:function(){return this.state.lastSyncDate}},{key:"getStatus",value:function(){return this.opStatus}},{key:"resetSyncState",value:function(){this.state.reset()}},{key:"isDatabaseLoaded",value:function(){return this.databaseLoaded}},{key:"getDatabasePayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageService.getAllRawPayloads().catch(function(t){throw e.notifyEvent(on.a.DatabaseReadError,t),t}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadDatabasePayloads",value:function(e){var t,n,r,a,i,s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.databaseLoaded){d.next=2;break}throw'Attempting to initialize already initialized local database.';case 2:if(0!==e.length){d.next=6;break}return this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0),d.abrupt("return");case 6:return t=e.map(function(e){try{return Object(Ee.e)(e)}catch(e){return void console.error('Creating payload failed',e)}}).filter(function(e){return!Object(_.w)(e)}),n=Mr(t,this.localLoadPriorty),r=n.filter(function(e){return e.content_type===F.a.ItemsKey}),Object(_.R)(n,r),d.next=12,b.awrap(this.protocolService.payloadsByDecryptingPayloads(r));case 12:return a=d.sent,d.next=15,b.awrap(this.payloadManager.emitPayloads(a,ht.a.LocalRetrieved));case 15:i=n.length,s=100,o=Math.ceil(i/s),c=0;case 19:if(!(c<o)){d.next=32;break}return u=c*s,l=n.slice(u,u+s),d.next=24,b.awrap(this.protocolService.payloadsByDecryptingPayloads(l));case 24:return p=d.sent,d.next=27,b.awrap(this.payloadManager.emitPayloads(p,ht.a.LocalRetrieved));case 27:this.notifyEvent(on.a.LocalDataIncrementalLoad),this.opStatus.setDatabaseLoadStatus(u,i,!1);case 29:c++,d.next=19;break;case 32:this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0);case 34:case"end":return d.stop()}},null,this,null,Promise)}},{key:"setLastSyncToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.syncToken=e,t.abrupt("return",this.storageService.setValue(o.LastSyncToken,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setPaginationToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cursorToken=e,!e){t.next=5;break}return t.abrupt("return",this.storageService.setValue(o.PaginationToken,e));case 5:return t.abrupt("return",this.storageService.removeValue(o.PaginationToken));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLastSyncToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.syncToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.LastSyncToken));case 3:this.syncToken=e.sent;case 4:return e.abrupt("return",this.syncToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPaginationToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cursorToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.PaginationToken));case 3:this.cursorToken=e.sent;case 4:return e.abrupt("return",this.cursorToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"clearSyncPositionTokens",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.syncToken=void 0,this.cursorToken=void 0,e.next=4,b.awrap(this.storageService.removeValue(o.LastSyncToken));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.PaginationToken));case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"itemsNeedingSync",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.itemManager.getDirtyItems(),t.abrupt("return",e);case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"alternateUuidForItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=this.itemManager.findItem(e),n=Object(Ee.e)(t),a.next=4,b.awrap(lt(n,this.payloadManager.getMasterCollection()));case 4:return r=a.sent,a.next=7,b.awrap(this.payloadManager.emitPayloads(r,ht.a.LocalChanged));case 7:return a.next=9,b.awrap(this.persistPayloads(r));case 9:return a.abrupt("return",this.itemManager.findItem(r[0].uuid));case 10:case"end":return a.stop()}},null,this,null,Promise)}},{key:"markAllItemsAsNeedingSync",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.log('Marking all items as needing sync'),e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e,{dirty:!0,dirtiedDate:new Date})}),n.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 5:return n.next=7,b.awrap(this.persistPayloads(t));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"popPayloadsNeedingPreSyncSave",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.state.lastPreSyncSave){r.next=3;break}return r.abrupt("return",e);case 3:return n=e.filter(function(e){return!e.dirtiedDate||e.dirtiedDate>t}),this.state.lastPreSyncSave=new Date,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"queueStrategyResolveOnNext",value:function(){var e=this;return new Promise(function(t,n){e.resolveQueue.push({resolve:t,reject:n})})}},{key:"queueStrategyForceSpawnNew",value:function(e){var t=this;return new Promise(function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})})}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(_.N)(this.spawnQueue,0),this.log('Syncing again from spawn queue'),this.sync(Yr({queueStrategy:Qr.ForceSpawnNew,source:$r.SpawnQueue},e.options)).then(function(){e.resolve()}).catch(function(){e.reject()})}},{key:"payloadsByPreparingForServer",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.protocolService.payloadsByEncryptingPayloads(e,function(e){return jr.includes(e.content_type)?Re.b.SyncDecrypted:Re.b.Sync}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"downloadFirstSync",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:n=5,r=0;case 2:if(!(r<n)){a.next=14;break}return a.next=5,b.awrap(this.sync(Yr({mode:Jr.DownloadFirst,queueStrategy:Qr.ForceSpawnNew},t)).catch(console.error));case 5:if(!this.completedOnlineDownloadFirstSync){a.next=9;break}return a.abrupt("return");case 9:return a.next=11,b.awrap(Object(_.P)(e));case 11:r++,a.next=2;break;case 14:console.error("Failed downloadFirstSync after ".concat(n," tries"));case 15:case"end":return a.stop()}},null,this,null,Promise)}},{key:"awaitCurrentSyncs",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.lastSyncInvokationPromise);case 2:return e.next=4,b.awrap(this.currentSyncRequestPromise);case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"sync",value:function(){var e,t=arguments;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},this.lastSyncInvokationPromise=this.performSync(e),n.abrupt("return",this.lastSyncInvokationPromise);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"performSync",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P=this,O=arguments;return b.async(function(C){for(;;)switch(C.prev=C.next){case 0:if(e=O.length>0&&void 0!==O[0]?O[0]:{},!this.locked){C.next=4;break}return this.log('Sync Locked'),C.abrupt("return");case 4:return t=function(){return P.syncLock},n=function(){P.syncLock=!0},r=function(){P.syncLock=!1},a=this.opStatus.syncInProgress,i=this.databaseLoaded,(s=!t())&&i&&!a&&n(),e.source||(e.source=$r.External),C.next=14,b.awrap(this.itemsNeedingSync());case 14:return o=C.sent,c=new Date,u=o.filter(function(e){return e.neverSynced&&e.deleted}),Object(_.R)(o,u),l=o.map(function(e){return e.payloadRepresentation()}),C.next=21,b.awrap(this.popPayloadsNeedingPreSyncSave(l));case 21:return p=C.sent,C.next=24,b.awrap(this.persistPayloads(p));case 24:if(d=this.resolveQueue.slice(),h=Object(_.w)(e.queueStrategy)?Qr.ResolveOnNext:e.queueStrategy,!a&&i&&s){C.next=37;break}if(this.log(s?a?'Attempting to sync while existing sync in progress.':'Attempting to sync before local database has loaded.':'Another function call has begun preparing for sync.'),h!==Qr.ResolveOnNext){C.next=32;break}return C.abrupt("return",this.queueStrategyResolveOnNext());case 32:if(h!==Qr.ForceSpawnNew){C.next=36;break}return C.abrupt("return",this.queueStrategyForceSpawnNew({mode:e.mode,checkIntegrity:e.checkIntegrity,source:e.source}));case 36:throw Error("Unhandled timing strategy ".concat(h));case 37:if(!this.dealloced){C.next=39;break}return C.abrupt("return");case 39:return this.opStatus.setDidBegin(),C.next=42,b.awrap(this.notifyEvent(on.a.SyncWillBegin));case 42:if(Object(_.R)(this.resolveQueue,d),!(o.length>0)){C.next=46;break}return C.next=46,b.awrap(this.itemManager.changeItems(Object(Ke.b)(o),function(e){e.lastSyncBegan=c},T.c.NonDirtying,ht.a.PreSyncSave));case 46:if(this.protocolService.hasAccount()!==this.sessionManager.online()&&this.handleInvalidSessionState(),f=this.sessionManager.online(),D=e.mode,v=f&&!P.completedOnlineDownloadFirstSync?Jr.DownloadFirst:Object(_.w)(D)?Jr.Default:D,y=[],v!==Jr.Default){C.next=63;break}if(!f||this.completedOnlineDownloadFirstSync){C.next=54;break}throw Error('Attempting to default mode sync without having completed initial.');case 54:if(!f){C.next=60;break}return C.next=57,b.awrap(this.payloadsByPreparingForServer(l));case 57:y=C.sent,C.next=61;break;case 60:y=l;case 61:C.next=64;break;case 63:v===Jr.DownloadFirst&&(y=[]);case 64:if(!f){C.next=70;break}return C.next=67,b.awrap(this.syncOnlineOperation(y,e.checkIntegrity,e.source,v));case 67:g=C.sent,C.next=73;break;case 70:return C.next=72,b.awrap(this.syncOfflineOperation(y,e.source,v));case 72:g=C.sent;case 73:return this.currentSyncRequestPromise=g.run(),C.next=76,b.awrap(this.currentSyncRequestPromise);case 76:if(!this.dealloced){C.next=78;break}return C.abrupt("return");case 78:if(this.opStatus.setDidEnd(),r(),!this.opStatus.hasError()){C.next=82;break}return C.abrupt("return");case 82:if(this.opStatus.reset(),this.state.lastSyncDate=new Date,g instanceof Hr&&g.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(on.a.MajorDataChange),!(u.length>0)){C.next=88;break}return C.next=88,b.awrap(this.handleNeverSyncedDeleted(u));case 88:if(v===Jr.DownloadFirst){C.next=91;break}return C.next=91,b.awrap(this.notifyEvent(on.a.FullSyncCompleted,{source:e.source}));case 91:if(v!==Jr.DownloadFirst){C.next=99;break}return f&&(this.completedOnlineDownloadFirstSync=!0),C.next=95,b.awrap(this.notifyEvent(on.a.DownloadFirstSyncCompleted));case 95:return C.next=97,b.awrap(this.sync({source:$r.AfterDownloadFirst,checkIntegrity:!0,awaitAll:e.awaitAll}));case 97:C.next=125;break;case 99:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){C.next=107;break}if(this.log('Syncing again from resolve queue'),m=this.sync({source:$r.ResolveQueue,checkIntegrity:e.checkIntegrity}),!e.awaitAll){C.next=105;break}return C.next=105,b.awrap(m);case 105:C.next=125;break;case 107:return C.next=109,b.awrap(this.itemsNeedingSync());case 109:if(C.t0=C.sent.length,!(C.t0>0)){C.next=115;break}return C.next=113,b.awrap(this.sync({source:$r.MoreDirtyItems,checkIntegrity:e.checkIntegrity,awaitAll:e.awaitAll}));case 113:C.next=125;break;case 115:if(!(g instanceof Hr&&g.checkIntegrity)){C.next=124;break}if(!this.state.needsSync||!g.done){C.next=122;break}if(this.log('Syncing again from integrity check'),w=this.sync({checkIntegrity:!0,queueStrategy:Qr.ForceSpawnNew,source:$r.IntegrityCheck,awaitAll:e.awaitAll}),!e.awaitAll){C.next=122;break}return C.next=122,b.awrap(w);case 122:C.next=125;break;case 124:this.state.clearIntegrityHashes();case 125:for(k=S(d);!(x=k()).done;)x.value.resolve();case 126:case"end":return C.stop()}var D},null,this,null,Promise)}},{key:"handleInvalidSessionState",value:function(){we.a.error(Error('Session missing while attempting to sync.')),this.sessionManager.reauthenticateInvalidSession()}},{key:"syncOnlineOperation",value:function(e,t,n,r){var a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.t0=Hr,s.t1=e,s.t2=function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next=r.t0===Ur.Response?3:r.t0===Ur.StatusChanged?13:15;break;case 3:if(!i.dealloced){r.next=5;break}return r.abrupt("return");case 5:if(!t.hasError){r.next=10;break}return r.next=8,b.awrap(i.handleErrorServerResponse(t));case 8:r.next=12;break;case 10:return r.next=12,b.awrap(i.handleSuccessServerResponse(a,t));case 12:return r.abrupt("break",15);case 13:return i.opStatus.setUploadStatus(n.completedUploadCount,n.totalUploadCount),r.abrupt("break",15);case 15:case"end":return r.stop()}},null,null,null,Promise)},s.next=5,b.awrap(this.getLastSyncToken());case 5:return s.t3=s.sent,s.next=8,b.awrap(this.getPaginationToken());case 8:return s.t4=s.sent,s.t5=t,s.t6=this.apiService,a=new s.t0(s.t1,s.t2,s.t3,s.t4,s.t5,s.t6),this.log('Syncing online user','source:',n,'operation id',a.id,'integrity check',t,'mode:',r,'payloads:',e),s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"syncOfflineOperation",value:function(e,t,n){var r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return this.log('Syncing offline user','source:',t,'mode:',n,'payloads:',e),r=new zr(e,function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!a.dealloced){n.next=2;break}return n.abrupt("return");case 2:if(e!==Ur.Response){n.next=5;break}return n.next=5,b.awrap(a.handleOfflineResponse(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}),i.abrupt("return",r);case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleOfflineResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.log('Offline Sync Response',e.rawResponse),!((t=e.savedPayloads).length>0)){a.next=8;break}return a.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalSaved));case 5:return n=this.payloadManager.find(Object(Ke.b)(t)),a.next=8,b.awrap(this.persistPayloads(n));case 8:if(!((r=e.deletedPayloads).length>0)){a.next=12;break}return a.next=12,b.awrap(this.deletePayloads(r));case 12:return this.opStatus.clearError(),this.opStatus.setDownloadStatus(e.retrievedPayloads.length),a.next=16,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,e));case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleErrorServerResponse",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.log('Sync Error',e),401===e.status&&this.notifyEvent(on.a.InvalidSession),null===(t=this.opStatus)||void 0===t||t.setError(e.error),this.notifyEvent(on.a.SyncError,e.error);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleSuccessServerResponse",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k;return b.async(function(x){for(;;)switch(x.prev=x.next){case 0:if(!this._simulate_latency){x.next=3;break}return x.next=3,b.awrap(Object(_.P)(this._simulate_latency.latency));case 3:this.log('Online Sync Response','operation id',e.id,t.rawResponse),this.setLastSyncToken(t.lastSyncToken),this.setPaginationToken(t.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus(t.retrievedPayloads.length),n=[],r=t.allProcessedPayloads,a={},i=S(r);case 12:if((s=i()).done){x.next=25;break}if(!(o=s.value).deleted&&o.fields.includes(Je.a.Content)){x.next=16;break}return x.abrupt("continue",23);case 16:return c=a[o.items_key_id],u=c?nt(c):void 0,x.next=20,b.awrap(this.protocolService.payloadByDecryptingPayload(o,u));case 20:(l=x.sent).content_type===F.a.ItemsKey&&(a[l.uuid]=l),n.push(l);case 23:x.next=12;break;case 25:return p=this.payloadManager.getMasterCollection(),d=this.historyService.getHistoryMapCopy(),h=new Vr(t,n,p,e.payloadsSavedOrSaving,d),x.next=30,b.awrap(h.collectionsByProcessingResponse());case 30:f=x.sent,v=S(f);case 32:if((y=v()).done){x.next=41;break}return g=y.value,x.next=36,b.awrap(this.payloadManager.emitCollection(g));case 36:return m=x.sent,x.next=39,b.awrap(this.persistPayloads(m));case 39:x.next=32;break;case 41:if(!((w=t.deletedPayloads).length>0)){x.next=45;break}return x.next=45,b.awrap(this.deletePayloads(w));case 45:return x.next=47,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,t));case 47:if(!t.checkIntegrity){x.next=53;break}return x.next=50,b.awrap(this.computeDataIntegrityHash());case 50:return k=x.sent,x.next=53,b.awrap(this.state.setIntegrityHashes(k,t.integrityHash));case 53:case"end":return x.stop()}},null,this,null,Promise)}},{key:"handleNeverSyncedDeleted",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e.map(function(e){return e.payloadRepresentation({dirty:!1})}),n.next=3,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.persistPayloads(t));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistPayloads",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(0!==e.length&&!this.dealloced){n.next=2;break}return n.abrupt("return");case 2:return n.abrupt("return",this.storageService.savePayloads(e).catch(function(e){t.notifyEvent(on.a.DatabaseWriteError,e),we.a.error(e)}));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.persistPayloads(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"computeDataIntegrityHash",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:u.prev=0,e=this.itemManager.nonDeletedItems.sort(function(e,t){return t.serverUpdatedAtTimestamp-e.serverUpdatedAtTimestamp}),t=[],n=1e3,r=S(e);case 5:if((a=r()).done){u.next=14;break}if(i=a.value,s=i.serverUpdatedAtTimestamp){u.next=10;break}return u.abrupt("return",void 0);case 10:o=Math.floor(s/n),t.push(o);case 12:u.next=5;break;case 14:return c=t.join(','),u.abrupt("return",this.protocolService.crypto.sha256(c));case 18:return u.prev=18,u.t0=u.catch(0),console.error('Error computing data integrity hash',u.t0),u.abrupt("return",void 0);case 22:case"end":return u.stop()}},null,this,[[0,18]],Promise)}},{key:"resolveOutOfSync",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=new Kr(this.apiService,this.protocolService,void 0,'resolve-out-of-sync'),a.next=3,b.awrap(e.run());case 3:return t=a.sent,n=new _t(this.payloadManager.getMasterCollection(),bt.WithPayloads(t,ht.a.RemoteRetrieved),void 0,this.historyService.getHistoryMapCopy()),a.next=7,b.awrap(n.resultingCollection());case 7:return r=a.sent,a.next=10,b.awrap(this.payloadManager.emitCollection(r));case 10:return a.next=12,b.awrap(this.persistPayloads(r.payloads));case 12:return a.abrupt("return",this.sync({checkIntegrity:!0,source:$r.ResolveOutOfSync}));case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"statelessDownloadAllItems",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=new Kr(this.apiService,this.protocolService,e,t),a.next=3,b.awrap(n.run());case 3:return r=a.sent,a.abrupt("return",r.map(function(e){return nt(e)}));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_clearLastSyncDate",value:function(){this.state.lastSyncDate=void 0}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=void 0}}]),n})(R.a),ta=(function(){function e(t,n,r,a,i,s){v(this,e),this.challenge=t,this.onValidValue=n,this.onInvalidValue=r,this.onNonvalidatedSubmit=a,this.onComplete=i,this.onCancel=s,this.nonvalidatedValues=[],this.validValues=[],this.invalidValues=[],this.artifacts={}}return y(e,[{key:"complete",value:function(e){var t;e||(e=new be(this.challenge,this.validValues,this.artifacts)),null===(t=this.onComplete)||void 0===t||t.call(this,e)}},{key:"nonvalidatedSubmit",value:function(){var e,t=new be(this.challenge,this.nonvalidatedValues.slice(),this.artifacts);null===(e=this.onNonvalidatedSubmit)||void 0===e||e.call(this,t),this.nonvalidatedValues=[]}},{key:"cancel",value:function(){var e;null===(e=this.onCancel)||void 0===e||e.call(this)}},{key:"isFinished",value:function(){return this.validValues.length===this.challenge.prompts.length}},{key:"nonvalidatedPrompts",value:function(){return this.challenge.prompts.filter(function(e){return!e.validates})}},{key:"addNonvalidatedValue",value:function(e){var t=this.nonvalidatedValues,n=t.find(function(t){return t.prompt.id===e.prompt.id});n&&Object(_.M)(t,n),t.push(e),this.nonvalidatedValues.length===this.nonvalidatedPrompts().length&&this.nonvalidatedSubmit()}},{key:"setValueStatus",value:function(e,t,n){var r,a,i=t?this.validValues:this.invalidValues,s=i.find(function(t){return t.prompt.validation===e.prompt.validation});(s&&Object(_.M)(i,s),i.push(e),w(this.artifacts,n),this.isFinished())?this.complete():t?null===(r=this.onValidValue)||void 0===r||r.call(this,e):null===(a=this.onInvalidValue)||void 0===a||a.call(this,e)}}]),e})(),na=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.protocolService=r,a.challengeOperations={},a.challengeObservers={},a}return y(n,[{key:"deinit",value:function(){this.storageService=void 0,this.protocolService=void 0,this.sendChallenge=void 0,this.challengeOperations=void 0,this.challengeObservers=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"promptForChallengeResponse",value:function(e){var t=this;return new Promise(function(n){t.createOrGetChallengeOperation(e,n),t.sendChallenge(e)})}},{key:"validateChallengeValue",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.prompt.validation,t.next=t.t0===te.LocalPasscode?3:t.t0===te.AccountPassword?4:t.t0===te.Biometric?5:t.t0===te.ProtectionSessionDuration?6:7;break;case 3:return t.abrupt("return",this.protocolService.validatePasscode(e.value));case 4:return t.abrupt("return",this.protocolService.validateAccountPassword(e.value));case 5:return t.abrupt("return",{valid:!0===e.value});case 6:return t.abrupt("return",{valid:(n=e.value,'number'==typeof n&&Object.values(er).includes(n))});case 7:throw Error("Unhandled validation mode ".concat(e.prompt.validation));case 8:case"end":return t.stop()}var n},null,this,null,Promise)}},{key:"promptForCorrectPasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=new ye([new ge(te.LocalPasscode)],e,!0),a.next=3,b.awrap(this.promptForChallengeResponse(t));case 3:if(n=a.sent){a.next=6;break}return a.abrupt("return",void 0);case 6:return r=n.getValueForType(te.LocalPasscode),a.abrupt("return",r.value);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",{});case 2:if(e){n.next=8;break}return n.next=5,b.awrap(this.promptForCorrectPasscode(ne.ResaveRootKey));case 5:if(e=n.sent){n.next=8;break}return n.abrupt("return",{canceled:!0});case 8:return n.next=10,b.awrap(this.protocolService.computeWrappingKey(e));case 10:return t=n.sent,n.abrupt("return",{wrappingKey:t});case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"isPasscodeLocked",value:function(){return this.protocolService.rootKeyNeedsUnwrapping()}},{key:"addChallengeObserver",value:function(e,t){var n=this.challengeObservers[e.id]||[];return n.push(t),this.challengeObservers[e.id]=n,function(){Object(_.M)(n,t)}}},{key:"createOrGetChallengeOperation",value:function(e,t){var n=this,r=this.getChallengeOperation(e);return r||(r=new ta(e,function(t){n.onChallengeValidValue(e,t)},function(t){n.onChallengeInvalidValue(e,t)},function(r){n.onChallengeNonvalidatedSubmit(e,r),t(r)},function(r){n.onChallengeComplete(e,r),t(r)},function(){n.onChallengeCancel(e),t(void 0)}),this.challengeOperations[e.id]=r),r}},{key:"performOnObservers",value:function(e,t){for(var n,r=S(this.challengeObservers[e.id]||[]);!(n=r()).done;){t(n.value)}}},{key:"onChallengeValidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onValidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeInvalidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onInvalidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeNonvalidatedSubmit",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onNonvalidatedSubmit)||void 0===n||n.call(e,t)})}},{key:"onChallengeComplete",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onComplete)||void 0===n||n.call(e,t)})}},{key:"onChallengeCancel",value:function(e){this.performOnObservers(e,function(e){var t;null===(t=e.onCancel)||void 0===t||t.call(e)})}},{key:"getChallengeOperation",value:function(e){return this.challengeOperations[e.id]}},{key:"deleteChallengeOperation",value:function(e){delete this.challengeOperations[e.challenge.id]}},{key:"cancelChallenge",value:function(e){var t=this.challengeOperations[e.id];t.cancel(),this.deleteChallengeOperation(t)}},{key:"completeChallenge",value:function(e){var t=this.challengeOperations[e.id];t.complete(),this.deleteChallengeOperation(t)}},{key:"submitValuesForChallenge",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(0!==t.length){c.next=2;break}throw Error('Attempting to submit 0 values for challenge');case 2:n=S(t);case 3:if((r=n()).done){c.next=18;break}if((a=r.value).prompt.validates){c.next=10;break}this.getChallengeOperation(e).addNonvalidatedValue(a),c.next=16;break;case 10:return c.next=12,b.awrap(this.validateChallengeValue(a));case 12:i=c.sent,s=i.valid,o=i.artifacts,this.setValidationStatusForChallenge(e,a,s,o);case 16:c.next=3;break;case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"setValidationStatusForChallenge",value:function(e,t,n,r){var a=this.getChallengeOperation(e);a.setValueStatus(t,n,r),a.isFinished()&&(this.deleteChallengeOperation(a),delete this.challengeObservers[a.challenge.id])}}]),n})(R.a),ra=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).singletonManager=e,i.itemManager=r,i.syncService=a,i.shouldReload=!0,i.reloading=!1,i.removeItemObserver=r.addObserver(F.a.UserPrefs,function(){i.shouldReload=!0}),i.removeSyncObserver=a.addEventObserver(function(e){e===on.a.FullSyncCompleted&&i.reload()}),i}return y(n,[{key:"deinit",value:function(){var e,t;null===(e=this.removeItemObserver)||void 0===e||e.call(this),null===(t=this.removeSyncObserver)||void 0===t||t.call(this),this.singletonManager=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.LoadedDatabase_12&&(this.preferences=this.singletonManager.findSingleton(z.singletonPredicate),this.preferences&&this.notifyEvent("preferencesChanged"));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){var n,r;return null!==(n=null===(r=this.preferences)||void 0===r?void 0:r.getPref(e))&&void 0!==n?n:t}},{key:"setValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.preferences){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,b.awrap(this.itemManager.changeItem(this.preferences.uuid,function(n){n.setPref(e,t)}));case 4:this.preferences=n.sent,this.notifyEvent("preferencesChanged"),this.syncService.sync();case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"reload",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.shouldReload&&!this.reloading){t.next=2;break}return t.abrupt("return");case 2:return this.reloading=!0,t.prev=3,e=this.preferences,t.next=7,b.awrap(this.singletonManager.findOrCreateSingleton(z.singletonPredicate,F.a.UserPrefs,Object(Ke.a)({})));case 7:this.preferences=t.sent,((null===e||void 0===e?void 0:e.uuid)!==this.preferences.uuid||this.preferences.userModifiedDate>e.userModifiedDate)&&this.notifyEvent('preferencesChanged'),this.shouldReload=!1;case 10:return t.prev=10,this.reloading=!1,t.finish(10);case 13:case"end":return t.stop()}},null,this,[[3,,10,13]],Promise)}}]),n})(R.a),aa=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).settingsService=e,i.crypto=r,i.featuresService=a,i}return y(n,[{key:"saveMfaSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.updateSetting(pr.SettingName.MfaSecret,e,!0));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaActivated",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.getSensitiveSetting(pr.SettingName.MfaSecret));case 2:return e=t.sent,t.abrupt("return",null!=e&&0!=e);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.crypto.generateOtpSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.totpToken(e,Date.now(),6,30));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null!=t,!n.t0){n.next=7;break}return n.t1=t,n.next=5,b.awrap(this.getOtpToken(e));case 5:n.t2=n.sent,n.t0=n.t1===n.t2;case 7:if(n.t0){n.next=10;break}throw new Error(j.S.IncorrectMfa);case 10:return n.abrupt("return",this.saveMfaSetting(e));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.settingsService.deleteSetting(pr.SettingName.MfaSecret));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){var e,t=this.featuresService.getFeature(L.FeatureIdentifier.TwoFactorAuth);return void 0!=t&&(!0===t.no_expire||(null!==(e=t.expires_at)&&void 0!==e?e:0)>Date.now())}},{key:"deinit",value:function(){this.settingsService=void 0,this.crypto=void 0,this.featuresService=void 0,p(f(n.prototype),"deinit",this).call(this)}}]),n})(R.a);function ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(n),!0).forEach(function(t){oa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=(function(){function e(t,n,r,a,i,s,o,c,u){v(this,e);var l=arguments.length>9&&void 0!==arguments[9]&&arguments[9],p=arguments.length>10?arguments[10]:void 0;if(this.environment=t,this.platform=n,this.deviceInterface=r,this.crypto=a,this.alertService=i,this.identifier=s,this.swapClasses=o,this.defaultHost=c,this.appVersion=u,this.enableV4=l,this.webSocketUrl=p,this.eventHandlers=[],this.services=[],this.streamRemovers=[],this.serviceObservers=[],this.managedSubscribers=[],this.createdNewDatabase=!1,this.started=!1,this.launched=!1,this.dealloced=!1,this.revokingSession=!1,this.handledFullSyncStage=!1,!we.a.onLog)throw Error('SNLog.onLog must be set.');if(!we.a.onError)throw Error('SNLog.onError must be set.');if(!r)throw Error('Device Interface must be supplied.');if(!t)throw Error('Environment must be supplied when creating an application.');if(!n)throw Error('Platform must be supplied when creating an application.');if(!a)throw Error('Crypto has to be supplied when creating an application.');if(!i)throw Error('AlertService must be supplied when creating an application.');if(!s)throw Error('ApplicationIdentifier must be supplied when creating an application.');if(!o)throw Error('SwapClasses array must be supplied when creating an application.');if(!c)throw Error('defaultHost must be supplied when creating an application.');if(!u)throw Error('appVersion must be supplied when creating an application.');this.constructServices()}return y(e,[{key:"prepareForLaunch",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.setLaunchCallback(e),r.next=3,b.awrap(this.deviceInterface.openDatabase(this.identifier).catch(function(e){n.notifyEvent(At.a.LocalDatabaseReadError,e)}));case 3:return t=r.sent,this.createdNewDatabase=(null===t||void 0===t?void 0:t.isNewDatabase)||!1,r.next=7,b.awrap(this.migrationService.initialize());case 7:return r.next=9,b.awrap(this.notifyEvent(At.a.MigrationsLoaded));case 9:return r.next=11,b.awrap(this.handleStage(ve.PreparingForLaunch_0));case 11:return r.next=13,b.awrap(this.storageService.initializeFromDisk());case 13:return r.next=15,b.awrap(this.notifyEvent(At.a.StorageReady));case 15:return r.next=17,b.awrap(this.protocolService.initialize());case 17:return r.next=19,b.awrap(this.handleStage(ve.ReadyForLaunch_05));case 19:return this.started=!0,r.next=22,b.awrap(this.notifyEvent(At.a.Started));case 22:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setLaunchCallback",value:function(e){this.challengeService.sendChallenge=e.receiveChallenge}},{key:"launch",value:function(){var e,t,n,r,a,i=this,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(e=s.length>0&&void 0!==s[0]&&s[0],this.launched=!1,!(t=this.getLaunchChallenge())){o.next=11;break}return o.next=6,b.awrap(this.challengeService.promptForChallengeResponse(t));case 6:if(n=o.sent){o.next=9;break}throw Error('Launch challenge was cancelled.');case 9:return o.next=11,b.awrap(this.handleLaunchChallengeResponse(n));case 11:if(!this.storageService.isStorageWrapped()){o.next=20;break}return o.prev=12,o.next=15,b.awrap(this.storageService.decryptStorage());case 15:o.next=20;break;case 17:o.prev=17,o.t0=o.catch(12),this.alertService.alert(j.B.StorageDecryptErrorBody,j.B.StorageDecryptErrorTitle);case 20:return o.next=22,b.awrap(this.handleStage(ve.StorageDecrypted_09));case 22:return o.next=24,b.awrap(this.apiService.loadHost());case 24:return o.next=26,b.awrap(this.webSocketsService.loadWebSocketUrl());case 26:return o.next=28,b.awrap(this.sessionManager.initializeFromDisk());case 28:return this.historyManager.initializeFromDisk(),this.settingsService.initializeFromDisk(),o.next=32,b.awrap(this.featuresService.initializeFromDisk());case 32:return this.launched=!0,o.next=35,b.awrap(this.notifyEvent(At.a.Launched));case 35:return o.next=37,b.awrap(this.handleStage(ve.Launched_10));case 37:return o.next=39,b.awrap(this.syncService.getDatabasePayloads());case 39:return r=o.sent,o.next=42,b.awrap(this.handleStage(ve.LoadingDatabase_11));case 42:if(!this.createdNewDatabase){o.next=45;break}return o.next=45,b.awrap(this.syncService.onNewDatabaseCreated());case 45:if(a=this.syncService.loadDatabasePayloads(r).then(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.dealloced){e.next=2;break}throw'Application has been destroyed.';case 2:return e.next=4,b.awrap(i.handleStage(ve.LoadedDatabase_12));case 4:return i.beginAutoSyncTimer(),e.next=7,b.awrap(i.syncService.sync({mode:Jr.DownloadFirst}));case 7:case"end":return e.stop()}},null,null,null,Promise)}),!e){o.next=49;break}return o.next=49,b.awrap(a);case 49:case"end":return o.stop()}},null,this,[[12,17]],Promise)}},{key:"onStart",value:function(){}},{key:"onLaunch",value:function(){}},{key:"getLaunchChallenge",value:function(){return this.protectionService.createLaunchChallenge()}},{key:"handleLaunchChallengeResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!e.challenge.hasPromptForValidationType(te.LocalPasscode)){a.next=9;break}if(n=null===(t=e.artifacts)||void 0===t?void 0:t.wrappingKey){a.next=7;break}return r=e.getValueForType(te.LocalPasscode),a.next=6,b.awrap(this.protocolService.computeWrappingKey(r.value));case 6:n=a.sent;case 7:return a.next=9,b.awrap(this.protocolService.unwrapRootKey(n));case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval(function(){e.syncService.log('Syncing from autosync'),e.sync()},3e4)}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(this.services);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(r.handleApplicationStage(e));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(_.M)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver(function(n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:n===e&&t(e);case 1:case"end":return r.stop()}},null,null,null,Promise)},e)}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e===At.a.Started?this.onStart():e===At.a.Launched&&this.onLaunch(),n=S(this.eventHandlers.slice());case 2:if((r=n()).done){i.next=14;break}if(!(a=r.value).singleEvent||a.singleEvent!==e){i.next=9;break}return i.next=7,b.awrap(a.callback(e,t||{}));case 7:i.next=12;break;case 9:if(a.singleEvent){i.next=12;break}return i.next=12,b.awrap(a.callback(e,t||{}));case 12:i.next=2;break;case 14:this.migrationService.handleApplicationEvent(e);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date}),n.next=3,b.awrap(this.payloadManager.emitPayload(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.syncService.sync());case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"findItem",value:function(e){return this.itemManager.findItem(e)}},{key:"allItems",value:function(){return this.itemManager.items}},{key:"findItems",value:function(e){return this.itemManager.itemsMatchingPredicate(e)}},{key:"getAll",value:function(e){return this.itemManager.findItems(e)}},{key:"mergeItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.emitItemFromPayload(e.payloadRepresentation(),t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createManagedItem",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=a.length>3?a[3]:void 0,i.abrupt("return",this.itemManager.createItem(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.createTemplateItem(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createItemFromPayload",value:function(e){return nt(e)}},{key:"createPayloadFromObject",value:function(e){return Object(Ee.e)(e)}},{key:"getLastSyncDate",value:function(){return this.syncService.getLastSyncDate()}},{key:"getSyncStatus",value:function(){return this.syncService.getStatus()}},{key:"getSessions",value:function(){return this.sessionManager.getSessionsList()}},{key:"revokeSession",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeSessionRevoking());case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.sessionManager.revokeSession(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.revokeAllOtherSessions());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"userCanManageSessions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent,!Object(_.w)(e)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",Object(Q.b)(e,Q.a.V004)>=0);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUserSubscription",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.sessionManager.getSubscription());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data.subscription);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getAvailableSubscriptions());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setItemNeedsSync",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]&&n[1],r.abrupt("return",this.itemManager.setItemDirty(e.uuid,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setItemsNeedsSync",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 2:return t.next=4,b.awrap(this.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emptyTrash",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.itemManager.emptyTrash());case 2:return e.next=4,b.awrap(this.sync());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getTrashedItems",value:function(){return this.itemManager.trashedItems}},{key:"setDisplayOptions",value:function(e,t,n,r){this.itemManager.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.itemManager.setNotesDisplayCriteria(e)}},{key:"getDisplayableItems",value:function(e){return this.itemManager.getDisplayableItems(e)}},{key:"insertItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=de(e,T.c.UserInteraction),n=t.getResult(),a.next=4,b.awrap(this.itemManager.emitItemFromPayload(n));case 4:return r=a.sent,a.abrupt("return",r);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"saveItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.itemManager.findItem(e)){n.next=3;break}throw Error('Attempting to save non-inserted item');case 3:if(t.dirty){n.next=6;break}return n.next=6,b.awrap(this.itemManager.changeItem(e,void 0,T.c.Internal));case 6:return n.next=8,b.awrap(this.syncService.sync());case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,Object(_.A)(e)){s.next=5;break}throw Error('Must use uuid to change item');case 5:return s.next=7,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0,r));case 7:return s.next=9,b.awrap(this.syncService.sync(a));case 9:return s.abrupt("return",this.findItem(e));case 10:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItems",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,s.next=5,b.awrap(this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0,r));case 5:return s.next=7,b.awrap(this.syncService.sync(a));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeItem",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=!(r.length>2&&void 0!==r[2])||r[2],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid to change item');case 3:return a.next=5,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0));case 5:return a.abrupt("return",this.findItem(e));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=!(r.length>2&&void 0!==r[2])||r[2],a.abrupt("return",this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"protectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNote(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNote(e));case 2:return t=n.sent,Object(_.w)(t)||this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.authorizeProtectedActionForNotes(e,t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.itemManager.getItems(e,t)}},{key:"notesMatchingSmartTag",value:function(e){return this.itemManager.notesMatchingSmartTag(e)}},{key:"referencesForItem",value:function(e,t){var n=this.itemManager.referencesForItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"referencingForItem",value:function(e,t){var n=this.itemManager.itemsReferencingItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"duplicateItem",value:function(e,t){var n=this.itemManager.duplicateItem(e.uuid,!1,t);return this.sync(),n}},{key:"findTagByTitle",value:function(e){return this.itemManager.findTagByTitle(e)}},{key:"searchTags",value:function(e,t){return this.itemManager.searchTags(e,t)}},{key:"isValidTagParent",value:function(e,t){return this.itemManager.isValidTagParent(e,t)}},{key:"setTagParent",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.itemManager.setTagParent(e,t));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unsetTagParent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.unsetTagParent(e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getTagParent",value:function(e){return this.itemManager.getTagParent(e.uuid)}},{key:"getTagParentChain",value:function(e){return this.itemManager.getTagParentChain(e.uuid)}},{key:"getTagChildren",value:function(e){return this.itemManager.getTagChildren(e.uuid)}},{key:"getSortedTagsForNote",value:function(e){return this.itemManager.getSortedTagsForNote(e)}},{key:"findOrCreateTag",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.findOrCreateTagByTitle(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){return this.itemManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.itemManager.noteCount}},{key:"streamItems",value:function(e,t){var n=this,r=this.itemManager.addObserver(e,function(e,n,r,a,i){var s=e.concat(n).concat(r);t(s,i)}),a=this.itemManager.getItems(e);return a.length>0&&t(a),this.streamRemovers.push(r),function(){r(),Object(_.M)(n.streamRemovers,r)}}},{key:"toggleComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.componentManager.toggleComponent(e));case 2:return t.next=4,b.awrap(this.syncService.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.apiService.setHost(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.apiService.getHost()}},{key:"setCustomHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.setHost(e));case 2:return t.next=4,b.awrap(this.webSocketsService.setWebSocketUrl(void 0));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUser",value:function(){if(!this.launched)throw Error('Attempting to access user before application unlocked');return this.sessionManager.getUser()}},{key:"getUserPasswordCreationDate",value:function(){return this.protocolService.getPasswordCreatedDate()}},{key:"getProtocolEncryptionDisplayName",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getEncryptionDisplayName());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getUserVersion",value:function(){return this.protocolService.getUserVersion()}},{key:"protocolUpgradeAvailable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isEncryptionAvailable",value:function(){return this.hasAccount()||this.hasPasscode()}},{key:"upgradeProtocolVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.credentialService.performProtocolUpgrade());case 2:return(e=t.sent).success?this.hasAccount()?this.alertService.alert(j.N.SuccessAccount):this.alertService.alert(j.N.SuccessPasscodeOnly):e.error&&this.alertService.alert(j.N.Fail),t.abrupt("return",e);case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"noAccount",value:function(){return!this.hasAccount()}},{key:"hasAccount",value:function(){return this.protocolService.hasAccount()}},{key:"hasProtectionSources",value:function(){return this.protectionService.hasProtectionSources()}},{key:"areProtectionsEnabled",value:function(){return this.protectionService.areProtectionsEnabled()}},{key:"getProtectionSessionExpiryDate",value:function(){return this.protectionService.getSessionExpiryDate()}},{key:"clearProtectionSession",value:function(){return this.protectionService.clearSession()}},{key:"authorizeNoteAccess",value:function(e){return this.protectionService.authorizeNoteAccess(e)}},{key:"authorizeAutolockIntervalChange",value:function(){return this.protectionService.authorizeAutolockIntervalChange()}},{key:"authorizeCloudLinkAccess",value:function(){return this.protectionService.authorizeCloudLinkAccess()}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.protectionService.authorizeSearchingProtectedNotesText()}},{key:"importData",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if(t=d.length>1&&void 0!==d[1]&&d[1],!e.version){h.next=11;break}if(n=e.version,this.protocolService.supportedVersions().includes(n)){h.next=6;break}return h.abrupt("return",{error:j.V});case 6:return h.next=8,b.awrap(this.getUserVersion());case 8:if(!(r=h.sent)||1!==Object(Q.b)(n,r)){h.next=11;break}return h.abrupt("return",{error:j.u});case 11:if(!e.auth_params&&!e.keyParams){h.next=20;break}return i=new ye([new ge(te.None,j.F.FileAccountPassword,void 0,!0)],ne.DecryptEncryptedFile,!0),h.next=15,b.awrap(this.challengeService.promptForChallengeResponse(i));case 15:if(s=h.sent,!Object(_.w)(s)){h.next=18;break}return h.abrupt("return");case 18:this.challengeService.completeChallenge(i),a=s.values[0].value;case 20:return h.next=22,b.awrap(this.protectionService.authorizeFileImport());case 22:if(h.sent){h.next=24;break}return h.abrupt("return");case 24:return h.next=26,b.awrap(this.protocolService.payloadsByDecryptingBackupFile(e,a));case 26:return o=h.sent,c=o.filter(function(e){return!e.errorDecrypting&&e.format!==ue.a.EncryptedString}).map(function(e){return e.content_type===F.a.Component&&e.safeContent.active?Object(Ee.b)(e,{content:sa(sa({},e.safeContent),{},{active:!1})}):e}),h.next=30,b.awrap(this.payloadManager.importPayloads(c));case 30:if(u=h.sent,l=this.sync(),!t){h.next=35;break}return h.next=35,b.awrap(l);case 35:return p=this.getAll(u),h.abrupt("return",{affectedItems:p,errorCount:o.length-c.length});case 37:case"end":return h.stop()}},null,this,null,Promise)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=i.length>1&&void 0!==i[1]&&i[1],n=e===Re.b.FileEncrypted,r=e===Re.b.FileDecrypted,a=n&&t||r,s.t0=a,!s.t0){s.next=9;break}return s.next=8,b.awrap(this.protectionService.authorizeBackupCreation(n));case 8:s.t0=!s.sent;case 9:if(!s.t0){s.next=11;break}return s.abrupt("return");case 11:return s.abrupt("return",this.protocolService.createBackupFile(e));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"sync",value:function(e){return this.syncService.sync(e)}},{key:"isOutOfSync",value:function(){return this.syncService.isOutOfSync()}},{key:"resolveOutOfSync",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.storageService.setValue(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){return this.storageService.getValue(e,t)}},{key:"removeValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.storageService.removeValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getPreference",value:function(e,t){return this.preferencesService.getValue(e,t)}},{key:"setPreference",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.preferencesService.setValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"prepareForDeinit",value:function(){var e,t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e=n.length>0&&void 0!==n[0]?n[0]:0,t=Promise.all(this.services.map(function(e){return e.blockDeinit()})),0!==e){r.next=7;break}return r.next=5,b.awrap(t);case 5:r.next=9;break;case 7:return r.next=9,b.awrap(Promise.race([t,Object(_.P)(e)]));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"promptForCustomChallenge",value:function(e){var t;return null===(t=this.challengeService)||void 0===t?void 0:t.promptForChallengeResponse(e)}},{key:"addChallengeObserver",value:function(e,t){return this.challengeService.addChallengeObserver(e,t)}},{key:"submitValuesForChallenge",value:function(e,t){return this.challengeService.submitValuesForChallenge(e,t)}},{key:"cancelChallenge",value:function(e){this.challengeService.cancelChallenge(e)}},{key:"setOnDeinit",value:function(e){this.onDeinit=e}},{key:"deinit",value:function(e){var t;clearInterval(this.autoSyncInterval);for(var n,r=S(this.serviceObservers);!(n=r()).done;){(0,n.value)()}for(var a,i=S(this.managedSubscribers);!(a=i()).done;){(0,a.value)()}for(var s,o=S(this.services);!(s=o()).done;){s.value.deinit()}null===(t=this.onDeinit)||void 0===t||t.call(this,this,e),this.onDeinit=void 0,this.crypto=void 0,this.createdNewDatabase=!1,this.services.length=0,this.serviceObservers.length=0,this.managedSubscribers.length=0,this.streamRemovers.length=0,this.clearServices(),this.dealloced=!0,this.started=!1}},{key:"register",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=!(a.length>3&&void 0!==a[3])||a[3],i.abrupt("return",this.credentialService.register(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return n=s.length>2&&void 0!==s[2]&&s[2],r=s.length>3&&void 0!==s[3]&&s[3],a=!(s.length>4&&void 0!==s[4])||s[4],i=s.length>5&&void 0!==s[5]&&s[5],o.abrupt("return",this.credentialService.signIn(e,t,n,r,a,i));case 5:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeEmail",value:function(e,t,n){var r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:A.g.EmailChange,i.abrupt("return",this.credentialService.changeCredentials({currentPassword:t,newEmail:e,passcode:n,origination:r,validateNewPasswordStrength:!1}));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"changePassword",value:function(e,t,n){var r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=i.length>3&&void 0!==i[3]?i[3]:A.g.PasswordChange,a=!(i.length>4&&void 0!==i[4])||i[4],s.abrupt("return",this.credentialService.changeCredentials({currentPassword:e,newPassword:t,passcode:n,origination:r,validateNewPasswordStrength:a}));case 3:case"end":return s.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e=i.length>0&&void 0!==i[0]&&i[0],t=function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(a.credentialService.signOut());case 2:return e.next=4,b.awrap(a.notifyEvent(At.a.SignedOut));case 4:return e.next=6,b.awrap(a.prepareForDeinit());case 6:a.deinit(C.SignOut);case 7:case"end":return e.stop()}},null,null,null,Promise)},!e){s.next=6;break}return s.next=5,b.awrap(t());case 5:return s.abrupt("return");case 6:if(!((n=this.itemManager.getDirtyItems()).length>0)){s.next=17;break}return r=1===n.length,s.next=11,b.awrap(this.alertService.confirm("There ".concat(r?'is':'are'," ").concat(n.length," ").concat(r?'item':'items'," with unsynced changes. If you sign out, these changes will be lost forever. Are you sure you want to sign out?")));case 11:if(!s.sent){s.next=15;break}return s.next=15,b.awrap(t());case 15:s.next=19;break;case 17:return s.next=19,b.awrap(t());case 19:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleRevokedSession",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.revokingSession){t.next=2;break}return t.abrupt("return");case 2:return this.revokingSession=!0,e=this.alertService,t.next=6,b.awrap(this.signOut(!0));case 6:e.alert(j.R.CurrentSessionRevoked);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.protocolService.validateAccountPassword(e));case 2:return t=r.sent,n=t.valid,r.abrupt("return",n);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isStarted",value:function(){return this.started}},{key:"isLaunched",value:function(){return this.launched}},{key:"hasBiometrics",value:function(){return this.protectionService.hasBiometricsEnabled()}},{key:"enableBiometrics",value:function(){return this.protectionService.enableBiometrics()}},{key:"disableBiometrics",value:function(){return this.protectionService.disableBiometrics()}},{key:"hasPasscode",value:function(){return this.protocolService.hasPasscode()}},{key:"isLocked",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.challengeService.isPasscodeLocked());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"lock",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=500,t.next=3,b.awrap(this.prepareForDeinit(e));case 3:return t.abrupt("return",this.deinit(C.Lock));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"addPasscode",value:function(e){return this.credentialService.addPasscode(e)}},{key:"removePasscode",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.credentialService.removePasscode());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"changePasscode",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:A.g.PasscodeChange,r.abrupt("return",this.credentialService.changePasscode(e,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.storageService.getStorageEncryptionPolicy()}},{key:"setStorageEncryptionPolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setEncryptionPolicy(e));case 2:return t.abrupt("return",this.protocolService.repersistAllItems());case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableEphemeralPersistencePolicy",value:function(){return this.storageService.setPersistencePolicy(Oe.Ephemeral)}},{key:"hasPendingMigrations",value:function(){return this.migrationService.hasPendingMigrations()}},{key:"generateUuid",value:function(){return I.GenerateUuid()}},{key:"presentKeyRecoveryWizard",value:function(){return this.keyRecoveryService.processPersistedUndecryptables()}},{key:"changeDeviceInterface",value:function(e){this.deviceInterface=e;for(var t,n=S(this.services);!(t=n()).done;){var r=t.value;r.deviceInterface&&(r.deviceInterface=e)}}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.settingsService.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=r.length>2&&void 0!==r[2]&&r[2],a.abrupt("return",this.settingsService.updateSetting(e,t,n));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){return this.mfaService.isMfaFeatureAvailable()}},{key:"isMfaActivated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.isMfaActivated());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.generateMfaSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mfaService.getOtpToken(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.mfaService.enableMfa(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protectionService.authorizeMfaDisable());case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",this.mfaService.disableMfa());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"downloadExternalFeature",value:function(e){return this.featuresService.validateAndDownloadExternalFeature(e)}},{key:"getFeature",value:function(e){return this.featuresService.getFeature(e)}},{key:"getFeatureStatus",value:function(e){return this.featuresService.getFeatureStatus(e)}},{key:"getNewSubscriptionToken",value:function(){return this.apiService.getNewSubscriptionToken()}},{key:"setOfflineFeaturesCode",value:function(e){return this.featuresService.setOfflineFeaturesCode(e)}},{key:"hasOfflineRepo",value:function(){return this.featuresService.hasOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.featuresService.deleteOfflineFeatureRepo());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isThirdPartyHostUsed",value:function(){return this.apiService.isThirdPartyHostUsed()}},{key:"constructServices",value:function(){this.createPayloadManager(),this.createItemManager(),this.createStorageManager(),this.createProtocolService();var e={payloadByEncryptingPayload:this.protocolService.payloadByEncryptingPayload.bind(this.protocolService),payloadByDecryptingPayload:this.protocolService.payloadByDecryptingPayload.bind(this.protocolService)};this.storageService.encryptionDelegate=e,this.createChallengeService(),this.createHttpManager(),this.createApiService(),this.createWebSocketsService(),this.createSessionManager(),this.createHistoryManager(),this.createSyncManager(),this.createProtectionService(),this.createCredentialService(),this.createKeyRecoveryService(),this.createSingletonManager(),this.createComponentManager(),this.createActionsManager(),this.createPreferencesService(),this.createSettingsService(),this.createFeaturesService(),this.createMigrationService(),this.createMfaService()}},{key:"clearServices",value:function(){this.migrationService=void 0,this.alertService=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.sessionManager=void 0,this.syncService=void 0,this.challengeService=void 0,this.singletonManager=void 0,this.componentManager=void 0,this.protectionService=void 0,this.actionsManager=void 0,this.historyManager=void 0,this.itemManager=void 0,this.keyRecoveryService=void 0,this.preferencesService=void 0,this.featuresService=void 0,this.credentialService=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.mfaService=void 0,this.services=[]}},{key:"createFeaturesService",value:function(){var e=this;this.featuresService=new dr(this.storageService,this.apiService,this.itemManager,this.componentManager,this.webSocketsService,this.settingsService,this.credentialService,this.syncService,this.alertService,this.sessionManager,this.crypto),this.serviceObservers.push(this.featuresService.addEventObserver(function(t){switch(t){case cr.UserRolesChanged:e.notifyEvent(At.a.UserRolesChanged);break;case cr.FeaturesUpdated:e.notifyEvent(At.a.FeaturesUpdated);break;default:Object(_.f)(t)}})),this.services.push(this.featuresService)}},{key:"createWebSocketsService",value:function(){this.webSocketsService=new lr(this.storageService,this.webSocketUrl),this.services.push(this.webSocketsService)}},{key:"createMigrationService",value:function(){this.migrationService=new En({protocolService:this.protocolService,deviceInterface:this.deviceInterface,storageService:this.storageService,sessionManager:this.sessionManager,challengeService:this.challengeService,itemManager:this.itemManager,singletonManager:this.singletonManager,featuresService:this.featuresService,environment:this.environment,identifier:this.identifier}),this.services.push(this.migrationService)}},{key:"createCredentialService",value:function(){var e=this;this.credentialService=new Qe(this.sessionManager,this.syncService,this.storageService,this.itemManager,this.protocolService,this.alertService,this.challengeService,this.protectionService),this.serviceObservers.push(this.credentialService.addEventObserver(function(t){switch(t){case Ye.SignedInOrRegistered:e.notifyEvent(At.a.SignedIn);break;default:Object(_.f)(t)}})),this.services.push(this.credentialService)}},{key:"createApiService",value:function(){this.apiService=new Yt(this.httpService,this.storageService,this.defaultHost),this.services.push(this.apiService)}},{key:"createItemManager",value:function(){this.itemManager=new _r(this.payloadManager),this.services.push(this.itemManager)}},{key:"createComponentManager",value:function(){var e=this.getClass(an);this.componentManager=new e(this.itemManager,this.syncService,this.alertService,this.environment,this.platform,this.deviceInterface.timeout),this.services.push(this.componentManager)}},{key:"createHttpManager",value:function(){this.httpService=new jt(this.environment,this.appVersion),this.services.push(this.httpService)}},{key:"createPayloadManager",value:function(){this.payloadManager=new sn,this.services.push(this.payloadManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new cn(this.itemManager,this.syncService),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new Ie(this.deviceInterface,this.alertService,this.identifier,this.environment),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(){var e=this;this.protocolService=new Gn(this.itemManager,this.payloadManager,this.deviceInterface,this.storageService,this.identifier,this.crypto),this.protocolService.onKeyStatusChange(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.notifyEvent(At.a.KeyStatusChanged));case 2:case"end":return t.stop()}},null,null,null,Promise)}),this.services.push(this.protocolService)}},{key:"createKeyRecoveryService",value:function(){this.keyRecoveryService=new Mt(this.itemManager,this.payloadManager,this.apiService,this.protocolService,this.challengeService,this.alertService,this.storageService,this.syncService,this.credentialService),this.services.push(this.keyRecoveryService)}},{key:"createSessionManager",value:function(){var e=this;this.sessionManager=new Ge(this.storageService,this.apiService,this.alertService,this.protocolService,this.challengeService,this.webSocketsService),this.serviceObservers.push(this.sessionManager.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=t,n.next=n.t0===ze.Restored?3:n.t0===ze.Revoked?5:8;break;case 3:return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.sync());case 2:e.protocolService.needsNewRootKeyBasedItemsKey()&&e.protocolService.createNewDefaultItemsKey().then(function(){e.sync()});case 3:case"end":return t.stop()}},null,null,null,Promise),n.abrupt("break",9);case 5:return n.next=7,b.awrap(e.handleRevokedSession());case 7:return n.abrupt("break",9);case 8:Object(_.f)(t);case 9:case"end":return n.stop()}},null,null,null,Promise)})),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new ea(this.itemManager,this.sessionManager,this.protocolService,this.storageService,this.payloadManager,this.apiService,this.historyManager,this.deviceInterface.interval);var t=this.syncService.addEventObserver(function(t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(n=Object(At.c)(t))){r.next=9;break}return r.next=4,b.awrap(e.notifyEvent(n));case 4:if(n!==At.a.CompletedFullSync){r.next=9;break}if(e.handledFullSyncStage){r.next=9;break}return e.handledFullSyncStage=!0,r.next=9,b.awrap(e.handleStage(ve.FullSyncCompleted_13));case 9:return r.next=11,b.awrap(e.protocolService.onSyncEvent(t));case 11:case"end":return r.stop()}},null,null,null,Promise)});this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createChallengeService",value:function(){this.challengeService=new na(this.storageService,this.protocolService),this.services.push(this.challengeService)}},{key:"createProtectionService",value:function(){var e=this;this.protectionService=new ir(this.protocolService,this.challengeService,this.storageService,this.itemManager),this.serviceObservers.push(this.protectionService.addEventObserver(function(t){t===Zn.SessionExpiryDateChanged&&e.notifyEvent(At.a.ProtectionSessionExpiryDateChanged)})),this.services.push(this.protectionService)}},{key:"createHistoryManager",value:function(){this.historyManager=new nr(this.itemManager,this.storageService,this.apiService,this.protocolService,this.deviceInterface),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new hn(this.itemManager,this.alertService,this.deviceInterface,this.httpService,this.payloadManager,this.protocolService,this.syncService),this.services.push(this.actionsManager)}},{key:"createPreferencesService",value:function(){var e=this;this.preferencesService=new ra(this.singletonManager,this.itemManager,this.syncService),this.serviceObservers.push(this.preferencesService.addEventObserver(function(){e.notifyEvent(At.a.PreferencesChanged)})),this.services.push(this.preferencesService)}},{key:"createSettingsService",value:function(){this.settingsService=new hr.SNSettingsService(this.sessionManager,this.apiService),this.services.push(this.settingsService)}},{key:"createMfaService",value:function(){this.mfaService=new aa(this.settingsService,this.crypto,this.featuresService),this.services.push(this.mfaService)}},{key:"getClass",value:function(e){var t=this.swapClasses.find(function(t){return t.swap===e});return t?t.with:e}}]),e})(),ua=(function(){function e(t,n){v(this,e),this.timeout=t||setTimeout.bind(Object(_.r)()),this.interval=n||setInterval.bind(Object(_.r)())}return y(e,[{key:"deinit",value:function(){this.timeout=void 0,this.interval=void 0}},{key:"getJsonParsedRawStorageValue",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getRawStorageValue(e));case 2:if(t=n.sent,!Object(_.w)(t)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.prev=5,n.abrupt("return",JSON.parse(t));case 9:return n.prev=9,n.t0=n.catch(5),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,[[5,9]],Promise)}}]),e})(),la=(function(){function e(t,n,r){var a=this;v(this,e),this.item=n.findItem(t),r&&r(this.item),this.removeObserver=n.streamItems(this.item.content_type,function(e){var n;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:(n=e.find(function(e){return e.uuid===t}))&&(a.item=n,r&&r(a.item));case 2:case"end":return i.stop()}},null,null,null,Promise)})}return y(e,[{key:"deinit",value:function(){this.removeObserver?(this.removeObserver(),this.removeObserver=void 0):console.error('A LiveItem is attempting to be deinited more than once.')}}]),e})(),pa=n(95)}])},'object'==typeof i&&'object'==typeof a?a.exports=c():'function'==typeof define&&define.amd?define("SNLibrary",[],c):'object'==typeof i?i.SNLibrary=c():o.SNLibrary=c()},443,[12,35,22,9,11,13,7,8,249,43,279,6]);^~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:449:66542: warning: the variable "setInterval" was not declared in anonymous function " 2117#"__d(function(e,t,n,r,a,i,s){var o,c,u=t(s[0]),l=t(s[1]),p=t(s[2]),d=t(s[3]),h=t(s[4]),f=t(s[5]),v=t(s[6]),y=t(s[7]),g=t(s[8]),m=t(s[9]),b=t(s[10]),w=t(s[11]);function k(e){var t=x();return function(){var n,r=f(e);if(t){var a=f(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return h(this,n)}}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=P(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o=window,c=function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=246)})([function(e,t,n){"use strict";(function(e){n.d(t,"r",function(){return y}),n.d(t,"n",function(){return g}),n.d(t,"C",function(){return k}),n.d(t,"y",function(){return x}),n.d(t,"q",function(){return P}),n.d(t,"O",function(){return O}),n.d(t,"h",function(){return C}),n.d(t,"x",function(){return D}),n.d(t,"v",function(){return _}),n.d(t,"w",function(){return E}),n.d(t,"t",function(){return R}),n.d(t,"A",function(){return I}),n.d(t,"s",function(){return M}),n.d(t,"U",function(){return A}),n.d(t,"V",function(){return j}),n.d(t,"W",function(){return T}),n.d(t,"F",function(){return K}),n.d(t,"o",function(){return F}),n.d(t,"R",function(){return L}),n.d(t,"M",function(){return U}),n.d(t,"b",function(){return N}),n.d(t,"p",function(){return V}),n.d(t,"c",function(){return B}),n.d(t,"g",function(){return W}),n.d(t,"N",function(){return H}),n.d(t,"d",function(){return z}),n.d(t,"H",function(){return q}),n.d(t,"Q",function(){return Y}),n.d(t,"K",function(){return G}),n.d(t,"j",function(){return Q}),n.d(t,"S",function(){return J}),n.d(t,"E",function(){return $}),n.d(t,"J",function(){return X}),n.d(t,"I",function(){return Z}),n.d(t,"D",function(){return ee}),n.d(t,"a",function(){return te}),n.d(t,"m",function(){return ne}),n.d(t,"L",function(){return re}),n.d(t,"l",function(){return ae}),n.d(t,"B",function(){return ie}),n.d(t,"T",function(){return se}),n.d(t,"P",function(){return oe}),n.d(t,"f",function(){return ce}),n.d(t,"z",function(){return ue}),n.d(t,"G",function(){return le}),n.d(t,"e",function(){return pe}),n.d(t,"i",function(){return ye}),n.d(t,"u",function(){return ge}),n.d(t,"k",function(){return me});var r=n(27),a=n.n(r),i=n(25),s=n.n(i),o=n(23),c=n.n(o),u=n(97),l=n.n(u),p=n(66),d=n.n(p),h=n(28),f=n.n(h),v='undefined'!=typeof Intl?new Intl.Collator('en',{numeric:!0}):void 0;function y(){return'undefined'!=typeof window?window:void 0!==e?e:null}function g(e){return Object.keys(e).map(function(t){return e[t]})}function k(){return null!==y()&&!x()&&!(document&&document.documentMode)||/Edge/.test(navigator.userAgent)&&window.crypto&&!!window.crypto.subtle}function x(){return'undefined'!=typeof navigator&&'ReactNative'===navigator.product}function P(e,t,n){return e.find(function(e){return e[t]===n})}function O(e,t){return s()(e,t)}function C(){for(var e=[],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var a=0,i=n;a<i.length;a++){var s=i[a];e=e.concat(s)}return e}function D(e){return null!==e&&('function'==typeof e||'object'==typeof e)}function _(e){return null!==e&&'function'==typeof e}function E(e){return null===e||void 0===e}function R(e){return!e||0===e.length}function I(e){return'string'==typeof e||e instanceof String}function M(e,t){return e>t?e:t}function A(e,t,n){return d()(e.concat(t),function(e,t){for(var r,a=S(n);!(r=a()).done;){var i=r.value;if(e[i]!==t[i])return!1}return!0})}function j(e){return f()(e)}function T(e,t){return d()(e,function(e,n){return e[t]===n[t]})}function K(e){return e[e.length-1]}function F(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;e.push(a)}}function L(e,t){for(var n,r=S(t);!(n=r()).done;){U(e,n.value)}}function U(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}function N(e,t){return!e.includes(t)&&(e.push(t),!0)}function V(e,t){a()(e,t)}function B(e,t){return e.filter(function(e){return!t.includes(e)}).concat(t.filter(function(t){return!e.includes(t)}))}function W(e,t){return!(e&&!t||!e&&t)&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof String&&t instanceof String?e===t:J(e,t))}function H(e,t){e.splice(t,1)}function z(e,t){var n=e.slice();return H(n,t),n}function q(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];t.push(e[a])}return t}function Y(e){for(var t,n={},r=S(Object.keys(e).sort());!(t=r()).done;){var a=t.value;n[a]=e[a]}return te(n)}function G(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];E(e[a])||(t[a]=e[a])}return t}function Q(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort(function(e,r){var a=e[t].getTime(),i=r[t].getTime(),s=n?1:-1;return a<i?-1*s:a>i?1*s:0})}function J(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var a=0,i=n;a<i.length;a++){var s=i[a];if(e[s]!==t[s])return!1}return!0}function $(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=void 0;try{i=JSON.parse(e[a])}catch(t){i=e[a]}t[a]=i}return t}function X(e,t){if(e)for(var n,r=S(t);!(n=r()).done;){delete e[n.value]}}function Z(e,t){if(!E(e)){for(var n,r=w({},e),a=S(t);!(n=a()).done;){delete r[n.value]}return r}}function ee(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(function(e,t){return 0===t?e.trim().replace(/[/]*$/g,''):e.trim().replace(/(^[/]*|[/]*$)/g,'')}).filter(function(e){return e.length}).join('/')}function te(e){return e instanceof Date?new Date(e):D(e)?JSON.parse(JSON.stringify(e)):e}function ne(e,t){if(!e||!t)throw'Attempting to deepMerge with null values';return l()(e,t,function(e,t){if(c()(e))return t}),e}function re(e,t){for(var n,r={},a=S(t);!(n=a()).done;){var i=n.value;r[i]=e[i]}return te(r)}function ae(e){for(var t,n=S(Object.getOwnPropertyNames(e));!(t=n()).done;){var r=t.value,a=e[r];a&&'object'==typeof a&&!Object.isFrozen(a)?e[r]=ae(a):e[r]=a}return Object.freeze(e)}function ie(e){try{return new URL(e),!0}catch(e){return!1}}function se(e,t){var n=t/4;return e.substring(0,n)}function oe(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Sleeping for ".concat(e,"ms")),t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},e)}));case 2:case"end":return t.stop()}},null,null,null,Promise)}function ce(e){throw Error('Unchecked case '+e)}function ue(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function le(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc'){case'asc':return m(e).sort(v?function(e,n){return v.compare(e[t],n[t])}:function(e,n){return e[t].localeCompare(n[t],'en',{numeric:!0})});case'desc':return m(e).sort(v?function(e,n){return v.compare(n[t],e[t])}:function(e,n){return n[t].localeCompare(e[t],'en',{numeric:!0})})}}function pe(e,t){return e.length===t.length&&(e.every(function(e){return t.includes(e)})&&t.every(function(t){return e.includes(t)}))}var de,he,fe=1e3,ve=1e3;function ye(e){switch(String(e).length){case de.Seconds:return e*ve;case de.Milliseconds:return e;case de.Microseconds:return Math.floor(e/fe);default:throw"Unhandled timestamp precision: ".concat(e)}}function ge(e){return void 0!==e.error}function me(e){if('undefined'!=typeof Intl&&Intl.DateTimeFormat&&'undefined'!=typeof navigator){if(!he){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;he=new Intl.DateTimeFormat(t,{year:'numeric',month:'short',day:'2-digit',weekday:'long',hour:'2-digit',minute:'2-digit'})}return he.format(e)}return e.toDateString()+' '+e.toLocaleTimeString()}!(function(e){e[e.Seconds=10]="Seconds",e[e.Milliseconds=13]="Milliseconds",e[e.Microseconds=16]="Microseconds"})(de||(de={}))}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"e",function(){return m}),n.d(t,"g",function(){return b}),n.d(t,"d",function(){return w}),n.d(t,"f",function(){return k}),n.d(t,"b",function(){return x}),n.d(t,"c",function(){return O}),n.d(t,"a",function(){return C});var r=n(32),a=n(4),i=n(8),s=n(0),o=n(5),c=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey,o.a.LastSyncBegan,o.a.LastSyncEnd,o.a.DuplicateOf]),u=Object.freeze([o.a.Uuid,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.Legacy003AuthHash,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey]),l=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Legacy003AuthHash,o.a.DuplicateOf]),p=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.WaitingForKey,o.a.DuplicateOf]),d=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.DuplicateOf]),h=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.Content,o.a.ServerUpdatedAt]),f=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),v=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),y=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ServerUpdatedAt,o.a.ServerUpdatedAtTimestamp,o.a.CreatedAtTimestamp,o.a.Deleted,o.a.Dirty,o.a.LastSyncEnd]),g=Object.freeze(d.slice());function m(e,t,n){return P(e,c.slice(),n,t)}function b(e,t,n,r){for(var a,i={},s=S(n||t.fields);!(a=s()).done;){var o=a.value;i[o]=t[o]}if(r)for(var c=0,u=Object.keys(r);c<u.length;c++){var l=u[c];i[l]=r[l]}return x(e,i)}function w(e,t,n){return P(e,D(t),a.a.Constructor,n)}function k(e,t,n){return P(e,_(t),t,n)}function x(e,t){return P(e,e.fields,e.source,t)}function P(e,t,n,i){for(var o,c=Object(s.L)(e,t),u=i instanceof r.a?i.fields.slice():Object.keys(i||[]),l=S(u);!(o=l()).done;){var p=o.value,d=i[p];c[p]=d?Object(s.a)(d):d}var h=Object(s.V)(t.concat(u));return new r.a(c,h,n||a.a.Constructor)}function O(e,t){return P(e,Object.keys(e),t)}function C(e,t){return P(e,u.slice(),void 0,t)}function D(e){if(e===i.b.FileEncrypted||e===i.b.FileDecrypted||e===i.b.FilePreferEncrypted)return l.slice();if(e===i.b.LocalStoragePreferEncrypted||e===i.b.LocalStorageDecrypted||e===i.b.LocalStorageEncrypted)return p.slice();if(e===i.b.Sync||e===i.b.SyncDecrypted)return d.slice();throw"No payload fields found for intent ".concat(e)}function _(e){if(e===a.a.FileImport)return l.slice();if(e===a.a.SessionHistory)return h.slice();if(e===a.a.RemoteHistory)return g.slice();if(e===a.a.ComponentRetrieved)return f.slice();if(e===a.a.ComponentCreated)return v.slice();if(e===a.a.LocalRetrieved||e===a.a.LocalChanged)return p.slice();if(e===a.a.RemoteRetrieved||e===a.a.ConflictData||e===a.a.ConflictUuid||e===a.a.RemoteRejected)return d.slice();if(e===a.a.LocalSaved||e===a.a.RemoteSaved)return y.slice();throw"No payload fields found for source ".concat(e)}},function(e,t,n){"use strict";n.d(t,"k",function(){return a}),n.d(t,"l",function(){return i}),n.d(t,"j",function(){return s}),n.d(t,"m",function(){return o}),n.d(t,"r",function(){return c}),n.d(t,"p",function(){return u}),n.d(t,"a",function(){return l}),n.d(t,"i",function(){return p}),n.d(t,"n",function(){return d}),n.d(t,"s",function(){return h}),n.d(t,"q",function(){return f}),n.d(t,"o",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"h",function(){return g}),n.d(t,"g",function(){return m}),n.d(t,"b",function(){return b}),n.d(t,"f",function(){return w}),n.d(t,"t",function(){return k}),n.d(t,"c",function(){return x}),n.d(t,"e",function(){return S}),n.d(t,"C",function(){return P}),n.d(t,"X",function(){return O}),n.d(t,"A",function(){return C}),n.d(t,"L",function(){return D}),n.d(t,"W",function(){return _}),n.d(t,"E",function(){return E}),n.d(t,"D",function(){return R}),n.d(t,"K",function(){return I}),n.d(t,"J",function(){return M}),n.d(t,"Y",function(){return A}),n.d(t,"Q",function(){return j}),n.d(t,"v",function(){return T}),n.d(t,"O",function(){return K}),n.d(t,"z",function(){return F}),n.d(t,"U",function(){return L}),n.d(t,"G",function(){return U}),n.d(t,"T",function(){return N}),n.d(t,"V",function(){return V}),n.d(t,"u",function(){return B}),n.d(t,"F",function(){return W}),n.d(t,"y",function(){return H}),n.d(t,"P",function(){return z}),n.d(t,"S",function(){return q}),n.d(t,"N",function(){return Y}),n.d(t,"H",function(){return G}),n.d(t,"w",function(){return Q}),n.d(t,"R",function(){return J}),n.d(t,"x",function(){return $}),n.d(t,"M",function(){return X}),n.d(t,"B",function(){return Z}),n.d(t,"I",function(){return ee});var r=n(13),a='A server error occurred while trying to sign in. Please try again.',i='A server error occurred while trying to register. Please try again.',s='Something went wrong while changing your credentials. Your credentials were not changed. Please try again.',o='Could not connect to server.',c='An existing registration request is already in progress.',u='An existing sign in request is already in progress.',l='An existing change credentials request is already in progress.',p='Invalid email or password.',d='A server error occurred while trying to refresh your session. Please try again.',h='Your account session is being renewed with the server. Please try your request again.',f='Too many successive server requests. Please wait a few minutes and try again.',v='Please sign in to an account in order to continue with your request.',y='Failed to get settings.',g='Failed to update settings.',m="Failed to get subscription's information.",b='Failed to access purchase flow.',w='Failed to get offline features.',k="The extension you are attempting to install comes from an \n  untrusted source. Untrusted extensions may lower the security of your data. Do you want to continue?",x="Error downloading package details. Please check the \n  extension link and try again.",S='An unknown issue occurred during offline activation. Please try again.',P='Invalid extension URL.',O='This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.',C='The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.',D='The encryption version for your account is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.com/help/security for more information.',_='Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.',E='Unable to sign in due to insecure password parameters. Please visit standardnotes.com/help/security for more information.',R='Invalid password.',I='Update Recommended',M='Sign In',A="Upgrading your account's encryption version\u2026",j='Setting passcode\u2026',T='Changing passcode\u2026',K='Removing passcode\u2026',F='Do not close the application until this process completes.',L='Unknown error.';function U(e){return"Your password must be at least ".concat(e," characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.")}function N(e,t){return"Strict Sign In has refused the server's sign-in parameters. The latest account version is ".concat(t,", but the server is reporting a version of ").concat(e," for your account. If you'd like to proceed with sign in anyway, please disable Strict Sign In and try again.")}var V='This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.',B="This backup file was created using a newer encryption version than your account's. Please run the available encryption upgrade and try again.",W={FileAccountPassword:'File account password'},H={PasscodeRequired:'Your passcode is required to process your credentials change.',Failed:'Unable to change your credentials due to a sync error. Please try again.'},z={PasscodeRequired:'Your passcode is required in order to register for an account.'},q={PasscodeRequired:'Your passcode is required in order to sign in to your account.',IncorrectMfa:'Incorrect two-factor authentication code. Please try again.',SignInCanceledMissingMfa:'Your sign in request has been canceled.'},Y={SuccessAccount:"Your encryption version has been successfully upgraded. You may be asked to enter your credentials again on other devices you're signed into.",SuccessPasscodeOnly:'Your encryption version has been successfully upgraded.',Fail:'Unable to upgrade encryption version. Please try again.',UpgradingPasscode:'Upgrading local encryption...'},G={KeyRecoveryLoginFlowPrompt:function(e){var t,n=null===(t=e.createdDate)||void 0===t?void 0:t.toLocaleString();switch(e.origination){case r.g.EmailChange:return"Enter your account password as it was when you changed your email on ".concat(n,".");case r.g.PasswordChange:return"Enter your account password after it was changed on ".concat(n,".");case r.g.Registration:return"Enter your account password as it was when you registered ".concat(n,".");case r.g.ProtocolUpgrade:return"Enter your account password as it was when you upgraded your encryption version on ".concat(n,".");case r.g.PasscodeChange:return"Enter your application passcode after it was changed on ".concat(n,".");case r.g.PasscodeCreate:return"Enter your application passcode as it was when you created it on ".concat(n,".");default:throw Error('Unhandled KeyParamsOrigination case for KeyRecoveryLoginFlowPrompt')}},KeyRecoveryLoginFlowReason:'Your account password is required to revalidate your session.',KeyRecoveryLoginFlowInvalidPassword:'Incorrect credentials entered. Please try again.',KeyRecoveryRootKeyReplaced:'Your credentials have successfully been updated.',KeyRecoveryPasscodeRequiredTitle:'Passcode Required',KeyRecoveryPasscodeRequiredText:'You must enter your passcode in order to save your new credentials.',KeyRecoveryPasswordRequired:'Your account password is required to recover an encryption key.',KeyRecoveryKeyRecovered:'Your key has successfully been recovered.',KeyRecoveryUnableToRecover:'Unable to recover your key with the attempted password. Please try again.'},Q={Generic:'Authentication Required',Migration:'Storage Update'},J={EnterEmailAndPassword:'Please enter your account email and password.',RecoverSession:function(e){return e?"Your credentials are needed for ".concat(e," to refresh your session with the server."):'Your credentials are needed to refresh your session with the server.'},SessionRestored:'Your session has been successfully restored.',EnterMfa:'Please enter your two-factor authentication code.',MfaInputPlaceholder:'Two-factor authentication code',EmailInputPlaceholder:'Email',PasswordInputPlaceholder:'Password',KeychainRecoveryErrorTitle:'Invalid Credentials',KeychainRecoveryError:'The email or password you entered is incorrect.\n\nPlease note that this sign-in request is made against the default server. If you are using a custom server, you must uninstall the app then reinstall, and sign back into your account.',RevokeTitle:'Revoke this session?',RevokeConfirmButton:'Revoke',RevokeCancelButton:'Cancel',RevokeText:"The associated app will be signed out and all data removed from the device when it is next launched. You can sign back in on that device at any time.",CurrentSessionRevoked:"Your session has been revoked and all local data has been removed from this device."},$={UnlockApplication:'Authentication is required to unlock the application',NoteAccess:'Authentication is required to view this note',ImportFile:'Authentication is required to import a backup file',AddPasscode:'Authentication is required to add a passcode',RemovePasscode:'Authentication is required to remove your passcode',ChangePasscode:'Authentication is required to change your passcode',ChangeAutolockInterval:'Authentication is required to change autolock timer duration',RevokeSession:'Authentication is required to revoke a session',AccessCloudLink:'Authentication is required to access CloudLink',EnterAccountPassword:'Enter your account password',EnterLocalPasscode:'Enter your application passcode',EnterPasscodeForMigration:'Your application passcode is required to perform an upgrade of your local data storage structure.',EnterPasscodeForRootResave:'Enter your application passcode to continue',EnterCredentialsForProtocolUpgrade:'Enter your credentials to perform encryption upgrade',EnterCredentialsForDecryptedBackupDownload:'Enter your credentials to download a decrypted backup',AccountPasswordPlaceholder:'Account Password',LocalPasscodePlaceholder:'Application Passcode',DecryptEncryptedFile:'Enter the account password associated with the import file',ExportBackup:'Authentication is required to export a backup',DisableBiometrics:'Authentication is required to disable biometrics',UnprotectNote:'Authentication is required to unprotect a note',SearchProtectedNotesText:'Authentication is required to search protected contents',SelectProtectedNote:'Authentication is required to select a protected note',DisableMfa:'Authentication is required to disable two-factor authentication'},X={AccountPassword:'Account Password',LocalPasscode:'Application Passcode',Biometrics:'Biometrics',RememberFor:'Remember For',Mfa:'Two-factor Authentication Code'},Z={MissingSessionTitle:'Missing Session',MissingSessionBody:'We were unable to load your server session. This represents an inconsistency with your application state. Please take an opportunity to backup your data, then sign out and sign back in to resolve this issue.',StorageDecryptErrorTitle:'Storage Error',StorageDecryptErrorBody:"We were unable to decrypt your local storage. Please restart the app and try again. If you're unable to resolve this issue, and you have an account, you may try uninstalling the app then reinstalling, then signing back into your account. Otherwise, please contact help@standardnotes.org for support."},ee={Title:'Restore Keychain',Text:"We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys."}},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i});var r=n(19);n.n(r);n.d(t,"a",function(){return r.ContentType});var a='org.standardnotes.sn';function i(e){var t;return(g(t={},r.ContentType.Note,'note'),g(t,r.ContentType.Tag,'tag'),g(t,r.ContentType.SmartTag,'smart tag'),g(t,r.ContentType.ActionsExtension,'action-based extension'),g(t,r.ContentType.Component,'component'),g(t,r.ContentType.Editor,'editor'),g(t,r.ContentType.Theme,'theme'),g(t,r.ContentType.ServerExtension,'server extension'),g(t,r.ContentType.FilesafeCredentials,'FileSafe credential'),g(t,r.ContentType.FilesafeFileMetadata,'FileSafe file'),g(t,r.ContentType.FilesafeIntegration,'FileSafe integration'),t)[e]}},function(e,t,n){"use strict";var r;function a(e){return[r.RemoteSaved,r.PreSyncSave].includes(e)}function i(e){return[r.RemoteRetrieved,r.ComponentRetrieved,r.RemoteActionRetrieved].includes(e)}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i}),(function(e){e[e.RemoteRetrieved=1]="RemoteRetrieved",e[e.RemoteSaved=2]="RemoteSaved",e[e.LocalSaved=3]="LocalSaved",e[e.LocalRetrieved=4]="LocalRetrieved",e[e.LocalChanged=5]="LocalChanged",e[e.ComponentRetrieved=6]="ComponentRetrieved",e[e.DesktopInstalled=7]="DesktopInstalled",e[e.RemoteActionRetrieved=8]="RemoteActionRetrieved",e[e.FileImport=9]="FileImport",e[e.RemoteConflict=10]="RemoteConflict",e[e.ImportConflict=11]="ImportConflict",e[e.SavedOrSaving=12]="SavedOrSaving",e[e.DecryptedTransient=13]="DecryptedTransient",e[e.ConflictUuid=14]="ConflictUuid",e[e.ConflictData=15]="ConflictData",e[e.SessionHistory=16]="SessionHistory",e[e.Constructor=17]="Constructor",e[e.ComponentCreated=18]="ComponentCreated",e[e.PreSyncSave=19]="PreSyncSave",e[e.RemoteHistory=20]="RemoteHistory",e[e.RemoteRejected=21]="RemoteRejected"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.Uuid="uuid",e.ContentType="content_type",e.ItemsKeyId="items_key_id",e.EncItemKey="enc_item_key",e.Content="content",e.CreatedAt="created_at",e.ServerUpdatedAt="updated_at",e.CreatedAtTimestamp="created_at_timestamp",e.ServerUpdatedAtTimestamp="updated_at_timestamp",e.Deleted="deleted",e.Legacy003AuthHash="auth_hash",e.Legacy003AuthParams="auth_params",e.Dirty="dirty",e.DirtiedDate="dirtiedDate",e.WaitingForKey="waitingForKey",e.ErrorDecrypting="errorDecrypting",e.ErrorDecryptingChanged="errorDecryptingValueChanged",e.LastSyncBegan="lastSyncBegan",e.LastSyncEnd="lastSyncEnd",e.DuplicateOf="duplicate_of"})(r||(r={}))},function(e,t,n){"use strict";var r;function a(e,t){return Number(e)-Number(t)}function i(e,t){return a(e,t)>=0}function s(e,t){return a(e,t)<=0}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"d",function(){return i}),n.d(t,"c",function(){return s}),(function(e){e.V000Base64Decrypted="000",e.V001="001",e.V002="002",e.V003="003",e.V004="004",e[e.VersionLength=3]="VersionLength"})(r||(r={}))},function(e,t,n){"use strict";(function(e){n.d(t,"c",function(){return r}),n.d(t,"a",function(){return a}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return f}),n.d(t,"b",function(){return g});var r,a,i,s=n(16),o=n(12),c=n(18),u=n(1),l=n(0),p=n(21),d=n(3),h=n(4);!(function(e){e[e.UserInteraction=1]="UserInteraction",e[e.Internal=2]="Internal",e[e.NonDirtying=3]="NonDirtying"})(r||(r={})),(function(e){e.Pinned="pinned",e.Archived="archived",e.Locked="locked",e.UserModifiedDate="client_updated_at",e.DefaultEditor="defaultEditor",e.MobileRules="mobileRules",e.NotAvailableOnMobile="notAvailableOnMobile",e.MobileActive="mobileActive",e.LastSize="lastSize",e.PrefersPlainEditor="prefersPlainEditor",e.ComponentInstallError="installError"})(a||(a={})),(function(e){e[e.KeepEarliest=1]="KeepEarliest"})(i||(i={}));var f=(function(){function t(n){var r=this;if(v(this,t),this.protected=!1,this.trashed=!1,this.pinned=!1,this.archived=!1,this.locked=!1,!n.uuid||!n.content_type)throw Error('Cannot create item without both uuid and content_type');n.format===o.a.DecryptedBareObject&&(n.enc_item_key||n.items_key_id||n.auth_hash)&&s.a.error(Error('Creating an item from a decrypted payload should not contain enc params')),this.payload=n,this.conflictOf=n.safeContent.conflict_of,this.duplicateOf=n.duplicate_of,this.createdAtString=this.created_at&&Object(l.k)(this.created_at),n.format===o.a.DecryptedBareObject?(this.userModifiedDate=new Date(this.getAppDomainValue(a.UserModifiedDate)||this.serverUpdatedAt),this.updatedAtString=Object(l.k)(this.userModifiedDate),this.protected=this.payload.safeContent.protected,this.trashed=this.payload.safeContent.trashed,this.pinned=this.getAppDomainValue(a.Pinned),this.archived=this.getAppDomainValue(a.Archived),this.locked=this.getAppDomainValue(a.Locked)):this.userModifiedDate=this.serverUpdatedAt||new Date,e(function(){Object(l.l)(r)})}return y(t,[{key:"payloadRepresentation",value:function(e){return Object(u.b)(this.payload,e)}},{key:"hasRelationshipWithItem",value:function(e){var t;return!!(null===(t=this.payload.safeContent.references)||void 0===t?void 0:t.find(function(t){return t.uuid===e.uuid}))}},{key:"getDomainData",value:function(e){var t=this.payload.safeContent.appData;if(t)return t[e]}},{key:"getAppDomainValue",value:function(e){return this.getDomainData(t.DefaultAppDomain())[e]}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['conflict_of']}},{key:"appDataContentKeysToIgnoreWhenCheckingEquality",value:function(){return[a.UserModifiedDate]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"strategyWhenConflictingWithItem",value:function(e,t){if(this.errorDecrypting)return c.a.KeepLeftDuplicateRight;if(this.isSingleton)return c.a.KeepLeft;if(this.deleted)return c.a.KeepRight;if(e.deleted)return this.payload.source===h.a.FileImport?c.a.KeepLeft:c.a.KeepRight;if(!m(this,e))return c.a.KeepRight;if(m(this,e,['references'])){if(t&&!m(t.itemFromPayload(),e))return c.a.KeepLeft;return e.payload.source===h.a.FileImport||Date.now()-this.userModifiedDate.getTime()<2e4?c.a.KeepLeftDuplicateRight:c.a.DuplicateLeftKeepRight}return c.a.KeepLeftMergeRefs}},{key:"isItemContentEqualWith",value:function(e){return b(this.payload.contentObject,e.payload.contentObject,this.contentKeysToIgnoreWhenCheckingEquality(),this.appDataContentKeysToIgnoreWhenCheckingEquality())}},{key:"satisfiesPredicate",value:function(e){return p.a.ItemSatisfiesPredicate(this,e)}},{key:"uuid",get:function(){return this.payload.uuid}},{key:"content",get:function(){return this.payload.content}},{key:"version",get:function(){if(this.payload.format===o.a.DecryptedBareObject)throw Error('Attempting to access version of decrypted payload');return this.payload.version}},{key:"safeContent",get:function(){return this.payload.safeContent}},{key:"references",get:function(){return this.payload.safeContent.references||[]}},{key:"deleted",get:function(){return this.payload.deleted}},{key:"content_type",get:function(){return this.payload.content_type}},{key:"created_at",get:function(){return this.payload.created_at}},{key:"serverUpdatedAt",get:function(){return this.payload.serverUpdatedAt}},{key:"serverUpdatedAtTimestamp",get:function(){return this.payload.updated_at_timestamp}},{key:"updated_at",get:function(){return this.serverUpdatedAt}},{key:"dirtiedDate",get:function(){return this.payload.dirtiedDate}},{key:"dirty",get:function(){return this.payload.dirty}},{key:"errorDecrypting",get:function(){return this.payload.errorDecrypting}},{key:"waitingForKey",get:function(){return this.payload.waitingForKey}},{key:"errorDecryptingValueChanged",get:function(){return this.payload.errorDecryptingValueChanged}},{key:"lastSyncBegan",get:function(){return this.payload.lastSyncBegan}},{key:"lastSyncEnd",get:function(){return this.payload.lastSyncEnd}},{key:"auth_hash",get:function(){return this.payload.auth_hash}},{key:"auth_params",get:function(){return this.payload.auth_params}},{key:"duplicate_of",get:function(){return this.payload.duplicate_of}},{key:"neverSynced",get:function(){return!this.serverUpdatedAt||0===this.serverUpdatedAt.getTime()}},{key:"isSingleton",get:function(){return!1}},{key:"singletonPredicate",get:function(){throw'Must override SNItem.singletonPredicate'}},{key:"singletonStrategy",get:function(){return i.KeepEarliest}},{key:"isSyncable",get:function(){return!this.errorDecrypting||!0===this.deleted}}],[{key:"DefaultAppDomain",value:function(){return d.b}}]),t})(),g=(function(){function e(t,n){v(this,e),this.item=t,this.type=n,this.payload=t.payload,this.payload.content&&(this.content=Object(l.a)(this.payload.content))}return y(e,[{key:"getUuid",value:function(){return this.payload.uuid}},{key:"getItem",value:function(){return this.item}},{key:"getResult",value:function(){if(this.type===r.NonDirtying)return Object(u.b)(this.payload,{content:this.content});this.payload.deleted||(this.type===r.UserInteraction?this.userModifiedDate=new Date:this.item.userModifiedDate||(this.userModifiedDate=new Date(this.item.serverUpdatedAt)));return Object(u.b)(this.payload,{content:this.content,dirty:!0,dirtiedDate:new Date})}},{key:"mergePayload",value:function(e){this.payload=Object(u.g)(this.payload,e),this.payload.content?this.content=Object(l.a)(this.payload.safeContent):this.content=void 0}},{key:"unsafe_setCustomContent",value:function(e){this.content=Object(l.a)(e)}},{key:"setDeleted",value:function(){this.content=void 0,this.payload=Object(u.b)(this.payload,{content:this.content,deleted:!0})}},{key:"setDomainData",value:function(e,t){this.payload.errorDecrypting||(this.content.appData||(this.content.appData={}),this.content.appData[t]=e)}},{key:"setDomainDataKey",value:function(e,t,n){if(!this.payload.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData;r[n]||(r[n]={}),r[n][e]=t}}},{key:"setAppDataItem",value:function(e,t){this.setDomainDataKey(e,t,f.DefaultAppDomain())}},{key:"addItemAsRelationship",value:function(e){var t=this.content.references||[];t.find(function(t){return t.uuid===e.uuid})||t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}},{key:"removeItemAsRelationship",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!==e.uuid}),this.content.references=t}},{key:"lastSyncBegan",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,lastSyncBegan:e})}},{key:"errorDecrypting",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,errorDecrypting:e})}},{key:"updated_at",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at:e})}},{key:"updated_at_timestamp",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at_timestamp:e})}},{key:"userModifiedDate",set:function(e){this.setAppDataItem(a.UserModifiedDate,e)}},{key:"conflictOf",set:function(e){this.content.conflict_of=e}},{key:"protected",set:function(e){this.content.protected=e}},{key:"trashed",set:function(e){this.content.trashed=e}},{key:"pinned",set:function(e){this.setAppDataItem(a.Pinned,e)}},{key:"archived",set:function(e){this.setAppDataItem(a.Archived,e)}},{key:"locked",set:function(e){this.setAppDataItem(a.Locked,e)}}]),e})();function m(e,t,n){return n||(n=[]),!b(e.content,t.content,e.contentKeysToIgnoreWhenCheckingEquality().concat(n),e.appDataContentKeysToIgnoreWhenCheckingEquality())}function b(e,t,n,r){if((e=Object(l.Q)(e)).appData){var a=e.appData[d.b];Object(l.J)(a,r),a?0===Object.keys(a).length&&delete e.appData:delete e.appData}if(Object(l.J)(e,n),(t=Object(l.Q)(t)).appData){var i=t.appData[d.b];Object(l.J)(i,r),i?0===Object.keys(i).length&&delete t.appData:delete t.appData}return Object(l.J)(t,n),JSON.stringify(e)===JSON.stringify(t)}}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"f",function(){return s}),n.d(t,"e",function(){return o}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return u});var r,a=n(3);function i(e){return e===a.a.RootKey||e===a.a.ItemsKey||e===a.a.EncryptedStorage}function s(e){return e===r.LocalStorageEncrypted||e===r.LocalStorageDecrypted||e===r.LocalStoragePreferEncrypted}function o(e){return e===r.FileEncrypted||e===r.FileDecrypted||e===r.FilePreferEncrypted}function c(e){return e===r.SyncDecrypted||e===r.LocalStorageDecrypted||e===r.FileDecrypted}function u(e){return e===r.Sync||e===r.LocalStorageEncrypted||e===r.FileEncrypted}!(function(e){e[e.Sync=0]="Sync",e[e.SyncDecrypted=1]="SyncDecrypted",e[e.LocalStorageEncrypted=2]="LocalStorageEncrypted",e[e.LocalStorageDecrypted=3]="LocalStorageDecrypted",e[e.LocalStoragePreferEncrypted=4]="LocalStoragePreferEncrypted",e[e.FileEncrypted=5]="FileEncrypted",e[e.FileDecrypted=6]="FileDecrypted",e[e.FilePreferEncrypted=7]="FilePreferEncrypted"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.FullSyncCompleted="sync:full-completed",e.SingleSyncCompleted="sync:single-completed",e.SyncWillBegin="sync:will-begin",e.DownloadFirstSyncCompleted="sync:download-first-completed",e.SyncTakingTooLong="sync:taking-too-long",e.SyncError="sync:error",e.InvalidSession="sync:invalid-session",e.MajorDataChange="major-data-change",e.LocalDataIncrementalLoad="local-data-incremental-load",e.LocalDataLoaded="local-data-loaded",e.EnterOutOfSync="enter-out-of-sync",e.ExitOutOfSync="exit-out-of-sync",e.StatusChanged="status-changed",e.DatabaseWriteError="database-write-error",e.DatabaseReadError="database-read-error"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var r=n(0),a=(function(){function e(){v(this,e),this.eventObservers=[],this.loggingEnabled=!1,this.criticalPromises=[]}return y(e,[{key:"addEventObserver",value:function(e){var t=this;return this.eventObservers.push(e),function(){Object(r.M)(t.eventObservers,e)}}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:n=S(this.eventObservers);case 1:if((r=n()).done){i.next=7;break}return a=r.value,i.next=5,b.awrap(a(e,t));case 5:i.next=1;break;case 7:case"end":return i.stop()}},null,this,null,Promise)}},{key:"blockDeinit",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(Promise.all(this.criticalPromises));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.eventObservers.length=0,this.deviceInterface=void 0}},{key:"executeCriticalFunction",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e(),this.criticalPromises.push(t),n.abrupt("return",t);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"log",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.loggingEnabled){var a,i=new Date,s=i.toLocaleTimeString().replace(' PM','').replace(' AM',''),o="".concat(s,".").concat(i.getMilliseconds());if(n)n=n.map(function(e){return Array.isArray(e)?e.slice():e}),(a=console).log.apply(a,[o,e].concat(m(n)));else console.log(o,e)}}}]),e})()},function(e,t,n){"use strict";n.d(t,"b",function(){return i}),n.d(t,"a",function(){return s});var r=n(7),a=n(3);function i(e){return e.map(function(e){return e.uuid})}function s(e){return e.references||(e.references=[]),e.appData||(e.appData={}),e.appData[a.b]||(e.appData[a.b]={}),e.appData[a.b][r.a.UserModifiedDate]||(e.appData[a.b][r.a.UserModifiedDate]="".concat(new Date)),e}},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.EncryptedString=0]="EncryptedString",e[e.DecryptedBareObject=1]="DecryptedBareObject",e[e.DecryptedBase64String=2]="DecryptedBase64String",e[e.Deleted=3]="Deleted"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"g",function(){return r}),n.d(t,"a",function(){return p}),n.d(t,"b",function(){return d}),n.d(t,"c",function(){return h}),n.d(t,"d",function(){return f}),n.d(t,"e",function(){return g}),n.d(t,"f",function(){return b}),n.d(t,"h",function(){return w});var r,a=n(14),i=n(6),s=n(0);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e.Registration="registration",e.EmailChange="email-change",e.PasswordChange="password-change",e.ProtocolUpgrade="protocol-upgrade",e.PasscodeCreate="passcode-create",e.PasscodeChange="passcode-change"})(r||(r={}));var l=['identifier','pw_cost','pw_nonce','pw_salt','version','origination','created'];function p(e){return g(e)}function d(e){return g(e)}function h(e){return g(e)}function f(e){return g(e)}function g(e){if(e.content)throw Error('Raw key params shouldnt have content; perhaps you passed in a SNRootKeyParams object.');return new w(e)}function m(e){if(e.version)return e.version;var t=e.pw_cost,n=a.a.PbkdfCostsUsed.includes(t),r=a.b.PbkdfCostsUsed.includes(t);return n&&!r?i.a.V001:r&&!n?i.a.V002:r&&n&&e.pw_nonce&&a.b.ImprobablePbkdfCostsUsed.includes(t)?i.a.V001:i.a.V002}function b(e,t){return g({identifier:t||e.data.identifier,pw_cost:e.data.pw_cost,pw_nonce:e.data.pw_nonce,pw_salt:e.data.pw_salt,version:m(e.data),origination:e.data.origination,created:e.data.created})}var w=(function(){function e(t){v(this,e),this.content=c(c({},t),{},{origination:t.origination||r.Registration,version:t.version||m(t)})}return y(e,[{key:"compare",value:function(e){if(this.version!==e.version)return!1;if([i.a.V004,i.a.V003].includes(this.version))return this.identifier===e.identifier&&this.content004.pw_nonce===e.content003.pw_nonce;if([i.a.V002,i.a.V001].includes(this.version))return this.identifier===e.identifier&&this.content002.pw_salt===e.content001.pw_salt;throw Error('Unhandled version in KeyParams.compare')}},{key:"getPortableValue",value:function(){return Object(s.L)(this.content,l)}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"identifier",get:function(){return this.content004.identifier||this.content002.email}},{key:"version",get:function(){return this.content.version}},{key:"origination",get:function(){return this.content.origination}},{key:"content001",get:function(){return this.content}},{key:"content002",get:function(){return this.content}},{key:"content003",get:function(){return this.content}},{key:"content004",get:function(){return this.content}},{key:"createdDate",get:function(){if(this.content004.created)return new Date(Number(this.content004.created))}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return s}),n.d(t,"c",function(){return r}),n.d(t,"d",function(){return a});var r,a,i=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:[3e3,5e3,1e4,6e4],PbkdfOutputLength:512,EncryptionKeyLength:256}),s=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:i.PbkdfCostsUsed.concat([1e5,101e3,102e3,103e3]),ImprobablePbkdfCostsUsed:[3e3,5e3],PbkdfOutputLength:768,EncryptionKeyLength:256,EncryptionIvLength:128});!(function(e){e[e.SaltSeedLength=256]="SaltSeedLength",e[e.PbkdfCost=11e4]="PbkdfCost",e[e.PbkdfOutputLength=768]="PbkdfOutputLength",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionIvLength=128]="EncryptionIvLength"})(r||(r={})),(function(e){e[e.ArgonSaltSeedLength=256]="ArgonSaltSeedLength",e[e.ArgonSaltLength=128]="ArgonSaltLength",e[e.ArgonIterations=5]="ArgonIterations",e[e.ArgonMemLimit=67108864]="ArgonMemLimit",e[e.ArgonOutputKeyBytes=64]="ArgonOutputKeyBytes",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionNonceLength=192]="EncryptionNonceLength"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"c",function(){return i}),n.d(t,"a",function(){return a});var r,a;n(22);function i(e){return e.status===r.HttpStatusExpiredAccessToken}!(function(e){e[e.LocalValidationError=10]="LocalValidationError",e[e.CanceledMfa=11]="CanceledMfa",e[e.UnknownError=12]="UnknownError",e[e.HttpStatusMinSuccess=200]="HttpStatusMinSuccess",e[e.HttpStatusNoContent=204]="HttpStatusNoContent",e[e.HttpStatusMaxSuccess=299]="HttpStatusMaxSuccess",e[e.HttpStatusExpiredAccessToken=498]="HttpStatusExpiredAccessToken",e[e.HttpStatusInvalidSession=401]="HttpStatusInvalidSession",e[e.HttpStatusForbidden=403]="HttpStatusForbidden",e[e.HttpBadRequest=400]="HttpBadRequest"})(r||(r={})),(function(e){e.ConflictingData="sync_conflict",e.UuidConflict="uuid_conflict",e.ContentTypeError="content_type_error",e.ContentError="content_error"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=(function(){function e(){v(this,e)}return y(e,null,[{key:"log",value:function(){this.onLog.apply(this,arguments)}},{key:"error",value:function(e){return this.onError(e),e}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"c",function(){return i});var r,a=n(9);function i(e){var t;return(t={},g(t,a.a.FullSyncCompleted,r.CompletedFullSync),g(t,a.a.SingleSyncCompleted,r.CompletedIncrementalSync),g(t,a.a.SyncError,r.FailedSync),g(t,a.a.SyncTakingTooLong,r.HighLatencySync),g(t,a.a.EnterOutOfSync,r.EnteredOutOfSync),g(t,a.a.ExitOutOfSync,r.ExitedOutOfSync),g(t,a.a.LocalDataLoaded,r.LocalDataLoaded),g(t,a.a.MajorDataChange,r.MajorDataChange),g(t,a.a.LocalDataIncrementalLoad,r.LocalDataIncrementalLoad),g(t,a.a.StatusChanged,r.SyncStatusChanged),g(t,a.a.SyncWillBegin,r.WillSync),g(t,a.a.InvalidSession,r.InvalidSyncSession),g(t,a.a.DatabaseReadError,r.LocalDatabaseReadError),g(t,a.a.DatabaseWriteError,r.LocalDatabaseWriteError),t)[e]}n.d(t,"b",function(){return a.a}),(function(e){e[e.SignedIn=2]="SignedIn",e[e.SignedOut=3]="SignedOut",e[e.CompletedFullSync=5]="CompletedFullSync",e[e.FailedSync=6]="FailedSync",e[e.HighLatencySync=7]="HighLatencySync",e[e.EnteredOutOfSync=8]="EnteredOutOfSync",e[e.ExitedOutOfSync=9]="ExitedOutOfSync",e[e.Started=10]="Started",e[e.Launched=11]="Launched",e[e.LocalDataLoaded=12]="LocalDataLoaded",e[e.KeyStatusChanged=13]="KeyStatusChanged",e[e.MajorDataChange=14]="MajorDataChange",e[e.CompletedRestart=15]="CompletedRestart",e[e.LocalDataIncrementalLoad=16]="LocalDataIncrementalLoad",e[e.SyncStatusChanged=17]="SyncStatusChanged",e[e.WillSync=18]="WillSync",e[e.InvalidSyncSession=19]="InvalidSyncSession",e[e.LocalDatabaseReadError=20]="LocalDatabaseReadError",e[e.LocalDatabaseWriteError=21]="LocalDatabaseWriteError",e[e.CompletedIncrementalSync=22]="CompletedIncrementalSync",e[e.MigrationsLoaded=23]="MigrationsLoaded",e[e.StorageReady=24]="StorageReady",e[e.PreferencesChanged=25]="PreferencesChanged",e[e.ProtectionSessionExpiryDateChanged=26]="ProtectionSessionExpiryDateChanged",e[e.UserRolesChanged=27]="UserRolesChanged",e[e.FeaturesUpdated=28]="FeaturesUpdated"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.KeepLeft=1]="KeepLeft",e[e.KeepRight=2]="KeepRight",e[e.KeepLeftDuplicateRight=3]="KeepLeftDuplicateRight",e[e.DuplicateLeftKeepRight=4]="DuplicateLeftKeepRight",e[e.KeepLeftMergeRefs=5]="KeepLeftMergeRefs"})(r||(r={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(211),t)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(221),t)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(0);function a(e){return e instanceof i?e:Array.isArray(e)?i.FromArray(e):i.FromJson(e)}var i=(function(){function e(t,n,r){if(v(this,e),this.keypath=t,this.operator=n,this.value=r,this.isRecursive()){var i=this.value;this.value=i.map(function(e){return a(e)})}else'true'!==this.value&&'false'!==this.value||(this.value=JSON.parse(this.value))}return y(e,[{key:"isRecursive",value:function(){return['and','or'].includes(this.operator)}},{key:"arrayRepresentation",value:function(){return[this.keypath,this.operator,this.value]}},{key:"valueAsArray",value:function(){return this.value}},{key:"keypathIncludesVerb",value:function(e){if(this.isRecursive()){for(var t,n=S(this.value);!(t=n()).done;){if(t.value.keypathIncludesVerb(e))return!0}return!1}return this.keypath.includes(e)}}],[{key:"FromJson",value:function(t){return new e(t.keypath,t.operator,t.value)}},{key:"FromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"CompoundPredicate",value:function(t){return new e('ignored','and',t)}},{key:"ObjectSatisfiesPredicate",value:function(e,t){if((t=a(t)).isRecursive()){if('and'===t.operator){for(var n,r=S(t.valueAsArray());!(n=r()).done;){var i=n.value;if(!this.ObjectSatisfiesPredicate(e,i))return!1}return!0}if('or'===t.operator){for(var s,o=S(t.valueAsArray());!(s=o()).done;){var c=s.value;if(this.ObjectSatisfiesPredicate(e,c))return!0}return!1}}var u=t.value;if('string'==typeof u&&u.includes('.ago')&&(u=this.DateFromString(u)),'not'===t.operator)return!this.ObjectSatisfiesPredicate(e,u);var l=t.keypath.split('.').reduce(function(e,t){return e&&e[t]},e),p=[!1,'',null,void 0,NaN];return void 0===l?'!='===t.operator?!p.includes(t.value):p.includes(t.value):'='===t.operator?Array.isArray(l)?JSON.stringify(l)===JSON.stringify(u):l===u:'!='===t.operator?Array.isArray(l)?JSON.stringify(l)!==JSON.stringify(u):l!==u:'<'===t.operator?l<u:'>'===t.operator?l>u:'<='===t.operator?l<=u:'>='===t.operator?l>=u:'startsWith'===t.operator?l.startsWith(u):'in'===t.operator?-1!==u.indexOf(l):'includes'===t.operator?this.resolveIncludesPredicate(l,u):'matches'===t.operator&&new RegExp(u).test(l)}},{key:"resolveIncludesPredicate",value:function(t,n){if(Object(r.A)(n))return t.includes(n);var a;a=Array.isArray(n)?e.FromArray(n):n;for(var i,s=S(t);!(i=s()).done;){var o=i.value;if(this.ObjectSatisfiesPredicate(o,a))return!0}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!this.ItemSatisfiesPredicate(e,a))return!1}return!0}},{key:"DateFromString",value:function(e){var t=e.split('.'),n=t[1],r=new Date,a=parseInt(t[0]);return'days'===n?r.setDate(r.getDate()-a):'hours'===n&&r.setHours(r.getHours()-a),r}}]),e})()},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.LastSyncToken="sync_token",e.PaginationToken="cursor_token",e.IntegrityCheck="compute_integrity",e.IntegrityResult="integrity_hash",e.SyncDlLimit="limit",e.SyncPayloads="items",e.ApiVersion="api"})(r||(r={}))},function(e,t,n){"use strict";var r=Array.isArray;e.exports=r},function(e,t,n){"use strict";var r=n(68),a='object'==typeof self&&self&&self.Object===Object&&self,i=r||a||Function('return this')();e.exports=i},function(e,t,n){"use strict";var r=n(173)(n(174));e.exports=r},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(e,t,n){"use strict";var r=n(48),a=n(168);e.exports=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,s=[],o=e.length;for(t=r(t,3);++i<o;){var c=e[i];t(c,i,e)&&(n.push(c),s.push(i))}return a(e,s),n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e){return e&&e.length?r(e):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(241),t)},function(e,t,n){"use strict";var r=n(110),a=n(115);e.exports=function(e,t){var n=a(e,t);return r(n)?n:void 0}},function(e,t,n){"use strict";e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t,n){"use strict";n.d(t,"a",function(){return u});var r=n(11),a=n(5),i=n(4),s=n(6),o=n(0),c=n(12),u=(function(){function e(t,n,u){if(v(this,e),this.fields=n||Object.keys(t),this.source=u||i.a.Constructor,this.uuid=t.uuid,!this.uuid&&this.fields.includes(a.a.Uuid))throw Error("uuid is null, yet this payloads fields indicate it shouldnt be. Content type: ".concat(t.content_type));this.content_type=t.content_type,t.content&&(Object(o.x)(t.content)?this.content=Object(r.a)(t.content):this.content=t.content),this.deleted=t.deleted,this.items_key_id=t.items_key_id,this.enc_item_key=t.enc_item_key,this.created_at=new Date(t.created_at||new Date),this.updated_at=new Date(t.updated_at||0),this.created_at_timestamp=t.created_at_timestamp,this.updated_at_timestamp=t.updated_at_timestamp,t.dirtiedDate&&(this.dirtiedDate=new Date(t.dirtiedDate)),this.dirty=t.dirty,this.errorDecrypting=t.errorDecrypting,this.waitingForKey=t.waitingForKey,this.errorDecryptingValueChanged=t.errorDecryptingValueChanged,this.lastSyncBegan=t.lastSyncBegan?new Date(t.lastSyncBegan):void 0,this.lastSyncEnd=t.lastSyncEnd?new Date(t.lastSyncEnd):void 0,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params,this.duplicate_of=t.duplicate_of,Object(o.A)(this.content)?this.content.startsWith(s.a.V000Base64Decrypted)?this.format=c.a.DecryptedBase64String:this.format=c.a.EncryptedString:Object(o.x)(this.content)?this.format=c.a.DecryptedBareObject:this.format=c.a.Deleted,Object(o.A)(this.content)?this.version=this.content.substring(0,s.a.VersionLength):this.content&&(this.version=this.content.version),Object(o.l)(this)}return y(e,[{key:"ejected",value:function(){for(var e,t=[a.a.Legacy003AuthHash,a.a.Deleted],n=[a.a.DirtiedDate,a.a.ErrorDecrypting,a.a.ErrorDecryptingChanged,a.a.WaitingForKey,a.a.LastSyncBegan,a.a.LastSyncEnd],r={},i=S(this.fields);!(e=i()).done;){var s=e.value;if(!n.includes(s)){var c=this[s];Object(o.w)(c)&&t.includes(s)||(r[s]=c)}}return r}},{key:"safeContent",get:function(){return this.format===c.a.DecryptedBareObject?this.content:{}}},{key:"references",get:function(){return this.safeReferences}},{key:"safeReferences",get:function(){return this.safeContent.references||[]}},{key:"contentObject",get:function(){if(this.format!==c.a.DecryptedBareObject)throw Error('Attempting to access non-object content as object');return this.content}},{key:"contentString",get:function(){if(this.format===c.a.DecryptedBareObject)throw Error('Attempting to access non-string content as string');return this.content}},{key:"discardable",get:function(){return this.deleted&&!this.dirty}},{key:"serverUpdatedAt",get:function(){return this.updated_at}}]),e})()},function(e,t,n){"use strict";var r=n(40),a=n(111),i=n(112),s='[object Null]',o='[object Undefined]',c=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?o:s:c&&c in Object(e)?a(e):i(e)}},function(e,t,n){"use strict";var r;r=(function(){return this})();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,n){"use strict";var r=n(51),a=n(59);e.exports=function(e){return null!=e&&a(e.length)&&!r(e)}},function(e,t,n){"use strict";var r=n(44);e.exports=function(e){if('string'==typeof e||r(e))return e;var t=e+'';return'0'==t&&1/e==-1/0?'-0':t}},function(e,t,n){"use strict";var r=n(100),a=n(101),i=n(102),s=n(103),o=n(104);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(35);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},function(e,t,n){"use strict";var r=n(24).Symbol;e.exports=r},function(e,t,n){"use strict";var r=n(30)(Object,'create');e.exports=r},function(e,t,n){"use strict";var r=n(124);e.exports=function(e,t){var n=e.__data__;return r(t)?n['string'==typeof t?'string':'hash']:n.map}},function(e,t,n){"use strict";var r=9007199254740991,a=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var n=typeof e;return!!(t=null==t?r:t)&&('number'==n||'symbol'!=n&&a.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Symbol]';e.exports=function(e){return'symbol'==typeof e||a(e)&&r(e)==i}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(231),t)},function(e,t,n){"use strict";var r=n(96);n.d(t,"SNSettingsService",function(){return r.a});var a=n(94);n.n(a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n){r(e,t,n)});e.exports=a},function(e,t,n){"use strict";var r=n(98),a=n(154),i=n(64),s=n(23),o=n(165);e.exports=function(e){return'function'==typeof e?e:null==e?i:'object'==typeof e?s(e)?a(e[0],e[1]):r(e):o(e)}},function(e,t,n){"use strict";var r=n(38),a=n(105),i=n(106),s=n(107),o=n(108),c=n(109);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=a,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=c,e.exports=u},function(e,t,n){"use strict";var r=n(30)(n(24),'Map');e.exports=r},function(e,t,n){"use strict";var r=n(33),a=n(26),i='[object AsyncFunction]',s='[object Function]',o='[object GeneratorFunction]',c='[object Proxy]';e.exports=function(e){if(!a(e))return!1;var t=r(e);return t==s||t==o||t==i||t==c}},function(e,t,n){"use strict";var r=n(116),a=n(123),i=n(125),s=n(126),o=n(127);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},function(e,t,n){"use strict";var r=n(75),a=n(147),i=n(36);e.exports=function(e){return i(e)?r(e):a(e)}},function(e,t,n){"use strict";var r=n(142),a=n(31),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,c=r((function(){return arguments})())?r:function(e){return a(e)&&s.call(e,'callee')&&!o.call(e,'callee')};e.exports=c},function(e,t,n){"use strict";(function(e){var r=n(24),a=n(143),i=t&&!t.nodeType&&t,s=i&&'object'==typeof e&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,c=(o?o.isBuffer:void 0)||a;e.exports=c}).call(this,n(57)(e))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";var r=n(144),a=n(145),i=n(146),s=i&&i.isTypedArray,o=s?a(s):r;e.exports=o},function(e,t,n){"use strict";var r=9007199254740991;e.exports=function(e){return'number'==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,n){"use strict";var r=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===('function'==typeof t&&t.prototype||r)}},function(e,t,n){"use strict";var r=n(62),a=n(37);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[a(t[n++])];return n&&n==i?e:void 0}},function(e,t,n){"use strict";var r=n(23),a=n(63),i=n(156),s=n(159);e.exports=function(e,t){return r(e)?e:a(e,t)?[e]:i(s(e))}},function(e,t,n){"use strict";var r=n(23),a=n(44),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!('number'!=n&&'symbol'!=n&&'boolean'!=n&&null!=e&&!a(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},function(e,t,n){"use strict";e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(83);e.exports=function(e,t,n){'__proto__'==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e,t){return t='function'==typeof t?t:void 0,e&&e.length?r(e,void 0,t):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(228),t),a(n(229),t),a(n(230),t)},function(e,t,n){"use strict";(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(34))},function(e,t,n){"use strict";var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+''}catch(e){}}return''}},function(e,t,n){"use strict";var r=n(128),a=n(31);e.exports=function e(t,n,i,s,o){return t===n||(null==t||null==n||!a(t)&&!a(n)?t!=t&&n!=n:r(t,n,i,s,e,o))}},function(e,t,n){"use strict";var r=n(72),a=n(131),i=n(73),s=1,o=2;e.exports=function(e,t,n,c,u,l){var p=n&s,d=e.length,h=t.length;if(d!=h&&!(p&&h>d))return!1;var f=l.get(e),v=l.get(t);if(f&&v)return f==t&&v==e;var y=-1,g=!0,m=n&o?new r:void 0;for(l.set(e,t),l.set(t,e);++y<d;){var b=e[y],w=t[y];if(c)var k=p?c(w,b,y,t,e,l):c(b,w,y,e,t,l);if(void 0!==k){if(k)continue;g=!1;break}if(m){if(!a(t,function(e,t){if(!i(m,t)&&(b===e||u(b,e,n,c,l)))return m.push(t)})){g=!1;break}}else if(b!==w&&!u(b,w,n,c,l)){g=!1;break}}return l.delete(e),l.delete(t),g}},function(e,t,n){"use strict";var r=n(52),a=n(129),i=n(130);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=a,s.prototype.has=i,e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t){return e.has(t)}},function(e,t,n){"use strict";var r=n(24).Uint8Array;e.exports=r},function(e,t,n){"use strict";var r=n(141),a=n(55),i=n(23),s=n(56),o=n(43),c=n(58),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&a(e),p=!n&&!l&&s(e),d=!n&&!l&&!p&&c(e),h=n||l||p||d,f=h?r(e.length,String):[],v=f.length;for(var y in e)!t&&!u.call(e,y)||h&&('length'==y||p&&('offset'==y||'parent'==y)||d&&('buffer'==y||'byteLength'==y||'byteOffset'==y)||o(y,v))||f.push(y);return f}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){"use strict";var r=n(30)(n(24),'Set');e.exports=r},function(e,t,n){"use strict";var r=n(26);e.exports=function(e){return e==e&&!r(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){for(var a=e.length,i=n+(r?1:-1);r?i--:++i<a;)if(t(e[i],i,e))return i;return-1}},function(e,t,n){"use strict";var r=n(49),a=n(82),i=n(178),s=n(180),o=n(26),c=n(86),u=n(85);e.exports=function e(t,n,l,p,d){t!==n&&i(n,function(i,c){if(d||(d=new r),o(i))s(t,n,c,l,e,p,d);else{var h=p?p(u(t,c),i,c+'',t,n,d):void 0;void 0===h&&(h=i),a(t,c,h)}},c)}},function(e,t,n){"use strict";var r=n(65),a=n(35);e.exports=function(e,t,n){(void 0===n||a(e[t],n))&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(30),a=(function(){try{var e=r(Object,'defineProperty');return e({},'',{}),e}catch(e){}})();e.exports=a},function(e,t,n){"use strict";var r=n(76)(Object.getPrototypeOf,Object);e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){if(('constructor'!==t||'function'!=typeof e[t])&&'__proto__'!=t)return e[t]}},function(e,t,n){"use strict";var r=n(75),a=n(192),i=n(36);e.exports=function(e){return i(e)?r(e,!0):a(e)}},function(e,t,n){"use strict";var r=n(194),a=n(201);e.exports=function(e){return r(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(s=e.length>3&&'function'==typeof s?(i--,s):void 0,o&&a(n[0],n[1],o)&&(s=i<3?void 0:s,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,s)}return t})}},function(e,t,n){"use strict";var r=n(72),a=n(202),i=n(206),s=n(73),o=n(207),c=n(53),u=200;e.exports=function(e,t,n){var l=-1,p=a,d=e.length,h=!0,f=[],v=f;if(n)h=!1,p=i;else if(d>=u){var y=t?null:o(e);if(y)return c(y);h=!1,p=s,v=new r}else v=t?[]:f;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=n||0!==g?g:0,h&&m==m){for(var b=v.length;b--;)if(v[b]===m)continue e;t&&v.push(m),f.push(g)}else p(v,m,n)||(v!==f&&v.push(m),f.push(g))}return f}},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(209),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeatureIdentifier=void 0,(function(e){e.AutobiographyTheme="org.standardnotes.theme-autobiography",e.BoldEditor="org.standardnotes.bold-editor",e.CloudLink="org.standardnotes.cloudlink",e.CodeEditor="org.standardnotes.code-editor",e.DailyDropboxBackup="org.standardnotes.daily-dropbox-backup",e.DailyEmailBackup="org.standardnotes.daily-email-backup",e.DailyGDriveBackup="org.standardnotes.daily-gdrive-backup",e.DailyOneDriveBackup="org.standardnotes.daily-onedrive-backup",e.DynamicTheme="org.standardnotes.theme-dynamic",e.Files="org.standardnotes.files",e.Files25GB="org.standardnotes.files-25-gb",e.Files5GB="org.standardnotes.files-5-gb",e.FileSafe="org.standardnotes.file-safe",e.FocusedTheme="org.standardnotes.theme-focus",e.FoldersComponent="org.standardnotes.folders",e.FuturaTheme="org.standardnotes.theme-futura",e.ListedCustomDomain="org.standardnotes.listed-custom-domain",e.MarkdownBasicEditor="org.standardnotes.simple-markdown-editor",e.MarkdownMathEditor="org.standardnotes.fancy-markdown-editor",e.MarkdownMinimistEditor="org.standardnotes.minimal-markdown-editor",e.MarkdownProEditor="org.standardnotes.advanced-markdown-editor",e.MidnightTheme="org.standardnotes.theme-midnight",e.NoDistractionTheme="org.standardnotes.theme-no-distraction",e.NoteHistory30Days="org.standardnotes.note-history-30",e.NoteHistory365Days="org.standardnotes.note-history-365",e.NoteHistoryUnlimited="org.standardnotes.note-history-unlimited",e.PlusEditor="org.standardnotes.plus-editor",e.SheetsEditor="org.standardnotes.standard-sheets",e.SolarizedDarkTheme="org.standardnotes.theme-solarized-dark",e.TagNesting="org.standardnotes.tag-nesting",e.TaskEditor="org.standardnotes.simple-task-editor",e.TitaniumTheme="org.standardnotes.theme-titanium",e.TokenVaultEditor="org.standardnotes.token-vault",e.TwoFactorAuth="org.standardnotes.two-factor-auth",e.TwoFactorAuthManager="org.standardnotes.mfa-link",e.FocusMode="org.standardnotes.focus-mode"})(t.FeatureIdentifier||(t.FeatureIdentifier={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentArea=void 0,(function(e){e.Editor="editor-editor",e.Themes="themes",e.TagsList="tags-list",e.EditorStack="editor-stack",e.NoteTags="note-tags",e.Rooms="rooms",e.Modal="modal",e.Any="*"})(t.ComponentArea||(t.ComponentArea={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentFlag=void 0,(function(e){e.New="New",e.Deprecated="Deprecated"})(t.ComponentFlag||(t.ComponentFlag={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionName=void 0,(function(e){e.AutobiographyTheme="theme:autobiography",e.BoldEditor="editor:bold",e.CloudLink="component:cloud-link",e.CodeEditor="editor:code-editor",e.ComponentFilesafe="component:filesafe",e.ComponentFolders="component:folders",e.DailyDropboxBackup="server:daily-dropbox-backup",e.DailyEmailBackup="server:daily-email-backup",e.DailyGDriveBackup="server:daily-gdrive-backup",e.DailyOneDriveBackup="server:daily-onedrive-backup",e.Files="app:files",e.Files25GB="server:files-25-gb",e.Files5GB="server:files-5-gb",e.FocusedTheme="theme:focused",e.FuturaTheme="theme:futura",e.ListedCustomDomain="listed:custom-domain",e.MarkdownBasicEditor="editor:markdown-basic",e.MarkdownMathEditor="editor:markdown-math",e.MarkdownMinimistEditor="editor:markdown-minimist",e.MarkdownProEditor="editor:markdown-pro",e.MidnightTheme="theme:midnight",e.NoteHistory30Days="server:note-history-30-days",e.NoteHistory365Days="server:note-history-365-days",e.NoteHistoryUnlimited="server:note-history-unlimited",e.PlusEditor="editor:plus",e.SheetsEditor="editor:sheets",e.SolarizedDarkTheme="theme:solarized-dark",e.TagNesting="app:tag-nesting",e.TaskEditor="editor:task-editor",e.ThemeDynamic="theme:dynamic",e.ThemeNoDistraction="theme:no-distraction",e.TitaniumTheme="theme:titanium",e.TokenVaultEditor="editor:token-vault",e.TwoFactorAuth="server:two-factor-auth",e.TwoFactorAuthManager="component:2fa-manager",e.FocusMode="app:focus-mode"})(t.PermissionName||(t.PermissionName={}))},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return i});var r=n(10),a=n(17),i=(function(t){d(r,t);var n=k(r);function r(t){var a;return v(this,r),(a=n.call(this)).application=t,e(function(){a.addAppEventObserver()}),a}return y(r,[{key:"deinit",value:function(){this.application=void 0,this.unsubApp(),this.unsubApp=void 0,p(f(r.prototype),"deinit",this).call(this)}},{key:"addAppEventObserver",value:function(){var e=this;this.application.isStarted()&&this.onAppStart(),this.application.isLaunched()&&this.onAppLaunch(),this.unsubApp=this.application.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(e.onAppEvent(t));case 2:t===a.a.Started?e.onAppStart():t===a.a.Launched?e.onAppLaunch():t===a.a.CompletedFullSync?e.onAppFullSync():t===a.a.CompletedIncrementalSync?e.onAppIncrementalSync():t===a.a.KeyStatusChanged&&e.onAppKeyChange();case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"onAppEvent",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppStart",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppLaunch",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppKeyChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppIncrementalSync",value:function(){}},{key:"onAppFullSync",value:function(){}}]),r})(r.a)}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(10),a=n(2),i=n(15),s=(function(){function e(t,n){v(this,e),this.settingsApi=t,this.userProvider=n}return y(e,[{key:"isReadyForModification",value:function(){return null!=this.getUser()}},{key:"getUser",value:function(){return this.userProvider.getUser()}},{key:"listSettings",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.settingsApi.listSettings(this.userUuid));case 2:if(e=o.sent,t=e.error,n=e.data,null==t){o.next=7;break}throw new Error(t.message);case 7:if(null!=n&&null!=n.settings){o.next=9;break}return o.abrupt("return",{});case 9:for(r={},a=S(n.settings);!(i=a()).done;)s=i.value,r[s.name]=s.value;return o.abrupt("return",r);case 12:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){var t,n,r,a;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((a=s.sent).status!==i.b.HttpBadRequest){s.next=5;break}return s.abrupt("return",null);case 5:if(null==a.error){s.next=7;break}throw new Error(a.error.message);case 7:return s.abrupt("return",null!==(t=null===a||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:null===(r=n.setting)||void 0===r?void 0:r.value)&&void 0!==t?t:null);case 8:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((r=a.sent).status!==i.b.HttpBadRequest){a.next=5;break}return a.abrupt("return",!1);case 5:if(null==r.error){a.next=7;break}throw new Error(r.error.message);case 7:return a.abrupt("return",null!==(t=null===(n=r.data)||void 0===n?void 0:n.success)&&void 0!==t&&t);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){var r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.settingsApi.updateSetting(this.userUuid,e,t,n));case 2:if(r=i.sent,null==(a=r.error)){i.next=6;break}throw new Error(a.message);case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.settingsApi.deleteSetting(this.userUuid,e));case 2:if(t=r.sent,null==(n=t.error)){r.next=6;break}throw new Error(n.message);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.settingsApi=void 0,this.userProvider=void 0}},{key:"userUuid",get:function(){var e=this.getUser();if(null==e||null==e.uuid)throw new Error(a.o);return e.uuid}}]),e})(),o=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).sessionManager=e,a.apiService=r,a}return y(n,[{key:"initializeFromDisk",value:function(){this._provider=new s(this.apiService,this.sessionManager)}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._provider.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this._provider.updateSetting(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){var e;null===(e=this._provider)||void 0===e||e.deinit(),this._provider=void 0,this.sessionManager=void 0,this.apiService=void 0}}]),n})(r.a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n,a){r(e,t,n,a)});e.exports=a},function(e,t,n){"use strict";var r=n(99),a=n(153),i=n(79);e.exports=function(e){var t=a(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){"use strict";var r=n(49),a=n(70);e.exports=function(e,t,n,i){var s=n.length,o=s,c=!i;if(null==e)return!o;for(e=Object(e);s--;){var u=n[s];if(c&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++s<o;){var l=(u=n[s])[0],p=e[l],d=u[1];if(c&&u[2]){if(void 0===p&&!(l in e))return!1}else{var h=new r;if(i)var f=i(p,d,l,e,t,h);if(!(void 0===f?a(d,p,3,i,h):f))return!1}}return!0}},function(e,t,n){"use strict";e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){"use strict";var r=n(39),a=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():a.call(t,n,1),--this.size,0))}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e,t){var n=this.__data__,a=r(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}},function(e,t,n){"use strict";var r=n(38);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.get(e)}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";var r=n(38),a=n(50),i=n(52);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!a||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){"use strict";var r=n(51),a=n(113),i=n(26),s=n(69),o=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,p=u.hasOwnProperty,d=RegExp('^'+l.call(p).replace(/[\\^$.*+?()[\]{}|]/g,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');e.exports=function(e){return!(!i(e)||a(e))&&(r(e)?d:o).test(s(e))}},function(e,t,n){"use strict";var r=n(40),a=Object.prototype,i=a.hasOwnProperty,s=a.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0}catch(e){}var r=s.call(e);return t?e[o]=n:delete e[o],r}},function(e,t,n){"use strict";var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,n){"use strict";var r,a=n(114),i=(r=/[^.]+$/.exec(a&&a.keys&&a.keys.IE_PROTO||''))?'Symbol(src)_1.'+r:'';e.exports=function(e){return!!i&&i in e}},function(e,t,n){"use strict";var r=n(24)['__core-js_shared__'];e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){"use strict";var r=n(117),a=n(38),i=n(50);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||a),string:new r}}},function(e,t,n){"use strict";var r=n(118),a=n(119),i=n(120),s=n(121),o=n(122);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(41);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__',i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===a?void 0:n}return i.call(t,e)?t[e]:void 0}},function(e,t,n){"use strict";var r=n(41),a=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:a.call(t,e)}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__';e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?a:t,this}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return'string'==t||'number'==t||'symbol'==t||'boolean'==t?'__proto__'!==e:null===e}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).get(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).has(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e,t){var n=r(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}},function(e,t,n){"use strict";var r=n(49),a=n(71),i=n(132),s=n(134),o=n(149),c=n(23),u=n(56),l=n(58),p=1,d='[object Arguments]',h='[object Array]',f='[object Object]',v=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,y,g,m){var b=c(e),w=c(t),k=b?h:o(e),x=w?h:o(t),S=(k=k==d?f:k)==f,P=(x=x==d?f:x)==f,O=k==x;if(O&&u(e)){if(!u(t))return!1;b=!0,S=!1}if(O&&!S)return m||(m=new r),b||l(e)?a(e,t,n,y,g,m):i(e,t,k,n,y,g,m);if(!(n&p)){var C=S&&v.call(e,'__wrapped__'),D=P&&v.call(t,'__wrapped__');if(C||D){var _=C?e.value():e,E=D?t.value():t;return m||(m=new r),g(_,E,n,y,m)}}return!!O&&(m||(m=new r),s(e,t,n,y,g,m))}},function(e,t,n){"use strict";var r='__lodash_hash_undefined__';e.exports=function(e){return this.__data__.set(e,r),this}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},function(e,t,n){"use strict";var r=n(40),a=n(74),i=n(35),s=n(71),o=n(133),c=n(53),u=1,l=2,p='[object Boolean]',d='[object Date]',h='[object Error]',f='[object Map]',v='[object Number]',y='[object RegExp]',g='[object Set]',m='[object String]',b='[object Symbol]',w='[object ArrayBuffer]',k='[object DataView]',x=r?r.prototype:void 0,S=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,P,O){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!P(new a(e),new a(t)));case p:case d:case v:return i(+e,+t);case h:return e.name==t.name&&e.message==t.message;case y:case m:return e==t+'';case f:var C=o;case g:var D=r&u;if(C||(C=c),e.size!=t.size&&!D)return!1;var _=O.get(e);if(_)return _==t;r|=l,O.set(e,t);var E=s(C(e),C(t),r,x,P,O);return O.delete(e),E;case b:if(S)return S.call(e)==S.call(t)}return!1}},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},function(e,t,n){"use strict";var r=n(135),a=1,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,s,o,c){var u=n&a,l=r(e),p=l.length;if(p!=r(t).length&&!u)return!1;for(var d=p;d--;){var h=l[d];if(!(u?h in t:i.call(t,h)))return!1}var f=c.get(e),v=c.get(t);if(f&&v)return f==t&&v==e;var y=!0;c.set(e,t),c.set(t,e);for(var g=u;++d<p;){var m=e[h=l[d]],b=t[h];if(s)var w=u?s(b,m,h,t,e,c):s(m,b,h,e,t,c);if(!(void 0===w?m===b||o(m,b,n,s,c):w)){y=!1;break}g||(g='constructor'==h)}if(y&&!g){var k=e.constructor,x=t.constructor;k!=x&&'constructor'in e&&'constructor'in t&&!('function'==typeof k&&k instanceof k&&'function'==typeof x&&x instanceof x)&&(y=!1)}return c.delete(e),c.delete(t),y}},function(e,t,n){"use strict";var r=n(136),a=n(138),i=n(54);e.exports=function(e){return r(e,i,a)}},function(e,t,n){"use strict";var r=n(137),a=n(23);e.exports=function(e,t,n){var i=t(e);return a(e)?i:r(i,n(e))}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}},function(e,t,n){"use strict";var r=n(139),a=n(140),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:a;e.exports=o},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}},function(e,t,n){"use strict";e.exports=function(){return[]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Arguments]';e.exports=function(e){return a(e)&&r(e)==i}},function(e,t,n){"use strict";e.exports=function(){return!1}},function(e,t,n){"use strict";var r=n(33),a=n(59),i=n(31),s={};s['[object Float32Array]']=s['[object Float64Array]']=s['[object Int8Array]']=s['[object Int16Array]']=s['[object Int32Array]']=s['[object Uint8Array]']=s['[object Uint8ClampedArray]']=s['[object Uint16Array]']=s['[object Uint32Array]']=!0,s['[object Arguments]']=s['[object Array]']=s['[object ArrayBuffer]']=s['[object Boolean]']=s['[object DataView]']=s['[object Date]']=s['[object Error]']=s['[object Function]']=s['[object Map]']=s['[object Number]']=s['[object Object]']=s['[object RegExp]']=s['[object Set]']=s['[object String]']=s['[object WeakMap]']=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!s[r(e)]}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){"use strict";(function(e){var r=n(68),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a&&r.process,o=(function(){try{var e=i&&i.require&&i.require('util').types;return e||s&&s.binding&&s.binding('util')}catch(e){}})();e.exports=o}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(60),a=n(148),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return a(e);var t=[];for(var n in Object(e))i.call(e,n)&&'constructor'!=n&&t.push(n);return t}},function(e,t,n){"use strict";var r=n(76)(Object.keys,Object);e.exports=r},function(e,t,n){"use strict";var r=n(150),a=n(50),i=n(151),s=n(77),o=n(152),c=n(33),u=n(69),l=u(r),p=u(a),d=u(i),h=u(s),f=u(o),v=c;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||a&&"[object Map]"!=v(new a)||i&&"[object Promise]"!=v(i.resolve())||s&&"[object Set]"!=v(new s)||o&&"[object WeakMap]"!=v(new o))&&(v=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):'';if(r)switch(r){case l:return"[object DataView]";case p:return"[object Map]";case d:return"[object Promise]";case h:return"[object Set]";case f:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";var r=n(30)(n(24),'DataView');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'Promise');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'WeakMap');e.exports=r},function(e,t,n){"use strict";var r=n(78),a=n(54);e.exports=function(e){for(var t=a(e),n=t.length;n--;){var i=t[n],s=e[i];t[n]=[i,s,r(s)]}return t}},function(e,t,n){"use strict";var r=n(70),a=n(155),i=n(162),s=n(63),o=n(78),c=n(79),u=n(37);e.exports=function(e,t){return s(e)&&o(t)?c(u(e),t):function(n){var s=a(n,e);return void 0===s&&s===t?i(n,e):r(t,s,3)}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e,t,n){var a=null==e?void 0:r(e,t);return void 0===a?n:a}},function(e,t,n){"use strict";var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,i=n(157)(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(''),e.replace(r,function(e,n,r,i){t.push(r?i.replace(a,'$1'):n||e)}),t});e.exports=i},function(e,t,n){"use strict";var r=n(158),a=500;e.exports=function(e){var t=r(e,function(e){return n.size===a&&n.clear(),e}),n=t.cache;return t}},function(e,t,n){"use strict";var r=n(52),a='Expected a function';function i(e,t){if('function'!=typeof e||null!=t&&'function'!=typeof t)throw new TypeError(a);var n=function n(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},function(e,t,n){"use strict";var r=n(160);e.exports=function(e){return null==e?'':r(e)}},function(e,t,n){"use strict";var r=n(40),a=n(161),i=n(23),s=n(44),o=r?r.prototype:void 0,c=o?o.toString:void 0;e.exports=function e(t){if('string'==typeof t)return t;if(i(t))return a(t,e)+'';if(s(t))return c?c.call(t):'';var n=t+'';return'0'==n&&1/t==-1/0?'-0':n}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}},function(e,t,n){"use strict";var r=n(163),a=n(164);e.exports=function(e,t){return null!=e&&a(e,t,r)}},function(e,t,n){"use strict";e.exports=function(e,t){return null!=e&&t in Object(e)}},function(e,t,n){"use strict";var r=n(62),a=n(55),i=n(23),s=n(43),o=n(59),c=n(37);e.exports=function(e,t,n){for(var u=-1,l=(t=r(t,e)).length,p=!1;++u<l;){var d=c(t[u]);if(!(p=null!=e&&n(e,d)))break;e=e[d]}return p||++u!=l?p:!!(l=null==e?0:e.length)&&o(l)&&s(d,l)&&(i(e)||a(e))}},function(e,t,n){"use strict";var r=n(166),a=n(167),i=n(63),s=n(37);e.exports=function(e){return i(e)?r(s(e)):a(e)}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e){return function(t){return r(t,e)}}},function(e,t,n){"use strict";var r=n(169),a=n(43),i=Array.prototype.splice;e.exports=function(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;a(o)?i.call(e,o,1):r(e,o)}}return e}},function(e,t,n){"use strict";var r=n(62),a=n(170),i=n(171),s=n(37);e.exports=function(e,t){return t=r(t,e),null==(e=i(e,t))||delete e[s(a(t))]}},function(e,t,n){"use strict";e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t,n){"use strict";var r=n(61),a=n(172);e.exports=function(e,t){return t.length<2?e:r(e,a(t,0,-1))}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(a);++r<a;)i[r]=e[r+t];return i}},function(e,t,n){"use strict";var r=n(48),a=n(36),i=n(54);e.exports=function(e){return function(t,n,s){var o=Object(t);if(!a(t)){var c=r(n,3);t=i(t),n=function(e){return c(o[e],e,o)}}var u=e(t,n,s);return u>-1?o[c?t[u]:u]:void 0}}},function(e,t,n){"use strict";var r=n(80),a=n(48),i=n(175),s=Math.max;e.exports=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var c=null==n?0:i(n);return c<0&&(c=s(o+c,0)),r(e,a(t,3),c)}},function(e,t,n){"use strict";var r=n(176);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){"use strict";var r=n(177),a=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=r(e))===a||e===-1/0?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,n){"use strict";var r=n(26),a=n(44),i=NaN,s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(a(e))return i;if(r(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=r(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):o.test(e)?i:+e}},function(e,t,n){"use strict";var r=n(179)();e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t,n,r){for(var a=-1,i=Object(t),s=r(t),o=s.length;o--;){var c=s[e?o:++a];if(!1===n(i[c],c,i))break}return t}}},function(e,t,n){"use strict";var r=n(82),a=n(181),i=n(182),s=n(184),o=n(185),c=n(55),u=n(23),l=n(187),p=n(56),d=n(51),h=n(26),f=n(188),v=n(58),y=n(85),g=n(189);e.exports=function(e,t,n,m,b,w,k){var x=y(e,n),S=y(t,n),P=k.get(S);if(P)r(e,n,P);else{var O=w?w(x,S,n+'',e,t,k):void 0,C=void 0===O;if(C){var D=u(S),_=!D&&p(S),E=!D&&!_&&v(S);O=S,D||_||E?u(x)?O=x:l(x)?O=s(x):_?(C=!1,O=a(S,!0)):E?(C=!1,O=i(S,!0)):O=[]:f(S)||c(S)?(O=x,c(x)?O=g(x):h(x)&&!d(x)||(O=o(S))):C=!1}C&&(k.set(S,O),b(O,S,m,w,k),k.delete(S)),r(e,n,O)}}},function(e,t,n){"use strict";(function(e){var r=n(24),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(183);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},function(e,t,n){"use strict";var r=n(74);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t,n){"use strict";e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},function(e,t,n){"use strict";var r=n(186),a=n(84),i=n(60);e.exports=function(e){return'function'!=typeof e.constructor||i(e)?{}:r(a(e))}},function(e,t,n){"use strict";var r=n(26),a=Object.create,i=(function(){function e(){}return function(t){if(!r(t))return{};if(a)return a(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}})();e.exports=i},function(e,t,n){"use strict";var r=n(36),a=n(31);e.exports=function(e){return a(e)&&r(e)}},function(e,t,n){"use strict";var r=n(33),a=n(84),i=n(31),s='[object Object]',o=Function.prototype,c=Object.prototype,u=o.toString,l=c.hasOwnProperty,p=u.call(Object);e.exports=function(e){if(!i(e)||r(e)!=s)return!1;var t=a(e);if(null===t)return!0;var n=l.call(t,'constructor')&&t.constructor;return'function'==typeof n&&n instanceof n&&u.call(n)==p}},function(e,t,n){"use strict";var r=n(190),a=n(86);e.exports=function(e){return r(e,a(e))}},function(e,t,n){"use strict";var r=n(191),a=n(65);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var o=-1,c=t.length;++o<c;){var u=t[o],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?a(n,u,l):r(n,u,l)}return n}},function(e,t,n){"use strict";var r=n(65),a=n(35),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&a(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(26),a=n(60),i=n(193),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=a(e),n=[];for(var o in e)('constructor'!=o||!t&&s.call(e,o))&&n.push(o);return n}},function(e,t,n){"use strict";e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},function(e,t,n){"use strict";var r=n(64),a=n(195),i=n(197);e.exports=function(e,t){return i(a(e,t,r),e+'')}},function(e,t,n){"use strict";var r=n(196),a=Math.max;e.exports=function(e,t,n){return t=a(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=a(i.length-t,0),c=Array(o);++s<o;)c[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(c),r(e,this,u)}}},function(e,t,n){"use strict";e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){"use strict";var r=n(198),a=n(200)(r);e.exports=a},function(e,t,n){"use strict";var r=n(199),a=n(83),i=n(64),s=a?function(e,t){return a(e,'toString',{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},function(e,t,n){"use strict";e.exports=function(e){return function(){return e}}},function(e,t,n){"use strict";var r=800,a=16,i=Date.now;e.exports=function(e){var t=0,n=0;return function(){var s=i(),o=a-(s-n);if(n=s,o>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){"use strict";var r=n(35),a=n(36),i=n(43),s=n(26);e.exports=function(e,t,n){if(!s(n))return!1;var o=typeof t;return!!('number'==o?a(n)&&i(t,n.length):'string'==o&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";var r=n(203);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t,n){"use strict";var r=n(80),a=n(204),i=n(205);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,a,n)}},function(e,t,n){"use strict";e.exports=function(e){return e!=e}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=n-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=-1,a=null==e?0:e.length;++r<a;)if(n(t,e[r]))return!0;return!1}},function(e,t,n){"use strict";var r=n(77),a=n(208),i=n(53),s=r&&1/i(new r([,-0]))[1]==1/0?function(e){return new r(e)}:a;e.exports=s},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";(function(e,t){!(function(e,n){if(!e.setImmediate){var r,a,i,s,o,c=1,u={},l=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){v(e)})}:!(function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}})()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){v(e.data)},r=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(a=p.documentElement,r=function(e){var t=p.createElement("script");t.onreadystatechange=function(){v(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(v,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&v(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return u[c]=a,r(c),c++},d.clearImmediate=h}function h(e){delete u[e]}function f(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}function v(e){if(l)setTimeout(v,0,e);else{var t=u[e];if(t){l=!0;try{f(t)}finally{h(e),l=!1}}}}})("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(34),n(210))},function(e,t,n){"use strict";var r,a,i=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(a===clearTimeout)return clearTimeout(e);if((a===o||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{return a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}!(function(){try{r='function'==typeof setTimeout?setTimeout:s}catch(e){r=s}try{a='function'==typeof clearTimeout?clearTimeout:o}catch(e){a=o}})();var l,p=[],d=!1,h=-1;function f(){d&&l&&(d=!1,l.length?p=l.concat(p):h=-1,p.length&&v())}function v(){if(!d){var e=c(f);d=!0;for(var t=p.length;t;){for(l=p,p=[];++h<t;)l&&l[h].run();h=-1,t=p.length}l=null,d=!1,u(e)}}function y(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new y(e,t)),1!==p.length||d||c(v)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title='browser',i.browser=!0,i.env={},i.argv=[],i.version='',i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error('process.binding is not supported')},i.cwd=function(){return'/'},i.chdir=function(e){throw new Error('process.chdir is not supported')},i.umask=function(){return 0}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(212),t),a(n(213),t),a(n(218),t),a(n(219),t),a(n(220),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentType=void 0,(function(e){e.Any="*",e.Item="SF|Item",e.RootKey="SN|RootKey|NoSync",e.ItemsKey="SN|ItemsKey",e.EncryptedStorage="SN|EncryptedStorage",e.Privileges="SN|Privileges",e.Note="Note",e.Tag="Tag",e.SmartTag="SN|SmartTag",e.Component="SN|Component",e.Editor="SN|Editor",e.ActionsExtension="Extension",e.UserPrefs="SN|UserPreferences",e.HistorySession="SN|HistorySession",e.Theme="SN|Theme",e.ServerExtension="SF|Extension",e.FilesafeCredentials="SN|FileSafe|Credentials",e.FilesafeFileMetadata="SN|FileSafe|FileMetadata",e.FilesafeIntegration="SN|FileSafe|Integration",e.ExtensionRepo="SN|ExtensionRepo",e.Unknown="Unknown"})(t.ContentType||(t.ContentType={}))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.ContentDecoder=void 0;var n=(function(){function t(){v(this,t)}return y(t,[{key:"decode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;try{var r=n>0?t.substring(n):t,a=e.from(r,'base64').toString();return JSON.parse(a)}catch(e){return{}}}},{key:"encode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=JSON.stringify(t),a=e.from(r).toString('base64');return a.padStart(a.length+n,'0')}}]),t})();t.ContentDecoder=n}).call(this,n(214).Buffer)},function(e,t,n){"use strict";(function(e){var r=n(215),a=n(216),i=n(217);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return d(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?v(e,t,n,r):'string'==typeof t?h(e,t,n):y(e,t)}function l(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function p(e,t,n,r){return l(t),t<=0?o(e,t):void 0!==n?'string'==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function d(e,t){if(l(t),e=o(e,t<0?0:0|g(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t,n){if('string'==typeof n&&''!==n||(n='utf8'),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(t,n),a=(e=o(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}function f(e,t){var n=t.length<0?0:0|g(t.length);e=o(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function v(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(r||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t),e}function y(e,t){if(c.isBuffer(t)){var n=0|g(t.length);return 0===(e=o(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||(r=t.length)!=r?o(e,0):f(e,t);if('Buffer'===t.type&&i(t.data))return f(e,t.data)}var r;throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function g(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+' bytes');return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return G(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return $(e).length;default:if(r)return G(e).length;t=(''+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),n<=0)return'';if((n>>>=0)<=(t>>>=0))return'';for(e||(e='utf8');;)switch(e){case'hex':return T(this,t,n);case'utf8':case'utf-8':return R(this,t,n);case'ascii':return A(this,t,n);case'latin1':case'binary':return j(this,t,n);case'base64':return E(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return K(this,t,n);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,a){if(0===e.length)return-1;if('string'==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if('string'==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:x(e,t,n,r,a);if('number'==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):x(e,[t],n,r,a);throw new TypeError('val must be string, number or Buffer')}function x(e,t,n,r,a){var i,s=1,o=e.length,c=t.length;if(void 0!==r&&('ucs2'===(r=String(r).toLowerCase())||'ucs-2'===r||'utf16le'===r||'utf-16le'===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var l=-1;for(i=n;i<o;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>o&&(n=o-c),i=n;i>=0;i--){for(var p=!0,d=0;d<c;d++)if(u(e,i+d)!==u(t,d)){p=!1;break}if(p)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError('Invalid hex string');r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function P(e,t,n,r){return X(G(t,e.length-n),e,n,r)}function O(e,t,n,r){return X(Q(t),e,n,r)}function C(e,t,n,r){return O(e,t,n,r)}function D(e,t,n,r){return X($(t),e,n,r)}function _(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,c,u=e[a],l=null,p=u>239?4:u>223?3:u>191?2:1;if(a+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=p}return M(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:(function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}})(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return p(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('Arguments must be Buffers');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,a),a+=s.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var t=0;t<e;t+=2)w(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?'':0===arguments.length?R(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e='',n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString('hex',0,n).match(/.{2}/g).join(' '),this.length>n&&(e+=' ... ')),'<Buffer '+e+'>'},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError('out of range index');if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,s=n-t,o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),p=0;p<o;++p)if(u[p]!==l[p]){i=u[p],s=l[p];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r='utf8',n=this.length,t=0;else if(void 0===n&&'string'==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');t|=0,isFinite(n)?(n|=0,void 0===r&&(r='utf8')):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return S(this,e,t,n);case'utf8':case'utf-8':return P(this,e,t,n);case'ascii':return O(this,e,t,n);case'latin1':case'binary':return C(this,e,t,n);case'base64':return D(this,e,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return _(this,e,t,n);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var n='',r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function A(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function j(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function T(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a='',i=t;i<n;++i)a+=Y(e[i]);return a}function K(e,t,n){for(var r=e.slice(t,n),a='',i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function L(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError('Index out of range')}function U(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function V(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError('Index out of range');if(n<0)throw new RangeError('Index out of range')}function B(e,t,n,r,i){return i||V(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function W(e,t,n,r,i){return i||V(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var a=t-e;n=new c(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return W(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return W(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError('targetStart out of bounds');if(n<0||n>=this.length)throw new RangeError('sourceStart out of bounds');if(r<0)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if('string'==typeof e){if('string'==typeof t?(r=t,t=0,n=this.length):'string'==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!c.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError('Out of range index');if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),'number'==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:G(new c(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var H=/[^+\/0-9A-Za-z-_]/g;function z(e){if((e=q(e).replace(H,'')).length<2)return'';for(;e.length%4!=0;)e+='=';return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function Y(e){return e<16?'0'+e.toString(16):e.toString(16)}function G(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error('Invalid code point');if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function J(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}function $(e){return r.toByteArray(z(e))}function X(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(34))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],o=r[1],c=new i(l(e,s,o)),p=0,d=o>0?s-4:s;for(n=0;n<d;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=0,o=n-a;s<o;s+=16383)i.push(p(e,s,s+16383>o?o:s+16383));1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+'==')):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+'='));return i.join('')};for(var r=[],a=[],i='undefined'!=typeof Uint8Array?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',o=0,c=s.length;o<c;++o)r[o]=s[o],a[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){return 3*(t+n)/4-n}function p(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join('')}a['-'.charCodeAt(0)]=62,a['_'.charCodeAt(0)]=63},function(e,t,n){"use strict";t.read=function(e,t,n,r,a){var i,s,o=8*a-r-1,c=(1<<o)-1,u=c>>1,l=-7,p=n?a-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=o;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var s,o,c,u=8*i-a-1,l=(1<<u)-1,p=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(o=0,s=l):s+p>=1?(o=(t*c-1)*Math.pow(2,a),s+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+h]=255&o,h+=f,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*v}},function(e,t,n){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==r.call(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTag=void 0,(function(e){e.MfaInvalid="mfa-invalid",e.MfaRequired="mfa-required",e.RefreshTokenInvalid="invalid-refresh-token",e.RefreshTokenExpired="expired-refresh-token",e.AccessTokenExpired="expired-access-token",e.ParametersInvalid="invalid-parameters",e.RevokedSession="revoked-session",e.AuthInvalid="invalid-auth"})(t.ErrorTag||(t.ErrorTag={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(222),t),a(n(90),t),a(n(223),t),a(n(225),t),a(n(93),t),a(n(91),t),a(n(92),t),a(n(226),t),a(n(227),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Features=void 0;for(var a,i=n(19),s=n(91),o=n(92),c=n(93),u=n(90),l=[],p=function(e){var t=e.identifier,n=e.permission_name,r=e.content_type,a=e.area,l=e.flags,p=Object.values(c.PermissionName),d=Object.values(u.FeatureIdentifier),h=Object.values(i.ContentType),f=Object.values(s.ComponentArea),v=Object.values(o.ComponentFlag);if(!d.includes(t))throw Error("Invalid feature identifier ".concat(t));if(!p.includes(n))throw Error("Invalid permission name ".concat(n));if(r&&!h.includes(r))throw Error("Invalid feature content type ".concat(r));if(a&&!f.includes(a))throw Error("Invalid feature area ".concat(a));if(l&&l.some(function(e){return!v.includes(e)}))throw Error("Invalid feature flag ".concat(l))},d=S(r(n(224)).default);!(a=d()).done;){var h=a.value;p(h),l.push(h)}t.Features=l},function(e){e.exports=JSON.parse("[{\"name\":\"Midnight\",\"identifier\":\"org.standardnotes.theme-midnight\",\"permission_name\":\"theme:midnight\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Elegant utilitarianism.\",\"url\":\"#{url_prefix}/themes/midnight\",\"download_url\":\"https://github.com/standardnotes/midnight-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/midnight\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#086DD6\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#086DD6\"}},{\"name\":\"Futura\",\"identifier\":\"org.standardnotes.theme-futura\",\"permission_name\":\"theme:futura\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Calm and relaxed. Take some time off.\",\"url\":\"#{url_prefix}/themes/futura\",\"download_url\":\"https://github.com/standardnotes/futura-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/futura\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#fca429\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#fca429\"}},{\"name\":\"Solarized Dark\",\"identifier\":\"org.standardnotes.theme-solarized-dark\",\"permission_name\":\"theme:solarized-dark\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.3\",\"description\":\"The perfect theme for any time.\",\"url\":\"#{url_prefix}/themes/solarized-dark\",\"download_url\":\"https://github.com/standardnotes/solarized-dark-theme/archive/1.2.3.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/solarized-dark\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#2AA198\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#2AA198\"}},{\"name\":\"Autobiography\",\"identifier\":\"org.standardnotes.theme-autobiography\",\"permission_name\":\"theme:autobiography\",\"content_type\":\"SN|Theme\",\"version\":\"1.0.1\",\"description\":\"A theme for writers and readers.\",\"url\":\"#{url_prefix}/themes/autobiography\",\"download_url\":\"https://github.com/standardnotes/autobiography-theme/archive/1.0.1.zip\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg\",\"flags\":[\"New\"],\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#9D7441\",\"foreground_color\":\"#ECE4DB\",\"border_color\":\"#9D7441\"}},{\"name\":\"Focus\",\"identifier\":\"org.standardnotes.theme-focus\",\"permission_name\":\"theme:focused\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.5\",\"description\":\"For when you need to go in.\",\"url\":\"#{url_prefix}/themes/focus\",\"download_url\":\"https://github.com/standardnotes/focus-theme/archive/1.2.5.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/focused\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#a464c2\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#a464c2\"}},{\"identifier\":\"org.standardnotes.theme-titanium\",\"permission_name\":\"theme:titanium\",\"name\":\"Titanium\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Light on the eyes, heavy on the spirit.\",\"url\":\"#{url_prefix}/themes/titanium\",\"download_url\":\"https://github.com/standardnotes/titanium-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/titanium\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#6e2b9e\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#6e2b9e\"}},{\"identifier\":\"org.standardnotes.theme-dynamic\",\"name\":\"Dynamic\",\"permission_name\":\"theme:dynamic\",\"content_type\":\"SN|Theme\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.0.0\",\"description\":\"A smart theme that minimizes the tags and notes panels when they are not in use.\",\"url\":\"#{url_prefix}/themes/dynamic\",\"download_url\":\"https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/dynamic\"},{\"identifier\":\"org.standardnotes.theme-no-distraction\",\"name\":\"No Distraction\",\"content_type\":\"SN|Theme\",\"permission_name\":\"theme:no-distraction\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.2.2\",\"description\":\"A theme for focusing on your writing.\",\"url\":\"#{url_prefix}/themes/no-distraction\",\"download_url\":\"https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/no-distraction\",\"dock_icon\":{\"type\":\"svg\",\"source\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><path d=\\\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\\\"/></svg>\"}},{\"name\":\"Bold Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.bold-editor\",\"permission_name\":\"editor:bold\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.2.9\",\"description\":\"A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.\",\"url\":\"#{url_prefix}/components/bold-editor\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg\",\"download_url\":\"https://github.com/standardnotes/bold-editor/archive/1.2.9.zip\"},{\"name\":\"Plus Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.plus-editor\",\"permission_name\":\"editor:plus\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.5.0\",\"description\":\"From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.\",\"url\":\"#{url_prefix}/components/plus-editor\",\"download_url\":\"https://github.com/standardnotes/plus-editor/archive/1.5.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/plus-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg\"},{\"name\":\"Markdown Basic\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.simple-markdown-editor\",\"permission_name\":\"editor:markdown-basic\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A Markdown editor with dynamic split-pane preview.\",\"url\":\"#{url_prefix}/components/simple-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg\"},{\"name\":\"Markdown Pro\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.advanced-markdown-editor\",\"permission_name\":\"editor:markdown-pro\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.14\",\"description\":\"A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.\",\"url\":\"#{url_prefix}/components/advanced-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/advanced-markdown-editor/archive/1.3.14.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/advanced-markdown\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg\"},{\"name\":\"Markdown Minimist\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.minimal-markdown-editor\",\"permission_name\":\"editor:markdown-minimist\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F\",\"url\":\"#{url_prefix}/components/minimal-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/minimal-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg\"},{\"name\":\"Markdown Math\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.fancy-markdown-editor\",\"permission_name\":\"editor:markdown-math\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.4\",\"description\":\"A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.\",\"url\":\"#{url_prefix}/components/fancy-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/math-editor/archive/1.3.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/math-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg\"},{\"name\":\"Task Editor\",\"note_type\":\"task\",\"file_type\":\"md\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.simple-task-editor\",\"permission_name\":\"editor:task-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A great way to manage short-term and long-term to-do\\\"s. You can mark tasks as completed, change their order, and edit the text naturally in place.\",\"url\":\"#{url_prefix}/components/simple-task-editor\",\"download_url\":\"https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-task-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg\"},{\"name\":\"Code Editor\",\"note_type\":\"code\",\"file_type\":\"txt\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.code-editor\",\"permission_name\":\"editor:code-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.8\",\"description\":\"Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.\",\"url\":\"#{url_prefix}/components/code-editor\",\"download_url\":\"https://github.com/standardnotes/code-editor/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/code-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg\"},{\"name\":\"TokenVault\",\"note_type\":\"authentication\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.token-vault\",\"permission_name\":\"editor:token-vault\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"2.0.6\",\"description\":\"Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.\",\"url\":\"#{url_prefix}/components/token-vault\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/token-vault/archive/2.0.6.zip\",\"thumbnail_url\":\"https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png\",\"flags\":[\"New\"]},{\"name\":\"Secure Spreadsheets\",\"note_type\":\"spreadsheet\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.standard-sheets\",\"permission_name\":\"editor:sheets\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.\",\"url\":\"#{url_prefix}/components/standard-sheets\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/secure-spreadsheets/archive/1.4.0.zip\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png\"},{\"identifier\":\"org.standardnotes.file-safe\",\"name\":\"FileSafe\",\"permission_name\":\"component:filesafe\",\"content_type\":\"SN|Component\",\"area\":\"editor-stack\",\"version\":\"2.0.10\",\"description\":\"Encrypted attachments for your notes using your Dropbox, Google Drive, or WebDAV server. Limited to 50MB per file.\",\"url\":\"#{url_prefix}/components/filesafe\",\"download_url\":\"https://github.com/standardnotes/filesafe-client/archive/2.0.10.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/filesafe\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/FileSafe-banner.png\"},{\"identifier\":\"org.standardnotes.folders\",\"name\":\"Folders\",\"content_type\":\"SN|Component\",\"permission_name\":\"component:folders\",\"area\":\"tags-list\",\"version\":\"1.3.8\",\"description\":\"Create nested folders with easy drag and drop.\",\"url\":\"#{url_prefix}/components/folders\",\"download_url\":\"https://github.com/standardnotes/folders-component/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/folders\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/components/folders.jpg\"},{\"name\":\"2FA Manager\",\"identifier\":\"org.standardnotes.mfa-link\",\"permission_name\":\"component:2fa-manager\",\"content_type\":\"SN|Component\",\"description\":\"Configure two-factor authentication to add an extra level of security to your account.\",\"version\":\"1.2.4\",\"url\":\"#{url_prefix}/components/mfa-link\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/mfa-link/archive/1.2.4.zip\",\"area\":\"modal\",\"no_expire\":true,\"deletion_warning\":\"Deleting 2FA Manager will not disable 2FA from your account. To disable 2FA, first open 2FA Manager, then follow the prompts.\",\"deprecated\":true},{\"name\":\"\",\"identifier\":\"org.standardnotes.two-factor-auth\",\"permission_name\":\"server:two-factor-auth\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-unlimited\",\"permission_name\":\"server:note-history-unlimited\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-365\",\"permission_name\":\"server:note-history-365-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-30\",\"permission_name\":\"server:note-history-30-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-email-backup\",\"permission_name\":\"server:daily-email-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-dropbox-backup\",\"permission_name\":\"server:daily-dropbox-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-gdrive-backup\",\"permission_name\":\"server:daily-gdrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-onedrive-backup\",\"permission_name\":\"server:daily-onedrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-25-gb\",\"permission_name\":\"server:files-25-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-5-gb\",\"permission_name\":\"server:files-5-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Tag Nesting\",\"identifier\":\"org.standardnotes.tag-nesting\",\"permission_name\":\"app:tag-nesting\",\"description\":\"Create nested tags with easy drag and drop.\",\"version\":\"0.1.0\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files\",\"permission_name\":\"app:files\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"CloudLink\",\"identifier\":\"org.standardnotes.cloudlink\",\"permission_name\":\"component:cloud-link\",\"content_type\":\"SN|Component\",\"description\":\"Manage and install cloud backups, including Note History, Dropbox, Google Drive, OneDrive, and Daily Email Backups.\",\"version\":\"1.2.3\",\"url\":\"#{url_prefix}/components/cloudlink\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Listed Custom Domain\",\"identifier\":\"org.standardnotes.listed-custom-domain\",\"permission_name\":\"listed:custom-domain\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"Focus Mode\",\"identifier\":\"org.standardnotes.focus-mode\",\"permission_name\":\"app:focus-mode\"}]")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoteType=void 0,(function(e){e.Authentication="authentication",e.Code="code",e.Markdown="markdown",e.RichText="rich-text",e.Spreadsheet="spreadsheet",e.Task="task"})(t.NoteType||(t.NoteType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timingSafeEqual=void 0,t.timingSafeEqual=function(e,t){var n=String(e),r=String(t),a=n.length,i=0;a!==r.length&&(r=n,i=1);for(var s=0;s<a;s++)i|=n.charCodeAt(s)^r.charCodeAt(s);return 0===i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(232),t),a(n(233),t),a(n(234),t),a(n(235),t),a(n(236),t),a(n(237),t),a(n(238),t),a(n(239),t),a(n(240),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoleName=void 0,(function(e){e.BasicUser="BASIC_USER",e.CoreUser="CORE_USER",e.PlusUser="PLUS_USER",e.ProUser="PRO_USER"})(t.RoleName||(t.RoleName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionName=void 0,(function(e){e.CorePlan="CORE_PLAN",e.PlusPlan="PLUS_PLAN",e.ProPlan="PRO_PLAN"})(t.SubscriptionName||(t.SubscriptionName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(242),t),a(n(243),t),a(n(244),t),a(n(245),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmailBackupFrequency=void 0,(function(e){e.Daily="daily",e.Weekly="weekly"})(t.EmailBackupFrequency||(t.EmailBackupFrequency={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedBackupsEmailsOption||(t.MuteFailedBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedCloudBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedCloudBackupsEmailsOption||(t.MuteFailedCloudBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingName=void 0,(function(e){e.MfaSecret="MFA_SECRET",e.ExtensionKey="EXTENSION_KEY",e.EmailBackup="EMAIL_BACKUP",e.MuteFailedBackupsEmails="MUTE_FAILED_BACKUPS_EMAILS",e.MuteFailedCloudBackupsEmails="MUTE_FAILED_CLOUD_BACKUPS_EMAILS"})(t.SettingName||(t.SettingName={}))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"SnjsVersion",function(){return h}),n.d(t,"isRightVersionGreaterThanLeft",function(){return x}),n.d(t,"compareSemVersions",function(){return P}),n.d(t,"SNApplicationGroup",function(){return M}),n.d(t,"DeinitSource",function(){return C}),n.d(t,"KeyParamsOrigination",function(){return A.g}),n.d(t,"KeyRecoveryStrings",function(){return j.H}),n.d(t,"SessionStrings",function(){return j.R}),n.d(t,"SNApplication",function(){return ca}),n.d(t,"SNProtocolService",function(){return Gn}),n.d(t,"KeyMode",function(){return Bn}),n.d(t,"SNProtocolOperator001",function(){return An}),n.d(t,"SNProtocolOperator002",function(){return Fn}),n.d(t,"SNProtocolOperator003",function(){return Ln}),n.d(t,"SNProtocolOperator004",function(){return Wn}),n.d(t,"SNRootKey",function(){return Ve}),n.d(t,"SNRootKeyParams",function(){return A.h}),n.d(t,"DeviceInterface",function(){return ua}),n.d(t,"SNItem",function(){return T.d}),n.d(t,"ItemMutator",function(){return T.b}),n.d(t,"AppDataField",function(){return T.a}),n.d(t,"SNItemsKey",function(){return J}),n.d(t,"SNPredicate",function(){return H.a}),n.d(t,"SNNote",function(){return le}),n.d(t,"NoteMutator",function(){return pe}),n.d(t,"SNTag",function(){return oe}),n.d(t,"TagMutator",function(){return ce}),n.d(t,"SNSmartTag",function(){return et}),n.d(t,"SNActionsExtension",function(){return ie}),n.d(t,"ActionsExtensionMutator",function(){return se}),n.d(t,"Action",function(){return ae}),n.d(t,"SNTheme",function(){return B}),n.d(t,"ThemeMutator",function(){return W}),n.d(t,"SNComponent",function(){return N}),n.d(t,"ComponentAction",function(){return E}),n.d(t,"ComponentMutator",function(){return V}),n.d(t,"SNEditor",function(){return Ze}),n.d(t,"SNUserPrefs",function(){return z}),n.d(t,"UserPrefsMutator",function(){return G}),n.d(t,"PrefKey",function(){return U}),n.d(t,"MutationType",function(){return T.c}),n.d(t,"ComponentArea",function(){return L.ComponentArea}),n.d(t,"LiveItem",function(){return la}),n.d(t,"FeatureStatus",function(){return ur}),n.d(t,"SNComponentManager",function(){return an}),n.d(t,"HistoryEntry",function(){return Qn}),n.d(t,"PayloadManager",function(){return sn}),n.d(t,"ItemManager",function(){return _r}),n.d(t,"SNHttpService",function(){return jt}),n.d(t,"ChallengeService",function(){return na}),n.d(t,"PureService",function(){return R.a}),n.d(t,"ApplicationService",function(){return pa.a}),n.d(t,"SNStorageService",function(){return Ie}),n.d(t,"StoragePersistencePolicies",function(){return Oe}),n.d(t,"StorageEncryptionPolicies",function(){return Ce}),n.d(t,"StorageValueModes",function(){return De}),n.d(t,"ValueModesKeys",function(){return _e}),n.d(t,"Challenge",function(){return ye}),n.d(t,"ChallengeReason",function(){return ne}),n.d(t,"ChallengeResponse",function(){return be}),n.d(t,"ChallengeValidation",function(){return te}),n.d(t,"ChallengeValue",function(){return me}),n.d(t,"ChallengePrompt",function(){return ge}),n.d(t,"SNSyncService",function(){return ea}),n.d(t,"SyncSources",function(){return $r}),n.d(t,"SyncModes",function(){return Jr}),n.d(t,"SyncQueueStrategy",function(){return Qr}),n.d(t,"SNCredentialService",function(){return Qe}),n.d(t,"SyncResponse",function(){return Br}),n.d(t,"SyncResponseResolver",function(){return Vr}),n.d(t,"SyncOpStatus",function(){return fr}),n.d(t,"SortPayloadsByRecentAndContentPriority",function(){return Mr}),n.d(t,"SyncUpDownLimit",function(){return Wr}),n.d(t,"SNSessionManager",function(){return Ge}),n.d(t,"SessionEvent",function(){return ze}),n.d(t,"SNMigrationService",function(){return En}),n.d(t,"ButtonType",function(){return St}),n.d(t,"SNHistoryManager",function(){return nr}),n.d(t,"SNProtectionService",function(){return ir}),n.d(t,"SNSingletonManager",function(){return cn}),n.d(t,"SNApiService",function(){return Yt}),n.d(t,"addIfUnique",function(){return _.b}),n.d(t,"arrayByDifference",function(){return _.c}),n.d(t,"Copy",function(){return _.a}),n.d(t,"dateSorted",function(){return _.j}),n.d(t,"deepMerge",function(){return _.m}),n.d(t,"dictToArray",function(){return _.n}),n.d(t,"extendArray",function(){return _.o}),n.d(t,"filterFromArray",function(){return _.p}),n.d(t,"findInArray",function(){return _.q}),n.d(t,"getGlobalScope",function(){return _.r}),n.d(t,"greaterOfTwoDates",function(){return _.s}),n.d(t,"isNullOrUndefined",function(){return _.w}),n.d(t,"isSameDay",function(){return _.z}),n.d(t,"jsonParseEmbeddedKeys",function(){return _.E}),n.d(t,"naturalSort",function(){return _.G}),n.d(t,"omitInPlace",function(){return _.J}),n.d(t,"omitUndefinedCopy",function(){return _.K}),n.d(t,"removeFromArray",function(){return _.M}),n.d(t,"removeFromIndex",function(){return _.N}),n.d(t,"subtractFromArray",function(){return _.R}),n.d(t,"topLevelCompare",function(){return _.S}),n.d(t,"truncateHexString",function(){return _.T}),n.d(t,"uniqueArrayByKey",function(){return _.W}),n.d(t,"uniqCombineObjArrays",function(){return _.U}),n.d(t,"convertTimestampToMilliseconds",function(){return _.i}),n.d(t,"arraysEqual",function(){return _.e}),n.d(t,"isValidUrl",function(){return _.B}),n.d(t,"dateToLocalizedString",function(){return _.k}),n.d(t,"Uuid",function(){return I}),n.d(t,"EncryptionIntent",function(){return Re.b}),n.d(t,"isLocalStorageIntent",function(){return Re.f}),n.d(t,"isFileIntent",function(){return Re.e}),n.d(t,"isDecryptedIntent",function(){return Re.d}),n.d(t,"intentRequiresEncryption",function(){return Re.c}),n.d(t,"ContentTypeUsesRootKeyEncryption",function(){return Re.a}),n.d(t,"ContentType",function(){return F.a}),n.d(t,"displayStringForContentType",function(){return F.c}),n.d(t,"CreateItemFromPayload",function(){return nt}),n.d(t,"Uuids",function(){return Ke.b}),n.d(t,"FillItemContent",function(){return Ke.a}),n.d(t,"ApplicationEvent",function(){return At.a}),n.d(t,"Environment",function(){return he}),n.d(t,"Platform",function(){return fe}),n.d(t,"isEnvironmentWebOrDesktop",function(){return Se}),n.d(t,"isEnvironmentMobile",function(){return Pe}),n.d(t,"platformFromString",function(){return ke}),n.d(t,"environmentFromString",function(){return xe}),n.d(t,"SyncEvent",function(){return on.a}),n.d(t,"MutableCollection",function(){return mt}),n.d(t,"ImmutablePayloadCollection",function(){return bt}),n.d(t,"ItemCollection",function(){return gn}),n.d(t,"CollectionSort",function(){return dn}),n.d(t,"CreateMaxPayloadFromAnyObject",function(){return Ee.e}),n.d(t,"CreateSourcedPayloadFromObject",function(){return Ee.f}),n.d(t,"CreateIntentPayloadFromObject",function(){return Ee.d}),n.d(t,"CreateEncryptionParameters",function(){return Ee.c}),n.d(t,"PayloadByMerging",function(){return Ee.g}),n.d(t,"CopyPayload",function(){return Ee.b}),n.d(t,"PayloadSource",function(){return ht.a}),n.d(t,"isPayloadSourceRetrieved",function(){return ht.c}),n.d(t,"isPayloadSourceInternalChange",function(){return ht.b}),n.d(t,"DeltaOutOfSync",function(){return _t}),n.d(t,"ProtocolVersion",function(){return Q.a}),n.d(t,"PayloadFormat",function(){return ue.a}),n.d(t,"PurePayload",function(){return ft.a}),n.d(t,"PayloadField",function(){return Je.a}),n.d(t,"NotesDisplayCriteria",function(){return br}),n.d(t,"notesMatchingCriteria",function(){return wr}),n.d(t,"StorageKey",function(){return o}),n.d(t,"RawStorageKey",function(){return s}),n.d(t,"NonwrappedStorageKey",function(){return c}),n.d(t,"namespacedKey",function(){return O}),n.d(t,"BaseMigration",function(){return _n}),n.d(t,"ProtectionSessionDurations",function(){return ar}),n.d(t,"SNLog",function(){return we.a}),n.d(t,"Features",function(){return L.Features}),n.d(t,"FeatureIdentifier",function(){return L.FeatureIdentifier}),n.d(t,"RoleName",function(){return sr.RoleName}),n.d(t,"SettingName",function(){return pr.SettingName}),n.d(t,"Migration2_20_0",function(){return Pn}),n.d(t,"ApplicationStage",function(){return ve});var a={};n.r(a),n.d(a,"Migration2_0_0",function(){return kn}),n.d(a,"Migration2_0_15",function(){return xn}),n.d(a,"Migration2_7_0",function(){return Sn}),n.d(a,"Migration2_20_0",function(){return Pn});var i={};n.r(i),n.d(i,"StorageReader2_0_0",function(){return On}),n.d(i,"StorageReader1_0_0",function(){return vn});var s,o,c,h="2.20.3";function x(e,t){return-1===P(e,t)}function P(e,t){for(var n=e.split('.'),r=t.split('.'),a=0;a<r.length;a++){var i=Number(~~r[a]),s=Number(~~n[a]);if(i>s)return-1;if(i<s)return 1}return 0}function O(e,t){return e?"".concat(e,"-").concat(t):t}!(function(e){e.StorageObject="storage",e.DescriptorRecord="descriptors",e.SnjsVersion="snjs_version"})(s||(s={})),(function(e){e.RootKeyParams="ROOT_KEY_PARAMS",e.WrappedRootKey="WRAPPED_ROOT_KEY",e.RootKeyWrapperKeyParams="ROOT_KEY_WRAPPER_KEY_PARAMS",e.Session="session",e.User="user",e.ServerHost="server",e.LegacyUuid="uuid",e.LastSyncToken="syncToken",e.PaginationToken="cursorToken",e.BiometricsState="biometrics_state",e.MobilePasscodeTiming="passcode_timing",e.MobileBiometricsTiming="biometrics_timing",e.MobilePasscodeKeyboardType="passcodeKeyboardType",e.MobilePreferences="preferences",e.MobileScreenshotPrivacyEnabled="screenshotPrivacy_enabled",e.ProtectionExpirey="SessionExpiresAtKey",e.ProtectionSessionLength="SessionLengthKey",e.SessionHistoryPersistable="sessionHistory_persist",e.SessionHistoryRevisions="sessionHistory_revisions",e.SessionHistoryOptimize="sessionHistory_autoOptimize",e.KeyRecoveryUndecryptableItems="key_recovery_undecryptable",e.StorageEncryptionPolicy="storage_policy",e.WebSocketUrl="webSocket_url",e.UserRoles="user_roles",e.UserFeatures="user_features"})(o||(o={})),(function(e){e.MobileFirstRun="first_run"})(c||(c={}));var C,D={WebPasscodeParamsKey:'offlineParams',MobilePasscodeParamsKey:'pc_params',AllAccountKeyParamsKey:'auth_params',WebEncryptedStorageKey:'encryptedStorage',MobileWrappedRootKeyKey:'encrypted_account_keys',MobileBiometricsPrefs:'biometrics_prefs',AllMigrations:'migrations',MobileThemesCache:'ThemePreferencesKey',MobileLightTheme:'lightTheme',MobileDarkTheme:'darkTheme',MobileLastExportDate:'LastExportDateKey',MobileDoNotWarnUnsupportedEditors:'DoNotShowAgainUnsupportedEditorsKey',MobileOptionsState:'options',MobilePasscodeKeyboardType:'passcodeKeyboardType'},_=n(0);!(function(e){e[e.SignOut=1]="SignOut",e[e.Lock=2]="Lock",e[e.AppGroupUnload=3]="AppGroupUnload"})(C||(C={}));var E,R=n(10),I=(function(){function e(){v(this,e)}return y(e,null,[{key:"SetGenerators",value:function(e,t){this.syncUuidFunc=t,this.asyncUuidFunc=e}},{key:"canGenSync",value:function(){return!Object(_.w)(this.syncUuidFunc)}},{key:"GenerateUuid",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.syncUuidFunc){e.next=4;break}return e.abrupt("return",this.syncUuidFunc());case 4:return e.abrupt("return",this.asyncUuidFunc());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"GenerateUuidSynchronously",value:function(){return this.syncUuidFunc()}}]),e})(),M=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).deviceInterface=e,r.changeObservers=[],r.applications=[],r.onApplicationDeinit=function(e,t){var n=t!==C.AppGroupUnload;if(r.primaryApplication===e&&(r.primaryApplication=void 0),Object(_.M)(r.applications,e),t===C.SignOut){if(r.removeDescriptor(r.descriptorForApplication(e)),n){var a=r.getDescriptors();return 0===a.length?r.addNewApplication():r.loadApplicationForDescriptor(a[0])}}else if(t===C.Lock&&n){var i=r.descriptorForApplication(e);return r.loadApplicationForDescriptor(i)}},r}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.deviceInterface.deinit(),this.deviceInterface=void 0}},{key:"initialize",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.callback=e,r.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(s.DescriptorRecord));case 3:if(this.descriptorRecord=r.sent,this.descriptorRecord){r.next=7;break}return r.next=7,b.awrap(this.createDescriptorRecord());case 7:if(t=this.findPrimaryDescriptor()){r.next=10;break}throw Error('No primary application descriptor found. Ensure migrations have been run.');case 10:n=this.buildApplication(t),this.applications.push(n),this.setPrimaryApplication(n,!1);case 13:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createDescriptorRecord",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:t=g({},e='standardnotes',{identifier:e,label:'Main Application',primary:!0}),this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(t)),this.descriptorRecord=t,this.persistDescriptors();case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getApplications",value:function(){return this.applications}},{key:"getDescriptors",value:function(){return Object.values(this.descriptorRecord)}},{key:"findPrimaryDescriptor",value:function(){for(var e,t=S(this.getDescriptors());!(e=t()).done;){var n=e.value;if(n.primary)return n}}},{key:"addApplicationChangeObserver",value:function(e){var t=this;return this.changeObservers.push(e),this.primaryApplication&&e(),function(){Object(_.M)(t.changeObservers,e)}}},{key:"notifyObserversOfAppChange",value:function(){for(var e,t=S(this.changeObservers);!(e=t()).done;){(0,e.value)()}}},{key:"setPrimaryApplication",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=!(r.length>1&&void 0!==r[1])||r[1],this.primaryApplication!==e){a.next=3;break}return a.abrupt("return");case 3:if(this.applications.includes(e)){a.next=5;break}throw Error('Application must be inserted before attempting to switch to it');case 5:if(this.primaryApplication&&this.primaryApplication.deinit(C.AppGroupUnload),this.primaryApplication=e,n=this.descriptorForApplication(e),this.setDescriptorAsPrimary(n),this.notifyObserversOfAppChange(),!t){a.next=13;break}return a.next=13,b.awrap(this.persistDescriptors());case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setDescriptorAsPrimary",value:function(e){for(var t,n=S(this.getDescriptors());!(t=n()).done;){var r=t.value;r.primary=r===e}}},{key:"persistDescriptors",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(this.descriptorRecord));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"renameDescriptor",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e.label=t,n.next=3,b.awrap(this.persistDescriptors());case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"removeDescriptor",value:function(e){return delete this.descriptorRecord[e.identifier],this.persistDescriptors()}},{key:"descriptorForApplication",value:function(e){return this.descriptorRecord[e.identifier]}},{key:"addNewApplication",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(I.GenerateUuid());case 2:return t=i.sent,n=this.getDescriptors().length+1,r={identifier:t,label:e||"Application ".concat(n),primary:!1},a=this.buildApplication(r),this.applications.push(a),this.descriptorRecord[t]=r,i.next=10,b.awrap(this.setPrimaryApplication(a));case 10:return i.next=12,b.awrap(this.persistDescriptors());case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"applicationForDescriptor",value:function(e){return this.applications.find(function(t){return t.identifier===e.identifier})}},{key:"loadApplicationForDescriptor",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=this.applicationForDescriptor(e))||(t=this.buildApplication(e),this.applications.push(t)),n.next=4,b.awrap(this.setPrimaryApplication(t));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"buildApplication",value:function(e){var t=this.callback.applicationCreator(e,this.deviceInterface);return t.setOnDeinit(this.onApplicationDeinit),t}}]),n})(R.a),A=n(13),j=n(2),T=n(7),K=n(18),F=n(3),L=n(20);!(function(e){e.SetSize="set-size",e.StreamItems="stream-items",e.StreamContextItem="stream-context-item",e.SaveItems="save-items",e.SelectItem="select-item",e.AssociateItem="associate-item",e.DeassociateItem="deassociate-item",e.ClearSelection="clear-selection",e.CreateItem="create-item",e.CreateItems="create-items",e.DeleteItems="delete-items",e.SetComponentData="set-component-data",e.InstallLocalComponent="install-local-component",e.ToggleActivateComponent="toggle-activate-component",e.RequestPermissions="request-permissions",e.PresentConflictResolution="present-conflict-resolution",e.DuplicateItem="duplicate-item",e.ComponentRegistered="component-registered",e.ActivateThemes="themes",e.Reply="reply",e.SaveSuccess="save-success",e.SaveError="save-error",e.ThemesActivated="themes-activated",e.KeyDown="key-down",e.KeyUp="key-up",e.Click="click"})(E||(E={}));var U,N=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).permissions=[],r.componentData=r.payload.safeContent.componentData||{},Object(_.B)(r.payload.safeContent.hosted_url)?r.hosted_url=r.payload.safeContent.hosted_url:Object(_.B)(r.payload.safeContent.url)?r.hosted_url=r.payload.safeContent.url:Object(_.B)(r.payload.safeContent.legacy_url)&&(r.hosted_url=r.payload.safeContent.legacy_url),r.local_url=r.payload.safeContent.local_url,r.valid_until=new Date(r.payload.safeContent.valid_until||0),r.offlineOnly=r.payload.safeContent.offlineOnly,r.name=r.payload.safeContent.name,r.area=r.payload.safeContent.area,r.package_info=r.payload.safeContent.package_info||{},r.permissions=r.payload.safeContent.permissions||[],r.active=r.payload.safeContent.active,r.autoupdateDisabled=r.payload.safeContent.autoupdateDisabled,r.disassociatedItemIds=r.payload.safeContent.disassociatedItemIds||[],r.associatedItemIds=r.payload.safeContent.associatedItemIds||[],r.isMobileDefault=r.payload.safeContent.isMobileDefault,r.legacy_url=r.payload.safeContent.hosted_url?void 0:r.payload.safeContent.url,r}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"isEditor",value:function(){return this.area===L.ComponentArea.Editor}},{key:"isTheme",value:function(){return this.content_type===F.a.Theme||this.area===L.ComponentArea.Themes}},{key:"isDefaultEditor",value:function(){return!0===this.getAppDomainValue(T.a.DefaultEditor)}},{key:"getLastSize",value:function(){return this.getAppDomainValue(T.a.LastSize)}},{key:"acceptsThemes",value:function(){var e;return null===(e=this.payload.safeContent.package_info)||void 0===e?void 0:e.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return void 0!=(this.hosted_url||this.legacy_url)}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['active','disassociatedItemIds','associatedItemIds'].concat(p(f(n.prototype),"contentKeysToIgnoreWhenCheckingEquality",this).call(this))}},{key:"isAssociative",value:function(){return n.associativeAreas().includes(this.area)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e)}},{key:"isExpired",get:function(){return this.valid_until.getTime()>0&&this.valid_until<=new Date}},{key:"identifier",get:function(){return this.package_info.identifier}},{key:"isDeprecated",get:function(){var e,t=null!==(e=this.package_info.flags)&&void 0!==e?e:[];return(t=t.map(function(e){return e.toLowerCase()})).includes(L.ComponentFlag.Deprecated)}}],[{key:"associativeAreas",value:function(){return[L.ComponentArea.Editor]}}]),n})(T.d),V=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"associateWithItem",value:function(e){var t=this.typedContent.associatedItemIds||[];Object(_.b)(t,e),this.typedContent.associatedItemIds=t}},{key:"disassociateWithItem",value:function(e){var t=this.typedContent.disassociatedItemIds||[];Object(_.b)(t,e),this.typedContent.disassociatedItemIds=t}},{key:"removeAssociatedItemId",value:function(e){Object(_.M)(this.typedContent.associatedItemIds||[],e)}},{key:"removeDisassociatedItemId",value:function(e){Object(_.M)(this.typedContent.disassociatedItemIds||[],e)}},{key:"setLastSize",value:function(e){this.setAppDataItem(T.a.LastSize,e)}},{key:"typedContent",get:function(){return this.content}},{key:"active",set:function(e){this.typedContent.active=e}},{key:"isMobileDefault",set:function(e){this.typedContent.isMobileDefault=e}},{key:"defaultEditor",set:function(e){this.setAppDataItem(T.a.DefaultEditor,e)}},{key:"componentData",set:function(e){this.typedContent.componentData=e}},{key:"package_info",set:function(e){this.typedContent.package_info=e}},{key:"local_url",set:function(e){this.typedContent.local_url=e}},{key:"hosted_url",set:function(e){this.typedContent.hosted_url=e}},{key:"valid_until",set:function(e){this.typedContent.valid_until=e}},{key:"permissions",set:function(e){this.typedContent.permissions=e}}]),n})(T.b),B=(function(e){d(n,N);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).area=L.ComponentArea.Themes,e}return y(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"getMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDomainValue(T.a.NotAvailableOnMobile)}},{key:"isMobileActive",value:function(){return this.getAppDomainValue(T.a.MobileActive)}}]),n})(),W=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setMobileRules",value:function(e){this.setAppDataItem(T.a.MobileRules,e)}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem(T.a.NotAvailableOnMobile,e)}},{key:"setMobileActive",value:function(e){this.setAppDataItem(T.a.MobileActive,e)}},{key:"local_url",set:function(e){this.content.local_url=e}}]),n})(T.b),H=n(21);!(function(e){e.TagsPanelWidth="tagsPanelWidth",e.NotesPanelWidth="notesPanelWidth",e.EditorWidth="editorWidth",e.EditorLeft="editorLeft",e.EditorMonospaceEnabled="monospaceFont",e.EditorSpellcheck="spellcheck",e.EditorResizersEnabled="marginResizersEnabled",e.SortNotesBy="sortBy",e.SortNotesReverse="sortReverse",e.NotesShowArchived="showArchived",e.NotesShowTrashed="showTrashed",e.NotesHideProtected="hideProtected",e.NotesHidePinned="hidePinned",e.NotesHideNotePreview="hideNotePreview",e.NotesHideDate="hideDate",e.NotesHideTags="hideTags"})(U||(U={}));var z=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getPref",value:function(e){return this.getAppDomainValue(e)}},{key:"isSingleton",get:function(){return!0}},{key:"singletonPredicate",get:function(){return n.singletonPredicate}}]),n})(T.d);z.singletonPredicate=new H.a('content_type','=',F.a.UserPrefs);var q,Y,G=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setPref",value:function(e,t){this.setAppDataItem(e,t)}}]),n})(T.b),Q=n(6),J=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"keyVersion",get:function(){return this.payload.safeContent.version}},{key:"isItemsKey",get:function(){return!0}},{key:"isDefault",get:function(){return this.payload.safeContent.isDefault}},{key:"itemsKey",get:function(){return this.payload.safeContent.itemsKey}},{key:"dataAuthenticationKey",get:function(){if(this.keyVersion===Q.a.V004)throw'Attempting to access legacy data authentication key.';return this.payload.safeContent.dataAuthenticationKey}}]),n})(T.d),$=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"isDefault",set:function(e){this.content.isDefault=e}}]),n})(T.b),X=n(47),Z=n.n(X);!(function(e){e.Encrypted="encrypted",e.Decrypted="decrypted"})(q||(q={})),(function(e){e.Get="get",e.Render="render",e.Show="show",e.Post="post",e.Nested="nested"})(Y||(Y={}));var ee=Number.MIN_SAFE_INTEGER;var te,ne,re,ae=function e(t){var n,r,a;v(this,e),this.id=((ee+=1)===Number.MAX_SAFE_INTEGER&&(ee=Number.MIN_SAFE_INTEGER),ee),Z()(this,t),this.running=null!==(n=t.running)&&void 0!==n&&n,this.error=null!==(r=t.error)&&void 0!==r&&r,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted)),this.subactions=null===(a=t.subactions)||void 0===a?void 0:a.map(function(t){return new e(t)})},ie=(function(e){d(n,N);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).actions=[],r.description=e.safeContent.description,r.url=e.safeContent.hosted_url||e.safeContent.url,r.supported_types=e.safeContent.supported_types,r.deprecation=e.safeContent.deprecation,e.safeContent.actions&&(r.actions=e.safeContent.actions.map(function(e){return new ae(e)})),r}return y(n,[{key:"actionsWithContextForItem",value:function(e){return this.actions.filter(function(t){return t.context===e.content_type||'Item'===t.context})}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}}]),n})(),se=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"description",set:function(e){this.content.description=e}},{key:"supported_types",set:function(e){this.content.supported_types=e}},{key:"actions",set:function(e){this.content.actions=e}},{key:"deprecation",set:function(e){this.content.deprecation=e}}]),n})(T.b),oe=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).title=r.payload.safeContent.title,r}return y(n,[{key:"noteReferences",get:function(){return this.payload.safeReferences.filter(function(e){return e.content_type===F.a.Note})}},{key:"noteCount",get:function(){return this.noteReferences.length}},{key:"isSmartTag",get:function(){return this.content_type===F.a.SmartTag}},{key:"isSystemSmartTag",get:function(){return this.payload.safeContent.isSystemTag}},{key:"isAllTag",get:function(){return this.payload.safeContent.isAllTag}},{key:"isTrashTag",get:function(){return this.payload.safeContent.isTrashTag}},{key:"isArchiveTag",get:function(){return this.payload.safeContent.isArchiveTag}},{key:"parentId",get:function(){var e=this.payload.safeContent.references.find(function(e){return e.content_type===F.a.Tag});return null===e||void 0===e?void 0:e.uuid}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title?1:-1}).map(function(e){return'#'+e.title}).join(' ')}}]),n})(T.d),ce=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"makeChildOf",value:function(e){var t=this.typedContent.references.filter(function(e){return e.content_type!==F.a.Tag});t.push({content_type:F.a.Tag,uuid:e.uuid}),this.typedContent.references=t}},{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}}]),n})(T.b),ue=n(12),le=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).text='',r.hidePreview=!1,r.title=r.payload.safeContent.title,r.text=r.payload.safeContent.text,r.preview_plain=r.payload.safeContent.preview_plain,r.preview_html=r.payload.safeContent.preview_html,r.hidePreview=r.payload.safeContent.hidePreview,e.format===ue.a.DecryptedBareObject&&(r.prefersPlainEditor=r.getAppDomainValue(T.a.PrefersPlainEditor)),Object(_.w)(r.payload.safeContent.mobilePrefersPlainEditor)||(r.mobilePrefersPlainEditor=r.payload.safeContent.mobilePrefersPlainEditor),r}return y(n,[{key:"safeText",value:function(){return this.text||''}},{key:"safeTitle",value:function(){return this.title||''}}]),n})(T.d),pe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}},{key:"text",set:function(e){this.typedContent.text=e}},{key:"hidePreview",set:function(e){this.typedContent.hidePreview=e}},{key:"preview_plain",set:function(e){this.typedContent.preview_plain=e}},{key:"preview_html",set:function(e){this.typedContent.preview_html=e}},{key:"prefersPlainEditor",set:function(e){this.setAppDataItem(T.a.PrefersPlainEditor,e)}}]),n})(T.b);function de(e,t){switch(e.content_type){case F.a.Note:return new pe(e,t);case F.a.Tag:return new ce(e,t);case F.a.Component:return new V(e,t);case F.a.ActionsExtension:return new se(e,t);case F.a.ItemsKey:return new $(e,t);case F.a.UserPrefs:return new G(e,t);case F.a.Theme:return new W(e,t);default:return new T.b(e,t)}}!(function(e){e[e.None=0]="None",e[e.LocalPasscode=1]="LocalPasscode",e[e.AccountPassword=2]="AccountPassword",e[e.Biometric=3]="Biometric",e[e.ProtectionSessionDuration=4]="ProtectionSessionDuration"})(te||(te={})),(function(e){e[e.ApplicationUnlock=1]="ApplicationUnlock",e[e.ResaveRootKey=2]="ResaveRootKey",e[e.ProtocolUpgrade=3]="ProtocolUpgrade",e[e.Migration=4]="Migration",e[e.Custom=5]="Custom",e[e.AccessProtectedNote=6]="AccessProtectedNote",e[e.ImportFile=7]="ImportFile",e[e.AddPasscode=8]="AddPasscode",e[e.RemovePasscode=9]="RemovePasscode",e[e.ChangePasscode=10]="ChangePasscode",e[e.ChangeAutolockInterval=11]="ChangeAutolockInterval",e[e.CreateDecryptedBackupWithProtectedItems=12]="CreateDecryptedBackupWithProtectedItems",e[e.RevokeSession=13]="RevokeSession",e[e.AccessCloudLink=14]="AccessCloudLink",e[e.DecryptEncryptedFile=15]="DecryptEncryptedFile",e[e.ExportBackup=16]="ExportBackup",e[e.DisableBiometrics=17]="DisableBiometrics",e[e.UnprotectNote=18]="UnprotectNote",e[e.SearchProtectedNotesText=19]="SearchProtectedNotesText",e[e.SelectProtectedNote=20]="SelectProtectedNote",e[e.DisableMfa=21]="DisableMfa"})(ne||(ne={})),(function(e){e.Alphanumeric="default",e.Numeric="numeric"})(re||(re={}));var he,fe,ve,ye=(function(){function e(t,n,r,a,i){v(this,e),this.prompts=t,this.reason=n,this.cancelable=r,this._heading=a,this._subheading=i,this.id=Math.random(),Object.freeze(this)}return y(e,[{key:"hasPromptForValidationType",value:function(e){for(var t,n=S(this.prompts);!(t=n()).done;){if(t.value.validation===e)return!0}return!1}},{key:"modalTitle",get:function(){switch(this.reason){case ne.Migration:return j.w.Migration;default:return j.w.Generic}}},{key:"heading",get:function(){if(this._heading)return this._heading;switch(this.reason){case ne.ApplicationUnlock:return j.x.UnlockApplication;case ne.Migration:return j.x.EnterLocalPasscode;case ne.ResaveRootKey:return j.x.EnterPasscodeForRootResave;case ne.ProtocolUpgrade:return j.x.EnterCredentialsForProtocolUpgrade;case ne.AccessProtectedNote:return j.x.NoteAccess;case ne.ImportFile:return j.x.ImportFile;case ne.AddPasscode:return j.x.AddPasscode;case ne.RemovePasscode:return j.x.RemovePasscode;case ne.ChangePasscode:return j.x.ChangePasscode;case ne.ChangeAutolockInterval:return j.x.ChangeAutolockInterval;case ne.CreateDecryptedBackupWithProtectedItems:return j.x.EnterCredentialsForDecryptedBackupDownload;case ne.RevokeSession:return j.x.RevokeSession;case ne.AccessCloudLink:return j.x.AccessCloudLink;case ne.DecryptEncryptedFile:return j.x.DecryptEncryptedFile;case ne.ExportBackup:return j.x.ExportBackup;case ne.DisableBiometrics:return j.x.DisableBiometrics;case ne.UnprotectNote:return j.x.UnprotectNote;case ne.SearchProtectedNotesText:return j.x.SearchProtectedNotesText;case ne.SelectProtectedNote:return j.x.SelectProtectedNote;case ne.DisableMfa:return j.x.DisableMfa;case ne.Custom:return'';default:return Object(_.f)(this.reason)}}},{key:"subheading",get:function(){if(this._subheading)return this._subheading;switch(this.reason){case ne.Migration:return j.x.EnterPasscodeForMigration;default:return}}}]),e})(),ge=function e(t,n,r){v(this,e);var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;switch(this.validation=t,this.secureTextEntry=a,this.keyboardType=i,this.initialValue=s,this.id=Math.random(),this.validation){case te.AccountPassword:this.title=null!==n&&void 0!==n?n:j.M.AccountPassword,this.placeholder=null!==r&&void 0!==r?r:j.M.AccountPassword,this.validates=!0;break;case te.LocalPasscode:this.title=null!==n&&void 0!==n?n:j.M.LocalPasscode,this.placeholder=null!==r&&void 0!==r?r:j.M.LocalPasscode,this.validates=!0;break;case te.Biometric:this.title=null!==n&&void 0!==n?n:j.M.Biometrics,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.ProtectionSessionDuration:this.title=null!==n&&void 0!==n?n:j.M.RememberFor,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.None:this.title=null!==n&&void 0!==n?n:'',this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!1;break;default:Object(_.f)(this.validation)}Object.freeze(this)},me=function e(t,n){v(this,e),this.prompt=t,this.value=n,Object.freeze(this)},be=(function(){function e(t,n,r){v(this,e),this.challenge=t,this.values=n,this.artifacts=r,Object.freeze(this)}return y(e,[{key:"getValueForType",value:function(e){var t=this.values.find(function(t){return t.prompt.validation===e});if(Object(_.w)(t))throw Error('Could not find value for validation type '+e);return t}},{key:"getDefaultValue",value:function(){if(this.values.length>1)throw Error('Attempting to retrieve default response value when more than one value exists');return this.values[0]}}]),e})(),we=n(16);function ke(e){return{'mac-web':fe.MacWeb,'mac-desktop':fe.MacDesktop,'linux-web':fe.LinuxWeb,'linux-desktop':fe.LinuxDesktop,'windows-web':fe.WindowsWeb,'windows-desktop':fe.WindowsDesktop,ios:fe.Ios,android:fe.Android}[e]}function xe(e){return{web:he.Web,desktop:he.Desktop,mobile:he.Mobile}[e]}function Se(e){return e===he.Web||e===he.Desktop}function Pe(e){return e===he.Mobile}!(function(e){e[e.Web=1]="Web",e[e.Desktop=2]="Desktop",e[e.Mobile=3]="Mobile"})(he||(he={})),(function(e){e[e.Ios=1]="Ios",e[e.Android=2]="Android",e[e.MacWeb=3]="MacWeb",e[e.MacDesktop=4]="MacDesktop",e[e.WindowsWeb=5]="WindowsWeb",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.LinuxWeb=7]="LinuxWeb",e[e.LinuxDesktop=8]="LinuxDesktop"})(fe||(fe={})),(function(e){e[e.PreparingForLaunch_0=0]="PreparingForLaunch_0",e[e.ReadyForLaunch_05=.5]="ReadyForLaunch_05",e[e.StorageDecrypted_09=.9]="StorageDecrypted_09",e[e.Launched_10=1]="Launched_10",e[e.LoadingDatabase_11=1.1]="LoadingDatabase_11",e[e.LoadedDatabase_12=1.2]="LoadedDatabase_12",e[e.FullSyncCompleted_13=1.3]="FullSyncCompleted_13",e[e.SignedIn_30=3]="SignedIn_30"})(ve||(ve={}));var Oe,Ce,De,_e,Ee=n(1),Re=n(8);!(function(e){e[e.Default=1]="Default",e[e.Ephemeral=2]="Ephemeral"})(Oe||(Oe={})),(function(e){e[e.Default=1]="Default",e[e.Disabled=2]="Disabled"})(Ce||(Ce={})),(function(e){e[e.Default=1]="Default",e[e.Nonwrapped=2]="Nonwrapped"})(De||(De={})),(function(e){e.Wrapped="wrapped",e.Unwrapped="unwrapped",e.Nonwrapped="nonwrapped"})(_e||(_e={}));var Ie=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).alertService=r,s.identifier=a,s.environment=i,s.storagePersistable=!1,s.needsPersist=!1,s.deviceInterface=e,s.setPersistencePolicy(Oe.Default),s.setEncryptionPolicy(Ce.Default,!1),s}return y(n,[{key:"deinit",value:function(){this.deviceInterface=void 0,this.encryptionDelegate=void 0,this.storagePersistable=!1,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:if(e!==ve.Launched_10){r.next=7;break}this.storagePersistable=!0,this.needsPersist&&this.persistValuesToDisk(),r.next=12;break;case 7:if(e!==ve.StorageDecrypted_09){r.next=12;break}return r.next=10,b.awrap(this.getValue(o.StorageEncryptionPolicy));case 10:(t=r.sent)&&this.setEncryptionPolicy(t,!1);case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setPersistencePolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.persistencePolicy=e,this.persistencePolicy!==Oe.Ephemeral){t.next=6;break}return t.next=4,b.awrap(this.deviceInterface.removeAllRawStorageValues());case 4:return t.next=6,b.awrap(this.clearAllPayloads());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setEncryptionPolicy",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],e!==Ce.Disabled||this.environment===he.Mobile){r.next=3;break}throw Error('Disabling storage encryption is only available on mobile.');case 3:if(this.encryptionPolicy=e,!t){r.next=7;break}return r.next=7,b.awrap(this.setValue(o.StorageEncryptionPolicy,e));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.persistencePolicy===Oe.Ephemeral}},{key:"initializeFromDisk",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getRawStorageValue(this.getPersistenceKey()));case 2:e=n.sent,t=e?JSON.parse(e):void 0,this.setInitialValues(t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){e||(e=this.defaultValuesObject()),e[_e.Unwrapped]||(e[_e.Unwrapped]={}),this.values=e}},{key:"isStorageWrapped",value:function(){var e=this.values[_e.Wrapped];return!Object(_.w)(e)&&Object.keys(e).length>0}},{key:"canDecryptWithKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.values[_e.Wrapped],r.next=3,b.awrap(this.decryptWrappedValue(t,e));case 3:return n=r.sent,r.abrupt("return",!n.errorDecrypting);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"decryptWrappedValue",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!==e&&void 0!==e&&e.content_type){a.next=2;break}throw Error('Attempting to decrypt nonexistent wrapped value');case 2:return n=Object(Ee.e)(e,{content_type:F.a.EncryptedStorage}),a.next=5,b.awrap(this.encryptionDelegate.payloadByDecryptingPayload(n,t));case 5:return r=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptStorage",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.values[_e.Wrapped],n.next=3,b.awrap(this.decryptWrappedValue(e));case 3:if(!(t=n.sent).errorDecrypting){n.next=6;break}throw we.a.error(Error('Unable to decrypt storage.'));case 6:this.values[_e.Unwrapped]=Object(_.a)(t.contentObject);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistValuesToDisk",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.storagePersistable){t.next=3;break}return this.needsPersist=!0,t.abrupt("return");case 3:if(this.persistencePolicy!==Oe.Ephemeral){t.next=5;break}return t.abrupt("return");case 5:return this.needsPersist=!1,t.next=8,b.awrap(this.immediatelyPersistValuesToDisk());case 8:e=t.sent,this.values[_e.Wrapped]=e[_e.Wrapped];case 10:case"end":return t.stop()}},null,this,null,Promise)}},{key:"immediatelyPersistValuesToDisk",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(e.generatePersistableValues());case 2:return n=r.sent,r.next=5,b.awrap(null===(t=e.deviceInterface)||void 0===t?void 0:t.setRawStorageValue(e.getPersistenceKey(),JSON.stringify(n)));case 5:return r.abrupt("return",n);case 6:case"end":return r.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generatePersistableValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=w({},this.values),n=t[_e.Unwrapped],i.t0=Object(Ee.e),i.next=5,b.awrap(I.GenerateUuid());case 5:return i.t1=i.sent,i.t2=n,i.t3=F.a.EncryptedStorage,i.t4={uuid:i.t1,content:i.t2,content_type:i.t3},r=(0,i.t0)(i.t4),i.next=12,b.awrap(null===(e=this.encryptionDelegate)||void 0===e?void 0:e.payloadByEncryptingPayload(r,Re.b.LocalStoragePreferEncrypted));case 12:return(a=i.sent)&&(t[_e.Wrapped]=a.ejected(),t[_e.Unwrapped]=void 0),i.abrupt("return",t);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=r.length>2&&void 0!==r[2]?r[2]:De.Default,this.values){a.next=3;break}throw Error("Attempting to set storage key ".concat(e," before loading local storage."));case 3:return this.values[this.domainKeyForMode(n)][e]=t,a.abrupt("return",this.persistValuesToDisk());case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De.Default,n=arguments.length>2?arguments[2]:void 0;if(!this.values)throw Error("Attempting to get storage key ".concat(e," before loading local storage."));if(!this.values[this.domainKeyForMode(t)])throw Error("Storage domain mode not available ".concat(t," for key ").concat(e));var r=this.values[this.domainKeyForMode(t)][e];return Object(_.w)(r)?n:r}},{key:"removeValue",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:De.Default,this.values){a.next=3;break}throw Error("Attempting to remove storage key ".concat(e," before loading local storage."));case 3:if(null===(n=this.values[this.domainKeyForMode(t)])||void 0===n||!n[e]){a.next=7;break}return delete n[e],a.abrupt("return",this.persistValuesToDisk());case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.encryptionPolicy}},{key:"getPersistenceKey",value:function(){return O(this.identifier,s.StorageObject)}},{key:"defaultValuesObject",value:function(e,t,r){return n.defaultValuesObject(e,t,r)}},{key:"domainKeyForMode",value:function(e){if(e===De.Default)return _e.Unwrapped;if(e===De.Nonwrapped)return _e.Nonwrapped;throw Error('Invalid mode')}},{key:"clearValues",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,b.awrap(this.immediatelyPersistValuesToDisk());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAllRawPayloads",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads(this.identifier));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"savePayload",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.savePayloads([e]));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"savePayloads",value:function(e){var t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.persistencePolicy!==Oe.Ephemeral){o.next=2;break}return o.abrupt("return");case 2:t=[],n=S(e);case 4:if((r=n()).done){o.next=19;break}if(!(a=r.value).discardable){o.next=11;break}return o.next=9,b.awrap(this.deletePayloadWithId(a.uuid));case 9:o.next=17;break;case 11:if(a.uuid){o.next=13;break}throw Error('Attempting to persist payload with no uuid');case 13:return o.next=15,b.awrap(this.encryptionDelegate.payloadByEncryptingPayload(a,this.encryptionPolicy===Ce.Default?Re.b.LocalStoragePreferEncrypted:Re.b.LocalStorageDecrypted));case 15:i=o.sent,t.push(i.ejected());case 17:o.next=4;break;case 19:return o.abrupt("return",this.executeCriticalFunction(function(){var e;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null===(e=s.deviceInterface)||void 0===e?void 0:e.saveRawDatabasePayloads(t,s.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 20:case"end":return o.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(e);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(this.deletePayloadWithId(r.uuid));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deletePayloadWithId",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.deviceInterface.removeRawDatabasePayloadWithId(e,t.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"clearAllPayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.deviceInterface.removeAllRawDatabasePayloads(e.identifier));case 1:case"end":return t.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"clearAllData",value:function(){var e=this;return this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.clearValues());case 2:return t.next=4,b.awrap(e.clearAllPayloads());case 4:return t.next=6,b.awrap(e.deviceInterface.removeRawStorageValue(O(e.identifier,s.SnjsVersion)));case 6:return t.next=8,b.awrap(e.deviceInterface.removeRawStorageValue(e.getPersistenceKey()));case 8:case"end":return t.stop()}},null,null,null,Promise)})}}],[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return g(e={},_e.Wrapped,t),g(e,_e.Unwrapped,n),g(e,_e.Nonwrapped,r),e}}]),n})(R.a),Me=(function(){function e(){v(this,e)}return y(e,null,[{key:"FromRawStorageValue",value:function(e){if(e.jwt)return new Ae(e.jwt);var t=e;return new je(t.accessToken,t.accessExpiration,t.refreshToken,t.refreshExpiration)}}]),e})(),Ae=(function(e){d(n,Me);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).jwt=e,r}return y(n,[{key:"canExpire",value:function(){return!1}},{key:"authorizationValue",get:function(){return this.jwt}}]),n})(),je=(function(e){d(n,Me);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).accessToken=e,s.accessExpiration=r,s.refreshToken=a,s.refreshExpiration=i,s}return y(n,[{key:"getExpireAt",value:function(){return this.accessExpiration||0}},{key:"canExpire",value:function(){return!0}},{key:"isExpired",value:function(){return this.getExpireAt()<Date.now()}},{key:"authorizationValue",get:function(){return this.accessToken}}],[{key:"FromApiResponse",value:function(e){var t=e.data.session.access_token,r=e.data.session.refresh_token;return new n(t,e.data.session.access_expiration,r,e.data.session.refresh_expiration)}}]),n})(),Te=n(15),Ke=n(11),Fe=n(67);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this,e)).keyParams=r,a}return y(n,[{key:"compare",value:function(e){if(this.keyVersion!==e.keyVersion)return!1;var t=!(!this.serverPassword||!e.serverPassword);return Object(Fe.timingSafeEqual)(this.masterKey,e.masterKey)&&(!t||Object(Fe.timingSafeEqual)(this.serverPassword,e.serverPassword))}},{key:"persistableValueWhenWrapping",value:function(){var e=this.getKeychainValue();return e.keyParams=this.keyParams.getPortableValue(),e}},{key:"getKeychainValue",value:function(){var e={version:this.keyVersion};return this.masterKey&&(e.masterKey=this.masterKey),this.dataAuthenticationKey&&(e.dataAuthenticationKey=this.dataAuthenticationKey),e}},{key:"typedContent",get:function(){return this.safeContent}},{key:"keyVersion",get:function(){if(!this.payload.safeContent.version)throw'Attempting to create key without version.';return this.payload.safeContent.version}},{key:"isRootKey",get:function(){return!0}},{key:"itemsKey",get:function(){return this.masterKey}},{key:"masterKey",get:function(){return this.payload.safeContent.masterKey}},{key:"serverPassword",get:function(){return this.payload.safeContent.serverPassword}},{key:"dataAuthenticationKey",get:function(){return this.payload.safeContent.dataAuthenticationKey}}],[{key:"Create",value:function(e,t){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t){s.next=4;break}return s.next=3,b.awrap(I.GenerateUuid());case 3:t=s.sent;case 4:if(e.version||(e.dataAuthenticationKey?e.version=Q.a.V002:e.version=Q.a.V001),r=Object(Ee.e)({uuid:t,content_type:F.a.RootKey,content:Object(Ke.a)(e)}),a=e.keyParams){s.next=9;break}throw Error('Attempting to create root key without key params');case 9:return i=a instanceof A.h?a:new A.h(a),s.abrupt("return",new n(r,i));case 11:case"end":return s.stop()}},null,null,null,Promise)}},{key:"ExpandedCopy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=e.typedContent,a.next=3,b.awrap(this.Create(Ue(Ue({},n),{},{keyParams:t||n.keyParams})));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(T.d);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){He(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ze,qe=function(e){return e.trim().toLowerCase()};!(function(e){e.Restored="SessionRestored",e.Revoked="SessionRevoked"})(ze||(ze={}));var Ye,Ge=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).storageService=e,c.apiService=r,c.alertService=a,c.protocolService=i,c.challengeService=s,c.webSocketsService=o,c.isSessionRenewChallengePresented=!1,r.setInvalidSessionObserver(function(e){e?c.notifyEvent(ze.Revoked):c.reauthenticateInvalidSession()}),c}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.alertService=void 0,this.challengeService=void 0,this.webSocketsService=void 0,this.user=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.storageService.getValue(o.User));case 2:if(this.user=r.sent,this.user){r.next=8;break}return r.next=6,b.awrap(this.storageService.getValue(o.LegacyUuid));case 6:(e=r.sent)&&(this.user={uuid:e,email:e});case 8:return r.next=10,b.awrap(this.storageService.getValue(o.Session));case 10:if(!(t=r.sent)){r.next=16;break}return n=Me.FromRawStorageValue(t),r.next=15,b.awrap(this.setSession(n,!1));case 15:this.webSocketsService.startWebSocketConnection(n.authorizationValue);case 16:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=!(n.length>1&&void 0!==n[1])||n[1],r.next=3,b.awrap(this.apiService.setSession(e,t));case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"online",value:function(){return!this.offline()}},{key:"offline",value:function(){return Object(_.w)(this.apiService.getSession())}},{key:"getUser",value:function(){return this.user}},{key:"getSession",value:function(){return this.apiService.getSession()}},{key:"signOut",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.user=void 0,!(e=this.apiService.getSession())||!e.canExpire()){t.next=6;break}return t.next=5,b.awrap(this.apiService.signOut());case 5:this.webSocketsService.closeWebSocketConnection();case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isSignedIn",value:function(){return void 0!=this.getUser()}},{key:"isSignedIntoFirstPartyServer",value:function(){return this.isSignedIn()&&!this.apiService.isThirdPartyHostUsed()}},{key:"reauthenticateInvalidSession",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=!(i.length>0&&void 0!==i[0])||i[0],n=i.length>1?i[1]:void 0,!this.isSessionRenewChallengePresented){s.next=4;break}return s.abrupt("return");case 4:return this.isSessionRenewChallengePresented=!0,r=new ye([new ge(te.None,void 0,j.R.EmailInputPlaceholder,!1),new ge(te.None,void 0,j.R.PasswordInputPlaceholder)],ne.Custom,t,j.R.EnterEmailAndPassword,j.R.RecoverSession(null===(e=this.getUser())||void 0===e?void 0:e.email)),s.abrupt("return",new Promise(function(e){a.challengeService.addChallengeObserver(r,{onCancel:function(){a.isSessionRenewChallengePresented=!1},onComplete:function(){a.isSessionRenewChallengePresented=!1},onNonvalidatedSubmit:function(t){var i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=t.values[0].value,s=t.values[1].value,u.next=4,b.awrap(a.protocolService.getAccountKeyParams());case 4:return o=u.sent,u.next=7,b.awrap(a.signIn(i,s,!1,a.storageService.isEphemeralSession(),null===o||void 0===o?void 0:o.version));case 7:(c=u.sent).response.error?(a.challengeService.setValidationStatusForChallenge(r,t.values[1],!1),null===n||void 0===n||n(c.response)):(e(),a.challengeService.completeChallenge(r),a.notifyEvent(ze.Restored),a.alertService.alert(j.R.SessionRestored));case 9:case"end":return u.stop()}},null,null,null,Promise)}}),a.challengeService.promptForChallengeResponse(r)}));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSubscription",value:function(){return this.apiService.getSubscription(this.user.uuid)}},{key:"promptForMfaValue",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=new ye([new ge(te.None,j.M.Mfa,j.R.MfaInputPlaceholder,!1,re.Numeric)],ne.Custom,!0,j.R.EnterMfa),n.next=3,b.awrap(this.challengeService.promptForChallengeResponse(e));case 3:if(!(t=n.sent)){n.next=7;break}return this.challengeService.completeChallenge(e),n.abrupt("return",t.values[0].value);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"register",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(t.length<8)){u.next=2;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.G(8))});case 2:return u.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(r=u.sent,a=r.wrappingKey,!r.canceled){u.next=9;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.P.PasscodeRequired,Te.b.LocalValidationError)});case 9:return e=qe(e),u.next=12,b.awrap(this.protocolService.createRootKey(e,t,A.g.Registration));case 12:return i=u.sent,s=i.serverPassword,o=i.keyParams,u.next=17,b.awrap(this.apiService.register(e,s,o,n));case 17:if((c=u.sent).error||!c.data){u.next=21;break}return u.next=21,b.awrap(this.handleSuccessAuthResponse(c,i,a));case 21:return u.abrupt("return",{response:c,rootKey:i});case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"retrieveKeyParams",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.apiService.getAccountKeyParams(e,t,n));case 2:if(!(r=c.sent).error&&!Object(_.w)(r.data)){c.next=17;break}if(!n){c.next=7;break}return c.next=7,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 7:if(null===(a=r.error)||void 0===a||null===(i=a.payload)||void 0===i||!i.mfa_key){c.next=16;break}return c.next=10,b.awrap(this.promptForMfaValue());case 10:if(s=c.sent){c.next=13;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa)});case 13:return c.abrupt("return",this.retrieveKeyParams(e,r.error.payload.mfa_key,s));case 16:return c.abrupt("return",{response:r});case 17:if((o=Object(A.f)(r,e))&&o.version){c.next=20;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 20:return c.abrupt("return",{keyParams:o,response:r,mfaKeyPath:t,mfaCode:n});case 21:case"end":return c.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=o.length>2&&void 0!==o[2]&&o[2],r=o.length>3&&void 0!==o[3]&&o[3],a=o.length>4?o[4]:void 0,c.next=5,b.awrap(this.performSignIn(e,t,n,r,a));case 5:if(!(i=c.sent).response.error||i.response.error.status===Te.b.LocalValidationError||i.response.error.status===Te.b.CanceledMfa){c.next=15;break}if((s=qe(e))===e){c.next=12;break}return c.abrupt("return",this.performSignIn(s,t,n,r,a));case 12:return c.abrupt("return",i);case 13:c.next=16;break;case 15:return c.abrupt("return",i);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"performSignIn",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=arguments;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return n=p.length>2&&void 0!==p[2]&&p[2],r=p.length>3&&void 0!==p[3]&&p[3],a=p.length>4?p[4]:void 0,d.next=5,b.awrap(this.retrieveKeyParams(e));case 5:if(!(i=d.sent).response.error){d.next=8;break}return d.abrupt("return",{response:i.response});case 8:if(s=i.keyParams,this.protocolService.supportedVersions().includes(s.version)){d.next=15;break}if(!this.protocolService.isVersionNewerThanLibraryVersion(s.version)){d.next=14;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.X)});case 14:return d.abrupt("return",{response:this.apiService.createErrorResponse(j.A)});case 15:if(!this.protocolService.isProtocolVersionOutdated(s.version)){d.next=25;break}if(o=this.protocolService.costMinimumForVersion(s.version),!(s.content002.pw_cost<o)){d.next=19;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.E)});case 19:return c=j.L,d.next=22,b.awrap(this.alertService.confirm(c,j.K,j.J));case 22:if(d.sent){d.next=25;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 25:if(this.protocolService.platformSupportsKeyDerivation(s)){d.next=27;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.W)});case 27:if(n&&(a=this.protocolService.getLatestVersion()),Object(_.w)(a)){d.next=31;break}if(Object(Q.d)(s.version,a)){d.next=31;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.T(s.version,a))});case 31:return d.next=33,b.awrap(this.protocolService.computeRootKey(t,s));case 33:return u=d.sent,d.next=36,b.awrap(this.bypassChecksAndSignInWithRootKey(e,u,i.mfaKeyPath,i.mfaCode,r));case 36:return l=d.sent,d.abrupt("return",{response:l});case 38:case"end":return d.stop()}},null,this,null,Promise)}},{key:"bypassChecksAndSignInWithRootKey",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return a=d.length>4&&void 0!==d[4]&&d[4],h.next=3,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 3:if(i=h.sent,s=i.wrappingKey,!i.canceled){h.next=8;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.PasscodeRequired,Te.b.LocalValidationError));case 8:return h.next=10,b.awrap(this.apiService.signIn(e,t.serverPassword,n,r,a));case 10:if((o=h.sent).error||!o.data){h.next=20;break}return h.next=14,b.awrap(Ve.ExpandedCopy(t,o.data.key_params));case 14:return c=h.sent,h.next=17,b.awrap(this.handleSuccessAuthResponse(o,c,s));case 17:return h.abrupt("return",o);case 20:if(null===(u=o.error)||void 0===u||null===(l=u.payload)||void 0===l||!l.mfa_key){h.next=32;break}if(!r){h.next=24;break}return h.next=24,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 24:return h.next=26,b.awrap(this.promptForMfaValue());case 26:if(p=h.sent){h.next=29;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa));case 29:return h.abrupt("return",this.bypassChecksAndSignInWithRootKey(e,t,o.error.payload.mfa_key,p));case 32:return h.abrupt("return",o);case 33:case"end":return h.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.user.uuid,r.next=3,b.awrap(this.apiService.changeCredentials({userUuid:t,currentServerPassword:e.currentServerPassword,newServerPassword:e.newRootKey.serverPassword,newKeyParams:e.newRootKey.keyParams,newEmail:e.newEmail}));case 3:return n=r.sent,r.abrupt("return",this.processChangeCredentialsResponse(n,e.newRootKey,e.wrappingKey));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getSessionsList());case 2:if(!(e=t.sent).error&&!Object(_.w)(e.data)){t.next=5;break}return t.abrupt("return",e);case 5:return e.data=e.data.map(function(e){return We(We({},e),{},{updated_at:new Date(e.updated_at)})}).sort(function(e,t){return e.updated_at<t.updated_at?1:-1}),t.abrupt("return",e);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeSession",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.deleteSession(e));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.getSessionsList());case 2:if(void 0==(e=s.sent).error&&void 0!=e.data){s.next=5;break}throw new Error(null!==(t=null===(n=e.error)||void 0===n?void 0:n.message)&&void 0!==t?t:j.m);case 5:return r=e.data,a=r.filter(function(e){return!e.current}),s.next=9,b.awrap(Promise.all(a.map(function(e){return i.revokeSession(e.uuid)})));case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"processChangeCredentialsResponse",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.error||!e.data){a.next=3;break}return a.next=3,b.awrap(this.handleSuccessAuthResponse(e,t,n));case 3:return a.abrupt("return",{response:e,keyParams:null===(r=e.data)||void 0===r?void 0:r.key_params});case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleSuccessAuthResponse",value:function(e,t,n){var r,a,i,s;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.protocolService.setRootKey(t,n));case 2:return r=e.data,a=r.user,this.user=a,c.next=7,b.awrap(this.storageService.setValue(o.User,a));case 7:if(this.apiService.setHost(this.apiService.getHost()),!r.token){c.next=15;break}return i=new Ae(r.token),c.next=12,b.awrap(this.setSession(i));case 12:this.webSocketsService.startWebSocketConnection(i.authorizationValue),c.next=20;break;case 15:if(!r.session){c.next=20;break}return s=je.FromApiResponse(e),c.next=19,b.awrap(this.setSession(s));case 19:this.webSocketsService.startWebSocketConnection(s.authorizationValue);case 20:case"end":return c.stop()}},null,this,null,Promise)}}]),n})(R.a);!(function(e){e.SignedInOrRegistered="SignedInOrRegistered"})(Ye||(Ye={}));var Qe=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).sessionManager=e,l.syncService=r,l.storageService=a,l.itemManager=i,l.protocolService=s,l.alertService=o,l.challengeService=c,l.protectionService=u,l.signingIn=!1,l.registering=!1,l}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.sessionManager=void 0,this.syncService=void 0,this.storageService=void 0,this.itemManager=void 0,this.protocolService=void 0,this.alertService=void 0,this.challengeService=void 0,this.protectionService=void 0}},{key:"register",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=!(i.length>3&&void 0!==i[3])||i[3],!this.protocolService.hasAccount()){s.next=4;break}throw Error('Tried to register when an account already exists.');case 4:if(!this.registering){s.next=6;break}throw Error('Already registering.');case 6:return this.registering=!0,s.prev=7,this.lockSyncing(),s.next=11,b.awrap(this.sessionManager.register(e,t,n));case 11:if((a=s.sent).response.error){s.next=32;break}return this.syncService.resetSyncState(),s.next=16,b.awrap(this.storageService.setPersistencePolicy(n?Oe.Ephemeral:Oe.Default));case 16:if(!r){s.next=21;break}return s.next=19,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 19:s.next=24;break;case 21:return this.itemManager.removeAllItemsFromMemory(),s.next=24,b.awrap(this.clearDatabase());case 24:return s.next=26,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 26:return this.unlockSyncing(),s.next=29,b.awrap(this.syncService.downloadFirstSync(300));case 29:this.protocolService.decryptErroredItems(),s.next=33;break;case 32:this.unlockSyncing();case 33:return s.abrupt("return",a.response);case 34:return s.prev=34,this.registering=!1,s.finish(34);case 37:case"end":return s.stop()}},null,this,[[7,,34,37]],Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o,c=this,u=arguments;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],r=u.length>3&&void 0!==u[3]&&u[3],a=!(u.length>4&&void 0!==u[4])||u[4],i=u.length>5&&void 0!==u[5]&&u[5],!this.protocolService.hasAccount()){l.next=6;break}throw Error('Tried to sign in when an account already exists.');case 6:if(!this.signingIn){l.next=8;break}throw Error('Already signing in.');case 8:return this.signingIn=!0,l.prev=9,this.lockSyncing(),l.next=13,b.awrap(this.sessionManager.signIn(e,t,n,r));case 13:if((s=l.sent).response.error){l.next=37;break}return this.syncService.resetSyncState(),l.next=18,b.awrap(this.storageService.setPersistencePolicy(r?Oe.Ephemeral:Oe.Default));case 18:if(!a){l.next=23;break}return l.next=21,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 21:l.next=26;break;case 23:return this.itemManager.removeAllItemsFromMemory(),l.next=26,b.awrap(this.clearDatabase());case 26:return l.next=28,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 28:if(this.unlockSyncing(),o=this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0,awaitAll:i}).then(function(){i||c.protocolService.decryptErroredItems()}),!i){l.next=35;break}return l.next=33,b.awrap(o);case 33:return l.next=35,b.awrap(this.protocolService.decryptErroredItems());case 35:l.next=38;break;case 37:this.unlockSyncing();case 38:return l.abrupt("return",s.response);case 39:return l.prev=39,this.signingIn=!1,l.finish(39);case 42:case"end":return l.stop()}},null,this,[[9,,39,42]],Promise)}},{key:"correctiveSignIn",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.lockSyncing(),n.next=3,b.awrap(this.sessionManager.bypassChecksAndSignInWithRootKey(e.keyParams.identifier,e));case 3:if((t=n.sent).error){n.next=10;break}return n.next=7,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 7:this.unlockSyncing(),this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0}),this.protocolService.decryptErroredItems();case 10:return this.unlockSyncing(),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.performCredentialsChange(e));case 2:return(t=n.sent).error&&this.alertService.alert(t.error.message),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.sessionManager.signOut());case 2:return e.next=4,b.awrap(this.protocolService.clearLocalKeyState());case 4:return e.next=6,b.awrap(this.storageService.clearAllData());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performProtocolUpgrade",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return e=this.protocolService.hasPasscode(),t=this.protocolService.hasAccount(),n=[],e&&n.push(new ge(te.LocalPasscode,void 0,j.x.LocalPasscodePlaceholder)),t&&n.push(new ge(te.AccountPassword,void 0,j.x.AccountPasswordPlaceholder)),r=new ye(n,ne.ProtocolUpgrade,!0),p.next=8,b.awrap(this.challengeService.promptForChallengeResponse(r));case 8:if(a=p.sent){p.next=11;break}return p.abrupt("return",{canceled:!0});case 11:return p.next=13,b.awrap(this.alertService.blockingDialog(j.z,j.Y));case 13:if(i=p.sent,p.prev=14,e&&(o=a.getValueForType(te.LocalPasscode),s=o.value),!t){p.next=24;break}return c=a.getValueForType(te.AccountPassword),u=c.value,p.next=21,b.awrap(this.changeCredentials({currentPassword:u,newPassword:u,passcode:s,origination:A.g.ProtocolUpgrade,validateNewPasswordStrength:!1}));case 21:if(null===(l=p.sent)||void 0===l||!l.error){p.next=24;break}return p.abrupt("return",{error:l.error});case 24:if(!e){p.next=29;break}return p.next=27,b.awrap(this.removePasscodeWithoutWarning());case 27:return p.next=29,b.awrap(this.setPasscodeWithoutWarning(s,A.g.ProtocolUpgrade));case 29:return p.abrupt("return",{success:!0});case 32:return p.prev=32,p.t0=p.catch(14),p.abrupt("return",{error:p.t0});case 35:return p.prev=35,i(),p.finish(35);case 38:case"end":return p.stop()}},null,this,[[14,32,35,38]],Promise)}},{key:"addPasscode",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e.length<1)){n.next=2;break}return n.abrupt("return",!1);case 2:return n.next=4,b.awrap(this.protectionService.authorizeAddingPasscode());case 4:if(n.sent){n.next=6;break}return n.abrupt("return",!1);case 6:return n.next=8,b.awrap(this.alertService.blockingDialog(j.z,j.Q));case 8:return t=n.sent,n.prev=9,n.next=12,b.awrap(this.setPasscodeWithoutWarning(e,A.g.PasscodeCreate));case 12:return n.abrupt("return",!0);case 13:return n.prev=13,t(),n.finish(13);case 16:case"end":return n.stop()}},null,this,[[9,,13,16]],Promise)}},{key:"removePasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeRemovingPasscode());case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,b.awrap(this.alertService.blockingDialog(j.z,j.O));case 6:return e=t.sent,t.prev=7,t.next=10,b.awrap(this.removePasscodeWithoutWarning());case 10:return t.abrupt("return",!0);case 11:return t.prev=11,e(),t.finish(11);case 14:case"end":return t.stop()}},null,this,[[7,,11,14]],Promise)}},{key:"changePasscode",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:A.g.PasscodeChange,!(e.length<1)){a.next=3;break}return a.abrupt("return",!1);case 3:return a.next=5,b.awrap(this.protectionService.authorizeChangingPasscode());case 5:if(a.sent){a.next=7;break}return a.abrupt("return",!1);case 7:return a.next=9,b.awrap(this.alertService.blockingDialog(j.z,t===A.g.ProtocolUpgrade?j.N.UpgradingPasscode:j.v));case 9:return n=a.sent,a.prev=10,a.next=13,b.awrap(this.removePasscodeWithoutWarning());case 13:return a.next=15,b.awrap(this.setPasscodeWithoutWarning(e,t));case 15:return a.abrupt("return",!0);case 16:return a.prev=16,n(),a.finish(16);case 19:case"end":return a.stop()}},null,this,[[10,,16,19]],Promise)}},{key:"setPasscodeWithoutWarning",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(I.GenerateUuid());case 2:return n=a.sent,a.next=5,b.awrap(this.protocolService.createRootKey(n,e,t));case 5:return r=a.sent,a.next=8,b.awrap(this.protocolService.setNewRootKeyWrapper(r));case 8:return a.next=10,b.awrap(this.rewriteItemsKeys());case 10:return a.next=12,b.awrap(this.syncService.sync());case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"removePasscodeWithoutWarning",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protocolService.removeRootKeyWrapper());case 2:return e.next=4,b.awrap(this.rewriteItemsKeys());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"rewriteItemsKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.itemsKeys(),t=e.map(function(e){return e.payloadRepresentation()}),n.next=4,b.awrap(this.storageService.deletePayloads(t));case 4:return n.next=6,b.awrap(this.syncService.persistPayloads(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"clearDatabase",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performCredentialsChange",value:function(e){var t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(this.challengeService.getWrappingKeyIfApplicable(e.passcode));case 2:if(t=u.sent,n=t.wrappingKey,!t.canceled){u.next=7;break}return u.abrupt("return",{error:Error(j.y.PasscodeRequired)});case 7:if(void 0===e.newPassword||!e.validateNewPasswordStrength){u.next=10;break}if(!(e.newPassword.length<8)){u.next=10;break}return u.abrupt("return",{error:Error(Object(j.G)(8))});case 10:return u.next=12,b.awrap(this.protocolService.validateAccountPassword(e.currentPassword));case 12:if(u.sent.valid){u.next=15;break}return u.abrupt("return",{error:Error(j.D)});case 15:return r=this.sessionManager.getUser(),a=r.email,u.next=19,b.awrap(this.recomputeRootKeysForCredentialChange({currentPassword:e.currentPassword,currentEmail:a,origination:e.origination,newEmail:e.newEmail,newPassword:e.newPassword}));case 19:return i=u.sent,this.lockSyncing(),u.next=23,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.currentRootKey.serverPassword,newRootKey:i.newRootKey,wrappingKey:n,newEmail:e.newEmail}));case 23:if(s=u.sent,this.unlockSyncing(),s.response.error){u.next=45;break}return u.next=28,b.awrap(this.protocolService.createNewItemsKeyWithRollback());case 28:return o=u.sent,u.next=31,b.awrap(this.protocolService.reencryptItemsKeys());case 31:return u.next=33,b.awrap(this.syncService.sync({awaitAll:!0}));case 33:if(c=this.protocolService.getDefaultItemsKey(),!c.neverSynced){u.next=45;break}return u.next=38,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.newRootKey.serverPassword,newRootKey:i.currentRootKey,wrappingKey:n}));case 38:return u.next=40,b.awrap(this.protocolService.reencryptItemsKeys());case 40:return u.next=42,b.awrap(o());case 42:return u.next=44,b.awrap(this.syncService.sync({awaitAll:!0}));case 44:return u.abrupt("return",{error:Error(j.y.Failed)});case 45:return u.abrupt("return",s.response);case 46:case"end":return u.stop()}},null,this,null,Promise)}},{key:"recomputeRootKeysForCredentialChange",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=b,i.t1=this.protocolService,i.t2=e.currentPassword,i.next=5,b.awrap(this.protocolService.getRootKeyParams());case 5:return i.t3=i.sent,i.t4=i.t1.computeRootKey.call(i.t1,i.t2,i.t3),i.next=9,i.t0.awrap.call(i.t0,i.t4);case 9:return r=i.sent,i.next=12,b.awrap(this.protocolService.createRootKey(null!==(t=e.newEmail)&&void 0!==t?t:e.currentEmail,null!==(n=e.newPassword)&&void 0!==n?n:e.currentPassword,e.origination));case 12:return a=i.sent,i.abrupt("return",{currentRootKey:r,newRootKey:a});case 14:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),Je=n(5),$e=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",get:function(){return this.payload.safeContent.migratedToUserSetting}},{key:"migratedToOfflineEntitlements",get:function(){return this.payload.safeContent.migratedToOfflineEntitlements}},{key:"onlineUrl",get:function(){return this.payload.safeContent.url}},{key:"offlineFeaturesUrl",get:function(){return this.payload.safeContent.offlineFeaturesUrl}},{key:"offlineKey",get:function(){return this.payload.safeContent.offlineKey}}]),n})(T.d),Xe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",set:function(e){this.content.migratedToUserSetting=e}},{key:"migratedToOfflineEntitlements",set:function(e){this.content.migratedToOfflineEntitlements=e}},{key:"offlineFeaturesUrl",set:function(e){this.content.offlineFeaturesUrl=e}},{key:"offlineKey",set:function(e){this.content.offlineKey=e}}]),n})(T.b),Ze=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).notes=[],r.data={},r.url=e.safeContent.url,r.name=e.safeContent.name,r.data=e.safeContent.data||{},r.isDefault=e.safeContent.default,r.systemEditor=e.safeContent.systemEditor,r}return n})(T.d),et=(function(e){d(n,oe);var t=k(n);function n(e){var r;return v(this,n),r=t.call(this,e),e.safeContent.predicate&&(r.predicate=H.a.FromJson(e.safeContent.predicate)),r}return n})(),tt=(g(r={},F.a.Note,le),g(r,F.a.Tag,oe),g(r,F.a.ItemsKey,J),g(r,F.a.SmartTag,et),g(r,F.a.ActionsExtension,ie),g(r,F.a.Editor,Ze),g(r,F.a.Theme,B),g(r,F.a.Component,N),g(r,F.a.UserPrefs,z),g(r,F.a.ExtensionRepo,$e),r);function nt(e){return new(tt[e.content_type]||T.d)(e)}var rt=n(27),at=n.n(rt);function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){ot(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ct=g({},F.a.Note,function(e,t,n){var r=n.all(F.a.Component).map(function(e){return nt(e)}).filter(function(e){return e.area===L.ComponentArea.Editor}).find(function(t){return t.isExplicitlyEnabledForItem(e.uuid)});if(r){var a=new V(r,T.c.Internal);return a.associateWithItem(t.uuid),[a.getResult()]}});function ut(e,t,n,r){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(!e.errorDecrypting){p.next=2;break}throw Error('Attempting to duplicate errored payload');case 2:return a=[],p.next=5,b.awrap(I.GenerateUuid());case 5:return p.t0=p.sent,p.t1=new Date,p.t2=e.uuid,(i={uuid:p.t0,dirty:!0,dirtiedDate:p.t1,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:p.t2}).content=st(st({},e.safeContent),r),n&&(i.content.conflict_of=e.uuid),s=Object(Ee.b)(e,i),a.push(s),o=t.elementsReferencingElement(e),c=pt(o,[{uuid:s.uuid,content_type:s.content_type}]),Object(_.o)(a,c),(u=ct[e.content_type])&&(l=u(e,s,t))&&Object(_.o)(a,l),p.abrupt("return",a);case 19:case"end":return p.stop()}},null,null,null,Promise)}function lt(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=[],u.t0=Object(Ee.b),u.t1=e,u.next=5,b.awrap(I.GenerateUuid());case 5:return u.t2=u.sent,u.t3=new Date,u.t4=e.uuid,u.t5={uuid:u.t2,dirty:!0,dirtiedDate:u.t3,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:u.t4},r=(0,u.t0)(u.t1,u.t5),n.push(r),a=t.elementsReferencingElement(e),i=pt(a,[{uuid:r.uuid,content_type:r.content_type}],[e.uuid]),Object(_.o)(n,i),e.content_type===F.a.ItemsKey&&(s=t.all().filter(function(t){return t.items_key_id===e.uuid}),(o=s.map(function(e){return Object(Ee.b)(e,{items_key_id:r.uuid})})).length>0&&Object(_.o)(n,o)),c=Object(Ee.b)(e,{deleted:!0,dirty:!1,content:void 0}),n.push(c),u.abrupt("return",n);case 18:case"end":return u.stop()}},null,null,null,Promise)}function pt(e,t,n){for(var r,a=[],i=S(e);!(r=i()).done;){var s=r.value,o=s.contentObject.references.slice();if(t)for(var c,u=S(t);!(c=u()).done;){var l=c.value;o.push(l)}if(n)for(var p,d=S(n);!(p=d()).done;){var h=p.value;at()(o,{uuid:h})}var f=Object(Ee.b)(s,{dirty:!0,dirtiedDate:new Date,content:st(st({},s.safeContent),{},{references:o})});a.push(f)}return a}function dt(e,t){var n=nt(e),r=nt(t);return n.isItemContentEqualWith(r)}var ht=n(4),ft=n(32),vt=(function(){function e(t,n,r,a){v(this,e),this.baseCollection=t,this.applyCollection=n,this.relatedCollectionSet=r,this.historyMap=a}return y(e,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:throw'Must override PayloadDelta.resultingCollection.';case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"findBasePayload",value:function(e){return this.baseCollection.find(e)}},{key:"findRelatedPayload",value:function(e,t){var n,r=null===(n=this.relatedCollectionSet)||void 0===n?void 0:n.collectionForSource(t);return null===r||void 0===r?void 0:r.find(e)}}]),e})(),yt=function(e){return e[0]},gt=(function(){function e(){v(this,e),this.directMap={},this.inverseMap={}}return y(e,[{key:"makeCopy",value:function(){var t=new e;return t.directMap=w({},this.directMap),t.inverseMap=w({},this.inverseMap),t}},{key:"getDirectRelationships",value:function(e){return this.directMap[e]||[]}},{key:"getInverseRelationships",value:function(e){return this.inverseMap[e]||[]}},{key:"establishRelationship",value:function(e,t){this.establishDirectRelationship(e,t),this.establishInverseRelationship(e,t)}},{key:"deestablishRelationship",value:function(e,t){this.deestablishDirectRelationship(e,t),this.deestablishInverseRelationship(e,t)}},{key:"setAllRelationships",value:function(e,t){var n=this.directMap[e]||[];this.directMap[e]=t;for(var r,a=S(n);!(r=a()).done;){var i=r.value;this.deestablishInverseRelationship(e,i)}for(var s,o=S(t);!(s=o()).done;){var c=s.value;this.establishInverseRelationship(e,c)}}},{key:"removeFromMap",value:function(e){for(var t,n=S(this.directMap[e]||[]);!(t=n()).done;){var r=t.value;Object(_.M)(this.inverseMap[r]||[],e)}delete this.directMap[e];for(var a,i=S(this.inverseMap[e]||[]);!(a=i()).done;){var s=a.value;Object(_.M)(this.directMap[s]||[],e)}delete this.inverseMap[e]}},{key:"establishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.b)(n,t),this.directMap[e]=n}},{key:"establishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.b)(n,e),this.inverseMap[t]=n}},{key:"deestablishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.M)(n,t),this.directMap[e]=n}},{key:"deestablishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.M)(n,e),this.inverseMap[t]=n}}]),e})(),mt=(function(){function e(){v(this,e);var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.map={},this.typedMap={},this.dirtyIndex=new Set,this.invalidsIndex=new Set,this.nondeletedIndex=new Set,t?(this.map=n,this.typedMap=r,this.referenceMap=a,this.conflictMap=i):(this.referenceMap=new gt,this.conflictMap=new gt)}return y(e,[{key:"uuids",value:function(){return Object.keys(this.map)}},{key:"all",value:function(e){var t=this;if(e){if(Array.isArray(e)){for(var n,r=[],a=S(e);!(n=a()).done;){var i=n.value;Object(_.o)(r,this.typedMap[i]||[])}return r}var s;return(null===(s=this.typedMap[e])||void 0===s?void 0:s.slice())||[]}return Object.keys(this.map).map(function(e){return t.map[e]})}},{key:"find",value:function(e){return this.map[e]}},{key:"dirtyElements",value:function(){var e=Array.from(this.dirtyIndex);return this.findAll(e)}},{key:"invalidElements",value:function(){var e=Array.from(this.invalidsIndex);return this.findAll(e)}},{key:"nondeletedElements",value:function(){var e=Array.from(this.nondeletedIndex);return this.findAll(e)}},{key:"findAll",value:function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],a=S(e);!(t=a()).done;){var i=t.value,s=this.map[i];(s||n)&&r.push(s)}return r}},{key:"set",value:function(e){if(0!==(e=Array.isArray(e)?e:[e]).length)for(var t,n=S(e);!(t=n()).done;){var r=t.value;if(this.map[r.uuid]=r,this.setToTypedMap(r),r.dirty?this.dirtyIndex.add(r.uuid):this.dirtyIndex.delete(r.uuid),r.errorDecrypting||r.waitingForKey?this.invalidsIndex.add(r.uuid):this.invalidsIndex.delete(r.uuid),r.deleted)this.referenceMap.removeFromMap(r.uuid),this.nondeletedIndex.delete(r.uuid);else{this.nondeletedIndex.add(r.uuid);var a=r.safeContent.conflict_of;a&&this.conflictMap.establishRelationship(a,r.uuid),this.referenceMap.setAllRelationships(r.uuid,r.references.map(function(e){return e.uuid}))}}else console.warn('Attempting to set 0 elements onto collection')}},{key:"discard",value:function(e){for(var t,n=S(e=Array.isArray(e)?e:[e]);!(t=n()).done;){var r=t.value;this.conflictMap.removeFromMap(r.uuid),this.referenceMap.removeFromMap(r.uuid),this.deleteFromTypedMap(r),delete this.map[r.uuid]}}},{key:"setToTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),t.push(e),this.typedMap[e.content_type]=t}},{key:"deleteFromTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),this.typedMap[e.content_type]=t}},{key:"uuidsThatReferenceUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getInverseRelationships(e)}},{key:"elementsReferencingElement",value:function(e,t){var n=this.uuidsThatReferenceUuid(e.uuid),r=this.findAll(n);return t?r.filter(function(e){return e.content_type===t}):r}},{key:"uuidReferencesForUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getDirectRelationships(e)}},{key:"referencesForElement",value:function(e){var t=this.referenceMap.getDirectRelationships(e.uuid);return this.findAll(t)}},{key:"conflictsOf",value:function(e){var t=this.conflictMap.getDirectRelationships(e);return this.findAll(t)}}]),e})(),bt=(function(e){d(n,mt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"mutableCopy",value:function(){var e=w({},this.map),t=w({},this.typedMap),n=this.referenceMap.makeCopy(),r=this.conflictMap.makeCopy();return new mt(!0,e,t,n,r)}},{key:"payloads",get:function(){return this.all()}}],[{key:"WithPayloads",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=new n;return r.source=t,e.length>0&&r.set(e),Object.freeze(r),r}},{key:"FromCollection",value:function(e){var t=new n(!0,Object.freeze(w({},e.map)),Object.freeze(w({},e.typedMap)),Object.freeze(e.referenceMap.makeCopy()),Object.freeze(e.conflictMap.makeCopy()));return Object.freeze(t),t}}]),n})();function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach(function(t){xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var St,Pt,Ot,Ct=(function(){function e(t,n,r,a,i){v(this,e),this.baseCollection=t,this.basePayload=n,this.applyPayload=r,this.source=a,this.historyMap=i}return y(e,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return t=nt(this.basePayload),n=nt(this.applyPayload),r=(null===(e=this.historyMap)||void 0===e?void 0:e[this.basePayload.uuid])||[],a=yt(r),i=t.strategyWhenConflictingWithItem(n,a),o.next=7,b.awrap(this.payloadsByHandlingStrategy(i));case 7:return s=o.sent,o.abrupt("return",bt.WithPayloads(s,this.source));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingStrategy",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if((t=this.baseCollection.conflictsOf(this.applyPayload.uuid)[0])&&dt(t,this.applyPayload)&&(e=K.a.KeepLeft),e!==K.a.KeepLeft){y.next=7;break}return n=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),r=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),a=Object(Ee.b)(this.basePayload,{updated_at:n,updated_at_timestamp:r,dirty:!0,dirtiedDate:new Date}),y.abrupt("return",[a]);case 7:if(e!==K.a.KeepRight){y.next=10;break}return i=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",[i]);case 10:if(e!==K.a.KeepLeftDuplicateRight){y.next=18;break}return s=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),o=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),c=Object(Ee.b)(this.basePayload,{updated_at:s,updated_at_timestamp:o,dirty:!0,dirtiedDate:new Date}),y.next=16,b.awrap(ut(this.applyPayload,this.baseCollection,!0));case 16:return u=y.sent,y.abrupt("return",[c].concat(u));case 18:if(e!==K.a.DuplicateLeftKeepRight){y.next=24;break}return y.next=21,b.awrap(ut(this.basePayload,this.baseCollection,!0));case 21:return l=y.sent,p=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",l.concat([p]));case 24:if(e!==K.a.KeepLeftMergeRefs){y.next=30;break}return d=Object(_.U)(this.basePayload.contentObject.references,this.applyPayload.contentObject.references,['uuid','content_type']),h=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),f=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),v=Object(Ee.b)(this.basePayload,{updated_at:h,updated_at_timestamp:f,dirty:!0,dirtiedDate:new Date,content:kt(kt({},this.basePayload.safeContent),{},{references:d})}),y.abrupt("return",[v]);case 30:throw Error('Unhandled strategy');case 31:case"end":return y.stop()}},null,this,null,Promise)}}]),e})(),Dt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}return r=n.value,s.next=6,b.awrap(this.payloadsByHandlingPayload(r,e));case 6:a=s.sent,i=a.map(function(e){return Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date,deleted:!1})}),Object(_.o)(e,i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.FileImport));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingPayload",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=t.find(function(t){return t.contentObject.conflict_of===e.uuid}))||(n=t.find(function(t){return t.uuid===e.uuid})),n||(n=this.findBasePayload(e.uuid)),n){i.next=5;break}return i.abrupt("return",[e]);case 5:return r=new Ct(this.baseCollection,n,e,ht.a.FileImport),i.next=8,b.awrap(r.resultingCollection());case 8:return a=i.sent,i.abrupt("return",a.all());case 10:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(),_t=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=17;break}if(r=n.value,e.push(r),a=this.findBasePayload(r.uuid)){s.next=8;break}return s.abrupt("continue",15);case 8:if(!dt(r,a)){s.next=11;break}return s.abrupt("continue",15);case 11:return s.next=13,b.awrap(ut(a,this.baseCollection,!0));case 13:i=s.sent,Object(_.o)(e,i);case 15:s.next=2;break;case 17:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 18:case"end":return s.stop()}},null,this,null,Promise)}}]),n})(),Et=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.applyCollection.source!==ht.a.ConflictUuid){e.next=4;break}return e.abrupt("return",this.collectionsByHandlingUuidConflicts());case 4:if(this.applyCollection.source!==ht.a.ConflictData){e.next=8;break}return e.abrupt("return",this.collectionsByHandlingDataConflicts());case 8:throw"Unhandled conflict type ".concat(this.applyCollection.source);case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingDataConflicts",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){u.next=19;break}if(r=n.value,a=this.findBasePayload(r.uuid)){u.next=8;break}return e.push(r),u.abrupt("continue",17);case 8:if((i=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient))||r.deleted){u.next=11;break}throw'Unable to find decrypted counterpart for data conflict.';case 11:return s=new Ct(this.baseCollection,a,i||r,ht.a.ConflictData,this.historyMap),u.next=14,b.awrap(s.resultingCollection());case 14:o=u.sent,c=o.all(),Object(_.o)(e,c);case 17:u.next=2;break;case 19:return u.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingUuidConflicts",value:function(){var e,t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:e=[],t=this.baseCollection.mutableCopy(),n=function(n){var r,a,i;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=e.find(function(e){return e.uuid===n.uuid}),a=r||s.findRelatedPayload(n.uuid,ht.a.DecryptedTransient)){o.next=6;break}return we.a.error(Error('Cannot find decrypted payload in conflict handling')),console.error('Unable to find decrypted counterpart for payload',n),o.abrupt("return","continue");case 6:return o.next=8,b.awrap(lt(a,bt.FromCollection(t)));case 8:i=o.sent,t.set(i),Object(_.p)(e,function(e){return Object(Ke.b)(i).includes(e.uuid)}),Object(_.o)(e,i);case 12:case"end":return o.stop()}},null,null,null,Promise)},r=S(this.applyCollection.all());case 4:if((a=r()).done){o.next=13;break}return i=a.value,o.next=8,b.awrap(n(i));case 8:if("continue"!==o.sent){o.next=11;break}return o.abrupt("continue",11);case 11:o.next=4;break;case 13:return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 14:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Rt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y;return b.async(function(g){for(;;)switch(g.prev=g.next){case 0:e=[],t=[],n=S(this.applyCollection.all());case 3:if((r=n()).done){g.next=22;break}if(a=r.value,i=this.findRelatedPayload(a.uuid,ht.a.SavedOrSaving),s=this.findRelatedPayload(a.uuid,ht.a.DecryptedTransient)){g.next=12;break}if(a.deleted){g.next=10;break}throw'Cannot find decrypted for non-deleted payload.';case 10:return e.push(a),g.abrupt("continue",20);case 12:if(!i){g.next=15;break}return t.push(s),g.abrupt("continue",20);case 15:if(null===(o=this.findBasePayload(a.uuid))||void 0===o||!o.dirty||o.errorDecrypting){g.next=19;break}return t.push(s),g.abrupt("continue",20);case 19:e.push(s);case 20:g.next=3;break;case 22:c=[],u=0,l=t;case 24:if(!(u<l.length)){g.next=41;break}if(p=l[u],d=this.findRelatedPayload(p.uuid,ht.a.DecryptedTransient)){g.next=29;break}return g.abrupt("continue",38);case 29:if(h=this.findBasePayload(p.uuid)){g.next=32;break}return g.abrupt("continue",38);case 32:return f=new Ct(this.baseCollection,h,d,ht.a.ConflictData),g.next=35,b.awrap(f.resultingCollection());case 35:v=g.sent,y=v.all(),Object(_.o)(c,y);case 38:u++,g.next=24;break;case 41:return g.abrupt("return",bt.WithPayloads(e.concat(c),ht.a.RemoteRetrieved));case 42:case"end":return g.stop()}},null,this,null,Promise)}}]),n})(),It=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:for(e=[],t=S(this.applyCollection.all());!(n=t()).done;)r=n.value,a=this.findBasePayload(r.uuid),i=a?a.deleted:r.deleted,s=Object(Ee.f)(r,ht.a.RemoteSaved,{lastSyncEnd:new Date,deleted:i,dirty:i}),e.push(s);return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteSaved));case 3:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Mt=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l){var p;return v(this,n),(p=t.call(this)).itemManager=e,p.payloadManager=r,p.apiService=a,p.protocolService=i,p.challengeService=s,p.alertService=o,p.storageService=c,p.syncService=u,p.credentialService=l,p.decryptionQueue=[],p.isProcessingQueue=!1,p.removeItemObserver=p.itemManager.addObserver([F.a.ItemsKey],function(e,t,n,r,a){if(a!==ht.a.LocalChanged){var i=e.concat(t).filter(function(e){return e.errorDecrypting});i.length>0&&p.handleUndecryptableItemsKeys(i),r.length>0&&p.handleIgnoredItemsKeys(r)}}),p}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.apiService=void 0,this.protocolService=void 0,this.challengeService=void 0,this.alertService=void 0,this.credentialService=void 0,this.syncService=void 0,this.storageService=void 0,this.removeItemObserver(),this.removeItemObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:p(f(n.prototype),"handleApplicationStage",this).call(this,e),e===ve.LoadedDatabase_12&&this.processPersistedUndecryptables();case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleIgnoredItemsKeys",value:function(e){var t=this,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(!(n.length>1&&void 0!==n[1])||n[1])){r.next=4;break}return r.next=4,b.awrap(this.saveToUndecryptables(e));case 4:return r.next=6,b.awrap(this.addKeysToQueue(e,function(e,n){n.success&&t.removeFromUndecryptables(e)}));case 6:return r.next=8,b.awrap(this.beginProcessingQueue());case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"handleUndecryptableItemsKeys",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.addKeysToQueue(e));case 2:return t.next=4,b.awrap(this.beginProcessingQueue());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"processPersistedUndecryptables",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getUndecryptables());case 2:if(e=r.sent,0!==(t=Object.values(e)).length){r.next=6;break}return r.abrupt("return");case 6:return n=t.map(function(e){return Object(Ee.e)(e)}).map(function(e){return nt(e)}),r.abrupt("return",this.handleIgnoredItemsKeys(n,!1));case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getUndecryptables",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.KeyRecoveryUndecryptableItems,De.Default,{}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"persistUndecryptables",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.KeyRecoveryUndecryptableItems,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"saveToUndecryptables",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.getUndecryptables());case 2:for(t=i.sent,n=S(e);!(r=n()).done;)a=r.value,t[a.uuid]=a.payload.ejected();return i.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"removeFromUndecryptables",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getUndecryptables());case 2:return delete(t=n.sent)[e.uuid],n.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getClientKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getAccountKeyParams());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"serverKeyParamsAreSafe",value:function(e){return Object(Q.d)(this.serverParams.version,e.version)}},{key:"performServerSignIn",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(e),j.H.KeyRecoveryLoginFlowReason),i.next=3,b.awrap(this.challengeService.promptForChallengeResponse(t));case 3:if(n=i.sent){i.next=6;break}return i.abrupt("return",void 0);case 6:return this.challengeService.completeChallenge(t),r=n.values[0].value,i.next=10,b.awrap(this.protocolService.computeRootKey(r,e));case 10:return a=i.sent,i.next=13,b.awrap(this.credentialService.correctiveSignIn(a));case 13:if(i.sent.error){i.next=19;break}return this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced),i.abrupt("return",a);case 19:return i.next=21,b.awrap(this.alertService.alert(j.H.KeyRecoveryLoginFlowInvalidPassword));case 21:return i.abrupt("return",this.performServerSignIn(e));case 22:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",void 0);case 2:return n.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(e=n.sent,t=e.wrappingKey,!e.canceled){n.next=11;break}return n.next=10,b.awrap(this.alertService.alert(j.H.KeyRecoveryPasscodeRequiredText,j.H.KeyRecoveryPasscodeRequiredTitle));case 10:return n.abrupt("return",this.getWrappingKeyIfApplicable());case 11:return n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"addKeysToQueue",value:function(e,t){var n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:n=function(e){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(s.protocolService.getKeyEmbeddedKeyParams(e));case 2:if(n=i.sent){i.next=5;break}return i.abrupt("return","continue");case 5:r={key:e,keyParams:n,callback:t},a=new Promise(function(e){r.resolve=e}),r.promise=a,s.decryptionQueue.push(r);case 9:case"end":return i.stop()}},null,null,null,Promise)},r=S(e);case 2:if((a=r()).done){o.next=11;break}return i=a.value,o.next=6,b.awrap(n(i));case 6:if("continue"!==o.sent){o.next=9;break}return o.abrupt("continue",9);case 9:o.next=2;break;case 11:case"end":return o.stop()}},null,null,null,Promise)}},{key:"readdQueueItem",value:function(e){var t=new Promise(function(t){e.resolve=t});e.promise=t,this.decryptionQueue.unshift(e)}},{key:"beginProcessingQueue",value:function(){var e,t,n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.isProcessingQueue){c.next=2;break}return c.abrupt("return");case 2:return this.isProcessingQueue=!0,c.next=5,b.awrap(this.getClientKeyParams());case 5:if(e=c.sent,this.serverParams||!e){c.next=11;break}return c.next=9,b.awrap(this.apiService.getAccountKeyParams(e.identifier));case 9:!(t=c.sent).error&&t.data&&(this.serverParams=Object(A.f)(t));case 11:if(n=this.protocolService.hasAccount(),r=this.protocolService.hasPasscode(),a=!n&&!r,i=this.decryptionQueue[0],!a){c.next=24;break}return c.next=18,b.awrap(this.performServerSignIn(i.keyParams));case 18:if(!(s=c.sent)){c.next=24;break}return c.next=22,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(s,!0));case 22:Object(_.M)(this.decryptionQueue,i),i=this.decryptionQueue[0];case 24:if(!i){c.next=31;break}return this.popQueueItem(i),c.next=28,b.awrap(i.promise);case 28:i=this.decryptionQueue[0],c.next=24;break;case 31:this.queuePromise.then(function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(o.isProcessingQueue=!1,!o.serverParams){n.next=9;break}return n.next=4,b.awrap(o.getClientKeyParams());case 4:if(e=n.sent,t=e&&!o.serverParams.compare(e),!o.serverKeyParamsAreSafe(e)||!t){n.next=9;break}return n.next=9,b.awrap(o.performServerSignIn(o.serverParams));case 9:o.syncService.isOutOfSync()&&o.syncService.sync({checkIntegrity:!0});case 10:case"end":return n.stop()}},null,null,null,Promise)});case 32:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueItem",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P;return b.async(function(O){for(;;)switch(O.prev=O.next){case 0:if(e.resolve){O.next=2;break}throw Error('Attempting to pop queue element with no resolve function');case 2:return Object(_.M)(this.decryptionQueue,e),t=e.keyParams,n=e.key,r=e.resolve,a=!1,O.next=9,b.awrap(this.getClientKeyParams());case 9:return i=O.sent,this.serverParams&&i&&!i.compare(this.serverParams)&&t.compare(this.serverParams)&&this.serverKeyParamsAreSafe(this.serverParams)&&(s=Object(_.j)(this.itemManager.nonErroredItemsForContentType(F.a.ItemsKey),Je.a.CreatedAt,!1)[0],o=!Object(_.w)(s),c=n.created_at>(null===s||void 0===s?void 0:s.created_at),a=!o||c),u=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(t),j.H.KeyRecoveryPasswordRequired),O.next=14,b.awrap(this.challengeService.promptForChallengeResponse(u));case 14:if(l=O.sent){O.next=20;break}return r(d={success:!1}),null===(p=e.callback)||void 0===p||p.call(e,n,d),O.abrupt("return");case 20:return h=l.values[0].value,O.next=23,b.awrap(this.protocolService.computeRootKey(h,t));case 23:return f=O.sent,O.next=26,b.awrap(this.protocolService.payloadByDecryptingPayload(n.payload,f));case 26:if(v=O.sent,this.challengeService.completeChallenge(u),v.errorDecrypting){O.next=38;break}return O.next=31,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(f,a,[v]));case 31:for(g=O.sent,r(m={success:!0}),null===(y=e.callback)||void 0===y||y.call(e,n,m),w=S(g);!(k=w()).done;)(x=k.value).resolve(m),null===(P=x.callback)||void 0===P||P.call(x,x.key,m);O.next=42;break;case 38:return O.next=40,b.awrap(this.alertService.alert(j.H.KeyRecoveryUnableToRecover));case 40:this.readdQueueItem(e),r({success:!1});case 42:case"end":return O.stop()}},null,this,null,Promise)}},{key:"handleDecryptionOfAllKeysMatchingCorrectRootKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:[],!t){c.next=7;break}return c.next=4,b.awrap(this.getWrappingKeyIfApplicable());case 4:return r=c.sent,c.next=7,b.awrap(this.protocolService.setRootKey(e,r));case 7:return a=this.popQueueForKeyParams(e.keyParams),c.next=10,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a.map(function(e){return e.key.payload}),e));case 10:return i=c.sent,s=n.concat(i),this.payloadManager.emitPayloads(s,ht.a.DecryptedTransient),c.next=15,b.awrap(this.storageService.savePayloads(s));case 15:return t?this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced):this.alertService.alert(j.H.KeyRecoveryKeyRecovered),c.abrupt("return",a);case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueForKeyParams",value:function(e){for(var t,n=[],r=[],a=S(this.decryptionQueue);!(t=a()).done;){var i=t.value;i.keyParams.compare(e)?n.push(i):r.push(i)}return this.decryptionQueue=r,n}},{key:"queuePromise",get:function(){return Promise.all(this.decryptionQueue.map(function(e){return e.promise}))}}]),n})(R.a),At=n(17);!(function(e){e[e.Info=0]="Info",e[e.Danger=1]="Danger"})(St||(St={})),(function(e){e.Get="GET",e.Post="POST",e.Put="PUT",e.Patch="PATCH",e.Delete="DELETE"})(Pt||(Pt={})),(function(e){e.RevokedSession="revoked-session"})(Ot||(Ot={}));var jt=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).environment=e,a.appVersion=r,a}return y(n,[{key:"getAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Get,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"postAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Post,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"putAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Put,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"patchAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Patch,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Delete,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"runHttp",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.createXmlRequest(e),n.abrupt("return",this.runRequest(t,e.verb,e.params));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createXmlRequest",value:function(e){var t=new XMLHttpRequest;e.params&&e.verb===Pt.Get&&Object.keys(e.params).length>0&&(e.url=this.urlForUrlAndParams(e.url,e.params)),t.open(e.verb,e.url,!0),t.setRequestHeader('Content-type','application/json'),t.setRequestHeader('X-SNJS-Version',h);var n="".concat(he[this.environment],"-").concat(this.appVersion);return t.setRequestHeader('X-Application-Version',n),e.authentication&&t.setRequestHeader('Authorization','Bearer '+e.authentication),e.customHeaders&&e.customHeaders.length>0&&e.customHeaders.forEach(function(e){var n=e.key,r=e.value;t.setRequestHeader(n,r)}),t}},{key:"runRequest",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,i){e.onreadystatechange=function(){r.stateChangeHandlerForRequest(e,a,i)},t===Pt.Post||t===Pt.Put||t===Pt.Patch||t===Pt.Delete?e.send(JSON.stringify(n)):e.send()}));case 1:case"end":return a.stop()}},null,null,null,Promise)}},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.status,a={status:r};try{if(r!==Te.b.HttpStatusNoContent){var i=JSON.parse(e.responseText);i.data||(a.data=i),w(a,i)}}catch(e){console.error(e)}r>=Te.b.HttpStatusMinSuccess&&r<=Te.b.HttpStatusMaxSuccess?t(a):(r===Te.b.HttpStatusForbidden?a.error={message:j.q,status:r}:Object(_.w)(a.error)&&(Object(_.w)(a.data)||Object(_.w)(a.data.error)?a.error={message:j.U,status:r}:a.error=a.data.error),n(a))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map(function(e){return e+'='+encodeURIComponent(t[e])}).join('&');return e.includes('?')?e+'&'+n:e+'?'+n}}]),n})(R.a),Tt=n(22),Kt=['api.standardnotes.com','api-dev.standardnotes.com','sync.standardnotes.org'],Ft=['api-dev.standardnotes.com','api.standardnotes.com','extensions.standardnotes.com','extensions.standardnotes.org','features.standardnotes.com'],Lt='localhost';function Ut(e){try{var t=new URL(e).host;return t.startsWith(Lt)||Kt.includes(t)}catch(e){return!1}}var Nt=['listed.to'];function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(n),!0).forEach(function(t){Wt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ht,zt={keyParams:'/v1/login-params',register:'/v1/users',signIn:'/v1/login',changeCredentials:function(e){return"/v1/users/".concat(e,"/attributes/credentials")},sync:'/v1/items',signOut:'/v1/logout',refreshSession:'/v1/sessions/refresh',sessions:'/v1/sessions',session:function(e){return"/v1/sessions/".concat(e)},itemRevisions:function(e){return"/v1/items/".concat(e,"/revisions")},itemRevision:function(e,t){return"/v1/items/".concat(e,"/revisions/").concat(t)},userFeatures:function(e){return"/v1/users/".concat(e,"/features")},settings:function(e){return"/v1/users/".concat(e,"/settings")},setting:function(e,t){return"/v1/users/".concat(e,"/settings/").concat(t)},subscription:function(e){return"/v1/users/".concat(e,"/subscription")},purchase:'/v1/purchase',subscriptionTokens:'/v1/subscription-tokens',offlineFeatures:'/v1/offline/features'},qt={subscriptions:'/v2/subscriptions'};!(function(e){e.MetaReceived="MetaReceived"})(Ht||(Ht={}));var Yt=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).httpService=e,i.storageService=r,i.host=a,i.registering=!1,i.authenticating=!1,i.changing=!1,i.refreshingSession=!1,i}return y(n,[{key:"deinit",value:function(){this.httpService=void 0,this.storageService=void 0,this.invalidSessionObserver=void 0,this.session=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"setInvalidSessionObserver",value:function(e){this.invalidSessionObserver=e}},{key:"loadHost",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ServerHost));case 2:e=t.sent,this.host=e||this.host||window._default_sync_server;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.host=e,t.next=3,b.awrap(this.storageService.setValue(o.ServerHost,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.host}},{key:"isThirdPartyHostUsed",value:function(){return!Ut(this.getHost()||'')}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],this.session=e,!t){r.next=5;break}return r.next=5,b.awrap(this.storageService.setValue(o.Session,e));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSession",value:function(){return this.session}},{key:"params",value:function(e){var t=Z()(e,g({},Tt.a.ApiVersion,this.apiVersion));return t}},{key:"createErrorResponse",value:function(e,t){return{error:{message:e,status:t}}}},{key:"errorResponseWithFallbackMessage",value:function(e,t){var n,r,a;null!==(n=e.error)&&void 0!==n&&n.message||(e.error=Bt(Bt({},e.error),{},{status:null!==(r=null===(a=e.error)||void 0===a?void 0:a.status)&&void 0!==r?r:Te.b.UnknownError,message:t}));return e}},{key:"processMetaObject",value:function(e){e.auth&&e.auth.userUuid&&e.auth.roles&&this.notifyEvent(Ht.MetaReceived,{userUuid:e.auth.userUuid,userRoles:e.auth.roles})}},{key:"processResponse",value:function(e){e.meta&&this.processMetaObject(e.meta)}},{key:"request",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.awrap(this.httpService.runHttp(e));case 3:return t=n.sent,this.processResponse(t),n.abrupt("return",t);case 8:return n.prev=8,n.t0=n.catch(0),n.abrupt("return",this.errorResponseWithFallbackMessage(n.t0,e.fallbackErrorMessage));case 11:case"end":return n.stop()}},null,this,[[0,8]],Promise)}},{key:"getAccountKeyParams",value:function(e,t,n){var r,a=this.params({email:e});return t&&n&&(a[t]=n),this.request({verb:Pt.Get,url:Object(_.D)(this.host,zt.keyParams),fallbackErrorMessage:j.k,params:a,authentication:null===(r=this.session)||void 0===r?void 0:r.authorizationValue})}},{key:"register",value:function(e,t,n,r){var a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.registering){o.next=2;break}return o.abrupt("return",this.createErrorResponse(j.r));case 2:return this.registering=!0,a=Object(_.D)(this.host,zt.register),i=this.params(Bt({password:t,email:e,ephemeral:r},n.getPortableValue())),o.next=7,b.awrap(this.request({verb:Pt.Post,url:a,fallbackErrorMessage:j.l,params:i}));case 7:return s=o.sent,this.registering=!1,o.abrupt("return",s);case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t,n,r){var a,i,s,o,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>4&&void 0!==c[4]&&c[4],!this.authenticating){u.next=3;break}return u.abrupt("return",this.createErrorResponse(j.p));case 3:return this.authenticating=!0,i=Object(_.D)(this.host,zt.signIn),s=this.params({email:e,password:t,ephemeral:a}),n&&r&&(s[n]=r),u.next=9,b.awrap(this.request({verb:Pt.Post,url:i,params:s,fallbackErrorMessage:j.k}));case 9:return o=u.sent,this.authenticating=!1,u.abrupt("return",o);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e=Object(_.D)(this.host,zt.signOut);return this.httpService.postAbsolute(e,void 0,this.session.authorizationValue).catch(function(e){return e})}},{key:"changeCredentials",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.changing){s.next=2;break}return s.abrupt("return",this.createErrorResponse(j.a));case 2:if(!(t=this.preprocessingError())){s.next=5;break}return s.abrupt("return",t);case 5:return this.changing=!0,n=Object(_.D)(this.host,zt.changeCredentials(e.userUuid)),r=this.params(Bt({current_password:e.currentServerPassword,new_password:e.newServerPassword,new_email:e.newEmail},e.newKeyParams.getPortableValue())),s.next=10,b.awrap(this.httpService.putAbsolute(n,r,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Object(Te.c)(e)){t.next=2;break}return t.abrupt("return",i.refreshSessionThenRetryRequest({verb:Pt.Put,url:n,params:r}));case 2:return t.abrupt("return",i.errorResponseWithFallbackMessage(e,j.j));case 3:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return a=s.sent,this.processResponse(a),this.changing=!1,s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"sync",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=this,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:if(i=h.length>4&&void 0!==h[4]&&h[4],s=h.length>5?h[5]:void 0,o=h.length>6?h[6]:void 0,!(c=this.preprocessingError())){f.next=6;break}return f.abrupt("return",c);case 6:return u=Object(_.D)(this.host,zt.sync),l=this.params((g(a={},Tt.a.SyncPayloads,e.map(function(e){return e.ejected()})),g(a,Tt.a.LastSyncToken,t),g(a,Tt.a.PaginationToken,n),g(a,Tt.a.IntegrityCheck,i),g(a,Tt.a.SyncDlLimit,r),g(a,"content_type",s),g(a,"event",o),a)),f.next=10,b.awrap(this.httpService.postAbsolute(u,l,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(d.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){t.next=3;break}return t.abrupt("return",d.refreshSessionThenRetryRequest({verb:Pt.Post,url:u,params:l}));case 3:return t.abrupt("return",d.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return p=f.sent,this.processResponse(p),f.abrupt("return",p);case 13:case"end":return f.stop()}},null,this,null,Promise)}},{key:"refreshSessionThenRetryRequest",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.refreshSession());case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=7;break}return n.abrupt("return",t);case 7:return n.abrupt("return",this.httpService.runHttp(Bt(Bt({},e),{},{authentication:this.session.authorizationValue})).catch(function(e){return e}));case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"refreshSession",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(e=this.preprocessingError())){s.next=3;break}return s.abrupt("return",e);case 3:return this.refreshingSession=!0,t=Object(_.D)(this.host,zt.refreshSession),n=this.session,r=this.params({access_token:n.accessToken,refresh_token:n.refreshToken}),s.next=9,b.awrap(this.httpService.postAbsolute(t,r).then(function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=je.FromApiResponse(e),n.next=3,b.awrap(i.setSession(t));case 3:return i.processResponse(e),n.abrupt("return",e);case 5:case"end":return n.stop()}},null,null,null,Promise)}).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),i.errorResponseWithFallbackMessage(e,j.n)}));case 9:return a=s.sent,this.refreshingSession=!1,s.abrupt("return",a);case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e=this.preprocessingError())){a.next=3;break}return a.abrupt("return",e);case 3:return t=Object(_.D)(this.host,zt.sessions),a.next=6,b.awrap(this.httpService.getAbsolute(t,{},this.session.authorizationValue).catch(function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){n.next=3;break}return n.abrupt("return",r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}));case 3:return n.abrupt("return",r.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return n.stop()}},null,null,null,Promise)}));case 6:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSession",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.session(e)),i.next=6,b.awrap(this.httpService.deleteAbsolute(n,{uuid:e},this.session.authorizationValue).catch(function(e){var t=e;return a.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?a.refreshSessionThenRetryRequest({verb:Pt.Delete,url:n}):a.errorResponseWithFallbackMessage(t,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getItemRevisions",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.itemRevisions(e)),i.next=6,b.awrap(this.httpService.getAbsolute(n,void 0,this.session.authorizationValue).catch(function(e){return a.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?a.refreshSessionThenRetryRequest({verb:Pt.Get,url:n}):a.errorResponseWithFallbackMessage(e,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getRevision",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(n=this.preprocessingError())){s.next=3;break}return s.abrupt("return",n);case 3:return r=Object(_.D)(this.host,zt.itemRevision(t,e.uuid)),s.next=6,b.awrap(this.httpService.getAbsolute(r,void 0,this.session.authorizationValue).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?i.refreshSessionThenRetryRequest({verb:Pt.Get,url:r}):i.errorResponseWithFallbackMessage(e,j.m)}));case 6:return a=s.sent,this.processResponse(a),s.abrupt("return",a);case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getUserFeatures",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=Object(_.D)(this.host,zt.userFeatures(e)),a.next=3,b.awrap(this.httpService.getAbsolute(t,void 0,this.session.authorizationValue).catch(function(e){return r.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}):r.errorResponseWithFallbackMessage(e,j.m)}));case 3:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"tokenRefreshableRequest",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(t=this.preprocessingError())){a.next=3;break}return a.abrupt("return",t);case 3:return a.next=5,b.awrap(this.httpService.runHttp(e).catch(function(t){return r.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?r.refreshSessionThenRetryRequest(e):r.errorResponseWithFallbackMessage(t,e.fallbackErrorMessage)}));case 5:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"listSettings",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.settings(e)),fallbackErrorMessage:j.d,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n,r){var a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return i={name:t,value:n,sensitive:r},s.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Put,url:Object(_.D)(this.host,zt.settings(e)),authentication:null===(a=this.session)||void 0===a?void 0:a.authorizationValue,fallbackErrorMessage:j.h,params:i}));case 2:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.setting(e,t.toLowerCase())),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.d}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Delete,url:Object(_.D)(this.host,zt.setting(e,t)),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.h}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"downloadFeatureUrl",value:function(e){return this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.k})}},{key:"getSubscription",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscription(e)),a.next=3,b.awrap(this.request({verb:Pt.Get,url:n,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue,fallbackErrorMessage:j.g}));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=Object(_.D)(this.host,qt.subscriptions),n.next=3,b.awrap(this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.g}));case 3:return t=n.sent,n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getNewSubscriptionToken",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscriptionTokens),a.next=3,b.awrap(this.request({verb:Pt.Post,url:n,authentication:null===(e=this.session)||void 0===e?void 0:e.authorizationValue,fallbackErrorMessage:j.b}));case 3:return r=a.sent,a.abrupt("return",null===(t=r.data)||void 0===t?void 0:t.token);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"downloadOfflineFeaturesFromRepo",value:function(e){var t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,n=e.offlineFeaturesUrl,r=e.offlineKey,a=new URL(n),i=a.host,Ft.includes(i)){o.next=6;break}return o.abrupt("return",{error:'This offline features host is not in the trusted allowlist.'});case 6:return o.next=8,b.awrap(this.request({verb:Pt.Get,url:n,fallbackErrorMessage:j.f,customHeaders:[{key:'x-offline-token',value:r}]}));case 8:return s=o.sent,o.abrupt("return",{features:(null===(t=s.data)||void 0===t?void 0:t.features)||[]});case 12:return o.prev=12,o.t0=o.catch(0),o.abrupt("return",{error:j.e});case 15:case"end":return o.stop()}},null,this,[[0,12]],Promise)}},{key:"preprocessingError",value:function(){return this.refreshingSession?this.createErrorResponse(j.s):this.session?void 0:this.createErrorResponse(j.o)}},{key:"preprocessAuthenticatedErrorResponse",value:function(e){var t,n;e.status===Te.b.HttpStatusInvalidSession&&this.session&&(null===(t=this.invalidSessionObserver)||void 0===t||t.call(this,(null===(n=e.error)||void 0===n?void 0:n.tag)===Ot.RevokedSession))}},{key:"apiVersion",get:function(){return"20200115"}}]),n})(R.a),Gt=n(25),Qt=n.n(Gt),Jt=n(28),$t=n.n(Jt);function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach(function(t){en(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tn,nn=Object.freeze([F.a.ActionsExtension,F.a.Component,F.a.Editor,F.a.ExtensionRepo,F.a.FilesafeCredentials,F.a.FilesafeFileMetadata,F.a.FilesafeIntegration,F.a.ServerExtension,F.a.SmartTag,F.a.Tag,F.a.Theme]),rn='org.standardnotes.sn.components';!(function(e){e.Shift="Shift",e.Ctrl="Control",e.Meta="Meta"})(tn||(tn={}));var an=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).componentState={},c.streamObservers=[],c.contextStreamObservers=[],c.permissionDialogs=[],c.handlers=[],c.templateComponents=[],c.detectFocusChange=function(){for(var e,t=function(e){if(document.activeElement===e)return c.timeout(function(){for(var t,n=c.findComponent(e.dataset.componentId),r=S(c.handlers);!(t=r()).done;){var a=t.value;a.focusHandler&&a.focusHandler(n,!0)}}),"break"},n=S(c.allComponentIframes());!(e=n()).done;){if("break"===t(e.value))break}},c.onWindowMessage=function(e){e.data.sessionKey&&(c.log('Component manager received message',e.data),c.handleMessage(c.componentForSessionKey(e.data.sessionKey),e.data))},c.timeout=o||setTimeout.bind(window),c.itemManager=e,c.syncService=r,c.alertService=a,c.environment=i,c.platform=s,c.configureForGeneralUsage(),i!==he.Mobile&&c.configureForNonMobileUsage(),c}return y(n,[{key:"componentsForArea",value:function(e){return this.components.filter(function(t){return t.area===e})}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.streamObservers.length=0,this.contextStreamObservers.length=0,this.permissionDialogs.length=0,this.templateComponents.length=0,this.handlers.length=0,this.itemManager=void 0,this.syncService=void 0,this.alertService=void 0,this.removeItemObserver(),this.removeItemObserver=null,window&&!this.isMobile&&(window.removeEventListener('focus',this.detectFocusChange,!0),window.removeEventListener('blur',this.detectFocusChange,!0),window.removeEventListener('message',this.onWindowMessage))}},{key:"setDesktopManager",value:function(e){this.desktopManager=e,this.configureForDesktop()}},{key:"configureForGeneralUsage",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n,r,a,i,s){var o=Object(_.h)(t,n,r),c=o.filter(function(e){return e.content_type===F.a.Component||e.content_type===F.a.Theme});c.length>0&&i!==ht.a.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(c),c.filter(function(e){return e.isTheme()}).length>0&&e.postActiveThemesToAllComponents();for(var u,l=S(c);!(u=l()).done;){var p=u.value;if(!p.isEditor()){var d=!!e.iframeForComponent(p.uuid);!p.active&&d&&e.deactivateComponent(p.uuid)}}e.notifyStreamObservers(o,i,s)})}},{key:"notifyStreamObservers",value:function(e,t,n){for(var r,a=this,i=function(t){if(n&&n===t.componentUuid)return"continue";var r=e.filter(function(e){return-1!==t.contentTypes.indexOf(e.content_type)});if(0===r.length)return"continue";var i=[{name:E.StreamItems,content_types:t.contentTypes.sort()}];a.runWithPermissions(t.componentUuid,i,function(){a.sendItemsInReply(t.componentUuid,r,t.originalMessage)})},s=S(this.streamObservers);!(r=s()).done;)i(r.value);for(var o,c=[{name:E.StreamContextItem}],u=function(r){if(n&&n===r.componentUuid)return"continue";for(var i,s=S(a.handlers);!(i=s()).done;){var o=i.value;if((o.areas.includes(r.area)||o.areas.includes(L.ComponentArea.Any))&&o.contextRequestHandler){var u=o.contextRequestHandler(r.componentUuid);if(u)if("continue"===(function(){var n=Qt()(e,{uuid:u.uuid});if(n){if(n.deleted)return"continue";a.runWithPermissions(r.componentUuid,c,function(){a.sendContextItemInReply(r.componentUuid,n,r.originalMessage,t)})}})())continue}}},l=S(this.contextStreamObservers);!(o=l()).done;)u(o.value)}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location],n=e.hosted_url,r=e.local_url&&e.local_url.replace("sn://",'');return t.includes(n)||t.includes(r)}},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener('focus',this.detectFocusChange,!0):window.attachEvent('onfocusout',this.detectFocusChange),window.addEventListener?window.addEventListener('blur',this.detectFocusChange,!0):window.attachEvent('onblur',this.detectFocusChange),window.addEventListener('message',this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver(function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()})}},{key:"postActiveThemesToAllComponents",value:function(){for(var e,t=S(this.components);!(e=t()).done;){var n=e.value;this.findOrCreateDataForComponent(n.uuid).window&&this.postActiveThemesToComponent(n)}}},{key:"getActiveThemes",value:function(){if(this.environment===he.Mobile)throw Error('getActiveThemes must be handled separately by mobile');return this.componentsForArea(L.ComponentArea.Themes).filter(function(e){return e.active})}},{key:"urlsForActiveThemes",value:function(){for(var e,t=[],n=S(this.getActiveThemes());!(e=n()).done;){var r=e.value,a=this.urlForComponent(r);a&&t.push(a)}return t}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()},n={action:E.ActivateThemes,data:t};this.sendMessageToComponent(e,n)}},{key:"findComponent",value:function(e){return this.templateComponents.find(function(t){return t.uuid===e})||this.itemManager.findItem(e)}},{key:"addTemporaryTemplateComponent",value:function(e){this.templateComponents.push(e)}},{key:"removeTemporaryTemplateComponent",value:function(e){this.templateComponents=this.templateComponents.filter(function(t){return t.uuid!==e.uuid})}},{key:"contextItemDidChangeInArea",value:function(e){for(var t,n=S(this.handlers);!(t=n()).done;){var r=t.value;if(r.areas.includes(e)||r.areas.includes(L.ComponentArea.Any))for(var a,i=S(this.contextStreamObservers.filter(function(t){return t.area===e}));!(a=i()).done;){var s=a.value;if(r.contextRequestHandler){var o=r.contextRequestHandler(s.componentUuid);o&&this.sendContextItemInReply(s.componentUuid,o,s.originalMessage)}}}}},{key:"isComponentHidden",value:function(e){return!0===this.findOrCreateDataForComponent(e.uuid).hidden}},{key:"setComponentHidden",value:function(e,t){var n=this.findOrCreateDataForComponent(e.uuid);if(t)n.hidden=!0;else if(n.hidden){n.hidden=!1;var r=Qt()(this.contextStreamObservers,{identifier:e.uuid});r&&this.handleStreamContextItemMessage(e,r.originalMessage);var a=Qt()(this.streamObservers,{identifier:e.uuid});a&&this.handleStreamItemsMessage(e,a.originalMessage)}}},{key:"jsonForItem",value:function(e,t,n){var r=n===ht.a.RemoteSaved||n===ht.a.LocalSaved||n===ht.a.PreSyncSave,a=(e.getDomainData(rn)||{})[t.getClientDataKey()]||{},i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.serverUpdatedAt,deleted:e.deleted,isMetadataUpdate:r,content:e.content,clientData:a};return this.responseItemsByRemovingPrivateProperties([i],t)[0]}},{key:"sendItemsInReply",value:function(e,t,n,r){var a=this,i=this.findComponent(e);this.log('Component manager send items in reply',i,t,n);var s={},o=t.map(function(e){return a.jsonForItem(e,i,r)});s.items=o,this.replyToMessage(i,n,s)}},{key:"sendContextItemInReply",value:function(e,t,n,r){var a=this.findComponent(e);this.log('Component manager send context item in reply','component:',a,'item: ',t,'originalMessage: ',n);var i={item:this.jsonForItem(t,a,r)};this.replyToMessage(a,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:E.Reply,original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n,r=[E.ComponentRegistered,E.ActivateThemes],a=this.findOrCreateDataForComponent(e.uuid);if(!a.hidden||r.includes(t.action))if(a.window||t.action!==E.Reply){this.log('Component manager send message to component',e,'message: ',t);var i=this.urlForComponent(e);i&&a.window?(i.startsWith('http')||i.startsWith('file')||(i=window.location.href+i),null===(n=a.window)||void 0===n||n.postMessage(this.isMobile?JSON.stringify(t):t,i)):this.alertService.alert("Standard Notes is trying to communicate with ".concat(e.name,", ")+'but an error is occurring. Please restart this extension and try again.')}else this.log('Component has been deallocated in between message send and reply',e,t);else this.log('Component disabled for current item, ignoring messages.',e.name)}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(!t)return null;if(this.isMobile){var n=this.platform===fe.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter(function(t){return t.hosted_url===e||t.legacy_url===e})[0]}},{key:"sessionKeyForComponent",value:function(e){return this.findOrCreateDataForComponent(e.uuid).sessionKey}},{key:"componentForSessionKey",value:function(e){for(var t,n=this,r=function(r){var a=n.componentState[r];if((null===a||void 0===a?void 0:a.sessionKey)===e)return t=n.components.find(function(e){return e.uuid===r}),"break"},a=0,i=Object.keys(this.componentState);a<i.length;a++){if("break"===r(i[a]))break}if(!t)for(var s,o=S(this.handlers);!(s=o()).done;){var c=s.value;if(c.componentForSessionKeyHandler&&(t=c.componentForSessionKeyHandler(e)))break}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log('Component not defined for message, returning',t),void this.alertService.alert("An extension is trying to communicate with Standard Notes, but there is an error establishing a bridge. Please restart the app and try again.");var r=[E.SaveItems,E.AssociateItem,E.DeassociateItem,E.CreateItem,E.CreateItems,E.DeleteItems,E.SetComponentData];if(this.getReadonlyStateForComponent(e).readonly&&r.includes(t.action))this.alertService.alert("The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes."));else{if(t.action===E.StreamItems)this.handleStreamItemsMessage(e,t);else if(t.action===E.StreamContextItem)this.handleStreamContextItemMessage(e,t);else if(t.action===E.SetComponentData)this.handleSetComponentDataMessage(e,t);else if(t.action===E.DeleteItems)this.handleDeleteItemsMessage(e,t);else if(t.action===E.CreateItems||t.action===E.CreateItem)this.handleCreateItemsMessage(e,t);else if(t.action===E.SaveItems)this.handleSaveItemsMessage(e,t);else if(t.action===E.ToggleActivateComponent){var a=this.itemManager.findItem(t.data.uuid);this.handleToggleComponentMessage(a)}else t.action===E.RequestPermissions?this.handleRequestPermissionsMessage(e,t):t.action===E.InstallLocalComponent?this.handleInstallLocalComponentMessage(e,t):t.action===E.DuplicateItem&&this.handleDuplicateItemMessage(e,t);for(var i,s=function(r){r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes(L.ComponentArea.Any))&&n.timeout(function(){r.actionHandler(e,t.action,t.data)})},o=S(this.handlers);!(i=o()).done;){s(i.value)}}}},{key:"responseItemsByRemovingPrivateProperties",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&this.isNativeExtension(t))return e;var r=['autoupdateDisabled','permissions','active'];return n&&(r=r.concat(['hosted_url','local_url'])),e.map(function(e){var t=r.slice();if(n&&e.content_type!==F.a.ServerExtension&&t.push('url'),!e.content||Object(_.A)(e.content))return e;for(var a={},i=0,s=Object.entries(e.content);i<s.length;i++){var o=s[i],c=l(o,2),u=c[0],p=c[1];t.includes(u)||(a[u]=p)}return Zt(Zt({},e),{},{content:a})})}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=t.data.content_types.filter(function(e){return nn.includes(e)}).sort(),a=[{name:E.StreamItems,content_types:r}];this.runWithPermissions(e.uuid,a,function(){Qt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t,contentTypes:r});for(var a,i=[],s=S(r);!(a=s()).done;){var o=a.value;Object(_.o)(i,n.itemManager.nonErroredItemsForContentType(o))}n.sendItemsInReply(e.uuid,i,t)})}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:E.StreamContextItem}];this.runWithPermissions(e.uuid,r,function(){Qt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t});for(var r,a=S(n.handlersForArea(e.area));!(r=a()).done;){var i=r.value;if(i.contextRequestHandler){var s=i.contextRequestHandler(e.uuid);s&&n.sendContextItemInReply(e.uuid,s,t)}}})}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){for(var t,n=[],r=S(this.handlersForArea(e.area));!(t=r()).done;){var a=t.value;if(a.contextRequestHandler){var i=a.contextRequestHandler(e.uuid);i&&n.push(i.uuid)}}return n}},{key:"handlersForArea",value:function(e){return this.handlers.filter(function(t){return t.areas.includes(e)})}},{key:"handleSaveItemsMessage",value:function(e,t){for(var n,r=this,a=t.data.items,i=[],s=this.itemIdsInContextJurisdictionForComponent(e),o=a.slice(),c=S(a.slice());!(n=c()).done;){var u=n.value;if(s.includes(u.uuid)){i.push({name:E.StreamContextItem}),Object(_.M)(o,u);break}}if(o.length>0){var l=$t()(o.map(function(e){return e.content_type})).sort();i.push({name:E.StreamItems,content_types:l})}this.runWithPermissions(e.uuid,i,function(){var n,i,s,o,c,u,l,p,d,h,f,v,y,g,m;return b.async(function(k){for(;;)switch(k.prev=k.next){case 0:a=r.responseItemsByRemovingPrivateProperties(a,e,!0),n=Object(Ke.b)(a),i=r.itemManager.findItems(n,!0),s=0,o=0,c=S(i);case 6:if((u=c()).done){k.next=13;break}if(l=u.value){k.next=10;break}return k.abrupt("continue",11);case 10:l.locked&&(at()(a,{uuid:l.uuid}),s++,l.content_type===F.a.Note&&o++);case 11:k.next=6;break;case 13:if(1!==o){k.next=18;break}return r.alertService.alert('The note you are attempting to save has editing disabled','Note has Editing Disabled'),k.abrupt("return");case 18:if(!(s>0)){k.next=23;break}return p=1===s?'item':o===s?'notes':'items',d=1===s?'has':'have',r.alertService.alert("".concat(s," ").concat(p," you are attempting to save ").concat(d," editing disabled."),'Items have Editing Disabled'),k.abrupt("return");case 23:h=a.map(function(e){return Object(Ee.f)(e,ht.a.ComponentRetrieved)}),f=S(h);case 25:if((v=f()).done){k.next=38;break}if(y=v.value,g=r.itemManager.findItem(y.uuid)){k.next=34;break}return m=nt(y),k.next=32,b.awrap(r.itemManager.insertItem(m));case 32:k.next=36;break;case 34:if(y.content_type===g.content_type){k.next=36;break}throw Error('Extension is trying to modify content type of item.');case 36:k.next=25;break;case 38:return k.next=40,b.awrap(r.itemManager.changeItems(n,function(t){var n=Object(_.O)(h,{uuid:t.getUuid()});t.mergePayload(n);var r=Object(_.O)(a,{uuid:t.getUuid()});if(r.clientData){var i=Object(_.a)(t.getItem().getDomainData(rn)||{});i[e.getClientDataKey()]=r.clientData,t.setDomainData(i,rn)}},T.c.UserInteraction,ht.a.ComponentRetrieved,e.uuid));case 40:r.syncService.sync().then(function(){var n=w({},t);n.action=E.SaveSuccess,r.replyToMessage(e,t,{}),r.handleMessage(e,n)}).catch(function(){var n=w({},t);n.action=E.SaveError,r.replyToMessage(e,t,{error:E.SaveError}),r.handleMessage(e,n)});case 41:case"end":return k.stop()}},null,null,null,Promise)})}},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,a=this.itemManager.findItem(r.uuid),i=[{name:E.StreamItems,content_types:[a.content_type]}];this.runWithPermissions(e.uuid,i,function(){var r;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(n.itemManager.duplicateItem(a.uuid));case 2:r=i.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(r,e)});case 5:case"end":return i.stop()}},null,null,null,Promise)})}},{key:"handleCreateItemsMessage",value:function(e,t){var n=this,r=t.data.item?[t.data.item]:t.data.items,a=$t()(r.map(function(e){return e.content_type})),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:r=n.responseItemsByRemovingPrivateProperties(r,e),a=[],i=function(t){var r,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(t.uuid){o.next=4;break}return o.next=3,b.awrap(I.GenerateUuid());case 3:t.uuid=o.sent;case 4:return r=Object(Ee.f)(t,ht.a.ComponentCreated),i=nt(r),o.next=8,b.awrap(n.itemManager.insertItem(i));case 8:return s=o.sent,o.next=11,b.awrap(n.itemManager.changeItem(s.uuid,function(n){if(t.clientData){var r=Object(_.a)(s.getDomainData(rn)||{});r[e.getClientDataKey()]=t.clientData,n.setDomainData(r,rn)}},T.c.UserInteraction,ht.a.ComponentCreated,e.uuid));case 11:a.push(s);case 12:case"end":return o.stop()}},null,null,null,Promise)},s=S(r);case 4:if((o=s()).done){l.next=10;break}return c=o.value,l.next=8,b.awrap(i(c));case 8:l.next=4;break;case 10:n.syncService.sync(),u=t.action===E.CreateItem?{item:n.jsonForItem(a[0],e)}:{items:a.map(function(t){return n.jsonForItem(t,e)})},n.replyToMessage(e,t,u);case 13:case"end":return l.stop()}},null,null,null,Promise)})}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=t.data.items.filter(function(e){return nn.includes(e.content_type)}),a=$t()(r.map(function(e){return e.content_type})).sort(),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return i=1===(a=r).length?'item':'items',s=null,p.next=5,b.awrap(n.alertService.confirm("Are you sure you want to delete ".concat(a.length," ").concat(i,"?")));case 5:if(!p.sent){p.next=25;break}o=S(a);case 8:if((c=o()).done){p.next=21;break}if(u=c.value,l=n.itemManager.findItem(u.uuid)){p.next=14;break}return n.alertService.alert('The item you are trying to delete cannot be found.'),p.abrupt("continue",19);case 14:if(![F.a.Component,F.a.Theme].includes(l.content_type)){p.next=17;break}return p.next=17,b.awrap(n.deactivateComponent(l.uuid));case 17:return p.next=19,b.awrap(n.itemManager.setItemToBeDeleted(l.uuid,ht.a.ComponentRetrieved));case 19:p.next=8;break;case 21:n.syncService.sync(),s={deleted:!0},p.next=26;break;case 25:s={deleted:!1};case 26:n.replyToMessage(e,t,s);case 27:case"end":return p.stop()}},null,null,null,Promise)})}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,t.data.permissions,function(){n.replyToMessage(e,t,{approved:!0})})}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,[],function(){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(n.itemManager.changeComponent(e.uuid,function(e){e.componentData=t.data.componentData}));case 2:n.syncService.sync();case 3:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"handleToggleComponentMessage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.toggleComponent(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"toggleComponent",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.area!==L.ComponentArea.Modal){s.next=4;break}this.openModalComponent(e),s.next=29;break;case 4:if(!e.active){s.next=9;break}return s.next=7,b.awrap(this.deactivateComponent(e.uuid));case 7:s.next=29;break;case 9:if(e.content_type!==F.a.Theme){s.next=27;break}return t=e,n=this.getActiveThemes(),s.next=14,b.awrap(this.activateComponent(e.uuid));case 14:if(t.isLayerable()){s.next=25;break}return s.next=17,b.awrap(Object(_.P)(10));case 17:r=S(n);case 18:if((a=r()).done){s.next=25;break}if(!(i=a.value)||i.isLayerable()){s.next=23;break}return s.next=23,b.awrap(this.deactivateComponent(i.uuid));case 23:s.next=18;break;case 25:s.next=29;break;case 27:return s.next=29,b.awrap(this.activateComponent(e.uuid));case 29:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.itemManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){var r=this.findComponent(e);t=Object(_.a)(t);for(var a,i=r.permissions,s=function(e){var n=i.find(function(t){return t.name===e.name});if(!n)return"continue";var r=e.content_types;if(!r)return Object(_.p)(t,e),"continue";for(var a,s=S(n.content_types);!(a=s()).done;){var o=a.value;Object(_.M)(r,o)}0===r.length&&Object(_.p)(t,e)},o=S(t.slice());!(a=o()).done;)s(a.value);t.length>0?this.promptForPermissions(r,t,function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:e&&n();case 1:case"end":return t.stop()}},null,null,null,Promise)}):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,a={component:e,permissions:t,permissionsString:this.permissionsStringForPermissions(t,e),actionBlock:n,callback:function(n){var i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(i=r.findComponent(e.uuid),!n){p.next=9;break}for(r.log('Changing component to expand permissions',e),s=Object(_.a)(i.permissions),o=function(e){var t=s.find(function(t){return t.name===e.name});if(t){var n=t.content_types||[];t.content_types=$t()(n.concat(e.content_types))}else s.push(e)},c=S(t);!(u=c()).done;)l=u.value,o(l);return p.next=8,b.awrap(r.itemManager.changeItem(e.uuid,function(e){e.permissions=s}));case 8:r.syncService.sync();case 9:r.permissionDialogs=r.permissionDialogs.filter(function(r){if(r===a)return r.actionBlock&&r.actionBlock(n),!1;var i;return!!(r.component!==e||r.permissions!==t&&(i=t,r.permissions.some(function(e){return!i.find(function(t){return JSON.stringify(t)===JSON.stringify(e)})})))||(n&&r.actionBlock&&r.actionBlock(n),!1)}),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 11:case"end":return p.stop()}},null,null,null,Promise)}},i=Qt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(a),i?this.log('Existing dialog, not presenting.'):this.presentPermissionsDialog(a)}},{key:"presentPermissionsDialog",value:function(e){throw'Must override SNComponentManager.presentPermissionsDialog'}},{key:"openModalComponent",value:function(e){throw'Must override SNComponentManager.openModalComponent'}},{key:"registerHandler",value:function(e){var t=this;return this.handlers.push(e),function(){var n=Qt()(t.handlers,{identifier:e.identifier});n?Object(_.M)(t.handlers,n):t.log('Attempting to deregister non-existing handler')}}},{key:"findOrCreateDataForComponent",value:function(e){var t=this.componentState[e];return t||(t={},this.componentState[e]=t),t}},{key:"setReadonlyStateForComponent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.findOrCreateDataForComponent(e.uuid);r.readonly=t,r.lockReadonly=n}},{key:"getReadonlyStateForComponent",value:function(e){var t=this.findOrCreateDataForComponent(e.uuid);return{readonly:t.readonly,lockReadonly:t.lockReadonly}}},{key:"registerComponentWindow",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return(n=this.findOrCreateDataForComponent(e.uuid)).window===t&&this.log('Web > componentManager','attempting to re-register same component window.'),this.log('Web > componentManager > registerComponentWindow','component: ',e,'window: ',t),n.window=t,r.next=6,b.awrap(I.GenerateUuid());case 6:n.sessionKey=r.sent,this.sendMessageToComponent(e,{action:E.ComponentRegistered,sessionKey:n.sessionKey,componentData:e.componentData,data:{uuid:e.uuid,environment:(s=this.environment,o=void 0,(g(o={},he.Web,'web'),g(o,he.Desktop,'desktop'),g(o,he.Mobile,'mobile'),o)[s]),platform:(a=this.platform,i=void 0,(g(i={},fe.MacWeb,'mac-web'),g(i,fe.MacDesktop,'mac-desktop'),g(i,fe.LinuxWeb,'linux-web'),g(i,fe.LinuxDesktop,'linux-desktop'),g(i,fe.WindowsWeb,'windows-web'),g(i,fe.WindowsDesktop,'windows-desktop'),g(i,fe.Ios,'ios'),g(i,fe.Android,'android'),i)[a]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(e),this.desktopManager&&this.desktopManager.notifyComponentActivation(e);case 10:case"end":return r.stop()}var a,i,s,o},null,this,null,Promise)}},{key:"activateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Activating component',e),(t=this.findComponent(e)).active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!0}));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"onComponentIframeDestroyed",value:function(e){this.deregisterComponent(e)}},{key:"deregisterComponent",value:function(e){this.log('Degregistering component',e),delete this.componentState[e],this.streamObservers=this.streamObservers.filter(function(t){return t.componentUuid!==e}),this.contextStreamObservers=this.contextStreamObservers.filter(function(t){return t.componentUuid!==e});var t=this.findComponent(e);(null===t||void 0===t?void 0:t.area)===L.ComponentArea.Themes&&this.postActiveThemesToAllComponents()}},{key:"deactivateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Deactivating component',e),null===(t=this.findComponent(e))||void 0===t||!t.active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!1}));case 5:this.findOrCreateDataForComponent(e).sessionKey=void 0,this.deregisterComponent(e);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deleteComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isComponentActive",value:function(e){return e.active}},{key:"allComponentIframes",value:function(){return this.isMobile?[]:Array.from(document.getElementsByTagName('iframe'))}},{key:"iframeForComponent",value:function(e){for(var t,n=S(this.allComponentIframes());!(t=n()).done;){var r=t.value;if(r.dataset.componentId===e)return r}}},{key:"handleSetSizeEvent",value:function(e,t){var n=function(e,n){var r=Object(_.A)(n.width)?n.width:"".concat(t.width,"px"),a=Object(_.A)(n.height)?n.height:"".concat(t.height,"px");e&&e.setAttribute('style',"width:".concat(r,"; height:").concat(a,";"))};if(e.area===L.ComponentArea.Rooms||e.area===L.ComponentArea.Modal){var r=e.area===L.ComponentArea.Rooms?'inner':'outer',a=document.getElementById("component-content-".concat(r,"-").concat(e.uuid));a&&n(a,t)}else{var i=this.iframeForComponent(e.uuid);if(!i)return;if(n(i,t),e.area===L.ComponentArea.EditorStack){var s=i.parentElement;s&&n(s,t)}}}},{key:"editorForNote",value:function(e){for(var t,n,r=S(this.componentsForArea(L.ComponentArea.Editor));!(t=r()).done;){var a=t.value;if(a.isExplicitlyEnabledForItem(e.uuid))return a}return this.isMobile?e.mobilePrefersPlainEditor||(n=this.getDefaultEditor()):e.prefersPlainEditor||(n=this.getDefaultEditor()),n&&!n.isExplicitlyDisabledForItem(e.uuid)?n:void 0}},{key:"getDefaultEditor",value:function(){var e=this.componentsForArea(L.ComponentArea.Editor);return this.isMobile?e.filter(function(e){return e.isMobileDefault})[0]:e.filter(function(e){return e.isDefaultEditor()})[0]}},{key:"permissionsStringForPermissions",value:function(e,t){if(0===e.length)return'.';var n=[],r=[];return e.forEach(function(e){switch(e.name){case E.StreamItems:if(!e.content_types)return;e.content_types.forEach(function(e){var t=Object(F.c)(e);t?n.push("".concat(t,"s")):n.push("items of type ".concat(e))});break;case E.StreamContextItem:var a,i=(g(a={},L.ComponentArea.EditorStack,'working note'),g(a,L.ComponentArea.NoteTags,'working note'),g(a,L.ComponentArea.Editor,'working note'),a);r.push(i[t.area])}}),n=$t()(n),r=$t()(r),0===n.length&&0===r.length?'.':n.concat(r).join(', ')+'.'}},{key:"isDesktop",get:function(){return this.environment===he.Desktop}},{key:"isMobile",get:function(){return this.environment===he.Mobile}},{key:"components",get:function(){var e=this.itemManager.getDisplayableItems(F.a.Component),t=this.itemManager.getDisplayableItems(F.a.Theme);return e.concat(t)}}]),n})(R.a),sn=(function(e){d(n,e);var t=k(n);function n(){var e;return v(this,n),(e=t.call(this)).changeObservers=[],e.emitQueue=[],e.overwriteProtection=[F.a.ItemsKey],e.collection=new mt,e}return y(n,[{key:"getMasterCollection",value:function(){return bt.FromCollection(this.collection)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.changeObservers.length=0,this.resetState()}},{key:"resetState",value:function(){this.collection=new mt}},{key:"find",value:function(e){return this.collection.findAll(e)}},{key:"emitCollection",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.emitPayloads(e.all(),e.source,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"emitPayload",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.emitPayloads([e],t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitPayloads",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return 0===e.length&&console.warn('Attempting to emit 0 payloads.'),a.abrupt("return",new Promise(function(a){r.emitQueue.push({payloads:e,source:t,sourceKey:n,resolve:a}),1===r.emitQueue.length&&r.popQueue()}));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"popQueue",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=this.emitQueue[0],t=this.mergePayloadsOntoMaster(e.payloads),n=t.changed,r=t.inserted,a=t.discarded,i=t.ignored,this.notifyChangeObservers(n,r,a,i,e.source,e.sourceKey),Object(_.M)(this.emitQueue,e),e.resolve(n.concat(r,a)),this.emitQueue.length>0&&this.popQueue();case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"mergePayloadsOntoMaster",value:function(e){for(var t,n=[],r=[],a=[],i=[],s=S(e);!(t=s()).done;){var o=t.value;if(o.uuid&&o.content_type){var c=this.collection.find(o.uuid);if(o.errorDecrypting&&c&&!c.errorDecrypting&&this.overwriteProtection.includes(o.content_type))i.push(o);else{var u=c?Object(Ee.g)(c,o):o;u.discardable?(this.collection.discard(u),a.push(u)):(this.collection.set(u),c?n.push(u):r.push(u))}}else console.error('Payload is corrupt:',o)}return{changed:n,inserted:r,discarded:a,ignored:i}}},{key:"addObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var a={types:e,priority:r,callback:t};return this.changeObservers.push(a),function(){Object(_.M)(n.changeObservers,a)}}},{key:"notifyChangeObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return t.includes(F.a.Any)?e.slice():e.slice().filter(function(e){return t.includes(e.content_type)})},c=S(this.changeObservers.slice().sort(function(e,t){return e.priority<t.priority?-1:1}));!(s=c()).done;){var u=s.value;u.callback(o(e,u.types),o(t,u.types),o(n,u.types),o(r,u.types),a,i)}}},{key:"importPayloads",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new Dt(this.getMasterCollection(),bt.WithPayloads(e,ht.a.FileImport),void 0),r.next=3,b.awrap(t.resultingCollection());case 3:return n=r.sent,r.next=6,b.awrap(this.emitCollection(n));case 6:return r.abrupt("return",Object(Ke.b)(n.payloads));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removePayloadLocally",value:function(e){this.collection.discard(e)}}]),n})(R.a),on=n(9),cn=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).itemManager=e,a.syncService=r,a.resolveQueue=[],a.registeredPredicates=[],a.itemManager=e,a.syncService=r,a.addObservers(),a}return y(n,[{key:"deinit",value:function(){this.syncService=void 0,this.itemManager=void 0,this.resolveQueue.length=0,this.registeredPredicates.length=0,this.removeItemObserver(),this.removeItemObserver=void 0,this.removeSyncObserver(),this.removeSyncObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"popResolveQueue",value:function(){var e=this.resolveQueue.slice();return this.resolveQueue=[],e}},{key:"addObservers",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n){if(t.length>0){var r=t.filter(function(e){return e.errorDecryptingValueChanged});r.length>0&&(e.resolveQueue=e.resolveQueue.concat(r))}n.length>0&&(e.resolveQueue=e.resolveQueue.concat(n))}),this.removeSyncObserver=this.syncService.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==on.a.DownloadFirstSyncCompleted&&t!==on.a.FullSyncCompleted){n.next=3;break}return n.next=3,b.awrap(e.resolveSingletonsForItems(e.popResolveQueue(),t));case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"registerPredicate",value:function(e){this.registeredPredicates.push(e)}},{key:"validItemsMatchingPredicate",value:function(e){return this.itemManager.itemsMatchingPredicate(e).filter(function(e){return!e.errorDecrypting})}},{key:"resolveSingletonsForItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=this;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:n=function(e){for(var t,n=S(p.registeredPredicates);!(t=n()).done;){var r=t.value;if(e.satisfiesPredicate(r))return p.validItemsMatchingPredicate(r)}},r=function(e){return e.isSingleton?p.validItemsMatchingPredicate(e.singletonPredicate):null},a=function(e){var t=r(e);return t&&t.length>0?t:n(e)},i=[],s=S(e);case 5:if((o=s()).done){d.next=17;break}if(c=o.value,!i.includes(c)){d.next=9;break}return d.abrupt("continue",15);case 9:if(u=a(c),Object(_.o)(i,u||[]),u&&!(u.length<=1)){d.next=13;break}return d.abrupt("continue",15);case 13:return d.next=15,b.awrap(this.handleStrategy(u,c.singletonStrategy));case 15:d.next=5;break;case 17:if(!(i.length>0&&t===on.a.FullSyncCompleted)){d.next=20;break}return d.next=20,b.awrap(null===(l=this.syncService)||void 0===l?void 0:l.sync());case 20:case"end":return d.stop()}},null,this,null,Promise)}},{key:"handleStrategy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t===T.e.KeepEarliest){a.next=2;break}throw'Unhandled singleton strategy';case 2:return n=e.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at<t.created_at?-1:1}),r=Object(_.d)(n,0),a.next=6,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(r)));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"findSingleton",value:function(e){var t=this.validItemsMatchingPredicate(e);if(t.length>0)return t[0]}},{key:"findOrCreateSingleton",value:function(e,t,n){var r,a,i,s,o,c,u,l=this;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(r=this.findSingleton(e),Object(_.w)(r)){p.next=3;break}return p.abrupt("return",r);case 3:if(this.syncService.getLastSyncDate()){p.next=13;break}return i=this.itemManager.addObserver(t,function(t,n){if(n.length>0){var r=l.itemManager.subItemsMatchingPredicates(n,[e]);r.length>0&&(a=r[0])}}),p.next=7,b.awrap(this.syncService.sync());case 7:if(i(),!a){p.next=10;break}return p.abrupt("return",a);case 10:if(!((s=this.validItemsMatchingPredicate(e)).length>0)){p.next=13;break}return p.abrupt("return",s[0]);case 13:if(!(o=this.itemManager.itemsMatchingPredicate(e).filter(function(e){return e.errorDecrypting})).length){p.next=17;break}return p.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(o)));case 17:return p.t0=Object(Ee.e),p.next=20,b.awrap(I.GenerateUuid());case 20:return p.t1=p.sent,p.t2=t,p.t3=n,p.t4=new Date,p.t5={uuid:p.t1,content_type:p.t2,content:p.t3,dirty:!0,dirtiedDate:p.t4},c=(0,p.t0)(p.t5),p.next=28,b.awrap(this.itemManager.emitItemFromPayload(c));case 28:return u=p.sent,this.syncService.sync(),p.abrupt("return",u);case 31:case"end":return p.stop()}},null,this,null,Promise)}}]),n})(R.a);function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach(function(t){pn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dn,hn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c){var u;return v(this,n),(u=t.call(this)).itemManager=e,u.alertService=r,u.previousPasswords=[],u.itemManager=e,u.alertService=r,u.deviceInterface=a,u.httpService=i,u.payloadManager=s,u.protocolService=o,u.syncService=c,u.previousPasswords=[],u}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.alertService=void 0,this.deviceInterface=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.syncService=void 0,this.previousPasswords.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"getExtensions",value:function(){return this.itemManager.nonErroredItemsForContentType(F.a.ActionsExtension)}},{key:"extensionsInContextOfItem",value:function(e){return this.getExtensions().filter(function(t){return t.supported_types.includes(e.content_type)||t.actionsWithContextForItem(e).length>0})}},{key:"loadExtensionInContextOfItem",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n={content_type:t.content_type,item_uuid:t.uuid},u.next=3,b.awrap(this.httpService.getAbsolute(e.url,n).catch(function(e){return console.error('Error loading extension',e),null}));case 3:if(r=u.sent){u.next=6;break}return u.abrupt("return");case 6:return a=r.description||e.description,i=r.supported_types||e.supported_types,s=r.actions?r.actions.map(function(e){return new ae(e)}):[],(o=new se(e,T.c.UserInteraction)).deprecation=r.deprecation,o.description=a,o.supported_types=i,o.actions=s,c=o.getResult(),u.abrupt("return",nt(c));case 16:case"end":return u.stop()}},null,this,null,Promise)}},{key:"runAction",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=e.verb,a.next='get'===a.t0?3:'render'===a.t0?7:'show'===a.t0?11:'post'===a.t0?15:19;break;case 3:return a.next=5,b.awrap(this.handleGetAction(e,n));case 5:return r=a.sent,a.abrupt("break",20);case 7:return a.next=9,b.awrap(this.handleRenderAction(e,n));case 9:return r=a.sent,a.abrupt("break",20);case 11:return a.next=13,b.awrap(this.handleShowAction(e));case 13:return r=a.sent,a.abrupt("break",20);case 15:return a.next=17,b.awrap(this.handlePostAction(e,t));case 17:return r=a.sent,a.abrupt("break",20);case 19:return a.abrupt("break",20);case 20:return a.abrupt("return",r);case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleGetAction",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.alertService.confirm("Are you sure you want to replace the current note contents with this action's results?"));case 2:if(!n.sent){n.next=7;break}return n.abrupt("return",this.runConfirmedGetAction(e,t));case 7:return n.abrupt("return",{error:{status:1,message:'Action canceled by user.'}});case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"runConfirmedGetAction",value:function(e,t){var n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.httpService.getAbsolute(e.url).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return a.alertService.alert(t.message),{error:t}}));case 2:if(!(n=i.sent).error){i.next=5;break}return i.abrupt("return",n);case 5:return i.next=7,b.awrap(this.payloadByDecryptingResponse(n,t));case 7:return r=i.sent,i.next=10,b.awrap(this.payloadManager.emitPayload(Object(Ee.b)(r,{dirty:!0,dirtiedDate:new Date}),ht.a.RemoteActionRetrieved));case 10:return this.syncService.sync(),i.abrupt("return",ln(ln({},n),{},{item:n.item}));case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleRenderAction",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.httpService.getAbsolute(e.url).then(function(e){var n,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(r.payloadByDecryptingResponse(e,t));case 2:if(!(n=i.sent)){i.next=6;break}return a=nt(n),i.abrupt("return",ln(ln({},e),{},{item:a}));case 6:case"end":return i.stop()}},null,null,null,Promise)}).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return r.alertService.alert(t.message),{error:t}}));case 2:return n=a.sent,a.abrupt("return",n);case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingResponse",value:function(e,t,n){var r,a,i,s,o,c,u,l,p,d,h,f=arguments;return b.async(function(v){for(;;)switch(v.prev=v.next){case 0:return r=f.length>3&&void 0!==f[3]?f[3]:[],a=Object(Ee.e)(e.item),v.next=4,b.awrap(this.protocolService.payloadByDecryptingPayload(a,n));case 4:if((i=v.sent).errorDecrypting){v.next=7;break}return v.abrupt("return",i);case 7:if(s=e.keyParams||e.auth_params){v.next=11;break}return this.alertService.alert("We were unable to decrypt this revision using your current keys, and this revision is missing metadata that would allow us to try different keys to decrypt it. This can likely be fixed with some manual intervention. Please email hello@standardnotes.org for assistance."),v.abrupt("return",void 0);case 11:o=this.protocolService.createKeyParams(s),c=S(this.previousPasswords);case 13:if((u=c()).done){v.next=30;break}if(l=u.value,!r.includes(l)){v.next=17;break}return v.abrupt("continue",28);case 17:return r.push(l),v.next=20,b.awrap(this.protocolService.computeRootKey(l,o));case 20:if(p=v.sent){v.next=23;break}return v.abrupt("continue",28);case 23:return v.next=25,b.awrap(this.payloadByDecryptingResponse(e,t,p,r));case 25:if(!(d=v.sent)){v.next=28;break}return v.abrupt("return",d);case 28:v.next=13;break;case 30:return v.next=32,b.awrap(t());case 32:if(h=v.sent,!this.previousPasswords.includes(h)){v.next=35;break}return v.abrupt("return",void 0);case 35:return this.previousPasswords.push(h),v.abrupt("return",this.payloadByDecryptingResponse(e,t,n));case 37:case"end":return v.stop()}},null,this,null,Promise)}},{key:"handlePostAction",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=e.access_type===q.Decrypted,s.next=3,b.awrap(this.outgoingPayloadForItem(t,n));case 3:return r=s.sent,a={items:[r]},s.abrupt("return",this.httpService.postAbsolute(e.url,a).then(function(e){return e}).catch(function(e){return console.error('Action error response:',e),i.alertService.alert('An issue occurred while processing this action. Please try again.'),e}));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleShowAction",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.deviceInterface.openUrl(e.url),t.abrupt("return",{});case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"outgoingPayloadForItem",value:function(e){var t,n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=a.length>1&&void 0!==a[1]&&a[1],n=t?Re.b.FileDecrypted:Re.b.FileEncrypted,i.next=4,b.awrap(this.protocolService.payloadByEncryptingPayload(e.payloadRepresentation(),n));case 4:return r=i.sent,i.abrupt("return",r.ejected());case 6:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),fn=(function(){function e(t,n,r){v(this,e),this.deviceInterface=t,this.identifier=n,this.environment=r}return y(e,null,[{key:"version",value:function(){throw Error('Must override')}}]),e})(),vn=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getJsonParsedRawStorageValue(D.AllAccountKeyParamsKey));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getRawKeychainValue());case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getRawStorageValue('mk'));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!!Pe(this.environment)}}],[{key:"version",value:function(){return"1.0.0"}}]),n})(),yn=(function(){function e(t){v(this,e),this.services=t,this.stageHandlers={},this.registerStageHandlers()}return y(e,[{key:"registerStageHandler",value:function(e,t){this.stageHandlers[e]=t}},{key:"markDone",value:function(){var e;null===(e=this.onDoneHandler)||void 0===e||e.call(this),this.onDoneHandler=void 0}},{key:"promptForPasscodeUntilCorrect",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new ye([new ge(te.None)],ne.Migration,!1),r.abrupt("return",new Promise(function(r){n.services.challengeService.addChallengeObserver(t,{onNonvalidatedSubmit:function(a){var i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return i=a.values[0],s=i.value,o.next=4,b.awrap(e(s));case 4:o.sent?(n.services.challengeService.completeChallenge(t),r(s)):n.services.challengeService.setValidationStatusForChallenge(t,i,!1);case 6:case"end":return o.stop()}},null,null,null,Promise)}}),n.services.challengeService.promptForChallengeResponse(t)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}},{key:"onDone",value:function(e){this.onDoneHandler=e}},{key:"handleStage",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t=this.stageHandlers[e])){n.next=4;break}return n.next=4,b.awrap(t());case 4:case"end":return n.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){throw'Must override'}}]),e})();!(function(e){e.CreatedAt="created_at",e.UpdatedAt="userModifiedDate",e.Title="title"})(dn||(dn={}));var gn=(function(e){d(n,mt);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).displaySortBy={},e.displayFilter={},e.filteredMap={},e.sortedMap={},e}return y(n,[{key:"set",value:function(e){e=Object(_.W)(Array.isArray(e)?e:[e],'uuid'),p(f(n.prototype),"set",this).call(this,e),this.filterSortElements(e)}},{key:"discard",value:function(e){e=Array.isArray(e)?e:[e],p(f(n.prototype),"discard",this).call(this,e),this.filterSortElements(e)}},{key:"setDisplayOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn.CreatedAt,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc',r=arguments.length>3?arguments[3]:void 0,a=this.displaySortBy[e],i=this.displayFilter[e];if(!a||a.key!==t||a.dir!==n||i||r){this.displaySortBy[e]=t?{key:t,dir:n}:void 0,this.displayFilter[e]=r,this.filteredMap[e]={},this.sortedMap[e]=[];var s=this.all(e);s.length>0&&this.filterSortElements(s)}}},{key:"displayElements",value:function(e){var t=this.sortedMap[e];if(!t)throw Error("Attempting to access display elements for\n        non-configured content type ".concat(e));return t.slice()}},{key:"filterSortElements",value:function(e){if(0!==Object.keys(this.displaySortBy).length){for(var t,n=new Set,r=S(e);!(t=r()).done;){var a=t.value,i=a.content_type,s=this.displaySortBy[i];if(s){var o=this.displayFilter[i],c=this.filteredMap[i],u=this.sortedMap[i],l=c[a.uuid],p=Object(_.w)(l)?void 0:u[l];if(!(a.deleted||!this.map[a.uuid])&&(!o||o(a)))if(Object(_.w)(p))u.push(a),n.add(i);else{var d=p.errorDecrypting?void 0:p[s.key],h=a[s.key];u[l]=a;var f=p.pinned!==a.pinned;Object(_.g)(d,h)&&!f||n.add(i)}else Object(_.w)(l)||(delete c[a.uuid],u[l]=void 0,n.add(i))}}for(var v,y=S(n.values());!(v=y()).done;){var g=v.value;this.resortContentType(g)}}}},{key:"resortContentType",value:function(e){for(var t,n=this.sortedMap[e],r=this.displaySortBy[e],a=this.filteredMap[e],i=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t)return-1;if(!n)return 1;if(!a){if(t.pinned&&n.pinned)return e(t,n,!0);if(t.pinned)return-1;if(n.pinned)return 1}var i=t[r.key]||'',s=n[r.key]||'',o=1;return'asc'===r.dir&&(o*=-1),r.key===dn.Title?o*i.localeCompare(s,'en',{numeric:!0}):i>s?-1*o:i<s?1*o:0},s=[],o=0,c=S(n.sort(function(e,t){return i(e,t)}));!(t=c()).done;){var u=t.value;u&&(s.push(u),a[u.uuid]=o,o++)}this.sortedMap[e]=s}}]),n})();function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(n),!0).forEach(function(t){wn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=(function(e){d(n,yn);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).legacyReader=new vn(r.services.deviceInterface,r.services.identifier,r.services.environment),r}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Se(e.services.environment)){t.next=5;break}return t.next=3,b.awrap(e.migrateStorageStructureForWebDesktop());case 3:t.next=8;break;case 5:if(!Pe(e.services.environment)){t.next=8;break}return t.next=8,b.awrap(e.migrateStorageStructureForMobile());case 8:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.StorageDecrypted_09,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.migrateArbitraryRawStorageToManagedStorageAllPlatforms());case 2:if(!Pe(e.services.environment)){t.next=5;break}return t.next=5,b.awrap(e.migrateMobilePreferences());case 5:return t.next=7,b.awrap(e.migrateSessionStorage());case 7:return t.next=9,b.awrap(e.deleteLegacyStorageValues());case 9:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.LoadingDatabase_11,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createDefaultItemsKeyForAllPlatforms());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"migrateStorageStructureForWebDesktop",value:function(){var e,t,n,r,a,i,s,c,u,l,p,d,h,f,v,y,m,w,k,x,S;return b.async(function(P){for(;;)switch(P.prev=P.next){case 0:return t=this.services.deviceInterface,g(e={},_e.Wrapped,{}),g(e,_e.Unwrapped,{}),g(e,_e.Nonwrapped,{}),n=e,P.next=4,b.awrap(this.legacyReader.getAccountKeyParams());case 4:return(r=P.sent)&&(n.nonwrapped[o.RootKeyParams]=r),P.next=8,b.awrap(t.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 8:if(!(a=P.sent)){P.next=37;break}return i=Object(Ee.e)(a),P.next=13,b.awrap(this.webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage(i));case 13:if(s=P.sent,c=s.key,u=s.decryptedStoragePayload,l=s.keyParams,n.nonwrapped[o.RootKeyWrapperKeyParams]=l.getPortableValue(),p=Object(_.a)(u.contentObject.storage),d=Object(_.E)(p),h=d[D.AllAccountKeyParamsKey],n.nonwrapped[o.RootKeyParams]=h,f=c,!!Object(_.w)(d.mk)){P.next=32;break}return P.next=27,b.awrap(this.webDesktopHelperExtractAndWrapAccountKeysFromValueStore(c,h,d));case 27:v=P.sent,y=v.accountKey,m=v.wrappedKey,f=y,n.nonwrapped[o.WrappedRootKey]=m;case 32:return P.next=34,b.awrap(this.webDesktopHelperEncryptStorage(f,u,d));case 34:n.wrapped=P.sent,P.next=55;break;case 37:return P.next=39,b.awrap(this.services.deviceInterface.getRawStorageValue('ak'));case 39:return w=P.sent,P.next=42,b.awrap(this.services.deviceInterface.getRawStorageValue('mk'));case 42:if(k=P.sent,!w&&!k){P.next=55;break}if(P.t0=null===r||void 0===r?void 0:r.version,P.t0){P.next=49;break}return P.next=48,b.awrap(this.getFallbackRootKeyVersion());case 48:P.t0=P.sent;case 49:return x=P.t0,P.next=52,b.awrap(Ve.Create({masterKey:k,dataAuthenticationKey:w,version:x,keyParams:r}));case 52:return S=P.sent,P.next=55,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(S.getKeychainValue(),this.services.identifier));case 55:return P.next=57,b.awrap(this.allPlatformHelperSetStorageStructure(n));case 57:case"end":return P.stop()}},null,this,null,Promise)}},{key:"allPlatformHelperSetStorageStructure",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Ie.defaultValuesObject(e.wrapped,e.unwrapped,e.nonwrapped))[_e.Unwrapped]=void 0,n.next=4,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.StorageObject),JSON.stringify(t)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.WebPasscodeParamsKey));case 2:return t=s.sent,n=this.services.protocolService.createKeyParams(t),s.next=6,b.awrap(this.promptForPasscodeUntilCorrect(function(t){return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(i.services.protocolService.computeRootKey(t,n));case 2:return a=s.sent,s.next=5,b.awrap(i.services.protocolService.payloadByDecryptingPayload(e,a));case 5:return r=s.sent,s.abrupt("return",!r.errorDecrypting);case 7:case"end":return s.stop()}},null,null,null,Promise)}));case 6:return s.abrupt("return",{decryptedStoragePayload:r,key:a,keyParams:n});case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperExtractAndWrapAccountKeysFromValueStore",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.t0=null===t||void 0===t?void 0:t.version,c.t0){c.next=5;break}return c.next=4,b.awrap(this.getFallbackRootKeyVersion());case 4:c.t0=c.sent;case 5:return a=c.t0,c.next=8,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:a,keyParams:t}));case 8:if(i=c.sent,delete n.mk,delete n.pw,delete n.ak,s=Object(Ee.e)(i),!e){c.next=17;break}return c.next=16,b.awrap(this.services.protocolService.payloadByEncryptingPayload(s,Re.b.LocalStorageEncrypted,e));case 16:o=c.sent;case 17:return c.abrupt("return",{accountKey:i,wrappedKey:null===(r=o)||void 0===r?void 0:r.ejected()});case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperEncryptStorage",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.services.protocolService.payloadByEncryptingPayload(Object(Ee.b)(t,{content_type:F.a.EncryptedStorage,content:n}),Re.b.LocalStoragePreferEncrypted,e));case 2:return r=a.sent,a.abrupt("return",r.ejected());case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"migrateStorageStructureForMobile",value:function(){var e,t,n,r,a,i,s,u,l,p,d,h,f,v,y,m,w,k,x,S,P,O,C,E,R=this;return b.async(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,b.awrap(this.services.deviceInterface.getRawKeychainValue());case 2:return n=M.sent,M.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileWrappedRootKeyKey));case 5:if(M.t0=M.sent,M.t0){M.next=8;break}M.t0=null===n||void 0===n?void 0:n.encryptedAccountKeys;case 8:return r=M.t0,M.next=11,b.awrap(this.legacyReader.getAccountKeyParams());case 11:return a=M.sent,M.next=14,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 14:return i=M.sent,M.next=17,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(c.MobileFirstRun));case 17:return s=M.sent,g(t={},_e.Nonwrapped,(g(e={},o.WrappedRootKey,r),g(e,o.RootKeyWrapperKeyParams,Object(_.I)(i,['hash'])),g(e,o.RootKeyParams,a),g(e,c.MobileFirstRun,s),e)),g(t,_e.Unwrapped,{}),g(t,_e.Wrapped,{}),u=t,M.next=21,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileBiometricsPrefs));case 21:return(l=M.sent)&&(u.nonwrapped[o.BiometricsState]=l.enabled,u.nonwrapped[o.MobileBiometricsTiming]=l.timing),M.next=25,b.awrap(this.services.deviceInterface.getRawStorageValue(D.MobilePasscodeKeyboardType));case 25:if((p=M.sent)&&(u.nonwrapped[o.MobilePasscodeKeyboardType]=p),!i){M.next=75;break}if(h=this.services.protocolService.createKeyParams(i),f=function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(R.promptForPasscodeUntilCorrect(function(t){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(R.services.protocolService.computeRootKey(t,h));case 2:if(e=u.sent,!(i=null===n||void 0===n?void 0:null===(a=n.offline)||void 0===a?void 0:a.pw)){u.next=8;break}return u.abrupt("return",e.serverPassword===i);case 8:if(!r){u.next=15;break}return u.next=11,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),e));case 11:return s=u.sent,u.abrupt("return",!s.errorDecrypting);case 15:return u.next=17,b.awrap(R.services.deviceInterface.getAllRawDatabasePayloads(R.services.identifier));case 17:if(o=u.sent[0]){u.next=20;break}throw Error('Passcode only migration aborting due to missing keychain.offline.pw');case 20:return u.next=22,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(o),e));case 22:return c=u.sent,u.abrupt("return",!c.errorDecrypting);case 24:case"end":return u.stop()}},null,null,null,Promise)}));case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},null,null,null,Promise)},u.nonwrapped[o.MobilePasscodeTiming]=null===n||void 0===n?void 0:null===(d=n.offline)||void 0===d?void 0:d.timing,!r){M.next=55;break}return M.next=34,b.awrap(f());case 34:return v=M.sent,M.next=37,b.awrap(this.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),v));case 37:if(y=M.sent,m=y.contentObject.accountKeys,M.t1=m.version||(null===a||void 0===a?void 0:a.version),M.t1){M.next=44;break}return M.next=43,b.awrap(this.getFallbackRootKeyVersion());case 43:M.t1=M.sent;case 44:return w=M.t1,k=Object(Ee.b)(y,{content:{masterKey:m.mk,dataAuthenticationKey:m.ak,version:w,keyParams:a,accountKeys:void 0}}),M.next=48,b.awrap(this.services.protocolService.payloadByEncryptingPayload(k,Re.b.LocalStoragePreferEncrypted,v));case 48:return x=M.sent,u.nonwrapped[o.WrappedRootKey]=x.ejected(),m.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",m.jwt),M.next=53,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 53:M.next=73;break;case 55:if(r){M.next=73;break}return M.next=58,b.awrap(f());case 58:return S=M.sent,M.t2=Object(Ee.e),M.next=62,b.awrap(I.GenerateUuid());case 62:return M.t3=M.sent,M.t4=Object(Ke.a)(u.unwrapped),M.t5=F.a.EncryptedStorage,M.t6={uuid:M.t3,content:M.t4,content_type:M.t5},P=(0,M.t2)(M.t6),M.next=69,b.awrap(this.services.protocolService.payloadByEncryptingPayload(P,Re.b.LocalStoragePreferEncrypted,S));case 69:return O=M.sent,u.wrapped=O.ejected(),M.next=73,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 73:M.next=89;break;case 75:if(!!Object(_.w)(null===n||void 0===n?void 0:n.mk)){M.next=89;break}if(M.t7=n.version||(null===a||void 0===a?void 0:a.version),M.t7){M.next=82;break}return M.next=81,b.awrap(this.getFallbackRootKeyVersion());case 81:M.t7=M.sent;case 82:return C=M.t7,M.next=85,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:C,keyParams:a}));case 85:return E=M.sent,M.next=88,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(E.getKeychainValue(),this.services.identifier));case 88:n.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",n.jwt);case 89:return M.next=91,b.awrap(this.allPlatformHelperSetStorageStructure(u));case 91:case"end":return M.stop()}},null,this,null,Promise)}},{key:"getFallbackRootKeyVersion",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.services.deviceInterface.getAllRawDatabasePayloads(this.services.identifier));case 2:if(e=n.sent[0]){n.next=5;break}return n.abrupt("return",Q.a.V002);case 5:return t=Object(Ee.e)(e),n.abrupt("return",t.version||Q.a.V002);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateArbitraryRawStorageToManagedStorageAllPlatforms",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getAllRawStorageKeyValues());case 2:e=p.sent,t=Object(_.H)(D),n=function(e){try{return JSON.parse(e)}catch(t){return e}},r=this.services.identifier,a=S(e);case 7:if((i=a()).done){p.next=20;break}if(s=i.value,o=s.key,c=s.value,u=r&&r.length>0&&o.startsWith(r),!t.includes(o)&&!u){p.next=14;break}return p.abrupt("continue",18);case 14:if(Object(_.w)(c)){p.next=18;break}return l=n(c),p.next=18,b.awrap(this.services.storageService.setValue(o,l));case 18:p.next=7;break;case 20:case"end":return p.stop()}},null,this,null,Promise)}},{key:"deleteLegacyStorageValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e=['mk','ak','pw','encryptionKey','authKey','jwt','ephemeral','cachedThemes'],t=[].concat(m(Object(_.H)(o)),m(Object(_.H)(D)),e),n=S(t);case 3:if((r=n()).done){i.next=9;break}return a=r.value,i.next=7,b.awrap(this.services.deviceInterface.removeRawStorageValue(a));case 7:i.next=3;break;case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"migrateMobilePreferences",value:function(){var e,t,n,r,a,i,s,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileLastExportDate));case 2:return e=p.sent,p.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileDoNotWarnUnsupportedEditors));case 5:return t=p.sent,p.next=8,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileOptionsState));case 8:return n=p.sent,r={},n&&(u=n.sortBy,r={sortBy:'updated_at'===u||'client_updated_at'===u?dn.UpdatedAt:u,sortReverse:null!==(a=n.sortReverse)&&void 0!==a&&a,hideNotePreview:null!==(i=n.hidePreviews)&&void 0!==i&&i,hideDate:null!==(s=n.hideDates)&&void 0!==s&&s,hideTags:null!==(c=n.hideTags)&&void 0!==c&&c}),l=bn(bn({},r),{},{lastExportDate:null!==e&&void 0!==e?e:void 0,doNotShowAgainUnsupportedEditors:null!==t&&void 0!==t&&t}),p.next=14,b.awrap(this.services.storageService.setValue(o.MobilePreferences,l));case 14:case"end":return p.stop()}},null,this,null,Promise)}},{key:"migrateSessionStorage",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return e='user',i.next=3,b.awrap(this.services.storageService.getValue("jwt"));case 3:return t=i.sent,i.next=6,b.awrap(this.services.storageService.getValue(e));case 6:if(n=i.sent,t||n&&(t=n.jwt),t){i.next=15;break}if(!!Object(_.w)(n)){i.next=14;break}t='junk-value',i.next=15;break;case 14:return i.abrupt("return");case 15:return r=new Ae(t),i.next=18,b.awrap(this.services.storageService.setValue(o.Session,r));case 18:if(!Pe(this.services.environment)){i.next=25;break}return i.next=21,b.awrap(this.services.storageService.getValue(e));case 21:if(!(a=i.sent)||!a.server){i.next=25;break}return i.next=25,b.awrap(this.services.storageService.setValue(o.ServerHost,a.server));case 25:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createDefaultItemsKeyForAllPlatforms",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e=this.services.protocolService.getRootKey())){i.next=18;break}return i.next=4,b.awrap(this.services.protocolService.getRootKeyParams());case 4:return t=i.sent,n=Q.a.V001,i.t0=Object(Ee.e),i.next=9,b.awrap(I.GenerateUuid());case 9:return i.t1=i.sent,i.t2=F.a.ItemsKey,i.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t.version||n}),i.t4=new Date,i.t5={uuid:i.t1,content_type:i.t2,content:i.t3,dirty:!0,dirtiedDate:i.t4},r=(0,i.t0)(i.t5),a=nt(r),i.next=18,b.awrap(this.services.itemManager.emitItemFromPayload(a.payloadRepresentation(),ht.a.LocalChanged));case 18:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return"2.0.0"}}]),n})(),xn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createNewDefaultItemsKeyIfNecessary());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"createNewDefaultItemsKeyIfNecessary",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.services.protocolService.needsNewRootKeyBasedItemsKey()){e.next=3;break}return e.next=3,b.awrap(this.services.protocolService.createNewDefaultItemsKey());case 3:case"end":return e.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.0.15'}}]),n})(),Sn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.FullSyncCompleted_13,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteBatchManagerSingleton());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteBatchManagerSingleton",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e='org.standardnotes.batch-manager',t=H.a.CompoundPredicate([new H.a('content_type','=',F.a.Component),new H.a('package_info.identifier','=',e)]),!(n=this.services.singletonManager.findSingleton(t))){r.next=6;break}return r.next=6,b.awrap(this.services.itemManager.setItemToBeDeleted(n.uuid));case 6:case"end":return r.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.7.0'}}]),n})(),Pn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteMfaItems());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteMfaItems",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e='SF|MFA',t=this.services.itemManager.getItems(e),n=S(t);case 3:if((r=n()).done){i.next=10;break}return a=r.value,this.services.itemManager.removeItemLocally(a),i.next=8,b.awrap(this.services.storageService.deletePayloadWithId(a.uuid));case 8:i.next=3;break;case 10:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.20.0'}}]),n})(),On=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getStorage",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=O(this.identifier,s.StorageObject),r.next=3,b.awrap(this.deviceInterface.getRawStorageValue(e));case 3:return t=r.sent,n=t?JSON.parse(t):void 0,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getNonWrappedValue",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getStorage());case 2:if(n=r.sent){r.next=5;break}return r.abrupt("return",void 0);case 5:return r.abrupt("return",null===(t=n[_e.Nonwrapped])||void 0===t?void 0:t[e]);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getNonWrappedValue(o.RootKeyParams));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getNonWrappedValue(o.WrappedRootKey));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!0}}],[{key:"version",value:function(){return"2.0.0"}}]),n})();function Cn(e){for(var t,n=S(Object.values(i).sort(function(e,t){return-1*P(e.version(),t.version())}));!(t=n()).done;){var r=t.value;if(r.version()===e)return r;if(x(r.version(),e))return r}throw Error("Cannot find reader for version ".concat(e))}function Dn(e,t,n,r){return new(Cn(e))(t,n,r)}var _n=(function(e){d(n,yn);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).didPreRun=!1,e}return y(n,[{key:"preRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storeVersionNumber());case 2:this.didPreRun=!0;case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.needsKeychainRepair());case 2:if(!t.sent){t.next=5;break}return t.next=5,b.awrap(e.repairMissingKeychain());case 5:e.markDone();case 6:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"getStoredVersion",value:function(){var e=O(this.services.identifier,s.SnjsVersion);return this.services.deviceInterface.getRawStorageValue(e)}},{key:"storeVersionNumber",value:function(){var e,t,n,r,a,i,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return e=O(this.services.identifier,s.SnjsVersion),c.next=3,b.awrap(this.getStoredVersion());case 3:if(c.sent){c.next=38;break}t=!1,n=0,r=['migrations','ephemeral','user','cachedThemes','syncToken','encryptedStorage'];case 8:if(!(n<r.length)){c.next=19;break}return a=r[n],c.next=12,b.awrap(this.services.deviceInterface.getRawStorageValue(a));case 12:if(!c.sent){c.next=16;break}return t=!0,c.abrupt("break",19);case 16:n++,c.next=8;break;case 19:if(!t){c.next=24;break}return c.next=22,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"1.0.0"));case 22:c.next=38;break;case 24:return i=O(this.services.identifier,"last_migration_timestamp"),c.next=27,b.awrap(this.services.deviceInterface.getRawStorageValue(i));case 27:if(o=c.sent,!!Object(_.w)(o)){c.next=36;break}return c.next=32,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"2.0.0"));case 32:return c.next=34,b.awrap(this.services.deviceInterface.removeRawStorageValue("last_migration_timestamp"));case 34:c.next=38;break;case 36:return c.next=38,b.awrap(this.services.deviceInterface.setRawStorageValue(e,h));case 38:case"end":return c.stop()}},null,this,null,Promise)}},{key:"loadReader",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.reader){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,b.awrap(this.getStoredVersion());case 4:e=t.sent,this.reader=Dn(e,this.services.deviceInterface,this.services.identifier,this.services.environment);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"needsKeychainRepair",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.didPreRun){t.next=2;break}throw Error('Attempting to access specialized function before prerun');case 2:if(this.reader){t.next=5;break}return t.next=5,b.awrap(this.loadReader());case 5:if(this.reader.usesKeychain){t.next=8;break}return t.abrupt("return",!1);case 8:return t.next=10,b.awrap(this.reader.getAccountKeyParams());case 10:if(e=t.sent,!Object(_.w)(e)){t.next=14;break}return t.abrupt("return",!1);case 14:return t.next=16,b.awrap(this.reader.hasPasscode());case 16:if(!t.sent){t.next=19;break}return t.abrupt("return",!1);case 19:return t.next=21,b.awrap(this.reader.hasNonWrappedAccountKeys());case 21:if(!t.sent){t.next=24;break}return t.abrupt("return",!1);case 24:return t.abrupt("return",!0);case 25:case"end":return t.stop()}},null,this,null,Promise)}},{key:"repairMissingKeychain",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getStoredVersion());case 2:return e=a.sent,a.next=5,b.awrap(this.reader.getAccountKeyParams());case 5:return t=a.sent,n=new ye([new ge(te.None,void 0,j.R.PasswordInputPlaceholder,!0)],ne.Custom,!1,j.I.Title,j.I.Text),a.abrupt("return",new Promise(function(a){r.services.challengeService.addChallengeObserver(n,{onNonvalidatedSubmit:function(i){var s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return s=i.values[0].value,o=r.services.protocolService.createKeyParams(t),d.next=4,b.awrap(r.services.protocolService.computeRootKey(s,o));case 4:return c=d.sent,d.next=7,b.awrap(r.services.deviceInterface.getAllRawDatabasePayloads(r.services.identifier));case 7:if(u=d.sent,(l=u.find(function(e){var t=Object(Ee.e)(e);return Object(Re.a)(t.content_type)}))||(l=u[0]),l){d.next=12;break}throw we.a.error(Error('Attempting keychain recovery validation but no items present.'));case 12:return d.next=14,b.awrap(r.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(l),c));case 14:if(!d.sent.errorDecrypting){d.next=19;break}r.services.challengeService.setValidationStatusForChallenge(n,i.values[0],!1),d.next=29;break;case 19:if("1.0.0"!==e){d.next=24;break}return d.next=22,b.awrap(r.services.deviceInterface.legacy_setRawKeychainValue({mk:c.masterKey,ak:c.dataAuthenticationKey,version:o.version}));case 22:d.next=27;break;case 24:return p=c.getKeychainValue(),d.next=27,b.awrap(r.services.deviceInterface.setNamespacedKeychainValue(p,r.services.identifier));case 27:a(),r.services.challengeService.completeChallenge(n);case 29:case"end":return d.stop()}},null,null,null,Promise)}}),r.services.challengeService.promptForChallengeResponse(n)}));case 8:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(),En=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).services=e,r}return y(n,[{key:"deinit",value:function(){this.services=void 0,this.activeMigrations&&(this.activeMigrations.length=0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.runBaseMigrationPreRun());case 2:return r.t0=b,r.t1=n,r.next=6,b.awrap(this.getStoredSnjsVersion());case 6:return r.t2=r.sent,r.t3=r.t1.getRequiredMigrations.call(r.t1,r.t2),r.next=10,r.t0.awrap.call(r.t0,r.t3);case 10:if(e=r.sent,this.activeMigrations=this.instantiateMigrationClasses(e),!(this.activeMigrations.length>0)){r.next=17;break}Object(_.F)(this.activeMigrations).onDone(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(t.markMigrationsAsDone());case 2:case"end":return e.stop()}},null,null,null,Promise)}),r.next=19;break;case 17:return r.next=19,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 19:case"end":return r.stop()}},null,this,null,Promise)}},{key:"markMigrationsAsDone",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"runBaseMigrationPreRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.baseMigration=new _n(this.services),e.next=3,b.awrap(this.baseMigration.preRun());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:return t.next=4,b.awrap(this.handleStage(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleApplicationEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.a.SignedIn){t.next=3;break}return t.next=3,b.awrap(this.handleStage(ve.SignedIn_30));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPendingMigrations",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=n,t.next=4,b.awrap(this.getStoredSnjsVersion());case 4:return t.t2=t.sent,t.t3=t.t1.getRequiredMigrations.call(t.t1,t.t2),t.next=8,t.t0.awrap.call(t.t0,t.t3);case 8:if(e=t.sent,t.t4=e.length>0,t.t4){t.next=14;break}return t.next=13,b.awrap(this.baseMigration.needsKeychainRepair());case 13:t.t4=t.sent;case 14:return t.abrupt("return",t.t4);case 15:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getStoredSnjsVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.services.deviceInterface.getRawStorageValue(O(this.services.identifier,s.SnjsVersion)));case 2:if(e=t.sent){t.next=5;break}throw we.a.error(Error('Snjs version missing from storage, run base migration.'));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"instantiateMigrationClasses",value:function(e){var t=this;return e.map(function(e){return new e(t.services)})}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.baseMigration.handleStage(e));case 2:t=S(this.activeMigrations);case 3:if((n=t()).done){a.next=9;break}return r=n.value,a.next=7,b.awrap(r.handleStage(e));case 7:a.next=3;break;case 9:case"end":return a.stop()}},null,this,null,Promise)}}],[{key:"getRequiredMigrations",value:function(e){var t,n,r,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:t=[],n=Object.keys(a).map(function(e){return a[e]}).sort(function(e,t){return P(e.version(),t.version())}),r=S(n);case 3:if((i=r()).done){c.next=11;break}if(s=i.value,(o=s.version())!==e){c.next=8;break}return c.abrupt("continue",9);case 8:x(e,o)&&t.push(s);case 9:c.next=3;break;case 11:return c.abrupt("return",t);case 12:case"end":return c.stop()}},null,null,null,Promise)}}]),n})(R.a),Rn=n(14),In=(function(){function e(t){v(this,e),this.crypto=t}return y(e,[{key:"firstHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"secondHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"splitKey",value:function(e,t){for(var n=e.length/t,r=[],a=0;a<t;a++){var i=e.slice(n*a,n*(a+1));r.push(i)}return r}},{key:"createItemsKey",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.generateNewItemsKeyContent());case 2:return e=n.sent,n.t0=Object(Ee.e),n.next=6,b.awrap(I.GenerateUuid());case 6:return n.t1=n.sent,n.t2=F.a.ItemsKey,n.t3=Object(Ke.a)(e),n.t4={uuid:n.t1,content_type:n.t2,content:n.t3},t=(0,n.t0)(n.t4),n.abrupt("return",nt(t));case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,n){var r,a,i;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==ue.a.DecryptedBareObject){n.next=4;break}return n.abrupt("return",Object(Ee.c)({content:e.content}));case 4:if(t!==ue.a.DecryptedBase64String){n.next=13;break}return r=JSON.stringify(e.content),n.next=8,b.awrap(this.crypto.base64Encode(r));case 8:return a=n.sent,i=Q.a.V000Base64Decrypted+a,n.abrupt("return",Object(Ee.c)({content:i}));case 13:throw"Must override generateEncryptedParameters to handle format ".concat(t,".");case 14:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var n,r,a,i;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=e.format)!==ue.a.DecryptedBareObject){t.next=5;break}return t.abrupt("return",e);case 5:if(n!==ue.a.DecryptedBase64String){t.next=20;break}return r=e.contentString.substring(Q.a.VersionLength,e.contentString.length),t.prev=7,t.next=10,b.awrap(this.crypto.base64Decode(r));case 10:i=t.sent,a=JSON.parse(i),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),a=e.content;case 17:return t.abrupt("return",Object(Ee.a)(e,{content:a}));case 20:throw Error("Must override generateDecryptedParameters to handle format ".concat(n,"."));case 21:case"end":return t.stop()}},null,this,[[7,14]],Promise)}}]),e})(),Mn='00000000000000000000000000000000',An=(function(e){d(n,In);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'AES-256'}},{key:"generateNewItemsKeyContent",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=Rn.a.EncryptionKeyLength,r.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=r.sent,n={itemsKey:t,version:Q.a.V001},r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Rn.a.PbkdfMinCost,o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.a.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+'SN'+a));case 6:return i=o.sent,s=Object(A.a)({email:e,pw_cost:r,pw_nonce:a,pw_salt:i,version:Q.a.V001,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcDecrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"encryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcEncrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c,u,l;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){d.next=2;break}return d.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){d.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r){d.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return d.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.a.EncryptionKeyLength));case 8:return a=d.sent,d.next=11,b.awrap(this.encryptString(a,r.itemsKey));case 11:return i=d.sent,d.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=d.sent,d.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=d.sent,d.next=20,b.awrap(this.encryptString(JSON.stringify(e.content),s));case 20:return c=d.sent,u=r.keyVersion+c,d.next=24,b.awrap(this.crypto.hmac256(u,o));case 24:return l=d.sent,d.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:u,enc_item_key:i,auth_hash:l}));case 26:case"end":return d.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){l.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:return a=e.enc_item_key,a=this.version+a,i=this.encryptionComponentsFromString(a,t.itemsKey),l.next=11,b.awrap(this.decryptString(i.ciphertext,i.key));case 11:if(s=l.sent){l.next=15;break}return console.error('Error decrypting parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 15:return l.next=17,b.awrap(this.firstHalfOfKey(s));case 17:return o=l.sent,c=this.encryptionComponentsFromString(e.contentString,o),l.next=21,b.awrap(this.decryptString(c.ciphertext,c.key));case 21:if(u=l.sent){l.next=26;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 27:case"end":return l.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString",value:function(e,t){var n=e.substring(0,Q.a.VersionLength);return{ciphertext:e.substring(Q.a.VersionLength,e.length),version:n,key:t}}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content001.pw_salt,t.content001.pw_cost,Rn.a.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,2),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],version:Q.a.V001,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V001}}]),n})();function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach(function(t){Kn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=(function(e){d(n,An);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.b.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V002},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Object(_.F)(Rn.b.PbkdfCostsUsed),o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.b.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+':'+a));case 6:return i=o.sent,s=Object(A.b)({email:e,pw_nonce:a,pw_cost:r,pw_salt:i,version:Q.a.V002,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcDecrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcEncrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptTextParams",value:function(e,t,n,r,a,i){var s,o,c,u,l,p,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,b.awrap(this.crypto.generateRandomKey(Rn.b.EncryptionIvLength));case 2:return s=h.sent,h.next=5,b.awrap(this.encryptString002(e,t,s));case 5:return o=h.sent,c=[a,r,s,o].join(':'),h.next=9,b.awrap(this.crypto.hmac256(c,n));case 9:if(u=h.sent,l=[a,u,r,s,o],!i){h.next=16;break}return h.next=14,b.awrap(this.crypto.base64Encode(JSON.stringify(i.content)));case 14:p=h.sent,l.push(p);case 16:return d=l.join(':'),h.abrupt("return",d);case 18:case"end":return h.stop()}},null,this,null,Promise)}},{key:"decryptTextParams",value:function(e,t,n,r,a,i){var s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n){o.next=2;break}throw'Attempting to decryptTextParams with null encryptionKey';case 2:return o.next=4,b.awrap(this.crypto.hmac256(e,i));case 4:if(s=o.sent,!1!==this.crypto.timingSafeEqual(a,s)){o.next=8;break}return we.a.error(Error('Auth hash does not match.')),o.abrupt("return",null);case 8:return o.abrupt("return",this.decryptString002(t,n,r));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(t=this.encryptionComponentsFromString002(e.enc_item_key),n=t.keyParams){i.next=4;break}return i.abrupt("return",void 0);case 4:return i.t0=JSON,i.next=7,b.awrap(this.crypto.base64Decode(n));case 7:return i.t1=i.sent,r=i.t0.parse.call(i.t0,i.t1),a=Tn({},r),i.abrupt("return",a);case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r&&r.itemsKey){u.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return u.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.b.EncryptionKeyLength));case 8:return a=u.sent,u.next=11,b.awrap(this.encryptTextParams(a,r.itemsKey,r.dataAuthenticationKey,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 11:return i=u.sent,u.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=u.sent,u.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=u.sent,u.next=20,b.awrap(this.encryptTextParams(JSON.stringify(e.content),s,o,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 20:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:c,enc_item_key:i}));case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u,l,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){h.next=3;break}return h.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){h.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:if(t&&t.itemsKey){h.next=8;break}throw Error('Attempting to generateDecryptedParameters with no itemsKey.');case 8:return a=e.enc_item_key,i=this.encryptionComponentsFromString002(a,t.itemsKey,t.dataAuthenticationKey),h.next=12,b.awrap(this.decryptTextParams(i.ciphertextToAuth,i.contentCiphertext,i.encryptionKey,i.iv,i.authHash,i.authKey));case 12:if(s=h.sent){h.next=16;break}return console.error('Error decrypting item_key parameters',e),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 16:return h.next=18,b.awrap(this.firstHalfOfKey(s));case 18:return o=h.sent,h.next=21,b.awrap(this.secondHalfOfKey(s));case 21:return c=h.sent,u=this.encryptionComponentsFromString002(e.contentString,o,c),h.next=25,b.awrap(this.decryptTextParams(u.ciphertextToAuth,u.contentCiphertext,u.encryptionKey,u.iv,u.authHash,u.authKey));case 25:if(l=h.sent){h.next=30;break}return h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 30:return h.prev=30,h.t0=JSON,h.next=34,b.awrap(this.crypto.base64Decode(u.keyParams));case 34:h.t1=h.sent,d=h.t0.parse.call(h.t0,h.t1),h.next=40;break;case 38:h.prev=38,h.t2=h.catch(30);case 40:return h.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(l),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,auth_params:d,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 41:case"end":return h.stop()}},null,this,[[30,38]],Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content002.pw_salt,t.content002.pw_cost,Rn.b.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,3),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],dataAuthenticationKey:r[2],version:Q.a.V002,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString002",value:function(e,t,n){var r=e.split(':');return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],keyParams:r[5],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(':'),encryptionKey:t,authKey:n}}},{key:"version",get:function(){return Q.a.V002}}]),n})(),Ln=(function(e){d(n,Fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.c.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V003},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.generateSalt(t.content003.identifier,Q.a.V003,Rn.c.PbkdfCost,t.content003.pw_nonce));case 2:return n=s.sent,s.next=5,b.awrap(this.crypto.pbkdf2(e,n,Rn.c.PbkdfCost,Rn.c.PbkdfOutputLength));case 5:return r=s.sent,a=this.splitKey(r,3),s.next=9,b.awrap(Ve.Create({serverPassword:a[0],masterKey:a[1],dataAuthenticationKey:a[2],version:Q.a.V003,keyParams:t.getPortableValue()}));case 9:return i=s.sent,s.abrupt("return",i);case 11:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V003,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.c.SaltSeedLength));case 3:return a=s.sent,i=Object(A.c)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"generateSalt",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.sha256([e,'SF',t,n,r].join(':')));case 2:return a=i.sent,i.abrupt("return",a);case 4:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V003}}]),n})();function Un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach(function(t){Vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bn,Wn=(function(e){d(n,Ln);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'XChaCha20-Poly1305'}},{key:"generateNewItemsKeyContent",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 2:return e=n.sent,t={itemsKey:e,version:Q.a.V004},n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateSalt004",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.crypto.sha256([e,t].join(":")));case 2:return n=r.sent,r.abrupt("return",Object(_.T)(n,Rn.d.ArgonSaltLength));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V004,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.d.ArgonSaltSeedLength));case 3:return a=s.sent,i=Object(A.d)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"encryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n){a.next=2;break}throw'encryptString null nonce';case 2:if(t){a.next=4;break}throw'encryptString null rawKey';case 4:return a.t0=this.crypto,a.t1=e,a.t2=n,a.t3=t,a.next=10,b.awrap(this.authenticatedDataToString(r));case 10:return a.t4=a.sent,a.abrupt("return",a.t0.xchacha20Encrypt.call(a.t0,a.t1,a.t2,a.t3,a.t4));case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.crypto.xchacha20Decrypt(e,n,t,r));case 1:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateEncryptedProtocolString",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionNonceLength));case 2:return r=o.sent,a=Q.a.V004,o.next=6,b.awrap(this.encryptString004(e,t,r,n));case 6:return i=o.sent,o.t0=a,o.t1=r,o.t2=i,o.next=12,b.awrap(this.authenticatedDataToString(n));case 12:return o.t3=o.sent,s=[o.t0,o.t1,o.t2,o.t3],o.abrupt("return",s.join(":"));case 15:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.format===ue.a.EncryptedString){a.next=2;break}throw Error('Attempting to get embedded key params of already decrypted item');case 2:return t=this.deconstructEncryptedPayloadString(e.enc_item_key),n=t.rawAuthenticatedData,a.next=6,b.awrap(this.stringToAuthenticatedData(n));case 6:return r=a.sent,a.abrupt("return",r);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateAuthenticatedDataForPayload",value:function(e,t){var n={u:e.uuid,v:Q.a.V004};if(Object(Re.a)(e.content_type))return Nn(Nn({},n),{},{kp:t.keyParams.content});if(!(t instanceof J))throw Error('Attempting to use non-items key for regular item.');return n}},{key:"authenticatedDataToString",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.base64Encode(JSON.stringify(Object(_.Q)(Object(_.K)(e)))));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"stringToAuthenticatedData",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=JSON,r.next=3,b.awrap(this.crypto.base64Decode(e));case 3:return r.t1=r.sent,n=r.t0.parse.call(r.t0,r.t1),r.abrupt("return",Object(_.Q)(Nn(Nn({},n),t)));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(e.uuid){u.next=6;break}throw'payload.uuid cannot be null';case 6:if(r&&r.itemsKey){u.next=8;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 8:return u.next=10,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 10:return a=u.sent,i=JSON.stringify(e.content),s=this.generateAuthenticatedDataForPayload(e,r),u.next=15,b.awrap(this.generateEncryptedProtocolString(i,a,s));case 15:return o=u.sent,u.next=18,b.awrap(this.generateEncryptedProtocolString(a,r.itemsKey,s));case 18:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:o,enc_item_key:c}));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.uuid){l.next=5;break}throw'encryptedParameters.uuid cannot be null';case 5:if(t&&t.itemsKey){l.next=7;break}throw'Attempting to generateDecryptedParameters with no itemsKey.';case 7:return a=this.deconstructEncryptedPayloadString(e.enc_item_key),l.next=10,b.awrap(this.stringToAuthenticatedData(a.rawAuthenticatedData,{u:e.uuid,v:e.version}));case 10:return i=l.sent,l.next=13,b.awrap(this.authenticatedDataToString(i));case 13:return s=l.sent,l.next=16,b.awrap(this.decryptString004(a.ciphertext,t.itemsKey,a.nonce,s));case 16:if(o=l.sent){l.next=20;break}return console.error('Error decrypting itemKey parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 20:return c=this.deconstructEncryptedPayloadString(e.contentString),l.next=23,b.awrap(this.decryptString004(c.ciphertext,o,c.nonce,s));case 23:if(u=l.sent){l.next=28;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 28:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 29:case"end":return l.stop()}},null,this,null,Promise)}},{key:"deconstructEncryptedPayloadString",value:function(e){var t=e.split(":");return{version:t[0],nonce:t[1],ciphertext:t[2],rawAuthenticatedData:t[3]}}},{key:"deriveKey",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.generateSalt004(t.content004.identifier,t.content004.pw_nonce));case 2:return n=o.sent,o.next=5,b.awrap(this.crypto.argon2(e,n,Rn.d.ArgonIterations,Rn.d.ArgonMemLimit,Rn.d.ArgonOutputKeyBytes));case 5:return r=o.sent,a=this.splitKey(r,2),i=a[0],s=a[1],o.abrupt("return",Ve.Create({masterKey:i,serverPassword:s,version:Q.a.V004,keyParams:t.getPortableValue()}));case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V004}}]),n})();function Hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(n),!0).forEach(function(t){qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e[e.RootKeyNone=0]="RootKeyNone",e[e.RootKeyOnly=1]="RootKeyOnly",e[e.RootKeyPlusWrapper=2]="RootKeyPlusWrapper",e[e.WrapperOnly=3]="WrapperOnly"})(Bn||(Bn={}));var Yn=Q.a.V003,Gn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).itemManager=e,c.payloadManager=r,c.storageService=i,c.identifier=s,c.operators={},c.keyMode=Bn.RootKeyNone,c.keyObservers=[],c.itemManager=e,c.payloadManager=r,c.deviceInterface=a,c.storageService=i,c.crypto=o,Object(_.y)()?I.SetGenerators(c.crypto.generateUUID,void 0):I.SetGenerators(c.crypto.generateUUID,c.crypto.generateUUIDSync),Object.defineProperty(u(c),'rootKey',{enumerable:!1,writable:!0}),c.removeItemsObserver=c.itemManager.addObserver([F.a.ItemsKey],function(e,t){e.concat(t).length>0&&c.decryptErroredItems()}),c}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.deviceInterface=void 0,this.storageService=void 0,this.crypto.deinit(),this.crypto=void 0,this.operators={},this.keyObservers.length=0,this.removeItemsObserver(),this.removeItemsObserver=null,this.rootKey=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:return e=a.sent,a.next=5,b.awrap(this.getAccountKeyParams());case 5:return t=a.sent,a.next=8,b.awrap(this.hasRootKeyWrapper());case 8:if(n=a.sent,r=!Object(_.w)(e)||!Object(_.w)(t),!n||!r){a.next=14;break}this.keyMode=Bn.RootKeyPlusWrapper,a.next=27;break;case 14:if(!n||r){a.next=18;break}this.keyMode=Bn.WrapperOnly,a.next=27;break;case 18:if(n||!r){a.next=22;break}this.keyMode=Bn.RootKeyOnly,a.next=27;break;case 22:if(n||r){a.next=26;break}this.keyMode=Bn.RootKeyNone,a.next=27;break;case 26:throw'Invalid key mode condition';case 27:if(this.keyMode!==Bn.RootKeyOnly){a.next=33;break}return a.next=30,b.awrap(this.getRootKeyFromKeychain());case 30:return this.rootKey=a.sent,a.next=33,b.awrap(this.notifyObserversOfKeyChange());case 33:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getEncryptionSourceVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasAccount()){t.next=4;break}return t.abrupt("return",this.getUserVersion());case 4:if(!this.hasPasscode()){t.next=9;break}return t.next=7,b.awrap(this.getRootKeyWrapperKeyParams());case 7:return e=t.sent,t.abrupt("return",e.version);case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getEncryptionDisplayName",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getEncryptionSourceVersion());case 2:if(!(e=t.sent)){t.next=5;break}return t.abrupt("return",this.operatorForVersion(e).getEncryptionDisplayName());case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLatestVersion",value:function(){return Q.a.V004}},{key:"hasAccount",value:function(){switch(this.keyMode){case Bn.RootKeyNone:case Bn.WrapperOnly:return!1;case Bn.RootKeyOnly:case Bn.RootKeyPlusWrapper:return!0;default:throw Error("Unhandled keyMode value '".concat(this.keyMode,"'."))}}},{key:"getUserVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getAccountKeyParams());case 2:return e=t.sent,t.abrupt("return",null===e||void 0===e?void 0:e.version);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"upgradeAvailable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.accountUpgradeAvailable());case 2:return e=n.sent,n.next=5,b.awrap(this.passcodeUpgradeAvailable());case 5:return t=n.sent,n.abrupt("return",e||t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"accountUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"passcodeUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e.version!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"platformSupportsKeyDerivation",value:function(e){return Object(Q.b)(e.version,Q.a.V004)>=0||(!!Object(_.C)()||Object(_.y)())}},{key:"supportedVersions",value:function(){return[Q.a.V001,Q.a.V002,Q.a.V003,Q.a.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.getLatestVersion();return 1===Object(Q.b)(e,t)}},{key:"isProtocolVersionOutdated",value:function(e){var t,n=(g(t={},Q.a.V001,Date.parse('2018-01-01')),g(t,Q.a.V002,Date.parse('2020-01-01')),t)[e];return!!n&&(new Date).getTime()>n}},{key:"costMinimumForVersion",value:function(e){if(Object(Q.b)(e,Q.a.V003)>=0)throw'Cost minimums only apply to versions <= 002';if(e===Q.a.V001)return Rn.a.PbkdfMinCost;if(e===Q.a.V002)return Rn.b.PbkdfMinCost;throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===Q.a.V001)return new An(this.crypto);if(e===Q.a.V002)return new Fn(this.crypto);if(e===Q.a.V003)return new Ln(this.crypto);if(e===Q.a.V004)return new Wn(this.crypto);if(e===Q.a.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw Error("Unable to find operator for version ".concat(e))}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=t.version,r=this.operatorForVersion(n),a.abrupt("return",r.computeRootKey(e,t));case 3:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return a=r?this.operatorForVersion(r):this.defaultOperator(),i.abrupt("return",a.createRootKey(e,t,n));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"payloadContentFormatForIntent",value:function(e,t){if(t){if(e===Re.b.Sync||e===Re.b.FileEncrypted||e===Re.b.FilePreferEncrypted||e===Re.b.LocalStorageEncrypted||e===Re.b.LocalStoragePreferEncrypted)return ue.a.EncryptedString;throw'Unhandled encrypted case in protocolService.payloadContentFormatForIntent.'}if(e===Re.b.LocalStorageDecrypted||e===Re.b.LocalStoragePreferEncrypted||e===Re.b.FileDecrypted||e===Re.b.FilePreferEncrypted)return ue.a.DecryptedBareObject;if(e===Re.b.SyncDecrypted)return ue.a.DecryptedBase64String;throw'Unhandled decrypted case in protocolService.payloadContentFormatForIntent.'}},{key:"payloadByEncryptingPayload",value:function(e,t,n){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(!e.errorDecrypting){l.next=2;break}return l.abrupt("return",e);case 2:if(!e.deleted){l.next=4;break}return l.abrupt("return",e);case 4:if(!Object(_.w)(t)){l.next=6;break}throw Error('Attempting to encrypt payload with null intent');case 6:if(n||Object(Re.d)(t)){l.next=10;break}return l.next=9,b.awrap(this.keyToUseForEncryptionOfPayload(e,t));case 9:n=l.sent;case 10:if(n||!Object(Re.c)(t)){l.next=12;break}throw Error('Attempting to generate encrypted payload with no key.');case 12:if(e.format===ue.a.DecryptedBareObject){l.next=14;break}throw Error('Attempting to encrypt already encrypted payload.');case 14:if(e.content){l.next=16;break}throw Error('Attempting to encrypt payload with no content.');case 16:if(e.uuid){l.next=18;break}throw Error('Attempting to encrypt payload with no uuid.');case 18:if(!(null!==(r=n)&&void 0!==r&&r.errorDecrypting||null!==(a=n)&&void 0!==a&&a.waitingForKey)){l.next=20;break}throw Error('Attempting to encrypt payload with encrypted key.');case 20:return i=n?n.keyVersion:this.getLatestVersion(),s=this.payloadContentFormatForIntent(t,n),o=this.operatorForVersion(i),l.next=25,b.awrap(o.generateEncryptedParameters(e,s,n));case 25:if(c=l.sent){l.next=28;break}throw'Unable to generate encryption parameters';case 28:return u=Object(Ee.d)(e,t,c),l.abrupt("return",u);case 30:case"end":return l.stop()}},null,this,null,Promise)}},{key:"payloadsByEncryptingPayloads",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){u.next=11;break}return s=i.value,o=Object(_.v)(t)?t(s):t,u.next=7,b.awrap(this.payloadByEncryptingPayload(s,o,n));case 7:c=u.sent,r.push(c);case 9:u.next=2;break;case 11:return u.abrupt("return",r);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingPayload",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content){c.next=3;break}return we.a.error(Error('Attempting to decrypt payload that has no content.')),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0}));case 3:if((r=e.format)!==ue.a.DecryptedBareObject){c.next=6;break}return c.abrupt("return",e);case 6:if(t||r!==ue.a.EncryptedString){c.next=10;break}if(t=this.keyToUseForDecryptionOfPayload(e)){c.next=10;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 10:if(null===(n=t)||void 0===n||!n.errorDecrypting){c.next=12;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 12:return a=e.version,i=e.source,s=this.operatorForVersion(a),c.prev=15,c.next=18,b.awrap(s.generateDecryptedParameters(e,t));case 18:return o=c.sent,c.abrupt("return",Object(Ee.e)(e,o,i));case 22:return c.prev=22,c.t0=c.catch(15),console.error('Error decrypting payload',e,c.t0),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:case"end":return c.stop()}},null,this,[[15,22]],Promise)}},{key:"payloadsByDecryptingPayloads",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e){n.next=2;break}return n.abrupt("return",e);case 2:if(!0!==e.deleted||!Object(_.w)(e.content)){n.next=4;break}return n.abrupt("return",e);case 4:if(Object(_.A)(e.content)){n.next=7;break}return n.abrupt("return",e);case 7:return n.abrupt("return",r.payloadByDecryptingPayload(e,t));case 8:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",Promise.all(e.map(function(e){return n(e)})));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"decryptErroredItems",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==(e=this.itemManager.invalidItems.filter(function(e){return e.content_type!==F.a.ItemsKey})).length){r.next=3;break}return r.abrupt("return");case 3:return t=e.map(function(e){return e.payloadRepresentation()}),r.next=6,b.awrap(this.payloadsByDecryptingPayloads(t));case 6:return n=r.sent,r.next=9,b.awrap(this.payloadManager.emitPayloads(n,ht.a.LocalChanged));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsByDecryptingBackupFile",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v=this;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if(n=e.keyParams||e.auth_params,r=e.items,a=r.map(function(e){return Object(Ee.f)(e,ht.a.FileImport)}),i=[],!n){y.next=28;break}return s=this.createKeyParams(n),y.next=8,b.awrap(this.computeRootKey(t,s));case 8:return o=y.sent,c=a.filter(function(e){return e.content_type===F.a.ItemsKey}),y.next=12,b.awrap(this.payloadsByDecryptingPayloads(c,o));case 12:u=y.sent,l=u.map(function(e){return nt(e)}),Object(_.o)(i,u),p=function(e){var t,n,r,a;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content_type!==F.a.ItemsKey){c.next=2;break}return c.abrupt("return","continue");case 2:return c.prev=2,e.items_key_id&&(t=v.itemsKeyForPayload(e)),t||(n=u.find(function(t){return e.items_key_id===t.uuid}),r=e.version,n?t=nt(n):Object(Q.d)(s.version,Q.a.V004)?t=v.defaultItemsKeyForItemVersion(r,l):Object(Q.b)(r,Q.a.V003)<=0&&(t=o)),c.next=7,b.awrap(v.payloadByDecryptingPayload(e,t));case 7:a=c.sent,i.push(a),c.next=15;break;case 11:c.prev=11,c.t0=c.catch(2),i.push(Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting})),console.error('Error decrypting payload',e,c.t0);case 15:case"end":return c.stop()}},null,null,[[2,11]],Promise)},d=S(a);case 17:if((h=d()).done){y.next=26;break}return f=h.value,y.next=21,b.awrap(p(f));case 21:if("continue"!==y.sent){y.next=24;break}return y.abrupt("continue",24);case 24:y.next=17;break;case 26:y.next=29;break;case 28:i=a;case 29:return y.abrupt("return",i);case 30:case"end":return y.stop()}},null,this,null,Promise)}},{key:"createKeyParams",value:function(e){return Object(A.e)(e)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return t=this.itemManager.items,e===Re.b.FileDecrypted&&(t=t.filter(function(e){return e.content_type!==F.a.ItemsKey})),n=Promise.all(t.map(function(t){if(t.errorDecrypting)return t.payload.ejected();var n=Object(Ee.f)(t.payload,ht.a.FileImport);return i.payloadByEncryptingPayload(n,e).then(function(e){return e.ejected()})})),s.t0=this.getLatestVersion(),s.next=6,b.awrap(n);case 6:if(s.t1=s.sent,r={version:s.t0,items:s.t1},e!==Re.b.FileEncrypted){s.next=13;break}return s.next=11,b.awrap(this.getRootKeyParams());case 11:a=s.sent,r.keyParams=null===a||void 0===a?void 0:a.getPortableValue();case 13:return s.abrupt("return",r);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"onKeyStatusChange",value:function(e){var t=this;return this.keyObservers.push(e),function(){Object(_.M)(t.keyObservers,e)}}},{key:"notifyObserversOfKeyChange",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:e=S(this.keyObservers);case 1:if((t=e()).done){r.next=7;break}return n=t.value,r.next=5,b.awrap(n());case 5:r.next=1;break;case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getRootKeyFromKeychain",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:if(e=n.sent,!Object(_.w)(e)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.t0=b,n.t1=Ve,n.t2=zn,n.t3=zn({},e),n.t4={},n.next=12,b.awrap(this.getRootKeyParams());case 12:return n.t5=n.sent,n.t6={keyParams:n.t5},n.t7=(0,n.t2)(n.t3,n.t4,n.t6),n.t8=n.t1.Create.call(n.t1,n.t7),n.next=18,n.t0.awrap.call(n.t0,n.t8);case 18:return t=n.sent,n.abrupt("return",t);case 20:case"end":return n.stop()}},null,this,null,Promise)}},{key:"saveRootKeyToKeychain",value:function(){var e,t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Object(_.w)(this.rootKey)){n.next=2;break}throw'Attempting to non-existent root key to the keychain.';case 2:if(this.keyMode===Bn.RootKeyOnly){n.next=4;break}throw'Should not be persisting wrapped key to keychain.';case 4:return e=this.rootKey.getKeychainValue(),n.abrupt("return",this.executeCriticalFunction(function(){return t.deviceInterface.setNamespacedKeychainValue(e,t.identifier)}));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasRootKeyWrapper",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){return this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper}},{key:"rootKeyNeedsUnwrapping",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.hasRootKeyWrapper());case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}e.t0=Object(_.w)(this.rootKey);case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyWrapperKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getWrappedRootKey",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.WrappedRootKey,De.Nonwrapped));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode!==Bn.WrapperOnly){e.next=4;break}return e.abrupt("return",this.getRootKeyWrapperKeyParams());case 4:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){e.next=8;break}return e.abrupt("return",this.getAccountKeyParams());case 8:if(this.keyMode!==Bn.RootKeyNone){e.next=12;break}return e.abrupt("return",void 0);case 12:throw"Unhandled key mode for getRootKeyParams ".concat(this.keyMode);case 13:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateWrappingKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:if(t=a.sent,this.keyMode!==Bn.WrapperOnly){a.next=7;break}return a.abrupt("return",this.storageService.canDecryptWithKey(e));case 7:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){a.next=15;break}return n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:return r=a.sent,a.abrupt("return",!r.errorDecrypting);case 15:throw'Unhandled case in validateWrappingKey';case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeWrappingKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=r.sent,r.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=r.sent,r.abrupt("return",n);case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"unwrapRootKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.keyMode!==Bn.WrapperOnly){a.next=3;break}return this.rootKey=e,a.abrupt("return");case 3:if(this.keyMode===Bn.RootKeyPlusWrapper){a.next=5;break}throw'Invalid key mode condition for unwrapping.';case 5:return a.next=7,b.awrap(this.getWrappedRootKey());case 7:return t=a.sent,n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:if(!(r=a.sent).errorDecrypting){a.next=16;break}throw Error('Unable to decrypt root key with provided wrapping key.');case 16:return a.next=18,b.awrap(Ve.Create(r.contentObject,r.uuid));case 18:return this.rootKey=a.sent,a.next=21,b.awrap(this.notifyObserversOfKeyChange());case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setNewRootKeyWrapper",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.keyMode!==Bn.RootKeyNone){t.next=4;break}this.keyMode=Bn.WrapperOnly,t.next=9;break;case 4:if(this.keyMode!==Bn.RootKeyOnly){t.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,t.next=9;break;case 8:throw Error('Attempting to set wrapper on already wrapped key.');case 9:return t.next=11,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 11:if(this.keyMode!==Bn.WrapperOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){t.next=26;break}if(this.keyMode!==Bn.WrapperOnly){t.next=18;break}return this.rootKey=e,t.next=16,b.awrap(this.reencryptItemsKeys());case 16:t.next=20;break;case 18:return t.next=20,b.awrap(this.wrapAndPersistRootKey(e));case 20:return t.next=22,b.awrap(this.storageService.setValue(o.RootKeyWrapperKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 22:return t.next=24,b.awrap(this.notifyObserversOfKeyChange());case 24:t.next=27;break;case 26:throw Error('Invalid keyMode on setNewRootKeyWrapper');case 27:case"end":return t.stop()}},null,this,null,Promise)}},{key:"wrapAndPersistRootKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=Object(Ee.e)(this.rootKey,{content:this.rootKey.persistableValueWhenWrapping()}),r.next=3,b.awrap(this.payloadByEncryptingPayload(t,Re.b.LocalStorageEncrypted,e));case 3:return n=r.sent,r.next=6,b.awrap(this.storageService.setValue(o.WrappedRootKey,n.ejected(),De.Nonwrapped));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removeRootKeyWrapper",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper){e.next=2;break}throw Error('Attempting to remove root key wrapper on unwrapped key.');case 2:return this.keyMode===Bn.WrapperOnly?(this.keyMode=Bn.RootKeyNone,this.rootKey=void 0):this.keyMode===Bn.RootKeyPlusWrapper&&(this.keyMode=Bn.RootKeyOnly),e.next=5,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 5:return e.next=7,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 7:if(this.keyMode!==Bn.RootKeyOnly){e.next=10;break}return e.next=10,b.awrap(this.saveRootKeyToKeychain());case 10:return e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.keyParams){n.next=2;break}throw Error('keyParams must be supplied if setting root key.');case 2:if(this.rootKey!==e){n.next=4;break}throw Error('Attempting to set root key as same current value.');case 4:if(this.keyMode!==Bn.WrapperOnly){n.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,n.next=16;break;case 8:if(this.keyMode!==Bn.RootKeyNone){n.next=12;break}this.keyMode=Bn.RootKeyOnly,n.next=16;break;case 12:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){n.next=15;break}n.next=16;break;case 15:throw Error("Unhandled key mode for setNewRootKey ".concat(this.keyMode));case 16:return this.rootKey=e,n.next=19,b.awrap(this.storageService.setValue(o.RootKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 19:if(this.keyMode!==Bn.RootKeyOnly){n.next=24;break}return n.next=22,b.awrap(this.saveRootKeyToKeychain());case 22:n.next=29;break;case 24:if(this.keyMode!==Bn.RootKeyPlusWrapper){n.next=29;break}if(t){n.next=27;break}throw Error('wrappingKey must be supplied');case 27:return n.next=29,b.awrap(this.wrapAndPersistRootKey(t));case 29:return n.next=31,b.awrap(this.notifyObserversOfKeyChange());case 31:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getRootKey",value:function(){return this.rootKey}},{key:"clearLocalKeyState",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 2:return e.next=4,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 6:return e.next=8,b.awrap(this.storageService.removeValue(o.RootKeyParams,De.Nonwrapped));case 8:return this.keyMode=Bn.RootKeyNone,this.rootKey=void 0,e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:if(n=a.sent,!(r=this.rootKey.compare(n))){a.next=11;break}return a.abrupt("return",{valid:r,artifacts:{rootKey:n}});case 11:return a.abrupt("return",{valid:!1});case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"validatePasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=a.sent,a.next=8,b.awrap(this.validateWrappingKey(n));case 8:if(!(r=a.sent)){a.next=13;break}return a.abrupt("return",{valid:r,artifacts:{wrappingKey:n}});case 13:return a.abrupt("return",{valid:!1});case 14:case"end":return a.stop()}},null,this,null,Promise)}},{key:"keyToUseForEncryptionOfPayload",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Object(_.w)(t)){s.next=2;break}throw'Intent must be supplied when looking up key for encryption of item.';case 2:if(!Object(Re.a)(e.content_type)){s.next=13;break}if(n=this.getRootKey()){s.next=10;break}if(!Object(Re.c)(t)){s.next=9;break}throw Error('Root key encryption is required but no root key is available.');case 9:return s.abrupt("return",void 0);case 10:return s.abrupt("return",n);case 13:return r=this.getDefaultItemsKey(),s.next=16,b.awrap(this.getUserVersion());case 16:if(!(a=s.sent)||a===(null===r||void 0===r?void 0:r.keyVersion)){s.next=22;break}return i=this.latestItemsKeys(),s.abrupt("return",i.find(function(e){return e.keyVersion===a}));case 22:return s.abrupt("return",r);case 23:case"end":return s.stop()}},null,this,null,Promise)}},{key:"keyToUseForDecryptionOfPayload",value:function(e){if(Object(Re.a)(e.content_type))return this.getRootKey();if(e.items_key_id)return this.itemsKeyForPayload(e);var t=e.version;if(t!==this.getLatestVersion())return this.defaultItemsKeyForItemVersion(t);we.a.error(Error('No associated key found for item encrypted with latest protocol version.'))}},{key:"onSyncEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.b.FullSyncCompleted){t.next=3;break}return t.next=3,b.awrap(this.handleFullSyncCompletion());case 3:if(e!==At.b.DownloadFirstSyncCompleted){t.next=6;break}return t.next=6,b.awrap(this.handleDownloadFirstSyncCompletion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleDownloadFirstSyncCompletion",value:function(){var e,t,n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.hasAccount()){c.next=2;break}return c.abrupt("return");case 2:if(e=this.latestItemsKeys(),t=e.filter(function(e){return e.neverSynced}),n=e.filter(function(e){return!e.neverSynced}),r=n.find(function(e){return e.isDefault}),!!Object(_.w)(r)){c.next=12;break}return c.next=10,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(t)));case 10:c.next=21;break;case 12:if(!(a=this.getRootKey())){c.next=21;break}if(!((i=t.filter(function(e){return e.keyVersion!==a.keyVersion})).length>0)){c.next=18;break}return c.next=18,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(i)));case 18:if(0!==this.latestItemsKeys().length){c.next=21;break}return c.next=21,b.awrap(this.createNewDefaultItemsKey());case 21:return c.next=23,b.awrap(this.getUserVersion());case 23:if(s=c.sent,o=this.latestItemsKeys().find(function(e){return e.keyVersion===s}),!Object(_.w)(o)){c.next=28;break}return c.next=28,b.awrap(this.createNewDefaultItemsKey());case 28:this.syncUnsycnedItemsKeys();case 29:case"end":return c.stop()}},null,this,null,Promise)}},{key:"handleFullSyncCompletion",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,b.awrap(this.createNewDefaultItemsKey());case 4:if(this.keyMode!==Bn.WrapperOnly){e.next=6;break}return e.abrupt("return",this.repersistAllItems());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"syncUnsycnedItemsKeys",value:function(){if(this.hasAccount()){var e=this.latestItemsKeys().filter(function(e){return e.neverSynced&&!e.dirty&&!e.deleted});e.length>0&&this.itemManager.setItemsDirty(Object(Ke.b)(e))}}},{key:"repersistAllItems",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e)}),n.abrupt("return",this.storageService.savePayloads(t));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"latestItemsKeys",value:function(){return this.itemManager.itemsKeys()}},{key:"itemsKeyForPayload",value:function(e){return this.latestItemsKeys().find(function(t){return t.uuid===e.items_key_id||t.duplicateOf===e.items_key_id})}},{key:"getDefaultItemsKey",value:function(){var e=this.latestItemsKeys();if(1===e.length)return e[0];var t=e.filter(function(e){return e.isDefault});if(t.length>1){var n=t.filter(function(e){return!e.neverSynced});if(n.length,n.length>0)return n[0]}return t[0]}},{key:"getKeyEmbeddedKeyParams",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.payload.format!==ue.a.DecryptedBareObject){s.next=2;break}return s.abrupt("return",void 0);case 2:return t=e.version,n=this.operatorForVersion(t),s.next=6,b.awrap(n.getPayloadAuthenticatedData(e.payload));case 6:if(r=s.sent){s.next=9;break}return s.abrupt("return",void 0);case 9:if(!Object(Q.c)(t,Q.a.V003)){s.next=14;break}return a=r,s.abrupt("return",this.createKeyParams(a));case 14:return i=r.kp,s.abrupt("return",this.createKeyParams(i));case 16:case"end":return s.stop()}},null,this,null,Promise)}},{key:"reencryptItemsKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!((e=this.latestItemsKeys()).length>0)){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"defaultItemsKeyForItemVersion",value:function(e,t){var n=t||this.latestItemsKeys(),r=n.find(function(t){return t.isDefault&&t.keyVersion===e});return r||n.find(function(t){return t.keyVersion===e})}},{key:"needsNewRootKeyBasedItemsKey",value:function(){if(!this.hasAccount())return!1;var e=this.getRootKey();if(!e)return!1;if(Object(Q.b)(e.keyVersion,Yn)>0)return!1;var t=this.getDefaultItemsKey();return!t||t.itemsKey!==e.itemsKey}},{key:"createNewDefaultItemsKey",value:function(){var e,t,n,r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e=this.getRootKey(),t=e?e.keyVersion:this.getLatestVersion(),!(Object(Q.b)(t,Yn)<=0)){l.next=14;break}return l.t0=Object(Ee.e),l.next=6,b.awrap(I.GenerateUuid());case 6:l.t1=l.sent,l.t2=F.a.ItemsKey,l.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t}),l.t4={uuid:l.t1,content_type:l.t2,content:l.t3},r=(0,l.t0)(l.t4),n=nt(r),l.next=17;break;case 14:return l.next=16,b.awrap(this.operatorForVersion(t).createItemsKey());case 16:n=l.sent;case 17:a=this.latestItemsKeys(),i=a.filter(function(e){return e.isDefault}),s=S(i);case 20:if((o=s()).done){l.next=26;break}return c=o.value,l.next=24,b.awrap(this.itemManager.changeItemsKey(c.uuid,function(e){e.isDefault=!1}));case 24:l.next=20;break;case 26:return l.next=28,b.awrap(this.itemManager.insertItem(n));case 28:return u=l.sent,l.next=31,b.awrap(this.itemManager.changeItemsKey(u.uuid,function(e){e.isDefault=!0}));case 31:return l.abrupt("return",u);case 32:case"end":return l.stop()}},null,this,null,Promise)}},{key:"createNewItemsKeyWithRollback",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=this.getDefaultItemsKey(),a.next=3,b.awrap(this.createNewDefaultItemsKey());case 3:return t=a.sent,n=function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(Promise.all([r.itemManager.setItemToBeDeleted(t.uuid),r.itemManager.changeItem(e.uuid,function(e){e.isDefault=!0})]));case 2:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getPasswordCreatedDate",value:function(){var e=this.getRootKey();return e?e.keyParams.createdDate:void 0}}]),n})(R.a),Qn=(function(){function e(t,n){v(this,e),this.defaultContentKeyToDiffOn='text',this.payload=Object(Ee.b)(t),this.previousEntry=n,this.hasPreviousEntry=!Object(_.w)(n);var r=this.payload.content[this.defaultContentKeyToDiffOn];this.textCharDiffLength=r?n?r.length-n.payload.content[this.defaultContentKeyToDiffOn].length:this.payload.content[this.defaultContentKeyToDiffOn].length:0}return y(e,[{key:"itemFromPayload",value:function(){return nt(this.payload)}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=this.itemFromPayload(),n=e.itemFromPayload();return!(t.userModifiedDate.getTime()!==n.userModifiedDate.getTime())&&t.isItemContentEqualWith(n)}},{key:"isDiscardable",value:function(){return!1}},{key:"operationVector",value:function(){return void 0!==this.textCharDiffLength?this.hasPreviousEntry&&0!==this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!==this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}}]),e})(),Jn=(function(e){d(n,Qn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"previewTitle",value:function(){return this.payload.updated_at.getTime()>0?this.payload.updated_at.toLocaleString():this.payload.created_at.toLocaleString()}},{key:"previewSubTitle",value:function(){return this.hasPreviousEntry?this.textCharDiffLength<0?"".concat(-1*this.textCharDiffLength," characters removed"):this.textCharDiffLength>0?"".concat(this.textCharDiffLength," characters added"):'Title or metadata changed':"".concat(this.textCharDiffLength," characters loaded")}},{key:"isDiscardable",value:function(){return Object(_.t)(this.payload.safeContent.text)}}]),n})();function $n(e,t){return new(Xn(e[Je.a.ContentType]))(e,t)}function Xn(e){switch(e){case F.a.Note:return Jn;default:return Qn}}var Zn,er,tr=20,nr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s){var o;return v(this,n),(o=t.call(this)).itemManager=e,o.storageService=r,o.apiService=a,o.protocolService=i,o.deviceInterface=s,o.persistable=!1,o.autoOptimize=!1,o.historyStaging={},o.history={},o.historyTypes=[F.a.Note],o.itemRevisionThreshold=tr,o.removeChangeObserver=o.itemManager.addObserver(o.historyTypes,function(e,t){o.recordNewHistoryForItems(e.concat(t))}),o}return y(n,[{key:"deinit",value:function(){this.cancelPendingPersist(),this.itemManager=void 0,this.storageService=void 0,this.history=void 0,this.removeChangeObserver&&(this.removeChangeObserver(),this.removeChangeObserver=void 0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.SessionHistoryPersistable));case 2:return this.persistable=e.sent,e.next=5,b.awrap(this.getPersistedHistory());case 5:return this.history=e.sent,e.next=8,b.awrap(this.storageService.getValue(o.SessionHistoryOptimize,void 0,!0));case 8:this.autoOptimize=e.sent;case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPersistedHistory",value:function(){var e,t,n,r,a,i,s,c,u,p,d,h,f,v,y,g;return b.async(function(m){for(;;)switch(m.prev=m.next){case 0:return e={},m.next=3,b.awrap(this.storageService.getValue(o.SessionHistoryRevisions));case 3:if(t=m.sent){m.next=6;break}return m.abrupt("return",e);case 6:for(n=0,r=Object.entries(t);n<r.length;n++){for(a=r[n],i=l(a,2),s=i[0],c=i[1],u=c.slice().reverse(),p=[],d=S(u);!(h=d()).done;)f=h.value,v=Object(Ee.f)(f.payload,ht.a.SessionHistory),y=yt(p),g=$n(v,y),p.unshift(g);e[s]=p}return m.abrupt("return",e);case 8:case"end":return m.stop()}},null,this,null,Promise)}},{key:"recordNewHistoryForItems",value:function(e){for(var t,n=!1,r=S(e);!(t=r()).done;){var a=t.value;if(this.historyTypes.includes(a.content_type)){var i=a.payload;if(!a.deleted&&i.format===ue.a.DecryptedBareObject){var s=this.history[a.uuid]||[],o=yt(s),c=$n(Object(Ee.f)(a,ht.a.SessionHistory),o);if(!c.isDiscardable()){var u=this.historyStaging[a.uuid];this.historyStaging[a.uuid]=c,u&&(u.isSameAsEntry(c)||o&&u.isSameAsEntry(o)||(s.unshift(u),this.history[a.uuid]=s,this.autoOptimize&&this.optimizeHistoryForItem(a.uuid),n=!0))}}}}n&&this.saveToDisk()}},{key:"isDiskEnabled",value:function(){return this.persistable}},{key:"isAutoOptimizeEnabled",value:function(){return this.autoOptimize}},{key:"cancelPendingPersist",value:function(){this.saveTimeout&&('cancel'in this.deviceInterface.timeout?this.deviceInterface.timeout.cancel(this.saveTimeout):clearTimeout(this.saveTimeout))}},{key:"saveToDisk",value:function(){var e=this;if(this.persistable){this.cancelPendingPersist();var t=this.persistableHistoryValue();this.saveTimeout=this.deviceInterface.timeout(function(){e.storageService.setValue(o.SessionHistoryRevisions,t)},2e3)}}},{key:"persistableHistoryValue",value:function(){for(var e={},t=0,n=Object.entries(this.history);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1].map(function(e){return{payload:e.payload}});e[i]=s}return e}},{key:"setSessionItemRevisionThreshold",value:function(e){this.itemRevisionThreshold=e}},{key:"sessionHistoryForItem",value:function(e){return this.history[e.uuid]||[]}},{key:"clearHistoryForItem",value:function(e){delete this.history[e.uuid],this.saveToDisk()}},{key:"clearAllHistory",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.history={},e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleDiskSaving",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistable=!this.persistable,!this.persistable){e.next=6;break}this.storageService.setValue(o.SessionHistoryPersistable,!0),this.saveToDisk(),e.next=8;break;case 6:return this.storageService.setValue(o.SessionHistoryPersistable,!1),e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 8:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleAutoOptimize",value:function(){this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageService.setValue(o.SessionHistoryOptimize,!0):this.storageService.setValue(o.SessionHistoryOptimize,!1)}},{key:"getHistoryMapCopy",value:function(){for(var e=w({},this.history),t=0,n=Object.entries(e);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1];e[i]=s.slice()}return Object.freeze(e)}},{key:"remoteHistoryForItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.getItemRevisions(e.uuid));case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.abrupt("return",t.data);case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"fetchRemoteRevision",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.apiService.getRevision(t,e));case 2:if(!(n=o.sent).error&&!Object(_.w)(n.data)){o.next=5;break}return o.abrupt("return",void 0);case 5:return r=n.data,a=Object(Ee.e)(r,{uuid:r.item_uuid}),i=Object(Ee.f)(a,ht.a.RemoteHistory),o.next=10,b.awrap(this.protocolService.payloadByDecryptingPayload(i));case 10:if(!(s=o.sent).errorDecrypting){o.next=13;break}return o.abrupt("return",void 0);case 13:return o.abrupt("return",new Qn(s));case 14:case"end":return o.stop()}},null,this,null,Promise)}},{key:"optimizeHistoryForItem",value:function(e){var t=this.history[e]||[];if(!(t.length<=this.itemRevisionThreshold)){for(var n=function(e){return e.deltaSize()>25},r=[],a=function(e,a,i){if(i){if(r.unshift(e),n(e)&&-1===e.operationVector()){var s=t[a+1];s&&r.unshift(s)}}else Object(_.M)(r,e)},i=t.length-1;i>=0;i--){var s=t[i];a(s,i,0===i||i===t.length-1||n(s))}var o=t.filter(function(e){return r.includes(e)});this.history[e]=o}}}]),n})(R.a);!(function(e){e.SessionExpiryDateChanged="SessionExpiryDateChanged"})(Zn||(Zn={})),(function(e){e[e.None=0]="None",e[e.FiveMinutes=300]="FiveMinutes",e[e.OneHour=3600]="OneHour",e[e.OneWeek=604800]="OneWeek"})(er||(er={}));var rr,ar=[{valueInSeconds:er.None,label:"Don't Remember"},{valueInSeconds:er.FiveMinutes,label:'5 Minutes'},{valueInSeconds:er.OneHour,label:'1 Hour'},{valueInSeconds:er.OneWeek,label:'1 Week'}],ir=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).protocolService=e,s.challengeService=r,s.storageService=a,s.itemManager=i,s.sessionExpiryTimeout=-1,s}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.challengeService=void 0,this.storageService=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return e===ve.LoadedDatabase_12&&this.updateSessionExpiryTimer(this.getSessionExpiryDate()),Promise.resolve()}},{key:"hasProtectionSources",value:function(){return this.protocolService.hasAccount()||this.protocolService.hasPasscode()||this.hasBiometricsEnabled()}},{key:"areProtectionsEnabled",value:function(){return this.hasProtectionSources()&&this.getSessionExpiryDate()<=new Date}},{key:"hasBiometricsEnabled",value:function(){var e=this.storageService.getValue(o.BiometricsState,De.Nonwrapped);return Boolean(e)}},{key:"enableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to enable biometrics when they already are enabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.storageService.setValue(o.BiometricsState,!0,De.Nonwrapped));case 5:return e.abrupt("return",!0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"disableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to disable biometrics when they already are disabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.validateOrRenewSession(ne.DisableBiometrics));case 5:if(!e.sent){e.next=11;break}return e.next=8,b.awrap(this.storageService.setValue(o.BiometricsState,!1,De.Nonwrapped));case 8:return e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"createLaunchChallenge",value:function(){var e=[];return this.hasBiometricsEnabled()&&e.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&e.push(new ge(te.LocalPasscode)),e.length>0?new ye(e,ne.ApplicationUnlock,!1):void 0}},{key:"protectNote",value:function(e){return this.itemManager.changeItem(e.uuid,function(e){e.protected=!0})}},{key:"unprotectNote",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.validateOrRenewSession(ne.UnprotectNote));case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.itemManager.changeItem(e.uuid,function(e){e.protected=!1}));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){c.next=15;break}if(s=i.value,(o=s.protected&&this.areProtectionsEnabled())&&!n&&(n=this.validateOrRenewSession(t)),c.t0=!o,c.t0){c.next=11;break}return c.next=10,b.awrap(n);case 10:c.t0=c.sent;case 11:if(!c.t0){c.next=13;break}r.push(s);case 13:c.next=2;break;case 15:return c.abrupt("return",r);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){return this.itemManager.changeItems(Object(Ke.b)(e),function(e){e.protected=!0})}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.authorizeProtectedActionForNotes(e,ne.UnprotectNote));case 2:return t=n.sent,n.abrupt("return",this.itemManager.changeItems(Object(Ke.b)(t),function(e){e.protected=!1}));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeNoteAccess",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.protected){t.next=2;break}return t.abrupt("return",!0);case 2:return t.abrupt("return",this.validateOrRenewSession(ne.AccessProtectedNote));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeAddingPasscode",value:function(){return this.validateOrRenewSession(ne.AddPasscode)}},{key:"authorizeChangingPasscode",value:function(){return this.validateOrRenewSession(ne.ChangePasscode)}},{key:"authorizeRemovingPasscode",value:function(){return this.validateOrRenewSession(ne.RemovePasscode)}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.validateOrRenewSession(ne.SearchProtectedNotesText)}},{key:"authorizeFileImport",value:function(){return this.validateOrRenewSession(ne.ImportFile)}},{key:"authorizeBackupCreation",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.validateOrRenewSession(ne.ExportBackup,{fallBackToAccountPassword:e}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeMfaDisable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.DisableMfa,{requireAccountPassword:!0}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeAutolockIntervalChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.ChangeAutolockInterval));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeSessionRevoking",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.RevokeSession));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeCloudLinkAccess",value:function(){return this.validateOrRenewSession(ne.AccessCloudLink)}},{key:"validateOrRenewSession",value:function(e){var t,n,r,a,i,s,o,c,u,l=arguments;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>1&&void 0!==l[1]?l[1]:{},n=t.fallBackToAccountPassword,r=void 0===n||n,a=t.requireAccountPassword,i=void 0!==a&&a,!(this.getSessionExpiryDate()>new Date)){p.next=3;break}return p.abrupt("return",!0);case 3:if(s=[],this.hasBiometricsEnabled()&&s.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&s.push(new ge(te.LocalPasscode)),!i){p.next=10;break}if(this.protocolService.hasAccount()){p.next=9;break}throw Error('Requiring account password for challenge with no account');case 9:s.push(new ge(te.AccountPassword));case 10:if(0!==s.length){p.next=16;break}if(!r||!this.protocolService.hasAccount()){p.next=15;break}s.push(new ge(te.AccountPassword)),p.next=16;break;case 15:return p.abrupt("return",!0);case 16:return p.t0=s,p.t1=ge,p.t2=te.ProtectionSessionDuration,p.t3=void 0,p.t4=void 0,p.t5=void 0,p.t6=void 0,p.next=25,b.awrap(this.getSessionLength());case 25:return p.t7=p.sent,p.t8=new p.t1(p.t2,p.t3,p.t4,p.t5,p.t6,p.t7),p.t0.push.call(p.t0,p.t8),p.next=30,b.awrap(this.challengeService.promptForChallengeResponse(new ye(s,e,!0)));case 30:if(!(o=p.sent)){p.next=42;break}if(u=null===(c=o.values.find(function(e){return e.prompt.validation===te.ProtectionSessionDuration}))||void 0===c?void 0:c.value,!Object(_.w)(u)){p.next=37;break}we.a.error(Error('No valid protection session length found. Got '+u)),p.next=39;break;case 37:return p.next=39,b.awrap(this.setSessionLength(u));case 39:return p.abrupt("return",!0);case 42:return p.abrupt("return",!1);case 43:case"end":return p.stop()}},null,this,null,Promise)}},{key:"getSessionExpiryDate",value:function(){var e=this.storageService.getValue(o.ProtectionExpirey);return e?new Date(e):new Date}},{key:"clearSession",value:function(){return this.setSessionExpiryDate(new Date)}},{key:"setSessionExpiryDate",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.ProtectionExpirey,e));case 2:this.notifyEvent(Zn.SessionExpiryDateChanged);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSessionLength",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ProtectionSessionLength));case 2:if(!(e=t.sent)){t.next=7;break}return t.abrupt("return",e);case 7:return t.abrupt("return",er.None);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setSessionLength",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.storageService.setValue(o.ProtectionSessionLength,e));case 2:return(t=new Date).setSeconds(t.getSeconds()+e),n.next=6,b.awrap(this.setSessionExpiryDate(t));case 6:this.updateSessionExpiryTimer(t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSessionExpiryTimer",value:function(e){var t=this,n=e.getTime();if(n>Date.now()){clearTimeout(this.sessionExpiryTimeout),this.sessionExpiryTimeout=setTimeout(function(){t.setSessionExpiryDate(new Date)},n-Date.now())}}}]),n})(R.a),sr=n(45),or=n(19);!(function(e){e.UserRoleMessageReceived="WebSocketMessageReceived"})(rr||(rr={}));var cr,ur,lr=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.webSocketUrl=r,a}return y(n,[{key:"setWebSocketUrl",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.webSocketUrl=e,t.next=3,b.awrap(this.storageService.setValue(o.WebSocketUrl,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadWebSocketUrl",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.WebSocketUrl));case 2:e=t.sent,this.webSocketUrl=e||this.webSocketUrl||window._websocket_url;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"startWebSocketConnection",value:function(e){if(this.webSocketUrl)try{this.webSocket=new WebSocket("".concat(this.webSocketUrl,"?authToken=Bearer+").concat(e)),this.webSocket.onmessage=this.onWebSocketMessage.bind(this),this.webSocket.onclose=this.onWebSocketClose.bind(this)}catch(e){console.error('Error starting WebSocket connection',e)}}},{key:"closeWebSocketConnection",value:function(){var e;null===(e=this.webSocket)||void 0===e||e.close()}},{key:"onWebSocketMessage",value:function(e){var t=JSON.parse(e.data);this.notifyEvent(rr.UserRoleMessageReceived,t)}},{key:"onWebSocketClose",value:function(){this.webSocket=void 0}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.storageService=void 0,this.closeWebSocketConnection()}}]),n})(R.a),pr=n(29);!(function(e){e.UserRolesChanged="UserRolesChanged",e.FeaturesUpdated="FeaturesUpdated"})(cr||(cr={})),(function(e){e.NoUserSubscription="NoUserSubscription",e.NotInCurrentPlan="NotInCurrentPlan",e.InCurrentPlanButExpired="InCurrentPlanButExpired",e.Entitled="Entitled"})(ur||(ur={}));var dr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l,p,d){var h;return v(this,n),(h=t.call(this)).storageService=e,h.apiService=r,h.itemManager=a,h.componentManager=i,h.webSocketsService=s,h.settingsService=o,h.credentialService=c,h.syncService=u,h.alertService=l,h.sessionManager=p,h.crypto=d,h.deinited=!1,h.roles=[],h.features=[],h.needsInitialFeaturesUpdate=!0,h.completedSuccessfulFeaturesRetrieval=!1,h.removeApiServiceObserver=r.addEventObserver(function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==Ht.MetaReceived){a.next=6;break}if(h.syncService.completedOnlineDownloadFirstSync){a.next=3;break}return a.abrupt("return");case 3:return n=t.userUuid,r=t.userRoles,a.next=6,b.awrap(h.updateRoles(n,r.map(function(e){return e.name})));case 6:case"end":return a.stop()}},null,null,null,Promise)}),h.removeWebSocketsServiceObserver=s.addEventObserver(function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e!==rr.UserRoleMessageReceived){i.next=6;break}return n=t.payload,r=n.userUuid,a=n.currentRoles,i.next=4,b.awrap(h.setRoles(a));case 4:return i.next=6,b.awrap(h.updateFeatures(r));case 6:case"end":return i.stop()}},null,null,null,Promise)}),h.removefeatureReposObserver=h.itemManager.addObserver(or.ContentType.ExtensionRepo,function(e,t,n,r,a){var i,s;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=[ht.a.Constructor,ht.a.LocalRetrieved,ht.a.RemoteRetrieved,ht.a.FileImport],!a||!i.includes(a)){n.next=10;break}if(s=[].concat(m(e),m(t)).filter(function(e){return!e.deleted}),!h.sessionManager.isSignedIntoFirstPartyServer()){n.next=8;break}return n.next=6,b.awrap(h.migrateFeatureRepoToUserSetting(s));case 6:n.next=10;break;case 8:return n.next=10,b.awrap(h.migrateFeatureRepoToOfflineEntitlements(s));case 10:case"end":return n.stop()}},null,null,null,Promise)}),h.removeSignInObserver=h.credentialService.addEventObserver(function(e){if(e===Ye.SignedInOrRegistered){var t=h.itemManager.getItems(or.ContentType.ExtensionRepo);h.apiService.isThirdPartyHostUsed()||h.migrateFeatureRepoToUserSetting(t)}}),h}return y(n,[{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.FullSyncCompleted_13&&(t=this.getOfflineRepo())&&this.downloadOfflineFeatures(t);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setOfflineFeaturesCode",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,t=e.replace(/\s/g,''),i.next=4,b.awrap(this.crypto.base64Decode(t));case 4:if(n=i.sent,r=this.parseOfflineEntitlementsCode(n),!Object(_.u)(r)){i.next=8;break}return i.abrupt("return",r);case 8:return i.next=10,b.awrap(this.itemManager.createItem(or.ContentType.ExtensionRepo,Object(Ke.a)({offlineFeaturesUrl:r.featuresUrl,offlineKey:r.extensionKey,migratedToOfflineEntitlements:!0}),!0));case 10:return a=i.sent,this.syncService.sync(),i.abrupt("return",this.downloadOfflineFeatures(a));case 15:return i.prev=15,i.t0=i.catch(0),i.abrupt("return",{error:j.e});case 18:case"end":return i.stop()}},null,this,[[0,15]],Promise)}},{key:"getOfflineRepo",value:function(){return this.itemManager.getItems(or.ContentType.ExtensionRepo).filter(function(e){return e.migratedToOfflineEntitlements})[0]}},{key:"hasOfflineRepo",value:function(){return void 0!=this.getOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this.getOfflineRepo())){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 4:return t.next=6,b.awrap(this.storageService.removeValue(o.UserFeatures));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"parseOfflineEntitlementsCode",value:function(e){try{var t=JSON.parse(e);return{featuresUrl:t.featuresUrl,extensionKey:t.extensionKey}}catch(e){return{error:j.e}}}},{key:"downloadOfflineFeatures",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.downloadOfflineFeaturesFromRepo(e));case 2:if(t=n.sent,!Object(_.u)(t)){n.next=5;break}return n.abrupt("return",t);case 5:return n.next=7,b.awrap(this.didDownloadFeatures(t.features));case 7:return n.next=9,b.awrap(this.mapFeaturesToItems(t.features));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToUserSetting",value:function(){var e,t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:[],t=S(e);case 2:if((n=t()).done){c.next=17;break}if(!(r=n.value).migratedToUserSetting){c.next=6;break}return c.abrupt("continue",15);case 6:if(!r.onlineUrl){c.next=15;break}if(a=r.onlineUrl,!((i=a.match(/\w{32,64}/))&&i.length>0)){c.next=15;break}return s=i[0],c.next=13,b.awrap(this.settingsService.updateSetting(pr.SettingName.ExtensionKey,s,!0));case 13:return c.next=15,b.awrap(this.itemManager.changeFeatureRepo(r.uuid,function(e){e.migratedToUserSetting=!0}));case 15:c.next=2;break;case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToOfflineEntitlements",value:function(){var e,t,n,r,a,i,s,o=this,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=c.length>0&&void 0!==c[0]?c[0]:[],t=S(e);case 2:if((n=t()).done){u.next=17;break}if(!(r=n.value).migratedToOfflineEntitlements){u.next=6;break}return u.abrupt("continue",15);case 6:if(!r.onlineUrl){u.next=15;break}if(a=r.onlineUrl,i=new URL(a),i.origin.includes("https://extensions.standardnotes.org")){u.next=11;break}return u.abrupt("continue",15);case 11:if(!((s=a.match(/\w{32,64}/))&&s.length>0)){u.next=15;break}return u.next=15,b.awrap((function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=s[0],n.next=3,b.awrap(o.itemManager.changeFeatureRepo(r.uuid,function(t){t.offlineFeaturesUrl="https://api.standardnotes.com/v1/offline/features",t.offlineKey=e,t.migratedToOfflineEntitlements=!0}));case 3:return t=n.sent,n.next=6,b.awrap(o.downloadOfflineFeatures(t));case 6:case"end":return n.stop()}},null,null,null,Promise)})());case 15:u.next=2;break;case 17:case"end":return u.stop()}},null,null,null,Promise)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.UserRoles,void 0,[]));case 2:return this.roles=e.sent,e.next=5,b.awrap(this.storageService.getValue(o.UserFeatures,void 0,[]));case 5:this.features=e.sent;case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"updateRoles",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.haveRolesChanged(t)&&!this.needsInitialFeaturesUpdate){n.next=7;break}return this.needsInitialFeaturesUpdate=!1,n.next=5,b.awrap(this.setRoles(t));case 5:return n.next=7,b.awrap(this.updateFeatures(e));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setRoles",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles=e,Object(_.e)(this.roles,e)||this.notifyEvent(cr.UserRolesChanged),t.next=4,b.awrap(this.storageService.setValue(o.UserRoles,this.roles));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"didDownloadFeatures",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.features=e,this.completedSuccessfulFeaturesRetrieval=!0,this.notifyEvent(cr.FeaturesUpdated),t.next=5,b.awrap(this.storageService.setValue(o.UserFeatures,this.features));case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getFeature",value:function(e){return this.features.find(function(t){return t.identifier===e})}},{key:"hasPaidOnlineOrOfflineSubscription",value:function(){if(this.sessionManager.isSignedIntoFirstPartyServer()){var e=this.roles,t=[sr.RoleName.BasicUser];return e.some(function(e){return!t.includes(e)})}return this.hasOfflineRepo()}},{key:"getFeatureStatus",value:function(e){if(void 0==L.Features.find(function(t){return t.identifier===e})){var t=this.itemManager.components.find(function(t){return t.identifier===e});return null!==t&&void 0!==t&&t.isExpired?ur.InCurrentPlanButExpired:ur.Entitled}if(this.hasPaidOnlineOrOfflineSubscription()&&!this.completedSuccessfulFeaturesRetrieval)return ur.Entitled;if(!this.hasPaidOnlineOrOfflineSubscription())return ur.NoUserSubscription;var n=this.features.find(function(t){return t.identifier===e});return n?n.expires_at&&new Date(n.expires_at).getTime()<(new Date).getTime()?this.roles.includes(n.role_name)?ur.InCurrentPlanButExpired:ur.NotInCurrentPlan:ur.Entitled:ur.NotInCurrentPlan}},{key:"haveRolesChanged",value:function(e){var t=this;return e.some(function(e){return!t.roles.includes(e)})||this.roles.some(function(t){return!e.includes(t)})}},{key:"updateFeatures",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.apiService.getUserFeatures(e));case 2:if((t=r.sent).error||!t.data||this.deinited){r.next=10;break}return(n=t.data.features).forEach(function(e){e.expires_at&&(e.expires_at=Object(_.i)(e.expires_at))}),r.next=8,b.awrap(this.didDownloadFeatures(n));case 8:return r.next=10,b.awrap(this.mapFeaturesToItems(n));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"componentContentForFeatureDescription",value:function(e){var t={area:e.area,hosted_url:e.url,name:e.name,package_info:e,valid_until:new Date(e.expires_at||0)};return Object(Ke.a)(t)}},{key:"mapFeaturesToItems",value:function(e){var t,n,r,a,i,s,o,c,u=this;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:t=this.itemManager.getItems([or.ContentType.Component,or.ContentType.Theme]),n=[],r=new Date,a=!1,i=function(e){var i,s,o,c;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e.content_type){l.next=2;break}return l.abrupt("return","continue");case 2:if(!e.url||Object(_.B)(e.url)){l.next=5;break}return l.abrupt("return","continue");case 5:if(i=new Date(e.expires_at||0).getTime()<r.getTime(),s=t.find(function(t){return!!t.safeContent.package_info&&(t.safeContent.package_info.identifier===e.identifier&&!t.deleted)}),o=s,!s){l.next=21;break}if(c=new Date(e.expires_at||0),!(e.url!==s.hosted_url||e.version!==s.package_info.version||c.getTime()!==s.valid_until.getTime())){l.next=18;break}return l.next=14,b.awrap(u.itemManager.changeComponent(s.uuid,function(t){t.hosted_url=e.url,t.package_info=e,t.valid_until=c}));case 14:o=l.sent,a=!0,l.next=19;break;case 18:o=s;case 19:l.next=26;break;case 21:if(i&&e.content_type!==or.ContentType.Component){l.next=26;break}return l.next=24,b.awrap(u.itemManager.createItem(e.content_type,u.componentContentForFeatureDescription(e),!0));case 24:o=l.sent,a=!0;case 26:i&&o&&(e.content_type===or.ContentType.Component?u.componentManager.setReadonlyStateForComponent(o,i):(n.push(o.uuid),a=!0));case 27:case"end":return l.stop()}},null,null,null,Promise)},s=S(e);case 6:if((o=s()).done){l.next=15;break}return c=o.value,l.next=10,b.awrap(i(c));case 10:if("continue"!==l.sent){l.next=13;break}return l.abrupt("continue",13);case 13:l.next=6;break;case 15:return l.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(n));case 17:a&&this.syncService.sync();case 18:case"end":return l.stop()}},null,this,null,Promise)}},{key:"validateAndDownloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=e,i.prev=1,i.next=4,b.awrap(this.crypto.base64Decode(e));case 4:t=i.sent,i.next=9;break;case 7:i.prev=7,i.t0=i.catch(1);case 9:if(i.prev=9,n=[].concat(Ft,Nt),r=new URL(t),a=r.host,n.includes(a)){i.next=20;break}return i.next=15,b.awrap(this.alertService.confirm(j.t,'Install extension from an untrusted source?','Proceed to install',St.Danger,'Cancel'));case 15:if(!i.sent){i.next=18;break}return i.abrupt("return",this.downloadExternalFeature(t));case 18:i.next=21;break;case 20:return i.abrupt("return",this.downloadExternalFeature(t));case 21:i.next=26;break;case 23:i.prev=23,i.t1=i.catch(9),this.alertService.alert(j.C);case 26:case"end":return i.stop()}},null,this,[[1,7],[9,23]],Promise)}},{key:"downloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.apiService.downloadFeatureUrl(e));case 2:if(!(t=i.sent).error){i.next=7;break}return i.next=6,b.awrap(this.alertService.alert(j.c));case 6:return i.abrupt("return",void 0);case 7:if((n=t.data).content_type){i.next=10;break}return i.abrupt("return");case 10:return r=this.componentContentForFeatureDescription(n),i.next=13,b.awrap(this.itemManager.createTemplateItem(n.content_type,r));case 13:return a=i.sent,i.abrupt("return",a);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.removeSignInObserver(),this.removeSignInObserver=void 0,this.removeApiServiceObserver(),this.removeApiServiceObserver=void 0,this.removeWebSocketsServiceObserver(),this.removeWebSocketsServiceObserver=void 0,this.removefeatureReposObserver(),this.removefeatureReposObserver=void 0,this.roles=void 0,this.storageService=void 0,this.apiService=void 0,this.itemManager=void 0,this.componentManager=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.credentialService=void 0,this.syncService=void 0,this.alertService=void 0,this.sessionManager=void 0,this.crypto=void 0,this.deinited=!0}}]),n})(R.a),hr=n(46),fr=(function(){function e(t,n){v(this,e),this.completedUpload=0,this.totalUpload=0,this.downloaded=0,this.databaseLoadCurrent=0,this.databaseLoadTotal=0,this.databaseLoadDone=!1,this.syncing=!1,this.interval=t,this.receiver=n}return y(e,[{key:"deinit",value:function(){this.stopTimingMonitor()}},{key:"setUploadStatus",value:function(e,t){this.completedUpload=e,this.totalUpload=t,this.receiver(on.a.StatusChanged)}},{key:"setDownloadStatus",value:function(e){this.downloaded+=e,this.receiver(on.a.StatusChanged)}},{key:"setDatabaseLoadStatus",value:function(e,t,n){this.databaseLoadCurrent=e,this.databaseLoadTotal=t,this.databaseLoadDone=n,n?this.receiver(on.a.LocalDataLoaded):this.receiver(on.a.LocalDataIncrementalLoad)}},{key:"getStats",value:function(){return{uploadCompletionCount:this.completedUpload,uploadTotalCount:this.totalUpload,downloadCount:this.downloaded,localDataDone:this.databaseLoadDone,localDataCurrent:this.databaseLoadCurrent,localDataTotal:this.databaseLoadTotal}}},{key:"setDidBegin",value:function(){this.syncing=!0,this.syncStart=new Date}},{key:"setDidEnd",value:function(){this.syncing=!1,this.syncEnd=new Date}},{key:"startTimingMonitor",value:function(){var e=this;this.timingMonitor&&this.stopTimingMonitor(),this.timingMonitor=this.interval(function(){e.secondsSinceSyncStart>5&&(e.receiver(on.a.SyncTakingTooLong),e.stopTimingMonitor())},500)}},{key:"stopTimingMonitor",value:function(){Object.prototype.hasOwnProperty.call(this.interval,'cancel')?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return!!this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.syncing=!1,this.error=null,this.stopTimingMonitor(),this.receiver(on.a.StatusChanged)}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return((new Date).getTime()-this.syncStart.getTime())/1e3}}]),e})();function vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mr,br=(function(){function e(){v(this,e),this.tags=[],this.includePinned=!0,this.includeProtected=!0,this.includeTrashed=!1,this.includeArchived=!1}return y(e,[{key:"computeFilters",value:function(e){for(var t,n=this,r=this.tags.filter(function(e){return!e.isSmartTag}),a=this.tags.filter(function(e){return e.isSmartTag}),i=a.filter(function(e){return e.isSystemSmartTag}),s=a.filter(function(e){return!e.isSystemSmartTag}),o=!1,c=!1,u=[],l=S(i);!(t=l()).done;){var p=t.value;p.isArchiveTag?(u.push(function(e){return e.archived&&!e.deleted}),o=!0):p.isTrashTag&&(u.push(function(e){return e.trashed&&!e.deleted}),c=!0)}if(s.length>0){var d=H.a.CompoundPredicate(s.map(function(e){return e.predicate}));u.push(function(t){if(d.keypathIncludesVerb('tags')){var n=yr(yr(yr({},t),t.payload),{},{tags:e.elementsReferencingElement(t,F.a.Tag)});return H.a.ObjectSatisfiesPredicate(n,d)}return H.a.ObjectSatisfiesPredicate(t,d)})}else if(r.length>0)for(var h,f=function(e){u.push(function(t){return e.hasRelationshipWithItem(t)})},v=S(r);!(h=v()).done;){f(h.value)}return this.searchQuery&&u.push(function(t){return xr(t,n.searchQuery,e)}),this.includePinned||u.push(function(e){return!e.pinned}),this.includeProtected||u.push(function(e){return!e.protected}),this.includeTrashed||c||u.push(function(e){return!e.trashed}),this.includeArchived||o||c||u.push(function(e){return!e.archived}),u}}],[{key:"Create",value:function(t){var n=new e;return w(n,t),Object.freeze(n)}},{key:"Copy",value:function(t,n){var r=new e;return w(r,t),w(r,n),Object.freeze(r)}}]),e})();function wr(e,t){var n=e.computeFilters(t);return t.displayElements(F.a.Note).filter(function(e){return kr(e,n)})}function kr(e,t){for(var n,r=S(t);!(n=r()).done;){if(!(0,n.value)(e))return!1}return!0}function xr(e,t,n){var r=n.elementsReferencingElement(e,F.a.Tag).some(function(e){return Pr(e,t.query)!==mr.None});if(e.protected&&!t.includeProtectedNoteText){var a=Sr(e,t.query);return a===mr.Title||a===mr.TitleAndText||r}return Sr(e,t.query)!==mr.None||r}function Sr(e,t){if(0===t.length)return mr.TitleAndText;var n=e.safeTitle().toLowerCase(),r=e.safeText().toLowerCase(),a=t.toLowerCase(),i=a.split(' '),s=Or(a);if(s)return(n.includes(s)?mr.Title:mr.None)+(r.includes(s)?mr.Text:mr.None);if(Cr(a))return e.uuid===a?mr.Uuid:mr.None;var o=i.every(function(e){return n.indexOf(e)>=0}),c=i.every(function(e){return r.indexOf(e)>=0});return(o?mr.Title:0)+(c?mr.Text:0)}function Pr(e,t){if(0===t.length)return mr.None;var n=e.title.toLowerCase(),r=t.toLowerCase(),a=r.split(' '),i=Or(r);return i?n.includes(i)?mr.Title:mr.None:a.every(function(e){return n.indexOf(e)>=0})?mr.Title:mr.None}function Or(e){var t=e.match(/"(.*?)"/);return t?t[1]:null}function Cr(e){return!!e.match(/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)}!(function(e){e[e.None=0]="None",e[e.Title=1]="Title",e[e.Text=2]="Text",e[e.TitleAndText=3]="TitleAndText",e[e.Uuid=5]="Uuid"})(mr||(mr={}));var Dr=(function(){function e(t){v(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:br.Create({});this.collection=t,this.criteria=n,this.displayedNotes=[],this.needsRebuilding=!0}return y(e,[{key:"setCriteria",value:function(e){this.criteria=e,this.collection.setDisplayOptions(F.a.Note,e.sortProperty,e.sortDirection),this.needsRebuilding=!0}},{key:"notesMatchingSmartTag",value:function(e){var t;return wr((t=e,br.Create({tags:[t]})),this.collection)}},{key:"rebuildList",value:function(){var e=this,t=br.Copy(this.criteria,{tags:this.criteria.tags.map(function(t){return t.isSystemSmartTag?t:e.collection.find(t.uuid)})});this.displayedNotes=wr(t,this.collection)}},{key:"setNeedsRebuilding",value:function(){this.needsRebuilding=!0}},{key:"displayElements",value:function(){return this.needsRebuilding&&(this.rebuildList(),this.needsRebuilding=!1),this.displayedNotes.slice()}}]),e})(),_r=(function(e){d(n,e);var t=k(n);function n(e){var r,a,i,s;return v(this,n),(r=t.call(this)).payloadManager=e,r.observers=[],r.payloadManager=e,r.systemSmartTags=(a=Object(Ee.e)({uuid:Er,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'All notes',isSystemTag:!0,isAllTag:!0})}),i=Object(Ee.e)({uuid:Rr,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Archived',isSystemTag:!0,isArchiveTag:!0})}),s=Object(Ee.e)({uuid:Ir,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Trash',isSystemTag:!0,isTrashTag:!0})}),[nt(a),nt(i),nt(s)]),r.createCollection(),r.unsubChangeObserver=r.payloadManager.addObserver(F.a.Any,r.setPayloads.bind(u(r))),r}return y(n,[{key:"createCollection",value:function(){this.collection=new gn,this.collection.setDisplayOptions(F.a.Note,dn.CreatedAt,'dsc'),this.collection.setDisplayOptions(F.a.Tag,dn.Title,'dsc'),this.collection.setDisplayOptions(F.a.ItemsKey,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Component,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Theme,dn.Title,'asc'),this.collection.setDisplayOptions(F.a.SmartTag,dn.Title,'asc'),this.notesView=new Dr(this.collection)}},{key:"setDisplayOptions",value:function(e,t,n,r){e===F.a.Note&&console.warn("Called setDisplayOptions with ContentType.Note. setNotesDisplayCriteria should be used instead."),this.collection.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.notesView.setCriteria(e)}},{key:"getDisplayableItems",value:function(e){return e===F.a.Note?this.notesView.displayElements():this.collection.displayElements(e)}},{key:"deinit",value:function(){this.unsubChangeObserver(),this.unsubChangeObserver=void 0,this.payloadManager=void 0,this.collection=void 0,this.notesView=void 0}},{key:"resetState",value:function(){this.createCollection()}},{key:"findItem",value:function(e){return this.collection.find(e)}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.collection.findAll(e,t)}},{key:"itemsKeys",value:function(){return this.collection.displayElements(F.a.ItemsKey)}},{key:"addObserver",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]);var r={contentType:e,callback:t};return this.observers.push(r),function(){Object(_.M)(n.observers,r)}}},{key:"itemsReferencingItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.collection.uuidsThatReferenceUuid(e);return this.findItems(t)}},{key:"referencesForItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.findItem(e).references.map(function(e){return e.uuid});return this.findItems(t)}},{key:"setPayloads",value:function(e,t,n,r,a,i){var s=e.map(function(e){return nt(e)}),o=t.map(function(e){return nt(e)}),c=r.map(function(e){return nt(e)}),u=s.concat(o);u.length>0&&this.collection.set(u);for(var l,p=n.map(function(e){return nt(e)}),d=S(p);!(l=d()).done;){var h=l.value;this.collection.discard(h)}this.notesView.setNeedsRebuilding(),this.notifyObservers(s,o,p,c,a,i)}},{key:"notifyObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return e.filter(function(e){return t.includes(F.a.Any)||t.includes(e.content_type)})},c=S(this.observers.slice());!(s=c()).done;){var u=s.value,l=o(e,u.contentType),p=o(t,u.contentType),d=o(n,u.contentType),h=o(r,u.contentType);0===l.length&&0===p.length&&0===d.length&&0===h.length||u.callback(l,p,d,h,a,i)}}},{key:"changeItem",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=s.length>2&&void 0!==s[2]?s[2]:T.c.UserInteraction,r=s.length>3&&void 0!==s[3]?s[3]:ht.a.LocalChanged,a=s.length>4?s[4]:void 0,Object(_.A)(e)){o.next=5;break}throw Error('Invalid uuid for changeItem');case 5:return o.next=7,b.awrap(this.changeItems([e],t,n,r,a));case 7:return i=o.sent,o.abrupt("return",i[0]);case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:n=h.length>2&&void 0!==h[2]?h[2]:T.c.UserInteraction,r=h.length>3&&void 0!==h[3]?h[3]:ht.a.LocalChanged,a=h.length>4?h[4]:void 0,i=this.findItems(e,!0),s=[],o=S(i);case 6:if((c=o()).done){f.next=16;break}if(u=c.value){f.next=10;break}throw Error('Attempting to change non-existant item');case 10:l=de(u,n),t&&t(l),p=l.getResult(),s.push(p);case 14:f.next=6;break;case 16:return f.next=18,b.awrap(this.payloadManager.emitPayloads(s,r,a));case 18:return d=this.findItems(s.map(function(e){return e.uuid})),f.abrupt("return",d);case 20:case"end":return f.stop()}},null,this,null,Promise)}},{key:"changeNote",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant note');case 6:return s=new pe(i,n),c.abrupt("return",this.applyTransform(s,t,r,a));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeTag",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant tag');case 6:return s=new ce(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeComponent",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant component');case 6:return s=new V(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeFeatureRepo",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant repo');case 6:return s=new Xe(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeActionsExtension",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant extension');case 6:return s=new se(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeItemsKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant itemsKey');case 6:return s=new $(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"applyTransform",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:ht.a.LocalChanged,r=i.length>3?i[3]:void 0,t(e),a=e.getResult(),s.abrupt("return",this.payloadManager.emitPayload(a,n,r));case 5:case"end":return s.stop()}},null,this,null,Promise)}},{key:"setItemDirty",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]&&r[1],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return a.next=5,b.awrap(this.setItemsDirty([e],t));case 5:return n=a.sent,a.abrupt("return",n[0]);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemsDirty",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=n.length>1&&void 0!==n[1]&&n[1],Object(_.A)(e[0])){r.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return r.abrupt("return",this.changeItems(e,void 0,t?T.c.UserInteraction:T.c.Internal));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getDirtyItems",value:function(){return this.collection.dirtyElements().filter(function(e){return e.isSyncable})}},{key:"duplicateItem",value:function(e){var t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return t=o.length>1&&void 0!==o[1]&&o[1],n=o.length>2?o[2]:void 0,r=this.findItem(e),a=Object(Ee.e)(r),c.next=6,b.awrap(ut(a,this.payloadManager.getMasterCollection(),t,n));case 6:return i=c.sent,c.next=9,b.awrap(this.payloadManager.emitPayloads(i,ht.a.LocalChanged));case 9:return s=this.findItem(i[0].uuid),c.abrupt("return",s);case 11:case"end":return c.stop()}},null,this,null,Promise)}},{key:"createItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=i.length>3?i[3]:void 0,e){s.next=4;break}throw'Attempting to create item with no contentType';case 4:return s.t0=Object(Ee.e),s.next=7,b.awrap(I.GenerateUuid());case 7:return s.t1=s.sent,s.t2=e,s.t3=t?Object(Ke.a)(t):void 0,s.t4=n,s.t5={uuid:s.t1,content_type:s.t2,content:s.t3,dirty:s.t4},s.t6=r,a=(0,s.t0)(s.t5,s.t6),s.next=16,b.awrap(this.payloadManager.emitPayload(a,ht.a.Constructor));case 16:return s.abrupt("return",this.findItem(a.uuid));case 17:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Object(Ee.e),r.next=3,b.awrap(I.GenerateUuid());case 3:return r.t1=r.sent,r.t2=e,r.t3=Object(Ke.a)(t||{}),r.t4={uuid:r.t1,content_type:r.t2,content:r.t3},n=(0,r.t0)(r.t4),r.abrupt("return",nt(n));case 9:case"end":return r.stop()}},null,null,null,Promise)}},{key:"insertItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemFromPayload(e.payload));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"insertItems",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemsFromPayloads(e.map(function(e){return e.payload})));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emitItemFromPayload",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:ht.a.Constructor,r.next=3,b.awrap(this.payloadManager.emitPayload(e,t));case 3:return r.abrupt("return",this.findItem(e.uuid));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitItemsFromPayloads",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:ht.a.Constructor,a.next=3,b.awrap(this.payloadManager.emitPayloads(e,t));case 3:return n=Object(Ke.b)(e),a.abrupt("return",this.findItems(n));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemToBeDeleted",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this.collection.uuidsThatReferenceUuid(e),r=this.findItem(e),u.next=4,b.awrap(this.changeItem(e,function(e){e.setDeleted()},void 0,t));case 4:a=u.sent,i=S(n);case 6:if((s=i()).done){u.next=14;break}if(o=s.value,!(c=this.findItem(o))){u.next=12;break}return u.next=12,b.awrap(this.changeItem(c.uuid,function(e){e.removeItemAsRelationship(r)}));case 12:u.next=6;break;case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}},null,this,null,Promise)}},{key:"setItemsToBeDeleted",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.all(e.map(function(e){return t.setItemToBeDeleted(e)})));case 1:case"end":return n.stop()}},null,null,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.collection.all(e);return t?n.filter(function(e){return!e.errorDecrypting&&!e.waitingForKey}):n}},{key:"nonErroredItemsForContentType",value:function(e){return this.collection.all(e).filter(function(e){return!e.errorDecrypting&&!e.waitingForKey})}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.subItemsMatchingPredicates(this.items,e)}},{key:"subItemsMatchingPredicates",value:function(e,t){return e.filter(function(e){if(e.deleted)return!1;for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!e.satisfiesPredicate(a))return!1}return!0})}},{key:"findTagByTitle",value:function(e){var t=e.toLowerCase();return this.tags.find(function(e){return e.title.toLowerCase()===t})}},{key:"searchTags",value:function(e,t){var n=this;return Object(_.G)(this.tags.filter(function(r){var a=new RegExp("^".concat(e,"|").concat(".").concat(e),'i').test(r.title),i=!!t&&n.itemsReferencingItem(t.uuid).some(function(e){return(null===e||void 0===e?void 0:e.uuid)===r.uuid});return a&&!i}),'title')}},{key:"getTagParent",value:function(e){var t=this.findItem(e).parentId;if(t)return this.findItem(t)}},{key:"getTagParentChain",value:function(e){for(var t=this.findItem(e).parentId,n=[];t;){var r=this.findItem(t);n.unshift(r),t=r.parentId}return n}},{key:"getTagChildren",value:function(e){var t=this.findItem(e);return this.collection.elementsReferencingElement(t)}},{key:"isTagAncestor",value:function(e,t){for(var n=this.findItem(t).parentId;n;){if(n===e)return!0;n=this.findItem(n).parentId}return!1}},{key:"isValidTagParent",value:function(e,t){return e!==t&&!this.isTagAncestor(t,e)}},{key:"setTagParent",value:function(e,t){if(e.uuid===t.uuid)throw new Error('can not set a tag parent of itself');if(this.isTagAncestor(t.uuid,e.uuid))throw new Error('can not set a tag ancestor of itself');return this.changeTag(t.uuid,function(t){t.makeChildOf(e)})}},{key:"unsetTagParent",value:function(e){var t=this.getTagParent(e.uuid);return t?this.changeTag(e.uuid,function(e){e.removeItemAsRelationship(t)}):Promise.resolve(e)}},{key:"addTagToNote",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.changeItem(t.uuid,function(t){t.addItemAsRelationship(e)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getSortedTagsForNote",value:function(e){return Object(_.G)(this.itemsReferencingItem(e.uuid).filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===F.a.Tag}),'title')}},{key:"findOrCreateTagByTitle",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.findTagByTitle(e),n.t0=t,n.t0){n.next=6;break}return n.next=5,b.awrap(this.createItem(F.a.Tag,Object(Ke.a)({title:e}),!0));case 5:n.t0=n.sent;case 6:return n.abrupt("return",n.t0);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"notesMatchingSmartTag",value:function(e){return this.notesView.notesMatchingSmartTag(e)}},{key:"emptyTrash",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.trashedItems,t.abrupt("return",this.setItemsToBeDeleted(Object(Ke.b)(e)));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){var e=this.collection.displayElements(F.a.SmartTag);return this.systemSmartTags.concat(e)}},{key:"removeAllItemsFromMemory",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Object(Ke.b)(this.items),t.next=3,b.awrap(this.changeItems(e,function(e){e.setDeleted()},T.c.NonDirtying));case 3:this.resetState(),this.payloadManager.resetState();case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"removeItemLocally",value:function(e){this.collection.discard(e),this.payloadManager.removePayloadLocally(e.payload)}},{key:"items",get:function(){return this.collection.all()}},{key:"nonDeletedItems",get:function(){return this.collection.nondeletedElements()}},{key:"invalidItems",get:function(){return this.collection.invalidElements()}},{key:"notes",get:function(){return this.notesView.displayElements()}},{key:"tags",get:function(){return this.collection.displayElements(F.a.Tag)}},{key:"components",get:function(){return this.collection.displayElements(F.a.Component)}},{key:"trashSmartTag",get:function(){return this.systemSmartTags.find(function(e){return e.isTrashTag})}},{key:"trashedItems",get:function(){return this.notesMatchingSmartTag(this.trashSmartTag)}},{key:"noteCount",get:function(){return this.collection.all(F.a.Note).length}}]),n})(R.a),Er='all-notes',Rr='archived-notes',Ir='trashed-notes';function Mr(e,t){return e.sort(function(e,n){var r=new Date(n.serverUpdatedAt).getTime()-new Date(e.serverUpdatedAt).getTime(),a=0,i=0;return t&&(a=t.indexOf(e.content_type),i=t.indexOf(n.content_type),-1===a&&(a=t.length),-1===i&&(i=t.length)),a===i?r:a<i?-1:1})}var Ar=(function(){function e(t,n){v(this,e),this.discordance=0,this.outOfSync=!1,this.receiver=t,this.maxDiscordance=n,this.reset()}return y(e,[{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"reset",value:function(){this.lastPreSyncSave=void 0,this.lastSyncDate=void 0,this.discordance=0,this.outOfSync=!1}},{key:"getLastClientIntegrityHash",value:function(){return this.lastClientHash}},{key:"clearIntegrityHashes",value:function(){this.lastClientHash=void 0,this.lastServerHash=void 0}},{key:"setIntegrityHashes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.lastClientHash=e,this.lastServerHash=t,!t||0===t.length||!e||e===t?(this.outOfSync&&(this.outOfSync=!1,this.receiver(on.a.ExitOutOfSync)),this.discordance=0):(this.discordance++,this.discordance>=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(on.a.EnterOutOfSync)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordance<this.maxDiscordance}}]),e})(),jr=Object.freeze([F.a.ServerExtension]);function Tr(e){return e.filter(function(e){var t=![ue.a.DecryptedBareObject,ue.a.DecryptedBase64String].includes(e.format),n=jr.includes(e.content_type),r=t||n;return r||console.error('Filtering disallowed payload',e),r})}var Kr=(function(){function e(t,n,r,a,i){v(this,e),this.apiService=t,this.protocolService=n,this.contentType=r,this.customEvent=a,this.limit=i,this.progress={retrievedPayloads:[]}}return y(e,[{key:"run",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.apiService.sync([],this.progress.lastSyncToken,this.progress.paginationToken,this.limit||500,!1,this.contentType,this.customEvent));case 2:return r=s.sent,a=Tr(r.data.retrieved_items.map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)})),s.next=6,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a));case 6:if(i=s.sent,this.progress.retrievedPayloads=this.progress.retrievedPayloads.concat(i),this.progress.lastSyncToken=null===(e=r.data)||void 0===e?void 0:e.sync_token,this.progress.paginationToken=null===(t=r.data)||void 0===t?void 0:t.cursor_token,null===(n=r.data)||void 0===n||!n.cursor_token){s.next=14;break}return s.abrupt("return",this.run());case 14:return s.abrupt("return",this.progress.retrievedPayloads);case 15:case"end":return s.stop()}},null,this,null,Promise)}}]),e})(),Fr=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}if(r=n.value,a=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient)){s.next=7;break}throw'Unable to find decrypted counterpart for rejected payload.';case 7:i=Object(Ee.f)(a,ht.a.RemoteRejected,{lastSyncEnd:new Date,dirty:!1}),e.push(i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRejected));case 12:case"end":return s.stop()}},null,this,null,Promise)}}]),n})();function Lr(e){if(e===ht.a.RemoteRetrieved)return Rt;if(e===ht.a.RemoteSaved)return It;if(e===ht.a.ConflictData||e===ht.a.ConflictUuid)return Et;if(e===ht.a.RemoteRejected)return Fr;throw"No delta class found for source ".concat(ht.a[e])}var Ur,Nr=(function(){function e(t){v(this,e),this.collections=t,Object.freeze(this)}return y(e,[{key:"collectionForSource",value:function(e){return this.collections.find(function(t){return t.source===e})}}]),e})(),Vr=(function(){function e(t,n,r,a,i){v(this,e),this.response=t,this.baseCollection=r,this.historyMap=i,this.relatedCollectionSet=new Nr([bt.WithPayloads(n,ht.a.DecryptedTransient),bt.WithPayloads(a,ht.a.SavedOrSaving)])}return y(e,[{key:"collectionsByProcessingResponse",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return e=[],s.next=3,b.awrap(this.collectionByProcessingPayloads(this.response.retrievedPayloads,ht.a.RemoteRetrieved));case 3:return(t=s.sent).all().length>0&&e.push(t),s.next=7,b.awrap(this.collectionByProcessingPayloads(this.response.savedPayloads,ht.a.RemoteSaved));case 7:if((n=s.sent).all().length>0&&e.push(n),!(this.response.uuidConflictPayloads.length>0)){s.next=14;break}return s.next=12,b.awrap(this.collectionByProcessingPayloads(this.response.uuidConflictPayloads,ht.a.ConflictUuid));case 12:(r=s.sent).all().length>0&&e.push(r);case 14:if(!(this.response.dataConflictPayloads.length>0)){s.next=19;break}return s.next=17,b.awrap(this.collectionByProcessingPayloads(this.response.dataConflictPayloads,ht.a.ConflictData));case 17:(a=s.sent).all().length>0&&e.push(a);case 19:if(!(this.response.rejectedPayloads.length>0)){s.next=24;break}return s.next=22,b.awrap(this.collectionByProcessingPayloads(this.response.rejectedPayloads,ht.a.RemoteRejected));case 22:(i=s.sent).all().length>0&&e.push(i);case 24:return s.abrupt("return",e);case 25:case"end":return s.stop()}},null,this,null,Promise)}},{key:"collectionByProcessingPayloads",value:function(e,t){var n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=bt.WithPayloads(Tr(e),t),r=Lr(t),a=new r(this.baseCollection,n,this.relatedCollectionSet,this.historyMap),c.next=5,b.awrap(a.resultingCollection());case 5:return i=c.sent,s=i.all().map(function(e){var t=o.finalDirtyStateForPayload(e);return Object(Ee.b)(e,{dirty:t,dirtiedDate:t?new Date:void 0})}),c.abrupt("return",bt.WithPayloads(s,t));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"finalDirtyStateForPayload",value:function(e){var t=this.baseCollection.find(e.uuid);return t?!t.dirtiedDate||e.dirtiedDate&&e.dirtiedDate>t.dirtiedDate?e.dirty:!e.discardable&&t.dirtiedDate>=t.lastSyncBegan:e.dirty}}]),e})(),Br=(function(){function e(t){var n,r;v(this,e),this.rawResponse=t,this.savedPayloads=this.filterRawItemArray(null===(n=t.data)||void 0===n?void 0:n.saved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteSaved)}),this.retrievedPayloads=this.filterRawItemArray(null===(r=t.data)||void 0===r?void 0:r.retrieved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)}),this.dataConflictPayloads=this.filterRawItemArray(this.rawDataConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictData)}),this.uuidConflictPayloads=this.filterRawItemArray(this.rawUuidConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictUuid)}),this.rejectedPayloads=this.filterRawItemArray(this.rawRejectedPayloads).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRejected)}),this.deletedPayloads=this.allProcessedPayloads.filter(function(e){return e.discardable}),Object(_.l)(this)}return y(e,[{key:"filterRawItemArray",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return!!e.uuid})}},{key:"error",get:function(){var e;return this.rawResponse.error||(null===(e=this.rawResponse.data)||void 0===e?void 0:e.error)}},{key:"status",get:function(){return this.rawResponse.status}},{key:"lastSyncToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.LastSyncToken]}},{key:"paginationToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.PaginationToken]}},{key:"integrityHash",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.IntegrityResult]}},{key:"checkIntegrity",get:function(){return this.integrityHash&&!this.paginationToken}},{key:"numberOfItemsInvolved",get:function(){return this.allProcessedPayloads.length}},{key:"allProcessedPayloads",get:function(){return this.savedPayloads.concat(this.retrievedPayloads).concat(this.dataConflictPayloads).concat(this.uuidConflictPayloads).concat(this.rejectedPayloads)}},{key:"rawUuidConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.UuidConflict}).map(function(e){return e.unsaved_item||e.item})}},{key:"rawDataConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ConflictingData}).map(function(e){return e.server_item||e.item})}},{key:"rawRejectedPayloads",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ContentTypeError||e.type===Te.a.ContentError}).map(function(e){return e.unsaved_item})}},{key:"rawConflictObjects",get:function(){var e,t,n=(null===(e=this.rawResponse.data)||void 0===e?void 0:e.conflicts)||[],r=(null===(t=this.rawResponse.data)||void 0===t?void 0:t.unsaved)||[];return n.concat(r)}},{key:"hasError",get:function(){return!Object(_.w)(this.rawResponse.error)}}]),e})();!(function(e){e[e.Response=1]="Response",e[e.StatusChanged=2]="StatusChanged"})(Ur||(Ur={}));var Wr=150,Hr=(function(){function e(t,n,r,a,i,s){v(this,e),this.payloads=t,this.receiver=n,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.id=Math.random(),this.responses=[],this.payloads=t,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.receiver=n,this.pendingPayloads=t.slice()}return y(e,[{key:"popPayloads",value:function(e){var t=this.pendingPayloads.slice(0,e);return Object(_.R)(this.pendingPayloads,t),t}},{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.receiver(Ur.StatusChanged,void 0,{completedUploadCount:this.totalUploadCount-this.pendingUploadCount,totalUploadCount:this.totalUploadCount}));case 2:return e=this.popPayloads(this.upLimit),r.next=5,b.awrap(this.apiService.sync(e,this.lastSyncToken,this.paginationToken,this.downLimit,this.checkIntegrity,void 0,void 0));case 5:return t=r.sent,n=new Br(t),this.responses.push(n),this.lastSyncToken=n.lastSyncToken,this.paginationToken=n.paginationToken,r.next=12,b.awrap(this.receiver(Ur.Response,n));case 12:if(this.done){r.next=14;break}return r.abrupt("return",this.run());case 14:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsSavedOrSaving",get:function(){return Object(_.c)(this.payloads,this.pendingPayloads)}},{key:"done",get:function(){return 0===this.pendingPayloads.length&&!this.paginationToken}},{key:"pendingUploadCount",get:function(){return this.pendingPayloads.length}},{key:"totalUploadCount",get:function(){return this.payloads.length}},{key:"upLimit",get:function(){return Wr}},{key:"downLimit",get:function(){return Wr}},{key:"numberOfItemsInvolved",get:function(){for(var e,t=0,n=S(this.responses);!(e=n()).done;){t+=e.value.numberOfItemsInvolved}return t}}]),e})(),zr=(function(){function e(t,n){v(this,e),this.payloads=t,this.receiver=n}return y(e,[{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=this.payloads.map(function(e){return Object(Ee.f)(e,ht.a.LocalSaved,{dirty:!1,lastSyncEnd:new Date})}),t=Object(_.a)(e),n=new Br({data:{saved_items:t}}),r.next=5,b.awrap(this.receiver(Ur.Response,n));case 5:case"end":return r.stop()}},null,this,null,Promise)}}]),e})();function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Qr,Jr,$r,Xr=5,Zr=15;!(function(e){e[e.ResolveOnNext=1]="ResolveOnNext",e[e.ForceSpawnNew=2]="ForceSpawnNew"})(Qr||(Qr={})),(function(e){e[e.Default=1]="Default",e[e.DownloadFirst=2]="DownloadFirst"})(Jr||(Jr={})),(function(e){e[e.External=1]="External",e[e.SpawnQueue=2]="SpawnQueue",e[e.ResolveQueue=3]="ResolveQueue",e[e.MoreDirtyItems=4]="MoreDirtyItems",e[e.AfterDownloadFirst=5]="AfterDownloadFirst",e[e.IntegrityCheck=6]="IntegrityCheck",e[e.ResolveOutOfSync=7]="ResolveOutOfSync"})($r||($r={}));var ea=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).itemManager=e,l.sessionManager=r,l.protocolService=a,l.storageService=i,l.payloadManager=s,l.apiService=o,l.historyService=c,l.resolveQueue=[],l.spawnQueue=[],l.completedOnlineDownloadFirstSync=!1,l.majorChangeThreshold=Zr,l.maxDiscordance=Xr,l.locked=!1,l.databaseLoaded=!1,l.syncLock=!1,l.dealloced=!1,l.localLoadPriorty=[F.a.ItemsKey,F.a.UserPrefs,F.a.Component,F.a.Theme],l.itemManager=e,l.sessionManager=r,l.protocolService=a,l.payloadManager=s,l.storageService=i,l.apiService=o,l.interval=u,l.initializeStatus(),l.initializeState(),l}return y(n,[{key:"onNewDatabaseCreated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.getLastSyncToken());case 2:if(!e.sent){e.next=5;break}return e.next=5,b.awrap(this.clearSyncPositionTokens());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.dealloced=!0,this.sessionManager=void 0,this.itemManager=void 0,this.protocolService=void 0,this.payloadManager=void 0,this.storageService=void 0,this.apiService=void 0,this.interval=void 0,this.state.reset(),this.opStatus.reset(),this.state=void 0,this.opStatus=void 0,this.resolveQueue.length=0,this.spawnQueue.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeStatus",value:function(){var e=this;this.opStatus=new fr(this.interval,function(t){e.notifyEvent(t)})}},{key:"initializeState",value:function(){var e=this;this.state=new Ar(function(t){t===on.a.EnterOutOfSync?e.notifyEvent(on.a.EnterOutOfSync):t===on.a.ExitOutOfSync&&e.notifyEvent(on.a.ExitOutOfSync)},this.maxDiscordance)}},{key:"lockSyncing",value:function(){this.locked=!0}},{key:"unlockSyncing",value:function(){this.locked=!1}},{key:"isOutOfSync",value:function(){return this.state.isOutOfSync()}},{key:"getLastSyncDate",value:function(){return this.state.lastSyncDate}},{key:"getStatus",value:function(){return this.opStatus}},{key:"resetSyncState",value:function(){this.state.reset()}},{key:"isDatabaseLoaded",value:function(){return this.databaseLoaded}},{key:"getDatabasePayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageService.getAllRawPayloads().catch(function(t){throw e.notifyEvent(on.a.DatabaseReadError,t),t}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadDatabasePayloads",value:function(e){var t,n,r,a,i,s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.databaseLoaded){d.next=2;break}throw'Attempting to initialize already initialized local database.';case 2:if(0!==e.length){d.next=6;break}return this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0),d.abrupt("return");case 6:return t=e.map(function(e){try{return Object(Ee.e)(e)}catch(e){return void console.error('Creating payload failed',e)}}).filter(function(e){return!Object(_.w)(e)}),n=Mr(t,this.localLoadPriorty),r=n.filter(function(e){return e.content_type===F.a.ItemsKey}),Object(_.R)(n,r),d.next=12,b.awrap(this.protocolService.payloadsByDecryptingPayloads(r));case 12:return a=d.sent,d.next=15,b.awrap(this.payloadManager.emitPayloads(a,ht.a.LocalRetrieved));case 15:i=n.length,s=100,o=Math.ceil(i/s),c=0;case 19:if(!(c<o)){d.next=32;break}return u=c*s,l=n.slice(u,u+s),d.next=24,b.awrap(this.protocolService.payloadsByDecryptingPayloads(l));case 24:return p=d.sent,d.next=27,b.awrap(this.payloadManager.emitPayloads(p,ht.a.LocalRetrieved));case 27:this.notifyEvent(on.a.LocalDataIncrementalLoad),this.opStatus.setDatabaseLoadStatus(u,i,!1);case 29:c++,d.next=19;break;case 32:this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0);case 34:case"end":return d.stop()}},null,this,null,Promise)}},{key:"setLastSyncToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.syncToken=e,t.abrupt("return",this.storageService.setValue(o.LastSyncToken,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setPaginationToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cursorToken=e,!e){t.next=5;break}return t.abrupt("return",this.storageService.setValue(o.PaginationToken,e));case 5:return t.abrupt("return",this.storageService.removeValue(o.PaginationToken));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLastSyncToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.syncToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.LastSyncToken));case 3:this.syncToken=e.sent;case 4:return e.abrupt("return",this.syncToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPaginationToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cursorToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.PaginationToken));case 3:this.cursorToken=e.sent;case 4:return e.abrupt("return",this.cursorToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"clearSyncPositionTokens",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.syncToken=void 0,this.cursorToken=void 0,e.next=4,b.awrap(this.storageService.removeValue(o.LastSyncToken));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.PaginationToken));case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"itemsNeedingSync",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.itemManager.getDirtyItems(),t.abrupt("return",e);case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"alternateUuidForItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=this.itemManager.findItem(e),n=Object(Ee.e)(t),a.next=4,b.awrap(lt(n,this.payloadManager.getMasterCollection()));case 4:return r=a.sent,a.next=7,b.awrap(this.payloadManager.emitPayloads(r,ht.a.LocalChanged));case 7:return a.next=9,b.awrap(this.persistPayloads(r));case 9:return a.abrupt("return",this.itemManager.findItem(r[0].uuid));case 10:case"end":return a.stop()}},null,this,null,Promise)}},{key:"markAllItemsAsNeedingSync",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.log('Marking all items as needing sync'),e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e,{dirty:!0,dirtiedDate:new Date})}),n.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 5:return n.next=7,b.awrap(this.persistPayloads(t));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"popPayloadsNeedingPreSyncSave",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.state.lastPreSyncSave){r.next=3;break}return r.abrupt("return",e);case 3:return n=e.filter(function(e){return!e.dirtiedDate||e.dirtiedDate>t}),this.state.lastPreSyncSave=new Date,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"queueStrategyResolveOnNext",value:function(){var e=this;return new Promise(function(t,n){e.resolveQueue.push({resolve:t,reject:n})})}},{key:"queueStrategyForceSpawnNew",value:function(e){var t=this;return new Promise(function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})})}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(_.N)(this.spawnQueue,0),this.log('Syncing again from spawn queue'),this.sync(Yr({queueStrategy:Qr.ForceSpawnNew,source:$r.SpawnQueue},e.options)).then(function(){e.resolve()}).catch(function(){e.reject()})}},{key:"payloadsByPreparingForServer",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.protocolService.payloadsByEncryptingPayloads(e,function(e){return jr.includes(e.content_type)?Re.b.SyncDecrypted:Re.b.Sync}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"downloadFirstSync",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:n=5,r=0;case 2:if(!(r<n)){a.next=14;break}return a.next=5,b.awrap(this.sync(Yr({mode:Jr.DownloadFirst,queueStrategy:Qr.ForceSpawnNew},t)).catch(console.error));case 5:if(!this.completedOnlineDownloadFirstSync){a.next=9;break}return a.abrupt("return");case 9:return a.next=11,b.awrap(Object(_.P)(e));case 11:r++,a.next=2;break;case 14:console.error("Failed downloadFirstSync after ".concat(n," tries"));case 15:case"end":return a.stop()}},null,this,null,Promise)}},{key:"awaitCurrentSyncs",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.lastSyncInvokationPromise);case 2:return e.next=4,b.awrap(this.currentSyncRequestPromise);case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"sync",value:function(){var e,t=arguments;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},this.lastSyncInvokationPromise=this.performSync(e),n.abrupt("return",this.lastSyncInvokationPromise);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"performSync",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P=this,O=arguments;return b.async(function(C){for(;;)switch(C.prev=C.next){case 0:if(e=O.length>0&&void 0!==O[0]?O[0]:{},!this.locked){C.next=4;break}return this.log('Sync Locked'),C.abrupt("return");case 4:return t=function(){return P.syncLock},n=function(){P.syncLock=!0},r=function(){P.syncLock=!1},a=this.opStatus.syncInProgress,i=this.databaseLoaded,(s=!t())&&i&&!a&&n(),e.source||(e.source=$r.External),C.next=14,b.awrap(this.itemsNeedingSync());case 14:return o=C.sent,c=new Date,u=o.filter(function(e){return e.neverSynced&&e.deleted}),Object(_.R)(o,u),l=o.map(function(e){return e.payloadRepresentation()}),C.next=21,b.awrap(this.popPayloadsNeedingPreSyncSave(l));case 21:return p=C.sent,C.next=24,b.awrap(this.persistPayloads(p));case 24:if(d=this.resolveQueue.slice(),h=Object(_.w)(e.queueStrategy)?Qr.ResolveOnNext:e.queueStrategy,!a&&i&&s){C.next=37;break}if(this.log(s?a?'Attempting to sync while existing sync in progress.':'Attempting to sync before local database has loaded.':'Another function call has begun preparing for sync.'),h!==Qr.ResolveOnNext){C.next=32;break}return C.abrupt("return",this.queueStrategyResolveOnNext());case 32:if(h!==Qr.ForceSpawnNew){C.next=36;break}return C.abrupt("return",this.queueStrategyForceSpawnNew({mode:e.mode,checkIntegrity:e.checkIntegrity,source:e.source}));case 36:throw Error("Unhandled timing strategy ".concat(h));case 37:if(!this.dealloced){C.next=39;break}return C.abrupt("return");case 39:return this.opStatus.setDidBegin(),C.next=42,b.awrap(this.notifyEvent(on.a.SyncWillBegin));case 42:if(Object(_.R)(this.resolveQueue,d),!(o.length>0)){C.next=46;break}return C.next=46,b.awrap(this.itemManager.changeItems(Object(Ke.b)(o),function(e){e.lastSyncBegan=c},T.c.NonDirtying,ht.a.PreSyncSave));case 46:if(this.protocolService.hasAccount()!==this.sessionManager.online()&&this.handleInvalidSessionState(),f=this.sessionManager.online(),D=e.mode,v=f&&!P.completedOnlineDownloadFirstSync?Jr.DownloadFirst:Object(_.w)(D)?Jr.Default:D,y=[],v!==Jr.Default){C.next=63;break}if(!f||this.completedOnlineDownloadFirstSync){C.next=54;break}throw Error('Attempting to default mode sync without having completed initial.');case 54:if(!f){C.next=60;break}return C.next=57,b.awrap(this.payloadsByPreparingForServer(l));case 57:y=C.sent,C.next=61;break;case 60:y=l;case 61:C.next=64;break;case 63:v===Jr.DownloadFirst&&(y=[]);case 64:if(!f){C.next=70;break}return C.next=67,b.awrap(this.syncOnlineOperation(y,e.checkIntegrity,e.source,v));case 67:g=C.sent,C.next=73;break;case 70:return C.next=72,b.awrap(this.syncOfflineOperation(y,e.source,v));case 72:g=C.sent;case 73:return this.currentSyncRequestPromise=g.run(),C.next=76,b.awrap(this.currentSyncRequestPromise);case 76:if(!this.dealloced){C.next=78;break}return C.abrupt("return");case 78:if(this.opStatus.setDidEnd(),r(),!this.opStatus.hasError()){C.next=82;break}return C.abrupt("return");case 82:if(this.opStatus.reset(),this.state.lastSyncDate=new Date,g instanceof Hr&&g.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(on.a.MajorDataChange),!(u.length>0)){C.next=88;break}return C.next=88,b.awrap(this.handleNeverSyncedDeleted(u));case 88:if(v===Jr.DownloadFirst){C.next=91;break}return C.next=91,b.awrap(this.notifyEvent(on.a.FullSyncCompleted,{source:e.source}));case 91:if(v!==Jr.DownloadFirst){C.next=99;break}return f&&(this.completedOnlineDownloadFirstSync=!0),C.next=95,b.awrap(this.notifyEvent(on.a.DownloadFirstSyncCompleted));case 95:return C.next=97,b.awrap(this.sync({source:$r.AfterDownloadFirst,checkIntegrity:!0,awaitAll:e.awaitAll}));case 97:C.next=125;break;case 99:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){C.next=107;break}if(this.log('Syncing again from resolve queue'),m=this.sync({source:$r.ResolveQueue,checkIntegrity:e.checkIntegrity}),!e.awaitAll){C.next=105;break}return C.next=105,b.awrap(m);case 105:C.next=125;break;case 107:return C.next=109,b.awrap(this.itemsNeedingSync());case 109:if(C.t0=C.sent.length,!(C.t0>0)){C.next=115;break}return C.next=113,b.awrap(this.sync({source:$r.MoreDirtyItems,checkIntegrity:e.checkIntegrity,awaitAll:e.awaitAll}));case 113:C.next=125;break;case 115:if(!(g instanceof Hr&&g.checkIntegrity)){C.next=124;break}if(!this.state.needsSync||!g.done){C.next=122;break}if(this.log('Syncing again from integrity check'),w=this.sync({checkIntegrity:!0,queueStrategy:Qr.ForceSpawnNew,source:$r.IntegrityCheck,awaitAll:e.awaitAll}),!e.awaitAll){C.next=122;break}return C.next=122,b.awrap(w);case 122:C.next=125;break;case 124:this.state.clearIntegrityHashes();case 125:for(k=S(d);!(x=k()).done;)x.value.resolve();case 126:case"end":return C.stop()}var D},null,this,null,Promise)}},{key:"handleInvalidSessionState",value:function(){we.a.error(Error('Session missing while attempting to sync.')),this.sessionManager.reauthenticateInvalidSession()}},{key:"syncOnlineOperation",value:function(e,t,n,r){var a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.t0=Hr,s.t1=e,s.t2=function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next=r.t0===Ur.Response?3:r.t0===Ur.StatusChanged?13:15;break;case 3:if(!i.dealloced){r.next=5;break}return r.abrupt("return");case 5:if(!t.hasError){r.next=10;break}return r.next=8,b.awrap(i.handleErrorServerResponse(t));case 8:r.next=12;break;case 10:return r.next=12,b.awrap(i.handleSuccessServerResponse(a,t));case 12:return r.abrupt("break",15);case 13:return i.opStatus.setUploadStatus(n.completedUploadCount,n.totalUploadCount),r.abrupt("break",15);case 15:case"end":return r.stop()}},null,null,null,Promise)},s.next=5,b.awrap(this.getLastSyncToken());case 5:return s.t3=s.sent,s.next=8,b.awrap(this.getPaginationToken());case 8:return s.t4=s.sent,s.t5=t,s.t6=this.apiService,a=new s.t0(s.t1,s.t2,s.t3,s.t4,s.t5,s.t6),this.log('Syncing online user','source:',n,'operation id',a.id,'integrity check',t,'mode:',r,'payloads:',e),s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"syncOfflineOperation",value:function(e,t,n){var r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return this.log('Syncing offline user','source:',t,'mode:',n,'payloads:',e),r=new zr(e,function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!a.dealloced){n.next=2;break}return n.abrupt("return");case 2:if(e!==Ur.Response){n.next=5;break}return n.next=5,b.awrap(a.handleOfflineResponse(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}),i.abrupt("return",r);case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleOfflineResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.log('Offline Sync Response',e.rawResponse),!((t=e.savedPayloads).length>0)){a.next=8;break}return a.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalSaved));case 5:return n=this.payloadManager.find(Object(Ke.b)(t)),a.next=8,b.awrap(this.persistPayloads(n));case 8:if(!((r=e.deletedPayloads).length>0)){a.next=12;break}return a.next=12,b.awrap(this.deletePayloads(r));case 12:return this.opStatus.clearError(),this.opStatus.setDownloadStatus(e.retrievedPayloads.length),a.next=16,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,e));case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleErrorServerResponse",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.log('Sync Error',e),401===e.status&&this.notifyEvent(on.a.InvalidSession),null===(t=this.opStatus)||void 0===t||t.setError(e.error),this.notifyEvent(on.a.SyncError,e.error);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleSuccessServerResponse",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k;return b.async(function(x){for(;;)switch(x.prev=x.next){case 0:if(!this._simulate_latency){x.next=3;break}return x.next=3,b.awrap(Object(_.P)(this._simulate_latency.latency));case 3:this.log('Online Sync Response','operation id',e.id,t.rawResponse),this.setLastSyncToken(t.lastSyncToken),this.setPaginationToken(t.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus(t.retrievedPayloads.length),n=[],r=t.allProcessedPayloads,a={},i=S(r);case 12:if((s=i()).done){x.next=25;break}if(!(o=s.value).deleted&&o.fields.includes(Je.a.Content)){x.next=16;break}return x.abrupt("continue",23);case 16:return c=a[o.items_key_id],u=c?nt(c):void 0,x.next=20,b.awrap(this.protocolService.payloadByDecryptingPayload(o,u));case 20:(l=x.sent).content_type===F.a.ItemsKey&&(a[l.uuid]=l),n.push(l);case 23:x.next=12;break;case 25:return p=this.payloadManager.getMasterCollection(),d=this.historyService.getHistoryMapCopy(),h=new Vr(t,n,p,e.payloadsSavedOrSaving,d),x.next=30,b.awrap(h.collectionsByProcessingResponse());case 30:f=x.sent,v=S(f);case 32:if((y=v()).done){x.next=41;break}return g=y.value,x.next=36,b.awrap(this.payloadManager.emitCollection(g));case 36:return m=x.sent,x.next=39,b.awrap(this.persistPayloads(m));case 39:x.next=32;break;case 41:if(!((w=t.deletedPayloads).length>0)){x.next=45;break}return x.next=45,b.awrap(this.deletePayloads(w));case 45:return x.next=47,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,t));case 47:if(!t.checkIntegrity){x.next=53;break}return x.next=50,b.awrap(this.computeDataIntegrityHash());case 50:return k=x.sent,x.next=53,b.awrap(this.state.setIntegrityHashes(k,t.integrityHash));case 53:case"end":return x.stop()}},null,this,null,Promise)}},{key:"handleNeverSyncedDeleted",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e.map(function(e){return e.payloadRepresentation({dirty:!1})}),n.next=3,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.persistPayloads(t));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistPayloads",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(0!==e.length&&!this.dealloced){n.next=2;break}return n.abrupt("return");case 2:return n.abrupt("return",this.storageService.savePayloads(e).catch(function(e){t.notifyEvent(on.a.DatabaseWriteError,e),we.a.error(e)}));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.persistPayloads(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"computeDataIntegrityHash",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:u.prev=0,e=this.itemManager.nonDeletedItems.sort(function(e,t){return t.serverUpdatedAtTimestamp-e.serverUpdatedAtTimestamp}),t=[],n=1e3,r=S(e);case 5:if((a=r()).done){u.next=14;break}if(i=a.value,s=i.serverUpdatedAtTimestamp){u.next=10;break}return u.abrupt("return",void 0);case 10:o=Math.floor(s/n),t.push(o);case 12:u.next=5;break;case 14:return c=t.join(','),u.abrupt("return",this.protocolService.crypto.sha256(c));case 18:return u.prev=18,u.t0=u.catch(0),console.error('Error computing data integrity hash',u.t0),u.abrupt("return",void 0);case 22:case"end":return u.stop()}},null,this,[[0,18]],Promise)}},{key:"resolveOutOfSync",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=new Kr(this.apiService,this.protocolService,void 0,'resolve-out-of-sync'),a.next=3,b.awrap(e.run());case 3:return t=a.sent,n=new _t(this.payloadManager.getMasterCollection(),bt.WithPayloads(t,ht.a.RemoteRetrieved),void 0,this.historyService.getHistoryMapCopy()),a.next=7,b.awrap(n.resultingCollection());case 7:return r=a.sent,a.next=10,b.awrap(this.payloadManager.emitCollection(r));case 10:return a.next=12,b.awrap(this.persistPayloads(r.payloads));case 12:return a.abrupt("return",this.sync({checkIntegrity:!0,source:$r.ResolveOutOfSync}));case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"statelessDownloadAllItems",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=new Kr(this.apiService,this.protocolService,e,t),a.next=3,b.awrap(n.run());case 3:return r=a.sent,a.abrupt("return",r.map(function(e){return nt(e)}));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_clearLastSyncDate",value:function(){this.state.lastSyncDate=void 0}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=void 0}}]),n})(R.a),ta=(function(){function e(t,n,r,a,i,s){v(this,e),this.challenge=t,this.onValidValue=n,this.onInvalidValue=r,this.onNonvalidatedSubmit=a,this.onComplete=i,this.onCancel=s,this.nonvalidatedValues=[],this.validValues=[],this.invalidValues=[],this.artifacts={}}return y(e,[{key:"complete",value:function(e){var t;e||(e=new be(this.challenge,this.validValues,this.artifacts)),null===(t=this.onComplete)||void 0===t||t.call(this,e)}},{key:"nonvalidatedSubmit",value:function(){var e,t=new be(this.challenge,this.nonvalidatedValues.slice(),this.artifacts);null===(e=this.onNonvalidatedSubmit)||void 0===e||e.call(this,t),this.nonvalidatedValues=[]}},{key:"cancel",value:function(){var e;null===(e=this.onCancel)||void 0===e||e.call(this)}},{key:"isFinished",value:function(){return this.validValues.length===this.challenge.prompts.length}},{key:"nonvalidatedPrompts",value:function(){return this.challenge.prompts.filter(function(e){return!e.validates})}},{key:"addNonvalidatedValue",value:function(e){var t=this.nonvalidatedValues,n=t.find(function(t){return t.prompt.id===e.prompt.id});n&&Object(_.M)(t,n),t.push(e),this.nonvalidatedValues.length===this.nonvalidatedPrompts().length&&this.nonvalidatedSubmit()}},{key:"setValueStatus",value:function(e,t,n){var r,a,i=t?this.validValues:this.invalidValues,s=i.find(function(t){return t.prompt.validation===e.prompt.validation});(s&&Object(_.M)(i,s),i.push(e),w(this.artifacts,n),this.isFinished())?this.complete():t?null===(r=this.onValidValue)||void 0===r||r.call(this,e):null===(a=this.onInvalidValue)||void 0===a||a.call(this,e)}}]),e})(),na=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.protocolService=r,a.challengeOperations={},a.challengeObservers={},a}return y(n,[{key:"deinit",value:function(){this.storageService=void 0,this.protocolService=void 0,this.sendChallenge=void 0,this.challengeOperations=void 0,this.challengeObservers=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"promptForChallengeResponse",value:function(e){var t=this;return new Promise(function(n){t.createOrGetChallengeOperation(e,n),t.sendChallenge(e)})}},{key:"validateChallengeValue",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.prompt.validation,t.next=t.t0===te.LocalPasscode?3:t.t0===te.AccountPassword?4:t.t0===te.Biometric?5:t.t0===te.ProtectionSessionDuration?6:7;break;case 3:return t.abrupt("return",this.protocolService.validatePasscode(e.value));case 4:return t.abrupt("return",this.protocolService.validateAccountPassword(e.value));case 5:return t.abrupt("return",{valid:!0===e.value});case 6:return t.abrupt("return",{valid:(n=e.value,'number'==typeof n&&Object.values(er).includes(n))});case 7:throw Error("Unhandled validation mode ".concat(e.prompt.validation));case 8:case"end":return t.stop()}var n},null,this,null,Promise)}},{key:"promptForCorrectPasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=new ye([new ge(te.LocalPasscode)],e,!0),a.next=3,b.awrap(this.promptForChallengeResponse(t));case 3:if(n=a.sent){a.next=6;break}return a.abrupt("return",void 0);case 6:return r=n.getValueForType(te.LocalPasscode),a.abrupt("return",r.value);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",{});case 2:if(e){n.next=8;break}return n.next=5,b.awrap(this.promptForCorrectPasscode(ne.ResaveRootKey));case 5:if(e=n.sent){n.next=8;break}return n.abrupt("return",{canceled:!0});case 8:return n.next=10,b.awrap(this.protocolService.computeWrappingKey(e));case 10:return t=n.sent,n.abrupt("return",{wrappingKey:t});case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"isPasscodeLocked",value:function(){return this.protocolService.rootKeyNeedsUnwrapping()}},{key:"addChallengeObserver",value:function(e,t){var n=this.challengeObservers[e.id]||[];return n.push(t),this.challengeObservers[e.id]=n,function(){Object(_.M)(n,t)}}},{key:"createOrGetChallengeOperation",value:function(e,t){var n=this,r=this.getChallengeOperation(e);return r||(r=new ta(e,function(t){n.onChallengeValidValue(e,t)},function(t){n.onChallengeInvalidValue(e,t)},function(r){n.onChallengeNonvalidatedSubmit(e,r),t(r)},function(r){n.onChallengeComplete(e,r),t(r)},function(){n.onChallengeCancel(e),t(void 0)}),this.challengeOperations[e.id]=r),r}},{key:"performOnObservers",value:function(e,t){for(var n,r=S(this.challengeObservers[e.id]||[]);!(n=r()).done;){t(n.value)}}},{key:"onChallengeValidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onValidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeInvalidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onInvalidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeNonvalidatedSubmit",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onNonvalidatedSubmit)||void 0===n||n.call(e,t)})}},{key:"onChallengeComplete",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onComplete)||void 0===n||n.call(e,t)})}},{key:"onChallengeCancel",value:function(e){this.performOnObservers(e,function(e){var t;null===(t=e.onCancel)||void 0===t||t.call(e)})}},{key:"getChallengeOperation",value:function(e){return this.challengeOperations[e.id]}},{key:"deleteChallengeOperation",value:function(e){delete this.challengeOperations[e.challenge.id]}},{key:"cancelChallenge",value:function(e){var t=this.challengeOperations[e.id];t.cancel(),this.deleteChallengeOperation(t)}},{key:"completeChallenge",value:function(e){var t=this.challengeOperations[e.id];t.complete(),this.deleteChallengeOperation(t)}},{key:"submitValuesForChallenge",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(0!==t.length){c.next=2;break}throw Error('Attempting to submit 0 values for challenge');case 2:n=S(t);case 3:if((r=n()).done){c.next=18;break}if((a=r.value).prompt.validates){c.next=10;break}this.getChallengeOperation(e).addNonvalidatedValue(a),c.next=16;break;case 10:return c.next=12,b.awrap(this.validateChallengeValue(a));case 12:i=c.sent,s=i.valid,o=i.artifacts,this.setValidationStatusForChallenge(e,a,s,o);case 16:c.next=3;break;case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"setValidationStatusForChallenge",value:function(e,t,n,r){var a=this.getChallengeOperation(e);a.setValueStatus(t,n,r),a.isFinished()&&(this.deleteChallengeOperation(a),delete this.challengeObservers[a.challenge.id])}}]),n})(R.a),ra=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).singletonManager=e,i.itemManager=r,i.syncService=a,i.shouldReload=!0,i.reloading=!1,i.removeItemObserver=r.addObserver(F.a.UserPrefs,function(){i.shouldReload=!0}),i.removeSyncObserver=a.addEventObserver(function(e){e===on.a.FullSyncCompleted&&i.reload()}),i}return y(n,[{key:"deinit",value:function(){var e,t;null===(e=this.removeItemObserver)||void 0===e||e.call(this),null===(t=this.removeSyncObserver)||void 0===t||t.call(this),this.singletonManager=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.LoadedDatabase_12&&(this.preferences=this.singletonManager.findSingleton(z.singletonPredicate),this.preferences&&this.notifyEvent("preferencesChanged"));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){var n,r;return null!==(n=null===(r=this.preferences)||void 0===r?void 0:r.getPref(e))&&void 0!==n?n:t}},{key:"setValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.preferences){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,b.awrap(this.itemManager.changeItem(this.preferences.uuid,function(n){n.setPref(e,t)}));case 4:this.preferences=n.sent,this.notifyEvent("preferencesChanged"),this.syncService.sync();case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"reload",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.shouldReload&&!this.reloading){t.next=2;break}return t.abrupt("return");case 2:return this.reloading=!0,t.prev=3,e=this.preferences,t.next=7,b.awrap(this.singletonManager.findOrCreateSingleton(z.singletonPredicate,F.a.UserPrefs,Object(Ke.a)({})));case 7:this.preferences=t.sent,((null===e||void 0===e?void 0:e.uuid)!==this.preferences.uuid||this.preferences.userModifiedDate>e.userModifiedDate)&&this.notifyEvent('preferencesChanged'),this.shouldReload=!1;case 10:return t.prev=10,this.reloading=!1,t.finish(10);case 13:case"end":return t.stop()}},null,this,[[3,,10,13]],Promise)}}]),n})(R.a),aa=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).settingsService=e,i.crypto=r,i.featuresService=a,i}return y(n,[{key:"saveMfaSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.updateSetting(pr.SettingName.MfaSecret,e,!0));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaActivated",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.getSensitiveSetting(pr.SettingName.MfaSecret));case 2:return e=t.sent,t.abrupt("return",null!=e&&0!=e);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.crypto.generateOtpSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.totpToken(e,Date.now(),6,30));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null!=t,!n.t0){n.next=7;break}return n.t1=t,n.next=5,b.awrap(this.getOtpToken(e));case 5:n.t2=n.sent,n.t0=n.t1===n.t2;case 7:if(n.t0){n.next=10;break}throw new Error(j.S.IncorrectMfa);case 10:return n.abrupt("return",this.saveMfaSetting(e));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.settingsService.deleteSetting(pr.SettingName.MfaSecret));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){var e,t=this.featuresService.getFeature(L.FeatureIdentifier.TwoFactorAuth);return void 0!=t&&(!0===t.no_expire||(null!==(e=t.expires_at)&&void 0!==e?e:0)>Date.now())}},{key:"deinit",value:function(){this.settingsService=void 0,this.crypto=void 0,this.featuresService=void 0,p(f(n.prototype),"deinit",this).call(this)}}]),n})(R.a);function ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(n),!0).forEach(function(t){oa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=(function(){function e(t,n,r,a,i,s,o,c,u){v(this,e);var l=arguments.length>9&&void 0!==arguments[9]&&arguments[9],p=arguments.length>10?arguments[10]:void 0;if(this.environment=t,this.platform=n,this.deviceInterface=r,this.crypto=a,this.alertService=i,this.identifier=s,this.swapClasses=o,this.defaultHost=c,this.appVersion=u,this.enableV4=l,this.webSocketUrl=p,this.eventHandlers=[],this.services=[],this.streamRemovers=[],this.serviceObservers=[],this.managedSubscribers=[],this.createdNewDatabase=!1,this.started=!1,this.launched=!1,this.dealloced=!1,this.revokingSession=!1,this.handledFullSyncStage=!1,!we.a.onLog)throw Error('SNLog.onLog must be set.');if(!we.a.onError)throw Error('SNLog.onError must be set.');if(!r)throw Error('Device Interface must be supplied.');if(!t)throw Error('Environment must be supplied when creating an application.');if(!n)throw Error('Platform must be supplied when creating an application.');if(!a)throw Error('Crypto has to be supplied when creating an application.');if(!i)throw Error('AlertService must be supplied when creating an application.');if(!s)throw Error('ApplicationIdentifier must be supplied when creating an application.');if(!o)throw Error('SwapClasses array must be supplied when creating an application.');if(!c)throw Error('defaultHost must be supplied when creating an application.');if(!u)throw Error('appVersion must be supplied when creating an application.');this.constructServices()}return y(e,[{key:"prepareForLaunch",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.setLaunchCallback(e),r.next=3,b.awrap(this.deviceInterface.openDatabase(this.identifier).catch(function(e){n.notifyEvent(At.a.LocalDatabaseReadError,e)}));case 3:return t=r.sent,this.createdNewDatabase=(null===t||void 0===t?void 0:t.isNewDatabase)||!1,r.next=7,b.awrap(this.migrationService.initialize());case 7:return r.next=9,b.awrap(this.notifyEvent(At.a.MigrationsLoaded));case 9:return r.next=11,b.awrap(this.handleStage(ve.PreparingForLaunch_0));case 11:return r.next=13,b.awrap(this.storageService.initializeFromDisk());case 13:return r.next=15,b.awrap(this.notifyEvent(At.a.StorageReady));case 15:return r.next=17,b.awrap(this.protocolService.initialize());case 17:return r.next=19,b.awrap(this.handleStage(ve.ReadyForLaunch_05));case 19:return this.started=!0,r.next=22,b.awrap(this.notifyEvent(At.a.Started));case 22:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setLaunchCallback",value:function(e){this.challengeService.sendChallenge=e.receiveChallenge}},{key:"launch",value:function(){var e,t,n,r,a,i=this,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(e=s.length>0&&void 0!==s[0]&&s[0],this.launched=!1,!(t=this.getLaunchChallenge())){o.next=11;break}return o.next=6,b.awrap(this.challengeService.promptForChallengeResponse(t));case 6:if(n=o.sent){o.next=9;break}throw Error('Launch challenge was cancelled.');case 9:return o.next=11,b.awrap(this.handleLaunchChallengeResponse(n));case 11:if(!this.storageService.isStorageWrapped()){o.next=20;break}return o.prev=12,o.next=15,b.awrap(this.storageService.decryptStorage());case 15:o.next=20;break;case 17:o.prev=17,o.t0=o.catch(12),this.alertService.alert(j.B.StorageDecryptErrorBody,j.B.StorageDecryptErrorTitle);case 20:return o.next=22,b.awrap(this.handleStage(ve.StorageDecrypted_09));case 22:return o.next=24,b.awrap(this.apiService.loadHost());case 24:return o.next=26,b.awrap(this.webSocketsService.loadWebSocketUrl());case 26:return o.next=28,b.awrap(this.sessionManager.initializeFromDisk());case 28:return this.historyManager.initializeFromDisk(),this.settingsService.initializeFromDisk(),o.next=32,b.awrap(this.featuresService.initializeFromDisk());case 32:return this.launched=!0,o.next=35,b.awrap(this.notifyEvent(At.a.Launched));case 35:return o.next=37,b.awrap(this.handleStage(ve.Launched_10));case 37:return o.next=39,b.awrap(this.syncService.getDatabasePayloads());case 39:return r=o.sent,o.next=42,b.awrap(this.handleStage(ve.LoadingDatabase_11));case 42:if(!this.createdNewDatabase){o.next=45;break}return o.next=45,b.awrap(this.syncService.onNewDatabaseCreated());case 45:if(a=this.syncService.loadDatabasePayloads(r).then(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.dealloced){e.next=2;break}throw'Application has been destroyed.';case 2:return e.next=4,b.awrap(i.handleStage(ve.LoadedDatabase_12));case 4:return i.beginAutoSyncTimer(),e.next=7,b.awrap(i.syncService.sync({mode:Jr.DownloadFirst}));case 7:case"end":return e.stop()}},null,null,null,Promise)}),!e){o.next=49;break}return o.next=49,b.awrap(a);case 49:case"end":return o.stop()}},null,this,[[12,17]],Promise)}},{key:"onStart",value:function(){}},{key:"onLaunch",value:function(){}},{key:"getLaunchChallenge",value:function(){return this.protectionService.createLaunchChallenge()}},{key:"handleLaunchChallengeResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!e.challenge.hasPromptForValidationType(te.LocalPasscode)){a.next=9;break}if(n=null===(t=e.artifacts)||void 0===t?void 0:t.wrappingKey){a.next=7;break}return r=e.getValueForType(te.LocalPasscode),a.next=6,b.awrap(this.protocolService.computeWrappingKey(r.value));case 6:n=a.sent;case 7:return a.next=9,b.awrap(this.protocolService.unwrapRootKey(n));case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval(function(){e.syncService.log('Syncing from autosync'),e.sync()},3e4)}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(this.services);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(r.handleApplicationStage(e));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(_.M)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver(function(n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:n===e&&t(e);case 1:case"end":return r.stop()}},null,null,null,Promise)},e)}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e===At.a.Started?this.onStart():e===At.a.Launched&&this.onLaunch(),n=S(this.eventHandlers.slice());case 2:if((r=n()).done){i.next=14;break}if(!(a=r.value).singleEvent||a.singleEvent!==e){i.next=9;break}return i.next=7,b.awrap(a.callback(e,t||{}));case 7:i.next=12;break;case 9:if(a.singleEvent){i.next=12;break}return i.next=12,b.awrap(a.callback(e,t||{}));case 12:i.next=2;break;case 14:this.migrationService.handleApplicationEvent(e);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date}),n.next=3,b.awrap(this.payloadManager.emitPayload(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.syncService.sync());case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"findItem",value:function(e){return this.itemManager.findItem(e)}},{key:"allItems",value:function(){return this.itemManager.items}},{key:"findItems",value:function(e){return this.itemManager.itemsMatchingPredicate(e)}},{key:"getAll",value:function(e){return this.itemManager.findItems(e)}},{key:"mergeItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.emitItemFromPayload(e.payloadRepresentation(),t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createManagedItem",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=a.length>3?a[3]:void 0,i.abrupt("return",this.itemManager.createItem(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.createTemplateItem(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createItemFromPayload",value:function(e){return nt(e)}},{key:"createPayloadFromObject",value:function(e){return Object(Ee.e)(e)}},{key:"getLastSyncDate",value:function(){return this.syncService.getLastSyncDate()}},{key:"getSyncStatus",value:function(){return this.syncService.getStatus()}},{key:"getSessions",value:function(){return this.sessionManager.getSessionsList()}},{key:"revokeSession",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeSessionRevoking());case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.sessionManager.revokeSession(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.revokeAllOtherSessions());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"userCanManageSessions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent,!Object(_.w)(e)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",Object(Q.b)(e,Q.a.V004)>=0);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUserSubscription",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.sessionManager.getSubscription());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data.subscription);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getAvailableSubscriptions());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setItemNeedsSync",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]&&n[1],r.abrupt("return",this.itemManager.setItemDirty(e.uuid,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setItemsNeedsSync",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 2:return t.next=4,b.awrap(this.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emptyTrash",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.itemManager.emptyTrash());case 2:return e.next=4,b.awrap(this.sync());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getTrashedItems",value:function(){return this.itemManager.trashedItems}},{key:"setDisplayOptions",value:function(e,t,n,r){this.itemManager.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.itemManager.setNotesDisplayCriteria(e)}},{key:"getDisplayableItems",value:function(e){return this.itemManager.getDisplayableItems(e)}},{key:"insertItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=de(e,T.c.UserInteraction),n=t.getResult(),a.next=4,b.awrap(this.itemManager.emitItemFromPayload(n));case 4:return r=a.sent,a.abrupt("return",r);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"saveItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.itemManager.findItem(e)){n.next=3;break}throw Error('Attempting to save non-inserted item');case 3:if(t.dirty){n.next=6;break}return n.next=6,b.awrap(this.itemManager.changeItem(e,void 0,T.c.Internal));case 6:return n.next=8,b.awrap(this.syncService.sync());case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,Object(_.A)(e)){s.next=5;break}throw Error('Must use uuid to change item');case 5:return s.next=7,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0,r));case 7:return s.next=9,b.awrap(this.syncService.sync(a));case 9:return s.abrupt("return",this.findItem(e));case 10:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItems",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,s.next=5,b.awrap(this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0,r));case 5:return s.next=7,b.awrap(this.syncService.sync(a));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeItem",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=!(r.length>2&&void 0!==r[2])||r[2],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid to change item');case 3:return a.next=5,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0));case 5:return a.abrupt("return",this.findItem(e));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=!(r.length>2&&void 0!==r[2])||r[2],a.abrupt("return",this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"protectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNote(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNote(e));case 2:return t=n.sent,Object(_.w)(t)||this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.authorizeProtectedActionForNotes(e,t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.itemManager.getItems(e,t)}},{key:"notesMatchingSmartTag",value:function(e){return this.itemManager.notesMatchingSmartTag(e)}},{key:"referencesForItem",value:function(e,t){var n=this.itemManager.referencesForItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"referencingForItem",value:function(e,t){var n=this.itemManager.itemsReferencingItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"duplicateItem",value:function(e,t){var n=this.itemManager.duplicateItem(e.uuid,!1,t);return this.sync(),n}},{key:"findTagByTitle",value:function(e){return this.itemManager.findTagByTitle(e)}},{key:"searchTags",value:function(e,t){return this.itemManager.searchTags(e,t)}},{key:"isValidTagParent",value:function(e,t){return this.itemManager.isValidTagParent(e,t)}},{key:"setTagParent",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.itemManager.setTagParent(e,t));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unsetTagParent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.unsetTagParent(e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getTagParent",value:function(e){return this.itemManager.getTagParent(e.uuid)}},{key:"getTagParentChain",value:function(e){return this.itemManager.getTagParentChain(e.uuid)}},{key:"getTagChildren",value:function(e){return this.itemManager.getTagChildren(e.uuid)}},{key:"getSortedTagsForNote",value:function(e){return this.itemManager.getSortedTagsForNote(e)}},{key:"findOrCreateTag",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.findOrCreateTagByTitle(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){return this.itemManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.itemManager.noteCount}},{key:"streamItems",value:function(e,t){var n=this,r=this.itemManager.addObserver(e,function(e,n,r,a,i){var s=e.concat(n).concat(r);t(s,i)}),a=this.itemManager.getItems(e);return a.length>0&&t(a),this.streamRemovers.push(r),function(){r(),Object(_.M)(n.streamRemovers,r)}}},{key:"toggleComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.componentManager.toggleComponent(e));case 2:return t.next=4,b.awrap(this.syncService.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.apiService.setHost(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.apiService.getHost()}},{key:"setCustomHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.setHost(e));case 2:return t.next=4,b.awrap(this.webSocketsService.setWebSocketUrl(void 0));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUser",value:function(){if(!this.launched)throw Error('Attempting to access user before application unlocked');return this.sessionManager.getUser()}},{key:"getUserPasswordCreationDate",value:function(){return this.protocolService.getPasswordCreatedDate()}},{key:"getProtocolEncryptionDisplayName",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getEncryptionDisplayName());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getUserVersion",value:function(){return this.protocolService.getUserVersion()}},{key:"protocolUpgradeAvailable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isEncryptionAvailable",value:function(){return this.hasAccount()||this.hasPasscode()}},{key:"upgradeProtocolVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.credentialService.performProtocolUpgrade());case 2:return(e=t.sent).success?this.hasAccount()?this.alertService.alert(j.N.SuccessAccount):this.alertService.alert(j.N.SuccessPasscodeOnly):e.error&&this.alertService.alert(j.N.Fail),t.abrupt("return",e);case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"noAccount",value:function(){return!this.hasAccount()}},{key:"hasAccount",value:function(){return this.protocolService.hasAccount()}},{key:"hasProtectionSources",value:function(){return this.protectionService.hasProtectionSources()}},{key:"areProtectionsEnabled",value:function(){return this.protectionService.areProtectionsEnabled()}},{key:"getProtectionSessionExpiryDate",value:function(){return this.protectionService.getSessionExpiryDate()}},{key:"clearProtectionSession",value:function(){return this.protectionService.clearSession()}},{key:"authorizeNoteAccess",value:function(e){return this.protectionService.authorizeNoteAccess(e)}},{key:"authorizeAutolockIntervalChange",value:function(){return this.protectionService.authorizeAutolockIntervalChange()}},{key:"authorizeCloudLinkAccess",value:function(){return this.protectionService.authorizeCloudLinkAccess()}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.protectionService.authorizeSearchingProtectedNotesText()}},{key:"importData",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if(t=d.length>1&&void 0!==d[1]&&d[1],!e.version){h.next=11;break}if(n=e.version,this.protocolService.supportedVersions().includes(n)){h.next=6;break}return h.abrupt("return",{error:j.V});case 6:return h.next=8,b.awrap(this.getUserVersion());case 8:if(!(r=h.sent)||1!==Object(Q.b)(n,r)){h.next=11;break}return h.abrupt("return",{error:j.u});case 11:if(!e.auth_params&&!e.keyParams){h.next=20;break}return i=new ye([new ge(te.None,j.F.FileAccountPassword,void 0,!0)],ne.DecryptEncryptedFile,!0),h.next=15,b.awrap(this.challengeService.promptForChallengeResponse(i));case 15:if(s=h.sent,!Object(_.w)(s)){h.next=18;break}return h.abrupt("return");case 18:this.challengeService.completeChallenge(i),a=s.values[0].value;case 20:return h.next=22,b.awrap(this.protectionService.authorizeFileImport());case 22:if(h.sent){h.next=24;break}return h.abrupt("return");case 24:return h.next=26,b.awrap(this.protocolService.payloadsByDecryptingBackupFile(e,a));case 26:return o=h.sent,c=o.filter(function(e){return!e.errorDecrypting&&e.format!==ue.a.EncryptedString}).map(function(e){return e.content_type===F.a.Component&&e.safeContent.active?Object(Ee.b)(e,{content:sa(sa({},e.safeContent),{},{active:!1})}):e}),h.next=30,b.awrap(this.payloadManager.importPayloads(c));case 30:if(u=h.sent,l=this.sync(),!t){h.next=35;break}return h.next=35,b.awrap(l);case 35:return p=this.getAll(u),h.abrupt("return",{affectedItems:p,errorCount:o.length-c.length});case 37:case"end":return h.stop()}},null,this,null,Promise)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=i.length>1&&void 0!==i[1]&&i[1],n=e===Re.b.FileEncrypted,r=e===Re.b.FileDecrypted,a=n&&t||r,s.t0=a,!s.t0){s.next=9;break}return s.next=8,b.awrap(this.protectionService.authorizeBackupCreation(n));case 8:s.t0=!s.sent;case 9:if(!s.t0){s.next=11;break}return s.abrupt("return");case 11:return s.abrupt("return",this.protocolService.createBackupFile(e));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"sync",value:function(e){return this.syncService.sync(e)}},{key:"isOutOfSync",value:function(){return this.syncService.isOutOfSync()}},{key:"resolveOutOfSync",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.storageService.setValue(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){return this.storageService.getValue(e,t)}},{key:"removeValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.storageService.removeValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getPreference",value:function(e,t){return this.preferencesService.getValue(e,t)}},{key:"setPreference",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.preferencesService.setValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"prepareForDeinit",value:function(){var e,t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e=n.length>0&&void 0!==n[0]?n[0]:0,t=Promise.all(this.services.map(function(e){return e.blockDeinit()})),0!==e){r.next=7;break}return r.next=5,b.awrap(t);case 5:r.next=9;break;case 7:return r.next=9,b.awrap(Promise.race([t,Object(_.P)(e)]));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"promptForCustomChallenge",value:function(e){var t;return null===(t=this.challengeService)||void 0===t?void 0:t.promptForChallengeResponse(e)}},{key:"addChallengeObserver",value:function(e,t){return this.challengeService.addChallengeObserver(e,t)}},{key:"submitValuesForChallenge",value:function(e,t){return this.challengeService.submitValuesForChallenge(e,t)}},{key:"cancelChallenge",value:function(e){this.challengeService.cancelChallenge(e)}},{key:"setOnDeinit",value:function(e){this.onDeinit=e}},{key:"deinit",value:function(e){var t;clearInterval(this.autoSyncInterval);for(var n,r=S(this.serviceObservers);!(n=r()).done;){(0,n.value)()}for(var a,i=S(this.managedSubscribers);!(a=i()).done;){(0,a.value)()}for(var s,o=S(this.services);!(s=o()).done;){s.value.deinit()}null===(t=this.onDeinit)||void 0===t||t.call(this,this,e),this.onDeinit=void 0,this.crypto=void 0,this.createdNewDatabase=!1,this.services.length=0,this.serviceObservers.length=0,this.managedSubscribers.length=0,this.streamRemovers.length=0,this.clearServices(),this.dealloced=!0,this.started=!1}},{key:"register",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=!(a.length>3&&void 0!==a[3])||a[3],i.abrupt("return",this.credentialService.register(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return n=s.length>2&&void 0!==s[2]&&s[2],r=s.length>3&&void 0!==s[3]&&s[3],a=!(s.length>4&&void 0!==s[4])||s[4],i=s.length>5&&void 0!==s[5]&&s[5],o.abrupt("return",this.credentialService.signIn(e,t,n,r,a,i));case 5:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeEmail",value:function(e,t,n){var r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:A.g.EmailChange,i.abrupt("return",this.credentialService.changeCredentials({currentPassword:t,newEmail:e,passcode:n,origination:r,validateNewPasswordStrength:!1}));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"changePassword",value:function(e,t,n){var r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=i.length>3&&void 0!==i[3]?i[3]:A.g.PasswordChange,a=!(i.length>4&&void 0!==i[4])||i[4],s.abrupt("return",this.credentialService.changeCredentials({currentPassword:e,newPassword:t,passcode:n,origination:r,validateNewPasswordStrength:a}));case 3:case"end":return s.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e=i.length>0&&void 0!==i[0]&&i[0],t=function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(a.credentialService.signOut());case 2:return e.next=4,b.awrap(a.notifyEvent(At.a.SignedOut));case 4:return e.next=6,b.awrap(a.prepareForDeinit());case 6:a.deinit(C.SignOut);case 7:case"end":return e.stop()}},null,null,null,Promise)},!e){s.next=6;break}return s.next=5,b.awrap(t());case 5:return s.abrupt("return");case 6:if(!((n=this.itemManager.getDirtyItems()).length>0)){s.next=17;break}return r=1===n.length,s.next=11,b.awrap(this.alertService.confirm("There ".concat(r?'is':'are'," ").concat(n.length," ").concat(r?'item':'items'," with unsynced changes. If you sign out, these changes will be lost forever. Are you sure you want to sign out?")));case 11:if(!s.sent){s.next=15;break}return s.next=15,b.awrap(t());case 15:s.next=19;break;case 17:return s.next=19,b.awrap(t());case 19:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleRevokedSession",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.revokingSession){t.next=2;break}return t.abrupt("return");case 2:return this.revokingSession=!0,e=this.alertService,t.next=6,b.awrap(this.signOut(!0));case 6:e.alert(j.R.CurrentSessionRevoked);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.protocolService.validateAccountPassword(e));case 2:return t=r.sent,n=t.valid,r.abrupt("return",n);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isStarted",value:function(){return this.started}},{key:"isLaunched",value:function(){return this.launched}},{key:"hasBiometrics",value:function(){return this.protectionService.hasBiometricsEnabled()}},{key:"enableBiometrics",value:function(){return this.protectionService.enableBiometrics()}},{key:"disableBiometrics",value:function(){return this.protectionService.disableBiometrics()}},{key:"hasPasscode",value:function(){return this.protocolService.hasPasscode()}},{key:"isLocked",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.challengeService.isPasscodeLocked());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"lock",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=500,t.next=3,b.awrap(this.prepareForDeinit(e));case 3:return t.abrupt("return",this.deinit(C.Lock));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"addPasscode",value:function(e){return this.credentialService.addPasscode(e)}},{key:"removePasscode",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.credentialService.removePasscode());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"changePasscode",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:A.g.PasscodeChange,r.abrupt("return",this.credentialService.changePasscode(e,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.storageService.getStorageEncryptionPolicy()}},{key:"setStorageEncryptionPolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setEncryptionPolicy(e));case 2:return t.abrupt("return",this.protocolService.repersistAllItems());case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableEphemeralPersistencePolicy",value:function(){return this.storageService.setPersistencePolicy(Oe.Ephemeral)}},{key:"hasPendingMigrations",value:function(){return this.migrationService.hasPendingMigrations()}},{key:"generateUuid",value:function(){return I.GenerateUuid()}},{key:"presentKeyRecoveryWizard",value:function(){return this.keyRecoveryService.processPersistedUndecryptables()}},{key:"changeDeviceInterface",value:function(e){this.deviceInterface=e;for(var t,n=S(this.services);!(t=n()).done;){var r=t.value;r.deviceInterface&&(r.deviceInterface=e)}}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.settingsService.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=r.length>2&&void 0!==r[2]&&r[2],a.abrupt("return",this.settingsService.updateSetting(e,t,n));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){return this.mfaService.isMfaFeatureAvailable()}},{key:"isMfaActivated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.isMfaActivated());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.generateMfaSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mfaService.getOtpToken(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.mfaService.enableMfa(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protectionService.authorizeMfaDisable());case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",this.mfaService.disableMfa());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"downloadExternalFeature",value:function(e){return this.featuresService.validateAndDownloadExternalFeature(e)}},{key:"getFeature",value:function(e){return this.featuresService.getFeature(e)}},{key:"getFeatureStatus",value:function(e){return this.featuresService.getFeatureStatus(e)}},{key:"getNewSubscriptionToken",value:function(){return this.apiService.getNewSubscriptionToken()}},{key:"setOfflineFeaturesCode",value:function(e){return this.featuresService.setOfflineFeaturesCode(e)}},{key:"hasOfflineRepo",value:function(){return this.featuresService.hasOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.featuresService.deleteOfflineFeatureRepo());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isThirdPartyHostUsed",value:function(){return this.apiService.isThirdPartyHostUsed()}},{key:"constructServices",value:function(){this.createPayloadManager(),this.createItemManager(),this.createStorageManager(),this.createProtocolService();var e={payloadByEncryptingPayload:this.protocolService.payloadByEncryptingPayload.bind(this.protocolService),payloadByDecryptingPayload:this.protocolService.payloadByDecryptingPayload.bind(this.protocolService)};this.storageService.encryptionDelegate=e,this.createChallengeService(),this.createHttpManager(),this.createApiService(),this.createWebSocketsService(),this.createSessionManager(),this.createHistoryManager(),this.createSyncManager(),this.createProtectionService(),this.createCredentialService(),this.createKeyRecoveryService(),this.createSingletonManager(),this.createComponentManager(),this.createActionsManager(),this.createPreferencesService(),this.createSettingsService(),this.createFeaturesService(),this.createMigrationService(),this.createMfaService()}},{key:"clearServices",value:function(){this.migrationService=void 0,this.alertService=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.sessionManager=void 0,this.syncService=void 0,this.challengeService=void 0,this.singletonManager=void 0,this.componentManager=void 0,this.protectionService=void 0,this.actionsManager=void 0,this.historyManager=void 0,this.itemManager=void 0,this.keyRecoveryService=void 0,this.preferencesService=void 0,this.featuresService=void 0,this.credentialService=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.mfaService=void 0,this.services=[]}},{key:"createFeaturesService",value:function(){var e=this;this.featuresService=new dr(this.storageService,this.apiService,this.itemManager,this.componentManager,this.webSocketsService,this.settingsService,this.credentialService,this.syncService,this.alertService,this.sessionManager,this.crypto),this.serviceObservers.push(this.featuresService.addEventObserver(function(t){switch(t){case cr.UserRolesChanged:e.notifyEvent(At.a.UserRolesChanged);break;case cr.FeaturesUpdated:e.notifyEvent(At.a.FeaturesUpdated);break;default:Object(_.f)(t)}})),this.services.push(this.featuresService)}},{key:"createWebSocketsService",value:function(){this.webSocketsService=new lr(this.storageService,this.webSocketUrl),this.services.push(this.webSocketsService)}},{key:"createMigrationService",value:function(){this.migrationService=new En({protocolService:this.protocolService,deviceInterface:this.deviceInterface,storageService:this.storageService,sessionManager:this.sessionManager,challengeService:this.challengeService,itemManager:this.itemManager,singletonManager:this.singletonManager,featuresService:this.featuresService,environment:this.environment,identifier:this.identifier}),this.services.push(this.migrationService)}},{key:"createCredentialService",value:function(){var e=this;this.credentialService=new Qe(this.sessionManager,this.syncService,this.storageService,this.itemManager,this.protocolService,this.alertService,this.challengeService,this.protectionService),this.serviceObservers.push(this.credentialService.addEventObserver(function(t){switch(t){case Ye.SignedInOrRegistered:e.notifyEvent(At.a.SignedIn);break;default:Object(_.f)(t)}})),this.services.push(this.credentialService)}},{key:"createApiService",value:function(){this.apiService=new Yt(this.httpService,this.storageService,this.defaultHost),this.services.push(this.apiService)}},{key:"createItemManager",value:function(){this.itemManager=new _r(this.payloadManager),this.services.push(this.itemManager)}},{key:"createComponentManager",value:function(){var e=this.getClass(an);this.componentManager=new e(this.itemManager,this.syncService,this.alertService,this.environment,this.platform,this.deviceInterface.timeout),this.services.push(this.componentManager)}},{key:"createHttpManager",value:function(){this.httpService=new jt(this.environment,this.appVersion),this.services.push(this.httpService)}},{key:"createPayloadManager",value:function(){this.payloadManager=new sn,this.services.push(this.payloadManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new cn(this.itemManager,this.syncService),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new Ie(this.deviceInterface,this.alertService,this.identifier,this.environment),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(){var e=this;this.protocolService=new Gn(this.itemManager,this.payloadManager,this.deviceInterface,this.storageService,this.identifier,this.crypto),this.protocolService.onKeyStatusChange(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.notifyEvent(At.a.KeyStatusChanged));case 2:case"end":return t.stop()}},null,null,null,Promise)}),this.services.push(this.protocolService)}},{key:"createKeyRecoveryService",value:function(){this.keyRecoveryService=new Mt(this.itemManager,this.payloadManager,this.apiService,this.protocolService,this.challengeService,this.alertService,this.storageService,this.syncService,this.credentialService),this.services.push(this.keyRecoveryService)}},{key:"createSessionManager",value:function(){var e=this;this.sessionManager=new Ge(this.storageService,this.apiService,this.alertService,this.protocolService,this.challengeService,this.webSocketsService),this.serviceObservers.push(this.sessionManager.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=t,n.next=n.t0===ze.Restored?3:n.t0===ze.Revoked?5:8;break;case 3:return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.sync());case 2:e.protocolService.needsNewRootKeyBasedItemsKey()&&e.protocolService.createNewDefaultItemsKey().then(function(){e.sync()});case 3:case"end":return t.stop()}},null,null,null,Promise),n.abrupt("break",9);case 5:return n.next=7,b.awrap(e.handleRevokedSession());case 7:return n.abrupt("break",9);case 8:Object(_.f)(t);case 9:case"end":return n.stop()}},null,null,null,Promise)})),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new ea(this.itemManager,this.sessionManager,this.protocolService,this.storageService,this.payloadManager,this.apiService,this.historyManager,this.deviceInterface.interval);var t=this.syncService.addEventObserver(function(t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(n=Object(At.c)(t))){r.next=9;break}return r.next=4,b.awrap(e.notifyEvent(n));case 4:if(n!==At.a.CompletedFullSync){r.next=9;break}if(e.handledFullSyncStage){r.next=9;break}return e.handledFullSyncStage=!0,r.next=9,b.awrap(e.handleStage(ve.FullSyncCompleted_13));case 9:return r.next=11,b.awrap(e.protocolService.onSyncEvent(t));case 11:case"end":return r.stop()}},null,null,null,Promise)});this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createChallengeService",value:function(){this.challengeService=new na(this.storageService,this.protocolService),this.services.push(this.challengeService)}},{key:"createProtectionService",value:function(){var e=this;this.protectionService=new ir(this.protocolService,this.challengeService,this.storageService,this.itemManager),this.serviceObservers.push(this.protectionService.addEventObserver(function(t){t===Zn.SessionExpiryDateChanged&&e.notifyEvent(At.a.ProtectionSessionExpiryDateChanged)})),this.services.push(this.protectionService)}},{key:"createHistoryManager",value:function(){this.historyManager=new nr(this.itemManager,this.storageService,this.apiService,this.protocolService,this.deviceInterface),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new hn(this.itemManager,this.alertService,this.deviceInterface,this.httpService,this.payloadManager,this.protocolService,this.syncService),this.services.push(this.actionsManager)}},{key:"createPreferencesService",value:function(){var e=this;this.preferencesService=new ra(this.singletonManager,this.itemManager,this.syncService),this.serviceObservers.push(this.preferencesService.addEventObserver(function(){e.notifyEvent(At.a.PreferencesChanged)})),this.services.push(this.preferencesService)}},{key:"createSettingsService",value:function(){this.settingsService=new hr.SNSettingsService(this.sessionManager,this.apiService),this.services.push(this.settingsService)}},{key:"createMfaService",value:function(){this.mfaService=new aa(this.settingsService,this.crypto,this.featuresService),this.services.push(this.mfaService)}},{key:"getClass",value:function(e){var t=this.swapClasses.find(function(t){return t.swap===e});return t?t.with:e}}]),e})(),ua=(function(){function e(t,n){v(this,e),this.timeout=t||setTimeout.bind(Object(_.r)()),this.interval=n||setInterval.bind(Object(_.r)())}return y(e,[{key:"deinit",value:function(){this.timeout=void 0,this.interval=void 0}},{key:"getJsonParsedRawStorageValue",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getRawStorageValue(e));case 2:if(t=n.sent,!Object(_.w)(t)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.prev=5,n.abrupt("return",JSON.parse(t));case 9:return n.prev=9,n.t0=n.catch(5),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,[[5,9]],Promise)}}]),e})(),la=(function(){function e(t,n,r){var a=this;v(this,e),this.item=n.findItem(t),r&&r(this.item),this.removeObserver=n.streamItems(this.item.content_type,function(e){var n;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:(n=e.find(function(e){return e.uuid===t}))&&(a.item=n,r&&r(a.item));case 2:case"end":return i.stop()}},null,null,null,Promise)})}return y(e,[{key:"deinit",value:function(){this.removeObserver?(this.removeObserver(),this.removeObserver=void 0):console.error('A LiveItem is attempting to be deinited more than once.')}}]),e})(),pa=n(95)}])},'object'==typeof i&&'object'==typeof a?a.exports=c():'function'==typeof define&&define.amd?define("SNLibrary",[],c):'object'==typeof i?i.SNLibrary=c():o.SNLibrary=c()},443,[12,35,22,9,11,13,7,8,249,43,279,6]);^~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:449:66567: warning: the variable "clearInterval" was not declared in anonymous function " 2117#"__d(function(e,t,n,r,a,i,s){var o,c,u=t(s[0]),l=t(s[1]),p=t(s[2]),d=t(s[3]),h=t(s[4]),f=t(s[5]),v=t(s[6]),y=t(s[7]),g=t(s[8]),m=t(s[9]),b=t(s[10]),w=t(s[11]);function k(e){var t=x();return function(){var n,r=f(e);if(t){var a=f(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return h(this,n)}}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=P(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o=window,c=function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=246)})([function(e,t,n){"use strict";(function(e){n.d(t,"r",function(){return y}),n.d(t,"n",function(){return g}),n.d(t,"C",function(){return k}),n.d(t,"y",function(){return x}),n.d(t,"q",function(){return P}),n.d(t,"O",function(){return O}),n.d(t,"h",function(){return C}),n.d(t,"x",function(){return D}),n.d(t,"v",function(){return _}),n.d(t,"w",function(){return E}),n.d(t,"t",function(){return R}),n.d(t,"A",function(){return I}),n.d(t,"s",function(){return M}),n.d(t,"U",function(){return A}),n.d(t,"V",function(){return j}),n.d(t,"W",function(){return T}),n.d(t,"F",function(){return K}),n.d(t,"o",function(){return F}),n.d(t,"R",function(){return L}),n.d(t,"M",function(){return U}),n.d(t,"b",function(){return N}),n.d(t,"p",function(){return V}),n.d(t,"c",function(){return B}),n.d(t,"g",function(){return W}),n.d(t,"N",function(){return H}),n.d(t,"d",function(){return z}),n.d(t,"H",function(){return q}),n.d(t,"Q",function(){return Y}),n.d(t,"K",function(){return G}),n.d(t,"j",function(){return Q}),n.d(t,"S",function(){return J}),n.d(t,"E",function(){return $}),n.d(t,"J",function(){return X}),n.d(t,"I",function(){return Z}),n.d(t,"D",function(){return ee}),n.d(t,"a",function(){return te}),n.d(t,"m",function(){return ne}),n.d(t,"L",function(){return re}),n.d(t,"l",function(){return ae}),n.d(t,"B",function(){return ie}),n.d(t,"T",function(){return se}),n.d(t,"P",function(){return oe}),n.d(t,"f",function(){return ce}),n.d(t,"z",function(){return ue}),n.d(t,"G",function(){return le}),n.d(t,"e",function(){return pe}),n.d(t,"i",function(){return ye}),n.d(t,"u",function(){return ge}),n.d(t,"k",function(){return me});var r=n(27),a=n.n(r),i=n(25),s=n.n(i),o=n(23),c=n.n(o),u=n(97),l=n.n(u),p=n(66),d=n.n(p),h=n(28),f=n.n(h),v='undefined'!=typeof Intl?new Intl.Collator('en',{numeric:!0}):void 0;function y(){return'undefined'!=typeof window?window:void 0!==e?e:null}function g(e){return Object.keys(e).map(function(t){return e[t]})}function k(){return null!==y()&&!x()&&!(document&&document.documentMode)||/Edge/.test(navigator.userAgent)&&window.crypto&&!!window.crypto.subtle}function x(){return'undefined'!=typeof navigator&&'ReactNative'===navigator.product}function P(e,t,n){return e.find(function(e){return e[t]===n})}function O(e,t){return s()(e,t)}function C(){for(var e=[],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var a=0,i=n;a<i.length;a++){var s=i[a];e=e.concat(s)}return e}function D(e){return null!==e&&('function'==typeof e||'object'==typeof e)}function _(e){return null!==e&&'function'==typeof e}function E(e){return null===e||void 0===e}function R(e){return!e||0===e.length}function I(e){return'string'==typeof e||e instanceof String}function M(e,t){return e>t?e:t}function A(e,t,n){return d()(e.concat(t),function(e,t){for(var r,a=S(n);!(r=a()).done;){var i=r.value;if(e[i]!==t[i])return!1}return!0})}function j(e){return f()(e)}function T(e,t){return d()(e,function(e,n){return e[t]===n[t]})}function K(e){return e[e.length-1]}function F(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;e.push(a)}}function L(e,t){for(var n,r=S(t);!(n=r()).done;){U(e,n.value)}}function U(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}function N(e,t){return!e.includes(t)&&(e.push(t),!0)}function V(e,t){a()(e,t)}function B(e,t){return e.filter(function(e){return!t.includes(e)}).concat(t.filter(function(t){return!e.includes(t)}))}function W(e,t){return!(e&&!t||!e&&t)&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof String&&t instanceof String?e===t:J(e,t))}function H(e,t){e.splice(t,1)}function z(e,t){var n=e.slice();return H(n,t),n}function q(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];t.push(e[a])}return t}function Y(e){for(var t,n={},r=S(Object.keys(e).sort());!(t=r()).done;){var a=t.value;n[a]=e[a]}return te(n)}function G(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];E(e[a])||(t[a]=e[a])}return t}function Q(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort(function(e,r){var a=e[t].getTime(),i=r[t].getTime(),s=n?1:-1;return a<i?-1*s:a>i?1*s:0})}function J(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var a=0,i=n;a<i.length;a++){var s=i[a];if(e[s]!==t[s])return!1}return!0}function $(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=void 0;try{i=JSON.parse(e[a])}catch(t){i=e[a]}t[a]=i}return t}function X(e,t){if(e)for(var n,r=S(t);!(n=r()).done;){delete e[n.value]}}function Z(e,t){if(!E(e)){for(var n,r=w({},e),a=S(t);!(n=a()).done;){delete r[n.value]}return r}}function ee(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(function(e,t){return 0===t?e.trim().replace(/[/]*$/g,''):e.trim().replace(/(^[/]*|[/]*$)/g,'')}).filter(function(e){return e.length}).join('/')}function te(e){return e instanceof Date?new Date(e):D(e)?JSON.parse(JSON.stringify(e)):e}function ne(e,t){if(!e||!t)throw'Attempting to deepMerge with null values';return l()(e,t,function(e,t){if(c()(e))return t}),e}function re(e,t){for(var n,r={},a=S(t);!(n=a()).done;){var i=n.value;r[i]=e[i]}return te(r)}function ae(e){for(var t,n=S(Object.getOwnPropertyNames(e));!(t=n()).done;){var r=t.value,a=e[r];a&&'object'==typeof a&&!Object.isFrozen(a)?e[r]=ae(a):e[r]=a}return Object.freeze(e)}function ie(e){try{return new URL(e),!0}catch(e){return!1}}function se(e,t){var n=t/4;return e.substring(0,n)}function oe(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Sleeping for ".concat(e,"ms")),t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},e)}));case 2:case"end":return t.stop()}},null,null,null,Promise)}function ce(e){throw Error('Unchecked case '+e)}function ue(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function le(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc'){case'asc':return m(e).sort(v?function(e,n){return v.compare(e[t],n[t])}:function(e,n){return e[t].localeCompare(n[t],'en',{numeric:!0})});case'desc':return m(e).sort(v?function(e,n){return v.compare(n[t],e[t])}:function(e,n){return n[t].localeCompare(e[t],'en',{numeric:!0})})}}function pe(e,t){return e.length===t.length&&(e.every(function(e){return t.includes(e)})&&t.every(function(t){return e.includes(t)}))}var de,he,fe=1e3,ve=1e3;function ye(e){switch(String(e).length){case de.Seconds:return e*ve;case de.Milliseconds:return e;case de.Microseconds:return Math.floor(e/fe);default:throw"Unhandled timestamp precision: ".concat(e)}}function ge(e){return void 0!==e.error}function me(e){if('undefined'!=typeof Intl&&Intl.DateTimeFormat&&'undefined'!=typeof navigator){if(!he){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;he=new Intl.DateTimeFormat(t,{year:'numeric',month:'short',day:'2-digit',weekday:'long',hour:'2-digit',minute:'2-digit'})}return he.format(e)}return e.toDateString()+' '+e.toLocaleTimeString()}!(function(e){e[e.Seconds=10]="Seconds",e[e.Milliseconds=13]="Milliseconds",e[e.Microseconds=16]="Microseconds"})(de||(de={}))}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"e",function(){return m}),n.d(t,"g",function(){return b}),n.d(t,"d",function(){return w}),n.d(t,"f",function(){return k}),n.d(t,"b",function(){return x}),n.d(t,"c",function(){return O}),n.d(t,"a",function(){return C});var r=n(32),a=n(4),i=n(8),s=n(0),o=n(5),c=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey,o.a.LastSyncBegan,o.a.LastSyncEnd,o.a.DuplicateOf]),u=Object.freeze([o.a.Uuid,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.Legacy003AuthHash,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey]),l=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Legacy003AuthHash,o.a.DuplicateOf]),p=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.WaitingForKey,o.a.DuplicateOf]),d=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.DuplicateOf]),h=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.Content,o.a.ServerUpdatedAt]),f=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),v=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),y=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ServerUpdatedAt,o.a.ServerUpdatedAtTimestamp,o.a.CreatedAtTimestamp,o.a.Deleted,o.a.Dirty,o.a.LastSyncEnd]),g=Object.freeze(d.slice());function m(e,t,n){return P(e,c.slice(),n,t)}function b(e,t,n,r){for(var a,i={},s=S(n||t.fields);!(a=s()).done;){var o=a.value;i[o]=t[o]}if(r)for(var c=0,u=Object.keys(r);c<u.length;c++){var l=u[c];i[l]=r[l]}return x(e,i)}function w(e,t,n){return P(e,D(t),a.a.Constructor,n)}function k(e,t,n){return P(e,_(t),t,n)}function x(e,t){return P(e,e.fields,e.source,t)}function P(e,t,n,i){for(var o,c=Object(s.L)(e,t),u=i instanceof r.a?i.fields.slice():Object.keys(i||[]),l=S(u);!(o=l()).done;){var p=o.value,d=i[p];c[p]=d?Object(s.a)(d):d}var h=Object(s.V)(t.concat(u));return new r.a(c,h,n||a.a.Constructor)}function O(e,t){return P(e,Object.keys(e),t)}function C(e,t){return P(e,u.slice(),void 0,t)}function D(e){if(e===i.b.FileEncrypted||e===i.b.FileDecrypted||e===i.b.FilePreferEncrypted)return l.slice();if(e===i.b.LocalStoragePreferEncrypted||e===i.b.LocalStorageDecrypted||e===i.b.LocalStorageEncrypted)return p.slice();if(e===i.b.Sync||e===i.b.SyncDecrypted)return d.slice();throw"No payload fields found for intent ".concat(e)}function _(e){if(e===a.a.FileImport)return l.slice();if(e===a.a.SessionHistory)return h.slice();if(e===a.a.RemoteHistory)return g.slice();if(e===a.a.ComponentRetrieved)return f.slice();if(e===a.a.ComponentCreated)return v.slice();if(e===a.a.LocalRetrieved||e===a.a.LocalChanged)return p.slice();if(e===a.a.RemoteRetrieved||e===a.a.ConflictData||e===a.a.ConflictUuid||e===a.a.RemoteRejected)return d.slice();if(e===a.a.LocalSaved||e===a.a.RemoteSaved)return y.slice();throw"No payload fields found for source ".concat(e)}},function(e,t,n){"use strict";n.d(t,"k",function(){return a}),n.d(t,"l",function(){return i}),n.d(t,"j",function(){return s}),n.d(t,"m",function(){return o}),n.d(t,"r",function(){return c}),n.d(t,"p",function(){return u}),n.d(t,"a",function(){return l}),n.d(t,"i",function(){return p}),n.d(t,"n",function(){return d}),n.d(t,"s",function(){return h}),n.d(t,"q",function(){return f}),n.d(t,"o",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"h",function(){return g}),n.d(t,"g",function(){return m}),n.d(t,"b",function(){return b}),n.d(t,"f",function(){return w}),n.d(t,"t",function(){return k}),n.d(t,"c",function(){return x}),n.d(t,"e",function(){return S}),n.d(t,"C",function(){return P}),n.d(t,"X",function(){return O}),n.d(t,"A",function(){return C}),n.d(t,"L",function(){return D}),n.d(t,"W",function(){return _}),n.d(t,"E",function(){return E}),n.d(t,"D",function(){return R}),n.d(t,"K",function(){return I}),n.d(t,"J",function(){return M}),n.d(t,"Y",function(){return A}),n.d(t,"Q",function(){return j}),n.d(t,"v",function(){return T}),n.d(t,"O",function(){return K}),n.d(t,"z",function(){return F}),n.d(t,"U",function(){return L}),n.d(t,"G",function(){return U}),n.d(t,"T",function(){return N}),n.d(t,"V",function(){return V}),n.d(t,"u",function(){return B}),n.d(t,"F",function(){return W}),n.d(t,"y",function(){return H}),n.d(t,"P",function(){return z}),n.d(t,"S",function(){return q}),n.d(t,"N",function(){return Y}),n.d(t,"H",function(){return G}),n.d(t,"w",function(){return Q}),n.d(t,"R",function(){return J}),n.d(t,"x",function(){return $}),n.d(t,"M",function(){return X}),n.d(t,"B",function(){return Z}),n.d(t,"I",function(){return ee});var r=n(13),a='A server error occurred while trying to sign in. Please try again.',i='A server error occurred while trying to register. Please try again.',s='Something went wrong while changing your credentials. Your credentials were not changed. Please try again.',o='Could not connect to server.',c='An existing registration request is already in progress.',u='An existing sign in request is already in progress.',l='An existing change credentials request is already in progress.',p='Invalid email or password.',d='A server error occurred while trying to refresh your session. Please try again.',h='Your account session is being renewed with the server. Please try your request again.',f='Too many successive server requests. Please wait a few minutes and try again.',v='Please sign in to an account in order to continue with your request.',y='Failed to get settings.',g='Failed to update settings.',m="Failed to get subscription's information.",b='Failed to access purchase flow.',w='Failed to get offline features.',k="The extension you are attempting to install comes from an \n  untrusted source. Untrusted extensions may lower the security of your data. Do you want to continue?",x="Error downloading package details. Please check the \n  extension link and try again.",S='An unknown issue occurred during offline activation. Please try again.',P='Invalid extension URL.',O='This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.',C='The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.',D='The encryption version for your account is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.com/help/security for more information.',_='Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.',E='Unable to sign in due to insecure password parameters. Please visit standardnotes.com/help/security for more information.',R='Invalid password.',I='Update Recommended',M='Sign In',A="Upgrading your account's encryption version\u2026",j='Setting passcode\u2026',T='Changing passcode\u2026',K='Removing passcode\u2026',F='Do not close the application until this process completes.',L='Unknown error.';function U(e){return"Your password must be at least ".concat(e," characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.")}function N(e,t){return"Strict Sign In has refused the server's sign-in parameters. The latest account version is ".concat(t,", but the server is reporting a version of ").concat(e," for your account. If you'd like to proceed with sign in anyway, please disable Strict Sign In and try again.")}var V='This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.',B="This backup file was created using a newer encryption version than your account's. Please run the available encryption upgrade and try again.",W={FileAccountPassword:'File account password'},H={PasscodeRequired:'Your passcode is required to process your credentials change.',Failed:'Unable to change your credentials due to a sync error. Please try again.'},z={PasscodeRequired:'Your passcode is required in order to register for an account.'},q={PasscodeRequired:'Your passcode is required in order to sign in to your account.',IncorrectMfa:'Incorrect two-factor authentication code. Please try again.',SignInCanceledMissingMfa:'Your sign in request has been canceled.'},Y={SuccessAccount:"Your encryption version has been successfully upgraded. You may be asked to enter your credentials again on other devices you're signed into.",SuccessPasscodeOnly:'Your encryption version has been successfully upgraded.',Fail:'Unable to upgrade encryption version. Please try again.',UpgradingPasscode:'Upgrading local encryption...'},G={KeyRecoveryLoginFlowPrompt:function(e){var t,n=null===(t=e.createdDate)||void 0===t?void 0:t.toLocaleString();switch(e.origination){case r.g.EmailChange:return"Enter your account password as it was when you changed your email on ".concat(n,".");case r.g.PasswordChange:return"Enter your account password after it was changed on ".concat(n,".");case r.g.Registration:return"Enter your account password as it was when you registered ".concat(n,".");case r.g.ProtocolUpgrade:return"Enter your account password as it was when you upgraded your encryption version on ".concat(n,".");case r.g.PasscodeChange:return"Enter your application passcode after it was changed on ".concat(n,".");case r.g.PasscodeCreate:return"Enter your application passcode as it was when you created it on ".concat(n,".");default:throw Error('Unhandled KeyParamsOrigination case for KeyRecoveryLoginFlowPrompt')}},KeyRecoveryLoginFlowReason:'Your account password is required to revalidate your session.',KeyRecoveryLoginFlowInvalidPassword:'Incorrect credentials entered. Please try again.',KeyRecoveryRootKeyReplaced:'Your credentials have successfully been updated.',KeyRecoveryPasscodeRequiredTitle:'Passcode Required',KeyRecoveryPasscodeRequiredText:'You must enter your passcode in order to save your new credentials.',KeyRecoveryPasswordRequired:'Your account password is required to recover an encryption key.',KeyRecoveryKeyRecovered:'Your key has successfully been recovered.',KeyRecoveryUnableToRecover:'Unable to recover your key with the attempted password. Please try again.'},Q={Generic:'Authentication Required',Migration:'Storage Update'},J={EnterEmailAndPassword:'Please enter your account email and password.',RecoverSession:function(e){return e?"Your credentials are needed for ".concat(e," to refresh your session with the server."):'Your credentials are needed to refresh your session with the server.'},SessionRestored:'Your session has been successfully restored.',EnterMfa:'Please enter your two-factor authentication code.',MfaInputPlaceholder:'Two-factor authentication code',EmailInputPlaceholder:'Email',PasswordInputPlaceholder:'Password',KeychainRecoveryErrorTitle:'Invalid Credentials',KeychainRecoveryError:'The email or password you entered is incorrect.\n\nPlease note that this sign-in request is made against the default server. If you are using a custom server, you must uninstall the app then reinstall, and sign back into your account.',RevokeTitle:'Revoke this session?',RevokeConfirmButton:'Revoke',RevokeCancelButton:'Cancel',RevokeText:"The associated app will be signed out and all data removed from the device when it is next launched. You can sign back in on that device at any time.",CurrentSessionRevoked:"Your session has been revoked and all local data has been removed from this device."},$={UnlockApplication:'Authentication is required to unlock the application',NoteAccess:'Authentication is required to view this note',ImportFile:'Authentication is required to import a backup file',AddPasscode:'Authentication is required to add a passcode',RemovePasscode:'Authentication is required to remove your passcode',ChangePasscode:'Authentication is required to change your passcode',ChangeAutolockInterval:'Authentication is required to change autolock timer duration',RevokeSession:'Authentication is required to revoke a session',AccessCloudLink:'Authentication is required to access CloudLink',EnterAccountPassword:'Enter your account password',EnterLocalPasscode:'Enter your application passcode',EnterPasscodeForMigration:'Your application passcode is required to perform an upgrade of your local data storage structure.',EnterPasscodeForRootResave:'Enter your application passcode to continue',EnterCredentialsForProtocolUpgrade:'Enter your credentials to perform encryption upgrade',EnterCredentialsForDecryptedBackupDownload:'Enter your credentials to download a decrypted backup',AccountPasswordPlaceholder:'Account Password',LocalPasscodePlaceholder:'Application Passcode',DecryptEncryptedFile:'Enter the account password associated with the import file',ExportBackup:'Authentication is required to export a backup',DisableBiometrics:'Authentication is required to disable biometrics',UnprotectNote:'Authentication is required to unprotect a note',SearchProtectedNotesText:'Authentication is required to search protected contents',SelectProtectedNote:'Authentication is required to select a protected note',DisableMfa:'Authentication is required to disable two-factor authentication'},X={AccountPassword:'Account Password',LocalPasscode:'Application Passcode',Biometrics:'Biometrics',RememberFor:'Remember For',Mfa:'Two-factor Authentication Code'},Z={MissingSessionTitle:'Missing Session',MissingSessionBody:'We were unable to load your server session. This represents an inconsistency with your application state. Please take an opportunity to backup your data, then sign out and sign back in to resolve this issue.',StorageDecryptErrorTitle:'Storage Error',StorageDecryptErrorBody:"We were unable to decrypt your local storage. Please restart the app and try again. If you're unable to resolve this issue, and you have an account, you may try uninstalling the app then reinstalling, then signing back into your account. Otherwise, please contact help@standardnotes.org for support."},ee={Title:'Restore Keychain',Text:"We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys."}},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i});var r=n(19);n.n(r);n.d(t,"a",function(){return r.ContentType});var a='org.standardnotes.sn';function i(e){var t;return(g(t={},r.ContentType.Note,'note'),g(t,r.ContentType.Tag,'tag'),g(t,r.ContentType.SmartTag,'smart tag'),g(t,r.ContentType.ActionsExtension,'action-based extension'),g(t,r.ContentType.Component,'component'),g(t,r.ContentType.Editor,'editor'),g(t,r.ContentType.Theme,'theme'),g(t,r.ContentType.ServerExtension,'server extension'),g(t,r.ContentType.FilesafeCredentials,'FileSafe credential'),g(t,r.ContentType.FilesafeFileMetadata,'FileSafe file'),g(t,r.ContentType.FilesafeIntegration,'FileSafe integration'),t)[e]}},function(e,t,n){"use strict";var r;function a(e){return[r.RemoteSaved,r.PreSyncSave].includes(e)}function i(e){return[r.RemoteRetrieved,r.ComponentRetrieved,r.RemoteActionRetrieved].includes(e)}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i}),(function(e){e[e.RemoteRetrieved=1]="RemoteRetrieved",e[e.RemoteSaved=2]="RemoteSaved",e[e.LocalSaved=3]="LocalSaved",e[e.LocalRetrieved=4]="LocalRetrieved",e[e.LocalChanged=5]="LocalChanged",e[e.ComponentRetrieved=6]="ComponentRetrieved",e[e.DesktopInstalled=7]="DesktopInstalled",e[e.RemoteActionRetrieved=8]="RemoteActionRetrieved",e[e.FileImport=9]="FileImport",e[e.RemoteConflict=10]="RemoteConflict",e[e.ImportConflict=11]="ImportConflict",e[e.SavedOrSaving=12]="SavedOrSaving",e[e.DecryptedTransient=13]="DecryptedTransient",e[e.ConflictUuid=14]="ConflictUuid",e[e.ConflictData=15]="ConflictData",e[e.SessionHistory=16]="SessionHistory",e[e.Constructor=17]="Constructor",e[e.ComponentCreated=18]="ComponentCreated",e[e.PreSyncSave=19]="PreSyncSave",e[e.RemoteHistory=20]="RemoteHistory",e[e.RemoteRejected=21]="RemoteRejected"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.Uuid="uuid",e.ContentType="content_type",e.ItemsKeyId="items_key_id",e.EncItemKey="enc_item_key",e.Content="content",e.CreatedAt="created_at",e.ServerUpdatedAt="updated_at",e.CreatedAtTimestamp="created_at_timestamp",e.ServerUpdatedAtTimestamp="updated_at_timestamp",e.Deleted="deleted",e.Legacy003AuthHash="auth_hash",e.Legacy003AuthParams="auth_params",e.Dirty="dirty",e.DirtiedDate="dirtiedDate",e.WaitingForKey="waitingForKey",e.ErrorDecrypting="errorDecrypting",e.ErrorDecryptingChanged="errorDecryptingValueChanged",e.LastSyncBegan="lastSyncBegan",e.LastSyncEnd="lastSyncEnd",e.DuplicateOf="duplicate_of"})(r||(r={}))},function(e,t,n){"use strict";var r;function a(e,t){return Number(e)-Number(t)}function i(e,t){return a(e,t)>=0}function s(e,t){return a(e,t)<=0}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"d",function(){return i}),n.d(t,"c",function(){return s}),(function(e){e.V000Base64Decrypted="000",e.V001="001",e.V002="002",e.V003="003",e.V004="004",e[e.VersionLength=3]="VersionLength"})(r||(r={}))},function(e,t,n){"use strict";(function(e){n.d(t,"c",function(){return r}),n.d(t,"a",function(){return a}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return f}),n.d(t,"b",function(){return g});var r,a,i,s=n(16),o=n(12),c=n(18),u=n(1),l=n(0),p=n(21),d=n(3),h=n(4);!(function(e){e[e.UserInteraction=1]="UserInteraction",e[e.Internal=2]="Internal",e[e.NonDirtying=3]="NonDirtying"})(r||(r={})),(function(e){e.Pinned="pinned",e.Archived="archived",e.Locked="locked",e.UserModifiedDate="client_updated_at",e.DefaultEditor="defaultEditor",e.MobileRules="mobileRules",e.NotAvailableOnMobile="notAvailableOnMobile",e.MobileActive="mobileActive",e.LastSize="lastSize",e.PrefersPlainEditor="prefersPlainEditor",e.ComponentInstallError="installError"})(a||(a={})),(function(e){e[e.KeepEarliest=1]="KeepEarliest"})(i||(i={}));var f=(function(){function t(n){var r=this;if(v(this,t),this.protected=!1,this.trashed=!1,this.pinned=!1,this.archived=!1,this.locked=!1,!n.uuid||!n.content_type)throw Error('Cannot create item without both uuid and content_type');n.format===o.a.DecryptedBareObject&&(n.enc_item_key||n.items_key_id||n.auth_hash)&&s.a.error(Error('Creating an item from a decrypted payload should not contain enc params')),this.payload=n,this.conflictOf=n.safeContent.conflict_of,this.duplicateOf=n.duplicate_of,this.createdAtString=this.created_at&&Object(l.k)(this.created_at),n.format===o.a.DecryptedBareObject?(this.userModifiedDate=new Date(this.getAppDomainValue(a.UserModifiedDate)||this.serverUpdatedAt),this.updatedAtString=Object(l.k)(this.userModifiedDate),this.protected=this.payload.safeContent.protected,this.trashed=this.payload.safeContent.trashed,this.pinned=this.getAppDomainValue(a.Pinned),this.archived=this.getAppDomainValue(a.Archived),this.locked=this.getAppDomainValue(a.Locked)):this.userModifiedDate=this.serverUpdatedAt||new Date,e(function(){Object(l.l)(r)})}return y(t,[{key:"payloadRepresentation",value:function(e){return Object(u.b)(this.payload,e)}},{key:"hasRelationshipWithItem",value:function(e){var t;return!!(null===(t=this.payload.safeContent.references)||void 0===t?void 0:t.find(function(t){return t.uuid===e.uuid}))}},{key:"getDomainData",value:function(e){var t=this.payload.safeContent.appData;if(t)return t[e]}},{key:"getAppDomainValue",value:function(e){return this.getDomainData(t.DefaultAppDomain())[e]}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['conflict_of']}},{key:"appDataContentKeysToIgnoreWhenCheckingEquality",value:function(){return[a.UserModifiedDate]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"strategyWhenConflictingWithItem",value:function(e,t){if(this.errorDecrypting)return c.a.KeepLeftDuplicateRight;if(this.isSingleton)return c.a.KeepLeft;if(this.deleted)return c.a.KeepRight;if(e.deleted)return this.payload.source===h.a.FileImport?c.a.KeepLeft:c.a.KeepRight;if(!m(this,e))return c.a.KeepRight;if(m(this,e,['references'])){if(t&&!m(t.itemFromPayload(),e))return c.a.KeepLeft;return e.payload.source===h.a.FileImport||Date.now()-this.userModifiedDate.getTime()<2e4?c.a.KeepLeftDuplicateRight:c.a.DuplicateLeftKeepRight}return c.a.KeepLeftMergeRefs}},{key:"isItemContentEqualWith",value:function(e){return b(this.payload.contentObject,e.payload.contentObject,this.contentKeysToIgnoreWhenCheckingEquality(),this.appDataContentKeysToIgnoreWhenCheckingEquality())}},{key:"satisfiesPredicate",value:function(e){return p.a.ItemSatisfiesPredicate(this,e)}},{key:"uuid",get:function(){return this.payload.uuid}},{key:"content",get:function(){return this.payload.content}},{key:"version",get:function(){if(this.payload.format===o.a.DecryptedBareObject)throw Error('Attempting to access version of decrypted payload');return this.payload.version}},{key:"safeContent",get:function(){return this.payload.safeContent}},{key:"references",get:function(){return this.payload.safeContent.references||[]}},{key:"deleted",get:function(){return this.payload.deleted}},{key:"content_type",get:function(){return this.payload.content_type}},{key:"created_at",get:function(){return this.payload.created_at}},{key:"serverUpdatedAt",get:function(){return this.payload.serverUpdatedAt}},{key:"serverUpdatedAtTimestamp",get:function(){return this.payload.updated_at_timestamp}},{key:"updated_at",get:function(){return this.serverUpdatedAt}},{key:"dirtiedDate",get:function(){return this.payload.dirtiedDate}},{key:"dirty",get:function(){return this.payload.dirty}},{key:"errorDecrypting",get:function(){return this.payload.errorDecrypting}},{key:"waitingForKey",get:function(){return this.payload.waitingForKey}},{key:"errorDecryptingValueChanged",get:function(){return this.payload.errorDecryptingValueChanged}},{key:"lastSyncBegan",get:function(){return this.payload.lastSyncBegan}},{key:"lastSyncEnd",get:function(){return this.payload.lastSyncEnd}},{key:"auth_hash",get:function(){return this.payload.auth_hash}},{key:"auth_params",get:function(){return this.payload.auth_params}},{key:"duplicate_of",get:function(){return this.payload.duplicate_of}},{key:"neverSynced",get:function(){return!this.serverUpdatedAt||0===this.serverUpdatedAt.getTime()}},{key:"isSingleton",get:function(){return!1}},{key:"singletonPredicate",get:function(){throw'Must override SNItem.singletonPredicate'}},{key:"singletonStrategy",get:function(){return i.KeepEarliest}},{key:"isSyncable",get:function(){return!this.errorDecrypting||!0===this.deleted}}],[{key:"DefaultAppDomain",value:function(){return d.b}}]),t})(),g=(function(){function e(t,n){v(this,e),this.item=t,this.type=n,this.payload=t.payload,this.payload.content&&(this.content=Object(l.a)(this.payload.content))}return y(e,[{key:"getUuid",value:function(){return this.payload.uuid}},{key:"getItem",value:function(){return this.item}},{key:"getResult",value:function(){if(this.type===r.NonDirtying)return Object(u.b)(this.payload,{content:this.content});this.payload.deleted||(this.type===r.UserInteraction?this.userModifiedDate=new Date:this.item.userModifiedDate||(this.userModifiedDate=new Date(this.item.serverUpdatedAt)));return Object(u.b)(this.payload,{content:this.content,dirty:!0,dirtiedDate:new Date})}},{key:"mergePayload",value:function(e){this.payload=Object(u.g)(this.payload,e),this.payload.content?this.content=Object(l.a)(this.payload.safeContent):this.content=void 0}},{key:"unsafe_setCustomContent",value:function(e){this.content=Object(l.a)(e)}},{key:"setDeleted",value:function(){this.content=void 0,this.payload=Object(u.b)(this.payload,{content:this.content,deleted:!0})}},{key:"setDomainData",value:function(e,t){this.payload.errorDecrypting||(this.content.appData||(this.content.appData={}),this.content.appData[t]=e)}},{key:"setDomainDataKey",value:function(e,t,n){if(!this.payload.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData;r[n]||(r[n]={}),r[n][e]=t}}},{key:"setAppDataItem",value:function(e,t){this.setDomainDataKey(e,t,f.DefaultAppDomain())}},{key:"addItemAsRelationship",value:function(e){var t=this.content.references||[];t.find(function(t){return t.uuid===e.uuid})||t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}},{key:"removeItemAsRelationship",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!==e.uuid}),this.content.references=t}},{key:"lastSyncBegan",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,lastSyncBegan:e})}},{key:"errorDecrypting",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,errorDecrypting:e})}},{key:"updated_at",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at:e})}},{key:"updated_at_timestamp",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at_timestamp:e})}},{key:"userModifiedDate",set:function(e){this.setAppDataItem(a.UserModifiedDate,e)}},{key:"conflictOf",set:function(e){this.content.conflict_of=e}},{key:"protected",set:function(e){this.content.protected=e}},{key:"trashed",set:function(e){this.content.trashed=e}},{key:"pinned",set:function(e){this.setAppDataItem(a.Pinned,e)}},{key:"archived",set:function(e){this.setAppDataItem(a.Archived,e)}},{key:"locked",set:function(e){this.setAppDataItem(a.Locked,e)}}]),e})();function m(e,t,n){return n||(n=[]),!b(e.content,t.content,e.contentKeysToIgnoreWhenCheckingEquality().concat(n),e.appDataContentKeysToIgnoreWhenCheckingEquality())}function b(e,t,n,r){if((e=Object(l.Q)(e)).appData){var a=e.appData[d.b];Object(l.J)(a,r),a?0===Object.keys(a).length&&delete e.appData:delete e.appData}if(Object(l.J)(e,n),(t=Object(l.Q)(t)).appData){var i=t.appData[d.b];Object(l.J)(i,r),i?0===Object.keys(i).length&&delete t.appData:delete t.appData}return Object(l.J)(t,n),JSON.stringify(e)===JSON.stringify(t)}}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"f",function(){return s}),n.d(t,"e",function(){return o}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return u});var r,a=n(3);function i(e){return e===a.a.RootKey||e===a.a.ItemsKey||e===a.a.EncryptedStorage}function s(e){return e===r.LocalStorageEncrypted||e===r.LocalStorageDecrypted||e===r.LocalStoragePreferEncrypted}function o(e){return e===r.FileEncrypted||e===r.FileDecrypted||e===r.FilePreferEncrypted}function c(e){return e===r.SyncDecrypted||e===r.LocalStorageDecrypted||e===r.FileDecrypted}function u(e){return e===r.Sync||e===r.LocalStorageEncrypted||e===r.FileEncrypted}!(function(e){e[e.Sync=0]="Sync",e[e.SyncDecrypted=1]="SyncDecrypted",e[e.LocalStorageEncrypted=2]="LocalStorageEncrypted",e[e.LocalStorageDecrypted=3]="LocalStorageDecrypted",e[e.LocalStoragePreferEncrypted=4]="LocalStoragePreferEncrypted",e[e.FileEncrypted=5]="FileEncrypted",e[e.FileDecrypted=6]="FileDecrypted",e[e.FilePreferEncrypted=7]="FilePreferEncrypted"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.FullSyncCompleted="sync:full-completed",e.SingleSyncCompleted="sync:single-completed",e.SyncWillBegin="sync:will-begin",e.DownloadFirstSyncCompleted="sync:download-first-completed",e.SyncTakingTooLong="sync:taking-too-long",e.SyncError="sync:error",e.InvalidSession="sync:invalid-session",e.MajorDataChange="major-data-change",e.LocalDataIncrementalLoad="local-data-incremental-load",e.LocalDataLoaded="local-data-loaded",e.EnterOutOfSync="enter-out-of-sync",e.ExitOutOfSync="exit-out-of-sync",e.StatusChanged="status-changed",e.DatabaseWriteError="database-write-error",e.DatabaseReadError="database-read-error"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var r=n(0),a=(function(){function e(){v(this,e),this.eventObservers=[],this.loggingEnabled=!1,this.criticalPromises=[]}return y(e,[{key:"addEventObserver",value:function(e){var t=this;return this.eventObservers.push(e),function(){Object(r.M)(t.eventObservers,e)}}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:n=S(this.eventObservers);case 1:if((r=n()).done){i.next=7;break}return a=r.value,i.next=5,b.awrap(a(e,t));case 5:i.next=1;break;case 7:case"end":return i.stop()}},null,this,null,Promise)}},{key:"blockDeinit",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(Promise.all(this.criticalPromises));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.eventObservers.length=0,this.deviceInterface=void 0}},{key:"executeCriticalFunction",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e(),this.criticalPromises.push(t),n.abrupt("return",t);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"log",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.loggingEnabled){var a,i=new Date,s=i.toLocaleTimeString().replace(' PM','').replace(' AM',''),o="".concat(s,".").concat(i.getMilliseconds());if(n)n=n.map(function(e){return Array.isArray(e)?e.slice():e}),(a=console).log.apply(a,[o,e].concat(m(n)));else console.log(o,e)}}}]),e})()},function(e,t,n){"use strict";n.d(t,"b",function(){return i}),n.d(t,"a",function(){return s});var r=n(7),a=n(3);function i(e){return e.map(function(e){return e.uuid})}function s(e){return e.references||(e.references=[]),e.appData||(e.appData={}),e.appData[a.b]||(e.appData[a.b]={}),e.appData[a.b][r.a.UserModifiedDate]||(e.appData[a.b][r.a.UserModifiedDate]="".concat(new Date)),e}},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.EncryptedString=0]="EncryptedString",e[e.DecryptedBareObject=1]="DecryptedBareObject",e[e.DecryptedBase64String=2]="DecryptedBase64String",e[e.Deleted=3]="Deleted"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"g",function(){return r}),n.d(t,"a",function(){return p}),n.d(t,"b",function(){return d}),n.d(t,"c",function(){return h}),n.d(t,"d",function(){return f}),n.d(t,"e",function(){return g}),n.d(t,"f",function(){return b}),n.d(t,"h",function(){return w});var r,a=n(14),i=n(6),s=n(0);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e.Registration="registration",e.EmailChange="email-change",e.PasswordChange="password-change",e.ProtocolUpgrade="protocol-upgrade",e.PasscodeCreate="passcode-create",e.PasscodeChange="passcode-change"})(r||(r={}));var l=['identifier','pw_cost','pw_nonce','pw_salt','version','origination','created'];function p(e){return g(e)}function d(e){return g(e)}function h(e){return g(e)}function f(e){return g(e)}function g(e){if(e.content)throw Error('Raw key params shouldnt have content; perhaps you passed in a SNRootKeyParams object.');return new w(e)}function m(e){if(e.version)return e.version;var t=e.pw_cost,n=a.a.PbkdfCostsUsed.includes(t),r=a.b.PbkdfCostsUsed.includes(t);return n&&!r?i.a.V001:r&&!n?i.a.V002:r&&n&&e.pw_nonce&&a.b.ImprobablePbkdfCostsUsed.includes(t)?i.a.V001:i.a.V002}function b(e,t){return g({identifier:t||e.data.identifier,pw_cost:e.data.pw_cost,pw_nonce:e.data.pw_nonce,pw_salt:e.data.pw_salt,version:m(e.data),origination:e.data.origination,created:e.data.created})}var w=(function(){function e(t){v(this,e),this.content=c(c({},t),{},{origination:t.origination||r.Registration,version:t.version||m(t)})}return y(e,[{key:"compare",value:function(e){if(this.version!==e.version)return!1;if([i.a.V004,i.a.V003].includes(this.version))return this.identifier===e.identifier&&this.content004.pw_nonce===e.content003.pw_nonce;if([i.a.V002,i.a.V001].includes(this.version))return this.identifier===e.identifier&&this.content002.pw_salt===e.content001.pw_salt;throw Error('Unhandled version in KeyParams.compare')}},{key:"getPortableValue",value:function(){return Object(s.L)(this.content,l)}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"identifier",get:function(){return this.content004.identifier||this.content002.email}},{key:"version",get:function(){return this.content.version}},{key:"origination",get:function(){return this.content.origination}},{key:"content001",get:function(){return this.content}},{key:"content002",get:function(){return this.content}},{key:"content003",get:function(){return this.content}},{key:"content004",get:function(){return this.content}},{key:"createdDate",get:function(){if(this.content004.created)return new Date(Number(this.content004.created))}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return s}),n.d(t,"c",function(){return r}),n.d(t,"d",function(){return a});var r,a,i=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:[3e3,5e3,1e4,6e4],PbkdfOutputLength:512,EncryptionKeyLength:256}),s=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:i.PbkdfCostsUsed.concat([1e5,101e3,102e3,103e3]),ImprobablePbkdfCostsUsed:[3e3,5e3],PbkdfOutputLength:768,EncryptionKeyLength:256,EncryptionIvLength:128});!(function(e){e[e.SaltSeedLength=256]="SaltSeedLength",e[e.PbkdfCost=11e4]="PbkdfCost",e[e.PbkdfOutputLength=768]="PbkdfOutputLength",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionIvLength=128]="EncryptionIvLength"})(r||(r={})),(function(e){e[e.ArgonSaltSeedLength=256]="ArgonSaltSeedLength",e[e.ArgonSaltLength=128]="ArgonSaltLength",e[e.ArgonIterations=5]="ArgonIterations",e[e.ArgonMemLimit=67108864]="ArgonMemLimit",e[e.ArgonOutputKeyBytes=64]="ArgonOutputKeyBytes",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionNonceLength=192]="EncryptionNonceLength"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"c",function(){return i}),n.d(t,"a",function(){return a});var r,a;n(22);function i(e){return e.status===r.HttpStatusExpiredAccessToken}!(function(e){e[e.LocalValidationError=10]="LocalValidationError",e[e.CanceledMfa=11]="CanceledMfa",e[e.UnknownError=12]="UnknownError",e[e.HttpStatusMinSuccess=200]="HttpStatusMinSuccess",e[e.HttpStatusNoContent=204]="HttpStatusNoContent",e[e.HttpStatusMaxSuccess=299]="HttpStatusMaxSuccess",e[e.HttpStatusExpiredAccessToken=498]="HttpStatusExpiredAccessToken",e[e.HttpStatusInvalidSession=401]="HttpStatusInvalidSession",e[e.HttpStatusForbidden=403]="HttpStatusForbidden",e[e.HttpBadRequest=400]="HttpBadRequest"})(r||(r={})),(function(e){e.ConflictingData="sync_conflict",e.UuidConflict="uuid_conflict",e.ContentTypeError="content_type_error",e.ContentError="content_error"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=(function(){function e(){v(this,e)}return y(e,null,[{key:"log",value:function(){this.onLog.apply(this,arguments)}},{key:"error",value:function(e){return this.onError(e),e}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"c",function(){return i});var r,a=n(9);function i(e){var t;return(t={},g(t,a.a.FullSyncCompleted,r.CompletedFullSync),g(t,a.a.SingleSyncCompleted,r.CompletedIncrementalSync),g(t,a.a.SyncError,r.FailedSync),g(t,a.a.SyncTakingTooLong,r.HighLatencySync),g(t,a.a.EnterOutOfSync,r.EnteredOutOfSync),g(t,a.a.ExitOutOfSync,r.ExitedOutOfSync),g(t,a.a.LocalDataLoaded,r.LocalDataLoaded),g(t,a.a.MajorDataChange,r.MajorDataChange),g(t,a.a.LocalDataIncrementalLoad,r.LocalDataIncrementalLoad),g(t,a.a.StatusChanged,r.SyncStatusChanged),g(t,a.a.SyncWillBegin,r.WillSync),g(t,a.a.InvalidSession,r.InvalidSyncSession),g(t,a.a.DatabaseReadError,r.LocalDatabaseReadError),g(t,a.a.DatabaseWriteError,r.LocalDatabaseWriteError),t)[e]}n.d(t,"b",function(){return a.a}),(function(e){e[e.SignedIn=2]="SignedIn",e[e.SignedOut=3]="SignedOut",e[e.CompletedFullSync=5]="CompletedFullSync",e[e.FailedSync=6]="FailedSync",e[e.HighLatencySync=7]="HighLatencySync",e[e.EnteredOutOfSync=8]="EnteredOutOfSync",e[e.ExitedOutOfSync=9]="ExitedOutOfSync",e[e.Started=10]="Started",e[e.Launched=11]="Launched",e[e.LocalDataLoaded=12]="LocalDataLoaded",e[e.KeyStatusChanged=13]="KeyStatusChanged",e[e.MajorDataChange=14]="MajorDataChange",e[e.CompletedRestart=15]="CompletedRestart",e[e.LocalDataIncrementalLoad=16]="LocalDataIncrementalLoad",e[e.SyncStatusChanged=17]="SyncStatusChanged",e[e.WillSync=18]="WillSync",e[e.InvalidSyncSession=19]="InvalidSyncSession",e[e.LocalDatabaseReadError=20]="LocalDatabaseReadError",e[e.LocalDatabaseWriteError=21]="LocalDatabaseWriteError",e[e.CompletedIncrementalSync=22]="CompletedIncrementalSync",e[e.MigrationsLoaded=23]="MigrationsLoaded",e[e.StorageReady=24]="StorageReady",e[e.PreferencesChanged=25]="PreferencesChanged",e[e.ProtectionSessionExpiryDateChanged=26]="ProtectionSessionExpiryDateChanged",e[e.UserRolesChanged=27]="UserRolesChanged",e[e.FeaturesUpdated=28]="FeaturesUpdated"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.KeepLeft=1]="KeepLeft",e[e.KeepRight=2]="KeepRight",e[e.KeepLeftDuplicateRight=3]="KeepLeftDuplicateRight",e[e.DuplicateLeftKeepRight=4]="DuplicateLeftKeepRight",e[e.KeepLeftMergeRefs=5]="KeepLeftMergeRefs"})(r||(r={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(211),t)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(221),t)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(0);function a(e){return e instanceof i?e:Array.isArray(e)?i.FromArray(e):i.FromJson(e)}var i=(function(){function e(t,n,r){if(v(this,e),this.keypath=t,this.operator=n,this.value=r,this.isRecursive()){var i=this.value;this.value=i.map(function(e){return a(e)})}else'true'!==this.value&&'false'!==this.value||(this.value=JSON.parse(this.value))}return y(e,[{key:"isRecursive",value:function(){return['and','or'].includes(this.operator)}},{key:"arrayRepresentation",value:function(){return[this.keypath,this.operator,this.value]}},{key:"valueAsArray",value:function(){return this.value}},{key:"keypathIncludesVerb",value:function(e){if(this.isRecursive()){for(var t,n=S(this.value);!(t=n()).done;){if(t.value.keypathIncludesVerb(e))return!0}return!1}return this.keypath.includes(e)}}],[{key:"FromJson",value:function(t){return new e(t.keypath,t.operator,t.value)}},{key:"FromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"CompoundPredicate",value:function(t){return new e('ignored','and',t)}},{key:"ObjectSatisfiesPredicate",value:function(e,t){if((t=a(t)).isRecursive()){if('and'===t.operator){for(var n,r=S(t.valueAsArray());!(n=r()).done;){var i=n.value;if(!this.ObjectSatisfiesPredicate(e,i))return!1}return!0}if('or'===t.operator){for(var s,o=S(t.valueAsArray());!(s=o()).done;){var c=s.value;if(this.ObjectSatisfiesPredicate(e,c))return!0}return!1}}var u=t.value;if('string'==typeof u&&u.includes('.ago')&&(u=this.DateFromString(u)),'not'===t.operator)return!this.ObjectSatisfiesPredicate(e,u);var l=t.keypath.split('.').reduce(function(e,t){return e&&e[t]},e),p=[!1,'',null,void 0,NaN];return void 0===l?'!='===t.operator?!p.includes(t.value):p.includes(t.value):'='===t.operator?Array.isArray(l)?JSON.stringify(l)===JSON.stringify(u):l===u:'!='===t.operator?Array.isArray(l)?JSON.stringify(l)!==JSON.stringify(u):l!==u:'<'===t.operator?l<u:'>'===t.operator?l>u:'<='===t.operator?l<=u:'>='===t.operator?l>=u:'startsWith'===t.operator?l.startsWith(u):'in'===t.operator?-1!==u.indexOf(l):'includes'===t.operator?this.resolveIncludesPredicate(l,u):'matches'===t.operator&&new RegExp(u).test(l)}},{key:"resolveIncludesPredicate",value:function(t,n){if(Object(r.A)(n))return t.includes(n);var a;a=Array.isArray(n)?e.FromArray(n):n;for(var i,s=S(t);!(i=s()).done;){var o=i.value;if(this.ObjectSatisfiesPredicate(o,a))return!0}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!this.ItemSatisfiesPredicate(e,a))return!1}return!0}},{key:"DateFromString",value:function(e){var t=e.split('.'),n=t[1],r=new Date,a=parseInt(t[0]);return'days'===n?r.setDate(r.getDate()-a):'hours'===n&&r.setHours(r.getHours()-a),r}}]),e})()},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.LastSyncToken="sync_token",e.PaginationToken="cursor_token",e.IntegrityCheck="compute_integrity",e.IntegrityResult="integrity_hash",e.SyncDlLimit="limit",e.SyncPayloads="items",e.ApiVersion="api"})(r||(r={}))},function(e,t,n){"use strict";var r=Array.isArray;e.exports=r},function(e,t,n){"use strict";var r=n(68),a='object'==typeof self&&self&&self.Object===Object&&self,i=r||a||Function('return this')();e.exports=i},function(e,t,n){"use strict";var r=n(173)(n(174));e.exports=r},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(e,t,n){"use strict";var r=n(48),a=n(168);e.exports=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,s=[],o=e.length;for(t=r(t,3);++i<o;){var c=e[i];t(c,i,e)&&(n.push(c),s.push(i))}return a(e,s),n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e){return e&&e.length?r(e):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(241),t)},function(e,t,n){"use strict";var r=n(110),a=n(115);e.exports=function(e,t){var n=a(e,t);return r(n)?n:void 0}},function(e,t,n){"use strict";e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t,n){"use strict";n.d(t,"a",function(){return u});var r=n(11),a=n(5),i=n(4),s=n(6),o=n(0),c=n(12),u=(function(){function e(t,n,u){if(v(this,e),this.fields=n||Object.keys(t),this.source=u||i.a.Constructor,this.uuid=t.uuid,!this.uuid&&this.fields.includes(a.a.Uuid))throw Error("uuid is null, yet this payloads fields indicate it shouldnt be. Content type: ".concat(t.content_type));this.content_type=t.content_type,t.content&&(Object(o.x)(t.content)?this.content=Object(r.a)(t.content):this.content=t.content),this.deleted=t.deleted,this.items_key_id=t.items_key_id,this.enc_item_key=t.enc_item_key,this.created_at=new Date(t.created_at||new Date),this.updated_at=new Date(t.updated_at||0),this.created_at_timestamp=t.created_at_timestamp,this.updated_at_timestamp=t.updated_at_timestamp,t.dirtiedDate&&(this.dirtiedDate=new Date(t.dirtiedDate)),this.dirty=t.dirty,this.errorDecrypting=t.errorDecrypting,this.waitingForKey=t.waitingForKey,this.errorDecryptingValueChanged=t.errorDecryptingValueChanged,this.lastSyncBegan=t.lastSyncBegan?new Date(t.lastSyncBegan):void 0,this.lastSyncEnd=t.lastSyncEnd?new Date(t.lastSyncEnd):void 0,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params,this.duplicate_of=t.duplicate_of,Object(o.A)(this.content)?this.content.startsWith(s.a.V000Base64Decrypted)?this.format=c.a.DecryptedBase64String:this.format=c.a.EncryptedString:Object(o.x)(this.content)?this.format=c.a.DecryptedBareObject:this.format=c.a.Deleted,Object(o.A)(this.content)?this.version=this.content.substring(0,s.a.VersionLength):this.content&&(this.version=this.content.version),Object(o.l)(this)}return y(e,[{key:"ejected",value:function(){for(var e,t=[a.a.Legacy003AuthHash,a.a.Deleted],n=[a.a.DirtiedDate,a.a.ErrorDecrypting,a.a.ErrorDecryptingChanged,a.a.WaitingForKey,a.a.LastSyncBegan,a.a.LastSyncEnd],r={},i=S(this.fields);!(e=i()).done;){var s=e.value;if(!n.includes(s)){var c=this[s];Object(o.w)(c)&&t.includes(s)||(r[s]=c)}}return r}},{key:"safeContent",get:function(){return this.format===c.a.DecryptedBareObject?this.content:{}}},{key:"references",get:function(){return this.safeReferences}},{key:"safeReferences",get:function(){return this.safeContent.references||[]}},{key:"contentObject",get:function(){if(this.format!==c.a.DecryptedBareObject)throw Error('Attempting to access non-object content as object');return this.content}},{key:"contentString",get:function(){if(this.format===c.a.DecryptedBareObject)throw Error('Attempting to access non-string content as string');return this.content}},{key:"discardable",get:function(){return this.deleted&&!this.dirty}},{key:"serverUpdatedAt",get:function(){return this.updated_at}}]),e})()},function(e,t,n){"use strict";var r=n(40),a=n(111),i=n(112),s='[object Null]',o='[object Undefined]',c=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?o:s:c&&c in Object(e)?a(e):i(e)}},function(e,t,n){"use strict";var r;r=(function(){return this})();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,n){"use strict";var r=n(51),a=n(59);e.exports=function(e){return null!=e&&a(e.length)&&!r(e)}},function(e,t,n){"use strict";var r=n(44);e.exports=function(e){if('string'==typeof e||r(e))return e;var t=e+'';return'0'==t&&1/e==-1/0?'-0':t}},function(e,t,n){"use strict";var r=n(100),a=n(101),i=n(102),s=n(103),o=n(104);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(35);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},function(e,t,n){"use strict";var r=n(24).Symbol;e.exports=r},function(e,t,n){"use strict";var r=n(30)(Object,'create');e.exports=r},function(e,t,n){"use strict";var r=n(124);e.exports=function(e,t){var n=e.__data__;return r(t)?n['string'==typeof t?'string':'hash']:n.map}},function(e,t,n){"use strict";var r=9007199254740991,a=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var n=typeof e;return!!(t=null==t?r:t)&&('number'==n||'symbol'!=n&&a.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Symbol]';e.exports=function(e){return'symbol'==typeof e||a(e)&&r(e)==i}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(231),t)},function(e,t,n){"use strict";var r=n(96);n.d(t,"SNSettingsService",function(){return r.a});var a=n(94);n.n(a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n){r(e,t,n)});e.exports=a},function(e,t,n){"use strict";var r=n(98),a=n(154),i=n(64),s=n(23),o=n(165);e.exports=function(e){return'function'==typeof e?e:null==e?i:'object'==typeof e?s(e)?a(e[0],e[1]):r(e):o(e)}},function(e,t,n){"use strict";var r=n(38),a=n(105),i=n(106),s=n(107),o=n(108),c=n(109);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=a,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=c,e.exports=u},function(e,t,n){"use strict";var r=n(30)(n(24),'Map');e.exports=r},function(e,t,n){"use strict";var r=n(33),a=n(26),i='[object AsyncFunction]',s='[object Function]',o='[object GeneratorFunction]',c='[object Proxy]';e.exports=function(e){if(!a(e))return!1;var t=r(e);return t==s||t==o||t==i||t==c}},function(e,t,n){"use strict";var r=n(116),a=n(123),i=n(125),s=n(126),o=n(127);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},function(e,t,n){"use strict";var r=n(75),a=n(147),i=n(36);e.exports=function(e){return i(e)?r(e):a(e)}},function(e,t,n){"use strict";var r=n(142),a=n(31),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,c=r((function(){return arguments})())?r:function(e){return a(e)&&s.call(e,'callee')&&!o.call(e,'callee')};e.exports=c},function(e,t,n){"use strict";(function(e){var r=n(24),a=n(143),i=t&&!t.nodeType&&t,s=i&&'object'==typeof e&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,c=(o?o.isBuffer:void 0)||a;e.exports=c}).call(this,n(57)(e))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";var r=n(144),a=n(145),i=n(146),s=i&&i.isTypedArray,o=s?a(s):r;e.exports=o},function(e,t,n){"use strict";var r=9007199254740991;e.exports=function(e){return'number'==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,n){"use strict";var r=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===('function'==typeof t&&t.prototype||r)}},function(e,t,n){"use strict";var r=n(62),a=n(37);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[a(t[n++])];return n&&n==i?e:void 0}},function(e,t,n){"use strict";var r=n(23),a=n(63),i=n(156),s=n(159);e.exports=function(e,t){return r(e)?e:a(e,t)?[e]:i(s(e))}},function(e,t,n){"use strict";var r=n(23),a=n(44),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!('number'!=n&&'symbol'!=n&&'boolean'!=n&&null!=e&&!a(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},function(e,t,n){"use strict";e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(83);e.exports=function(e,t,n){'__proto__'==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e,t){return t='function'==typeof t?t:void 0,e&&e.length?r(e,void 0,t):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(228),t),a(n(229),t),a(n(230),t)},function(e,t,n){"use strict";(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(34))},function(e,t,n){"use strict";var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+''}catch(e){}}return''}},function(e,t,n){"use strict";var r=n(128),a=n(31);e.exports=function e(t,n,i,s,o){return t===n||(null==t||null==n||!a(t)&&!a(n)?t!=t&&n!=n:r(t,n,i,s,e,o))}},function(e,t,n){"use strict";var r=n(72),a=n(131),i=n(73),s=1,o=2;e.exports=function(e,t,n,c,u,l){var p=n&s,d=e.length,h=t.length;if(d!=h&&!(p&&h>d))return!1;var f=l.get(e),v=l.get(t);if(f&&v)return f==t&&v==e;var y=-1,g=!0,m=n&o?new r:void 0;for(l.set(e,t),l.set(t,e);++y<d;){var b=e[y],w=t[y];if(c)var k=p?c(w,b,y,t,e,l):c(b,w,y,e,t,l);if(void 0!==k){if(k)continue;g=!1;break}if(m){if(!a(t,function(e,t){if(!i(m,t)&&(b===e||u(b,e,n,c,l)))return m.push(t)})){g=!1;break}}else if(b!==w&&!u(b,w,n,c,l)){g=!1;break}}return l.delete(e),l.delete(t),g}},function(e,t,n){"use strict";var r=n(52),a=n(129),i=n(130);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=a,s.prototype.has=i,e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t){return e.has(t)}},function(e,t,n){"use strict";var r=n(24).Uint8Array;e.exports=r},function(e,t,n){"use strict";var r=n(141),a=n(55),i=n(23),s=n(56),o=n(43),c=n(58),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&a(e),p=!n&&!l&&s(e),d=!n&&!l&&!p&&c(e),h=n||l||p||d,f=h?r(e.length,String):[],v=f.length;for(var y in e)!t&&!u.call(e,y)||h&&('length'==y||p&&('offset'==y||'parent'==y)||d&&('buffer'==y||'byteLength'==y||'byteOffset'==y)||o(y,v))||f.push(y);return f}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){"use strict";var r=n(30)(n(24),'Set');e.exports=r},function(e,t,n){"use strict";var r=n(26);e.exports=function(e){return e==e&&!r(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){for(var a=e.length,i=n+(r?1:-1);r?i--:++i<a;)if(t(e[i],i,e))return i;return-1}},function(e,t,n){"use strict";var r=n(49),a=n(82),i=n(178),s=n(180),o=n(26),c=n(86),u=n(85);e.exports=function e(t,n,l,p,d){t!==n&&i(n,function(i,c){if(d||(d=new r),o(i))s(t,n,c,l,e,p,d);else{var h=p?p(u(t,c),i,c+'',t,n,d):void 0;void 0===h&&(h=i),a(t,c,h)}},c)}},function(e,t,n){"use strict";var r=n(65),a=n(35);e.exports=function(e,t,n){(void 0===n||a(e[t],n))&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(30),a=(function(){try{var e=r(Object,'defineProperty');return e({},'',{}),e}catch(e){}})();e.exports=a},function(e,t,n){"use strict";var r=n(76)(Object.getPrototypeOf,Object);e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){if(('constructor'!==t||'function'!=typeof e[t])&&'__proto__'!=t)return e[t]}},function(e,t,n){"use strict";var r=n(75),a=n(192),i=n(36);e.exports=function(e){return i(e)?r(e,!0):a(e)}},function(e,t,n){"use strict";var r=n(194),a=n(201);e.exports=function(e){return r(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(s=e.length>3&&'function'==typeof s?(i--,s):void 0,o&&a(n[0],n[1],o)&&(s=i<3?void 0:s,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,s)}return t})}},function(e,t,n){"use strict";var r=n(72),a=n(202),i=n(206),s=n(73),o=n(207),c=n(53),u=200;e.exports=function(e,t,n){var l=-1,p=a,d=e.length,h=!0,f=[],v=f;if(n)h=!1,p=i;else if(d>=u){var y=t?null:o(e);if(y)return c(y);h=!1,p=s,v=new r}else v=t?[]:f;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=n||0!==g?g:0,h&&m==m){for(var b=v.length;b--;)if(v[b]===m)continue e;t&&v.push(m),f.push(g)}else p(v,m,n)||(v!==f&&v.push(m),f.push(g))}return f}},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(209),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeatureIdentifier=void 0,(function(e){e.AutobiographyTheme="org.standardnotes.theme-autobiography",e.BoldEditor="org.standardnotes.bold-editor",e.CloudLink="org.standardnotes.cloudlink",e.CodeEditor="org.standardnotes.code-editor",e.DailyDropboxBackup="org.standardnotes.daily-dropbox-backup",e.DailyEmailBackup="org.standardnotes.daily-email-backup",e.DailyGDriveBackup="org.standardnotes.daily-gdrive-backup",e.DailyOneDriveBackup="org.standardnotes.daily-onedrive-backup",e.DynamicTheme="org.standardnotes.theme-dynamic",e.Files="org.standardnotes.files",e.Files25GB="org.standardnotes.files-25-gb",e.Files5GB="org.standardnotes.files-5-gb",e.FileSafe="org.standardnotes.file-safe",e.FocusedTheme="org.standardnotes.theme-focus",e.FoldersComponent="org.standardnotes.folders",e.FuturaTheme="org.standardnotes.theme-futura",e.ListedCustomDomain="org.standardnotes.listed-custom-domain",e.MarkdownBasicEditor="org.standardnotes.simple-markdown-editor",e.MarkdownMathEditor="org.standardnotes.fancy-markdown-editor",e.MarkdownMinimistEditor="org.standardnotes.minimal-markdown-editor",e.MarkdownProEditor="org.standardnotes.advanced-markdown-editor",e.MidnightTheme="org.standardnotes.theme-midnight",e.NoDistractionTheme="org.standardnotes.theme-no-distraction",e.NoteHistory30Days="org.standardnotes.note-history-30",e.NoteHistory365Days="org.standardnotes.note-history-365",e.NoteHistoryUnlimited="org.standardnotes.note-history-unlimited",e.PlusEditor="org.standardnotes.plus-editor",e.SheetsEditor="org.standardnotes.standard-sheets",e.SolarizedDarkTheme="org.standardnotes.theme-solarized-dark",e.TagNesting="org.standardnotes.tag-nesting",e.TaskEditor="org.standardnotes.simple-task-editor",e.TitaniumTheme="org.standardnotes.theme-titanium",e.TokenVaultEditor="org.standardnotes.token-vault",e.TwoFactorAuth="org.standardnotes.two-factor-auth",e.TwoFactorAuthManager="org.standardnotes.mfa-link",e.FocusMode="org.standardnotes.focus-mode"})(t.FeatureIdentifier||(t.FeatureIdentifier={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentArea=void 0,(function(e){e.Editor="editor-editor",e.Themes="themes",e.TagsList="tags-list",e.EditorStack="editor-stack",e.NoteTags="note-tags",e.Rooms="rooms",e.Modal="modal",e.Any="*"})(t.ComponentArea||(t.ComponentArea={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentFlag=void 0,(function(e){e.New="New",e.Deprecated="Deprecated"})(t.ComponentFlag||(t.ComponentFlag={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionName=void 0,(function(e){e.AutobiographyTheme="theme:autobiography",e.BoldEditor="editor:bold",e.CloudLink="component:cloud-link",e.CodeEditor="editor:code-editor",e.ComponentFilesafe="component:filesafe",e.ComponentFolders="component:folders",e.DailyDropboxBackup="server:daily-dropbox-backup",e.DailyEmailBackup="server:daily-email-backup",e.DailyGDriveBackup="server:daily-gdrive-backup",e.DailyOneDriveBackup="server:daily-onedrive-backup",e.Files="app:files",e.Files25GB="server:files-25-gb",e.Files5GB="server:files-5-gb",e.FocusedTheme="theme:focused",e.FuturaTheme="theme:futura",e.ListedCustomDomain="listed:custom-domain",e.MarkdownBasicEditor="editor:markdown-basic",e.MarkdownMathEditor="editor:markdown-math",e.MarkdownMinimistEditor="editor:markdown-minimist",e.MarkdownProEditor="editor:markdown-pro",e.MidnightTheme="theme:midnight",e.NoteHistory30Days="server:note-history-30-days",e.NoteHistory365Days="server:note-history-365-days",e.NoteHistoryUnlimited="server:note-history-unlimited",e.PlusEditor="editor:plus",e.SheetsEditor="editor:sheets",e.SolarizedDarkTheme="theme:solarized-dark",e.TagNesting="app:tag-nesting",e.TaskEditor="editor:task-editor",e.ThemeDynamic="theme:dynamic",e.ThemeNoDistraction="theme:no-distraction",e.TitaniumTheme="theme:titanium",e.TokenVaultEditor="editor:token-vault",e.TwoFactorAuth="server:two-factor-auth",e.TwoFactorAuthManager="component:2fa-manager",e.FocusMode="app:focus-mode"})(t.PermissionName||(t.PermissionName={}))},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return i});var r=n(10),a=n(17),i=(function(t){d(r,t);var n=k(r);function r(t){var a;return v(this,r),(a=n.call(this)).application=t,e(function(){a.addAppEventObserver()}),a}return y(r,[{key:"deinit",value:function(){this.application=void 0,this.unsubApp(),this.unsubApp=void 0,p(f(r.prototype),"deinit",this).call(this)}},{key:"addAppEventObserver",value:function(){var e=this;this.application.isStarted()&&this.onAppStart(),this.application.isLaunched()&&this.onAppLaunch(),this.unsubApp=this.application.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(e.onAppEvent(t));case 2:t===a.a.Started?e.onAppStart():t===a.a.Launched?e.onAppLaunch():t===a.a.CompletedFullSync?e.onAppFullSync():t===a.a.CompletedIncrementalSync?e.onAppIncrementalSync():t===a.a.KeyStatusChanged&&e.onAppKeyChange();case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"onAppEvent",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppStart",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppLaunch",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppKeyChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppIncrementalSync",value:function(){}},{key:"onAppFullSync",value:function(){}}]),r})(r.a)}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(10),a=n(2),i=n(15),s=(function(){function e(t,n){v(this,e),this.settingsApi=t,this.userProvider=n}return y(e,[{key:"isReadyForModification",value:function(){return null!=this.getUser()}},{key:"getUser",value:function(){return this.userProvider.getUser()}},{key:"listSettings",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.settingsApi.listSettings(this.userUuid));case 2:if(e=o.sent,t=e.error,n=e.data,null==t){o.next=7;break}throw new Error(t.message);case 7:if(null!=n&&null!=n.settings){o.next=9;break}return o.abrupt("return",{});case 9:for(r={},a=S(n.settings);!(i=a()).done;)s=i.value,r[s.name]=s.value;return o.abrupt("return",r);case 12:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){var t,n,r,a;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((a=s.sent).status!==i.b.HttpBadRequest){s.next=5;break}return s.abrupt("return",null);case 5:if(null==a.error){s.next=7;break}throw new Error(a.error.message);case 7:return s.abrupt("return",null!==(t=null===a||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:null===(r=n.setting)||void 0===r?void 0:r.value)&&void 0!==t?t:null);case 8:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((r=a.sent).status!==i.b.HttpBadRequest){a.next=5;break}return a.abrupt("return",!1);case 5:if(null==r.error){a.next=7;break}throw new Error(r.error.message);case 7:return a.abrupt("return",null!==(t=null===(n=r.data)||void 0===n?void 0:n.success)&&void 0!==t&&t);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){var r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.settingsApi.updateSetting(this.userUuid,e,t,n));case 2:if(r=i.sent,null==(a=r.error)){i.next=6;break}throw new Error(a.message);case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.settingsApi.deleteSetting(this.userUuid,e));case 2:if(t=r.sent,null==(n=t.error)){r.next=6;break}throw new Error(n.message);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.settingsApi=void 0,this.userProvider=void 0}},{key:"userUuid",get:function(){var e=this.getUser();if(null==e||null==e.uuid)throw new Error(a.o);return e.uuid}}]),e})(),o=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).sessionManager=e,a.apiService=r,a}return y(n,[{key:"initializeFromDisk",value:function(){this._provider=new s(this.apiService,this.sessionManager)}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._provider.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this._provider.updateSetting(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){var e;null===(e=this._provider)||void 0===e||e.deinit(),this._provider=void 0,this.sessionManager=void 0,this.apiService=void 0}}]),n})(r.a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n,a){r(e,t,n,a)});e.exports=a},function(e,t,n){"use strict";var r=n(99),a=n(153),i=n(79);e.exports=function(e){var t=a(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){"use strict";var r=n(49),a=n(70);e.exports=function(e,t,n,i){var s=n.length,o=s,c=!i;if(null==e)return!o;for(e=Object(e);s--;){var u=n[s];if(c&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++s<o;){var l=(u=n[s])[0],p=e[l],d=u[1];if(c&&u[2]){if(void 0===p&&!(l in e))return!1}else{var h=new r;if(i)var f=i(p,d,l,e,t,h);if(!(void 0===f?a(d,p,3,i,h):f))return!1}}return!0}},function(e,t,n){"use strict";e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){"use strict";var r=n(39),a=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():a.call(t,n,1),--this.size,0))}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e,t){var n=this.__data__,a=r(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}},function(e,t,n){"use strict";var r=n(38);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.get(e)}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";var r=n(38),a=n(50),i=n(52);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!a||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){"use strict";var r=n(51),a=n(113),i=n(26),s=n(69),o=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,p=u.hasOwnProperty,d=RegExp('^'+l.call(p).replace(/[\\^$.*+?()[\]{}|]/g,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');e.exports=function(e){return!(!i(e)||a(e))&&(r(e)?d:o).test(s(e))}},function(e,t,n){"use strict";var r=n(40),a=Object.prototype,i=a.hasOwnProperty,s=a.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0}catch(e){}var r=s.call(e);return t?e[o]=n:delete e[o],r}},function(e,t,n){"use strict";var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,n){"use strict";var r,a=n(114),i=(r=/[^.]+$/.exec(a&&a.keys&&a.keys.IE_PROTO||''))?'Symbol(src)_1.'+r:'';e.exports=function(e){return!!i&&i in e}},function(e,t,n){"use strict";var r=n(24)['__core-js_shared__'];e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){"use strict";var r=n(117),a=n(38),i=n(50);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||a),string:new r}}},function(e,t,n){"use strict";var r=n(118),a=n(119),i=n(120),s=n(121),o=n(122);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(41);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__',i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===a?void 0:n}return i.call(t,e)?t[e]:void 0}},function(e,t,n){"use strict";var r=n(41),a=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:a.call(t,e)}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__';e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?a:t,this}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return'string'==t||'number'==t||'symbol'==t||'boolean'==t?'__proto__'!==e:null===e}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).get(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).has(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e,t){var n=r(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}},function(e,t,n){"use strict";var r=n(49),a=n(71),i=n(132),s=n(134),o=n(149),c=n(23),u=n(56),l=n(58),p=1,d='[object Arguments]',h='[object Array]',f='[object Object]',v=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,y,g,m){var b=c(e),w=c(t),k=b?h:o(e),x=w?h:o(t),S=(k=k==d?f:k)==f,P=(x=x==d?f:x)==f,O=k==x;if(O&&u(e)){if(!u(t))return!1;b=!0,S=!1}if(O&&!S)return m||(m=new r),b||l(e)?a(e,t,n,y,g,m):i(e,t,k,n,y,g,m);if(!(n&p)){var C=S&&v.call(e,'__wrapped__'),D=P&&v.call(t,'__wrapped__');if(C||D){var _=C?e.value():e,E=D?t.value():t;return m||(m=new r),g(_,E,n,y,m)}}return!!O&&(m||(m=new r),s(e,t,n,y,g,m))}},function(e,t,n){"use strict";var r='__lodash_hash_undefined__';e.exports=function(e){return this.__data__.set(e,r),this}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},function(e,t,n){"use strict";var r=n(40),a=n(74),i=n(35),s=n(71),o=n(133),c=n(53),u=1,l=2,p='[object Boolean]',d='[object Date]',h='[object Error]',f='[object Map]',v='[object Number]',y='[object RegExp]',g='[object Set]',m='[object String]',b='[object Symbol]',w='[object ArrayBuffer]',k='[object DataView]',x=r?r.prototype:void 0,S=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,P,O){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!P(new a(e),new a(t)));case p:case d:case v:return i(+e,+t);case h:return e.name==t.name&&e.message==t.message;case y:case m:return e==t+'';case f:var C=o;case g:var D=r&u;if(C||(C=c),e.size!=t.size&&!D)return!1;var _=O.get(e);if(_)return _==t;r|=l,O.set(e,t);var E=s(C(e),C(t),r,x,P,O);return O.delete(e),E;case b:if(S)return S.call(e)==S.call(t)}return!1}},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},function(e,t,n){"use strict";var r=n(135),a=1,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,s,o,c){var u=n&a,l=r(e),p=l.length;if(p!=r(t).length&&!u)return!1;for(var d=p;d--;){var h=l[d];if(!(u?h in t:i.call(t,h)))return!1}var f=c.get(e),v=c.get(t);if(f&&v)return f==t&&v==e;var y=!0;c.set(e,t),c.set(t,e);for(var g=u;++d<p;){var m=e[h=l[d]],b=t[h];if(s)var w=u?s(b,m,h,t,e,c):s(m,b,h,e,t,c);if(!(void 0===w?m===b||o(m,b,n,s,c):w)){y=!1;break}g||(g='constructor'==h)}if(y&&!g){var k=e.constructor,x=t.constructor;k!=x&&'constructor'in e&&'constructor'in t&&!('function'==typeof k&&k instanceof k&&'function'==typeof x&&x instanceof x)&&(y=!1)}return c.delete(e),c.delete(t),y}},function(e,t,n){"use strict";var r=n(136),a=n(138),i=n(54);e.exports=function(e){return r(e,i,a)}},function(e,t,n){"use strict";var r=n(137),a=n(23);e.exports=function(e,t,n){var i=t(e);return a(e)?i:r(i,n(e))}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}},function(e,t,n){"use strict";var r=n(139),a=n(140),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:a;e.exports=o},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}},function(e,t,n){"use strict";e.exports=function(){return[]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Arguments]';e.exports=function(e){return a(e)&&r(e)==i}},function(e,t,n){"use strict";e.exports=function(){return!1}},function(e,t,n){"use strict";var r=n(33),a=n(59),i=n(31),s={};s['[object Float32Array]']=s['[object Float64Array]']=s['[object Int8Array]']=s['[object Int16Array]']=s['[object Int32Array]']=s['[object Uint8Array]']=s['[object Uint8ClampedArray]']=s['[object Uint16Array]']=s['[object Uint32Array]']=!0,s['[object Arguments]']=s['[object Array]']=s['[object ArrayBuffer]']=s['[object Boolean]']=s['[object DataView]']=s['[object Date]']=s['[object Error]']=s['[object Function]']=s['[object Map]']=s['[object Number]']=s['[object Object]']=s['[object RegExp]']=s['[object Set]']=s['[object String]']=s['[object WeakMap]']=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!s[r(e)]}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){"use strict";(function(e){var r=n(68),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a&&r.process,o=(function(){try{var e=i&&i.require&&i.require('util').types;return e||s&&s.binding&&s.binding('util')}catch(e){}})();e.exports=o}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(60),a=n(148),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return a(e);var t=[];for(var n in Object(e))i.call(e,n)&&'constructor'!=n&&t.push(n);return t}},function(e,t,n){"use strict";var r=n(76)(Object.keys,Object);e.exports=r},function(e,t,n){"use strict";var r=n(150),a=n(50),i=n(151),s=n(77),o=n(152),c=n(33),u=n(69),l=u(r),p=u(a),d=u(i),h=u(s),f=u(o),v=c;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||a&&"[object Map]"!=v(new a)||i&&"[object Promise]"!=v(i.resolve())||s&&"[object Set]"!=v(new s)||o&&"[object WeakMap]"!=v(new o))&&(v=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):'';if(r)switch(r){case l:return"[object DataView]";case p:return"[object Map]";case d:return"[object Promise]";case h:return"[object Set]";case f:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";var r=n(30)(n(24),'DataView');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'Promise');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'WeakMap');e.exports=r},function(e,t,n){"use strict";var r=n(78),a=n(54);e.exports=function(e){for(var t=a(e),n=t.length;n--;){var i=t[n],s=e[i];t[n]=[i,s,r(s)]}return t}},function(e,t,n){"use strict";var r=n(70),a=n(155),i=n(162),s=n(63),o=n(78),c=n(79),u=n(37);e.exports=function(e,t){return s(e)&&o(t)?c(u(e),t):function(n){var s=a(n,e);return void 0===s&&s===t?i(n,e):r(t,s,3)}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e,t,n){var a=null==e?void 0:r(e,t);return void 0===a?n:a}},function(e,t,n){"use strict";var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,i=n(157)(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(''),e.replace(r,function(e,n,r,i){t.push(r?i.replace(a,'$1'):n||e)}),t});e.exports=i},function(e,t,n){"use strict";var r=n(158),a=500;e.exports=function(e){var t=r(e,function(e){return n.size===a&&n.clear(),e}),n=t.cache;return t}},function(e,t,n){"use strict";var r=n(52),a='Expected a function';function i(e,t){if('function'!=typeof e||null!=t&&'function'!=typeof t)throw new TypeError(a);var n=function n(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},function(e,t,n){"use strict";var r=n(160);e.exports=function(e){return null==e?'':r(e)}},function(e,t,n){"use strict";var r=n(40),a=n(161),i=n(23),s=n(44),o=r?r.prototype:void 0,c=o?o.toString:void 0;e.exports=function e(t){if('string'==typeof t)return t;if(i(t))return a(t,e)+'';if(s(t))return c?c.call(t):'';var n=t+'';return'0'==n&&1/t==-1/0?'-0':n}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}},function(e,t,n){"use strict";var r=n(163),a=n(164);e.exports=function(e,t){return null!=e&&a(e,t,r)}},function(e,t,n){"use strict";e.exports=function(e,t){return null!=e&&t in Object(e)}},function(e,t,n){"use strict";var r=n(62),a=n(55),i=n(23),s=n(43),o=n(59),c=n(37);e.exports=function(e,t,n){for(var u=-1,l=(t=r(t,e)).length,p=!1;++u<l;){var d=c(t[u]);if(!(p=null!=e&&n(e,d)))break;e=e[d]}return p||++u!=l?p:!!(l=null==e?0:e.length)&&o(l)&&s(d,l)&&(i(e)||a(e))}},function(e,t,n){"use strict";var r=n(166),a=n(167),i=n(63),s=n(37);e.exports=function(e){return i(e)?r(s(e)):a(e)}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e){return function(t){return r(t,e)}}},function(e,t,n){"use strict";var r=n(169),a=n(43),i=Array.prototype.splice;e.exports=function(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;a(o)?i.call(e,o,1):r(e,o)}}return e}},function(e,t,n){"use strict";var r=n(62),a=n(170),i=n(171),s=n(37);e.exports=function(e,t){return t=r(t,e),null==(e=i(e,t))||delete e[s(a(t))]}},function(e,t,n){"use strict";e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t,n){"use strict";var r=n(61),a=n(172);e.exports=function(e,t){return t.length<2?e:r(e,a(t,0,-1))}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(a);++r<a;)i[r]=e[r+t];return i}},function(e,t,n){"use strict";var r=n(48),a=n(36),i=n(54);e.exports=function(e){return function(t,n,s){var o=Object(t);if(!a(t)){var c=r(n,3);t=i(t),n=function(e){return c(o[e],e,o)}}var u=e(t,n,s);return u>-1?o[c?t[u]:u]:void 0}}},function(e,t,n){"use strict";var r=n(80),a=n(48),i=n(175),s=Math.max;e.exports=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var c=null==n?0:i(n);return c<0&&(c=s(o+c,0)),r(e,a(t,3),c)}},function(e,t,n){"use strict";var r=n(176);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){"use strict";var r=n(177),a=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=r(e))===a||e===-1/0?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,n){"use strict";var r=n(26),a=n(44),i=NaN,s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(a(e))return i;if(r(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=r(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):o.test(e)?i:+e}},function(e,t,n){"use strict";var r=n(179)();e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t,n,r){for(var a=-1,i=Object(t),s=r(t),o=s.length;o--;){var c=s[e?o:++a];if(!1===n(i[c],c,i))break}return t}}},function(e,t,n){"use strict";var r=n(82),a=n(181),i=n(182),s=n(184),o=n(185),c=n(55),u=n(23),l=n(187),p=n(56),d=n(51),h=n(26),f=n(188),v=n(58),y=n(85),g=n(189);e.exports=function(e,t,n,m,b,w,k){var x=y(e,n),S=y(t,n),P=k.get(S);if(P)r(e,n,P);else{var O=w?w(x,S,n+'',e,t,k):void 0,C=void 0===O;if(C){var D=u(S),_=!D&&p(S),E=!D&&!_&&v(S);O=S,D||_||E?u(x)?O=x:l(x)?O=s(x):_?(C=!1,O=a(S,!0)):E?(C=!1,O=i(S,!0)):O=[]:f(S)||c(S)?(O=x,c(x)?O=g(x):h(x)&&!d(x)||(O=o(S))):C=!1}C&&(k.set(S,O),b(O,S,m,w,k),k.delete(S)),r(e,n,O)}}},function(e,t,n){"use strict";(function(e){var r=n(24),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(183);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},function(e,t,n){"use strict";var r=n(74);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t,n){"use strict";e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},function(e,t,n){"use strict";var r=n(186),a=n(84),i=n(60);e.exports=function(e){return'function'!=typeof e.constructor||i(e)?{}:r(a(e))}},function(e,t,n){"use strict";var r=n(26),a=Object.create,i=(function(){function e(){}return function(t){if(!r(t))return{};if(a)return a(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}})();e.exports=i},function(e,t,n){"use strict";var r=n(36),a=n(31);e.exports=function(e){return a(e)&&r(e)}},function(e,t,n){"use strict";var r=n(33),a=n(84),i=n(31),s='[object Object]',o=Function.prototype,c=Object.prototype,u=o.toString,l=c.hasOwnProperty,p=u.call(Object);e.exports=function(e){if(!i(e)||r(e)!=s)return!1;var t=a(e);if(null===t)return!0;var n=l.call(t,'constructor')&&t.constructor;return'function'==typeof n&&n instanceof n&&u.call(n)==p}},function(e,t,n){"use strict";var r=n(190),a=n(86);e.exports=function(e){return r(e,a(e))}},function(e,t,n){"use strict";var r=n(191),a=n(65);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var o=-1,c=t.length;++o<c;){var u=t[o],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?a(n,u,l):r(n,u,l)}return n}},function(e,t,n){"use strict";var r=n(65),a=n(35),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&a(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(26),a=n(60),i=n(193),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=a(e),n=[];for(var o in e)('constructor'!=o||!t&&s.call(e,o))&&n.push(o);return n}},function(e,t,n){"use strict";e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},function(e,t,n){"use strict";var r=n(64),a=n(195),i=n(197);e.exports=function(e,t){return i(a(e,t,r),e+'')}},function(e,t,n){"use strict";var r=n(196),a=Math.max;e.exports=function(e,t,n){return t=a(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=a(i.length-t,0),c=Array(o);++s<o;)c[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(c),r(e,this,u)}}},function(e,t,n){"use strict";e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){"use strict";var r=n(198),a=n(200)(r);e.exports=a},function(e,t,n){"use strict";var r=n(199),a=n(83),i=n(64),s=a?function(e,t){return a(e,'toString',{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},function(e,t,n){"use strict";e.exports=function(e){return function(){return e}}},function(e,t,n){"use strict";var r=800,a=16,i=Date.now;e.exports=function(e){var t=0,n=0;return function(){var s=i(),o=a-(s-n);if(n=s,o>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){"use strict";var r=n(35),a=n(36),i=n(43),s=n(26);e.exports=function(e,t,n){if(!s(n))return!1;var o=typeof t;return!!('number'==o?a(n)&&i(t,n.length):'string'==o&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";var r=n(203);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t,n){"use strict";var r=n(80),a=n(204),i=n(205);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,a,n)}},function(e,t,n){"use strict";e.exports=function(e){return e!=e}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=n-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=-1,a=null==e?0:e.length;++r<a;)if(n(t,e[r]))return!0;return!1}},function(e,t,n){"use strict";var r=n(77),a=n(208),i=n(53),s=r&&1/i(new r([,-0]))[1]==1/0?function(e){return new r(e)}:a;e.exports=s},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";(function(e,t){!(function(e,n){if(!e.setImmediate){var r,a,i,s,o,c=1,u={},l=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){v(e)})}:!(function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}})()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){v(e.data)},r=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(a=p.documentElement,r=function(e){var t=p.createElement("script");t.onreadystatechange=function(){v(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(v,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&v(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return u[c]=a,r(c),c++},d.clearImmediate=h}function h(e){delete u[e]}function f(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}function v(e){if(l)setTimeout(v,0,e);else{var t=u[e];if(t){l=!0;try{f(t)}finally{h(e),l=!1}}}}})("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(34),n(210))},function(e,t,n){"use strict";var r,a,i=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(a===clearTimeout)return clearTimeout(e);if((a===o||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{return a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}!(function(){try{r='function'==typeof setTimeout?setTimeout:s}catch(e){r=s}try{a='function'==typeof clearTimeout?clearTimeout:o}catch(e){a=o}})();var l,p=[],d=!1,h=-1;function f(){d&&l&&(d=!1,l.length?p=l.concat(p):h=-1,p.length&&v())}function v(){if(!d){var e=c(f);d=!0;for(var t=p.length;t;){for(l=p,p=[];++h<t;)l&&l[h].run();h=-1,t=p.length}l=null,d=!1,u(e)}}function y(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new y(e,t)),1!==p.length||d||c(v)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title='browser',i.browser=!0,i.env={},i.argv=[],i.version='',i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error('process.binding is not supported')},i.cwd=function(){return'/'},i.chdir=function(e){throw new Error('process.chdir is not supported')},i.umask=function(){return 0}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(212),t),a(n(213),t),a(n(218),t),a(n(219),t),a(n(220),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentType=void 0,(function(e){e.Any="*",e.Item="SF|Item",e.RootKey="SN|RootKey|NoSync",e.ItemsKey="SN|ItemsKey",e.EncryptedStorage="SN|EncryptedStorage",e.Privileges="SN|Privileges",e.Note="Note",e.Tag="Tag",e.SmartTag="SN|SmartTag",e.Component="SN|Component",e.Editor="SN|Editor",e.ActionsExtension="Extension",e.UserPrefs="SN|UserPreferences",e.HistorySession="SN|HistorySession",e.Theme="SN|Theme",e.ServerExtension="SF|Extension",e.FilesafeCredentials="SN|FileSafe|Credentials",e.FilesafeFileMetadata="SN|FileSafe|FileMetadata",e.FilesafeIntegration="SN|FileSafe|Integration",e.ExtensionRepo="SN|ExtensionRepo",e.Unknown="Unknown"})(t.ContentType||(t.ContentType={}))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.ContentDecoder=void 0;var n=(function(){function t(){v(this,t)}return y(t,[{key:"decode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;try{var r=n>0?t.substring(n):t,a=e.from(r,'base64').toString();return JSON.parse(a)}catch(e){return{}}}},{key:"encode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=JSON.stringify(t),a=e.from(r).toString('base64');return a.padStart(a.length+n,'0')}}]),t})();t.ContentDecoder=n}).call(this,n(214).Buffer)},function(e,t,n){"use strict";(function(e){var r=n(215),a=n(216),i=n(217);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return d(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?v(e,t,n,r):'string'==typeof t?h(e,t,n):y(e,t)}function l(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function p(e,t,n,r){return l(t),t<=0?o(e,t):void 0!==n?'string'==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function d(e,t){if(l(t),e=o(e,t<0?0:0|g(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t,n){if('string'==typeof n&&''!==n||(n='utf8'),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(t,n),a=(e=o(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}function f(e,t){var n=t.length<0?0:0|g(t.length);e=o(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function v(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(r||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t),e}function y(e,t){if(c.isBuffer(t)){var n=0|g(t.length);return 0===(e=o(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||(r=t.length)!=r?o(e,0):f(e,t);if('Buffer'===t.type&&i(t.data))return f(e,t.data)}var r;throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function g(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+' bytes');return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return G(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return $(e).length;default:if(r)return G(e).length;t=(''+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),n<=0)return'';if((n>>>=0)<=(t>>>=0))return'';for(e||(e='utf8');;)switch(e){case'hex':return T(this,t,n);case'utf8':case'utf-8':return R(this,t,n);case'ascii':return A(this,t,n);case'latin1':case'binary':return j(this,t,n);case'base64':return E(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return K(this,t,n);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,a){if(0===e.length)return-1;if('string'==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if('string'==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:x(e,t,n,r,a);if('number'==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):x(e,[t],n,r,a);throw new TypeError('val must be string, number or Buffer')}function x(e,t,n,r,a){var i,s=1,o=e.length,c=t.length;if(void 0!==r&&('ucs2'===(r=String(r).toLowerCase())||'ucs-2'===r||'utf16le'===r||'utf-16le'===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var l=-1;for(i=n;i<o;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>o&&(n=o-c),i=n;i>=0;i--){for(var p=!0,d=0;d<c;d++)if(u(e,i+d)!==u(t,d)){p=!1;break}if(p)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError('Invalid hex string');r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function P(e,t,n,r){return X(G(t,e.length-n),e,n,r)}function O(e,t,n,r){return X(Q(t),e,n,r)}function C(e,t,n,r){return O(e,t,n,r)}function D(e,t,n,r){return X($(t),e,n,r)}function _(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,c,u=e[a],l=null,p=u>239?4:u>223?3:u>191?2:1;if(a+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=p}return M(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:(function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}})(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return p(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('Arguments must be Buffers');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,a),a+=s.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var t=0;t<e;t+=2)w(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?'':0===arguments.length?R(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e='',n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString('hex',0,n).match(/.{2}/g).join(' '),this.length>n&&(e+=' ... ')),'<Buffer '+e+'>'},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError('out of range index');if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,s=n-t,o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),p=0;p<o;++p)if(u[p]!==l[p]){i=u[p],s=l[p];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r='utf8',n=this.length,t=0;else if(void 0===n&&'string'==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');t|=0,isFinite(n)?(n|=0,void 0===r&&(r='utf8')):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return S(this,e,t,n);case'utf8':case'utf-8':return P(this,e,t,n);case'ascii':return O(this,e,t,n);case'latin1':case'binary':return C(this,e,t,n);case'base64':return D(this,e,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return _(this,e,t,n);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var n='',r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function A(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function j(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function T(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a='',i=t;i<n;++i)a+=Y(e[i]);return a}function K(e,t,n){for(var r=e.slice(t,n),a='',i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function L(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError('Index out of range')}function U(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function V(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError('Index out of range');if(n<0)throw new RangeError('Index out of range')}function B(e,t,n,r,i){return i||V(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function W(e,t,n,r,i){return i||V(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var a=t-e;n=new c(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return W(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return W(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError('targetStart out of bounds');if(n<0||n>=this.length)throw new RangeError('sourceStart out of bounds');if(r<0)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if('string'==typeof e){if('string'==typeof t?(r=t,t=0,n=this.length):'string'==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!c.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError('Out of range index');if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),'number'==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:G(new c(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var H=/[^+\/0-9A-Za-z-_]/g;function z(e){if((e=q(e).replace(H,'')).length<2)return'';for(;e.length%4!=0;)e+='=';return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function Y(e){return e<16?'0'+e.toString(16):e.toString(16)}function G(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error('Invalid code point');if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function J(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}function $(e){return r.toByteArray(z(e))}function X(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(34))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],o=r[1],c=new i(l(e,s,o)),p=0,d=o>0?s-4:s;for(n=0;n<d;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=0,o=n-a;s<o;s+=16383)i.push(p(e,s,s+16383>o?o:s+16383));1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+'==')):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+'='));return i.join('')};for(var r=[],a=[],i='undefined'!=typeof Uint8Array?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',o=0,c=s.length;o<c;++o)r[o]=s[o],a[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){return 3*(t+n)/4-n}function p(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join('')}a['-'.charCodeAt(0)]=62,a['_'.charCodeAt(0)]=63},function(e,t,n){"use strict";t.read=function(e,t,n,r,a){var i,s,o=8*a-r-1,c=(1<<o)-1,u=c>>1,l=-7,p=n?a-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=o;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var s,o,c,u=8*i-a-1,l=(1<<u)-1,p=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(o=0,s=l):s+p>=1?(o=(t*c-1)*Math.pow(2,a),s+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+h]=255&o,h+=f,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*v}},function(e,t,n){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==r.call(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTag=void 0,(function(e){e.MfaInvalid="mfa-invalid",e.MfaRequired="mfa-required",e.RefreshTokenInvalid="invalid-refresh-token",e.RefreshTokenExpired="expired-refresh-token",e.AccessTokenExpired="expired-access-token",e.ParametersInvalid="invalid-parameters",e.RevokedSession="revoked-session",e.AuthInvalid="invalid-auth"})(t.ErrorTag||(t.ErrorTag={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(222),t),a(n(90),t),a(n(223),t),a(n(225),t),a(n(93),t),a(n(91),t),a(n(92),t),a(n(226),t),a(n(227),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Features=void 0;for(var a,i=n(19),s=n(91),o=n(92),c=n(93),u=n(90),l=[],p=function(e){var t=e.identifier,n=e.permission_name,r=e.content_type,a=e.area,l=e.flags,p=Object.values(c.PermissionName),d=Object.values(u.FeatureIdentifier),h=Object.values(i.ContentType),f=Object.values(s.ComponentArea),v=Object.values(o.ComponentFlag);if(!d.includes(t))throw Error("Invalid feature identifier ".concat(t));if(!p.includes(n))throw Error("Invalid permission name ".concat(n));if(r&&!h.includes(r))throw Error("Invalid feature content type ".concat(r));if(a&&!f.includes(a))throw Error("Invalid feature area ".concat(a));if(l&&l.some(function(e){return!v.includes(e)}))throw Error("Invalid feature flag ".concat(l))},d=S(r(n(224)).default);!(a=d()).done;){var h=a.value;p(h),l.push(h)}t.Features=l},function(e){e.exports=JSON.parse("[{\"name\":\"Midnight\",\"identifier\":\"org.standardnotes.theme-midnight\",\"permission_name\":\"theme:midnight\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Elegant utilitarianism.\",\"url\":\"#{url_prefix}/themes/midnight\",\"download_url\":\"https://github.com/standardnotes/midnight-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/midnight\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#086DD6\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#086DD6\"}},{\"name\":\"Futura\",\"identifier\":\"org.standardnotes.theme-futura\",\"permission_name\":\"theme:futura\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Calm and relaxed. Take some time off.\",\"url\":\"#{url_prefix}/themes/futura\",\"download_url\":\"https://github.com/standardnotes/futura-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/futura\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#fca429\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#fca429\"}},{\"name\":\"Solarized Dark\",\"identifier\":\"org.standardnotes.theme-solarized-dark\",\"permission_name\":\"theme:solarized-dark\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.3\",\"description\":\"The perfect theme for any time.\",\"url\":\"#{url_prefix}/themes/solarized-dark\",\"download_url\":\"https://github.com/standardnotes/solarized-dark-theme/archive/1.2.3.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/solarized-dark\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#2AA198\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#2AA198\"}},{\"name\":\"Autobiography\",\"identifier\":\"org.standardnotes.theme-autobiography\",\"permission_name\":\"theme:autobiography\",\"content_type\":\"SN|Theme\",\"version\":\"1.0.1\",\"description\":\"A theme for writers and readers.\",\"url\":\"#{url_prefix}/themes/autobiography\",\"download_url\":\"https://github.com/standardnotes/autobiography-theme/archive/1.0.1.zip\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg\",\"flags\":[\"New\"],\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#9D7441\",\"foreground_color\":\"#ECE4DB\",\"border_color\":\"#9D7441\"}},{\"name\":\"Focus\",\"identifier\":\"org.standardnotes.theme-focus\",\"permission_name\":\"theme:focused\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.5\",\"description\":\"For when you need to go in.\",\"url\":\"#{url_prefix}/themes/focus\",\"download_url\":\"https://github.com/standardnotes/focus-theme/archive/1.2.5.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/focused\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#a464c2\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#a464c2\"}},{\"identifier\":\"org.standardnotes.theme-titanium\",\"permission_name\":\"theme:titanium\",\"name\":\"Titanium\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Light on the eyes, heavy on the spirit.\",\"url\":\"#{url_prefix}/themes/titanium\",\"download_url\":\"https://github.com/standardnotes/titanium-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/titanium\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#6e2b9e\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#6e2b9e\"}},{\"identifier\":\"org.standardnotes.theme-dynamic\",\"name\":\"Dynamic\",\"permission_name\":\"theme:dynamic\",\"content_type\":\"SN|Theme\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.0.0\",\"description\":\"A smart theme that minimizes the tags and notes panels when they are not in use.\",\"url\":\"#{url_prefix}/themes/dynamic\",\"download_url\":\"https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/dynamic\"},{\"identifier\":\"org.standardnotes.theme-no-distraction\",\"name\":\"No Distraction\",\"content_type\":\"SN|Theme\",\"permission_name\":\"theme:no-distraction\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.2.2\",\"description\":\"A theme for focusing on your writing.\",\"url\":\"#{url_prefix}/themes/no-distraction\",\"download_url\":\"https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/no-distraction\",\"dock_icon\":{\"type\":\"svg\",\"source\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><path d=\\\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\\\"/></svg>\"}},{\"name\":\"Bold Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.bold-editor\",\"permission_name\":\"editor:bold\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.2.9\",\"description\":\"A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.\",\"url\":\"#{url_prefix}/components/bold-editor\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg\",\"download_url\":\"https://github.com/standardnotes/bold-editor/archive/1.2.9.zip\"},{\"name\":\"Plus Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.plus-editor\",\"permission_name\":\"editor:plus\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.5.0\",\"description\":\"From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.\",\"url\":\"#{url_prefix}/components/plus-editor\",\"download_url\":\"https://github.com/standardnotes/plus-editor/archive/1.5.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/plus-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg\"},{\"name\":\"Markdown Basic\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.simple-markdown-editor\",\"permission_name\":\"editor:markdown-basic\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A Markdown editor with dynamic split-pane preview.\",\"url\":\"#{url_prefix}/components/simple-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg\"},{\"name\":\"Markdown Pro\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.advanced-markdown-editor\",\"permission_name\":\"editor:markdown-pro\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.14\",\"description\":\"A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.\",\"url\":\"#{url_prefix}/components/advanced-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/advanced-markdown-editor/archive/1.3.14.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/advanced-markdown\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg\"},{\"name\":\"Markdown Minimist\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.minimal-markdown-editor\",\"permission_name\":\"editor:markdown-minimist\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F\",\"url\":\"#{url_prefix}/components/minimal-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/minimal-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg\"},{\"name\":\"Markdown Math\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.fancy-markdown-editor\",\"permission_name\":\"editor:markdown-math\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.4\",\"description\":\"A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.\",\"url\":\"#{url_prefix}/components/fancy-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/math-editor/archive/1.3.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/math-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg\"},{\"name\":\"Task Editor\",\"note_type\":\"task\",\"file_type\":\"md\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.simple-task-editor\",\"permission_name\":\"editor:task-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A great way to manage short-term and long-term to-do\\\"s. You can mark tasks as completed, change their order, and edit the text naturally in place.\",\"url\":\"#{url_prefix}/components/simple-task-editor\",\"download_url\":\"https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-task-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg\"},{\"name\":\"Code Editor\",\"note_type\":\"code\",\"file_type\":\"txt\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.code-editor\",\"permission_name\":\"editor:code-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.8\",\"description\":\"Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.\",\"url\":\"#{url_prefix}/components/code-editor\",\"download_url\":\"https://github.com/standardnotes/code-editor/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/code-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg\"},{\"name\":\"TokenVault\",\"note_type\":\"authentication\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.token-vault\",\"permission_name\":\"editor:token-vault\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"2.0.6\",\"description\":\"Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.\",\"url\":\"#{url_prefix}/components/token-vault\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/token-vault/archive/2.0.6.zip\",\"thumbnail_url\":\"https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png\",\"flags\":[\"New\"]},{\"name\":\"Secure Spreadsheets\",\"note_type\":\"spreadsheet\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.standard-sheets\",\"permission_name\":\"editor:sheets\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.\",\"url\":\"#{url_prefix}/components/standard-sheets\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/secure-spreadsheets/archive/1.4.0.zip\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png\"},{\"identifier\":\"org.standardnotes.file-safe\",\"name\":\"FileSafe\",\"permission_name\":\"component:filesafe\",\"content_type\":\"SN|Component\",\"area\":\"editor-stack\",\"version\":\"2.0.10\",\"description\":\"Encrypted attachments for your notes using your Dropbox, Google Drive, or WebDAV server. Limited to 50MB per file.\",\"url\":\"#{url_prefix}/components/filesafe\",\"download_url\":\"https://github.com/standardnotes/filesafe-client/archive/2.0.10.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/filesafe\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/FileSafe-banner.png\"},{\"identifier\":\"org.standardnotes.folders\",\"name\":\"Folders\",\"content_type\":\"SN|Component\",\"permission_name\":\"component:folders\",\"area\":\"tags-list\",\"version\":\"1.3.8\",\"description\":\"Create nested folders with easy drag and drop.\",\"url\":\"#{url_prefix}/components/folders\",\"download_url\":\"https://github.com/standardnotes/folders-component/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/folders\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/components/folders.jpg\"},{\"name\":\"2FA Manager\",\"identifier\":\"org.standardnotes.mfa-link\",\"permission_name\":\"component:2fa-manager\",\"content_type\":\"SN|Component\",\"description\":\"Configure two-factor authentication to add an extra level of security to your account.\",\"version\":\"1.2.4\",\"url\":\"#{url_prefix}/components/mfa-link\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/mfa-link/archive/1.2.4.zip\",\"area\":\"modal\",\"no_expire\":true,\"deletion_warning\":\"Deleting 2FA Manager will not disable 2FA from your account. To disable 2FA, first open 2FA Manager, then follow the prompts.\",\"deprecated\":true},{\"name\":\"\",\"identifier\":\"org.standardnotes.two-factor-auth\",\"permission_name\":\"server:two-factor-auth\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-unlimited\",\"permission_name\":\"server:note-history-unlimited\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-365\",\"permission_name\":\"server:note-history-365-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-30\",\"permission_name\":\"server:note-history-30-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-email-backup\",\"permission_name\":\"server:daily-email-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-dropbox-backup\",\"permission_name\":\"server:daily-dropbox-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-gdrive-backup\",\"permission_name\":\"server:daily-gdrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-onedrive-backup\",\"permission_name\":\"server:daily-onedrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-25-gb\",\"permission_name\":\"server:files-25-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-5-gb\",\"permission_name\":\"server:files-5-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Tag Nesting\",\"identifier\":\"org.standardnotes.tag-nesting\",\"permission_name\":\"app:tag-nesting\",\"description\":\"Create nested tags with easy drag and drop.\",\"version\":\"0.1.0\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files\",\"permission_name\":\"app:files\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"CloudLink\",\"identifier\":\"org.standardnotes.cloudlink\",\"permission_name\":\"component:cloud-link\",\"content_type\":\"SN|Component\",\"description\":\"Manage and install cloud backups, including Note History, Dropbox, Google Drive, OneDrive, and Daily Email Backups.\",\"version\":\"1.2.3\",\"url\":\"#{url_prefix}/components/cloudlink\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Listed Custom Domain\",\"identifier\":\"org.standardnotes.listed-custom-domain\",\"permission_name\":\"listed:custom-domain\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"Focus Mode\",\"identifier\":\"org.standardnotes.focus-mode\",\"permission_name\":\"app:focus-mode\"}]")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoteType=void 0,(function(e){e.Authentication="authentication",e.Code="code",e.Markdown="markdown",e.RichText="rich-text",e.Spreadsheet="spreadsheet",e.Task="task"})(t.NoteType||(t.NoteType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timingSafeEqual=void 0,t.timingSafeEqual=function(e,t){var n=String(e),r=String(t),a=n.length,i=0;a!==r.length&&(r=n,i=1);for(var s=0;s<a;s++)i|=n.charCodeAt(s)^r.charCodeAt(s);return 0===i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(232),t),a(n(233),t),a(n(234),t),a(n(235),t),a(n(236),t),a(n(237),t),a(n(238),t),a(n(239),t),a(n(240),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoleName=void 0,(function(e){e.BasicUser="BASIC_USER",e.CoreUser="CORE_USER",e.PlusUser="PLUS_USER",e.ProUser="PRO_USER"})(t.RoleName||(t.RoleName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionName=void 0,(function(e){e.CorePlan="CORE_PLAN",e.PlusPlan="PLUS_PLAN",e.ProPlan="PRO_PLAN"})(t.SubscriptionName||(t.SubscriptionName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(242),t),a(n(243),t),a(n(244),t),a(n(245),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmailBackupFrequency=void 0,(function(e){e.Daily="daily",e.Weekly="weekly"})(t.EmailBackupFrequency||(t.EmailBackupFrequency={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedBackupsEmailsOption||(t.MuteFailedBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedCloudBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedCloudBackupsEmailsOption||(t.MuteFailedCloudBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingName=void 0,(function(e){e.MfaSecret="MFA_SECRET",e.ExtensionKey="EXTENSION_KEY",e.EmailBackup="EMAIL_BACKUP",e.MuteFailedBackupsEmails="MUTE_FAILED_BACKUPS_EMAILS",e.MuteFailedCloudBackupsEmails="MUTE_FAILED_CLOUD_BACKUPS_EMAILS"})(t.SettingName||(t.SettingName={}))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"SnjsVersion",function(){return h}),n.d(t,"isRightVersionGreaterThanLeft",function(){return x}),n.d(t,"compareSemVersions",function(){return P}),n.d(t,"SNApplicationGroup",function(){return M}),n.d(t,"DeinitSource",function(){return C}),n.d(t,"KeyParamsOrigination",function(){return A.g}),n.d(t,"KeyRecoveryStrings",function(){return j.H}),n.d(t,"SessionStrings",function(){return j.R}),n.d(t,"SNApplication",function(){return ca}),n.d(t,"SNProtocolService",function(){return Gn}),n.d(t,"KeyMode",function(){return Bn}),n.d(t,"SNProtocolOperator001",function(){return An}),n.d(t,"SNProtocolOperator002",function(){return Fn}),n.d(t,"SNProtocolOperator003",function(){return Ln}),n.d(t,"SNProtocolOperator004",function(){return Wn}),n.d(t,"SNRootKey",function(){return Ve}),n.d(t,"SNRootKeyParams",function(){return A.h}),n.d(t,"DeviceInterface",function(){return ua}),n.d(t,"SNItem",function(){return T.d}),n.d(t,"ItemMutator",function(){return T.b}),n.d(t,"AppDataField",function(){return T.a}),n.d(t,"SNItemsKey",function(){return J}),n.d(t,"SNPredicate",function(){return H.a}),n.d(t,"SNNote",function(){return le}),n.d(t,"NoteMutator",function(){return pe}),n.d(t,"SNTag",function(){return oe}),n.d(t,"TagMutator",function(){return ce}),n.d(t,"SNSmartTag",function(){return et}),n.d(t,"SNActionsExtension",function(){return ie}),n.d(t,"ActionsExtensionMutator",function(){return se}),n.d(t,"Action",function(){return ae}),n.d(t,"SNTheme",function(){return B}),n.d(t,"ThemeMutator",function(){return W}),n.d(t,"SNComponent",function(){return N}),n.d(t,"ComponentAction",function(){return E}),n.d(t,"ComponentMutator",function(){return V}),n.d(t,"SNEditor",function(){return Ze}),n.d(t,"SNUserPrefs",function(){return z}),n.d(t,"UserPrefsMutator",function(){return G}),n.d(t,"PrefKey",function(){return U}),n.d(t,"MutationType",function(){return T.c}),n.d(t,"ComponentArea",function(){return L.ComponentArea}),n.d(t,"LiveItem",function(){return la}),n.d(t,"FeatureStatus",function(){return ur}),n.d(t,"SNComponentManager",function(){return an}),n.d(t,"HistoryEntry",function(){return Qn}),n.d(t,"PayloadManager",function(){return sn}),n.d(t,"ItemManager",function(){return _r}),n.d(t,"SNHttpService",function(){return jt}),n.d(t,"ChallengeService",function(){return na}),n.d(t,"PureService",function(){return R.a}),n.d(t,"ApplicationService",function(){return pa.a}),n.d(t,"SNStorageService",function(){return Ie}),n.d(t,"StoragePersistencePolicies",function(){return Oe}),n.d(t,"StorageEncryptionPolicies",function(){return Ce}),n.d(t,"StorageValueModes",function(){return De}),n.d(t,"ValueModesKeys",function(){return _e}),n.d(t,"Challenge",function(){return ye}),n.d(t,"ChallengeReason",function(){return ne}),n.d(t,"ChallengeResponse",function(){return be}),n.d(t,"ChallengeValidation",function(){return te}),n.d(t,"ChallengeValue",function(){return me}),n.d(t,"ChallengePrompt",function(){return ge}),n.d(t,"SNSyncService",function(){return ea}),n.d(t,"SyncSources",function(){return $r}),n.d(t,"SyncModes",function(){return Jr}),n.d(t,"SyncQueueStrategy",function(){return Qr}),n.d(t,"SNCredentialService",function(){return Qe}),n.d(t,"SyncResponse",function(){return Br}),n.d(t,"SyncResponseResolver",function(){return Vr}),n.d(t,"SyncOpStatus",function(){return fr}),n.d(t,"SortPayloadsByRecentAndContentPriority",function(){return Mr}),n.d(t,"SyncUpDownLimit",function(){return Wr}),n.d(t,"SNSessionManager",function(){return Ge}),n.d(t,"SessionEvent",function(){return ze}),n.d(t,"SNMigrationService",function(){return En}),n.d(t,"ButtonType",function(){return St}),n.d(t,"SNHistoryManager",function(){return nr}),n.d(t,"SNProtectionService",function(){return ir}),n.d(t,"SNSingletonManager",function(){return cn}),n.d(t,"SNApiService",function(){return Yt}),n.d(t,"addIfUnique",function(){return _.b}),n.d(t,"arrayByDifference",function(){return _.c}),n.d(t,"Copy",function(){return _.a}),n.d(t,"dateSorted",function(){return _.j}),n.d(t,"deepMerge",function(){return _.m}),n.d(t,"dictToArray",function(){return _.n}),n.d(t,"extendArray",function(){return _.o}),n.d(t,"filterFromArray",function(){return _.p}),n.d(t,"findInArray",function(){return _.q}),n.d(t,"getGlobalScope",function(){return _.r}),n.d(t,"greaterOfTwoDates",function(){return _.s}),n.d(t,"isNullOrUndefined",function(){return _.w}),n.d(t,"isSameDay",function(){return _.z}),n.d(t,"jsonParseEmbeddedKeys",function(){return _.E}),n.d(t,"naturalSort",function(){return _.G}),n.d(t,"omitInPlace",function(){return _.J}),n.d(t,"omitUndefinedCopy",function(){return _.K}),n.d(t,"removeFromArray",function(){return _.M}),n.d(t,"removeFromIndex",function(){return _.N}),n.d(t,"subtractFromArray",function(){return _.R}),n.d(t,"topLevelCompare",function(){return _.S}),n.d(t,"truncateHexString",function(){return _.T}),n.d(t,"uniqueArrayByKey",function(){return _.W}),n.d(t,"uniqCombineObjArrays",function(){return _.U}),n.d(t,"convertTimestampToMilliseconds",function(){return _.i}),n.d(t,"arraysEqual",function(){return _.e}),n.d(t,"isValidUrl",function(){return _.B}),n.d(t,"dateToLocalizedString",function(){return _.k}),n.d(t,"Uuid",function(){return I}),n.d(t,"EncryptionIntent",function(){return Re.b}),n.d(t,"isLocalStorageIntent",function(){return Re.f}),n.d(t,"isFileIntent",function(){return Re.e}),n.d(t,"isDecryptedIntent",function(){return Re.d}),n.d(t,"intentRequiresEncryption",function(){return Re.c}),n.d(t,"ContentTypeUsesRootKeyEncryption",function(){return Re.a}),n.d(t,"ContentType",function(){return F.a}),n.d(t,"displayStringForContentType",function(){return F.c}),n.d(t,"CreateItemFromPayload",function(){return nt}),n.d(t,"Uuids",function(){return Ke.b}),n.d(t,"FillItemContent",function(){return Ke.a}),n.d(t,"ApplicationEvent",function(){return At.a}),n.d(t,"Environment",function(){return he}),n.d(t,"Platform",function(){return fe}),n.d(t,"isEnvironmentWebOrDesktop",function(){return Se}),n.d(t,"isEnvironmentMobile",function(){return Pe}),n.d(t,"platformFromString",function(){return ke}),n.d(t,"environmentFromString",function(){return xe}),n.d(t,"SyncEvent",function(){return on.a}),n.d(t,"MutableCollection",function(){return mt}),n.d(t,"ImmutablePayloadCollection",function(){return bt}),n.d(t,"ItemCollection",function(){return gn}),n.d(t,"CollectionSort",function(){return dn}),n.d(t,"CreateMaxPayloadFromAnyObject",function(){return Ee.e}),n.d(t,"CreateSourcedPayloadFromObject",function(){return Ee.f}),n.d(t,"CreateIntentPayloadFromObject",function(){return Ee.d}),n.d(t,"CreateEncryptionParameters",function(){return Ee.c}),n.d(t,"PayloadByMerging",function(){return Ee.g}),n.d(t,"CopyPayload",function(){return Ee.b}),n.d(t,"PayloadSource",function(){return ht.a}),n.d(t,"isPayloadSourceRetrieved",function(){return ht.c}),n.d(t,"isPayloadSourceInternalChange",function(){return ht.b}),n.d(t,"DeltaOutOfSync",function(){return _t}),n.d(t,"ProtocolVersion",function(){return Q.a}),n.d(t,"PayloadFormat",function(){return ue.a}),n.d(t,"PurePayload",function(){return ft.a}),n.d(t,"PayloadField",function(){return Je.a}),n.d(t,"NotesDisplayCriteria",function(){return br}),n.d(t,"notesMatchingCriteria",function(){return wr}),n.d(t,"StorageKey",function(){return o}),n.d(t,"RawStorageKey",function(){return s}),n.d(t,"NonwrappedStorageKey",function(){return c}),n.d(t,"namespacedKey",function(){return O}),n.d(t,"BaseMigration",function(){return _n}),n.d(t,"ProtectionSessionDurations",function(){return ar}),n.d(t,"SNLog",function(){return we.a}),n.d(t,"Features",function(){return L.Features}),n.d(t,"FeatureIdentifier",function(){return L.FeatureIdentifier}),n.d(t,"RoleName",function(){return sr.RoleName}),n.d(t,"SettingName",function(){return pr.SettingName}),n.d(t,"Migration2_20_0",function(){return Pn}),n.d(t,"ApplicationStage",function(){return ve});var a={};n.r(a),n.d(a,"Migration2_0_0",function(){return kn}),n.d(a,"Migration2_0_15",function(){return xn}),n.d(a,"Migration2_7_0",function(){return Sn}),n.d(a,"Migration2_20_0",function(){return Pn});var i={};n.r(i),n.d(i,"StorageReader2_0_0",function(){return On}),n.d(i,"StorageReader1_0_0",function(){return vn});var s,o,c,h="2.20.3";function x(e,t){return-1===P(e,t)}function P(e,t){for(var n=e.split('.'),r=t.split('.'),a=0;a<r.length;a++){var i=Number(~~r[a]),s=Number(~~n[a]);if(i>s)return-1;if(i<s)return 1}return 0}function O(e,t){return e?"".concat(e,"-").concat(t):t}!(function(e){e.StorageObject="storage",e.DescriptorRecord="descriptors",e.SnjsVersion="snjs_version"})(s||(s={})),(function(e){e.RootKeyParams="ROOT_KEY_PARAMS",e.WrappedRootKey="WRAPPED_ROOT_KEY",e.RootKeyWrapperKeyParams="ROOT_KEY_WRAPPER_KEY_PARAMS",e.Session="session",e.User="user",e.ServerHost="server",e.LegacyUuid="uuid",e.LastSyncToken="syncToken",e.PaginationToken="cursorToken",e.BiometricsState="biometrics_state",e.MobilePasscodeTiming="passcode_timing",e.MobileBiometricsTiming="biometrics_timing",e.MobilePasscodeKeyboardType="passcodeKeyboardType",e.MobilePreferences="preferences",e.MobileScreenshotPrivacyEnabled="screenshotPrivacy_enabled",e.ProtectionExpirey="SessionExpiresAtKey",e.ProtectionSessionLength="SessionLengthKey",e.SessionHistoryPersistable="sessionHistory_persist",e.SessionHistoryRevisions="sessionHistory_revisions",e.SessionHistoryOptimize="sessionHistory_autoOptimize",e.KeyRecoveryUndecryptableItems="key_recovery_undecryptable",e.StorageEncryptionPolicy="storage_policy",e.WebSocketUrl="webSocket_url",e.UserRoles="user_roles",e.UserFeatures="user_features"})(o||(o={})),(function(e){e.MobileFirstRun="first_run"})(c||(c={}));var C,D={WebPasscodeParamsKey:'offlineParams',MobilePasscodeParamsKey:'pc_params',AllAccountKeyParamsKey:'auth_params',WebEncryptedStorageKey:'encryptedStorage',MobileWrappedRootKeyKey:'encrypted_account_keys',MobileBiometricsPrefs:'biometrics_prefs',AllMigrations:'migrations',MobileThemesCache:'ThemePreferencesKey',MobileLightTheme:'lightTheme',MobileDarkTheme:'darkTheme',MobileLastExportDate:'LastExportDateKey',MobileDoNotWarnUnsupportedEditors:'DoNotShowAgainUnsupportedEditorsKey',MobileOptionsState:'options',MobilePasscodeKeyboardType:'passcodeKeyboardType'},_=n(0);!(function(e){e[e.SignOut=1]="SignOut",e[e.Lock=2]="Lock",e[e.AppGroupUnload=3]="AppGroupUnload"})(C||(C={}));var E,R=n(10),I=(function(){function e(){v(this,e)}return y(e,null,[{key:"SetGenerators",value:function(e,t){this.syncUuidFunc=t,this.asyncUuidFunc=e}},{key:"canGenSync",value:function(){return!Object(_.w)(this.syncUuidFunc)}},{key:"GenerateUuid",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.syncUuidFunc){e.next=4;break}return e.abrupt("return",this.syncUuidFunc());case 4:return e.abrupt("return",this.asyncUuidFunc());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"GenerateUuidSynchronously",value:function(){return this.syncUuidFunc()}}]),e})(),M=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).deviceInterface=e,r.changeObservers=[],r.applications=[],r.onApplicationDeinit=function(e,t){var n=t!==C.AppGroupUnload;if(r.primaryApplication===e&&(r.primaryApplication=void 0),Object(_.M)(r.applications,e),t===C.SignOut){if(r.removeDescriptor(r.descriptorForApplication(e)),n){var a=r.getDescriptors();return 0===a.length?r.addNewApplication():r.loadApplicationForDescriptor(a[0])}}else if(t===C.Lock&&n){var i=r.descriptorForApplication(e);return r.loadApplicationForDescriptor(i)}},r}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.deviceInterface.deinit(),this.deviceInterface=void 0}},{key:"initialize",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.callback=e,r.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(s.DescriptorRecord));case 3:if(this.descriptorRecord=r.sent,this.descriptorRecord){r.next=7;break}return r.next=7,b.awrap(this.createDescriptorRecord());case 7:if(t=this.findPrimaryDescriptor()){r.next=10;break}throw Error('No primary application descriptor found. Ensure migrations have been run.');case 10:n=this.buildApplication(t),this.applications.push(n),this.setPrimaryApplication(n,!1);case 13:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createDescriptorRecord",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:t=g({},e='standardnotes',{identifier:e,label:'Main Application',primary:!0}),this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(t)),this.descriptorRecord=t,this.persistDescriptors();case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getApplications",value:function(){return this.applications}},{key:"getDescriptors",value:function(){return Object.values(this.descriptorRecord)}},{key:"findPrimaryDescriptor",value:function(){for(var e,t=S(this.getDescriptors());!(e=t()).done;){var n=e.value;if(n.primary)return n}}},{key:"addApplicationChangeObserver",value:function(e){var t=this;return this.changeObservers.push(e),this.primaryApplication&&e(),function(){Object(_.M)(t.changeObservers,e)}}},{key:"notifyObserversOfAppChange",value:function(){for(var e,t=S(this.changeObservers);!(e=t()).done;){(0,e.value)()}}},{key:"setPrimaryApplication",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=!(r.length>1&&void 0!==r[1])||r[1],this.primaryApplication!==e){a.next=3;break}return a.abrupt("return");case 3:if(this.applications.includes(e)){a.next=5;break}throw Error('Application must be inserted before attempting to switch to it');case 5:if(this.primaryApplication&&this.primaryApplication.deinit(C.AppGroupUnload),this.primaryApplication=e,n=this.descriptorForApplication(e),this.setDescriptorAsPrimary(n),this.notifyObserversOfAppChange(),!t){a.next=13;break}return a.next=13,b.awrap(this.persistDescriptors());case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setDescriptorAsPrimary",value:function(e){for(var t,n=S(this.getDescriptors());!(t=n()).done;){var r=t.value;r.primary=r===e}}},{key:"persistDescriptors",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(this.descriptorRecord));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"renameDescriptor",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e.label=t,n.next=3,b.awrap(this.persistDescriptors());case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"removeDescriptor",value:function(e){return delete this.descriptorRecord[e.identifier],this.persistDescriptors()}},{key:"descriptorForApplication",value:function(e){return this.descriptorRecord[e.identifier]}},{key:"addNewApplication",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(I.GenerateUuid());case 2:return t=i.sent,n=this.getDescriptors().length+1,r={identifier:t,label:e||"Application ".concat(n),primary:!1},a=this.buildApplication(r),this.applications.push(a),this.descriptorRecord[t]=r,i.next=10,b.awrap(this.setPrimaryApplication(a));case 10:return i.next=12,b.awrap(this.persistDescriptors());case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"applicationForDescriptor",value:function(e){return this.applications.find(function(t){return t.identifier===e.identifier})}},{key:"loadApplicationForDescriptor",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=this.applicationForDescriptor(e))||(t=this.buildApplication(e),this.applications.push(t)),n.next=4,b.awrap(this.setPrimaryApplication(t));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"buildApplication",value:function(e){var t=this.callback.applicationCreator(e,this.deviceInterface);return t.setOnDeinit(this.onApplicationDeinit),t}}]),n})(R.a),A=n(13),j=n(2),T=n(7),K=n(18),F=n(3),L=n(20);!(function(e){e.SetSize="set-size",e.StreamItems="stream-items",e.StreamContextItem="stream-context-item",e.SaveItems="save-items",e.SelectItem="select-item",e.AssociateItem="associate-item",e.DeassociateItem="deassociate-item",e.ClearSelection="clear-selection",e.CreateItem="create-item",e.CreateItems="create-items",e.DeleteItems="delete-items",e.SetComponentData="set-component-data",e.InstallLocalComponent="install-local-component",e.ToggleActivateComponent="toggle-activate-component",e.RequestPermissions="request-permissions",e.PresentConflictResolution="present-conflict-resolution",e.DuplicateItem="duplicate-item",e.ComponentRegistered="component-registered",e.ActivateThemes="themes",e.Reply="reply",e.SaveSuccess="save-success",e.SaveError="save-error",e.ThemesActivated="themes-activated",e.KeyDown="key-down",e.KeyUp="key-up",e.Click="click"})(E||(E={}));var U,N=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).permissions=[],r.componentData=r.payload.safeContent.componentData||{},Object(_.B)(r.payload.safeContent.hosted_url)?r.hosted_url=r.payload.safeContent.hosted_url:Object(_.B)(r.payload.safeContent.url)?r.hosted_url=r.payload.safeContent.url:Object(_.B)(r.payload.safeContent.legacy_url)&&(r.hosted_url=r.payload.safeContent.legacy_url),r.local_url=r.payload.safeContent.local_url,r.valid_until=new Date(r.payload.safeContent.valid_until||0),r.offlineOnly=r.payload.safeContent.offlineOnly,r.name=r.payload.safeContent.name,r.area=r.payload.safeContent.area,r.package_info=r.payload.safeContent.package_info||{},r.permissions=r.payload.safeContent.permissions||[],r.active=r.payload.safeContent.active,r.autoupdateDisabled=r.payload.safeContent.autoupdateDisabled,r.disassociatedItemIds=r.payload.safeContent.disassociatedItemIds||[],r.associatedItemIds=r.payload.safeContent.associatedItemIds||[],r.isMobileDefault=r.payload.safeContent.isMobileDefault,r.legacy_url=r.payload.safeContent.hosted_url?void 0:r.payload.safeContent.url,r}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"isEditor",value:function(){return this.area===L.ComponentArea.Editor}},{key:"isTheme",value:function(){return this.content_type===F.a.Theme||this.area===L.ComponentArea.Themes}},{key:"isDefaultEditor",value:function(){return!0===this.getAppDomainValue(T.a.DefaultEditor)}},{key:"getLastSize",value:function(){return this.getAppDomainValue(T.a.LastSize)}},{key:"acceptsThemes",value:function(){var e;return null===(e=this.payload.safeContent.package_info)||void 0===e?void 0:e.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return void 0!=(this.hosted_url||this.legacy_url)}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['active','disassociatedItemIds','associatedItemIds'].concat(p(f(n.prototype),"contentKeysToIgnoreWhenCheckingEquality",this).call(this))}},{key:"isAssociative",value:function(){return n.associativeAreas().includes(this.area)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e)}},{key:"isExpired",get:function(){return this.valid_until.getTime()>0&&this.valid_until<=new Date}},{key:"identifier",get:function(){return this.package_info.identifier}},{key:"isDeprecated",get:function(){var e,t=null!==(e=this.package_info.flags)&&void 0!==e?e:[];return(t=t.map(function(e){return e.toLowerCase()})).includes(L.ComponentFlag.Deprecated)}}],[{key:"associativeAreas",value:function(){return[L.ComponentArea.Editor]}}]),n})(T.d),V=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"associateWithItem",value:function(e){var t=this.typedContent.associatedItemIds||[];Object(_.b)(t,e),this.typedContent.associatedItemIds=t}},{key:"disassociateWithItem",value:function(e){var t=this.typedContent.disassociatedItemIds||[];Object(_.b)(t,e),this.typedContent.disassociatedItemIds=t}},{key:"removeAssociatedItemId",value:function(e){Object(_.M)(this.typedContent.associatedItemIds||[],e)}},{key:"removeDisassociatedItemId",value:function(e){Object(_.M)(this.typedContent.disassociatedItemIds||[],e)}},{key:"setLastSize",value:function(e){this.setAppDataItem(T.a.LastSize,e)}},{key:"typedContent",get:function(){return this.content}},{key:"active",set:function(e){this.typedContent.active=e}},{key:"isMobileDefault",set:function(e){this.typedContent.isMobileDefault=e}},{key:"defaultEditor",set:function(e){this.setAppDataItem(T.a.DefaultEditor,e)}},{key:"componentData",set:function(e){this.typedContent.componentData=e}},{key:"package_info",set:function(e){this.typedContent.package_info=e}},{key:"local_url",set:function(e){this.typedContent.local_url=e}},{key:"hosted_url",set:function(e){this.typedContent.hosted_url=e}},{key:"valid_until",set:function(e){this.typedContent.valid_until=e}},{key:"permissions",set:function(e){this.typedContent.permissions=e}}]),n})(T.b),B=(function(e){d(n,N);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).area=L.ComponentArea.Themes,e}return y(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"getMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDomainValue(T.a.NotAvailableOnMobile)}},{key:"isMobileActive",value:function(){return this.getAppDomainValue(T.a.MobileActive)}}]),n})(),W=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setMobileRules",value:function(e){this.setAppDataItem(T.a.MobileRules,e)}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem(T.a.NotAvailableOnMobile,e)}},{key:"setMobileActive",value:function(e){this.setAppDataItem(T.a.MobileActive,e)}},{key:"local_url",set:function(e){this.content.local_url=e}}]),n})(T.b),H=n(21);!(function(e){e.TagsPanelWidth="tagsPanelWidth",e.NotesPanelWidth="notesPanelWidth",e.EditorWidth="editorWidth",e.EditorLeft="editorLeft",e.EditorMonospaceEnabled="monospaceFont",e.EditorSpellcheck="spellcheck",e.EditorResizersEnabled="marginResizersEnabled",e.SortNotesBy="sortBy",e.SortNotesReverse="sortReverse",e.NotesShowArchived="showArchived",e.NotesShowTrashed="showTrashed",e.NotesHideProtected="hideProtected",e.NotesHidePinned="hidePinned",e.NotesHideNotePreview="hideNotePreview",e.NotesHideDate="hideDate",e.NotesHideTags="hideTags"})(U||(U={}));var z=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getPref",value:function(e){return this.getAppDomainValue(e)}},{key:"isSingleton",get:function(){return!0}},{key:"singletonPredicate",get:function(){return n.singletonPredicate}}]),n})(T.d);z.singletonPredicate=new H.a('content_type','=',F.a.UserPrefs);var q,Y,G=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setPref",value:function(e,t){this.setAppDataItem(e,t)}}]),n})(T.b),Q=n(6),J=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"keyVersion",get:function(){return this.payload.safeContent.version}},{key:"isItemsKey",get:function(){return!0}},{key:"isDefault",get:function(){return this.payload.safeContent.isDefault}},{key:"itemsKey",get:function(){return this.payload.safeContent.itemsKey}},{key:"dataAuthenticationKey",get:function(){if(this.keyVersion===Q.a.V004)throw'Attempting to access legacy data authentication key.';return this.payload.safeContent.dataAuthenticationKey}}]),n})(T.d),$=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"isDefault",set:function(e){this.content.isDefault=e}}]),n})(T.b),X=n(47),Z=n.n(X);!(function(e){e.Encrypted="encrypted",e.Decrypted="decrypted"})(q||(q={})),(function(e){e.Get="get",e.Render="render",e.Show="show",e.Post="post",e.Nested="nested"})(Y||(Y={}));var ee=Number.MIN_SAFE_INTEGER;var te,ne,re,ae=function e(t){var n,r,a;v(this,e),this.id=((ee+=1)===Number.MAX_SAFE_INTEGER&&(ee=Number.MIN_SAFE_INTEGER),ee),Z()(this,t),this.running=null!==(n=t.running)&&void 0!==n&&n,this.error=null!==(r=t.error)&&void 0!==r&&r,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted)),this.subactions=null===(a=t.subactions)||void 0===a?void 0:a.map(function(t){return new e(t)})},ie=(function(e){d(n,N);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).actions=[],r.description=e.safeContent.description,r.url=e.safeContent.hosted_url||e.safeContent.url,r.supported_types=e.safeContent.supported_types,r.deprecation=e.safeContent.deprecation,e.safeContent.actions&&(r.actions=e.safeContent.actions.map(function(e){return new ae(e)})),r}return y(n,[{key:"actionsWithContextForItem",value:function(e){return this.actions.filter(function(t){return t.context===e.content_type||'Item'===t.context})}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}}]),n})(),se=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"description",set:function(e){this.content.description=e}},{key:"supported_types",set:function(e){this.content.supported_types=e}},{key:"actions",set:function(e){this.content.actions=e}},{key:"deprecation",set:function(e){this.content.deprecation=e}}]),n})(T.b),oe=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).title=r.payload.safeContent.title,r}return y(n,[{key:"noteReferences",get:function(){return this.payload.safeReferences.filter(function(e){return e.content_type===F.a.Note})}},{key:"noteCount",get:function(){return this.noteReferences.length}},{key:"isSmartTag",get:function(){return this.content_type===F.a.SmartTag}},{key:"isSystemSmartTag",get:function(){return this.payload.safeContent.isSystemTag}},{key:"isAllTag",get:function(){return this.payload.safeContent.isAllTag}},{key:"isTrashTag",get:function(){return this.payload.safeContent.isTrashTag}},{key:"isArchiveTag",get:function(){return this.payload.safeContent.isArchiveTag}},{key:"parentId",get:function(){var e=this.payload.safeContent.references.find(function(e){return e.content_type===F.a.Tag});return null===e||void 0===e?void 0:e.uuid}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title?1:-1}).map(function(e){return'#'+e.title}).join(' ')}}]),n})(T.d),ce=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"makeChildOf",value:function(e){var t=this.typedContent.references.filter(function(e){return e.content_type!==F.a.Tag});t.push({content_type:F.a.Tag,uuid:e.uuid}),this.typedContent.references=t}},{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}}]),n})(T.b),ue=n(12),le=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).text='',r.hidePreview=!1,r.title=r.payload.safeContent.title,r.text=r.payload.safeContent.text,r.preview_plain=r.payload.safeContent.preview_plain,r.preview_html=r.payload.safeContent.preview_html,r.hidePreview=r.payload.safeContent.hidePreview,e.format===ue.a.DecryptedBareObject&&(r.prefersPlainEditor=r.getAppDomainValue(T.a.PrefersPlainEditor)),Object(_.w)(r.payload.safeContent.mobilePrefersPlainEditor)||(r.mobilePrefersPlainEditor=r.payload.safeContent.mobilePrefersPlainEditor),r}return y(n,[{key:"safeText",value:function(){return this.text||''}},{key:"safeTitle",value:function(){return this.title||''}}]),n})(T.d),pe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}},{key:"text",set:function(e){this.typedContent.text=e}},{key:"hidePreview",set:function(e){this.typedContent.hidePreview=e}},{key:"preview_plain",set:function(e){this.typedContent.preview_plain=e}},{key:"preview_html",set:function(e){this.typedContent.preview_html=e}},{key:"prefersPlainEditor",set:function(e){this.setAppDataItem(T.a.PrefersPlainEditor,e)}}]),n})(T.b);function de(e,t){switch(e.content_type){case F.a.Note:return new pe(e,t);case F.a.Tag:return new ce(e,t);case F.a.Component:return new V(e,t);case F.a.ActionsExtension:return new se(e,t);case F.a.ItemsKey:return new $(e,t);case F.a.UserPrefs:return new G(e,t);case F.a.Theme:return new W(e,t);default:return new T.b(e,t)}}!(function(e){e[e.None=0]="None",e[e.LocalPasscode=1]="LocalPasscode",e[e.AccountPassword=2]="AccountPassword",e[e.Biometric=3]="Biometric",e[e.ProtectionSessionDuration=4]="ProtectionSessionDuration"})(te||(te={})),(function(e){e[e.ApplicationUnlock=1]="ApplicationUnlock",e[e.ResaveRootKey=2]="ResaveRootKey",e[e.ProtocolUpgrade=3]="ProtocolUpgrade",e[e.Migration=4]="Migration",e[e.Custom=5]="Custom",e[e.AccessProtectedNote=6]="AccessProtectedNote",e[e.ImportFile=7]="ImportFile",e[e.AddPasscode=8]="AddPasscode",e[e.RemovePasscode=9]="RemovePasscode",e[e.ChangePasscode=10]="ChangePasscode",e[e.ChangeAutolockInterval=11]="ChangeAutolockInterval",e[e.CreateDecryptedBackupWithProtectedItems=12]="CreateDecryptedBackupWithProtectedItems",e[e.RevokeSession=13]="RevokeSession",e[e.AccessCloudLink=14]="AccessCloudLink",e[e.DecryptEncryptedFile=15]="DecryptEncryptedFile",e[e.ExportBackup=16]="ExportBackup",e[e.DisableBiometrics=17]="DisableBiometrics",e[e.UnprotectNote=18]="UnprotectNote",e[e.SearchProtectedNotesText=19]="SearchProtectedNotesText",e[e.SelectProtectedNote=20]="SelectProtectedNote",e[e.DisableMfa=21]="DisableMfa"})(ne||(ne={})),(function(e){e.Alphanumeric="default",e.Numeric="numeric"})(re||(re={}));var he,fe,ve,ye=(function(){function e(t,n,r,a,i){v(this,e),this.prompts=t,this.reason=n,this.cancelable=r,this._heading=a,this._subheading=i,this.id=Math.random(),Object.freeze(this)}return y(e,[{key:"hasPromptForValidationType",value:function(e){for(var t,n=S(this.prompts);!(t=n()).done;){if(t.value.validation===e)return!0}return!1}},{key:"modalTitle",get:function(){switch(this.reason){case ne.Migration:return j.w.Migration;default:return j.w.Generic}}},{key:"heading",get:function(){if(this._heading)return this._heading;switch(this.reason){case ne.ApplicationUnlock:return j.x.UnlockApplication;case ne.Migration:return j.x.EnterLocalPasscode;case ne.ResaveRootKey:return j.x.EnterPasscodeForRootResave;case ne.ProtocolUpgrade:return j.x.EnterCredentialsForProtocolUpgrade;case ne.AccessProtectedNote:return j.x.NoteAccess;case ne.ImportFile:return j.x.ImportFile;case ne.AddPasscode:return j.x.AddPasscode;case ne.RemovePasscode:return j.x.RemovePasscode;case ne.ChangePasscode:return j.x.ChangePasscode;case ne.ChangeAutolockInterval:return j.x.ChangeAutolockInterval;case ne.CreateDecryptedBackupWithProtectedItems:return j.x.EnterCredentialsForDecryptedBackupDownload;case ne.RevokeSession:return j.x.RevokeSession;case ne.AccessCloudLink:return j.x.AccessCloudLink;case ne.DecryptEncryptedFile:return j.x.DecryptEncryptedFile;case ne.ExportBackup:return j.x.ExportBackup;case ne.DisableBiometrics:return j.x.DisableBiometrics;case ne.UnprotectNote:return j.x.UnprotectNote;case ne.SearchProtectedNotesText:return j.x.SearchProtectedNotesText;case ne.SelectProtectedNote:return j.x.SelectProtectedNote;case ne.DisableMfa:return j.x.DisableMfa;case ne.Custom:return'';default:return Object(_.f)(this.reason)}}},{key:"subheading",get:function(){if(this._subheading)return this._subheading;switch(this.reason){case ne.Migration:return j.x.EnterPasscodeForMigration;default:return}}}]),e})(),ge=function e(t,n,r){v(this,e);var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;switch(this.validation=t,this.secureTextEntry=a,this.keyboardType=i,this.initialValue=s,this.id=Math.random(),this.validation){case te.AccountPassword:this.title=null!==n&&void 0!==n?n:j.M.AccountPassword,this.placeholder=null!==r&&void 0!==r?r:j.M.AccountPassword,this.validates=!0;break;case te.LocalPasscode:this.title=null!==n&&void 0!==n?n:j.M.LocalPasscode,this.placeholder=null!==r&&void 0!==r?r:j.M.LocalPasscode,this.validates=!0;break;case te.Biometric:this.title=null!==n&&void 0!==n?n:j.M.Biometrics,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.ProtectionSessionDuration:this.title=null!==n&&void 0!==n?n:j.M.RememberFor,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.None:this.title=null!==n&&void 0!==n?n:'',this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!1;break;default:Object(_.f)(this.validation)}Object.freeze(this)},me=function e(t,n){v(this,e),this.prompt=t,this.value=n,Object.freeze(this)},be=(function(){function e(t,n,r){v(this,e),this.challenge=t,this.values=n,this.artifacts=r,Object.freeze(this)}return y(e,[{key:"getValueForType",value:function(e){var t=this.values.find(function(t){return t.prompt.validation===e});if(Object(_.w)(t))throw Error('Could not find value for validation type '+e);return t}},{key:"getDefaultValue",value:function(){if(this.values.length>1)throw Error('Attempting to retrieve default response value when more than one value exists');return this.values[0]}}]),e})(),we=n(16);function ke(e){return{'mac-web':fe.MacWeb,'mac-desktop':fe.MacDesktop,'linux-web':fe.LinuxWeb,'linux-desktop':fe.LinuxDesktop,'windows-web':fe.WindowsWeb,'windows-desktop':fe.WindowsDesktop,ios:fe.Ios,android:fe.Android}[e]}function xe(e){return{web:he.Web,desktop:he.Desktop,mobile:he.Mobile}[e]}function Se(e){return e===he.Web||e===he.Desktop}function Pe(e){return e===he.Mobile}!(function(e){e[e.Web=1]="Web",e[e.Desktop=2]="Desktop",e[e.Mobile=3]="Mobile"})(he||(he={})),(function(e){e[e.Ios=1]="Ios",e[e.Android=2]="Android",e[e.MacWeb=3]="MacWeb",e[e.MacDesktop=4]="MacDesktop",e[e.WindowsWeb=5]="WindowsWeb",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.LinuxWeb=7]="LinuxWeb",e[e.LinuxDesktop=8]="LinuxDesktop"})(fe||(fe={})),(function(e){e[e.PreparingForLaunch_0=0]="PreparingForLaunch_0",e[e.ReadyForLaunch_05=.5]="ReadyForLaunch_05",e[e.StorageDecrypted_09=.9]="StorageDecrypted_09",e[e.Launched_10=1]="Launched_10",e[e.LoadingDatabase_11=1.1]="LoadingDatabase_11",e[e.LoadedDatabase_12=1.2]="LoadedDatabase_12",e[e.FullSyncCompleted_13=1.3]="FullSyncCompleted_13",e[e.SignedIn_30=3]="SignedIn_30"})(ve||(ve={}));var Oe,Ce,De,_e,Ee=n(1),Re=n(8);!(function(e){e[e.Default=1]="Default",e[e.Ephemeral=2]="Ephemeral"})(Oe||(Oe={})),(function(e){e[e.Default=1]="Default",e[e.Disabled=2]="Disabled"})(Ce||(Ce={})),(function(e){e[e.Default=1]="Default",e[e.Nonwrapped=2]="Nonwrapped"})(De||(De={})),(function(e){e.Wrapped="wrapped",e.Unwrapped="unwrapped",e.Nonwrapped="nonwrapped"})(_e||(_e={}));var Ie=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).alertService=r,s.identifier=a,s.environment=i,s.storagePersistable=!1,s.needsPersist=!1,s.deviceInterface=e,s.setPersistencePolicy(Oe.Default),s.setEncryptionPolicy(Ce.Default,!1),s}return y(n,[{key:"deinit",value:function(){this.deviceInterface=void 0,this.encryptionDelegate=void 0,this.storagePersistable=!1,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:if(e!==ve.Launched_10){r.next=7;break}this.storagePersistable=!0,this.needsPersist&&this.persistValuesToDisk(),r.next=12;break;case 7:if(e!==ve.StorageDecrypted_09){r.next=12;break}return r.next=10,b.awrap(this.getValue(o.StorageEncryptionPolicy));case 10:(t=r.sent)&&this.setEncryptionPolicy(t,!1);case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setPersistencePolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.persistencePolicy=e,this.persistencePolicy!==Oe.Ephemeral){t.next=6;break}return t.next=4,b.awrap(this.deviceInterface.removeAllRawStorageValues());case 4:return t.next=6,b.awrap(this.clearAllPayloads());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setEncryptionPolicy",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],e!==Ce.Disabled||this.environment===he.Mobile){r.next=3;break}throw Error('Disabling storage encryption is only available on mobile.');case 3:if(this.encryptionPolicy=e,!t){r.next=7;break}return r.next=7,b.awrap(this.setValue(o.StorageEncryptionPolicy,e));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.persistencePolicy===Oe.Ephemeral}},{key:"initializeFromDisk",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getRawStorageValue(this.getPersistenceKey()));case 2:e=n.sent,t=e?JSON.parse(e):void 0,this.setInitialValues(t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){e||(e=this.defaultValuesObject()),e[_e.Unwrapped]||(e[_e.Unwrapped]={}),this.values=e}},{key:"isStorageWrapped",value:function(){var e=this.values[_e.Wrapped];return!Object(_.w)(e)&&Object.keys(e).length>0}},{key:"canDecryptWithKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.values[_e.Wrapped],r.next=3,b.awrap(this.decryptWrappedValue(t,e));case 3:return n=r.sent,r.abrupt("return",!n.errorDecrypting);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"decryptWrappedValue",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!==e&&void 0!==e&&e.content_type){a.next=2;break}throw Error('Attempting to decrypt nonexistent wrapped value');case 2:return n=Object(Ee.e)(e,{content_type:F.a.EncryptedStorage}),a.next=5,b.awrap(this.encryptionDelegate.payloadByDecryptingPayload(n,t));case 5:return r=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptStorage",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.values[_e.Wrapped],n.next=3,b.awrap(this.decryptWrappedValue(e));case 3:if(!(t=n.sent).errorDecrypting){n.next=6;break}throw we.a.error(Error('Unable to decrypt storage.'));case 6:this.values[_e.Unwrapped]=Object(_.a)(t.contentObject);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistValuesToDisk",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.storagePersistable){t.next=3;break}return this.needsPersist=!0,t.abrupt("return");case 3:if(this.persistencePolicy!==Oe.Ephemeral){t.next=5;break}return t.abrupt("return");case 5:return this.needsPersist=!1,t.next=8,b.awrap(this.immediatelyPersistValuesToDisk());case 8:e=t.sent,this.values[_e.Wrapped]=e[_e.Wrapped];case 10:case"end":return t.stop()}},null,this,null,Promise)}},{key:"immediatelyPersistValuesToDisk",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(e.generatePersistableValues());case 2:return n=r.sent,r.next=5,b.awrap(null===(t=e.deviceInterface)||void 0===t?void 0:t.setRawStorageValue(e.getPersistenceKey(),JSON.stringify(n)));case 5:return r.abrupt("return",n);case 6:case"end":return r.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generatePersistableValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=w({},this.values),n=t[_e.Unwrapped],i.t0=Object(Ee.e),i.next=5,b.awrap(I.GenerateUuid());case 5:return i.t1=i.sent,i.t2=n,i.t3=F.a.EncryptedStorage,i.t4={uuid:i.t1,content:i.t2,content_type:i.t3},r=(0,i.t0)(i.t4),i.next=12,b.awrap(null===(e=this.encryptionDelegate)||void 0===e?void 0:e.payloadByEncryptingPayload(r,Re.b.LocalStoragePreferEncrypted));case 12:return(a=i.sent)&&(t[_e.Wrapped]=a.ejected(),t[_e.Unwrapped]=void 0),i.abrupt("return",t);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=r.length>2&&void 0!==r[2]?r[2]:De.Default,this.values){a.next=3;break}throw Error("Attempting to set storage key ".concat(e," before loading local storage."));case 3:return this.values[this.domainKeyForMode(n)][e]=t,a.abrupt("return",this.persistValuesToDisk());case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De.Default,n=arguments.length>2?arguments[2]:void 0;if(!this.values)throw Error("Attempting to get storage key ".concat(e," before loading local storage."));if(!this.values[this.domainKeyForMode(t)])throw Error("Storage domain mode not available ".concat(t," for key ").concat(e));var r=this.values[this.domainKeyForMode(t)][e];return Object(_.w)(r)?n:r}},{key:"removeValue",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:De.Default,this.values){a.next=3;break}throw Error("Attempting to remove storage key ".concat(e," before loading local storage."));case 3:if(null===(n=this.values[this.domainKeyForMode(t)])||void 0===n||!n[e]){a.next=7;break}return delete n[e],a.abrupt("return",this.persistValuesToDisk());case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.encryptionPolicy}},{key:"getPersistenceKey",value:function(){return O(this.identifier,s.StorageObject)}},{key:"defaultValuesObject",value:function(e,t,r){return n.defaultValuesObject(e,t,r)}},{key:"domainKeyForMode",value:function(e){if(e===De.Default)return _e.Unwrapped;if(e===De.Nonwrapped)return _e.Nonwrapped;throw Error('Invalid mode')}},{key:"clearValues",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,b.awrap(this.immediatelyPersistValuesToDisk());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAllRawPayloads",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads(this.identifier));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"savePayload",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.savePayloads([e]));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"savePayloads",value:function(e){var t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.persistencePolicy!==Oe.Ephemeral){o.next=2;break}return o.abrupt("return");case 2:t=[],n=S(e);case 4:if((r=n()).done){o.next=19;break}if(!(a=r.value).discardable){o.next=11;break}return o.next=9,b.awrap(this.deletePayloadWithId(a.uuid));case 9:o.next=17;break;case 11:if(a.uuid){o.next=13;break}throw Error('Attempting to persist payload with no uuid');case 13:return o.next=15,b.awrap(this.encryptionDelegate.payloadByEncryptingPayload(a,this.encryptionPolicy===Ce.Default?Re.b.LocalStoragePreferEncrypted:Re.b.LocalStorageDecrypted));case 15:i=o.sent,t.push(i.ejected());case 17:o.next=4;break;case 19:return o.abrupt("return",this.executeCriticalFunction(function(){var e;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null===(e=s.deviceInterface)||void 0===e?void 0:e.saveRawDatabasePayloads(t,s.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 20:case"end":return o.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(e);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(this.deletePayloadWithId(r.uuid));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deletePayloadWithId",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.deviceInterface.removeRawDatabasePayloadWithId(e,t.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"clearAllPayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.deviceInterface.removeAllRawDatabasePayloads(e.identifier));case 1:case"end":return t.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"clearAllData",value:function(){var e=this;return this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.clearValues());case 2:return t.next=4,b.awrap(e.clearAllPayloads());case 4:return t.next=6,b.awrap(e.deviceInterface.removeRawStorageValue(O(e.identifier,s.SnjsVersion)));case 6:return t.next=8,b.awrap(e.deviceInterface.removeRawStorageValue(e.getPersistenceKey()));case 8:case"end":return t.stop()}},null,null,null,Promise)})}}],[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return g(e={},_e.Wrapped,t),g(e,_e.Unwrapped,n),g(e,_e.Nonwrapped,r),e}}]),n})(R.a),Me=(function(){function e(){v(this,e)}return y(e,null,[{key:"FromRawStorageValue",value:function(e){if(e.jwt)return new Ae(e.jwt);var t=e;return new je(t.accessToken,t.accessExpiration,t.refreshToken,t.refreshExpiration)}}]),e})(),Ae=(function(e){d(n,Me);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).jwt=e,r}return y(n,[{key:"canExpire",value:function(){return!1}},{key:"authorizationValue",get:function(){return this.jwt}}]),n})(),je=(function(e){d(n,Me);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).accessToken=e,s.accessExpiration=r,s.refreshToken=a,s.refreshExpiration=i,s}return y(n,[{key:"getExpireAt",value:function(){return this.accessExpiration||0}},{key:"canExpire",value:function(){return!0}},{key:"isExpired",value:function(){return this.getExpireAt()<Date.now()}},{key:"authorizationValue",get:function(){return this.accessToken}}],[{key:"FromApiResponse",value:function(e){var t=e.data.session.access_token,r=e.data.session.refresh_token;return new n(t,e.data.session.access_expiration,r,e.data.session.refresh_expiration)}}]),n})(),Te=n(15),Ke=n(11),Fe=n(67);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this,e)).keyParams=r,a}return y(n,[{key:"compare",value:function(e){if(this.keyVersion!==e.keyVersion)return!1;var t=!(!this.serverPassword||!e.serverPassword);return Object(Fe.timingSafeEqual)(this.masterKey,e.masterKey)&&(!t||Object(Fe.timingSafeEqual)(this.serverPassword,e.serverPassword))}},{key:"persistableValueWhenWrapping",value:function(){var e=this.getKeychainValue();return e.keyParams=this.keyParams.getPortableValue(),e}},{key:"getKeychainValue",value:function(){var e={version:this.keyVersion};return this.masterKey&&(e.masterKey=this.masterKey),this.dataAuthenticationKey&&(e.dataAuthenticationKey=this.dataAuthenticationKey),e}},{key:"typedContent",get:function(){return this.safeContent}},{key:"keyVersion",get:function(){if(!this.payload.safeContent.version)throw'Attempting to create key without version.';return this.payload.safeContent.version}},{key:"isRootKey",get:function(){return!0}},{key:"itemsKey",get:function(){return this.masterKey}},{key:"masterKey",get:function(){return this.payload.safeContent.masterKey}},{key:"serverPassword",get:function(){return this.payload.safeContent.serverPassword}},{key:"dataAuthenticationKey",get:function(){return this.payload.safeContent.dataAuthenticationKey}}],[{key:"Create",value:function(e,t){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t){s.next=4;break}return s.next=3,b.awrap(I.GenerateUuid());case 3:t=s.sent;case 4:if(e.version||(e.dataAuthenticationKey?e.version=Q.a.V002:e.version=Q.a.V001),r=Object(Ee.e)({uuid:t,content_type:F.a.RootKey,content:Object(Ke.a)(e)}),a=e.keyParams){s.next=9;break}throw Error('Attempting to create root key without key params');case 9:return i=a instanceof A.h?a:new A.h(a),s.abrupt("return",new n(r,i));case 11:case"end":return s.stop()}},null,null,null,Promise)}},{key:"ExpandedCopy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=e.typedContent,a.next=3,b.awrap(this.Create(Ue(Ue({},n),{},{keyParams:t||n.keyParams})));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(T.d);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){He(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ze,qe=function(e){return e.trim().toLowerCase()};!(function(e){e.Restored="SessionRestored",e.Revoked="SessionRevoked"})(ze||(ze={}));var Ye,Ge=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).storageService=e,c.apiService=r,c.alertService=a,c.protocolService=i,c.challengeService=s,c.webSocketsService=o,c.isSessionRenewChallengePresented=!1,r.setInvalidSessionObserver(function(e){e?c.notifyEvent(ze.Revoked):c.reauthenticateInvalidSession()}),c}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.alertService=void 0,this.challengeService=void 0,this.webSocketsService=void 0,this.user=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.storageService.getValue(o.User));case 2:if(this.user=r.sent,this.user){r.next=8;break}return r.next=6,b.awrap(this.storageService.getValue(o.LegacyUuid));case 6:(e=r.sent)&&(this.user={uuid:e,email:e});case 8:return r.next=10,b.awrap(this.storageService.getValue(o.Session));case 10:if(!(t=r.sent)){r.next=16;break}return n=Me.FromRawStorageValue(t),r.next=15,b.awrap(this.setSession(n,!1));case 15:this.webSocketsService.startWebSocketConnection(n.authorizationValue);case 16:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=!(n.length>1&&void 0!==n[1])||n[1],r.next=3,b.awrap(this.apiService.setSession(e,t));case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"online",value:function(){return!this.offline()}},{key:"offline",value:function(){return Object(_.w)(this.apiService.getSession())}},{key:"getUser",value:function(){return this.user}},{key:"getSession",value:function(){return this.apiService.getSession()}},{key:"signOut",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.user=void 0,!(e=this.apiService.getSession())||!e.canExpire()){t.next=6;break}return t.next=5,b.awrap(this.apiService.signOut());case 5:this.webSocketsService.closeWebSocketConnection();case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isSignedIn",value:function(){return void 0!=this.getUser()}},{key:"isSignedIntoFirstPartyServer",value:function(){return this.isSignedIn()&&!this.apiService.isThirdPartyHostUsed()}},{key:"reauthenticateInvalidSession",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=!(i.length>0&&void 0!==i[0])||i[0],n=i.length>1?i[1]:void 0,!this.isSessionRenewChallengePresented){s.next=4;break}return s.abrupt("return");case 4:return this.isSessionRenewChallengePresented=!0,r=new ye([new ge(te.None,void 0,j.R.EmailInputPlaceholder,!1),new ge(te.None,void 0,j.R.PasswordInputPlaceholder)],ne.Custom,t,j.R.EnterEmailAndPassword,j.R.RecoverSession(null===(e=this.getUser())||void 0===e?void 0:e.email)),s.abrupt("return",new Promise(function(e){a.challengeService.addChallengeObserver(r,{onCancel:function(){a.isSessionRenewChallengePresented=!1},onComplete:function(){a.isSessionRenewChallengePresented=!1},onNonvalidatedSubmit:function(t){var i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=t.values[0].value,s=t.values[1].value,u.next=4,b.awrap(a.protocolService.getAccountKeyParams());case 4:return o=u.sent,u.next=7,b.awrap(a.signIn(i,s,!1,a.storageService.isEphemeralSession(),null===o||void 0===o?void 0:o.version));case 7:(c=u.sent).response.error?(a.challengeService.setValidationStatusForChallenge(r,t.values[1],!1),null===n||void 0===n||n(c.response)):(e(),a.challengeService.completeChallenge(r),a.notifyEvent(ze.Restored),a.alertService.alert(j.R.SessionRestored));case 9:case"end":return u.stop()}},null,null,null,Promise)}}),a.challengeService.promptForChallengeResponse(r)}));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSubscription",value:function(){return this.apiService.getSubscription(this.user.uuid)}},{key:"promptForMfaValue",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=new ye([new ge(te.None,j.M.Mfa,j.R.MfaInputPlaceholder,!1,re.Numeric)],ne.Custom,!0,j.R.EnterMfa),n.next=3,b.awrap(this.challengeService.promptForChallengeResponse(e));case 3:if(!(t=n.sent)){n.next=7;break}return this.challengeService.completeChallenge(e),n.abrupt("return",t.values[0].value);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"register",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(t.length<8)){u.next=2;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.G(8))});case 2:return u.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(r=u.sent,a=r.wrappingKey,!r.canceled){u.next=9;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.P.PasscodeRequired,Te.b.LocalValidationError)});case 9:return e=qe(e),u.next=12,b.awrap(this.protocolService.createRootKey(e,t,A.g.Registration));case 12:return i=u.sent,s=i.serverPassword,o=i.keyParams,u.next=17,b.awrap(this.apiService.register(e,s,o,n));case 17:if((c=u.sent).error||!c.data){u.next=21;break}return u.next=21,b.awrap(this.handleSuccessAuthResponse(c,i,a));case 21:return u.abrupt("return",{response:c,rootKey:i});case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"retrieveKeyParams",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.apiService.getAccountKeyParams(e,t,n));case 2:if(!(r=c.sent).error&&!Object(_.w)(r.data)){c.next=17;break}if(!n){c.next=7;break}return c.next=7,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 7:if(null===(a=r.error)||void 0===a||null===(i=a.payload)||void 0===i||!i.mfa_key){c.next=16;break}return c.next=10,b.awrap(this.promptForMfaValue());case 10:if(s=c.sent){c.next=13;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa)});case 13:return c.abrupt("return",this.retrieveKeyParams(e,r.error.payload.mfa_key,s));case 16:return c.abrupt("return",{response:r});case 17:if((o=Object(A.f)(r,e))&&o.version){c.next=20;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 20:return c.abrupt("return",{keyParams:o,response:r,mfaKeyPath:t,mfaCode:n});case 21:case"end":return c.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=o.length>2&&void 0!==o[2]&&o[2],r=o.length>3&&void 0!==o[3]&&o[3],a=o.length>4?o[4]:void 0,c.next=5,b.awrap(this.performSignIn(e,t,n,r,a));case 5:if(!(i=c.sent).response.error||i.response.error.status===Te.b.LocalValidationError||i.response.error.status===Te.b.CanceledMfa){c.next=15;break}if((s=qe(e))===e){c.next=12;break}return c.abrupt("return",this.performSignIn(s,t,n,r,a));case 12:return c.abrupt("return",i);case 13:c.next=16;break;case 15:return c.abrupt("return",i);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"performSignIn",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=arguments;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return n=p.length>2&&void 0!==p[2]&&p[2],r=p.length>3&&void 0!==p[3]&&p[3],a=p.length>4?p[4]:void 0,d.next=5,b.awrap(this.retrieveKeyParams(e));case 5:if(!(i=d.sent).response.error){d.next=8;break}return d.abrupt("return",{response:i.response});case 8:if(s=i.keyParams,this.protocolService.supportedVersions().includes(s.version)){d.next=15;break}if(!this.protocolService.isVersionNewerThanLibraryVersion(s.version)){d.next=14;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.X)});case 14:return d.abrupt("return",{response:this.apiService.createErrorResponse(j.A)});case 15:if(!this.protocolService.isProtocolVersionOutdated(s.version)){d.next=25;break}if(o=this.protocolService.costMinimumForVersion(s.version),!(s.content002.pw_cost<o)){d.next=19;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.E)});case 19:return c=j.L,d.next=22,b.awrap(this.alertService.confirm(c,j.K,j.J));case 22:if(d.sent){d.next=25;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 25:if(this.protocolService.platformSupportsKeyDerivation(s)){d.next=27;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.W)});case 27:if(n&&(a=this.protocolService.getLatestVersion()),Object(_.w)(a)){d.next=31;break}if(Object(Q.d)(s.version,a)){d.next=31;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.T(s.version,a))});case 31:return d.next=33,b.awrap(this.protocolService.computeRootKey(t,s));case 33:return u=d.sent,d.next=36,b.awrap(this.bypassChecksAndSignInWithRootKey(e,u,i.mfaKeyPath,i.mfaCode,r));case 36:return l=d.sent,d.abrupt("return",{response:l});case 38:case"end":return d.stop()}},null,this,null,Promise)}},{key:"bypassChecksAndSignInWithRootKey",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return a=d.length>4&&void 0!==d[4]&&d[4],h.next=3,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 3:if(i=h.sent,s=i.wrappingKey,!i.canceled){h.next=8;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.PasscodeRequired,Te.b.LocalValidationError));case 8:return h.next=10,b.awrap(this.apiService.signIn(e,t.serverPassword,n,r,a));case 10:if((o=h.sent).error||!o.data){h.next=20;break}return h.next=14,b.awrap(Ve.ExpandedCopy(t,o.data.key_params));case 14:return c=h.sent,h.next=17,b.awrap(this.handleSuccessAuthResponse(o,c,s));case 17:return h.abrupt("return",o);case 20:if(null===(u=o.error)||void 0===u||null===(l=u.payload)||void 0===l||!l.mfa_key){h.next=32;break}if(!r){h.next=24;break}return h.next=24,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 24:return h.next=26,b.awrap(this.promptForMfaValue());case 26:if(p=h.sent){h.next=29;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa));case 29:return h.abrupt("return",this.bypassChecksAndSignInWithRootKey(e,t,o.error.payload.mfa_key,p));case 32:return h.abrupt("return",o);case 33:case"end":return h.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.user.uuid,r.next=3,b.awrap(this.apiService.changeCredentials({userUuid:t,currentServerPassword:e.currentServerPassword,newServerPassword:e.newRootKey.serverPassword,newKeyParams:e.newRootKey.keyParams,newEmail:e.newEmail}));case 3:return n=r.sent,r.abrupt("return",this.processChangeCredentialsResponse(n,e.newRootKey,e.wrappingKey));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getSessionsList());case 2:if(!(e=t.sent).error&&!Object(_.w)(e.data)){t.next=5;break}return t.abrupt("return",e);case 5:return e.data=e.data.map(function(e){return We(We({},e),{},{updated_at:new Date(e.updated_at)})}).sort(function(e,t){return e.updated_at<t.updated_at?1:-1}),t.abrupt("return",e);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeSession",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.deleteSession(e));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.getSessionsList());case 2:if(void 0==(e=s.sent).error&&void 0!=e.data){s.next=5;break}throw new Error(null!==(t=null===(n=e.error)||void 0===n?void 0:n.message)&&void 0!==t?t:j.m);case 5:return r=e.data,a=r.filter(function(e){return!e.current}),s.next=9,b.awrap(Promise.all(a.map(function(e){return i.revokeSession(e.uuid)})));case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"processChangeCredentialsResponse",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.error||!e.data){a.next=3;break}return a.next=3,b.awrap(this.handleSuccessAuthResponse(e,t,n));case 3:return a.abrupt("return",{response:e,keyParams:null===(r=e.data)||void 0===r?void 0:r.key_params});case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleSuccessAuthResponse",value:function(e,t,n){var r,a,i,s;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.protocolService.setRootKey(t,n));case 2:return r=e.data,a=r.user,this.user=a,c.next=7,b.awrap(this.storageService.setValue(o.User,a));case 7:if(this.apiService.setHost(this.apiService.getHost()),!r.token){c.next=15;break}return i=new Ae(r.token),c.next=12,b.awrap(this.setSession(i));case 12:this.webSocketsService.startWebSocketConnection(i.authorizationValue),c.next=20;break;case 15:if(!r.session){c.next=20;break}return s=je.FromApiResponse(e),c.next=19,b.awrap(this.setSession(s));case 19:this.webSocketsService.startWebSocketConnection(s.authorizationValue);case 20:case"end":return c.stop()}},null,this,null,Promise)}}]),n})(R.a);!(function(e){e.SignedInOrRegistered="SignedInOrRegistered"})(Ye||(Ye={}));var Qe=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).sessionManager=e,l.syncService=r,l.storageService=a,l.itemManager=i,l.protocolService=s,l.alertService=o,l.challengeService=c,l.protectionService=u,l.signingIn=!1,l.registering=!1,l}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.sessionManager=void 0,this.syncService=void 0,this.storageService=void 0,this.itemManager=void 0,this.protocolService=void 0,this.alertService=void 0,this.challengeService=void 0,this.protectionService=void 0}},{key:"register",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=!(i.length>3&&void 0!==i[3])||i[3],!this.protocolService.hasAccount()){s.next=4;break}throw Error('Tried to register when an account already exists.');case 4:if(!this.registering){s.next=6;break}throw Error('Already registering.');case 6:return this.registering=!0,s.prev=7,this.lockSyncing(),s.next=11,b.awrap(this.sessionManager.register(e,t,n));case 11:if((a=s.sent).response.error){s.next=32;break}return this.syncService.resetSyncState(),s.next=16,b.awrap(this.storageService.setPersistencePolicy(n?Oe.Ephemeral:Oe.Default));case 16:if(!r){s.next=21;break}return s.next=19,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 19:s.next=24;break;case 21:return this.itemManager.removeAllItemsFromMemory(),s.next=24,b.awrap(this.clearDatabase());case 24:return s.next=26,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 26:return this.unlockSyncing(),s.next=29,b.awrap(this.syncService.downloadFirstSync(300));case 29:this.protocolService.decryptErroredItems(),s.next=33;break;case 32:this.unlockSyncing();case 33:return s.abrupt("return",a.response);case 34:return s.prev=34,this.registering=!1,s.finish(34);case 37:case"end":return s.stop()}},null,this,[[7,,34,37]],Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o,c=this,u=arguments;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],r=u.length>3&&void 0!==u[3]&&u[3],a=!(u.length>4&&void 0!==u[4])||u[4],i=u.length>5&&void 0!==u[5]&&u[5],!this.protocolService.hasAccount()){l.next=6;break}throw Error('Tried to sign in when an account already exists.');case 6:if(!this.signingIn){l.next=8;break}throw Error('Already signing in.');case 8:return this.signingIn=!0,l.prev=9,this.lockSyncing(),l.next=13,b.awrap(this.sessionManager.signIn(e,t,n,r));case 13:if((s=l.sent).response.error){l.next=37;break}return this.syncService.resetSyncState(),l.next=18,b.awrap(this.storageService.setPersistencePolicy(r?Oe.Ephemeral:Oe.Default));case 18:if(!a){l.next=23;break}return l.next=21,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 21:l.next=26;break;case 23:return this.itemManager.removeAllItemsFromMemory(),l.next=26,b.awrap(this.clearDatabase());case 26:return l.next=28,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 28:if(this.unlockSyncing(),o=this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0,awaitAll:i}).then(function(){i||c.protocolService.decryptErroredItems()}),!i){l.next=35;break}return l.next=33,b.awrap(o);case 33:return l.next=35,b.awrap(this.protocolService.decryptErroredItems());case 35:l.next=38;break;case 37:this.unlockSyncing();case 38:return l.abrupt("return",s.response);case 39:return l.prev=39,this.signingIn=!1,l.finish(39);case 42:case"end":return l.stop()}},null,this,[[9,,39,42]],Promise)}},{key:"correctiveSignIn",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.lockSyncing(),n.next=3,b.awrap(this.sessionManager.bypassChecksAndSignInWithRootKey(e.keyParams.identifier,e));case 3:if((t=n.sent).error){n.next=10;break}return n.next=7,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 7:this.unlockSyncing(),this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0}),this.protocolService.decryptErroredItems();case 10:return this.unlockSyncing(),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.performCredentialsChange(e));case 2:return(t=n.sent).error&&this.alertService.alert(t.error.message),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.sessionManager.signOut());case 2:return e.next=4,b.awrap(this.protocolService.clearLocalKeyState());case 4:return e.next=6,b.awrap(this.storageService.clearAllData());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performProtocolUpgrade",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return e=this.protocolService.hasPasscode(),t=this.protocolService.hasAccount(),n=[],e&&n.push(new ge(te.LocalPasscode,void 0,j.x.LocalPasscodePlaceholder)),t&&n.push(new ge(te.AccountPassword,void 0,j.x.AccountPasswordPlaceholder)),r=new ye(n,ne.ProtocolUpgrade,!0),p.next=8,b.awrap(this.challengeService.promptForChallengeResponse(r));case 8:if(a=p.sent){p.next=11;break}return p.abrupt("return",{canceled:!0});case 11:return p.next=13,b.awrap(this.alertService.blockingDialog(j.z,j.Y));case 13:if(i=p.sent,p.prev=14,e&&(o=a.getValueForType(te.LocalPasscode),s=o.value),!t){p.next=24;break}return c=a.getValueForType(te.AccountPassword),u=c.value,p.next=21,b.awrap(this.changeCredentials({currentPassword:u,newPassword:u,passcode:s,origination:A.g.ProtocolUpgrade,validateNewPasswordStrength:!1}));case 21:if(null===(l=p.sent)||void 0===l||!l.error){p.next=24;break}return p.abrupt("return",{error:l.error});case 24:if(!e){p.next=29;break}return p.next=27,b.awrap(this.removePasscodeWithoutWarning());case 27:return p.next=29,b.awrap(this.setPasscodeWithoutWarning(s,A.g.ProtocolUpgrade));case 29:return p.abrupt("return",{success:!0});case 32:return p.prev=32,p.t0=p.catch(14),p.abrupt("return",{error:p.t0});case 35:return p.prev=35,i(),p.finish(35);case 38:case"end":return p.stop()}},null,this,[[14,32,35,38]],Promise)}},{key:"addPasscode",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e.length<1)){n.next=2;break}return n.abrupt("return",!1);case 2:return n.next=4,b.awrap(this.protectionService.authorizeAddingPasscode());case 4:if(n.sent){n.next=6;break}return n.abrupt("return",!1);case 6:return n.next=8,b.awrap(this.alertService.blockingDialog(j.z,j.Q));case 8:return t=n.sent,n.prev=9,n.next=12,b.awrap(this.setPasscodeWithoutWarning(e,A.g.PasscodeCreate));case 12:return n.abrupt("return",!0);case 13:return n.prev=13,t(),n.finish(13);case 16:case"end":return n.stop()}},null,this,[[9,,13,16]],Promise)}},{key:"removePasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeRemovingPasscode());case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,b.awrap(this.alertService.blockingDialog(j.z,j.O));case 6:return e=t.sent,t.prev=7,t.next=10,b.awrap(this.removePasscodeWithoutWarning());case 10:return t.abrupt("return",!0);case 11:return t.prev=11,e(),t.finish(11);case 14:case"end":return t.stop()}},null,this,[[7,,11,14]],Promise)}},{key:"changePasscode",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:A.g.PasscodeChange,!(e.length<1)){a.next=3;break}return a.abrupt("return",!1);case 3:return a.next=5,b.awrap(this.protectionService.authorizeChangingPasscode());case 5:if(a.sent){a.next=7;break}return a.abrupt("return",!1);case 7:return a.next=9,b.awrap(this.alertService.blockingDialog(j.z,t===A.g.ProtocolUpgrade?j.N.UpgradingPasscode:j.v));case 9:return n=a.sent,a.prev=10,a.next=13,b.awrap(this.removePasscodeWithoutWarning());case 13:return a.next=15,b.awrap(this.setPasscodeWithoutWarning(e,t));case 15:return a.abrupt("return",!0);case 16:return a.prev=16,n(),a.finish(16);case 19:case"end":return a.stop()}},null,this,[[10,,16,19]],Promise)}},{key:"setPasscodeWithoutWarning",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(I.GenerateUuid());case 2:return n=a.sent,a.next=5,b.awrap(this.protocolService.createRootKey(n,e,t));case 5:return r=a.sent,a.next=8,b.awrap(this.protocolService.setNewRootKeyWrapper(r));case 8:return a.next=10,b.awrap(this.rewriteItemsKeys());case 10:return a.next=12,b.awrap(this.syncService.sync());case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"removePasscodeWithoutWarning",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protocolService.removeRootKeyWrapper());case 2:return e.next=4,b.awrap(this.rewriteItemsKeys());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"rewriteItemsKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.itemsKeys(),t=e.map(function(e){return e.payloadRepresentation()}),n.next=4,b.awrap(this.storageService.deletePayloads(t));case 4:return n.next=6,b.awrap(this.syncService.persistPayloads(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"clearDatabase",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performCredentialsChange",value:function(e){var t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(this.challengeService.getWrappingKeyIfApplicable(e.passcode));case 2:if(t=u.sent,n=t.wrappingKey,!t.canceled){u.next=7;break}return u.abrupt("return",{error:Error(j.y.PasscodeRequired)});case 7:if(void 0===e.newPassword||!e.validateNewPasswordStrength){u.next=10;break}if(!(e.newPassword.length<8)){u.next=10;break}return u.abrupt("return",{error:Error(Object(j.G)(8))});case 10:return u.next=12,b.awrap(this.protocolService.validateAccountPassword(e.currentPassword));case 12:if(u.sent.valid){u.next=15;break}return u.abrupt("return",{error:Error(j.D)});case 15:return r=this.sessionManager.getUser(),a=r.email,u.next=19,b.awrap(this.recomputeRootKeysForCredentialChange({currentPassword:e.currentPassword,currentEmail:a,origination:e.origination,newEmail:e.newEmail,newPassword:e.newPassword}));case 19:return i=u.sent,this.lockSyncing(),u.next=23,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.currentRootKey.serverPassword,newRootKey:i.newRootKey,wrappingKey:n,newEmail:e.newEmail}));case 23:if(s=u.sent,this.unlockSyncing(),s.response.error){u.next=45;break}return u.next=28,b.awrap(this.protocolService.createNewItemsKeyWithRollback());case 28:return o=u.sent,u.next=31,b.awrap(this.protocolService.reencryptItemsKeys());case 31:return u.next=33,b.awrap(this.syncService.sync({awaitAll:!0}));case 33:if(c=this.protocolService.getDefaultItemsKey(),!c.neverSynced){u.next=45;break}return u.next=38,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.newRootKey.serverPassword,newRootKey:i.currentRootKey,wrappingKey:n}));case 38:return u.next=40,b.awrap(this.protocolService.reencryptItemsKeys());case 40:return u.next=42,b.awrap(o());case 42:return u.next=44,b.awrap(this.syncService.sync({awaitAll:!0}));case 44:return u.abrupt("return",{error:Error(j.y.Failed)});case 45:return u.abrupt("return",s.response);case 46:case"end":return u.stop()}},null,this,null,Promise)}},{key:"recomputeRootKeysForCredentialChange",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=b,i.t1=this.protocolService,i.t2=e.currentPassword,i.next=5,b.awrap(this.protocolService.getRootKeyParams());case 5:return i.t3=i.sent,i.t4=i.t1.computeRootKey.call(i.t1,i.t2,i.t3),i.next=9,i.t0.awrap.call(i.t0,i.t4);case 9:return r=i.sent,i.next=12,b.awrap(this.protocolService.createRootKey(null!==(t=e.newEmail)&&void 0!==t?t:e.currentEmail,null!==(n=e.newPassword)&&void 0!==n?n:e.currentPassword,e.origination));case 12:return a=i.sent,i.abrupt("return",{currentRootKey:r,newRootKey:a});case 14:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),Je=n(5),$e=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",get:function(){return this.payload.safeContent.migratedToUserSetting}},{key:"migratedToOfflineEntitlements",get:function(){return this.payload.safeContent.migratedToOfflineEntitlements}},{key:"onlineUrl",get:function(){return this.payload.safeContent.url}},{key:"offlineFeaturesUrl",get:function(){return this.payload.safeContent.offlineFeaturesUrl}},{key:"offlineKey",get:function(){return this.payload.safeContent.offlineKey}}]),n})(T.d),Xe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",set:function(e){this.content.migratedToUserSetting=e}},{key:"migratedToOfflineEntitlements",set:function(e){this.content.migratedToOfflineEntitlements=e}},{key:"offlineFeaturesUrl",set:function(e){this.content.offlineFeaturesUrl=e}},{key:"offlineKey",set:function(e){this.content.offlineKey=e}}]),n})(T.b),Ze=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).notes=[],r.data={},r.url=e.safeContent.url,r.name=e.safeContent.name,r.data=e.safeContent.data||{},r.isDefault=e.safeContent.default,r.systemEditor=e.safeContent.systemEditor,r}return n})(T.d),et=(function(e){d(n,oe);var t=k(n);function n(e){var r;return v(this,n),r=t.call(this,e),e.safeContent.predicate&&(r.predicate=H.a.FromJson(e.safeContent.predicate)),r}return n})(),tt=(g(r={},F.a.Note,le),g(r,F.a.Tag,oe),g(r,F.a.ItemsKey,J),g(r,F.a.SmartTag,et),g(r,F.a.ActionsExtension,ie),g(r,F.a.Editor,Ze),g(r,F.a.Theme,B),g(r,F.a.Component,N),g(r,F.a.UserPrefs,z),g(r,F.a.ExtensionRepo,$e),r);function nt(e){return new(tt[e.content_type]||T.d)(e)}var rt=n(27),at=n.n(rt);function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){ot(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ct=g({},F.a.Note,function(e,t,n){var r=n.all(F.a.Component).map(function(e){return nt(e)}).filter(function(e){return e.area===L.ComponentArea.Editor}).find(function(t){return t.isExplicitlyEnabledForItem(e.uuid)});if(r){var a=new V(r,T.c.Internal);return a.associateWithItem(t.uuid),[a.getResult()]}});function ut(e,t,n,r){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(!e.errorDecrypting){p.next=2;break}throw Error('Attempting to duplicate errored payload');case 2:return a=[],p.next=5,b.awrap(I.GenerateUuid());case 5:return p.t0=p.sent,p.t1=new Date,p.t2=e.uuid,(i={uuid:p.t0,dirty:!0,dirtiedDate:p.t1,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:p.t2}).content=st(st({},e.safeContent),r),n&&(i.content.conflict_of=e.uuid),s=Object(Ee.b)(e,i),a.push(s),o=t.elementsReferencingElement(e),c=pt(o,[{uuid:s.uuid,content_type:s.content_type}]),Object(_.o)(a,c),(u=ct[e.content_type])&&(l=u(e,s,t))&&Object(_.o)(a,l),p.abrupt("return",a);case 19:case"end":return p.stop()}},null,null,null,Promise)}function lt(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=[],u.t0=Object(Ee.b),u.t1=e,u.next=5,b.awrap(I.GenerateUuid());case 5:return u.t2=u.sent,u.t3=new Date,u.t4=e.uuid,u.t5={uuid:u.t2,dirty:!0,dirtiedDate:u.t3,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:u.t4},r=(0,u.t0)(u.t1,u.t5),n.push(r),a=t.elementsReferencingElement(e),i=pt(a,[{uuid:r.uuid,content_type:r.content_type}],[e.uuid]),Object(_.o)(n,i),e.content_type===F.a.ItemsKey&&(s=t.all().filter(function(t){return t.items_key_id===e.uuid}),(o=s.map(function(e){return Object(Ee.b)(e,{items_key_id:r.uuid})})).length>0&&Object(_.o)(n,o)),c=Object(Ee.b)(e,{deleted:!0,dirty:!1,content:void 0}),n.push(c),u.abrupt("return",n);case 18:case"end":return u.stop()}},null,null,null,Promise)}function pt(e,t,n){for(var r,a=[],i=S(e);!(r=i()).done;){var s=r.value,o=s.contentObject.references.slice();if(t)for(var c,u=S(t);!(c=u()).done;){var l=c.value;o.push(l)}if(n)for(var p,d=S(n);!(p=d()).done;){var h=p.value;at()(o,{uuid:h})}var f=Object(Ee.b)(s,{dirty:!0,dirtiedDate:new Date,content:st(st({},s.safeContent),{},{references:o})});a.push(f)}return a}function dt(e,t){var n=nt(e),r=nt(t);return n.isItemContentEqualWith(r)}var ht=n(4),ft=n(32),vt=(function(){function e(t,n,r,a){v(this,e),this.baseCollection=t,this.applyCollection=n,this.relatedCollectionSet=r,this.historyMap=a}return y(e,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:throw'Must override PayloadDelta.resultingCollection.';case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"findBasePayload",value:function(e){return this.baseCollection.find(e)}},{key:"findRelatedPayload",value:function(e,t){var n,r=null===(n=this.relatedCollectionSet)||void 0===n?void 0:n.collectionForSource(t);return null===r||void 0===r?void 0:r.find(e)}}]),e})(),yt=function(e){return e[0]},gt=(function(){function e(){v(this,e),this.directMap={},this.inverseMap={}}return y(e,[{key:"makeCopy",value:function(){var t=new e;return t.directMap=w({},this.directMap),t.inverseMap=w({},this.inverseMap),t}},{key:"getDirectRelationships",value:function(e){return this.directMap[e]||[]}},{key:"getInverseRelationships",value:function(e){return this.inverseMap[e]||[]}},{key:"establishRelationship",value:function(e,t){this.establishDirectRelationship(e,t),this.establishInverseRelationship(e,t)}},{key:"deestablishRelationship",value:function(e,t){this.deestablishDirectRelationship(e,t),this.deestablishInverseRelationship(e,t)}},{key:"setAllRelationships",value:function(e,t){var n=this.directMap[e]||[];this.directMap[e]=t;for(var r,a=S(n);!(r=a()).done;){var i=r.value;this.deestablishInverseRelationship(e,i)}for(var s,o=S(t);!(s=o()).done;){var c=s.value;this.establishInverseRelationship(e,c)}}},{key:"removeFromMap",value:function(e){for(var t,n=S(this.directMap[e]||[]);!(t=n()).done;){var r=t.value;Object(_.M)(this.inverseMap[r]||[],e)}delete this.directMap[e];for(var a,i=S(this.inverseMap[e]||[]);!(a=i()).done;){var s=a.value;Object(_.M)(this.directMap[s]||[],e)}delete this.inverseMap[e]}},{key:"establishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.b)(n,t),this.directMap[e]=n}},{key:"establishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.b)(n,e),this.inverseMap[t]=n}},{key:"deestablishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.M)(n,t),this.directMap[e]=n}},{key:"deestablishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.M)(n,e),this.inverseMap[t]=n}}]),e})(),mt=(function(){function e(){v(this,e);var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.map={},this.typedMap={},this.dirtyIndex=new Set,this.invalidsIndex=new Set,this.nondeletedIndex=new Set,t?(this.map=n,this.typedMap=r,this.referenceMap=a,this.conflictMap=i):(this.referenceMap=new gt,this.conflictMap=new gt)}return y(e,[{key:"uuids",value:function(){return Object.keys(this.map)}},{key:"all",value:function(e){var t=this;if(e){if(Array.isArray(e)){for(var n,r=[],a=S(e);!(n=a()).done;){var i=n.value;Object(_.o)(r,this.typedMap[i]||[])}return r}var s;return(null===(s=this.typedMap[e])||void 0===s?void 0:s.slice())||[]}return Object.keys(this.map).map(function(e){return t.map[e]})}},{key:"find",value:function(e){return this.map[e]}},{key:"dirtyElements",value:function(){var e=Array.from(this.dirtyIndex);return this.findAll(e)}},{key:"invalidElements",value:function(){var e=Array.from(this.invalidsIndex);return this.findAll(e)}},{key:"nondeletedElements",value:function(){var e=Array.from(this.nondeletedIndex);return this.findAll(e)}},{key:"findAll",value:function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],a=S(e);!(t=a()).done;){var i=t.value,s=this.map[i];(s||n)&&r.push(s)}return r}},{key:"set",value:function(e){if(0!==(e=Array.isArray(e)?e:[e]).length)for(var t,n=S(e);!(t=n()).done;){var r=t.value;if(this.map[r.uuid]=r,this.setToTypedMap(r),r.dirty?this.dirtyIndex.add(r.uuid):this.dirtyIndex.delete(r.uuid),r.errorDecrypting||r.waitingForKey?this.invalidsIndex.add(r.uuid):this.invalidsIndex.delete(r.uuid),r.deleted)this.referenceMap.removeFromMap(r.uuid),this.nondeletedIndex.delete(r.uuid);else{this.nondeletedIndex.add(r.uuid);var a=r.safeContent.conflict_of;a&&this.conflictMap.establishRelationship(a,r.uuid),this.referenceMap.setAllRelationships(r.uuid,r.references.map(function(e){return e.uuid}))}}else console.warn('Attempting to set 0 elements onto collection')}},{key:"discard",value:function(e){for(var t,n=S(e=Array.isArray(e)?e:[e]);!(t=n()).done;){var r=t.value;this.conflictMap.removeFromMap(r.uuid),this.referenceMap.removeFromMap(r.uuid),this.deleteFromTypedMap(r),delete this.map[r.uuid]}}},{key:"setToTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),t.push(e),this.typedMap[e.content_type]=t}},{key:"deleteFromTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),this.typedMap[e.content_type]=t}},{key:"uuidsThatReferenceUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getInverseRelationships(e)}},{key:"elementsReferencingElement",value:function(e,t){var n=this.uuidsThatReferenceUuid(e.uuid),r=this.findAll(n);return t?r.filter(function(e){return e.content_type===t}):r}},{key:"uuidReferencesForUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getDirectRelationships(e)}},{key:"referencesForElement",value:function(e){var t=this.referenceMap.getDirectRelationships(e.uuid);return this.findAll(t)}},{key:"conflictsOf",value:function(e){var t=this.conflictMap.getDirectRelationships(e);return this.findAll(t)}}]),e})(),bt=(function(e){d(n,mt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"mutableCopy",value:function(){var e=w({},this.map),t=w({},this.typedMap),n=this.referenceMap.makeCopy(),r=this.conflictMap.makeCopy();return new mt(!0,e,t,n,r)}},{key:"payloads",get:function(){return this.all()}}],[{key:"WithPayloads",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=new n;return r.source=t,e.length>0&&r.set(e),Object.freeze(r),r}},{key:"FromCollection",value:function(e){var t=new n(!0,Object.freeze(w({},e.map)),Object.freeze(w({},e.typedMap)),Object.freeze(e.referenceMap.makeCopy()),Object.freeze(e.conflictMap.makeCopy()));return Object.freeze(t),t}}]),n})();function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach(function(t){xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var St,Pt,Ot,Ct=(function(){function e(t,n,r,a,i){v(this,e),this.baseCollection=t,this.basePayload=n,this.applyPayload=r,this.source=a,this.historyMap=i}return y(e,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return t=nt(this.basePayload),n=nt(this.applyPayload),r=(null===(e=this.historyMap)||void 0===e?void 0:e[this.basePayload.uuid])||[],a=yt(r),i=t.strategyWhenConflictingWithItem(n,a),o.next=7,b.awrap(this.payloadsByHandlingStrategy(i));case 7:return s=o.sent,o.abrupt("return",bt.WithPayloads(s,this.source));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingStrategy",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if((t=this.baseCollection.conflictsOf(this.applyPayload.uuid)[0])&&dt(t,this.applyPayload)&&(e=K.a.KeepLeft),e!==K.a.KeepLeft){y.next=7;break}return n=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),r=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),a=Object(Ee.b)(this.basePayload,{updated_at:n,updated_at_timestamp:r,dirty:!0,dirtiedDate:new Date}),y.abrupt("return",[a]);case 7:if(e!==K.a.KeepRight){y.next=10;break}return i=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",[i]);case 10:if(e!==K.a.KeepLeftDuplicateRight){y.next=18;break}return s=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),o=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),c=Object(Ee.b)(this.basePayload,{updated_at:s,updated_at_timestamp:o,dirty:!0,dirtiedDate:new Date}),y.next=16,b.awrap(ut(this.applyPayload,this.baseCollection,!0));case 16:return u=y.sent,y.abrupt("return",[c].concat(u));case 18:if(e!==K.a.DuplicateLeftKeepRight){y.next=24;break}return y.next=21,b.awrap(ut(this.basePayload,this.baseCollection,!0));case 21:return l=y.sent,p=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",l.concat([p]));case 24:if(e!==K.a.KeepLeftMergeRefs){y.next=30;break}return d=Object(_.U)(this.basePayload.contentObject.references,this.applyPayload.contentObject.references,['uuid','content_type']),h=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),f=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),v=Object(Ee.b)(this.basePayload,{updated_at:h,updated_at_timestamp:f,dirty:!0,dirtiedDate:new Date,content:kt(kt({},this.basePayload.safeContent),{},{references:d})}),y.abrupt("return",[v]);case 30:throw Error('Unhandled strategy');case 31:case"end":return y.stop()}},null,this,null,Promise)}}]),e})(),Dt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}return r=n.value,s.next=6,b.awrap(this.payloadsByHandlingPayload(r,e));case 6:a=s.sent,i=a.map(function(e){return Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date,deleted:!1})}),Object(_.o)(e,i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.FileImport));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingPayload",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=t.find(function(t){return t.contentObject.conflict_of===e.uuid}))||(n=t.find(function(t){return t.uuid===e.uuid})),n||(n=this.findBasePayload(e.uuid)),n){i.next=5;break}return i.abrupt("return",[e]);case 5:return r=new Ct(this.baseCollection,n,e,ht.a.FileImport),i.next=8,b.awrap(r.resultingCollection());case 8:return a=i.sent,i.abrupt("return",a.all());case 10:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(),_t=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=17;break}if(r=n.value,e.push(r),a=this.findBasePayload(r.uuid)){s.next=8;break}return s.abrupt("continue",15);case 8:if(!dt(r,a)){s.next=11;break}return s.abrupt("continue",15);case 11:return s.next=13,b.awrap(ut(a,this.baseCollection,!0));case 13:i=s.sent,Object(_.o)(e,i);case 15:s.next=2;break;case 17:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 18:case"end":return s.stop()}},null,this,null,Promise)}}]),n})(),Et=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.applyCollection.source!==ht.a.ConflictUuid){e.next=4;break}return e.abrupt("return",this.collectionsByHandlingUuidConflicts());case 4:if(this.applyCollection.source!==ht.a.ConflictData){e.next=8;break}return e.abrupt("return",this.collectionsByHandlingDataConflicts());case 8:throw"Unhandled conflict type ".concat(this.applyCollection.source);case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingDataConflicts",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){u.next=19;break}if(r=n.value,a=this.findBasePayload(r.uuid)){u.next=8;break}return e.push(r),u.abrupt("continue",17);case 8:if((i=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient))||r.deleted){u.next=11;break}throw'Unable to find decrypted counterpart for data conflict.';case 11:return s=new Ct(this.baseCollection,a,i||r,ht.a.ConflictData,this.historyMap),u.next=14,b.awrap(s.resultingCollection());case 14:o=u.sent,c=o.all(),Object(_.o)(e,c);case 17:u.next=2;break;case 19:return u.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingUuidConflicts",value:function(){var e,t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:e=[],t=this.baseCollection.mutableCopy(),n=function(n){var r,a,i;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=e.find(function(e){return e.uuid===n.uuid}),a=r||s.findRelatedPayload(n.uuid,ht.a.DecryptedTransient)){o.next=6;break}return we.a.error(Error('Cannot find decrypted payload in conflict handling')),console.error('Unable to find decrypted counterpart for payload',n),o.abrupt("return","continue");case 6:return o.next=8,b.awrap(lt(a,bt.FromCollection(t)));case 8:i=o.sent,t.set(i),Object(_.p)(e,function(e){return Object(Ke.b)(i).includes(e.uuid)}),Object(_.o)(e,i);case 12:case"end":return o.stop()}},null,null,null,Promise)},r=S(this.applyCollection.all());case 4:if((a=r()).done){o.next=13;break}return i=a.value,o.next=8,b.awrap(n(i));case 8:if("continue"!==o.sent){o.next=11;break}return o.abrupt("continue",11);case 11:o.next=4;break;case 13:return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 14:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Rt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y;return b.async(function(g){for(;;)switch(g.prev=g.next){case 0:e=[],t=[],n=S(this.applyCollection.all());case 3:if((r=n()).done){g.next=22;break}if(a=r.value,i=this.findRelatedPayload(a.uuid,ht.a.SavedOrSaving),s=this.findRelatedPayload(a.uuid,ht.a.DecryptedTransient)){g.next=12;break}if(a.deleted){g.next=10;break}throw'Cannot find decrypted for non-deleted payload.';case 10:return e.push(a),g.abrupt("continue",20);case 12:if(!i){g.next=15;break}return t.push(s),g.abrupt("continue",20);case 15:if(null===(o=this.findBasePayload(a.uuid))||void 0===o||!o.dirty||o.errorDecrypting){g.next=19;break}return t.push(s),g.abrupt("continue",20);case 19:e.push(s);case 20:g.next=3;break;case 22:c=[],u=0,l=t;case 24:if(!(u<l.length)){g.next=41;break}if(p=l[u],d=this.findRelatedPayload(p.uuid,ht.a.DecryptedTransient)){g.next=29;break}return g.abrupt("continue",38);case 29:if(h=this.findBasePayload(p.uuid)){g.next=32;break}return g.abrupt("continue",38);case 32:return f=new Ct(this.baseCollection,h,d,ht.a.ConflictData),g.next=35,b.awrap(f.resultingCollection());case 35:v=g.sent,y=v.all(),Object(_.o)(c,y);case 38:u++,g.next=24;break;case 41:return g.abrupt("return",bt.WithPayloads(e.concat(c),ht.a.RemoteRetrieved));case 42:case"end":return g.stop()}},null,this,null,Promise)}}]),n})(),It=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:for(e=[],t=S(this.applyCollection.all());!(n=t()).done;)r=n.value,a=this.findBasePayload(r.uuid),i=a?a.deleted:r.deleted,s=Object(Ee.f)(r,ht.a.RemoteSaved,{lastSyncEnd:new Date,deleted:i,dirty:i}),e.push(s);return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteSaved));case 3:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Mt=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l){var p;return v(this,n),(p=t.call(this)).itemManager=e,p.payloadManager=r,p.apiService=a,p.protocolService=i,p.challengeService=s,p.alertService=o,p.storageService=c,p.syncService=u,p.credentialService=l,p.decryptionQueue=[],p.isProcessingQueue=!1,p.removeItemObserver=p.itemManager.addObserver([F.a.ItemsKey],function(e,t,n,r,a){if(a!==ht.a.LocalChanged){var i=e.concat(t).filter(function(e){return e.errorDecrypting});i.length>0&&p.handleUndecryptableItemsKeys(i),r.length>0&&p.handleIgnoredItemsKeys(r)}}),p}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.apiService=void 0,this.protocolService=void 0,this.challengeService=void 0,this.alertService=void 0,this.credentialService=void 0,this.syncService=void 0,this.storageService=void 0,this.removeItemObserver(),this.removeItemObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:p(f(n.prototype),"handleApplicationStage",this).call(this,e),e===ve.LoadedDatabase_12&&this.processPersistedUndecryptables();case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleIgnoredItemsKeys",value:function(e){var t=this,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(!(n.length>1&&void 0!==n[1])||n[1])){r.next=4;break}return r.next=4,b.awrap(this.saveToUndecryptables(e));case 4:return r.next=6,b.awrap(this.addKeysToQueue(e,function(e,n){n.success&&t.removeFromUndecryptables(e)}));case 6:return r.next=8,b.awrap(this.beginProcessingQueue());case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"handleUndecryptableItemsKeys",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.addKeysToQueue(e));case 2:return t.next=4,b.awrap(this.beginProcessingQueue());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"processPersistedUndecryptables",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getUndecryptables());case 2:if(e=r.sent,0!==(t=Object.values(e)).length){r.next=6;break}return r.abrupt("return");case 6:return n=t.map(function(e){return Object(Ee.e)(e)}).map(function(e){return nt(e)}),r.abrupt("return",this.handleIgnoredItemsKeys(n,!1));case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getUndecryptables",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.KeyRecoveryUndecryptableItems,De.Default,{}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"persistUndecryptables",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.KeyRecoveryUndecryptableItems,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"saveToUndecryptables",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.getUndecryptables());case 2:for(t=i.sent,n=S(e);!(r=n()).done;)a=r.value,t[a.uuid]=a.payload.ejected();return i.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"removeFromUndecryptables",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getUndecryptables());case 2:return delete(t=n.sent)[e.uuid],n.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getClientKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getAccountKeyParams());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"serverKeyParamsAreSafe",value:function(e){return Object(Q.d)(this.serverParams.version,e.version)}},{key:"performServerSignIn",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(e),j.H.KeyRecoveryLoginFlowReason),i.next=3,b.awrap(this.challengeService.promptForChallengeResponse(t));case 3:if(n=i.sent){i.next=6;break}return i.abrupt("return",void 0);case 6:return this.challengeService.completeChallenge(t),r=n.values[0].value,i.next=10,b.awrap(this.protocolService.computeRootKey(r,e));case 10:return a=i.sent,i.next=13,b.awrap(this.credentialService.correctiveSignIn(a));case 13:if(i.sent.error){i.next=19;break}return this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced),i.abrupt("return",a);case 19:return i.next=21,b.awrap(this.alertService.alert(j.H.KeyRecoveryLoginFlowInvalidPassword));case 21:return i.abrupt("return",this.performServerSignIn(e));case 22:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",void 0);case 2:return n.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(e=n.sent,t=e.wrappingKey,!e.canceled){n.next=11;break}return n.next=10,b.awrap(this.alertService.alert(j.H.KeyRecoveryPasscodeRequiredText,j.H.KeyRecoveryPasscodeRequiredTitle));case 10:return n.abrupt("return",this.getWrappingKeyIfApplicable());case 11:return n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"addKeysToQueue",value:function(e,t){var n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:n=function(e){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(s.protocolService.getKeyEmbeddedKeyParams(e));case 2:if(n=i.sent){i.next=5;break}return i.abrupt("return","continue");case 5:r={key:e,keyParams:n,callback:t},a=new Promise(function(e){r.resolve=e}),r.promise=a,s.decryptionQueue.push(r);case 9:case"end":return i.stop()}},null,null,null,Promise)},r=S(e);case 2:if((a=r()).done){o.next=11;break}return i=a.value,o.next=6,b.awrap(n(i));case 6:if("continue"!==o.sent){o.next=9;break}return o.abrupt("continue",9);case 9:o.next=2;break;case 11:case"end":return o.stop()}},null,null,null,Promise)}},{key:"readdQueueItem",value:function(e){var t=new Promise(function(t){e.resolve=t});e.promise=t,this.decryptionQueue.unshift(e)}},{key:"beginProcessingQueue",value:function(){var e,t,n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.isProcessingQueue){c.next=2;break}return c.abrupt("return");case 2:return this.isProcessingQueue=!0,c.next=5,b.awrap(this.getClientKeyParams());case 5:if(e=c.sent,this.serverParams||!e){c.next=11;break}return c.next=9,b.awrap(this.apiService.getAccountKeyParams(e.identifier));case 9:!(t=c.sent).error&&t.data&&(this.serverParams=Object(A.f)(t));case 11:if(n=this.protocolService.hasAccount(),r=this.protocolService.hasPasscode(),a=!n&&!r,i=this.decryptionQueue[0],!a){c.next=24;break}return c.next=18,b.awrap(this.performServerSignIn(i.keyParams));case 18:if(!(s=c.sent)){c.next=24;break}return c.next=22,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(s,!0));case 22:Object(_.M)(this.decryptionQueue,i),i=this.decryptionQueue[0];case 24:if(!i){c.next=31;break}return this.popQueueItem(i),c.next=28,b.awrap(i.promise);case 28:i=this.decryptionQueue[0],c.next=24;break;case 31:this.queuePromise.then(function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(o.isProcessingQueue=!1,!o.serverParams){n.next=9;break}return n.next=4,b.awrap(o.getClientKeyParams());case 4:if(e=n.sent,t=e&&!o.serverParams.compare(e),!o.serverKeyParamsAreSafe(e)||!t){n.next=9;break}return n.next=9,b.awrap(o.performServerSignIn(o.serverParams));case 9:o.syncService.isOutOfSync()&&o.syncService.sync({checkIntegrity:!0});case 10:case"end":return n.stop()}},null,null,null,Promise)});case 32:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueItem",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P;return b.async(function(O){for(;;)switch(O.prev=O.next){case 0:if(e.resolve){O.next=2;break}throw Error('Attempting to pop queue element with no resolve function');case 2:return Object(_.M)(this.decryptionQueue,e),t=e.keyParams,n=e.key,r=e.resolve,a=!1,O.next=9,b.awrap(this.getClientKeyParams());case 9:return i=O.sent,this.serverParams&&i&&!i.compare(this.serverParams)&&t.compare(this.serverParams)&&this.serverKeyParamsAreSafe(this.serverParams)&&(s=Object(_.j)(this.itemManager.nonErroredItemsForContentType(F.a.ItemsKey),Je.a.CreatedAt,!1)[0],o=!Object(_.w)(s),c=n.created_at>(null===s||void 0===s?void 0:s.created_at),a=!o||c),u=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(t),j.H.KeyRecoveryPasswordRequired),O.next=14,b.awrap(this.challengeService.promptForChallengeResponse(u));case 14:if(l=O.sent){O.next=20;break}return r(d={success:!1}),null===(p=e.callback)||void 0===p||p.call(e,n,d),O.abrupt("return");case 20:return h=l.values[0].value,O.next=23,b.awrap(this.protocolService.computeRootKey(h,t));case 23:return f=O.sent,O.next=26,b.awrap(this.protocolService.payloadByDecryptingPayload(n.payload,f));case 26:if(v=O.sent,this.challengeService.completeChallenge(u),v.errorDecrypting){O.next=38;break}return O.next=31,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(f,a,[v]));case 31:for(g=O.sent,r(m={success:!0}),null===(y=e.callback)||void 0===y||y.call(e,n,m),w=S(g);!(k=w()).done;)(x=k.value).resolve(m),null===(P=x.callback)||void 0===P||P.call(x,x.key,m);O.next=42;break;case 38:return O.next=40,b.awrap(this.alertService.alert(j.H.KeyRecoveryUnableToRecover));case 40:this.readdQueueItem(e),r({success:!1});case 42:case"end":return O.stop()}},null,this,null,Promise)}},{key:"handleDecryptionOfAllKeysMatchingCorrectRootKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:[],!t){c.next=7;break}return c.next=4,b.awrap(this.getWrappingKeyIfApplicable());case 4:return r=c.sent,c.next=7,b.awrap(this.protocolService.setRootKey(e,r));case 7:return a=this.popQueueForKeyParams(e.keyParams),c.next=10,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a.map(function(e){return e.key.payload}),e));case 10:return i=c.sent,s=n.concat(i),this.payloadManager.emitPayloads(s,ht.a.DecryptedTransient),c.next=15,b.awrap(this.storageService.savePayloads(s));case 15:return t?this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced):this.alertService.alert(j.H.KeyRecoveryKeyRecovered),c.abrupt("return",a);case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueForKeyParams",value:function(e){for(var t,n=[],r=[],a=S(this.decryptionQueue);!(t=a()).done;){var i=t.value;i.keyParams.compare(e)?n.push(i):r.push(i)}return this.decryptionQueue=r,n}},{key:"queuePromise",get:function(){return Promise.all(this.decryptionQueue.map(function(e){return e.promise}))}}]),n})(R.a),At=n(17);!(function(e){e[e.Info=0]="Info",e[e.Danger=1]="Danger"})(St||(St={})),(function(e){e.Get="GET",e.Post="POST",e.Put="PUT",e.Patch="PATCH",e.Delete="DELETE"})(Pt||(Pt={})),(function(e){e.RevokedSession="revoked-session"})(Ot||(Ot={}));var jt=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).environment=e,a.appVersion=r,a}return y(n,[{key:"getAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Get,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"postAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Post,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"putAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Put,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"patchAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Patch,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Delete,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"runHttp",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.createXmlRequest(e),n.abrupt("return",this.runRequest(t,e.verb,e.params));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createXmlRequest",value:function(e){var t=new XMLHttpRequest;e.params&&e.verb===Pt.Get&&Object.keys(e.params).length>0&&(e.url=this.urlForUrlAndParams(e.url,e.params)),t.open(e.verb,e.url,!0),t.setRequestHeader('Content-type','application/json'),t.setRequestHeader('X-SNJS-Version',h);var n="".concat(he[this.environment],"-").concat(this.appVersion);return t.setRequestHeader('X-Application-Version',n),e.authentication&&t.setRequestHeader('Authorization','Bearer '+e.authentication),e.customHeaders&&e.customHeaders.length>0&&e.customHeaders.forEach(function(e){var n=e.key,r=e.value;t.setRequestHeader(n,r)}),t}},{key:"runRequest",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,i){e.onreadystatechange=function(){r.stateChangeHandlerForRequest(e,a,i)},t===Pt.Post||t===Pt.Put||t===Pt.Patch||t===Pt.Delete?e.send(JSON.stringify(n)):e.send()}));case 1:case"end":return a.stop()}},null,null,null,Promise)}},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.status,a={status:r};try{if(r!==Te.b.HttpStatusNoContent){var i=JSON.parse(e.responseText);i.data||(a.data=i),w(a,i)}}catch(e){console.error(e)}r>=Te.b.HttpStatusMinSuccess&&r<=Te.b.HttpStatusMaxSuccess?t(a):(r===Te.b.HttpStatusForbidden?a.error={message:j.q,status:r}:Object(_.w)(a.error)&&(Object(_.w)(a.data)||Object(_.w)(a.data.error)?a.error={message:j.U,status:r}:a.error=a.data.error),n(a))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map(function(e){return e+'='+encodeURIComponent(t[e])}).join('&');return e.includes('?')?e+'&'+n:e+'?'+n}}]),n})(R.a),Tt=n(22),Kt=['api.standardnotes.com','api-dev.standardnotes.com','sync.standardnotes.org'],Ft=['api-dev.standardnotes.com','api.standardnotes.com','extensions.standardnotes.com','extensions.standardnotes.org','features.standardnotes.com'],Lt='localhost';function Ut(e){try{var t=new URL(e).host;return t.startsWith(Lt)||Kt.includes(t)}catch(e){return!1}}var Nt=['listed.to'];function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(n),!0).forEach(function(t){Wt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ht,zt={keyParams:'/v1/login-params',register:'/v1/users',signIn:'/v1/login',changeCredentials:function(e){return"/v1/users/".concat(e,"/attributes/credentials")},sync:'/v1/items',signOut:'/v1/logout',refreshSession:'/v1/sessions/refresh',sessions:'/v1/sessions',session:function(e){return"/v1/sessions/".concat(e)},itemRevisions:function(e){return"/v1/items/".concat(e,"/revisions")},itemRevision:function(e,t){return"/v1/items/".concat(e,"/revisions/").concat(t)},userFeatures:function(e){return"/v1/users/".concat(e,"/features")},settings:function(e){return"/v1/users/".concat(e,"/settings")},setting:function(e,t){return"/v1/users/".concat(e,"/settings/").concat(t)},subscription:function(e){return"/v1/users/".concat(e,"/subscription")},purchase:'/v1/purchase',subscriptionTokens:'/v1/subscription-tokens',offlineFeatures:'/v1/offline/features'},qt={subscriptions:'/v2/subscriptions'};!(function(e){e.MetaReceived="MetaReceived"})(Ht||(Ht={}));var Yt=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).httpService=e,i.storageService=r,i.host=a,i.registering=!1,i.authenticating=!1,i.changing=!1,i.refreshingSession=!1,i}return y(n,[{key:"deinit",value:function(){this.httpService=void 0,this.storageService=void 0,this.invalidSessionObserver=void 0,this.session=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"setInvalidSessionObserver",value:function(e){this.invalidSessionObserver=e}},{key:"loadHost",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ServerHost));case 2:e=t.sent,this.host=e||this.host||window._default_sync_server;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.host=e,t.next=3,b.awrap(this.storageService.setValue(o.ServerHost,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.host}},{key:"isThirdPartyHostUsed",value:function(){return!Ut(this.getHost()||'')}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],this.session=e,!t){r.next=5;break}return r.next=5,b.awrap(this.storageService.setValue(o.Session,e));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSession",value:function(){return this.session}},{key:"params",value:function(e){var t=Z()(e,g({},Tt.a.ApiVersion,this.apiVersion));return t}},{key:"createErrorResponse",value:function(e,t){return{error:{message:e,status:t}}}},{key:"errorResponseWithFallbackMessage",value:function(e,t){var n,r,a;null!==(n=e.error)&&void 0!==n&&n.message||(e.error=Bt(Bt({},e.error),{},{status:null!==(r=null===(a=e.error)||void 0===a?void 0:a.status)&&void 0!==r?r:Te.b.UnknownError,message:t}));return e}},{key:"processMetaObject",value:function(e){e.auth&&e.auth.userUuid&&e.auth.roles&&this.notifyEvent(Ht.MetaReceived,{userUuid:e.auth.userUuid,userRoles:e.auth.roles})}},{key:"processResponse",value:function(e){e.meta&&this.processMetaObject(e.meta)}},{key:"request",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.awrap(this.httpService.runHttp(e));case 3:return t=n.sent,this.processResponse(t),n.abrupt("return",t);case 8:return n.prev=8,n.t0=n.catch(0),n.abrupt("return",this.errorResponseWithFallbackMessage(n.t0,e.fallbackErrorMessage));case 11:case"end":return n.stop()}},null,this,[[0,8]],Promise)}},{key:"getAccountKeyParams",value:function(e,t,n){var r,a=this.params({email:e});return t&&n&&(a[t]=n),this.request({verb:Pt.Get,url:Object(_.D)(this.host,zt.keyParams),fallbackErrorMessage:j.k,params:a,authentication:null===(r=this.session)||void 0===r?void 0:r.authorizationValue})}},{key:"register",value:function(e,t,n,r){var a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.registering){o.next=2;break}return o.abrupt("return",this.createErrorResponse(j.r));case 2:return this.registering=!0,a=Object(_.D)(this.host,zt.register),i=this.params(Bt({password:t,email:e,ephemeral:r},n.getPortableValue())),o.next=7,b.awrap(this.request({verb:Pt.Post,url:a,fallbackErrorMessage:j.l,params:i}));case 7:return s=o.sent,this.registering=!1,o.abrupt("return",s);case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t,n,r){var a,i,s,o,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>4&&void 0!==c[4]&&c[4],!this.authenticating){u.next=3;break}return u.abrupt("return",this.createErrorResponse(j.p));case 3:return this.authenticating=!0,i=Object(_.D)(this.host,zt.signIn),s=this.params({email:e,password:t,ephemeral:a}),n&&r&&(s[n]=r),u.next=9,b.awrap(this.request({verb:Pt.Post,url:i,params:s,fallbackErrorMessage:j.k}));case 9:return o=u.sent,this.authenticating=!1,u.abrupt("return",o);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e=Object(_.D)(this.host,zt.signOut);return this.httpService.postAbsolute(e,void 0,this.session.authorizationValue).catch(function(e){return e})}},{key:"changeCredentials",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.changing){s.next=2;break}return s.abrupt("return",this.createErrorResponse(j.a));case 2:if(!(t=this.preprocessingError())){s.next=5;break}return s.abrupt("return",t);case 5:return this.changing=!0,n=Object(_.D)(this.host,zt.changeCredentials(e.userUuid)),r=this.params(Bt({current_password:e.currentServerPassword,new_password:e.newServerPassword,new_email:e.newEmail},e.newKeyParams.getPortableValue())),s.next=10,b.awrap(this.httpService.putAbsolute(n,r,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Object(Te.c)(e)){t.next=2;break}return t.abrupt("return",i.refreshSessionThenRetryRequest({verb:Pt.Put,url:n,params:r}));case 2:return t.abrupt("return",i.errorResponseWithFallbackMessage(e,j.j));case 3:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return a=s.sent,this.processResponse(a),this.changing=!1,s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"sync",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=this,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:if(i=h.length>4&&void 0!==h[4]&&h[4],s=h.length>5?h[5]:void 0,o=h.length>6?h[6]:void 0,!(c=this.preprocessingError())){f.next=6;break}return f.abrupt("return",c);case 6:return u=Object(_.D)(this.host,zt.sync),l=this.params((g(a={},Tt.a.SyncPayloads,e.map(function(e){return e.ejected()})),g(a,Tt.a.LastSyncToken,t),g(a,Tt.a.PaginationToken,n),g(a,Tt.a.IntegrityCheck,i),g(a,Tt.a.SyncDlLimit,r),g(a,"content_type",s),g(a,"event",o),a)),f.next=10,b.awrap(this.httpService.postAbsolute(u,l,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(d.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){t.next=3;break}return t.abrupt("return",d.refreshSessionThenRetryRequest({verb:Pt.Post,url:u,params:l}));case 3:return t.abrupt("return",d.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return p=f.sent,this.processResponse(p),f.abrupt("return",p);case 13:case"end":return f.stop()}},null,this,null,Promise)}},{key:"refreshSessionThenRetryRequest",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.refreshSession());case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=7;break}return n.abrupt("return",t);case 7:return n.abrupt("return",this.httpService.runHttp(Bt(Bt({},e),{},{authentication:this.session.authorizationValue})).catch(function(e){return e}));case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"refreshSession",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(e=this.preprocessingError())){s.next=3;break}return s.abrupt("return",e);case 3:return this.refreshingSession=!0,t=Object(_.D)(this.host,zt.refreshSession),n=this.session,r=this.params({access_token:n.accessToken,refresh_token:n.refreshToken}),s.next=9,b.awrap(this.httpService.postAbsolute(t,r).then(function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=je.FromApiResponse(e),n.next=3,b.awrap(i.setSession(t));case 3:return i.processResponse(e),n.abrupt("return",e);case 5:case"end":return n.stop()}},null,null,null,Promise)}).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),i.errorResponseWithFallbackMessage(e,j.n)}));case 9:return a=s.sent,this.refreshingSession=!1,s.abrupt("return",a);case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e=this.preprocessingError())){a.next=3;break}return a.abrupt("return",e);case 3:return t=Object(_.D)(this.host,zt.sessions),a.next=6,b.awrap(this.httpService.getAbsolute(t,{},this.session.authorizationValue).catch(function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){n.next=3;break}return n.abrupt("return",r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}));case 3:return n.abrupt("return",r.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return n.stop()}},null,null,null,Promise)}));case 6:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSession",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.session(e)),i.next=6,b.awrap(this.httpService.deleteAbsolute(n,{uuid:e},this.session.authorizationValue).catch(function(e){var t=e;return a.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?a.refreshSessionThenRetryRequest({verb:Pt.Delete,url:n}):a.errorResponseWithFallbackMessage(t,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getItemRevisions",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.itemRevisions(e)),i.next=6,b.awrap(this.httpService.getAbsolute(n,void 0,this.session.authorizationValue).catch(function(e){return a.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?a.refreshSessionThenRetryRequest({verb:Pt.Get,url:n}):a.errorResponseWithFallbackMessage(e,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getRevision",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(n=this.preprocessingError())){s.next=3;break}return s.abrupt("return",n);case 3:return r=Object(_.D)(this.host,zt.itemRevision(t,e.uuid)),s.next=6,b.awrap(this.httpService.getAbsolute(r,void 0,this.session.authorizationValue).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?i.refreshSessionThenRetryRequest({verb:Pt.Get,url:r}):i.errorResponseWithFallbackMessage(e,j.m)}));case 6:return a=s.sent,this.processResponse(a),s.abrupt("return",a);case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getUserFeatures",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=Object(_.D)(this.host,zt.userFeatures(e)),a.next=3,b.awrap(this.httpService.getAbsolute(t,void 0,this.session.authorizationValue).catch(function(e){return r.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}):r.errorResponseWithFallbackMessage(e,j.m)}));case 3:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"tokenRefreshableRequest",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(t=this.preprocessingError())){a.next=3;break}return a.abrupt("return",t);case 3:return a.next=5,b.awrap(this.httpService.runHttp(e).catch(function(t){return r.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?r.refreshSessionThenRetryRequest(e):r.errorResponseWithFallbackMessage(t,e.fallbackErrorMessage)}));case 5:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"listSettings",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.settings(e)),fallbackErrorMessage:j.d,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n,r){var a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return i={name:t,value:n,sensitive:r},s.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Put,url:Object(_.D)(this.host,zt.settings(e)),authentication:null===(a=this.session)||void 0===a?void 0:a.authorizationValue,fallbackErrorMessage:j.h,params:i}));case 2:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.setting(e,t.toLowerCase())),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.d}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Delete,url:Object(_.D)(this.host,zt.setting(e,t)),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.h}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"downloadFeatureUrl",value:function(e){return this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.k})}},{key:"getSubscription",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscription(e)),a.next=3,b.awrap(this.request({verb:Pt.Get,url:n,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue,fallbackErrorMessage:j.g}));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=Object(_.D)(this.host,qt.subscriptions),n.next=3,b.awrap(this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.g}));case 3:return t=n.sent,n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getNewSubscriptionToken",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscriptionTokens),a.next=3,b.awrap(this.request({verb:Pt.Post,url:n,authentication:null===(e=this.session)||void 0===e?void 0:e.authorizationValue,fallbackErrorMessage:j.b}));case 3:return r=a.sent,a.abrupt("return",null===(t=r.data)||void 0===t?void 0:t.token);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"downloadOfflineFeaturesFromRepo",value:function(e){var t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,n=e.offlineFeaturesUrl,r=e.offlineKey,a=new URL(n),i=a.host,Ft.includes(i)){o.next=6;break}return o.abrupt("return",{error:'This offline features host is not in the trusted allowlist.'});case 6:return o.next=8,b.awrap(this.request({verb:Pt.Get,url:n,fallbackErrorMessage:j.f,customHeaders:[{key:'x-offline-token',value:r}]}));case 8:return s=o.sent,o.abrupt("return",{features:(null===(t=s.data)||void 0===t?void 0:t.features)||[]});case 12:return o.prev=12,o.t0=o.catch(0),o.abrupt("return",{error:j.e});case 15:case"end":return o.stop()}},null,this,[[0,12]],Promise)}},{key:"preprocessingError",value:function(){return this.refreshingSession?this.createErrorResponse(j.s):this.session?void 0:this.createErrorResponse(j.o)}},{key:"preprocessAuthenticatedErrorResponse",value:function(e){var t,n;e.status===Te.b.HttpStatusInvalidSession&&this.session&&(null===(t=this.invalidSessionObserver)||void 0===t||t.call(this,(null===(n=e.error)||void 0===n?void 0:n.tag)===Ot.RevokedSession))}},{key:"apiVersion",get:function(){return"20200115"}}]),n})(R.a),Gt=n(25),Qt=n.n(Gt),Jt=n(28),$t=n.n(Jt);function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach(function(t){en(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tn,nn=Object.freeze([F.a.ActionsExtension,F.a.Component,F.a.Editor,F.a.ExtensionRepo,F.a.FilesafeCredentials,F.a.FilesafeFileMetadata,F.a.FilesafeIntegration,F.a.ServerExtension,F.a.SmartTag,F.a.Tag,F.a.Theme]),rn='org.standardnotes.sn.components';!(function(e){e.Shift="Shift",e.Ctrl="Control",e.Meta="Meta"})(tn||(tn={}));var an=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).componentState={},c.streamObservers=[],c.contextStreamObservers=[],c.permissionDialogs=[],c.handlers=[],c.templateComponents=[],c.detectFocusChange=function(){for(var e,t=function(e){if(document.activeElement===e)return c.timeout(function(){for(var t,n=c.findComponent(e.dataset.componentId),r=S(c.handlers);!(t=r()).done;){var a=t.value;a.focusHandler&&a.focusHandler(n,!0)}}),"break"},n=S(c.allComponentIframes());!(e=n()).done;){if("break"===t(e.value))break}},c.onWindowMessage=function(e){e.data.sessionKey&&(c.log('Component manager received message',e.data),c.handleMessage(c.componentForSessionKey(e.data.sessionKey),e.data))},c.timeout=o||setTimeout.bind(window),c.itemManager=e,c.syncService=r,c.alertService=a,c.environment=i,c.platform=s,c.configureForGeneralUsage(),i!==he.Mobile&&c.configureForNonMobileUsage(),c}return y(n,[{key:"componentsForArea",value:function(e){return this.components.filter(function(t){return t.area===e})}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.streamObservers.length=0,this.contextStreamObservers.length=0,this.permissionDialogs.length=0,this.templateComponents.length=0,this.handlers.length=0,this.itemManager=void 0,this.syncService=void 0,this.alertService=void 0,this.removeItemObserver(),this.removeItemObserver=null,window&&!this.isMobile&&(window.removeEventListener('focus',this.detectFocusChange,!0),window.removeEventListener('blur',this.detectFocusChange,!0),window.removeEventListener('message',this.onWindowMessage))}},{key:"setDesktopManager",value:function(e){this.desktopManager=e,this.configureForDesktop()}},{key:"configureForGeneralUsage",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n,r,a,i,s){var o=Object(_.h)(t,n,r),c=o.filter(function(e){return e.content_type===F.a.Component||e.content_type===F.a.Theme});c.length>0&&i!==ht.a.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(c),c.filter(function(e){return e.isTheme()}).length>0&&e.postActiveThemesToAllComponents();for(var u,l=S(c);!(u=l()).done;){var p=u.value;if(!p.isEditor()){var d=!!e.iframeForComponent(p.uuid);!p.active&&d&&e.deactivateComponent(p.uuid)}}e.notifyStreamObservers(o,i,s)})}},{key:"notifyStreamObservers",value:function(e,t,n){for(var r,a=this,i=function(t){if(n&&n===t.componentUuid)return"continue";var r=e.filter(function(e){return-1!==t.contentTypes.indexOf(e.content_type)});if(0===r.length)return"continue";var i=[{name:E.StreamItems,content_types:t.contentTypes.sort()}];a.runWithPermissions(t.componentUuid,i,function(){a.sendItemsInReply(t.componentUuid,r,t.originalMessage)})},s=S(this.streamObservers);!(r=s()).done;)i(r.value);for(var o,c=[{name:E.StreamContextItem}],u=function(r){if(n&&n===r.componentUuid)return"continue";for(var i,s=S(a.handlers);!(i=s()).done;){var o=i.value;if((o.areas.includes(r.area)||o.areas.includes(L.ComponentArea.Any))&&o.contextRequestHandler){var u=o.contextRequestHandler(r.componentUuid);if(u)if("continue"===(function(){var n=Qt()(e,{uuid:u.uuid});if(n){if(n.deleted)return"continue";a.runWithPermissions(r.componentUuid,c,function(){a.sendContextItemInReply(r.componentUuid,n,r.originalMessage,t)})}})())continue}}},l=S(this.contextStreamObservers);!(o=l()).done;)u(o.value)}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location],n=e.hosted_url,r=e.local_url&&e.local_url.replace("sn://",'');return t.includes(n)||t.includes(r)}},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener('focus',this.detectFocusChange,!0):window.attachEvent('onfocusout',this.detectFocusChange),window.addEventListener?window.addEventListener('blur',this.detectFocusChange,!0):window.attachEvent('onblur',this.detectFocusChange),window.addEventListener('message',this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver(function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()})}},{key:"postActiveThemesToAllComponents",value:function(){for(var e,t=S(this.components);!(e=t()).done;){var n=e.value;this.findOrCreateDataForComponent(n.uuid).window&&this.postActiveThemesToComponent(n)}}},{key:"getActiveThemes",value:function(){if(this.environment===he.Mobile)throw Error('getActiveThemes must be handled separately by mobile');return this.componentsForArea(L.ComponentArea.Themes).filter(function(e){return e.active})}},{key:"urlsForActiveThemes",value:function(){for(var e,t=[],n=S(this.getActiveThemes());!(e=n()).done;){var r=e.value,a=this.urlForComponent(r);a&&t.push(a)}return t}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()},n={action:E.ActivateThemes,data:t};this.sendMessageToComponent(e,n)}},{key:"findComponent",value:function(e){return this.templateComponents.find(function(t){return t.uuid===e})||this.itemManager.findItem(e)}},{key:"addTemporaryTemplateComponent",value:function(e){this.templateComponents.push(e)}},{key:"removeTemporaryTemplateComponent",value:function(e){this.templateComponents=this.templateComponents.filter(function(t){return t.uuid!==e.uuid})}},{key:"contextItemDidChangeInArea",value:function(e){for(var t,n=S(this.handlers);!(t=n()).done;){var r=t.value;if(r.areas.includes(e)||r.areas.includes(L.ComponentArea.Any))for(var a,i=S(this.contextStreamObservers.filter(function(t){return t.area===e}));!(a=i()).done;){var s=a.value;if(r.contextRequestHandler){var o=r.contextRequestHandler(s.componentUuid);o&&this.sendContextItemInReply(s.componentUuid,o,s.originalMessage)}}}}},{key:"isComponentHidden",value:function(e){return!0===this.findOrCreateDataForComponent(e.uuid).hidden}},{key:"setComponentHidden",value:function(e,t){var n=this.findOrCreateDataForComponent(e.uuid);if(t)n.hidden=!0;else if(n.hidden){n.hidden=!1;var r=Qt()(this.contextStreamObservers,{identifier:e.uuid});r&&this.handleStreamContextItemMessage(e,r.originalMessage);var a=Qt()(this.streamObservers,{identifier:e.uuid});a&&this.handleStreamItemsMessage(e,a.originalMessage)}}},{key:"jsonForItem",value:function(e,t,n){var r=n===ht.a.RemoteSaved||n===ht.a.LocalSaved||n===ht.a.PreSyncSave,a=(e.getDomainData(rn)||{})[t.getClientDataKey()]||{},i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.serverUpdatedAt,deleted:e.deleted,isMetadataUpdate:r,content:e.content,clientData:a};return this.responseItemsByRemovingPrivateProperties([i],t)[0]}},{key:"sendItemsInReply",value:function(e,t,n,r){var a=this,i=this.findComponent(e);this.log('Component manager send items in reply',i,t,n);var s={},o=t.map(function(e){return a.jsonForItem(e,i,r)});s.items=o,this.replyToMessage(i,n,s)}},{key:"sendContextItemInReply",value:function(e,t,n,r){var a=this.findComponent(e);this.log('Component manager send context item in reply','component:',a,'item: ',t,'originalMessage: ',n);var i={item:this.jsonForItem(t,a,r)};this.replyToMessage(a,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:E.Reply,original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n,r=[E.ComponentRegistered,E.ActivateThemes],a=this.findOrCreateDataForComponent(e.uuid);if(!a.hidden||r.includes(t.action))if(a.window||t.action!==E.Reply){this.log('Component manager send message to component',e,'message: ',t);var i=this.urlForComponent(e);i&&a.window?(i.startsWith('http')||i.startsWith('file')||(i=window.location.href+i),null===(n=a.window)||void 0===n||n.postMessage(this.isMobile?JSON.stringify(t):t,i)):this.alertService.alert("Standard Notes is trying to communicate with ".concat(e.name,", ")+'but an error is occurring. Please restart this extension and try again.')}else this.log('Component has been deallocated in between message send and reply',e,t);else this.log('Component disabled for current item, ignoring messages.',e.name)}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(!t)return null;if(this.isMobile){var n=this.platform===fe.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter(function(t){return t.hosted_url===e||t.legacy_url===e})[0]}},{key:"sessionKeyForComponent",value:function(e){return this.findOrCreateDataForComponent(e.uuid).sessionKey}},{key:"componentForSessionKey",value:function(e){for(var t,n=this,r=function(r){var a=n.componentState[r];if((null===a||void 0===a?void 0:a.sessionKey)===e)return t=n.components.find(function(e){return e.uuid===r}),"break"},a=0,i=Object.keys(this.componentState);a<i.length;a++){if("break"===r(i[a]))break}if(!t)for(var s,o=S(this.handlers);!(s=o()).done;){var c=s.value;if(c.componentForSessionKeyHandler&&(t=c.componentForSessionKeyHandler(e)))break}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log('Component not defined for message, returning',t),void this.alertService.alert("An extension is trying to communicate with Standard Notes, but there is an error establishing a bridge. Please restart the app and try again.");var r=[E.SaveItems,E.AssociateItem,E.DeassociateItem,E.CreateItem,E.CreateItems,E.DeleteItems,E.SetComponentData];if(this.getReadonlyStateForComponent(e).readonly&&r.includes(t.action))this.alertService.alert("The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes."));else{if(t.action===E.StreamItems)this.handleStreamItemsMessage(e,t);else if(t.action===E.StreamContextItem)this.handleStreamContextItemMessage(e,t);else if(t.action===E.SetComponentData)this.handleSetComponentDataMessage(e,t);else if(t.action===E.DeleteItems)this.handleDeleteItemsMessage(e,t);else if(t.action===E.CreateItems||t.action===E.CreateItem)this.handleCreateItemsMessage(e,t);else if(t.action===E.SaveItems)this.handleSaveItemsMessage(e,t);else if(t.action===E.ToggleActivateComponent){var a=this.itemManager.findItem(t.data.uuid);this.handleToggleComponentMessage(a)}else t.action===E.RequestPermissions?this.handleRequestPermissionsMessage(e,t):t.action===E.InstallLocalComponent?this.handleInstallLocalComponentMessage(e,t):t.action===E.DuplicateItem&&this.handleDuplicateItemMessage(e,t);for(var i,s=function(r){r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes(L.ComponentArea.Any))&&n.timeout(function(){r.actionHandler(e,t.action,t.data)})},o=S(this.handlers);!(i=o()).done;){s(i.value)}}}},{key:"responseItemsByRemovingPrivateProperties",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&this.isNativeExtension(t))return e;var r=['autoupdateDisabled','permissions','active'];return n&&(r=r.concat(['hosted_url','local_url'])),e.map(function(e){var t=r.slice();if(n&&e.content_type!==F.a.ServerExtension&&t.push('url'),!e.content||Object(_.A)(e.content))return e;for(var a={},i=0,s=Object.entries(e.content);i<s.length;i++){var o=s[i],c=l(o,2),u=c[0],p=c[1];t.includes(u)||(a[u]=p)}return Zt(Zt({},e),{},{content:a})})}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=t.data.content_types.filter(function(e){return nn.includes(e)}).sort(),a=[{name:E.StreamItems,content_types:r}];this.runWithPermissions(e.uuid,a,function(){Qt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t,contentTypes:r});for(var a,i=[],s=S(r);!(a=s()).done;){var o=a.value;Object(_.o)(i,n.itemManager.nonErroredItemsForContentType(o))}n.sendItemsInReply(e.uuid,i,t)})}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:E.StreamContextItem}];this.runWithPermissions(e.uuid,r,function(){Qt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t});for(var r,a=S(n.handlersForArea(e.area));!(r=a()).done;){var i=r.value;if(i.contextRequestHandler){var s=i.contextRequestHandler(e.uuid);s&&n.sendContextItemInReply(e.uuid,s,t)}}})}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){for(var t,n=[],r=S(this.handlersForArea(e.area));!(t=r()).done;){var a=t.value;if(a.contextRequestHandler){var i=a.contextRequestHandler(e.uuid);i&&n.push(i.uuid)}}return n}},{key:"handlersForArea",value:function(e){return this.handlers.filter(function(t){return t.areas.includes(e)})}},{key:"handleSaveItemsMessage",value:function(e,t){for(var n,r=this,a=t.data.items,i=[],s=this.itemIdsInContextJurisdictionForComponent(e),o=a.slice(),c=S(a.slice());!(n=c()).done;){var u=n.value;if(s.includes(u.uuid)){i.push({name:E.StreamContextItem}),Object(_.M)(o,u);break}}if(o.length>0){var l=$t()(o.map(function(e){return e.content_type})).sort();i.push({name:E.StreamItems,content_types:l})}this.runWithPermissions(e.uuid,i,function(){var n,i,s,o,c,u,l,p,d,h,f,v,y,g,m;return b.async(function(k){for(;;)switch(k.prev=k.next){case 0:a=r.responseItemsByRemovingPrivateProperties(a,e,!0),n=Object(Ke.b)(a),i=r.itemManager.findItems(n,!0),s=0,o=0,c=S(i);case 6:if((u=c()).done){k.next=13;break}if(l=u.value){k.next=10;break}return k.abrupt("continue",11);case 10:l.locked&&(at()(a,{uuid:l.uuid}),s++,l.content_type===F.a.Note&&o++);case 11:k.next=6;break;case 13:if(1!==o){k.next=18;break}return r.alertService.alert('The note you are attempting to save has editing disabled','Note has Editing Disabled'),k.abrupt("return");case 18:if(!(s>0)){k.next=23;break}return p=1===s?'item':o===s?'notes':'items',d=1===s?'has':'have',r.alertService.alert("".concat(s," ").concat(p," you are attempting to save ").concat(d," editing disabled."),'Items have Editing Disabled'),k.abrupt("return");case 23:h=a.map(function(e){return Object(Ee.f)(e,ht.a.ComponentRetrieved)}),f=S(h);case 25:if((v=f()).done){k.next=38;break}if(y=v.value,g=r.itemManager.findItem(y.uuid)){k.next=34;break}return m=nt(y),k.next=32,b.awrap(r.itemManager.insertItem(m));case 32:k.next=36;break;case 34:if(y.content_type===g.content_type){k.next=36;break}throw Error('Extension is trying to modify content type of item.');case 36:k.next=25;break;case 38:return k.next=40,b.awrap(r.itemManager.changeItems(n,function(t){var n=Object(_.O)(h,{uuid:t.getUuid()});t.mergePayload(n);var r=Object(_.O)(a,{uuid:t.getUuid()});if(r.clientData){var i=Object(_.a)(t.getItem().getDomainData(rn)||{});i[e.getClientDataKey()]=r.clientData,t.setDomainData(i,rn)}},T.c.UserInteraction,ht.a.ComponentRetrieved,e.uuid));case 40:r.syncService.sync().then(function(){var n=w({},t);n.action=E.SaveSuccess,r.replyToMessage(e,t,{}),r.handleMessage(e,n)}).catch(function(){var n=w({},t);n.action=E.SaveError,r.replyToMessage(e,t,{error:E.SaveError}),r.handleMessage(e,n)});case 41:case"end":return k.stop()}},null,null,null,Promise)})}},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,a=this.itemManager.findItem(r.uuid),i=[{name:E.StreamItems,content_types:[a.content_type]}];this.runWithPermissions(e.uuid,i,function(){var r;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(n.itemManager.duplicateItem(a.uuid));case 2:r=i.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(r,e)});case 5:case"end":return i.stop()}},null,null,null,Promise)})}},{key:"handleCreateItemsMessage",value:function(e,t){var n=this,r=t.data.item?[t.data.item]:t.data.items,a=$t()(r.map(function(e){return e.content_type})),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:r=n.responseItemsByRemovingPrivateProperties(r,e),a=[],i=function(t){var r,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(t.uuid){o.next=4;break}return o.next=3,b.awrap(I.GenerateUuid());case 3:t.uuid=o.sent;case 4:return r=Object(Ee.f)(t,ht.a.ComponentCreated),i=nt(r),o.next=8,b.awrap(n.itemManager.insertItem(i));case 8:return s=o.sent,o.next=11,b.awrap(n.itemManager.changeItem(s.uuid,function(n){if(t.clientData){var r=Object(_.a)(s.getDomainData(rn)||{});r[e.getClientDataKey()]=t.clientData,n.setDomainData(r,rn)}},T.c.UserInteraction,ht.a.ComponentCreated,e.uuid));case 11:a.push(s);case 12:case"end":return o.stop()}},null,null,null,Promise)},s=S(r);case 4:if((o=s()).done){l.next=10;break}return c=o.value,l.next=8,b.awrap(i(c));case 8:l.next=4;break;case 10:n.syncService.sync(),u=t.action===E.CreateItem?{item:n.jsonForItem(a[0],e)}:{items:a.map(function(t){return n.jsonForItem(t,e)})},n.replyToMessage(e,t,u);case 13:case"end":return l.stop()}},null,null,null,Promise)})}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=t.data.items.filter(function(e){return nn.includes(e.content_type)}),a=$t()(r.map(function(e){return e.content_type})).sort(),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return i=1===(a=r).length?'item':'items',s=null,p.next=5,b.awrap(n.alertService.confirm("Are you sure you want to delete ".concat(a.length," ").concat(i,"?")));case 5:if(!p.sent){p.next=25;break}o=S(a);case 8:if((c=o()).done){p.next=21;break}if(u=c.value,l=n.itemManager.findItem(u.uuid)){p.next=14;break}return n.alertService.alert('The item you are trying to delete cannot be found.'),p.abrupt("continue",19);case 14:if(![F.a.Component,F.a.Theme].includes(l.content_type)){p.next=17;break}return p.next=17,b.awrap(n.deactivateComponent(l.uuid));case 17:return p.next=19,b.awrap(n.itemManager.setItemToBeDeleted(l.uuid,ht.a.ComponentRetrieved));case 19:p.next=8;break;case 21:n.syncService.sync(),s={deleted:!0},p.next=26;break;case 25:s={deleted:!1};case 26:n.replyToMessage(e,t,s);case 27:case"end":return p.stop()}},null,null,null,Promise)})}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,t.data.permissions,function(){n.replyToMessage(e,t,{approved:!0})})}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,[],function(){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(n.itemManager.changeComponent(e.uuid,function(e){e.componentData=t.data.componentData}));case 2:n.syncService.sync();case 3:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"handleToggleComponentMessage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.toggleComponent(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"toggleComponent",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.area!==L.ComponentArea.Modal){s.next=4;break}this.openModalComponent(e),s.next=29;break;case 4:if(!e.active){s.next=9;break}return s.next=7,b.awrap(this.deactivateComponent(e.uuid));case 7:s.next=29;break;case 9:if(e.content_type!==F.a.Theme){s.next=27;break}return t=e,n=this.getActiveThemes(),s.next=14,b.awrap(this.activateComponent(e.uuid));case 14:if(t.isLayerable()){s.next=25;break}return s.next=17,b.awrap(Object(_.P)(10));case 17:r=S(n);case 18:if((a=r()).done){s.next=25;break}if(!(i=a.value)||i.isLayerable()){s.next=23;break}return s.next=23,b.awrap(this.deactivateComponent(i.uuid));case 23:s.next=18;break;case 25:s.next=29;break;case 27:return s.next=29,b.awrap(this.activateComponent(e.uuid));case 29:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.itemManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){var r=this.findComponent(e);t=Object(_.a)(t);for(var a,i=r.permissions,s=function(e){var n=i.find(function(t){return t.name===e.name});if(!n)return"continue";var r=e.content_types;if(!r)return Object(_.p)(t,e),"continue";for(var a,s=S(n.content_types);!(a=s()).done;){var o=a.value;Object(_.M)(r,o)}0===r.length&&Object(_.p)(t,e)},o=S(t.slice());!(a=o()).done;)s(a.value);t.length>0?this.promptForPermissions(r,t,function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:e&&n();case 1:case"end":return t.stop()}},null,null,null,Promise)}):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,a={component:e,permissions:t,permissionsString:this.permissionsStringForPermissions(t,e),actionBlock:n,callback:function(n){var i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(i=r.findComponent(e.uuid),!n){p.next=9;break}for(r.log('Changing component to expand permissions',e),s=Object(_.a)(i.permissions),o=function(e){var t=s.find(function(t){return t.name===e.name});if(t){var n=t.content_types||[];t.content_types=$t()(n.concat(e.content_types))}else s.push(e)},c=S(t);!(u=c()).done;)l=u.value,o(l);return p.next=8,b.awrap(r.itemManager.changeItem(e.uuid,function(e){e.permissions=s}));case 8:r.syncService.sync();case 9:r.permissionDialogs=r.permissionDialogs.filter(function(r){if(r===a)return r.actionBlock&&r.actionBlock(n),!1;var i;return!!(r.component!==e||r.permissions!==t&&(i=t,r.permissions.some(function(e){return!i.find(function(t){return JSON.stringify(t)===JSON.stringify(e)})})))||(n&&r.actionBlock&&r.actionBlock(n),!1)}),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 11:case"end":return p.stop()}},null,null,null,Promise)}},i=Qt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(a),i?this.log('Existing dialog, not presenting.'):this.presentPermissionsDialog(a)}},{key:"presentPermissionsDialog",value:function(e){throw'Must override SNComponentManager.presentPermissionsDialog'}},{key:"openModalComponent",value:function(e){throw'Must override SNComponentManager.openModalComponent'}},{key:"registerHandler",value:function(e){var t=this;return this.handlers.push(e),function(){var n=Qt()(t.handlers,{identifier:e.identifier});n?Object(_.M)(t.handlers,n):t.log('Attempting to deregister non-existing handler')}}},{key:"findOrCreateDataForComponent",value:function(e){var t=this.componentState[e];return t||(t={},this.componentState[e]=t),t}},{key:"setReadonlyStateForComponent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.findOrCreateDataForComponent(e.uuid);r.readonly=t,r.lockReadonly=n}},{key:"getReadonlyStateForComponent",value:function(e){var t=this.findOrCreateDataForComponent(e.uuid);return{readonly:t.readonly,lockReadonly:t.lockReadonly}}},{key:"registerComponentWindow",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return(n=this.findOrCreateDataForComponent(e.uuid)).window===t&&this.log('Web > componentManager','attempting to re-register same component window.'),this.log('Web > componentManager > registerComponentWindow','component: ',e,'window: ',t),n.window=t,r.next=6,b.awrap(I.GenerateUuid());case 6:n.sessionKey=r.sent,this.sendMessageToComponent(e,{action:E.ComponentRegistered,sessionKey:n.sessionKey,componentData:e.componentData,data:{uuid:e.uuid,environment:(s=this.environment,o=void 0,(g(o={},he.Web,'web'),g(o,he.Desktop,'desktop'),g(o,he.Mobile,'mobile'),o)[s]),platform:(a=this.platform,i=void 0,(g(i={},fe.MacWeb,'mac-web'),g(i,fe.MacDesktop,'mac-desktop'),g(i,fe.LinuxWeb,'linux-web'),g(i,fe.LinuxDesktop,'linux-desktop'),g(i,fe.WindowsWeb,'windows-web'),g(i,fe.WindowsDesktop,'windows-desktop'),g(i,fe.Ios,'ios'),g(i,fe.Android,'android'),i)[a]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(e),this.desktopManager&&this.desktopManager.notifyComponentActivation(e);case 10:case"end":return r.stop()}var a,i,s,o},null,this,null,Promise)}},{key:"activateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Activating component',e),(t=this.findComponent(e)).active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!0}));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"onComponentIframeDestroyed",value:function(e){this.deregisterComponent(e)}},{key:"deregisterComponent",value:function(e){this.log('Degregistering component',e),delete this.componentState[e],this.streamObservers=this.streamObservers.filter(function(t){return t.componentUuid!==e}),this.contextStreamObservers=this.contextStreamObservers.filter(function(t){return t.componentUuid!==e});var t=this.findComponent(e);(null===t||void 0===t?void 0:t.area)===L.ComponentArea.Themes&&this.postActiveThemesToAllComponents()}},{key:"deactivateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Deactivating component',e),null===(t=this.findComponent(e))||void 0===t||!t.active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!1}));case 5:this.findOrCreateDataForComponent(e).sessionKey=void 0,this.deregisterComponent(e);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deleteComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isComponentActive",value:function(e){return e.active}},{key:"allComponentIframes",value:function(){return this.isMobile?[]:Array.from(document.getElementsByTagName('iframe'))}},{key:"iframeForComponent",value:function(e){for(var t,n=S(this.allComponentIframes());!(t=n()).done;){var r=t.value;if(r.dataset.componentId===e)return r}}},{key:"handleSetSizeEvent",value:function(e,t){var n=function(e,n){var r=Object(_.A)(n.width)?n.width:"".concat(t.width,"px"),a=Object(_.A)(n.height)?n.height:"".concat(t.height,"px");e&&e.setAttribute('style',"width:".concat(r,"; height:").concat(a,";"))};if(e.area===L.ComponentArea.Rooms||e.area===L.ComponentArea.Modal){var r=e.area===L.ComponentArea.Rooms?'inner':'outer',a=document.getElementById("component-content-".concat(r,"-").concat(e.uuid));a&&n(a,t)}else{var i=this.iframeForComponent(e.uuid);if(!i)return;if(n(i,t),e.area===L.ComponentArea.EditorStack){var s=i.parentElement;s&&n(s,t)}}}},{key:"editorForNote",value:function(e){for(var t,n,r=S(this.componentsForArea(L.ComponentArea.Editor));!(t=r()).done;){var a=t.value;if(a.isExplicitlyEnabledForItem(e.uuid))return a}return this.isMobile?e.mobilePrefersPlainEditor||(n=this.getDefaultEditor()):e.prefersPlainEditor||(n=this.getDefaultEditor()),n&&!n.isExplicitlyDisabledForItem(e.uuid)?n:void 0}},{key:"getDefaultEditor",value:function(){var e=this.componentsForArea(L.ComponentArea.Editor);return this.isMobile?e.filter(function(e){return e.isMobileDefault})[0]:e.filter(function(e){return e.isDefaultEditor()})[0]}},{key:"permissionsStringForPermissions",value:function(e,t){if(0===e.length)return'.';var n=[],r=[];return e.forEach(function(e){switch(e.name){case E.StreamItems:if(!e.content_types)return;e.content_types.forEach(function(e){var t=Object(F.c)(e);t?n.push("".concat(t,"s")):n.push("items of type ".concat(e))});break;case E.StreamContextItem:var a,i=(g(a={},L.ComponentArea.EditorStack,'working note'),g(a,L.ComponentArea.NoteTags,'working note'),g(a,L.ComponentArea.Editor,'working note'),a);r.push(i[t.area])}}),n=$t()(n),r=$t()(r),0===n.length&&0===r.length?'.':n.concat(r).join(', ')+'.'}},{key:"isDesktop",get:function(){return this.environment===he.Desktop}},{key:"isMobile",get:function(){return this.environment===he.Mobile}},{key:"components",get:function(){var e=this.itemManager.getDisplayableItems(F.a.Component),t=this.itemManager.getDisplayableItems(F.a.Theme);return e.concat(t)}}]),n})(R.a),sn=(function(e){d(n,e);var t=k(n);function n(){var e;return v(this,n),(e=t.call(this)).changeObservers=[],e.emitQueue=[],e.overwriteProtection=[F.a.ItemsKey],e.collection=new mt,e}return y(n,[{key:"getMasterCollection",value:function(){return bt.FromCollection(this.collection)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.changeObservers.length=0,this.resetState()}},{key:"resetState",value:function(){this.collection=new mt}},{key:"find",value:function(e){return this.collection.findAll(e)}},{key:"emitCollection",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.emitPayloads(e.all(),e.source,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"emitPayload",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.emitPayloads([e],t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitPayloads",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return 0===e.length&&console.warn('Attempting to emit 0 payloads.'),a.abrupt("return",new Promise(function(a){r.emitQueue.push({payloads:e,source:t,sourceKey:n,resolve:a}),1===r.emitQueue.length&&r.popQueue()}));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"popQueue",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=this.emitQueue[0],t=this.mergePayloadsOntoMaster(e.payloads),n=t.changed,r=t.inserted,a=t.discarded,i=t.ignored,this.notifyChangeObservers(n,r,a,i,e.source,e.sourceKey),Object(_.M)(this.emitQueue,e),e.resolve(n.concat(r,a)),this.emitQueue.length>0&&this.popQueue();case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"mergePayloadsOntoMaster",value:function(e){for(var t,n=[],r=[],a=[],i=[],s=S(e);!(t=s()).done;){var o=t.value;if(o.uuid&&o.content_type){var c=this.collection.find(o.uuid);if(o.errorDecrypting&&c&&!c.errorDecrypting&&this.overwriteProtection.includes(o.content_type))i.push(o);else{var u=c?Object(Ee.g)(c,o):o;u.discardable?(this.collection.discard(u),a.push(u)):(this.collection.set(u),c?n.push(u):r.push(u))}}else console.error('Payload is corrupt:',o)}return{changed:n,inserted:r,discarded:a,ignored:i}}},{key:"addObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var a={types:e,priority:r,callback:t};return this.changeObservers.push(a),function(){Object(_.M)(n.changeObservers,a)}}},{key:"notifyChangeObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return t.includes(F.a.Any)?e.slice():e.slice().filter(function(e){return t.includes(e.content_type)})},c=S(this.changeObservers.slice().sort(function(e,t){return e.priority<t.priority?-1:1}));!(s=c()).done;){var u=s.value;u.callback(o(e,u.types),o(t,u.types),o(n,u.types),o(r,u.types),a,i)}}},{key:"importPayloads",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new Dt(this.getMasterCollection(),bt.WithPayloads(e,ht.a.FileImport),void 0),r.next=3,b.awrap(t.resultingCollection());case 3:return n=r.sent,r.next=6,b.awrap(this.emitCollection(n));case 6:return r.abrupt("return",Object(Ke.b)(n.payloads));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removePayloadLocally",value:function(e){this.collection.discard(e)}}]),n})(R.a),on=n(9),cn=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).itemManager=e,a.syncService=r,a.resolveQueue=[],a.registeredPredicates=[],a.itemManager=e,a.syncService=r,a.addObservers(),a}return y(n,[{key:"deinit",value:function(){this.syncService=void 0,this.itemManager=void 0,this.resolveQueue.length=0,this.registeredPredicates.length=0,this.removeItemObserver(),this.removeItemObserver=void 0,this.removeSyncObserver(),this.removeSyncObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"popResolveQueue",value:function(){var e=this.resolveQueue.slice();return this.resolveQueue=[],e}},{key:"addObservers",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n){if(t.length>0){var r=t.filter(function(e){return e.errorDecryptingValueChanged});r.length>0&&(e.resolveQueue=e.resolveQueue.concat(r))}n.length>0&&(e.resolveQueue=e.resolveQueue.concat(n))}),this.removeSyncObserver=this.syncService.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==on.a.DownloadFirstSyncCompleted&&t!==on.a.FullSyncCompleted){n.next=3;break}return n.next=3,b.awrap(e.resolveSingletonsForItems(e.popResolveQueue(),t));case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"registerPredicate",value:function(e){this.registeredPredicates.push(e)}},{key:"validItemsMatchingPredicate",value:function(e){return this.itemManager.itemsMatchingPredicate(e).filter(function(e){return!e.errorDecrypting})}},{key:"resolveSingletonsForItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=this;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:n=function(e){for(var t,n=S(p.registeredPredicates);!(t=n()).done;){var r=t.value;if(e.satisfiesPredicate(r))return p.validItemsMatchingPredicate(r)}},r=function(e){return e.isSingleton?p.validItemsMatchingPredicate(e.singletonPredicate):null},a=function(e){var t=r(e);return t&&t.length>0?t:n(e)},i=[],s=S(e);case 5:if((o=s()).done){d.next=17;break}if(c=o.value,!i.includes(c)){d.next=9;break}return d.abrupt("continue",15);case 9:if(u=a(c),Object(_.o)(i,u||[]),u&&!(u.length<=1)){d.next=13;break}return d.abrupt("continue",15);case 13:return d.next=15,b.awrap(this.handleStrategy(u,c.singletonStrategy));case 15:d.next=5;break;case 17:if(!(i.length>0&&t===on.a.FullSyncCompleted)){d.next=20;break}return d.next=20,b.awrap(null===(l=this.syncService)||void 0===l?void 0:l.sync());case 20:case"end":return d.stop()}},null,this,null,Promise)}},{key:"handleStrategy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t===T.e.KeepEarliest){a.next=2;break}throw'Unhandled singleton strategy';case 2:return n=e.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at<t.created_at?-1:1}),r=Object(_.d)(n,0),a.next=6,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(r)));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"findSingleton",value:function(e){var t=this.validItemsMatchingPredicate(e);if(t.length>0)return t[0]}},{key:"findOrCreateSingleton",value:function(e,t,n){var r,a,i,s,o,c,u,l=this;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(r=this.findSingleton(e),Object(_.w)(r)){p.next=3;break}return p.abrupt("return",r);case 3:if(this.syncService.getLastSyncDate()){p.next=13;break}return i=this.itemManager.addObserver(t,function(t,n){if(n.length>0){var r=l.itemManager.subItemsMatchingPredicates(n,[e]);r.length>0&&(a=r[0])}}),p.next=7,b.awrap(this.syncService.sync());case 7:if(i(),!a){p.next=10;break}return p.abrupt("return",a);case 10:if(!((s=this.validItemsMatchingPredicate(e)).length>0)){p.next=13;break}return p.abrupt("return",s[0]);case 13:if(!(o=this.itemManager.itemsMatchingPredicate(e).filter(function(e){return e.errorDecrypting})).length){p.next=17;break}return p.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(o)));case 17:return p.t0=Object(Ee.e),p.next=20,b.awrap(I.GenerateUuid());case 20:return p.t1=p.sent,p.t2=t,p.t3=n,p.t4=new Date,p.t5={uuid:p.t1,content_type:p.t2,content:p.t3,dirty:!0,dirtiedDate:p.t4},c=(0,p.t0)(p.t5),p.next=28,b.awrap(this.itemManager.emitItemFromPayload(c));case 28:return u=p.sent,this.syncService.sync(),p.abrupt("return",u);case 31:case"end":return p.stop()}},null,this,null,Promise)}}]),n})(R.a);function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach(function(t){pn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dn,hn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c){var u;return v(this,n),(u=t.call(this)).itemManager=e,u.alertService=r,u.previousPasswords=[],u.itemManager=e,u.alertService=r,u.deviceInterface=a,u.httpService=i,u.payloadManager=s,u.protocolService=o,u.syncService=c,u.previousPasswords=[],u}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.alertService=void 0,this.deviceInterface=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.syncService=void 0,this.previousPasswords.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"getExtensions",value:function(){return this.itemManager.nonErroredItemsForContentType(F.a.ActionsExtension)}},{key:"extensionsInContextOfItem",value:function(e){return this.getExtensions().filter(function(t){return t.supported_types.includes(e.content_type)||t.actionsWithContextForItem(e).length>0})}},{key:"loadExtensionInContextOfItem",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n={content_type:t.content_type,item_uuid:t.uuid},u.next=3,b.awrap(this.httpService.getAbsolute(e.url,n).catch(function(e){return console.error('Error loading extension',e),null}));case 3:if(r=u.sent){u.next=6;break}return u.abrupt("return");case 6:return a=r.description||e.description,i=r.supported_types||e.supported_types,s=r.actions?r.actions.map(function(e){return new ae(e)}):[],(o=new se(e,T.c.UserInteraction)).deprecation=r.deprecation,o.description=a,o.supported_types=i,o.actions=s,c=o.getResult(),u.abrupt("return",nt(c));case 16:case"end":return u.stop()}},null,this,null,Promise)}},{key:"runAction",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=e.verb,a.next='get'===a.t0?3:'render'===a.t0?7:'show'===a.t0?11:'post'===a.t0?15:19;break;case 3:return a.next=5,b.awrap(this.handleGetAction(e,n));case 5:return r=a.sent,a.abrupt("break",20);case 7:return a.next=9,b.awrap(this.handleRenderAction(e,n));case 9:return r=a.sent,a.abrupt("break",20);case 11:return a.next=13,b.awrap(this.handleShowAction(e));case 13:return r=a.sent,a.abrupt("break",20);case 15:return a.next=17,b.awrap(this.handlePostAction(e,t));case 17:return r=a.sent,a.abrupt("break",20);case 19:return a.abrupt("break",20);case 20:return a.abrupt("return",r);case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleGetAction",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.alertService.confirm("Are you sure you want to replace the current note contents with this action's results?"));case 2:if(!n.sent){n.next=7;break}return n.abrupt("return",this.runConfirmedGetAction(e,t));case 7:return n.abrupt("return",{error:{status:1,message:'Action canceled by user.'}});case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"runConfirmedGetAction",value:function(e,t){var n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.httpService.getAbsolute(e.url).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return a.alertService.alert(t.message),{error:t}}));case 2:if(!(n=i.sent).error){i.next=5;break}return i.abrupt("return",n);case 5:return i.next=7,b.awrap(this.payloadByDecryptingResponse(n,t));case 7:return r=i.sent,i.next=10,b.awrap(this.payloadManager.emitPayload(Object(Ee.b)(r,{dirty:!0,dirtiedDate:new Date}),ht.a.RemoteActionRetrieved));case 10:return this.syncService.sync(),i.abrupt("return",ln(ln({},n),{},{item:n.item}));case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleRenderAction",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.httpService.getAbsolute(e.url).then(function(e){var n,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(r.payloadByDecryptingResponse(e,t));case 2:if(!(n=i.sent)){i.next=6;break}return a=nt(n),i.abrupt("return",ln(ln({},e),{},{item:a}));case 6:case"end":return i.stop()}},null,null,null,Promise)}).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return r.alertService.alert(t.message),{error:t}}));case 2:return n=a.sent,a.abrupt("return",n);case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingResponse",value:function(e,t,n){var r,a,i,s,o,c,u,l,p,d,h,f=arguments;return b.async(function(v){for(;;)switch(v.prev=v.next){case 0:return r=f.length>3&&void 0!==f[3]?f[3]:[],a=Object(Ee.e)(e.item),v.next=4,b.awrap(this.protocolService.payloadByDecryptingPayload(a,n));case 4:if((i=v.sent).errorDecrypting){v.next=7;break}return v.abrupt("return",i);case 7:if(s=e.keyParams||e.auth_params){v.next=11;break}return this.alertService.alert("We were unable to decrypt this revision using your current keys, and this revision is missing metadata that would allow us to try different keys to decrypt it. This can likely be fixed with some manual intervention. Please email hello@standardnotes.org for assistance."),v.abrupt("return",void 0);case 11:o=this.protocolService.createKeyParams(s),c=S(this.previousPasswords);case 13:if((u=c()).done){v.next=30;break}if(l=u.value,!r.includes(l)){v.next=17;break}return v.abrupt("continue",28);case 17:return r.push(l),v.next=20,b.awrap(this.protocolService.computeRootKey(l,o));case 20:if(p=v.sent){v.next=23;break}return v.abrupt("continue",28);case 23:return v.next=25,b.awrap(this.payloadByDecryptingResponse(e,t,p,r));case 25:if(!(d=v.sent)){v.next=28;break}return v.abrupt("return",d);case 28:v.next=13;break;case 30:return v.next=32,b.awrap(t());case 32:if(h=v.sent,!this.previousPasswords.includes(h)){v.next=35;break}return v.abrupt("return",void 0);case 35:return this.previousPasswords.push(h),v.abrupt("return",this.payloadByDecryptingResponse(e,t,n));case 37:case"end":return v.stop()}},null,this,null,Promise)}},{key:"handlePostAction",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=e.access_type===q.Decrypted,s.next=3,b.awrap(this.outgoingPayloadForItem(t,n));case 3:return r=s.sent,a={items:[r]},s.abrupt("return",this.httpService.postAbsolute(e.url,a).then(function(e){return e}).catch(function(e){return console.error('Action error response:',e),i.alertService.alert('An issue occurred while processing this action. Please try again.'),e}));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleShowAction",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.deviceInterface.openUrl(e.url),t.abrupt("return",{});case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"outgoingPayloadForItem",value:function(e){var t,n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=a.length>1&&void 0!==a[1]&&a[1],n=t?Re.b.FileDecrypted:Re.b.FileEncrypted,i.next=4,b.awrap(this.protocolService.payloadByEncryptingPayload(e.payloadRepresentation(),n));case 4:return r=i.sent,i.abrupt("return",r.ejected());case 6:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),fn=(function(){function e(t,n,r){v(this,e),this.deviceInterface=t,this.identifier=n,this.environment=r}return y(e,null,[{key:"version",value:function(){throw Error('Must override')}}]),e})(),vn=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getJsonParsedRawStorageValue(D.AllAccountKeyParamsKey));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getRawKeychainValue());case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getRawStorageValue('mk'));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!!Pe(this.environment)}}],[{key:"version",value:function(){return"1.0.0"}}]),n})(),yn=(function(){function e(t){v(this,e),this.services=t,this.stageHandlers={},this.registerStageHandlers()}return y(e,[{key:"registerStageHandler",value:function(e,t){this.stageHandlers[e]=t}},{key:"markDone",value:function(){var e;null===(e=this.onDoneHandler)||void 0===e||e.call(this),this.onDoneHandler=void 0}},{key:"promptForPasscodeUntilCorrect",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new ye([new ge(te.None)],ne.Migration,!1),r.abrupt("return",new Promise(function(r){n.services.challengeService.addChallengeObserver(t,{onNonvalidatedSubmit:function(a){var i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return i=a.values[0],s=i.value,o.next=4,b.awrap(e(s));case 4:o.sent?(n.services.challengeService.completeChallenge(t),r(s)):n.services.challengeService.setValidationStatusForChallenge(t,i,!1);case 6:case"end":return o.stop()}},null,null,null,Promise)}}),n.services.challengeService.promptForChallengeResponse(t)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}},{key:"onDone",value:function(e){this.onDoneHandler=e}},{key:"handleStage",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t=this.stageHandlers[e])){n.next=4;break}return n.next=4,b.awrap(t());case 4:case"end":return n.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){throw'Must override'}}]),e})();!(function(e){e.CreatedAt="created_at",e.UpdatedAt="userModifiedDate",e.Title="title"})(dn||(dn={}));var gn=(function(e){d(n,mt);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).displaySortBy={},e.displayFilter={},e.filteredMap={},e.sortedMap={},e}return y(n,[{key:"set",value:function(e){e=Object(_.W)(Array.isArray(e)?e:[e],'uuid'),p(f(n.prototype),"set",this).call(this,e),this.filterSortElements(e)}},{key:"discard",value:function(e){e=Array.isArray(e)?e:[e],p(f(n.prototype),"discard",this).call(this,e),this.filterSortElements(e)}},{key:"setDisplayOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn.CreatedAt,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc',r=arguments.length>3?arguments[3]:void 0,a=this.displaySortBy[e],i=this.displayFilter[e];if(!a||a.key!==t||a.dir!==n||i||r){this.displaySortBy[e]=t?{key:t,dir:n}:void 0,this.displayFilter[e]=r,this.filteredMap[e]={},this.sortedMap[e]=[];var s=this.all(e);s.length>0&&this.filterSortElements(s)}}},{key:"displayElements",value:function(e){var t=this.sortedMap[e];if(!t)throw Error("Attempting to access display elements for\n        non-configured content type ".concat(e));return t.slice()}},{key:"filterSortElements",value:function(e){if(0!==Object.keys(this.displaySortBy).length){for(var t,n=new Set,r=S(e);!(t=r()).done;){var a=t.value,i=a.content_type,s=this.displaySortBy[i];if(s){var o=this.displayFilter[i],c=this.filteredMap[i],u=this.sortedMap[i],l=c[a.uuid],p=Object(_.w)(l)?void 0:u[l];if(!(a.deleted||!this.map[a.uuid])&&(!o||o(a)))if(Object(_.w)(p))u.push(a),n.add(i);else{var d=p.errorDecrypting?void 0:p[s.key],h=a[s.key];u[l]=a;var f=p.pinned!==a.pinned;Object(_.g)(d,h)&&!f||n.add(i)}else Object(_.w)(l)||(delete c[a.uuid],u[l]=void 0,n.add(i))}}for(var v,y=S(n.values());!(v=y()).done;){var g=v.value;this.resortContentType(g)}}}},{key:"resortContentType",value:function(e){for(var t,n=this.sortedMap[e],r=this.displaySortBy[e],a=this.filteredMap[e],i=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t)return-1;if(!n)return 1;if(!a){if(t.pinned&&n.pinned)return e(t,n,!0);if(t.pinned)return-1;if(n.pinned)return 1}var i=t[r.key]||'',s=n[r.key]||'',o=1;return'asc'===r.dir&&(o*=-1),r.key===dn.Title?o*i.localeCompare(s,'en',{numeric:!0}):i>s?-1*o:i<s?1*o:0},s=[],o=0,c=S(n.sort(function(e,t){return i(e,t)}));!(t=c()).done;){var u=t.value;u&&(s.push(u),a[u.uuid]=o,o++)}this.sortedMap[e]=s}}]),n})();function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(n),!0).forEach(function(t){wn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=(function(e){d(n,yn);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).legacyReader=new vn(r.services.deviceInterface,r.services.identifier,r.services.environment),r}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Se(e.services.environment)){t.next=5;break}return t.next=3,b.awrap(e.migrateStorageStructureForWebDesktop());case 3:t.next=8;break;case 5:if(!Pe(e.services.environment)){t.next=8;break}return t.next=8,b.awrap(e.migrateStorageStructureForMobile());case 8:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.StorageDecrypted_09,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.migrateArbitraryRawStorageToManagedStorageAllPlatforms());case 2:if(!Pe(e.services.environment)){t.next=5;break}return t.next=5,b.awrap(e.migrateMobilePreferences());case 5:return t.next=7,b.awrap(e.migrateSessionStorage());case 7:return t.next=9,b.awrap(e.deleteLegacyStorageValues());case 9:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.LoadingDatabase_11,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createDefaultItemsKeyForAllPlatforms());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"migrateStorageStructureForWebDesktop",value:function(){var e,t,n,r,a,i,s,c,u,l,p,d,h,f,v,y,m,w,k,x,S;return b.async(function(P){for(;;)switch(P.prev=P.next){case 0:return t=this.services.deviceInterface,g(e={},_e.Wrapped,{}),g(e,_e.Unwrapped,{}),g(e,_e.Nonwrapped,{}),n=e,P.next=4,b.awrap(this.legacyReader.getAccountKeyParams());case 4:return(r=P.sent)&&(n.nonwrapped[o.RootKeyParams]=r),P.next=8,b.awrap(t.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 8:if(!(a=P.sent)){P.next=37;break}return i=Object(Ee.e)(a),P.next=13,b.awrap(this.webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage(i));case 13:if(s=P.sent,c=s.key,u=s.decryptedStoragePayload,l=s.keyParams,n.nonwrapped[o.RootKeyWrapperKeyParams]=l.getPortableValue(),p=Object(_.a)(u.contentObject.storage),d=Object(_.E)(p),h=d[D.AllAccountKeyParamsKey],n.nonwrapped[o.RootKeyParams]=h,f=c,!!Object(_.w)(d.mk)){P.next=32;break}return P.next=27,b.awrap(this.webDesktopHelperExtractAndWrapAccountKeysFromValueStore(c,h,d));case 27:v=P.sent,y=v.accountKey,m=v.wrappedKey,f=y,n.nonwrapped[o.WrappedRootKey]=m;case 32:return P.next=34,b.awrap(this.webDesktopHelperEncryptStorage(f,u,d));case 34:n.wrapped=P.sent,P.next=55;break;case 37:return P.next=39,b.awrap(this.services.deviceInterface.getRawStorageValue('ak'));case 39:return w=P.sent,P.next=42,b.awrap(this.services.deviceInterface.getRawStorageValue('mk'));case 42:if(k=P.sent,!w&&!k){P.next=55;break}if(P.t0=null===r||void 0===r?void 0:r.version,P.t0){P.next=49;break}return P.next=48,b.awrap(this.getFallbackRootKeyVersion());case 48:P.t0=P.sent;case 49:return x=P.t0,P.next=52,b.awrap(Ve.Create({masterKey:k,dataAuthenticationKey:w,version:x,keyParams:r}));case 52:return S=P.sent,P.next=55,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(S.getKeychainValue(),this.services.identifier));case 55:return P.next=57,b.awrap(this.allPlatformHelperSetStorageStructure(n));case 57:case"end":return P.stop()}},null,this,null,Promise)}},{key:"allPlatformHelperSetStorageStructure",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Ie.defaultValuesObject(e.wrapped,e.unwrapped,e.nonwrapped))[_e.Unwrapped]=void 0,n.next=4,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.StorageObject),JSON.stringify(t)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.WebPasscodeParamsKey));case 2:return t=s.sent,n=this.services.protocolService.createKeyParams(t),s.next=6,b.awrap(this.promptForPasscodeUntilCorrect(function(t){return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(i.services.protocolService.computeRootKey(t,n));case 2:return a=s.sent,s.next=5,b.awrap(i.services.protocolService.payloadByDecryptingPayload(e,a));case 5:return r=s.sent,s.abrupt("return",!r.errorDecrypting);case 7:case"end":return s.stop()}},null,null,null,Promise)}));case 6:return s.abrupt("return",{decryptedStoragePayload:r,key:a,keyParams:n});case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperExtractAndWrapAccountKeysFromValueStore",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.t0=null===t||void 0===t?void 0:t.version,c.t0){c.next=5;break}return c.next=4,b.awrap(this.getFallbackRootKeyVersion());case 4:c.t0=c.sent;case 5:return a=c.t0,c.next=8,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:a,keyParams:t}));case 8:if(i=c.sent,delete n.mk,delete n.pw,delete n.ak,s=Object(Ee.e)(i),!e){c.next=17;break}return c.next=16,b.awrap(this.services.protocolService.payloadByEncryptingPayload(s,Re.b.LocalStorageEncrypted,e));case 16:o=c.sent;case 17:return c.abrupt("return",{accountKey:i,wrappedKey:null===(r=o)||void 0===r?void 0:r.ejected()});case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperEncryptStorage",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.services.protocolService.payloadByEncryptingPayload(Object(Ee.b)(t,{content_type:F.a.EncryptedStorage,content:n}),Re.b.LocalStoragePreferEncrypted,e));case 2:return r=a.sent,a.abrupt("return",r.ejected());case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"migrateStorageStructureForMobile",value:function(){var e,t,n,r,a,i,s,u,l,p,d,h,f,v,y,m,w,k,x,S,P,O,C,E,R=this;return b.async(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,b.awrap(this.services.deviceInterface.getRawKeychainValue());case 2:return n=M.sent,M.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileWrappedRootKeyKey));case 5:if(M.t0=M.sent,M.t0){M.next=8;break}M.t0=null===n||void 0===n?void 0:n.encryptedAccountKeys;case 8:return r=M.t0,M.next=11,b.awrap(this.legacyReader.getAccountKeyParams());case 11:return a=M.sent,M.next=14,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 14:return i=M.sent,M.next=17,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(c.MobileFirstRun));case 17:return s=M.sent,g(t={},_e.Nonwrapped,(g(e={},o.WrappedRootKey,r),g(e,o.RootKeyWrapperKeyParams,Object(_.I)(i,['hash'])),g(e,o.RootKeyParams,a),g(e,c.MobileFirstRun,s),e)),g(t,_e.Unwrapped,{}),g(t,_e.Wrapped,{}),u=t,M.next=21,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileBiometricsPrefs));case 21:return(l=M.sent)&&(u.nonwrapped[o.BiometricsState]=l.enabled,u.nonwrapped[o.MobileBiometricsTiming]=l.timing),M.next=25,b.awrap(this.services.deviceInterface.getRawStorageValue(D.MobilePasscodeKeyboardType));case 25:if((p=M.sent)&&(u.nonwrapped[o.MobilePasscodeKeyboardType]=p),!i){M.next=75;break}if(h=this.services.protocolService.createKeyParams(i),f=function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(R.promptForPasscodeUntilCorrect(function(t){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(R.services.protocolService.computeRootKey(t,h));case 2:if(e=u.sent,!(i=null===n||void 0===n?void 0:null===(a=n.offline)||void 0===a?void 0:a.pw)){u.next=8;break}return u.abrupt("return",e.serverPassword===i);case 8:if(!r){u.next=15;break}return u.next=11,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),e));case 11:return s=u.sent,u.abrupt("return",!s.errorDecrypting);case 15:return u.next=17,b.awrap(R.services.deviceInterface.getAllRawDatabasePayloads(R.services.identifier));case 17:if(o=u.sent[0]){u.next=20;break}throw Error('Passcode only migration aborting due to missing keychain.offline.pw');case 20:return u.next=22,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(o),e));case 22:return c=u.sent,u.abrupt("return",!c.errorDecrypting);case 24:case"end":return u.stop()}},null,null,null,Promise)}));case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},null,null,null,Promise)},u.nonwrapped[o.MobilePasscodeTiming]=null===n||void 0===n?void 0:null===(d=n.offline)||void 0===d?void 0:d.timing,!r){M.next=55;break}return M.next=34,b.awrap(f());case 34:return v=M.sent,M.next=37,b.awrap(this.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),v));case 37:if(y=M.sent,m=y.contentObject.accountKeys,M.t1=m.version||(null===a||void 0===a?void 0:a.version),M.t1){M.next=44;break}return M.next=43,b.awrap(this.getFallbackRootKeyVersion());case 43:M.t1=M.sent;case 44:return w=M.t1,k=Object(Ee.b)(y,{content:{masterKey:m.mk,dataAuthenticationKey:m.ak,version:w,keyParams:a,accountKeys:void 0}}),M.next=48,b.awrap(this.services.protocolService.payloadByEncryptingPayload(k,Re.b.LocalStoragePreferEncrypted,v));case 48:return x=M.sent,u.nonwrapped[o.WrappedRootKey]=x.ejected(),m.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",m.jwt),M.next=53,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 53:M.next=73;break;case 55:if(r){M.next=73;break}return M.next=58,b.awrap(f());case 58:return S=M.sent,M.t2=Object(Ee.e),M.next=62,b.awrap(I.GenerateUuid());case 62:return M.t3=M.sent,M.t4=Object(Ke.a)(u.unwrapped),M.t5=F.a.EncryptedStorage,M.t6={uuid:M.t3,content:M.t4,content_type:M.t5},P=(0,M.t2)(M.t6),M.next=69,b.awrap(this.services.protocolService.payloadByEncryptingPayload(P,Re.b.LocalStoragePreferEncrypted,S));case 69:return O=M.sent,u.wrapped=O.ejected(),M.next=73,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 73:M.next=89;break;case 75:if(!!Object(_.w)(null===n||void 0===n?void 0:n.mk)){M.next=89;break}if(M.t7=n.version||(null===a||void 0===a?void 0:a.version),M.t7){M.next=82;break}return M.next=81,b.awrap(this.getFallbackRootKeyVersion());case 81:M.t7=M.sent;case 82:return C=M.t7,M.next=85,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:C,keyParams:a}));case 85:return E=M.sent,M.next=88,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(E.getKeychainValue(),this.services.identifier));case 88:n.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",n.jwt);case 89:return M.next=91,b.awrap(this.allPlatformHelperSetStorageStructure(u));case 91:case"end":return M.stop()}},null,this,null,Promise)}},{key:"getFallbackRootKeyVersion",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.services.deviceInterface.getAllRawDatabasePayloads(this.services.identifier));case 2:if(e=n.sent[0]){n.next=5;break}return n.abrupt("return",Q.a.V002);case 5:return t=Object(Ee.e)(e),n.abrupt("return",t.version||Q.a.V002);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateArbitraryRawStorageToManagedStorageAllPlatforms",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getAllRawStorageKeyValues());case 2:e=p.sent,t=Object(_.H)(D),n=function(e){try{return JSON.parse(e)}catch(t){return e}},r=this.services.identifier,a=S(e);case 7:if((i=a()).done){p.next=20;break}if(s=i.value,o=s.key,c=s.value,u=r&&r.length>0&&o.startsWith(r),!t.includes(o)&&!u){p.next=14;break}return p.abrupt("continue",18);case 14:if(Object(_.w)(c)){p.next=18;break}return l=n(c),p.next=18,b.awrap(this.services.storageService.setValue(o,l));case 18:p.next=7;break;case 20:case"end":return p.stop()}},null,this,null,Promise)}},{key:"deleteLegacyStorageValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e=['mk','ak','pw','encryptionKey','authKey','jwt','ephemeral','cachedThemes'],t=[].concat(m(Object(_.H)(o)),m(Object(_.H)(D)),e),n=S(t);case 3:if((r=n()).done){i.next=9;break}return a=r.value,i.next=7,b.awrap(this.services.deviceInterface.removeRawStorageValue(a));case 7:i.next=3;break;case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"migrateMobilePreferences",value:function(){var e,t,n,r,a,i,s,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileLastExportDate));case 2:return e=p.sent,p.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileDoNotWarnUnsupportedEditors));case 5:return t=p.sent,p.next=8,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileOptionsState));case 8:return n=p.sent,r={},n&&(u=n.sortBy,r={sortBy:'updated_at'===u||'client_updated_at'===u?dn.UpdatedAt:u,sortReverse:null!==(a=n.sortReverse)&&void 0!==a&&a,hideNotePreview:null!==(i=n.hidePreviews)&&void 0!==i&&i,hideDate:null!==(s=n.hideDates)&&void 0!==s&&s,hideTags:null!==(c=n.hideTags)&&void 0!==c&&c}),l=bn(bn({},r),{},{lastExportDate:null!==e&&void 0!==e?e:void 0,doNotShowAgainUnsupportedEditors:null!==t&&void 0!==t&&t}),p.next=14,b.awrap(this.services.storageService.setValue(o.MobilePreferences,l));case 14:case"end":return p.stop()}},null,this,null,Promise)}},{key:"migrateSessionStorage",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return e='user',i.next=3,b.awrap(this.services.storageService.getValue("jwt"));case 3:return t=i.sent,i.next=6,b.awrap(this.services.storageService.getValue(e));case 6:if(n=i.sent,t||n&&(t=n.jwt),t){i.next=15;break}if(!!Object(_.w)(n)){i.next=14;break}t='junk-value',i.next=15;break;case 14:return i.abrupt("return");case 15:return r=new Ae(t),i.next=18,b.awrap(this.services.storageService.setValue(o.Session,r));case 18:if(!Pe(this.services.environment)){i.next=25;break}return i.next=21,b.awrap(this.services.storageService.getValue(e));case 21:if(!(a=i.sent)||!a.server){i.next=25;break}return i.next=25,b.awrap(this.services.storageService.setValue(o.ServerHost,a.server));case 25:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createDefaultItemsKeyForAllPlatforms",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e=this.services.protocolService.getRootKey())){i.next=18;break}return i.next=4,b.awrap(this.services.protocolService.getRootKeyParams());case 4:return t=i.sent,n=Q.a.V001,i.t0=Object(Ee.e),i.next=9,b.awrap(I.GenerateUuid());case 9:return i.t1=i.sent,i.t2=F.a.ItemsKey,i.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t.version||n}),i.t4=new Date,i.t5={uuid:i.t1,content_type:i.t2,content:i.t3,dirty:!0,dirtiedDate:i.t4},r=(0,i.t0)(i.t5),a=nt(r),i.next=18,b.awrap(this.services.itemManager.emitItemFromPayload(a.payloadRepresentation(),ht.a.LocalChanged));case 18:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return"2.0.0"}}]),n})(),xn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createNewDefaultItemsKeyIfNecessary());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"createNewDefaultItemsKeyIfNecessary",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.services.protocolService.needsNewRootKeyBasedItemsKey()){e.next=3;break}return e.next=3,b.awrap(this.services.protocolService.createNewDefaultItemsKey());case 3:case"end":return e.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.0.15'}}]),n})(),Sn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.FullSyncCompleted_13,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteBatchManagerSingleton());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteBatchManagerSingleton",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e='org.standardnotes.batch-manager',t=H.a.CompoundPredicate([new H.a('content_type','=',F.a.Component),new H.a('package_info.identifier','=',e)]),!(n=this.services.singletonManager.findSingleton(t))){r.next=6;break}return r.next=6,b.awrap(this.services.itemManager.setItemToBeDeleted(n.uuid));case 6:case"end":return r.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.7.0'}}]),n})(),Pn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteMfaItems());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteMfaItems",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e='SF|MFA',t=this.services.itemManager.getItems(e),n=S(t);case 3:if((r=n()).done){i.next=10;break}return a=r.value,this.services.itemManager.removeItemLocally(a),i.next=8,b.awrap(this.services.storageService.deletePayloadWithId(a.uuid));case 8:i.next=3;break;case 10:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.20.0'}}]),n})(),On=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getStorage",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=O(this.identifier,s.StorageObject),r.next=3,b.awrap(this.deviceInterface.getRawStorageValue(e));case 3:return t=r.sent,n=t?JSON.parse(t):void 0,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getNonWrappedValue",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getStorage());case 2:if(n=r.sent){r.next=5;break}return r.abrupt("return",void 0);case 5:return r.abrupt("return",null===(t=n[_e.Nonwrapped])||void 0===t?void 0:t[e]);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getNonWrappedValue(o.RootKeyParams));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getNonWrappedValue(o.WrappedRootKey));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!0}}],[{key:"version",value:function(){return"2.0.0"}}]),n})();function Cn(e){for(var t,n=S(Object.values(i).sort(function(e,t){return-1*P(e.version(),t.version())}));!(t=n()).done;){var r=t.value;if(r.version()===e)return r;if(x(r.version(),e))return r}throw Error("Cannot find reader for version ".concat(e))}function Dn(e,t,n,r){return new(Cn(e))(t,n,r)}var _n=(function(e){d(n,yn);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).didPreRun=!1,e}return y(n,[{key:"preRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storeVersionNumber());case 2:this.didPreRun=!0;case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.needsKeychainRepair());case 2:if(!t.sent){t.next=5;break}return t.next=5,b.awrap(e.repairMissingKeychain());case 5:e.markDone();case 6:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"getStoredVersion",value:function(){var e=O(this.services.identifier,s.SnjsVersion);return this.services.deviceInterface.getRawStorageValue(e)}},{key:"storeVersionNumber",value:function(){var e,t,n,r,a,i,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return e=O(this.services.identifier,s.SnjsVersion),c.next=3,b.awrap(this.getStoredVersion());case 3:if(c.sent){c.next=38;break}t=!1,n=0,r=['migrations','ephemeral','user','cachedThemes','syncToken','encryptedStorage'];case 8:if(!(n<r.length)){c.next=19;break}return a=r[n],c.next=12,b.awrap(this.services.deviceInterface.getRawStorageValue(a));case 12:if(!c.sent){c.next=16;break}return t=!0,c.abrupt("break",19);case 16:n++,c.next=8;break;case 19:if(!t){c.next=24;break}return c.next=22,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"1.0.0"));case 22:c.next=38;break;case 24:return i=O(this.services.identifier,"last_migration_timestamp"),c.next=27,b.awrap(this.services.deviceInterface.getRawStorageValue(i));case 27:if(o=c.sent,!!Object(_.w)(o)){c.next=36;break}return c.next=32,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"2.0.0"));case 32:return c.next=34,b.awrap(this.services.deviceInterface.removeRawStorageValue("last_migration_timestamp"));case 34:c.next=38;break;case 36:return c.next=38,b.awrap(this.services.deviceInterface.setRawStorageValue(e,h));case 38:case"end":return c.stop()}},null,this,null,Promise)}},{key:"loadReader",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.reader){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,b.awrap(this.getStoredVersion());case 4:e=t.sent,this.reader=Dn(e,this.services.deviceInterface,this.services.identifier,this.services.environment);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"needsKeychainRepair",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.didPreRun){t.next=2;break}throw Error('Attempting to access specialized function before prerun');case 2:if(this.reader){t.next=5;break}return t.next=5,b.awrap(this.loadReader());case 5:if(this.reader.usesKeychain){t.next=8;break}return t.abrupt("return",!1);case 8:return t.next=10,b.awrap(this.reader.getAccountKeyParams());case 10:if(e=t.sent,!Object(_.w)(e)){t.next=14;break}return t.abrupt("return",!1);case 14:return t.next=16,b.awrap(this.reader.hasPasscode());case 16:if(!t.sent){t.next=19;break}return t.abrupt("return",!1);case 19:return t.next=21,b.awrap(this.reader.hasNonWrappedAccountKeys());case 21:if(!t.sent){t.next=24;break}return t.abrupt("return",!1);case 24:return t.abrupt("return",!0);case 25:case"end":return t.stop()}},null,this,null,Promise)}},{key:"repairMissingKeychain",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getStoredVersion());case 2:return e=a.sent,a.next=5,b.awrap(this.reader.getAccountKeyParams());case 5:return t=a.sent,n=new ye([new ge(te.None,void 0,j.R.PasswordInputPlaceholder,!0)],ne.Custom,!1,j.I.Title,j.I.Text),a.abrupt("return",new Promise(function(a){r.services.challengeService.addChallengeObserver(n,{onNonvalidatedSubmit:function(i){var s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return s=i.values[0].value,o=r.services.protocolService.createKeyParams(t),d.next=4,b.awrap(r.services.protocolService.computeRootKey(s,o));case 4:return c=d.sent,d.next=7,b.awrap(r.services.deviceInterface.getAllRawDatabasePayloads(r.services.identifier));case 7:if(u=d.sent,(l=u.find(function(e){var t=Object(Ee.e)(e);return Object(Re.a)(t.content_type)}))||(l=u[0]),l){d.next=12;break}throw we.a.error(Error('Attempting keychain recovery validation but no items present.'));case 12:return d.next=14,b.awrap(r.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(l),c));case 14:if(!d.sent.errorDecrypting){d.next=19;break}r.services.challengeService.setValidationStatusForChallenge(n,i.values[0],!1),d.next=29;break;case 19:if("1.0.0"!==e){d.next=24;break}return d.next=22,b.awrap(r.services.deviceInterface.legacy_setRawKeychainValue({mk:c.masterKey,ak:c.dataAuthenticationKey,version:o.version}));case 22:d.next=27;break;case 24:return p=c.getKeychainValue(),d.next=27,b.awrap(r.services.deviceInterface.setNamespacedKeychainValue(p,r.services.identifier));case 27:a(),r.services.challengeService.completeChallenge(n);case 29:case"end":return d.stop()}},null,null,null,Promise)}}),r.services.challengeService.promptForChallengeResponse(n)}));case 8:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(),En=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).services=e,r}return y(n,[{key:"deinit",value:function(){this.services=void 0,this.activeMigrations&&(this.activeMigrations.length=0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.runBaseMigrationPreRun());case 2:return r.t0=b,r.t1=n,r.next=6,b.awrap(this.getStoredSnjsVersion());case 6:return r.t2=r.sent,r.t3=r.t1.getRequiredMigrations.call(r.t1,r.t2),r.next=10,r.t0.awrap.call(r.t0,r.t3);case 10:if(e=r.sent,this.activeMigrations=this.instantiateMigrationClasses(e),!(this.activeMigrations.length>0)){r.next=17;break}Object(_.F)(this.activeMigrations).onDone(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(t.markMigrationsAsDone());case 2:case"end":return e.stop()}},null,null,null,Promise)}),r.next=19;break;case 17:return r.next=19,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 19:case"end":return r.stop()}},null,this,null,Promise)}},{key:"markMigrationsAsDone",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"runBaseMigrationPreRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.baseMigration=new _n(this.services),e.next=3,b.awrap(this.baseMigration.preRun());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:return t.next=4,b.awrap(this.handleStage(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleApplicationEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.a.SignedIn){t.next=3;break}return t.next=3,b.awrap(this.handleStage(ve.SignedIn_30));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPendingMigrations",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=n,t.next=4,b.awrap(this.getStoredSnjsVersion());case 4:return t.t2=t.sent,t.t3=t.t1.getRequiredMigrations.call(t.t1,t.t2),t.next=8,t.t0.awrap.call(t.t0,t.t3);case 8:if(e=t.sent,t.t4=e.length>0,t.t4){t.next=14;break}return t.next=13,b.awrap(this.baseMigration.needsKeychainRepair());case 13:t.t4=t.sent;case 14:return t.abrupt("return",t.t4);case 15:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getStoredSnjsVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.services.deviceInterface.getRawStorageValue(O(this.services.identifier,s.SnjsVersion)));case 2:if(e=t.sent){t.next=5;break}throw we.a.error(Error('Snjs version missing from storage, run base migration.'));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"instantiateMigrationClasses",value:function(e){var t=this;return e.map(function(e){return new e(t.services)})}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.baseMigration.handleStage(e));case 2:t=S(this.activeMigrations);case 3:if((n=t()).done){a.next=9;break}return r=n.value,a.next=7,b.awrap(r.handleStage(e));case 7:a.next=3;break;case 9:case"end":return a.stop()}},null,this,null,Promise)}}],[{key:"getRequiredMigrations",value:function(e){var t,n,r,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:t=[],n=Object.keys(a).map(function(e){return a[e]}).sort(function(e,t){return P(e.version(),t.version())}),r=S(n);case 3:if((i=r()).done){c.next=11;break}if(s=i.value,(o=s.version())!==e){c.next=8;break}return c.abrupt("continue",9);case 8:x(e,o)&&t.push(s);case 9:c.next=3;break;case 11:return c.abrupt("return",t);case 12:case"end":return c.stop()}},null,null,null,Promise)}}]),n})(R.a),Rn=n(14),In=(function(){function e(t){v(this,e),this.crypto=t}return y(e,[{key:"firstHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"secondHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"splitKey",value:function(e,t){for(var n=e.length/t,r=[],a=0;a<t;a++){var i=e.slice(n*a,n*(a+1));r.push(i)}return r}},{key:"createItemsKey",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.generateNewItemsKeyContent());case 2:return e=n.sent,n.t0=Object(Ee.e),n.next=6,b.awrap(I.GenerateUuid());case 6:return n.t1=n.sent,n.t2=F.a.ItemsKey,n.t3=Object(Ke.a)(e),n.t4={uuid:n.t1,content_type:n.t2,content:n.t3},t=(0,n.t0)(n.t4),n.abrupt("return",nt(t));case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,n){var r,a,i;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==ue.a.DecryptedBareObject){n.next=4;break}return n.abrupt("return",Object(Ee.c)({content:e.content}));case 4:if(t!==ue.a.DecryptedBase64String){n.next=13;break}return r=JSON.stringify(e.content),n.next=8,b.awrap(this.crypto.base64Encode(r));case 8:return a=n.sent,i=Q.a.V000Base64Decrypted+a,n.abrupt("return",Object(Ee.c)({content:i}));case 13:throw"Must override generateEncryptedParameters to handle format ".concat(t,".");case 14:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var n,r,a,i;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=e.format)!==ue.a.DecryptedBareObject){t.next=5;break}return t.abrupt("return",e);case 5:if(n!==ue.a.DecryptedBase64String){t.next=20;break}return r=e.contentString.substring(Q.a.VersionLength,e.contentString.length),t.prev=7,t.next=10,b.awrap(this.crypto.base64Decode(r));case 10:i=t.sent,a=JSON.parse(i),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),a=e.content;case 17:return t.abrupt("return",Object(Ee.a)(e,{content:a}));case 20:throw Error("Must override generateDecryptedParameters to handle format ".concat(n,"."));case 21:case"end":return t.stop()}},null,this,[[7,14]],Promise)}}]),e})(),Mn='00000000000000000000000000000000',An=(function(e){d(n,In);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'AES-256'}},{key:"generateNewItemsKeyContent",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=Rn.a.EncryptionKeyLength,r.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=r.sent,n={itemsKey:t,version:Q.a.V001},r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Rn.a.PbkdfMinCost,o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.a.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+'SN'+a));case 6:return i=o.sent,s=Object(A.a)({email:e,pw_cost:r,pw_nonce:a,pw_salt:i,version:Q.a.V001,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcDecrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"encryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcEncrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c,u,l;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){d.next=2;break}return d.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){d.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r){d.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return d.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.a.EncryptionKeyLength));case 8:return a=d.sent,d.next=11,b.awrap(this.encryptString(a,r.itemsKey));case 11:return i=d.sent,d.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=d.sent,d.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=d.sent,d.next=20,b.awrap(this.encryptString(JSON.stringify(e.content),s));case 20:return c=d.sent,u=r.keyVersion+c,d.next=24,b.awrap(this.crypto.hmac256(u,o));case 24:return l=d.sent,d.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:u,enc_item_key:i,auth_hash:l}));case 26:case"end":return d.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){l.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:return a=e.enc_item_key,a=this.version+a,i=this.encryptionComponentsFromString(a,t.itemsKey),l.next=11,b.awrap(this.decryptString(i.ciphertext,i.key));case 11:if(s=l.sent){l.next=15;break}return console.error('Error decrypting parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 15:return l.next=17,b.awrap(this.firstHalfOfKey(s));case 17:return o=l.sent,c=this.encryptionComponentsFromString(e.contentString,o),l.next=21,b.awrap(this.decryptString(c.ciphertext,c.key));case 21:if(u=l.sent){l.next=26;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 27:case"end":return l.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString",value:function(e,t){var n=e.substring(0,Q.a.VersionLength);return{ciphertext:e.substring(Q.a.VersionLength,e.length),version:n,key:t}}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content001.pw_salt,t.content001.pw_cost,Rn.a.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,2),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],version:Q.a.V001,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V001}}]),n})();function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach(function(t){Kn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=(function(e){d(n,An);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.b.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V002},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Object(_.F)(Rn.b.PbkdfCostsUsed),o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.b.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+':'+a));case 6:return i=o.sent,s=Object(A.b)({email:e,pw_nonce:a,pw_cost:r,pw_salt:i,version:Q.a.V002,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcDecrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcEncrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptTextParams",value:function(e,t,n,r,a,i){var s,o,c,u,l,p,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,b.awrap(this.crypto.generateRandomKey(Rn.b.EncryptionIvLength));case 2:return s=h.sent,h.next=5,b.awrap(this.encryptString002(e,t,s));case 5:return o=h.sent,c=[a,r,s,o].join(':'),h.next=9,b.awrap(this.crypto.hmac256(c,n));case 9:if(u=h.sent,l=[a,u,r,s,o],!i){h.next=16;break}return h.next=14,b.awrap(this.crypto.base64Encode(JSON.stringify(i.content)));case 14:p=h.sent,l.push(p);case 16:return d=l.join(':'),h.abrupt("return",d);case 18:case"end":return h.stop()}},null,this,null,Promise)}},{key:"decryptTextParams",value:function(e,t,n,r,a,i){var s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n){o.next=2;break}throw'Attempting to decryptTextParams with null encryptionKey';case 2:return o.next=4,b.awrap(this.crypto.hmac256(e,i));case 4:if(s=o.sent,!1!==this.crypto.timingSafeEqual(a,s)){o.next=8;break}return we.a.error(Error('Auth hash does not match.')),o.abrupt("return",null);case 8:return o.abrupt("return",this.decryptString002(t,n,r));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(t=this.encryptionComponentsFromString002(e.enc_item_key),n=t.keyParams){i.next=4;break}return i.abrupt("return",void 0);case 4:return i.t0=JSON,i.next=7,b.awrap(this.crypto.base64Decode(n));case 7:return i.t1=i.sent,r=i.t0.parse.call(i.t0,i.t1),a=Tn({},r),i.abrupt("return",a);case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r&&r.itemsKey){u.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return u.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.b.EncryptionKeyLength));case 8:return a=u.sent,u.next=11,b.awrap(this.encryptTextParams(a,r.itemsKey,r.dataAuthenticationKey,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 11:return i=u.sent,u.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=u.sent,u.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=u.sent,u.next=20,b.awrap(this.encryptTextParams(JSON.stringify(e.content),s,o,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 20:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:c,enc_item_key:i}));case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u,l,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){h.next=3;break}return h.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){h.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:if(t&&t.itemsKey){h.next=8;break}throw Error('Attempting to generateDecryptedParameters with no itemsKey.');case 8:return a=e.enc_item_key,i=this.encryptionComponentsFromString002(a,t.itemsKey,t.dataAuthenticationKey),h.next=12,b.awrap(this.decryptTextParams(i.ciphertextToAuth,i.contentCiphertext,i.encryptionKey,i.iv,i.authHash,i.authKey));case 12:if(s=h.sent){h.next=16;break}return console.error('Error decrypting item_key parameters',e),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 16:return h.next=18,b.awrap(this.firstHalfOfKey(s));case 18:return o=h.sent,h.next=21,b.awrap(this.secondHalfOfKey(s));case 21:return c=h.sent,u=this.encryptionComponentsFromString002(e.contentString,o,c),h.next=25,b.awrap(this.decryptTextParams(u.ciphertextToAuth,u.contentCiphertext,u.encryptionKey,u.iv,u.authHash,u.authKey));case 25:if(l=h.sent){h.next=30;break}return h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 30:return h.prev=30,h.t0=JSON,h.next=34,b.awrap(this.crypto.base64Decode(u.keyParams));case 34:h.t1=h.sent,d=h.t0.parse.call(h.t0,h.t1),h.next=40;break;case 38:h.prev=38,h.t2=h.catch(30);case 40:return h.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(l),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,auth_params:d,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 41:case"end":return h.stop()}},null,this,[[30,38]],Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content002.pw_salt,t.content002.pw_cost,Rn.b.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,3),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],dataAuthenticationKey:r[2],version:Q.a.V002,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString002",value:function(e,t,n){var r=e.split(':');return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],keyParams:r[5],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(':'),encryptionKey:t,authKey:n}}},{key:"version",get:function(){return Q.a.V002}}]),n})(),Ln=(function(e){d(n,Fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.c.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V003},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.generateSalt(t.content003.identifier,Q.a.V003,Rn.c.PbkdfCost,t.content003.pw_nonce));case 2:return n=s.sent,s.next=5,b.awrap(this.crypto.pbkdf2(e,n,Rn.c.PbkdfCost,Rn.c.PbkdfOutputLength));case 5:return r=s.sent,a=this.splitKey(r,3),s.next=9,b.awrap(Ve.Create({serverPassword:a[0],masterKey:a[1],dataAuthenticationKey:a[2],version:Q.a.V003,keyParams:t.getPortableValue()}));case 9:return i=s.sent,s.abrupt("return",i);case 11:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V003,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.c.SaltSeedLength));case 3:return a=s.sent,i=Object(A.c)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"generateSalt",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.sha256([e,'SF',t,n,r].join(':')));case 2:return a=i.sent,i.abrupt("return",a);case 4:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V003}}]),n})();function Un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach(function(t){Vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bn,Wn=(function(e){d(n,Ln);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'XChaCha20-Poly1305'}},{key:"generateNewItemsKeyContent",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 2:return e=n.sent,t={itemsKey:e,version:Q.a.V004},n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateSalt004",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.crypto.sha256([e,t].join(":")));case 2:return n=r.sent,r.abrupt("return",Object(_.T)(n,Rn.d.ArgonSaltLength));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V004,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.d.ArgonSaltSeedLength));case 3:return a=s.sent,i=Object(A.d)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"encryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n){a.next=2;break}throw'encryptString null nonce';case 2:if(t){a.next=4;break}throw'encryptString null rawKey';case 4:return a.t0=this.crypto,a.t1=e,a.t2=n,a.t3=t,a.next=10,b.awrap(this.authenticatedDataToString(r));case 10:return a.t4=a.sent,a.abrupt("return",a.t0.xchacha20Encrypt.call(a.t0,a.t1,a.t2,a.t3,a.t4));case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.crypto.xchacha20Decrypt(e,n,t,r));case 1:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateEncryptedProtocolString",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionNonceLength));case 2:return r=o.sent,a=Q.a.V004,o.next=6,b.awrap(this.encryptString004(e,t,r,n));case 6:return i=o.sent,o.t0=a,o.t1=r,o.t2=i,o.next=12,b.awrap(this.authenticatedDataToString(n));case 12:return o.t3=o.sent,s=[o.t0,o.t1,o.t2,o.t3],o.abrupt("return",s.join(":"));case 15:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.format===ue.a.EncryptedString){a.next=2;break}throw Error('Attempting to get embedded key params of already decrypted item');case 2:return t=this.deconstructEncryptedPayloadString(e.enc_item_key),n=t.rawAuthenticatedData,a.next=6,b.awrap(this.stringToAuthenticatedData(n));case 6:return r=a.sent,a.abrupt("return",r);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateAuthenticatedDataForPayload",value:function(e,t){var n={u:e.uuid,v:Q.a.V004};if(Object(Re.a)(e.content_type))return Nn(Nn({},n),{},{kp:t.keyParams.content});if(!(t instanceof J))throw Error('Attempting to use non-items key for regular item.');return n}},{key:"authenticatedDataToString",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.base64Encode(JSON.stringify(Object(_.Q)(Object(_.K)(e)))));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"stringToAuthenticatedData",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=JSON,r.next=3,b.awrap(this.crypto.base64Decode(e));case 3:return r.t1=r.sent,n=r.t0.parse.call(r.t0,r.t1),r.abrupt("return",Object(_.Q)(Nn(Nn({},n),t)));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(e.uuid){u.next=6;break}throw'payload.uuid cannot be null';case 6:if(r&&r.itemsKey){u.next=8;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 8:return u.next=10,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 10:return a=u.sent,i=JSON.stringify(e.content),s=this.generateAuthenticatedDataForPayload(e,r),u.next=15,b.awrap(this.generateEncryptedProtocolString(i,a,s));case 15:return o=u.sent,u.next=18,b.awrap(this.generateEncryptedProtocolString(a,r.itemsKey,s));case 18:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:o,enc_item_key:c}));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.uuid){l.next=5;break}throw'encryptedParameters.uuid cannot be null';case 5:if(t&&t.itemsKey){l.next=7;break}throw'Attempting to generateDecryptedParameters with no itemsKey.';case 7:return a=this.deconstructEncryptedPayloadString(e.enc_item_key),l.next=10,b.awrap(this.stringToAuthenticatedData(a.rawAuthenticatedData,{u:e.uuid,v:e.version}));case 10:return i=l.sent,l.next=13,b.awrap(this.authenticatedDataToString(i));case 13:return s=l.sent,l.next=16,b.awrap(this.decryptString004(a.ciphertext,t.itemsKey,a.nonce,s));case 16:if(o=l.sent){l.next=20;break}return console.error('Error decrypting itemKey parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 20:return c=this.deconstructEncryptedPayloadString(e.contentString),l.next=23,b.awrap(this.decryptString004(c.ciphertext,o,c.nonce,s));case 23:if(u=l.sent){l.next=28;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 28:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 29:case"end":return l.stop()}},null,this,null,Promise)}},{key:"deconstructEncryptedPayloadString",value:function(e){var t=e.split(":");return{version:t[0],nonce:t[1],ciphertext:t[2],rawAuthenticatedData:t[3]}}},{key:"deriveKey",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.generateSalt004(t.content004.identifier,t.content004.pw_nonce));case 2:return n=o.sent,o.next=5,b.awrap(this.crypto.argon2(e,n,Rn.d.ArgonIterations,Rn.d.ArgonMemLimit,Rn.d.ArgonOutputKeyBytes));case 5:return r=o.sent,a=this.splitKey(r,2),i=a[0],s=a[1],o.abrupt("return",Ve.Create({masterKey:i,serverPassword:s,version:Q.a.V004,keyParams:t.getPortableValue()}));case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V004}}]),n})();function Hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(n),!0).forEach(function(t){qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e[e.RootKeyNone=0]="RootKeyNone",e[e.RootKeyOnly=1]="RootKeyOnly",e[e.RootKeyPlusWrapper=2]="RootKeyPlusWrapper",e[e.WrapperOnly=3]="WrapperOnly"})(Bn||(Bn={}));var Yn=Q.a.V003,Gn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).itemManager=e,c.payloadManager=r,c.storageService=i,c.identifier=s,c.operators={},c.keyMode=Bn.RootKeyNone,c.keyObservers=[],c.itemManager=e,c.payloadManager=r,c.deviceInterface=a,c.storageService=i,c.crypto=o,Object(_.y)()?I.SetGenerators(c.crypto.generateUUID,void 0):I.SetGenerators(c.crypto.generateUUID,c.crypto.generateUUIDSync),Object.defineProperty(u(c),'rootKey',{enumerable:!1,writable:!0}),c.removeItemsObserver=c.itemManager.addObserver([F.a.ItemsKey],function(e,t){e.concat(t).length>0&&c.decryptErroredItems()}),c}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.deviceInterface=void 0,this.storageService=void 0,this.crypto.deinit(),this.crypto=void 0,this.operators={},this.keyObservers.length=0,this.removeItemsObserver(),this.removeItemsObserver=null,this.rootKey=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:return e=a.sent,a.next=5,b.awrap(this.getAccountKeyParams());case 5:return t=a.sent,a.next=8,b.awrap(this.hasRootKeyWrapper());case 8:if(n=a.sent,r=!Object(_.w)(e)||!Object(_.w)(t),!n||!r){a.next=14;break}this.keyMode=Bn.RootKeyPlusWrapper,a.next=27;break;case 14:if(!n||r){a.next=18;break}this.keyMode=Bn.WrapperOnly,a.next=27;break;case 18:if(n||!r){a.next=22;break}this.keyMode=Bn.RootKeyOnly,a.next=27;break;case 22:if(n||r){a.next=26;break}this.keyMode=Bn.RootKeyNone,a.next=27;break;case 26:throw'Invalid key mode condition';case 27:if(this.keyMode!==Bn.RootKeyOnly){a.next=33;break}return a.next=30,b.awrap(this.getRootKeyFromKeychain());case 30:return this.rootKey=a.sent,a.next=33,b.awrap(this.notifyObserversOfKeyChange());case 33:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getEncryptionSourceVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasAccount()){t.next=4;break}return t.abrupt("return",this.getUserVersion());case 4:if(!this.hasPasscode()){t.next=9;break}return t.next=7,b.awrap(this.getRootKeyWrapperKeyParams());case 7:return e=t.sent,t.abrupt("return",e.version);case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getEncryptionDisplayName",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getEncryptionSourceVersion());case 2:if(!(e=t.sent)){t.next=5;break}return t.abrupt("return",this.operatorForVersion(e).getEncryptionDisplayName());case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLatestVersion",value:function(){return Q.a.V004}},{key:"hasAccount",value:function(){switch(this.keyMode){case Bn.RootKeyNone:case Bn.WrapperOnly:return!1;case Bn.RootKeyOnly:case Bn.RootKeyPlusWrapper:return!0;default:throw Error("Unhandled keyMode value '".concat(this.keyMode,"'."))}}},{key:"getUserVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getAccountKeyParams());case 2:return e=t.sent,t.abrupt("return",null===e||void 0===e?void 0:e.version);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"upgradeAvailable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.accountUpgradeAvailable());case 2:return e=n.sent,n.next=5,b.awrap(this.passcodeUpgradeAvailable());case 5:return t=n.sent,n.abrupt("return",e||t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"accountUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"passcodeUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e.version!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"platformSupportsKeyDerivation",value:function(e){return Object(Q.b)(e.version,Q.a.V004)>=0||(!!Object(_.C)()||Object(_.y)())}},{key:"supportedVersions",value:function(){return[Q.a.V001,Q.a.V002,Q.a.V003,Q.a.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.getLatestVersion();return 1===Object(Q.b)(e,t)}},{key:"isProtocolVersionOutdated",value:function(e){var t,n=(g(t={},Q.a.V001,Date.parse('2018-01-01')),g(t,Q.a.V002,Date.parse('2020-01-01')),t)[e];return!!n&&(new Date).getTime()>n}},{key:"costMinimumForVersion",value:function(e){if(Object(Q.b)(e,Q.a.V003)>=0)throw'Cost minimums only apply to versions <= 002';if(e===Q.a.V001)return Rn.a.PbkdfMinCost;if(e===Q.a.V002)return Rn.b.PbkdfMinCost;throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===Q.a.V001)return new An(this.crypto);if(e===Q.a.V002)return new Fn(this.crypto);if(e===Q.a.V003)return new Ln(this.crypto);if(e===Q.a.V004)return new Wn(this.crypto);if(e===Q.a.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw Error("Unable to find operator for version ".concat(e))}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=t.version,r=this.operatorForVersion(n),a.abrupt("return",r.computeRootKey(e,t));case 3:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return a=r?this.operatorForVersion(r):this.defaultOperator(),i.abrupt("return",a.createRootKey(e,t,n));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"payloadContentFormatForIntent",value:function(e,t){if(t){if(e===Re.b.Sync||e===Re.b.FileEncrypted||e===Re.b.FilePreferEncrypted||e===Re.b.LocalStorageEncrypted||e===Re.b.LocalStoragePreferEncrypted)return ue.a.EncryptedString;throw'Unhandled encrypted case in protocolService.payloadContentFormatForIntent.'}if(e===Re.b.LocalStorageDecrypted||e===Re.b.LocalStoragePreferEncrypted||e===Re.b.FileDecrypted||e===Re.b.FilePreferEncrypted)return ue.a.DecryptedBareObject;if(e===Re.b.SyncDecrypted)return ue.a.DecryptedBase64String;throw'Unhandled decrypted case in protocolService.payloadContentFormatForIntent.'}},{key:"payloadByEncryptingPayload",value:function(e,t,n){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(!e.errorDecrypting){l.next=2;break}return l.abrupt("return",e);case 2:if(!e.deleted){l.next=4;break}return l.abrupt("return",e);case 4:if(!Object(_.w)(t)){l.next=6;break}throw Error('Attempting to encrypt payload with null intent');case 6:if(n||Object(Re.d)(t)){l.next=10;break}return l.next=9,b.awrap(this.keyToUseForEncryptionOfPayload(e,t));case 9:n=l.sent;case 10:if(n||!Object(Re.c)(t)){l.next=12;break}throw Error('Attempting to generate encrypted payload with no key.');case 12:if(e.format===ue.a.DecryptedBareObject){l.next=14;break}throw Error('Attempting to encrypt already encrypted payload.');case 14:if(e.content){l.next=16;break}throw Error('Attempting to encrypt payload with no content.');case 16:if(e.uuid){l.next=18;break}throw Error('Attempting to encrypt payload with no uuid.');case 18:if(!(null!==(r=n)&&void 0!==r&&r.errorDecrypting||null!==(a=n)&&void 0!==a&&a.waitingForKey)){l.next=20;break}throw Error('Attempting to encrypt payload with encrypted key.');case 20:return i=n?n.keyVersion:this.getLatestVersion(),s=this.payloadContentFormatForIntent(t,n),o=this.operatorForVersion(i),l.next=25,b.awrap(o.generateEncryptedParameters(e,s,n));case 25:if(c=l.sent){l.next=28;break}throw'Unable to generate encryption parameters';case 28:return u=Object(Ee.d)(e,t,c),l.abrupt("return",u);case 30:case"end":return l.stop()}},null,this,null,Promise)}},{key:"payloadsByEncryptingPayloads",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){u.next=11;break}return s=i.value,o=Object(_.v)(t)?t(s):t,u.next=7,b.awrap(this.payloadByEncryptingPayload(s,o,n));case 7:c=u.sent,r.push(c);case 9:u.next=2;break;case 11:return u.abrupt("return",r);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingPayload",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content){c.next=3;break}return we.a.error(Error('Attempting to decrypt payload that has no content.')),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0}));case 3:if((r=e.format)!==ue.a.DecryptedBareObject){c.next=6;break}return c.abrupt("return",e);case 6:if(t||r!==ue.a.EncryptedString){c.next=10;break}if(t=this.keyToUseForDecryptionOfPayload(e)){c.next=10;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 10:if(null===(n=t)||void 0===n||!n.errorDecrypting){c.next=12;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 12:return a=e.version,i=e.source,s=this.operatorForVersion(a),c.prev=15,c.next=18,b.awrap(s.generateDecryptedParameters(e,t));case 18:return o=c.sent,c.abrupt("return",Object(Ee.e)(e,o,i));case 22:return c.prev=22,c.t0=c.catch(15),console.error('Error decrypting payload',e,c.t0),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:case"end":return c.stop()}},null,this,[[15,22]],Promise)}},{key:"payloadsByDecryptingPayloads",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e){n.next=2;break}return n.abrupt("return",e);case 2:if(!0!==e.deleted||!Object(_.w)(e.content)){n.next=4;break}return n.abrupt("return",e);case 4:if(Object(_.A)(e.content)){n.next=7;break}return n.abrupt("return",e);case 7:return n.abrupt("return",r.payloadByDecryptingPayload(e,t));case 8:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",Promise.all(e.map(function(e){return n(e)})));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"decryptErroredItems",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==(e=this.itemManager.invalidItems.filter(function(e){return e.content_type!==F.a.ItemsKey})).length){r.next=3;break}return r.abrupt("return");case 3:return t=e.map(function(e){return e.payloadRepresentation()}),r.next=6,b.awrap(this.payloadsByDecryptingPayloads(t));case 6:return n=r.sent,r.next=9,b.awrap(this.payloadManager.emitPayloads(n,ht.a.LocalChanged));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsByDecryptingBackupFile",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v=this;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if(n=e.keyParams||e.auth_params,r=e.items,a=r.map(function(e){return Object(Ee.f)(e,ht.a.FileImport)}),i=[],!n){y.next=28;break}return s=this.createKeyParams(n),y.next=8,b.awrap(this.computeRootKey(t,s));case 8:return o=y.sent,c=a.filter(function(e){return e.content_type===F.a.ItemsKey}),y.next=12,b.awrap(this.payloadsByDecryptingPayloads(c,o));case 12:u=y.sent,l=u.map(function(e){return nt(e)}),Object(_.o)(i,u),p=function(e){var t,n,r,a;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content_type!==F.a.ItemsKey){c.next=2;break}return c.abrupt("return","continue");case 2:return c.prev=2,e.items_key_id&&(t=v.itemsKeyForPayload(e)),t||(n=u.find(function(t){return e.items_key_id===t.uuid}),r=e.version,n?t=nt(n):Object(Q.d)(s.version,Q.a.V004)?t=v.defaultItemsKeyForItemVersion(r,l):Object(Q.b)(r,Q.a.V003)<=0&&(t=o)),c.next=7,b.awrap(v.payloadByDecryptingPayload(e,t));case 7:a=c.sent,i.push(a),c.next=15;break;case 11:c.prev=11,c.t0=c.catch(2),i.push(Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting})),console.error('Error decrypting payload',e,c.t0);case 15:case"end":return c.stop()}},null,null,[[2,11]],Promise)},d=S(a);case 17:if((h=d()).done){y.next=26;break}return f=h.value,y.next=21,b.awrap(p(f));case 21:if("continue"!==y.sent){y.next=24;break}return y.abrupt("continue",24);case 24:y.next=17;break;case 26:y.next=29;break;case 28:i=a;case 29:return y.abrupt("return",i);case 30:case"end":return y.stop()}},null,this,null,Promise)}},{key:"createKeyParams",value:function(e){return Object(A.e)(e)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return t=this.itemManager.items,e===Re.b.FileDecrypted&&(t=t.filter(function(e){return e.content_type!==F.a.ItemsKey})),n=Promise.all(t.map(function(t){if(t.errorDecrypting)return t.payload.ejected();var n=Object(Ee.f)(t.payload,ht.a.FileImport);return i.payloadByEncryptingPayload(n,e).then(function(e){return e.ejected()})})),s.t0=this.getLatestVersion(),s.next=6,b.awrap(n);case 6:if(s.t1=s.sent,r={version:s.t0,items:s.t1},e!==Re.b.FileEncrypted){s.next=13;break}return s.next=11,b.awrap(this.getRootKeyParams());case 11:a=s.sent,r.keyParams=null===a||void 0===a?void 0:a.getPortableValue();case 13:return s.abrupt("return",r);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"onKeyStatusChange",value:function(e){var t=this;return this.keyObservers.push(e),function(){Object(_.M)(t.keyObservers,e)}}},{key:"notifyObserversOfKeyChange",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:e=S(this.keyObservers);case 1:if((t=e()).done){r.next=7;break}return n=t.value,r.next=5,b.awrap(n());case 5:r.next=1;break;case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getRootKeyFromKeychain",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:if(e=n.sent,!Object(_.w)(e)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.t0=b,n.t1=Ve,n.t2=zn,n.t3=zn({},e),n.t4={},n.next=12,b.awrap(this.getRootKeyParams());case 12:return n.t5=n.sent,n.t6={keyParams:n.t5},n.t7=(0,n.t2)(n.t3,n.t4,n.t6),n.t8=n.t1.Create.call(n.t1,n.t7),n.next=18,n.t0.awrap.call(n.t0,n.t8);case 18:return t=n.sent,n.abrupt("return",t);case 20:case"end":return n.stop()}},null,this,null,Promise)}},{key:"saveRootKeyToKeychain",value:function(){var e,t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Object(_.w)(this.rootKey)){n.next=2;break}throw'Attempting to non-existent root key to the keychain.';case 2:if(this.keyMode===Bn.RootKeyOnly){n.next=4;break}throw'Should not be persisting wrapped key to keychain.';case 4:return e=this.rootKey.getKeychainValue(),n.abrupt("return",this.executeCriticalFunction(function(){return t.deviceInterface.setNamespacedKeychainValue(e,t.identifier)}));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasRootKeyWrapper",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){return this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper}},{key:"rootKeyNeedsUnwrapping",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.hasRootKeyWrapper());case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}e.t0=Object(_.w)(this.rootKey);case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyWrapperKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getWrappedRootKey",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.WrappedRootKey,De.Nonwrapped));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode!==Bn.WrapperOnly){e.next=4;break}return e.abrupt("return",this.getRootKeyWrapperKeyParams());case 4:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){e.next=8;break}return e.abrupt("return",this.getAccountKeyParams());case 8:if(this.keyMode!==Bn.RootKeyNone){e.next=12;break}return e.abrupt("return",void 0);case 12:throw"Unhandled key mode for getRootKeyParams ".concat(this.keyMode);case 13:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateWrappingKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:if(t=a.sent,this.keyMode!==Bn.WrapperOnly){a.next=7;break}return a.abrupt("return",this.storageService.canDecryptWithKey(e));case 7:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){a.next=15;break}return n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:return r=a.sent,a.abrupt("return",!r.errorDecrypting);case 15:throw'Unhandled case in validateWrappingKey';case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeWrappingKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=r.sent,r.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=r.sent,r.abrupt("return",n);case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"unwrapRootKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.keyMode!==Bn.WrapperOnly){a.next=3;break}return this.rootKey=e,a.abrupt("return");case 3:if(this.keyMode===Bn.RootKeyPlusWrapper){a.next=5;break}throw'Invalid key mode condition for unwrapping.';case 5:return a.next=7,b.awrap(this.getWrappedRootKey());case 7:return t=a.sent,n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:if(!(r=a.sent).errorDecrypting){a.next=16;break}throw Error('Unable to decrypt root key with provided wrapping key.');case 16:return a.next=18,b.awrap(Ve.Create(r.contentObject,r.uuid));case 18:return this.rootKey=a.sent,a.next=21,b.awrap(this.notifyObserversOfKeyChange());case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setNewRootKeyWrapper",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.keyMode!==Bn.RootKeyNone){t.next=4;break}this.keyMode=Bn.WrapperOnly,t.next=9;break;case 4:if(this.keyMode!==Bn.RootKeyOnly){t.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,t.next=9;break;case 8:throw Error('Attempting to set wrapper on already wrapped key.');case 9:return t.next=11,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 11:if(this.keyMode!==Bn.WrapperOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){t.next=26;break}if(this.keyMode!==Bn.WrapperOnly){t.next=18;break}return this.rootKey=e,t.next=16,b.awrap(this.reencryptItemsKeys());case 16:t.next=20;break;case 18:return t.next=20,b.awrap(this.wrapAndPersistRootKey(e));case 20:return t.next=22,b.awrap(this.storageService.setValue(o.RootKeyWrapperKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 22:return t.next=24,b.awrap(this.notifyObserversOfKeyChange());case 24:t.next=27;break;case 26:throw Error('Invalid keyMode on setNewRootKeyWrapper');case 27:case"end":return t.stop()}},null,this,null,Promise)}},{key:"wrapAndPersistRootKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=Object(Ee.e)(this.rootKey,{content:this.rootKey.persistableValueWhenWrapping()}),r.next=3,b.awrap(this.payloadByEncryptingPayload(t,Re.b.LocalStorageEncrypted,e));case 3:return n=r.sent,r.next=6,b.awrap(this.storageService.setValue(o.WrappedRootKey,n.ejected(),De.Nonwrapped));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removeRootKeyWrapper",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper){e.next=2;break}throw Error('Attempting to remove root key wrapper on unwrapped key.');case 2:return this.keyMode===Bn.WrapperOnly?(this.keyMode=Bn.RootKeyNone,this.rootKey=void 0):this.keyMode===Bn.RootKeyPlusWrapper&&(this.keyMode=Bn.RootKeyOnly),e.next=5,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 5:return e.next=7,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 7:if(this.keyMode!==Bn.RootKeyOnly){e.next=10;break}return e.next=10,b.awrap(this.saveRootKeyToKeychain());case 10:return e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.keyParams){n.next=2;break}throw Error('keyParams must be supplied if setting root key.');case 2:if(this.rootKey!==e){n.next=4;break}throw Error('Attempting to set root key as same current value.');case 4:if(this.keyMode!==Bn.WrapperOnly){n.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,n.next=16;break;case 8:if(this.keyMode!==Bn.RootKeyNone){n.next=12;break}this.keyMode=Bn.RootKeyOnly,n.next=16;break;case 12:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){n.next=15;break}n.next=16;break;case 15:throw Error("Unhandled key mode for setNewRootKey ".concat(this.keyMode));case 16:return this.rootKey=e,n.next=19,b.awrap(this.storageService.setValue(o.RootKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 19:if(this.keyMode!==Bn.RootKeyOnly){n.next=24;break}return n.next=22,b.awrap(this.saveRootKeyToKeychain());case 22:n.next=29;break;case 24:if(this.keyMode!==Bn.RootKeyPlusWrapper){n.next=29;break}if(t){n.next=27;break}throw Error('wrappingKey must be supplied');case 27:return n.next=29,b.awrap(this.wrapAndPersistRootKey(t));case 29:return n.next=31,b.awrap(this.notifyObserversOfKeyChange());case 31:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getRootKey",value:function(){return this.rootKey}},{key:"clearLocalKeyState",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 2:return e.next=4,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 6:return e.next=8,b.awrap(this.storageService.removeValue(o.RootKeyParams,De.Nonwrapped));case 8:return this.keyMode=Bn.RootKeyNone,this.rootKey=void 0,e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:if(n=a.sent,!(r=this.rootKey.compare(n))){a.next=11;break}return a.abrupt("return",{valid:r,artifacts:{rootKey:n}});case 11:return a.abrupt("return",{valid:!1});case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"validatePasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=a.sent,a.next=8,b.awrap(this.validateWrappingKey(n));case 8:if(!(r=a.sent)){a.next=13;break}return a.abrupt("return",{valid:r,artifacts:{wrappingKey:n}});case 13:return a.abrupt("return",{valid:!1});case 14:case"end":return a.stop()}},null,this,null,Promise)}},{key:"keyToUseForEncryptionOfPayload",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Object(_.w)(t)){s.next=2;break}throw'Intent must be supplied when looking up key for encryption of item.';case 2:if(!Object(Re.a)(e.content_type)){s.next=13;break}if(n=this.getRootKey()){s.next=10;break}if(!Object(Re.c)(t)){s.next=9;break}throw Error('Root key encryption is required but no root key is available.');case 9:return s.abrupt("return",void 0);case 10:return s.abrupt("return",n);case 13:return r=this.getDefaultItemsKey(),s.next=16,b.awrap(this.getUserVersion());case 16:if(!(a=s.sent)||a===(null===r||void 0===r?void 0:r.keyVersion)){s.next=22;break}return i=this.latestItemsKeys(),s.abrupt("return",i.find(function(e){return e.keyVersion===a}));case 22:return s.abrupt("return",r);case 23:case"end":return s.stop()}},null,this,null,Promise)}},{key:"keyToUseForDecryptionOfPayload",value:function(e){if(Object(Re.a)(e.content_type))return this.getRootKey();if(e.items_key_id)return this.itemsKeyForPayload(e);var t=e.version;if(t!==this.getLatestVersion())return this.defaultItemsKeyForItemVersion(t);we.a.error(Error('No associated key found for item encrypted with latest protocol version.'))}},{key:"onSyncEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.b.FullSyncCompleted){t.next=3;break}return t.next=3,b.awrap(this.handleFullSyncCompletion());case 3:if(e!==At.b.DownloadFirstSyncCompleted){t.next=6;break}return t.next=6,b.awrap(this.handleDownloadFirstSyncCompletion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleDownloadFirstSyncCompletion",value:function(){var e,t,n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.hasAccount()){c.next=2;break}return c.abrupt("return");case 2:if(e=this.latestItemsKeys(),t=e.filter(function(e){return e.neverSynced}),n=e.filter(function(e){return!e.neverSynced}),r=n.find(function(e){return e.isDefault}),!!Object(_.w)(r)){c.next=12;break}return c.next=10,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(t)));case 10:c.next=21;break;case 12:if(!(a=this.getRootKey())){c.next=21;break}if(!((i=t.filter(function(e){return e.keyVersion!==a.keyVersion})).length>0)){c.next=18;break}return c.next=18,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(i)));case 18:if(0!==this.latestItemsKeys().length){c.next=21;break}return c.next=21,b.awrap(this.createNewDefaultItemsKey());case 21:return c.next=23,b.awrap(this.getUserVersion());case 23:if(s=c.sent,o=this.latestItemsKeys().find(function(e){return e.keyVersion===s}),!Object(_.w)(o)){c.next=28;break}return c.next=28,b.awrap(this.createNewDefaultItemsKey());case 28:this.syncUnsycnedItemsKeys();case 29:case"end":return c.stop()}},null,this,null,Promise)}},{key:"handleFullSyncCompletion",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,b.awrap(this.createNewDefaultItemsKey());case 4:if(this.keyMode!==Bn.WrapperOnly){e.next=6;break}return e.abrupt("return",this.repersistAllItems());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"syncUnsycnedItemsKeys",value:function(){if(this.hasAccount()){var e=this.latestItemsKeys().filter(function(e){return e.neverSynced&&!e.dirty&&!e.deleted});e.length>0&&this.itemManager.setItemsDirty(Object(Ke.b)(e))}}},{key:"repersistAllItems",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e)}),n.abrupt("return",this.storageService.savePayloads(t));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"latestItemsKeys",value:function(){return this.itemManager.itemsKeys()}},{key:"itemsKeyForPayload",value:function(e){return this.latestItemsKeys().find(function(t){return t.uuid===e.items_key_id||t.duplicateOf===e.items_key_id})}},{key:"getDefaultItemsKey",value:function(){var e=this.latestItemsKeys();if(1===e.length)return e[0];var t=e.filter(function(e){return e.isDefault});if(t.length>1){var n=t.filter(function(e){return!e.neverSynced});if(n.length,n.length>0)return n[0]}return t[0]}},{key:"getKeyEmbeddedKeyParams",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.payload.format!==ue.a.DecryptedBareObject){s.next=2;break}return s.abrupt("return",void 0);case 2:return t=e.version,n=this.operatorForVersion(t),s.next=6,b.awrap(n.getPayloadAuthenticatedData(e.payload));case 6:if(r=s.sent){s.next=9;break}return s.abrupt("return",void 0);case 9:if(!Object(Q.c)(t,Q.a.V003)){s.next=14;break}return a=r,s.abrupt("return",this.createKeyParams(a));case 14:return i=r.kp,s.abrupt("return",this.createKeyParams(i));case 16:case"end":return s.stop()}},null,this,null,Promise)}},{key:"reencryptItemsKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!((e=this.latestItemsKeys()).length>0)){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"defaultItemsKeyForItemVersion",value:function(e,t){var n=t||this.latestItemsKeys(),r=n.find(function(t){return t.isDefault&&t.keyVersion===e});return r||n.find(function(t){return t.keyVersion===e})}},{key:"needsNewRootKeyBasedItemsKey",value:function(){if(!this.hasAccount())return!1;var e=this.getRootKey();if(!e)return!1;if(Object(Q.b)(e.keyVersion,Yn)>0)return!1;var t=this.getDefaultItemsKey();return!t||t.itemsKey!==e.itemsKey}},{key:"createNewDefaultItemsKey",value:function(){var e,t,n,r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e=this.getRootKey(),t=e?e.keyVersion:this.getLatestVersion(),!(Object(Q.b)(t,Yn)<=0)){l.next=14;break}return l.t0=Object(Ee.e),l.next=6,b.awrap(I.GenerateUuid());case 6:l.t1=l.sent,l.t2=F.a.ItemsKey,l.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t}),l.t4={uuid:l.t1,content_type:l.t2,content:l.t3},r=(0,l.t0)(l.t4),n=nt(r),l.next=17;break;case 14:return l.next=16,b.awrap(this.operatorForVersion(t).createItemsKey());case 16:n=l.sent;case 17:a=this.latestItemsKeys(),i=a.filter(function(e){return e.isDefault}),s=S(i);case 20:if((o=s()).done){l.next=26;break}return c=o.value,l.next=24,b.awrap(this.itemManager.changeItemsKey(c.uuid,function(e){e.isDefault=!1}));case 24:l.next=20;break;case 26:return l.next=28,b.awrap(this.itemManager.insertItem(n));case 28:return u=l.sent,l.next=31,b.awrap(this.itemManager.changeItemsKey(u.uuid,function(e){e.isDefault=!0}));case 31:return l.abrupt("return",u);case 32:case"end":return l.stop()}},null,this,null,Promise)}},{key:"createNewItemsKeyWithRollback",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=this.getDefaultItemsKey(),a.next=3,b.awrap(this.createNewDefaultItemsKey());case 3:return t=a.sent,n=function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(Promise.all([r.itemManager.setItemToBeDeleted(t.uuid),r.itemManager.changeItem(e.uuid,function(e){e.isDefault=!0})]));case 2:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getPasswordCreatedDate",value:function(){var e=this.getRootKey();return e?e.keyParams.createdDate:void 0}}]),n})(R.a),Qn=(function(){function e(t,n){v(this,e),this.defaultContentKeyToDiffOn='text',this.payload=Object(Ee.b)(t),this.previousEntry=n,this.hasPreviousEntry=!Object(_.w)(n);var r=this.payload.content[this.defaultContentKeyToDiffOn];this.textCharDiffLength=r?n?r.length-n.payload.content[this.defaultContentKeyToDiffOn].length:this.payload.content[this.defaultContentKeyToDiffOn].length:0}return y(e,[{key:"itemFromPayload",value:function(){return nt(this.payload)}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=this.itemFromPayload(),n=e.itemFromPayload();return!(t.userModifiedDate.getTime()!==n.userModifiedDate.getTime())&&t.isItemContentEqualWith(n)}},{key:"isDiscardable",value:function(){return!1}},{key:"operationVector",value:function(){return void 0!==this.textCharDiffLength?this.hasPreviousEntry&&0!==this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!==this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}}]),e})(),Jn=(function(e){d(n,Qn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"previewTitle",value:function(){return this.payload.updated_at.getTime()>0?this.payload.updated_at.toLocaleString():this.payload.created_at.toLocaleString()}},{key:"previewSubTitle",value:function(){return this.hasPreviousEntry?this.textCharDiffLength<0?"".concat(-1*this.textCharDiffLength," characters removed"):this.textCharDiffLength>0?"".concat(this.textCharDiffLength," characters added"):'Title or metadata changed':"".concat(this.textCharDiffLength," characters loaded")}},{key:"isDiscardable",value:function(){return Object(_.t)(this.payload.safeContent.text)}}]),n})();function $n(e,t){return new(Xn(e[Je.a.ContentType]))(e,t)}function Xn(e){switch(e){case F.a.Note:return Jn;default:return Qn}}var Zn,er,tr=20,nr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s){var o;return v(this,n),(o=t.call(this)).itemManager=e,o.storageService=r,o.apiService=a,o.protocolService=i,o.deviceInterface=s,o.persistable=!1,o.autoOptimize=!1,o.historyStaging={},o.history={},o.historyTypes=[F.a.Note],o.itemRevisionThreshold=tr,o.removeChangeObserver=o.itemManager.addObserver(o.historyTypes,function(e,t){o.recordNewHistoryForItems(e.concat(t))}),o}return y(n,[{key:"deinit",value:function(){this.cancelPendingPersist(),this.itemManager=void 0,this.storageService=void 0,this.history=void 0,this.removeChangeObserver&&(this.removeChangeObserver(),this.removeChangeObserver=void 0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.SessionHistoryPersistable));case 2:return this.persistable=e.sent,e.next=5,b.awrap(this.getPersistedHistory());case 5:return this.history=e.sent,e.next=8,b.awrap(this.storageService.getValue(o.SessionHistoryOptimize,void 0,!0));case 8:this.autoOptimize=e.sent;case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPersistedHistory",value:function(){var e,t,n,r,a,i,s,c,u,p,d,h,f,v,y,g;return b.async(function(m){for(;;)switch(m.prev=m.next){case 0:return e={},m.next=3,b.awrap(this.storageService.getValue(o.SessionHistoryRevisions));case 3:if(t=m.sent){m.next=6;break}return m.abrupt("return",e);case 6:for(n=0,r=Object.entries(t);n<r.length;n++){for(a=r[n],i=l(a,2),s=i[0],c=i[1],u=c.slice().reverse(),p=[],d=S(u);!(h=d()).done;)f=h.value,v=Object(Ee.f)(f.payload,ht.a.SessionHistory),y=yt(p),g=$n(v,y),p.unshift(g);e[s]=p}return m.abrupt("return",e);case 8:case"end":return m.stop()}},null,this,null,Promise)}},{key:"recordNewHistoryForItems",value:function(e){for(var t,n=!1,r=S(e);!(t=r()).done;){var a=t.value;if(this.historyTypes.includes(a.content_type)){var i=a.payload;if(!a.deleted&&i.format===ue.a.DecryptedBareObject){var s=this.history[a.uuid]||[],o=yt(s),c=$n(Object(Ee.f)(a,ht.a.SessionHistory),o);if(!c.isDiscardable()){var u=this.historyStaging[a.uuid];this.historyStaging[a.uuid]=c,u&&(u.isSameAsEntry(c)||o&&u.isSameAsEntry(o)||(s.unshift(u),this.history[a.uuid]=s,this.autoOptimize&&this.optimizeHistoryForItem(a.uuid),n=!0))}}}}n&&this.saveToDisk()}},{key:"isDiskEnabled",value:function(){return this.persistable}},{key:"isAutoOptimizeEnabled",value:function(){return this.autoOptimize}},{key:"cancelPendingPersist",value:function(){this.saveTimeout&&('cancel'in this.deviceInterface.timeout?this.deviceInterface.timeout.cancel(this.saveTimeout):clearTimeout(this.saveTimeout))}},{key:"saveToDisk",value:function(){var e=this;if(this.persistable){this.cancelPendingPersist();var t=this.persistableHistoryValue();this.saveTimeout=this.deviceInterface.timeout(function(){e.storageService.setValue(o.SessionHistoryRevisions,t)},2e3)}}},{key:"persistableHistoryValue",value:function(){for(var e={},t=0,n=Object.entries(this.history);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1].map(function(e){return{payload:e.payload}});e[i]=s}return e}},{key:"setSessionItemRevisionThreshold",value:function(e){this.itemRevisionThreshold=e}},{key:"sessionHistoryForItem",value:function(e){return this.history[e.uuid]||[]}},{key:"clearHistoryForItem",value:function(e){delete this.history[e.uuid],this.saveToDisk()}},{key:"clearAllHistory",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.history={},e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleDiskSaving",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistable=!this.persistable,!this.persistable){e.next=6;break}this.storageService.setValue(o.SessionHistoryPersistable,!0),this.saveToDisk(),e.next=8;break;case 6:return this.storageService.setValue(o.SessionHistoryPersistable,!1),e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 8:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleAutoOptimize",value:function(){this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageService.setValue(o.SessionHistoryOptimize,!0):this.storageService.setValue(o.SessionHistoryOptimize,!1)}},{key:"getHistoryMapCopy",value:function(){for(var e=w({},this.history),t=0,n=Object.entries(e);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1];e[i]=s.slice()}return Object.freeze(e)}},{key:"remoteHistoryForItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.getItemRevisions(e.uuid));case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.abrupt("return",t.data);case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"fetchRemoteRevision",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.apiService.getRevision(t,e));case 2:if(!(n=o.sent).error&&!Object(_.w)(n.data)){o.next=5;break}return o.abrupt("return",void 0);case 5:return r=n.data,a=Object(Ee.e)(r,{uuid:r.item_uuid}),i=Object(Ee.f)(a,ht.a.RemoteHistory),o.next=10,b.awrap(this.protocolService.payloadByDecryptingPayload(i));case 10:if(!(s=o.sent).errorDecrypting){o.next=13;break}return o.abrupt("return",void 0);case 13:return o.abrupt("return",new Qn(s));case 14:case"end":return o.stop()}},null,this,null,Promise)}},{key:"optimizeHistoryForItem",value:function(e){var t=this.history[e]||[];if(!(t.length<=this.itemRevisionThreshold)){for(var n=function(e){return e.deltaSize()>25},r=[],a=function(e,a,i){if(i){if(r.unshift(e),n(e)&&-1===e.operationVector()){var s=t[a+1];s&&r.unshift(s)}}else Object(_.M)(r,e)},i=t.length-1;i>=0;i--){var s=t[i];a(s,i,0===i||i===t.length-1||n(s))}var o=t.filter(function(e){return r.includes(e)});this.history[e]=o}}}]),n})(R.a);!(function(e){e.SessionExpiryDateChanged="SessionExpiryDateChanged"})(Zn||(Zn={})),(function(e){e[e.None=0]="None",e[e.FiveMinutes=300]="FiveMinutes",e[e.OneHour=3600]="OneHour",e[e.OneWeek=604800]="OneWeek"})(er||(er={}));var rr,ar=[{valueInSeconds:er.None,label:"Don't Remember"},{valueInSeconds:er.FiveMinutes,label:'5 Minutes'},{valueInSeconds:er.OneHour,label:'1 Hour'},{valueInSeconds:er.OneWeek,label:'1 Week'}],ir=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).protocolService=e,s.challengeService=r,s.storageService=a,s.itemManager=i,s.sessionExpiryTimeout=-1,s}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.challengeService=void 0,this.storageService=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return e===ve.LoadedDatabase_12&&this.updateSessionExpiryTimer(this.getSessionExpiryDate()),Promise.resolve()}},{key:"hasProtectionSources",value:function(){return this.protocolService.hasAccount()||this.protocolService.hasPasscode()||this.hasBiometricsEnabled()}},{key:"areProtectionsEnabled",value:function(){return this.hasProtectionSources()&&this.getSessionExpiryDate()<=new Date}},{key:"hasBiometricsEnabled",value:function(){var e=this.storageService.getValue(o.BiometricsState,De.Nonwrapped);return Boolean(e)}},{key:"enableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to enable biometrics when they already are enabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.storageService.setValue(o.BiometricsState,!0,De.Nonwrapped));case 5:return e.abrupt("return",!0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"disableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to disable biometrics when they already are disabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.validateOrRenewSession(ne.DisableBiometrics));case 5:if(!e.sent){e.next=11;break}return e.next=8,b.awrap(this.storageService.setValue(o.BiometricsState,!1,De.Nonwrapped));case 8:return e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"createLaunchChallenge",value:function(){var e=[];return this.hasBiometricsEnabled()&&e.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&e.push(new ge(te.LocalPasscode)),e.length>0?new ye(e,ne.ApplicationUnlock,!1):void 0}},{key:"protectNote",value:function(e){return this.itemManager.changeItem(e.uuid,function(e){e.protected=!0})}},{key:"unprotectNote",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.validateOrRenewSession(ne.UnprotectNote));case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.itemManager.changeItem(e.uuid,function(e){e.protected=!1}));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){c.next=15;break}if(s=i.value,(o=s.protected&&this.areProtectionsEnabled())&&!n&&(n=this.validateOrRenewSession(t)),c.t0=!o,c.t0){c.next=11;break}return c.next=10,b.awrap(n);case 10:c.t0=c.sent;case 11:if(!c.t0){c.next=13;break}r.push(s);case 13:c.next=2;break;case 15:return c.abrupt("return",r);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){return this.itemManager.changeItems(Object(Ke.b)(e),function(e){e.protected=!0})}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.authorizeProtectedActionForNotes(e,ne.UnprotectNote));case 2:return t=n.sent,n.abrupt("return",this.itemManager.changeItems(Object(Ke.b)(t),function(e){e.protected=!1}));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeNoteAccess",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.protected){t.next=2;break}return t.abrupt("return",!0);case 2:return t.abrupt("return",this.validateOrRenewSession(ne.AccessProtectedNote));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeAddingPasscode",value:function(){return this.validateOrRenewSession(ne.AddPasscode)}},{key:"authorizeChangingPasscode",value:function(){return this.validateOrRenewSession(ne.ChangePasscode)}},{key:"authorizeRemovingPasscode",value:function(){return this.validateOrRenewSession(ne.RemovePasscode)}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.validateOrRenewSession(ne.SearchProtectedNotesText)}},{key:"authorizeFileImport",value:function(){return this.validateOrRenewSession(ne.ImportFile)}},{key:"authorizeBackupCreation",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.validateOrRenewSession(ne.ExportBackup,{fallBackToAccountPassword:e}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeMfaDisable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.DisableMfa,{requireAccountPassword:!0}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeAutolockIntervalChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.ChangeAutolockInterval));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeSessionRevoking",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.RevokeSession));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeCloudLinkAccess",value:function(){return this.validateOrRenewSession(ne.AccessCloudLink)}},{key:"validateOrRenewSession",value:function(e){var t,n,r,a,i,s,o,c,u,l=arguments;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>1&&void 0!==l[1]?l[1]:{},n=t.fallBackToAccountPassword,r=void 0===n||n,a=t.requireAccountPassword,i=void 0!==a&&a,!(this.getSessionExpiryDate()>new Date)){p.next=3;break}return p.abrupt("return",!0);case 3:if(s=[],this.hasBiometricsEnabled()&&s.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&s.push(new ge(te.LocalPasscode)),!i){p.next=10;break}if(this.protocolService.hasAccount()){p.next=9;break}throw Error('Requiring account password for challenge with no account');case 9:s.push(new ge(te.AccountPassword));case 10:if(0!==s.length){p.next=16;break}if(!r||!this.protocolService.hasAccount()){p.next=15;break}s.push(new ge(te.AccountPassword)),p.next=16;break;case 15:return p.abrupt("return",!0);case 16:return p.t0=s,p.t1=ge,p.t2=te.ProtectionSessionDuration,p.t3=void 0,p.t4=void 0,p.t5=void 0,p.t6=void 0,p.next=25,b.awrap(this.getSessionLength());case 25:return p.t7=p.sent,p.t8=new p.t1(p.t2,p.t3,p.t4,p.t5,p.t6,p.t7),p.t0.push.call(p.t0,p.t8),p.next=30,b.awrap(this.challengeService.promptForChallengeResponse(new ye(s,e,!0)));case 30:if(!(o=p.sent)){p.next=42;break}if(u=null===(c=o.values.find(function(e){return e.prompt.validation===te.ProtectionSessionDuration}))||void 0===c?void 0:c.value,!Object(_.w)(u)){p.next=37;break}we.a.error(Error('No valid protection session length found. Got '+u)),p.next=39;break;case 37:return p.next=39,b.awrap(this.setSessionLength(u));case 39:return p.abrupt("return",!0);case 42:return p.abrupt("return",!1);case 43:case"end":return p.stop()}},null,this,null,Promise)}},{key:"getSessionExpiryDate",value:function(){var e=this.storageService.getValue(o.ProtectionExpirey);return e?new Date(e):new Date}},{key:"clearSession",value:function(){return this.setSessionExpiryDate(new Date)}},{key:"setSessionExpiryDate",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.ProtectionExpirey,e));case 2:this.notifyEvent(Zn.SessionExpiryDateChanged);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSessionLength",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ProtectionSessionLength));case 2:if(!(e=t.sent)){t.next=7;break}return t.abrupt("return",e);case 7:return t.abrupt("return",er.None);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setSessionLength",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.storageService.setValue(o.ProtectionSessionLength,e));case 2:return(t=new Date).setSeconds(t.getSeconds()+e),n.next=6,b.awrap(this.setSessionExpiryDate(t));case 6:this.updateSessionExpiryTimer(t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSessionExpiryTimer",value:function(e){var t=this,n=e.getTime();if(n>Date.now()){clearTimeout(this.sessionExpiryTimeout),this.sessionExpiryTimeout=setTimeout(function(){t.setSessionExpiryDate(new Date)},n-Date.now())}}}]),n})(R.a),sr=n(45),or=n(19);!(function(e){e.UserRoleMessageReceived="WebSocketMessageReceived"})(rr||(rr={}));var cr,ur,lr=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.webSocketUrl=r,a}return y(n,[{key:"setWebSocketUrl",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.webSocketUrl=e,t.next=3,b.awrap(this.storageService.setValue(o.WebSocketUrl,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadWebSocketUrl",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.WebSocketUrl));case 2:e=t.sent,this.webSocketUrl=e||this.webSocketUrl||window._websocket_url;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"startWebSocketConnection",value:function(e){if(this.webSocketUrl)try{this.webSocket=new WebSocket("".concat(this.webSocketUrl,"?authToken=Bearer+").concat(e)),this.webSocket.onmessage=this.onWebSocketMessage.bind(this),this.webSocket.onclose=this.onWebSocketClose.bind(this)}catch(e){console.error('Error starting WebSocket connection',e)}}},{key:"closeWebSocketConnection",value:function(){var e;null===(e=this.webSocket)||void 0===e||e.close()}},{key:"onWebSocketMessage",value:function(e){var t=JSON.parse(e.data);this.notifyEvent(rr.UserRoleMessageReceived,t)}},{key:"onWebSocketClose",value:function(){this.webSocket=void 0}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.storageService=void 0,this.closeWebSocketConnection()}}]),n})(R.a),pr=n(29);!(function(e){e.UserRolesChanged="UserRolesChanged",e.FeaturesUpdated="FeaturesUpdated"})(cr||(cr={})),(function(e){e.NoUserSubscription="NoUserSubscription",e.NotInCurrentPlan="NotInCurrentPlan",e.InCurrentPlanButExpired="InCurrentPlanButExpired",e.Entitled="Entitled"})(ur||(ur={}));var dr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l,p,d){var h;return v(this,n),(h=t.call(this)).storageService=e,h.apiService=r,h.itemManager=a,h.componentManager=i,h.webSocketsService=s,h.settingsService=o,h.credentialService=c,h.syncService=u,h.alertService=l,h.sessionManager=p,h.crypto=d,h.deinited=!1,h.roles=[],h.features=[],h.needsInitialFeaturesUpdate=!0,h.completedSuccessfulFeaturesRetrieval=!1,h.removeApiServiceObserver=r.addEventObserver(function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==Ht.MetaReceived){a.next=6;break}if(h.syncService.completedOnlineDownloadFirstSync){a.next=3;break}return a.abrupt("return");case 3:return n=t.userUuid,r=t.userRoles,a.next=6,b.awrap(h.updateRoles(n,r.map(function(e){return e.name})));case 6:case"end":return a.stop()}},null,null,null,Promise)}),h.removeWebSocketsServiceObserver=s.addEventObserver(function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e!==rr.UserRoleMessageReceived){i.next=6;break}return n=t.payload,r=n.userUuid,a=n.currentRoles,i.next=4,b.awrap(h.setRoles(a));case 4:return i.next=6,b.awrap(h.updateFeatures(r));case 6:case"end":return i.stop()}},null,null,null,Promise)}),h.removefeatureReposObserver=h.itemManager.addObserver(or.ContentType.ExtensionRepo,function(e,t,n,r,a){var i,s;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=[ht.a.Constructor,ht.a.LocalRetrieved,ht.a.RemoteRetrieved,ht.a.FileImport],!a||!i.includes(a)){n.next=10;break}if(s=[].concat(m(e),m(t)).filter(function(e){return!e.deleted}),!h.sessionManager.isSignedIntoFirstPartyServer()){n.next=8;break}return n.next=6,b.awrap(h.migrateFeatureRepoToUserSetting(s));case 6:n.next=10;break;case 8:return n.next=10,b.awrap(h.migrateFeatureRepoToOfflineEntitlements(s));case 10:case"end":return n.stop()}},null,null,null,Promise)}),h.removeSignInObserver=h.credentialService.addEventObserver(function(e){if(e===Ye.SignedInOrRegistered){var t=h.itemManager.getItems(or.ContentType.ExtensionRepo);h.apiService.isThirdPartyHostUsed()||h.migrateFeatureRepoToUserSetting(t)}}),h}return y(n,[{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.FullSyncCompleted_13&&(t=this.getOfflineRepo())&&this.downloadOfflineFeatures(t);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setOfflineFeaturesCode",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,t=e.replace(/\s/g,''),i.next=4,b.awrap(this.crypto.base64Decode(t));case 4:if(n=i.sent,r=this.parseOfflineEntitlementsCode(n),!Object(_.u)(r)){i.next=8;break}return i.abrupt("return",r);case 8:return i.next=10,b.awrap(this.itemManager.createItem(or.ContentType.ExtensionRepo,Object(Ke.a)({offlineFeaturesUrl:r.featuresUrl,offlineKey:r.extensionKey,migratedToOfflineEntitlements:!0}),!0));case 10:return a=i.sent,this.syncService.sync(),i.abrupt("return",this.downloadOfflineFeatures(a));case 15:return i.prev=15,i.t0=i.catch(0),i.abrupt("return",{error:j.e});case 18:case"end":return i.stop()}},null,this,[[0,15]],Promise)}},{key:"getOfflineRepo",value:function(){return this.itemManager.getItems(or.ContentType.ExtensionRepo).filter(function(e){return e.migratedToOfflineEntitlements})[0]}},{key:"hasOfflineRepo",value:function(){return void 0!=this.getOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this.getOfflineRepo())){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 4:return t.next=6,b.awrap(this.storageService.removeValue(o.UserFeatures));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"parseOfflineEntitlementsCode",value:function(e){try{var t=JSON.parse(e);return{featuresUrl:t.featuresUrl,extensionKey:t.extensionKey}}catch(e){return{error:j.e}}}},{key:"downloadOfflineFeatures",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.downloadOfflineFeaturesFromRepo(e));case 2:if(t=n.sent,!Object(_.u)(t)){n.next=5;break}return n.abrupt("return",t);case 5:return n.next=7,b.awrap(this.didDownloadFeatures(t.features));case 7:return n.next=9,b.awrap(this.mapFeaturesToItems(t.features));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToUserSetting",value:function(){var e,t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:[],t=S(e);case 2:if((n=t()).done){c.next=17;break}if(!(r=n.value).migratedToUserSetting){c.next=6;break}return c.abrupt("continue",15);case 6:if(!r.onlineUrl){c.next=15;break}if(a=r.onlineUrl,!((i=a.match(/\w{32,64}/))&&i.length>0)){c.next=15;break}return s=i[0],c.next=13,b.awrap(this.settingsService.updateSetting(pr.SettingName.ExtensionKey,s,!0));case 13:return c.next=15,b.awrap(this.itemManager.changeFeatureRepo(r.uuid,function(e){e.migratedToUserSetting=!0}));case 15:c.next=2;break;case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToOfflineEntitlements",value:function(){var e,t,n,r,a,i,s,o=this,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=c.length>0&&void 0!==c[0]?c[0]:[],t=S(e);case 2:if((n=t()).done){u.next=17;break}if(!(r=n.value).migratedToOfflineEntitlements){u.next=6;break}return u.abrupt("continue",15);case 6:if(!r.onlineUrl){u.next=15;break}if(a=r.onlineUrl,i=new URL(a),i.origin.includes("https://extensions.standardnotes.org")){u.next=11;break}return u.abrupt("continue",15);case 11:if(!((s=a.match(/\w{32,64}/))&&s.length>0)){u.next=15;break}return u.next=15,b.awrap((function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=s[0],n.next=3,b.awrap(o.itemManager.changeFeatureRepo(r.uuid,function(t){t.offlineFeaturesUrl="https://api.standardnotes.com/v1/offline/features",t.offlineKey=e,t.migratedToOfflineEntitlements=!0}));case 3:return t=n.sent,n.next=6,b.awrap(o.downloadOfflineFeatures(t));case 6:case"end":return n.stop()}},null,null,null,Promise)})());case 15:u.next=2;break;case 17:case"end":return u.stop()}},null,null,null,Promise)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.UserRoles,void 0,[]));case 2:return this.roles=e.sent,e.next=5,b.awrap(this.storageService.getValue(o.UserFeatures,void 0,[]));case 5:this.features=e.sent;case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"updateRoles",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.haveRolesChanged(t)&&!this.needsInitialFeaturesUpdate){n.next=7;break}return this.needsInitialFeaturesUpdate=!1,n.next=5,b.awrap(this.setRoles(t));case 5:return n.next=7,b.awrap(this.updateFeatures(e));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setRoles",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles=e,Object(_.e)(this.roles,e)||this.notifyEvent(cr.UserRolesChanged),t.next=4,b.awrap(this.storageService.setValue(o.UserRoles,this.roles));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"didDownloadFeatures",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.features=e,this.completedSuccessfulFeaturesRetrieval=!0,this.notifyEvent(cr.FeaturesUpdated),t.next=5,b.awrap(this.storageService.setValue(o.UserFeatures,this.features));case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getFeature",value:function(e){return this.features.find(function(t){return t.identifier===e})}},{key:"hasPaidOnlineOrOfflineSubscription",value:function(){if(this.sessionManager.isSignedIntoFirstPartyServer()){var e=this.roles,t=[sr.RoleName.BasicUser];return e.some(function(e){return!t.includes(e)})}return this.hasOfflineRepo()}},{key:"getFeatureStatus",value:function(e){if(void 0==L.Features.find(function(t){return t.identifier===e})){var t=this.itemManager.components.find(function(t){return t.identifier===e});return null!==t&&void 0!==t&&t.isExpired?ur.InCurrentPlanButExpired:ur.Entitled}if(this.hasPaidOnlineOrOfflineSubscription()&&!this.completedSuccessfulFeaturesRetrieval)return ur.Entitled;if(!this.hasPaidOnlineOrOfflineSubscription())return ur.NoUserSubscription;var n=this.features.find(function(t){return t.identifier===e});return n?n.expires_at&&new Date(n.expires_at).getTime()<(new Date).getTime()?this.roles.includes(n.role_name)?ur.InCurrentPlanButExpired:ur.NotInCurrentPlan:ur.Entitled:ur.NotInCurrentPlan}},{key:"haveRolesChanged",value:function(e){var t=this;return e.some(function(e){return!t.roles.includes(e)})||this.roles.some(function(t){return!e.includes(t)})}},{key:"updateFeatures",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.apiService.getUserFeatures(e));case 2:if((t=r.sent).error||!t.data||this.deinited){r.next=10;break}return(n=t.data.features).forEach(function(e){e.expires_at&&(e.expires_at=Object(_.i)(e.expires_at))}),r.next=8,b.awrap(this.didDownloadFeatures(n));case 8:return r.next=10,b.awrap(this.mapFeaturesToItems(n));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"componentContentForFeatureDescription",value:function(e){var t={area:e.area,hosted_url:e.url,name:e.name,package_info:e,valid_until:new Date(e.expires_at||0)};return Object(Ke.a)(t)}},{key:"mapFeaturesToItems",value:function(e){var t,n,r,a,i,s,o,c,u=this;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:t=this.itemManager.getItems([or.ContentType.Component,or.ContentType.Theme]),n=[],r=new Date,a=!1,i=function(e){var i,s,o,c;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e.content_type){l.next=2;break}return l.abrupt("return","continue");case 2:if(!e.url||Object(_.B)(e.url)){l.next=5;break}return l.abrupt("return","continue");case 5:if(i=new Date(e.expires_at||0).getTime()<r.getTime(),s=t.find(function(t){return!!t.safeContent.package_info&&(t.safeContent.package_info.identifier===e.identifier&&!t.deleted)}),o=s,!s){l.next=21;break}if(c=new Date(e.expires_at||0),!(e.url!==s.hosted_url||e.version!==s.package_info.version||c.getTime()!==s.valid_until.getTime())){l.next=18;break}return l.next=14,b.awrap(u.itemManager.changeComponent(s.uuid,function(t){t.hosted_url=e.url,t.package_info=e,t.valid_until=c}));case 14:o=l.sent,a=!0,l.next=19;break;case 18:o=s;case 19:l.next=26;break;case 21:if(i&&e.content_type!==or.ContentType.Component){l.next=26;break}return l.next=24,b.awrap(u.itemManager.createItem(e.content_type,u.componentContentForFeatureDescription(e),!0));case 24:o=l.sent,a=!0;case 26:i&&o&&(e.content_type===or.ContentType.Component?u.componentManager.setReadonlyStateForComponent(o,i):(n.push(o.uuid),a=!0));case 27:case"end":return l.stop()}},null,null,null,Promise)},s=S(e);case 6:if((o=s()).done){l.next=15;break}return c=o.value,l.next=10,b.awrap(i(c));case 10:if("continue"!==l.sent){l.next=13;break}return l.abrupt("continue",13);case 13:l.next=6;break;case 15:return l.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(n));case 17:a&&this.syncService.sync();case 18:case"end":return l.stop()}},null,this,null,Promise)}},{key:"validateAndDownloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=e,i.prev=1,i.next=4,b.awrap(this.crypto.base64Decode(e));case 4:t=i.sent,i.next=9;break;case 7:i.prev=7,i.t0=i.catch(1);case 9:if(i.prev=9,n=[].concat(Ft,Nt),r=new URL(t),a=r.host,n.includes(a)){i.next=20;break}return i.next=15,b.awrap(this.alertService.confirm(j.t,'Install extension from an untrusted source?','Proceed to install',St.Danger,'Cancel'));case 15:if(!i.sent){i.next=18;break}return i.abrupt("return",this.downloadExternalFeature(t));case 18:i.next=21;break;case 20:return i.abrupt("return",this.downloadExternalFeature(t));case 21:i.next=26;break;case 23:i.prev=23,i.t1=i.catch(9),this.alertService.alert(j.C);case 26:case"end":return i.stop()}},null,this,[[1,7],[9,23]],Promise)}},{key:"downloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.apiService.downloadFeatureUrl(e));case 2:if(!(t=i.sent).error){i.next=7;break}return i.next=6,b.awrap(this.alertService.alert(j.c));case 6:return i.abrupt("return",void 0);case 7:if((n=t.data).content_type){i.next=10;break}return i.abrupt("return");case 10:return r=this.componentContentForFeatureDescription(n),i.next=13,b.awrap(this.itemManager.createTemplateItem(n.content_type,r));case 13:return a=i.sent,i.abrupt("return",a);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.removeSignInObserver(),this.removeSignInObserver=void 0,this.removeApiServiceObserver(),this.removeApiServiceObserver=void 0,this.removeWebSocketsServiceObserver(),this.removeWebSocketsServiceObserver=void 0,this.removefeatureReposObserver(),this.removefeatureReposObserver=void 0,this.roles=void 0,this.storageService=void 0,this.apiService=void 0,this.itemManager=void 0,this.componentManager=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.credentialService=void 0,this.syncService=void 0,this.alertService=void 0,this.sessionManager=void 0,this.crypto=void 0,this.deinited=!0}}]),n})(R.a),hr=n(46),fr=(function(){function e(t,n){v(this,e),this.completedUpload=0,this.totalUpload=0,this.downloaded=0,this.databaseLoadCurrent=0,this.databaseLoadTotal=0,this.databaseLoadDone=!1,this.syncing=!1,this.interval=t,this.receiver=n}return y(e,[{key:"deinit",value:function(){this.stopTimingMonitor()}},{key:"setUploadStatus",value:function(e,t){this.completedUpload=e,this.totalUpload=t,this.receiver(on.a.StatusChanged)}},{key:"setDownloadStatus",value:function(e){this.downloaded+=e,this.receiver(on.a.StatusChanged)}},{key:"setDatabaseLoadStatus",value:function(e,t,n){this.databaseLoadCurrent=e,this.databaseLoadTotal=t,this.databaseLoadDone=n,n?this.receiver(on.a.LocalDataLoaded):this.receiver(on.a.LocalDataIncrementalLoad)}},{key:"getStats",value:function(){return{uploadCompletionCount:this.completedUpload,uploadTotalCount:this.totalUpload,downloadCount:this.downloaded,localDataDone:this.databaseLoadDone,localDataCurrent:this.databaseLoadCurrent,localDataTotal:this.databaseLoadTotal}}},{key:"setDidBegin",value:function(){this.syncing=!0,this.syncStart=new Date}},{key:"setDidEnd",value:function(){this.syncing=!1,this.syncEnd=new Date}},{key:"startTimingMonitor",value:function(){var e=this;this.timingMonitor&&this.stopTimingMonitor(),this.timingMonitor=this.interval(function(){e.secondsSinceSyncStart>5&&(e.receiver(on.a.SyncTakingTooLong),e.stopTimingMonitor())},500)}},{key:"stopTimingMonitor",value:function(){Object.prototype.hasOwnProperty.call(this.interval,'cancel')?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return!!this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.syncing=!1,this.error=null,this.stopTimingMonitor(),this.receiver(on.a.StatusChanged)}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return((new Date).getTime()-this.syncStart.getTime())/1e3}}]),e})();function vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mr,br=(function(){function e(){v(this,e),this.tags=[],this.includePinned=!0,this.includeProtected=!0,this.includeTrashed=!1,this.includeArchived=!1}return y(e,[{key:"computeFilters",value:function(e){for(var t,n=this,r=this.tags.filter(function(e){return!e.isSmartTag}),a=this.tags.filter(function(e){return e.isSmartTag}),i=a.filter(function(e){return e.isSystemSmartTag}),s=a.filter(function(e){return!e.isSystemSmartTag}),o=!1,c=!1,u=[],l=S(i);!(t=l()).done;){var p=t.value;p.isArchiveTag?(u.push(function(e){return e.archived&&!e.deleted}),o=!0):p.isTrashTag&&(u.push(function(e){return e.trashed&&!e.deleted}),c=!0)}if(s.length>0){var d=H.a.CompoundPredicate(s.map(function(e){return e.predicate}));u.push(function(t){if(d.keypathIncludesVerb('tags')){var n=yr(yr(yr({},t),t.payload),{},{tags:e.elementsReferencingElement(t,F.a.Tag)});return H.a.ObjectSatisfiesPredicate(n,d)}return H.a.ObjectSatisfiesPredicate(t,d)})}else if(r.length>0)for(var h,f=function(e){u.push(function(t){return e.hasRelationshipWithItem(t)})},v=S(r);!(h=v()).done;){f(h.value)}return this.searchQuery&&u.push(function(t){return xr(t,n.searchQuery,e)}),this.includePinned||u.push(function(e){return!e.pinned}),this.includeProtected||u.push(function(e){return!e.protected}),this.includeTrashed||c||u.push(function(e){return!e.trashed}),this.includeArchived||o||c||u.push(function(e){return!e.archived}),u}}],[{key:"Create",value:function(t){var n=new e;return w(n,t),Object.freeze(n)}},{key:"Copy",value:function(t,n){var r=new e;return w(r,t),w(r,n),Object.freeze(r)}}]),e})();function wr(e,t){var n=e.computeFilters(t);return t.displayElements(F.a.Note).filter(function(e){return kr(e,n)})}function kr(e,t){for(var n,r=S(t);!(n=r()).done;){if(!(0,n.value)(e))return!1}return!0}function xr(e,t,n){var r=n.elementsReferencingElement(e,F.a.Tag).some(function(e){return Pr(e,t.query)!==mr.None});if(e.protected&&!t.includeProtectedNoteText){var a=Sr(e,t.query);return a===mr.Title||a===mr.TitleAndText||r}return Sr(e,t.query)!==mr.None||r}function Sr(e,t){if(0===t.length)return mr.TitleAndText;var n=e.safeTitle().toLowerCase(),r=e.safeText().toLowerCase(),a=t.toLowerCase(),i=a.split(' '),s=Or(a);if(s)return(n.includes(s)?mr.Title:mr.None)+(r.includes(s)?mr.Text:mr.None);if(Cr(a))return e.uuid===a?mr.Uuid:mr.None;var o=i.every(function(e){return n.indexOf(e)>=0}),c=i.every(function(e){return r.indexOf(e)>=0});return(o?mr.Title:0)+(c?mr.Text:0)}function Pr(e,t){if(0===t.length)return mr.None;var n=e.title.toLowerCase(),r=t.toLowerCase(),a=r.split(' '),i=Or(r);return i?n.includes(i)?mr.Title:mr.None:a.every(function(e){return n.indexOf(e)>=0})?mr.Title:mr.None}function Or(e){var t=e.match(/"(.*?)"/);return t?t[1]:null}function Cr(e){return!!e.match(/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)}!(function(e){e[e.None=0]="None",e[e.Title=1]="Title",e[e.Text=2]="Text",e[e.TitleAndText=3]="TitleAndText",e[e.Uuid=5]="Uuid"})(mr||(mr={}));var Dr=(function(){function e(t){v(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:br.Create({});this.collection=t,this.criteria=n,this.displayedNotes=[],this.needsRebuilding=!0}return y(e,[{key:"setCriteria",value:function(e){this.criteria=e,this.collection.setDisplayOptions(F.a.Note,e.sortProperty,e.sortDirection),this.needsRebuilding=!0}},{key:"notesMatchingSmartTag",value:function(e){var t;return wr((t=e,br.Create({tags:[t]})),this.collection)}},{key:"rebuildList",value:function(){var e=this,t=br.Copy(this.criteria,{tags:this.criteria.tags.map(function(t){return t.isSystemSmartTag?t:e.collection.find(t.uuid)})});this.displayedNotes=wr(t,this.collection)}},{key:"setNeedsRebuilding",value:function(){this.needsRebuilding=!0}},{key:"displayElements",value:function(){return this.needsRebuilding&&(this.rebuildList(),this.needsRebuilding=!1),this.displayedNotes.slice()}}]),e})(),_r=(function(e){d(n,e);var t=k(n);function n(e){var r,a,i,s;return v(this,n),(r=t.call(this)).payloadManager=e,r.observers=[],r.payloadManager=e,r.systemSmartTags=(a=Object(Ee.e)({uuid:Er,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'All notes',isSystemTag:!0,isAllTag:!0})}),i=Object(Ee.e)({uuid:Rr,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Archived',isSystemTag:!0,isArchiveTag:!0})}),s=Object(Ee.e)({uuid:Ir,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Trash',isSystemTag:!0,isTrashTag:!0})}),[nt(a),nt(i),nt(s)]),r.createCollection(),r.unsubChangeObserver=r.payloadManager.addObserver(F.a.Any,r.setPayloads.bind(u(r))),r}return y(n,[{key:"createCollection",value:function(){this.collection=new gn,this.collection.setDisplayOptions(F.a.Note,dn.CreatedAt,'dsc'),this.collection.setDisplayOptions(F.a.Tag,dn.Title,'dsc'),this.collection.setDisplayOptions(F.a.ItemsKey,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Component,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Theme,dn.Title,'asc'),this.collection.setDisplayOptions(F.a.SmartTag,dn.Title,'asc'),this.notesView=new Dr(this.collection)}},{key:"setDisplayOptions",value:function(e,t,n,r){e===F.a.Note&&console.warn("Called setDisplayOptions with ContentType.Note. setNotesDisplayCriteria should be used instead."),this.collection.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.notesView.setCriteria(e)}},{key:"getDisplayableItems",value:function(e){return e===F.a.Note?this.notesView.displayElements():this.collection.displayElements(e)}},{key:"deinit",value:function(){this.unsubChangeObserver(),this.unsubChangeObserver=void 0,this.payloadManager=void 0,this.collection=void 0,this.notesView=void 0}},{key:"resetState",value:function(){this.createCollection()}},{key:"findItem",value:function(e){return this.collection.find(e)}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.collection.findAll(e,t)}},{key:"itemsKeys",value:function(){return this.collection.displayElements(F.a.ItemsKey)}},{key:"addObserver",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]);var r={contentType:e,callback:t};return this.observers.push(r),function(){Object(_.M)(n.observers,r)}}},{key:"itemsReferencingItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.collection.uuidsThatReferenceUuid(e);return this.findItems(t)}},{key:"referencesForItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.findItem(e).references.map(function(e){return e.uuid});return this.findItems(t)}},{key:"setPayloads",value:function(e,t,n,r,a,i){var s=e.map(function(e){return nt(e)}),o=t.map(function(e){return nt(e)}),c=r.map(function(e){return nt(e)}),u=s.concat(o);u.length>0&&this.collection.set(u);for(var l,p=n.map(function(e){return nt(e)}),d=S(p);!(l=d()).done;){var h=l.value;this.collection.discard(h)}this.notesView.setNeedsRebuilding(),this.notifyObservers(s,o,p,c,a,i)}},{key:"notifyObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return e.filter(function(e){return t.includes(F.a.Any)||t.includes(e.content_type)})},c=S(this.observers.slice());!(s=c()).done;){var u=s.value,l=o(e,u.contentType),p=o(t,u.contentType),d=o(n,u.contentType),h=o(r,u.contentType);0===l.length&&0===p.length&&0===d.length&&0===h.length||u.callback(l,p,d,h,a,i)}}},{key:"changeItem",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=s.length>2&&void 0!==s[2]?s[2]:T.c.UserInteraction,r=s.length>3&&void 0!==s[3]?s[3]:ht.a.LocalChanged,a=s.length>4?s[4]:void 0,Object(_.A)(e)){o.next=5;break}throw Error('Invalid uuid for changeItem');case 5:return o.next=7,b.awrap(this.changeItems([e],t,n,r,a));case 7:return i=o.sent,o.abrupt("return",i[0]);case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:n=h.length>2&&void 0!==h[2]?h[2]:T.c.UserInteraction,r=h.length>3&&void 0!==h[3]?h[3]:ht.a.LocalChanged,a=h.length>4?h[4]:void 0,i=this.findItems(e,!0),s=[],o=S(i);case 6:if((c=o()).done){f.next=16;break}if(u=c.value){f.next=10;break}throw Error('Attempting to change non-existant item');case 10:l=de(u,n),t&&t(l),p=l.getResult(),s.push(p);case 14:f.next=6;break;case 16:return f.next=18,b.awrap(this.payloadManager.emitPayloads(s,r,a));case 18:return d=this.findItems(s.map(function(e){return e.uuid})),f.abrupt("return",d);case 20:case"end":return f.stop()}},null,this,null,Promise)}},{key:"changeNote",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant note');case 6:return s=new pe(i,n),c.abrupt("return",this.applyTransform(s,t,r,a));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeTag",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant tag');case 6:return s=new ce(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeComponent",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant component');case 6:return s=new V(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeFeatureRepo",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant repo');case 6:return s=new Xe(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeActionsExtension",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant extension');case 6:return s=new se(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeItemsKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant itemsKey');case 6:return s=new $(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"applyTransform",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:ht.a.LocalChanged,r=i.length>3?i[3]:void 0,t(e),a=e.getResult(),s.abrupt("return",this.payloadManager.emitPayload(a,n,r));case 5:case"end":return s.stop()}},null,this,null,Promise)}},{key:"setItemDirty",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]&&r[1],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return a.next=5,b.awrap(this.setItemsDirty([e],t));case 5:return n=a.sent,a.abrupt("return",n[0]);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemsDirty",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=n.length>1&&void 0!==n[1]&&n[1],Object(_.A)(e[0])){r.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return r.abrupt("return",this.changeItems(e,void 0,t?T.c.UserInteraction:T.c.Internal));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getDirtyItems",value:function(){return this.collection.dirtyElements().filter(function(e){return e.isSyncable})}},{key:"duplicateItem",value:function(e){var t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return t=o.length>1&&void 0!==o[1]&&o[1],n=o.length>2?o[2]:void 0,r=this.findItem(e),a=Object(Ee.e)(r),c.next=6,b.awrap(ut(a,this.payloadManager.getMasterCollection(),t,n));case 6:return i=c.sent,c.next=9,b.awrap(this.payloadManager.emitPayloads(i,ht.a.LocalChanged));case 9:return s=this.findItem(i[0].uuid),c.abrupt("return",s);case 11:case"end":return c.stop()}},null,this,null,Promise)}},{key:"createItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=i.length>3?i[3]:void 0,e){s.next=4;break}throw'Attempting to create item with no contentType';case 4:return s.t0=Object(Ee.e),s.next=7,b.awrap(I.GenerateUuid());case 7:return s.t1=s.sent,s.t2=e,s.t3=t?Object(Ke.a)(t):void 0,s.t4=n,s.t5={uuid:s.t1,content_type:s.t2,content:s.t3,dirty:s.t4},s.t6=r,a=(0,s.t0)(s.t5,s.t6),s.next=16,b.awrap(this.payloadManager.emitPayload(a,ht.a.Constructor));case 16:return s.abrupt("return",this.findItem(a.uuid));case 17:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Object(Ee.e),r.next=3,b.awrap(I.GenerateUuid());case 3:return r.t1=r.sent,r.t2=e,r.t3=Object(Ke.a)(t||{}),r.t4={uuid:r.t1,content_type:r.t2,content:r.t3},n=(0,r.t0)(r.t4),r.abrupt("return",nt(n));case 9:case"end":return r.stop()}},null,null,null,Promise)}},{key:"insertItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemFromPayload(e.payload));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"insertItems",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemsFromPayloads(e.map(function(e){return e.payload})));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emitItemFromPayload",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:ht.a.Constructor,r.next=3,b.awrap(this.payloadManager.emitPayload(e,t));case 3:return r.abrupt("return",this.findItem(e.uuid));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitItemsFromPayloads",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:ht.a.Constructor,a.next=3,b.awrap(this.payloadManager.emitPayloads(e,t));case 3:return n=Object(Ke.b)(e),a.abrupt("return",this.findItems(n));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemToBeDeleted",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this.collection.uuidsThatReferenceUuid(e),r=this.findItem(e),u.next=4,b.awrap(this.changeItem(e,function(e){e.setDeleted()},void 0,t));case 4:a=u.sent,i=S(n);case 6:if((s=i()).done){u.next=14;break}if(o=s.value,!(c=this.findItem(o))){u.next=12;break}return u.next=12,b.awrap(this.changeItem(c.uuid,function(e){e.removeItemAsRelationship(r)}));case 12:u.next=6;break;case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}},null,this,null,Promise)}},{key:"setItemsToBeDeleted",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.all(e.map(function(e){return t.setItemToBeDeleted(e)})));case 1:case"end":return n.stop()}},null,null,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.collection.all(e);return t?n.filter(function(e){return!e.errorDecrypting&&!e.waitingForKey}):n}},{key:"nonErroredItemsForContentType",value:function(e){return this.collection.all(e).filter(function(e){return!e.errorDecrypting&&!e.waitingForKey})}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.subItemsMatchingPredicates(this.items,e)}},{key:"subItemsMatchingPredicates",value:function(e,t){return e.filter(function(e){if(e.deleted)return!1;for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!e.satisfiesPredicate(a))return!1}return!0})}},{key:"findTagByTitle",value:function(e){var t=e.toLowerCase();return this.tags.find(function(e){return e.title.toLowerCase()===t})}},{key:"searchTags",value:function(e,t){var n=this;return Object(_.G)(this.tags.filter(function(r){var a=new RegExp("^".concat(e,"|").concat(".").concat(e),'i').test(r.title),i=!!t&&n.itemsReferencingItem(t.uuid).some(function(e){return(null===e||void 0===e?void 0:e.uuid)===r.uuid});return a&&!i}),'title')}},{key:"getTagParent",value:function(e){var t=this.findItem(e).parentId;if(t)return this.findItem(t)}},{key:"getTagParentChain",value:function(e){for(var t=this.findItem(e).parentId,n=[];t;){var r=this.findItem(t);n.unshift(r),t=r.parentId}return n}},{key:"getTagChildren",value:function(e){var t=this.findItem(e);return this.collection.elementsReferencingElement(t)}},{key:"isTagAncestor",value:function(e,t){for(var n=this.findItem(t).parentId;n;){if(n===e)return!0;n=this.findItem(n).parentId}return!1}},{key:"isValidTagParent",value:function(e,t){return e!==t&&!this.isTagAncestor(t,e)}},{key:"setTagParent",value:function(e,t){if(e.uuid===t.uuid)throw new Error('can not set a tag parent of itself');if(this.isTagAncestor(t.uuid,e.uuid))throw new Error('can not set a tag ancestor of itself');return this.changeTag(t.uuid,function(t){t.makeChildOf(e)})}},{key:"unsetTagParent",value:function(e){var t=this.getTagParent(e.uuid);return t?this.changeTag(e.uuid,function(e){e.removeItemAsRelationship(t)}):Promise.resolve(e)}},{key:"addTagToNote",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.changeItem(t.uuid,function(t){t.addItemAsRelationship(e)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getSortedTagsForNote",value:function(e){return Object(_.G)(this.itemsReferencingItem(e.uuid).filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===F.a.Tag}),'title')}},{key:"findOrCreateTagByTitle",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.findTagByTitle(e),n.t0=t,n.t0){n.next=6;break}return n.next=5,b.awrap(this.createItem(F.a.Tag,Object(Ke.a)({title:e}),!0));case 5:n.t0=n.sent;case 6:return n.abrupt("return",n.t0);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"notesMatchingSmartTag",value:function(e){return this.notesView.notesMatchingSmartTag(e)}},{key:"emptyTrash",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.trashedItems,t.abrupt("return",this.setItemsToBeDeleted(Object(Ke.b)(e)));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){var e=this.collection.displayElements(F.a.SmartTag);return this.systemSmartTags.concat(e)}},{key:"removeAllItemsFromMemory",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Object(Ke.b)(this.items),t.next=3,b.awrap(this.changeItems(e,function(e){e.setDeleted()},T.c.NonDirtying));case 3:this.resetState(),this.payloadManager.resetState();case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"removeItemLocally",value:function(e){this.collection.discard(e),this.payloadManager.removePayloadLocally(e.payload)}},{key:"items",get:function(){return this.collection.all()}},{key:"nonDeletedItems",get:function(){return this.collection.nondeletedElements()}},{key:"invalidItems",get:function(){return this.collection.invalidElements()}},{key:"notes",get:function(){return this.notesView.displayElements()}},{key:"tags",get:function(){return this.collection.displayElements(F.a.Tag)}},{key:"components",get:function(){return this.collection.displayElements(F.a.Component)}},{key:"trashSmartTag",get:function(){return this.systemSmartTags.find(function(e){return e.isTrashTag})}},{key:"trashedItems",get:function(){return this.notesMatchingSmartTag(this.trashSmartTag)}},{key:"noteCount",get:function(){return this.collection.all(F.a.Note).length}}]),n})(R.a),Er='all-notes',Rr='archived-notes',Ir='trashed-notes';function Mr(e,t){return e.sort(function(e,n){var r=new Date(n.serverUpdatedAt).getTime()-new Date(e.serverUpdatedAt).getTime(),a=0,i=0;return t&&(a=t.indexOf(e.content_type),i=t.indexOf(n.content_type),-1===a&&(a=t.length),-1===i&&(i=t.length)),a===i?r:a<i?-1:1})}var Ar=(function(){function e(t,n){v(this,e),this.discordance=0,this.outOfSync=!1,this.receiver=t,this.maxDiscordance=n,this.reset()}return y(e,[{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"reset",value:function(){this.lastPreSyncSave=void 0,this.lastSyncDate=void 0,this.discordance=0,this.outOfSync=!1}},{key:"getLastClientIntegrityHash",value:function(){return this.lastClientHash}},{key:"clearIntegrityHashes",value:function(){this.lastClientHash=void 0,this.lastServerHash=void 0}},{key:"setIntegrityHashes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.lastClientHash=e,this.lastServerHash=t,!t||0===t.length||!e||e===t?(this.outOfSync&&(this.outOfSync=!1,this.receiver(on.a.ExitOutOfSync)),this.discordance=0):(this.discordance++,this.discordance>=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(on.a.EnterOutOfSync)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordance<this.maxDiscordance}}]),e})(),jr=Object.freeze([F.a.ServerExtension]);function Tr(e){return e.filter(function(e){var t=![ue.a.DecryptedBareObject,ue.a.DecryptedBase64String].includes(e.format),n=jr.includes(e.content_type),r=t||n;return r||console.error('Filtering disallowed payload',e),r})}var Kr=(function(){function e(t,n,r,a,i){v(this,e),this.apiService=t,this.protocolService=n,this.contentType=r,this.customEvent=a,this.limit=i,this.progress={retrievedPayloads:[]}}return y(e,[{key:"run",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.apiService.sync([],this.progress.lastSyncToken,this.progress.paginationToken,this.limit||500,!1,this.contentType,this.customEvent));case 2:return r=s.sent,a=Tr(r.data.retrieved_items.map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)})),s.next=6,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a));case 6:if(i=s.sent,this.progress.retrievedPayloads=this.progress.retrievedPayloads.concat(i),this.progress.lastSyncToken=null===(e=r.data)||void 0===e?void 0:e.sync_token,this.progress.paginationToken=null===(t=r.data)||void 0===t?void 0:t.cursor_token,null===(n=r.data)||void 0===n||!n.cursor_token){s.next=14;break}return s.abrupt("return",this.run());case 14:return s.abrupt("return",this.progress.retrievedPayloads);case 15:case"end":return s.stop()}},null,this,null,Promise)}}]),e})(),Fr=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}if(r=n.value,a=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient)){s.next=7;break}throw'Unable to find decrypted counterpart for rejected payload.';case 7:i=Object(Ee.f)(a,ht.a.RemoteRejected,{lastSyncEnd:new Date,dirty:!1}),e.push(i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRejected));case 12:case"end":return s.stop()}},null,this,null,Promise)}}]),n})();function Lr(e){if(e===ht.a.RemoteRetrieved)return Rt;if(e===ht.a.RemoteSaved)return It;if(e===ht.a.ConflictData||e===ht.a.ConflictUuid)return Et;if(e===ht.a.RemoteRejected)return Fr;throw"No delta class found for source ".concat(ht.a[e])}var Ur,Nr=(function(){function e(t){v(this,e),this.collections=t,Object.freeze(this)}return y(e,[{key:"collectionForSource",value:function(e){return this.collections.find(function(t){return t.source===e})}}]),e})(),Vr=(function(){function e(t,n,r,a,i){v(this,e),this.response=t,this.baseCollection=r,this.historyMap=i,this.relatedCollectionSet=new Nr([bt.WithPayloads(n,ht.a.DecryptedTransient),bt.WithPayloads(a,ht.a.SavedOrSaving)])}return y(e,[{key:"collectionsByProcessingResponse",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return e=[],s.next=3,b.awrap(this.collectionByProcessingPayloads(this.response.retrievedPayloads,ht.a.RemoteRetrieved));case 3:return(t=s.sent).all().length>0&&e.push(t),s.next=7,b.awrap(this.collectionByProcessingPayloads(this.response.savedPayloads,ht.a.RemoteSaved));case 7:if((n=s.sent).all().length>0&&e.push(n),!(this.response.uuidConflictPayloads.length>0)){s.next=14;break}return s.next=12,b.awrap(this.collectionByProcessingPayloads(this.response.uuidConflictPayloads,ht.a.ConflictUuid));case 12:(r=s.sent).all().length>0&&e.push(r);case 14:if(!(this.response.dataConflictPayloads.length>0)){s.next=19;break}return s.next=17,b.awrap(this.collectionByProcessingPayloads(this.response.dataConflictPayloads,ht.a.ConflictData));case 17:(a=s.sent).all().length>0&&e.push(a);case 19:if(!(this.response.rejectedPayloads.length>0)){s.next=24;break}return s.next=22,b.awrap(this.collectionByProcessingPayloads(this.response.rejectedPayloads,ht.a.RemoteRejected));case 22:(i=s.sent).all().length>0&&e.push(i);case 24:return s.abrupt("return",e);case 25:case"end":return s.stop()}},null,this,null,Promise)}},{key:"collectionByProcessingPayloads",value:function(e,t){var n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=bt.WithPayloads(Tr(e),t),r=Lr(t),a=new r(this.baseCollection,n,this.relatedCollectionSet,this.historyMap),c.next=5,b.awrap(a.resultingCollection());case 5:return i=c.sent,s=i.all().map(function(e){var t=o.finalDirtyStateForPayload(e);return Object(Ee.b)(e,{dirty:t,dirtiedDate:t?new Date:void 0})}),c.abrupt("return",bt.WithPayloads(s,t));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"finalDirtyStateForPayload",value:function(e){var t=this.baseCollection.find(e.uuid);return t?!t.dirtiedDate||e.dirtiedDate&&e.dirtiedDate>t.dirtiedDate?e.dirty:!e.discardable&&t.dirtiedDate>=t.lastSyncBegan:e.dirty}}]),e})(),Br=(function(){function e(t){var n,r;v(this,e),this.rawResponse=t,this.savedPayloads=this.filterRawItemArray(null===(n=t.data)||void 0===n?void 0:n.saved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteSaved)}),this.retrievedPayloads=this.filterRawItemArray(null===(r=t.data)||void 0===r?void 0:r.retrieved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)}),this.dataConflictPayloads=this.filterRawItemArray(this.rawDataConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictData)}),this.uuidConflictPayloads=this.filterRawItemArray(this.rawUuidConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictUuid)}),this.rejectedPayloads=this.filterRawItemArray(this.rawRejectedPayloads).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRejected)}),this.deletedPayloads=this.allProcessedPayloads.filter(function(e){return e.discardable}),Object(_.l)(this)}return y(e,[{key:"filterRawItemArray",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return!!e.uuid})}},{key:"error",get:function(){var e;return this.rawResponse.error||(null===(e=this.rawResponse.data)||void 0===e?void 0:e.error)}},{key:"status",get:function(){return this.rawResponse.status}},{key:"lastSyncToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.LastSyncToken]}},{key:"paginationToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.PaginationToken]}},{key:"integrityHash",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.IntegrityResult]}},{key:"checkIntegrity",get:function(){return this.integrityHash&&!this.paginationToken}},{key:"numberOfItemsInvolved",get:function(){return this.allProcessedPayloads.length}},{key:"allProcessedPayloads",get:function(){return this.savedPayloads.concat(this.retrievedPayloads).concat(this.dataConflictPayloads).concat(this.uuidConflictPayloads).concat(this.rejectedPayloads)}},{key:"rawUuidConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.UuidConflict}).map(function(e){return e.unsaved_item||e.item})}},{key:"rawDataConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ConflictingData}).map(function(e){return e.server_item||e.item})}},{key:"rawRejectedPayloads",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ContentTypeError||e.type===Te.a.ContentError}).map(function(e){return e.unsaved_item})}},{key:"rawConflictObjects",get:function(){var e,t,n=(null===(e=this.rawResponse.data)||void 0===e?void 0:e.conflicts)||[],r=(null===(t=this.rawResponse.data)||void 0===t?void 0:t.unsaved)||[];return n.concat(r)}},{key:"hasError",get:function(){return!Object(_.w)(this.rawResponse.error)}}]),e})();!(function(e){e[e.Response=1]="Response",e[e.StatusChanged=2]="StatusChanged"})(Ur||(Ur={}));var Wr=150,Hr=(function(){function e(t,n,r,a,i,s){v(this,e),this.payloads=t,this.receiver=n,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.id=Math.random(),this.responses=[],this.payloads=t,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.receiver=n,this.pendingPayloads=t.slice()}return y(e,[{key:"popPayloads",value:function(e){var t=this.pendingPayloads.slice(0,e);return Object(_.R)(this.pendingPayloads,t),t}},{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.receiver(Ur.StatusChanged,void 0,{completedUploadCount:this.totalUploadCount-this.pendingUploadCount,totalUploadCount:this.totalUploadCount}));case 2:return e=this.popPayloads(this.upLimit),r.next=5,b.awrap(this.apiService.sync(e,this.lastSyncToken,this.paginationToken,this.downLimit,this.checkIntegrity,void 0,void 0));case 5:return t=r.sent,n=new Br(t),this.responses.push(n),this.lastSyncToken=n.lastSyncToken,this.paginationToken=n.paginationToken,r.next=12,b.awrap(this.receiver(Ur.Response,n));case 12:if(this.done){r.next=14;break}return r.abrupt("return",this.run());case 14:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsSavedOrSaving",get:function(){return Object(_.c)(this.payloads,this.pendingPayloads)}},{key:"done",get:function(){return 0===this.pendingPayloads.length&&!this.paginationToken}},{key:"pendingUploadCount",get:function(){return this.pendingPayloads.length}},{key:"totalUploadCount",get:function(){return this.payloads.length}},{key:"upLimit",get:function(){return Wr}},{key:"downLimit",get:function(){return Wr}},{key:"numberOfItemsInvolved",get:function(){for(var e,t=0,n=S(this.responses);!(e=n()).done;){t+=e.value.numberOfItemsInvolved}return t}}]),e})(),zr=(function(){function e(t,n){v(this,e),this.payloads=t,this.receiver=n}return y(e,[{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=this.payloads.map(function(e){return Object(Ee.f)(e,ht.a.LocalSaved,{dirty:!1,lastSyncEnd:new Date})}),t=Object(_.a)(e),n=new Br({data:{saved_items:t}}),r.next=5,b.awrap(this.receiver(Ur.Response,n));case 5:case"end":return r.stop()}},null,this,null,Promise)}}]),e})();function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Qr,Jr,$r,Xr=5,Zr=15;!(function(e){e[e.ResolveOnNext=1]="ResolveOnNext",e[e.ForceSpawnNew=2]="ForceSpawnNew"})(Qr||(Qr={})),(function(e){e[e.Default=1]="Default",e[e.DownloadFirst=2]="DownloadFirst"})(Jr||(Jr={})),(function(e){e[e.External=1]="External",e[e.SpawnQueue=2]="SpawnQueue",e[e.ResolveQueue=3]="ResolveQueue",e[e.MoreDirtyItems=4]="MoreDirtyItems",e[e.AfterDownloadFirst=5]="AfterDownloadFirst",e[e.IntegrityCheck=6]="IntegrityCheck",e[e.ResolveOutOfSync=7]="ResolveOutOfSync"})($r||($r={}));var ea=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).itemManager=e,l.sessionManager=r,l.protocolService=a,l.storageService=i,l.payloadManager=s,l.apiService=o,l.historyService=c,l.resolveQueue=[],l.spawnQueue=[],l.completedOnlineDownloadFirstSync=!1,l.majorChangeThreshold=Zr,l.maxDiscordance=Xr,l.locked=!1,l.databaseLoaded=!1,l.syncLock=!1,l.dealloced=!1,l.localLoadPriorty=[F.a.ItemsKey,F.a.UserPrefs,F.a.Component,F.a.Theme],l.itemManager=e,l.sessionManager=r,l.protocolService=a,l.payloadManager=s,l.storageService=i,l.apiService=o,l.interval=u,l.initializeStatus(),l.initializeState(),l}return y(n,[{key:"onNewDatabaseCreated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.getLastSyncToken());case 2:if(!e.sent){e.next=5;break}return e.next=5,b.awrap(this.clearSyncPositionTokens());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.dealloced=!0,this.sessionManager=void 0,this.itemManager=void 0,this.protocolService=void 0,this.payloadManager=void 0,this.storageService=void 0,this.apiService=void 0,this.interval=void 0,this.state.reset(),this.opStatus.reset(),this.state=void 0,this.opStatus=void 0,this.resolveQueue.length=0,this.spawnQueue.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeStatus",value:function(){var e=this;this.opStatus=new fr(this.interval,function(t){e.notifyEvent(t)})}},{key:"initializeState",value:function(){var e=this;this.state=new Ar(function(t){t===on.a.EnterOutOfSync?e.notifyEvent(on.a.EnterOutOfSync):t===on.a.ExitOutOfSync&&e.notifyEvent(on.a.ExitOutOfSync)},this.maxDiscordance)}},{key:"lockSyncing",value:function(){this.locked=!0}},{key:"unlockSyncing",value:function(){this.locked=!1}},{key:"isOutOfSync",value:function(){return this.state.isOutOfSync()}},{key:"getLastSyncDate",value:function(){return this.state.lastSyncDate}},{key:"getStatus",value:function(){return this.opStatus}},{key:"resetSyncState",value:function(){this.state.reset()}},{key:"isDatabaseLoaded",value:function(){return this.databaseLoaded}},{key:"getDatabasePayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageService.getAllRawPayloads().catch(function(t){throw e.notifyEvent(on.a.DatabaseReadError,t),t}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadDatabasePayloads",value:function(e){var t,n,r,a,i,s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.databaseLoaded){d.next=2;break}throw'Attempting to initialize already initialized local database.';case 2:if(0!==e.length){d.next=6;break}return this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0),d.abrupt("return");case 6:return t=e.map(function(e){try{return Object(Ee.e)(e)}catch(e){return void console.error('Creating payload failed',e)}}).filter(function(e){return!Object(_.w)(e)}),n=Mr(t,this.localLoadPriorty),r=n.filter(function(e){return e.content_type===F.a.ItemsKey}),Object(_.R)(n,r),d.next=12,b.awrap(this.protocolService.payloadsByDecryptingPayloads(r));case 12:return a=d.sent,d.next=15,b.awrap(this.payloadManager.emitPayloads(a,ht.a.LocalRetrieved));case 15:i=n.length,s=100,o=Math.ceil(i/s),c=0;case 19:if(!(c<o)){d.next=32;break}return u=c*s,l=n.slice(u,u+s),d.next=24,b.awrap(this.protocolService.payloadsByDecryptingPayloads(l));case 24:return p=d.sent,d.next=27,b.awrap(this.payloadManager.emitPayloads(p,ht.a.LocalRetrieved));case 27:this.notifyEvent(on.a.LocalDataIncrementalLoad),this.opStatus.setDatabaseLoadStatus(u,i,!1);case 29:c++,d.next=19;break;case 32:this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0);case 34:case"end":return d.stop()}},null,this,null,Promise)}},{key:"setLastSyncToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.syncToken=e,t.abrupt("return",this.storageService.setValue(o.LastSyncToken,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setPaginationToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cursorToken=e,!e){t.next=5;break}return t.abrupt("return",this.storageService.setValue(o.PaginationToken,e));case 5:return t.abrupt("return",this.storageService.removeValue(o.PaginationToken));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLastSyncToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.syncToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.LastSyncToken));case 3:this.syncToken=e.sent;case 4:return e.abrupt("return",this.syncToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPaginationToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cursorToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.PaginationToken));case 3:this.cursorToken=e.sent;case 4:return e.abrupt("return",this.cursorToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"clearSyncPositionTokens",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.syncToken=void 0,this.cursorToken=void 0,e.next=4,b.awrap(this.storageService.removeValue(o.LastSyncToken));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.PaginationToken));case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"itemsNeedingSync",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.itemManager.getDirtyItems(),t.abrupt("return",e);case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"alternateUuidForItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=this.itemManager.findItem(e),n=Object(Ee.e)(t),a.next=4,b.awrap(lt(n,this.payloadManager.getMasterCollection()));case 4:return r=a.sent,a.next=7,b.awrap(this.payloadManager.emitPayloads(r,ht.a.LocalChanged));case 7:return a.next=9,b.awrap(this.persistPayloads(r));case 9:return a.abrupt("return",this.itemManager.findItem(r[0].uuid));case 10:case"end":return a.stop()}},null,this,null,Promise)}},{key:"markAllItemsAsNeedingSync",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.log('Marking all items as needing sync'),e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e,{dirty:!0,dirtiedDate:new Date})}),n.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 5:return n.next=7,b.awrap(this.persistPayloads(t));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"popPayloadsNeedingPreSyncSave",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.state.lastPreSyncSave){r.next=3;break}return r.abrupt("return",e);case 3:return n=e.filter(function(e){return!e.dirtiedDate||e.dirtiedDate>t}),this.state.lastPreSyncSave=new Date,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"queueStrategyResolveOnNext",value:function(){var e=this;return new Promise(function(t,n){e.resolveQueue.push({resolve:t,reject:n})})}},{key:"queueStrategyForceSpawnNew",value:function(e){var t=this;return new Promise(function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})})}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(_.N)(this.spawnQueue,0),this.log('Syncing again from spawn queue'),this.sync(Yr({queueStrategy:Qr.ForceSpawnNew,source:$r.SpawnQueue},e.options)).then(function(){e.resolve()}).catch(function(){e.reject()})}},{key:"payloadsByPreparingForServer",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.protocolService.payloadsByEncryptingPayloads(e,function(e){return jr.includes(e.content_type)?Re.b.SyncDecrypted:Re.b.Sync}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"downloadFirstSync",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:n=5,r=0;case 2:if(!(r<n)){a.next=14;break}return a.next=5,b.awrap(this.sync(Yr({mode:Jr.DownloadFirst,queueStrategy:Qr.ForceSpawnNew},t)).catch(console.error));case 5:if(!this.completedOnlineDownloadFirstSync){a.next=9;break}return a.abrupt("return");case 9:return a.next=11,b.awrap(Object(_.P)(e));case 11:r++,a.next=2;break;case 14:console.error("Failed downloadFirstSync after ".concat(n," tries"));case 15:case"end":return a.stop()}},null,this,null,Promise)}},{key:"awaitCurrentSyncs",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.lastSyncInvokationPromise);case 2:return e.next=4,b.awrap(this.currentSyncRequestPromise);case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"sync",value:function(){var e,t=arguments;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},this.lastSyncInvokationPromise=this.performSync(e),n.abrupt("return",this.lastSyncInvokationPromise);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"performSync",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P=this,O=arguments;return b.async(function(C){for(;;)switch(C.prev=C.next){case 0:if(e=O.length>0&&void 0!==O[0]?O[0]:{},!this.locked){C.next=4;break}return this.log('Sync Locked'),C.abrupt("return");case 4:return t=function(){return P.syncLock},n=function(){P.syncLock=!0},r=function(){P.syncLock=!1},a=this.opStatus.syncInProgress,i=this.databaseLoaded,(s=!t())&&i&&!a&&n(),e.source||(e.source=$r.External),C.next=14,b.awrap(this.itemsNeedingSync());case 14:return o=C.sent,c=new Date,u=o.filter(function(e){return e.neverSynced&&e.deleted}),Object(_.R)(o,u),l=o.map(function(e){return e.payloadRepresentation()}),C.next=21,b.awrap(this.popPayloadsNeedingPreSyncSave(l));case 21:return p=C.sent,C.next=24,b.awrap(this.persistPayloads(p));case 24:if(d=this.resolveQueue.slice(),h=Object(_.w)(e.queueStrategy)?Qr.ResolveOnNext:e.queueStrategy,!a&&i&&s){C.next=37;break}if(this.log(s?a?'Attempting to sync while existing sync in progress.':'Attempting to sync before local database has loaded.':'Another function call has begun preparing for sync.'),h!==Qr.ResolveOnNext){C.next=32;break}return C.abrupt("return",this.queueStrategyResolveOnNext());case 32:if(h!==Qr.ForceSpawnNew){C.next=36;break}return C.abrupt("return",this.queueStrategyForceSpawnNew({mode:e.mode,checkIntegrity:e.checkIntegrity,source:e.source}));case 36:throw Error("Unhandled timing strategy ".concat(h));case 37:if(!this.dealloced){C.next=39;break}return C.abrupt("return");case 39:return this.opStatus.setDidBegin(),C.next=42,b.awrap(this.notifyEvent(on.a.SyncWillBegin));case 42:if(Object(_.R)(this.resolveQueue,d),!(o.length>0)){C.next=46;break}return C.next=46,b.awrap(this.itemManager.changeItems(Object(Ke.b)(o),function(e){e.lastSyncBegan=c},T.c.NonDirtying,ht.a.PreSyncSave));case 46:if(this.protocolService.hasAccount()!==this.sessionManager.online()&&this.handleInvalidSessionState(),f=this.sessionManager.online(),D=e.mode,v=f&&!P.completedOnlineDownloadFirstSync?Jr.DownloadFirst:Object(_.w)(D)?Jr.Default:D,y=[],v!==Jr.Default){C.next=63;break}if(!f||this.completedOnlineDownloadFirstSync){C.next=54;break}throw Error('Attempting to default mode sync without having completed initial.');case 54:if(!f){C.next=60;break}return C.next=57,b.awrap(this.payloadsByPreparingForServer(l));case 57:y=C.sent,C.next=61;break;case 60:y=l;case 61:C.next=64;break;case 63:v===Jr.DownloadFirst&&(y=[]);case 64:if(!f){C.next=70;break}return C.next=67,b.awrap(this.syncOnlineOperation(y,e.checkIntegrity,e.source,v));case 67:g=C.sent,C.next=73;break;case 70:return C.next=72,b.awrap(this.syncOfflineOperation(y,e.source,v));case 72:g=C.sent;case 73:return this.currentSyncRequestPromise=g.run(),C.next=76,b.awrap(this.currentSyncRequestPromise);case 76:if(!this.dealloced){C.next=78;break}return C.abrupt("return");case 78:if(this.opStatus.setDidEnd(),r(),!this.opStatus.hasError()){C.next=82;break}return C.abrupt("return");case 82:if(this.opStatus.reset(),this.state.lastSyncDate=new Date,g instanceof Hr&&g.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(on.a.MajorDataChange),!(u.length>0)){C.next=88;break}return C.next=88,b.awrap(this.handleNeverSyncedDeleted(u));case 88:if(v===Jr.DownloadFirst){C.next=91;break}return C.next=91,b.awrap(this.notifyEvent(on.a.FullSyncCompleted,{source:e.source}));case 91:if(v!==Jr.DownloadFirst){C.next=99;break}return f&&(this.completedOnlineDownloadFirstSync=!0),C.next=95,b.awrap(this.notifyEvent(on.a.DownloadFirstSyncCompleted));case 95:return C.next=97,b.awrap(this.sync({source:$r.AfterDownloadFirst,checkIntegrity:!0,awaitAll:e.awaitAll}));case 97:C.next=125;break;case 99:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){C.next=107;break}if(this.log('Syncing again from resolve queue'),m=this.sync({source:$r.ResolveQueue,checkIntegrity:e.checkIntegrity}),!e.awaitAll){C.next=105;break}return C.next=105,b.awrap(m);case 105:C.next=125;break;case 107:return C.next=109,b.awrap(this.itemsNeedingSync());case 109:if(C.t0=C.sent.length,!(C.t0>0)){C.next=115;break}return C.next=113,b.awrap(this.sync({source:$r.MoreDirtyItems,checkIntegrity:e.checkIntegrity,awaitAll:e.awaitAll}));case 113:C.next=125;break;case 115:if(!(g instanceof Hr&&g.checkIntegrity)){C.next=124;break}if(!this.state.needsSync||!g.done){C.next=122;break}if(this.log('Syncing again from integrity check'),w=this.sync({checkIntegrity:!0,queueStrategy:Qr.ForceSpawnNew,source:$r.IntegrityCheck,awaitAll:e.awaitAll}),!e.awaitAll){C.next=122;break}return C.next=122,b.awrap(w);case 122:C.next=125;break;case 124:this.state.clearIntegrityHashes();case 125:for(k=S(d);!(x=k()).done;)x.value.resolve();case 126:case"end":return C.stop()}var D},null,this,null,Promise)}},{key:"handleInvalidSessionState",value:function(){we.a.error(Error('Session missing while attempting to sync.')),this.sessionManager.reauthenticateInvalidSession()}},{key:"syncOnlineOperation",value:function(e,t,n,r){var a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.t0=Hr,s.t1=e,s.t2=function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next=r.t0===Ur.Response?3:r.t0===Ur.StatusChanged?13:15;break;case 3:if(!i.dealloced){r.next=5;break}return r.abrupt("return");case 5:if(!t.hasError){r.next=10;break}return r.next=8,b.awrap(i.handleErrorServerResponse(t));case 8:r.next=12;break;case 10:return r.next=12,b.awrap(i.handleSuccessServerResponse(a,t));case 12:return r.abrupt("break",15);case 13:return i.opStatus.setUploadStatus(n.completedUploadCount,n.totalUploadCount),r.abrupt("break",15);case 15:case"end":return r.stop()}},null,null,null,Promise)},s.next=5,b.awrap(this.getLastSyncToken());case 5:return s.t3=s.sent,s.next=8,b.awrap(this.getPaginationToken());case 8:return s.t4=s.sent,s.t5=t,s.t6=this.apiService,a=new s.t0(s.t1,s.t2,s.t3,s.t4,s.t5,s.t6),this.log('Syncing online user','source:',n,'operation id',a.id,'integrity check',t,'mode:',r,'payloads:',e),s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"syncOfflineOperation",value:function(e,t,n){var r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return this.log('Syncing offline user','source:',t,'mode:',n,'payloads:',e),r=new zr(e,function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!a.dealloced){n.next=2;break}return n.abrupt("return");case 2:if(e!==Ur.Response){n.next=5;break}return n.next=5,b.awrap(a.handleOfflineResponse(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}),i.abrupt("return",r);case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleOfflineResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.log('Offline Sync Response',e.rawResponse),!((t=e.savedPayloads).length>0)){a.next=8;break}return a.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalSaved));case 5:return n=this.payloadManager.find(Object(Ke.b)(t)),a.next=8,b.awrap(this.persistPayloads(n));case 8:if(!((r=e.deletedPayloads).length>0)){a.next=12;break}return a.next=12,b.awrap(this.deletePayloads(r));case 12:return this.opStatus.clearError(),this.opStatus.setDownloadStatus(e.retrievedPayloads.length),a.next=16,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,e));case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleErrorServerResponse",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.log('Sync Error',e),401===e.status&&this.notifyEvent(on.a.InvalidSession),null===(t=this.opStatus)||void 0===t||t.setError(e.error),this.notifyEvent(on.a.SyncError,e.error);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleSuccessServerResponse",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k;return b.async(function(x){for(;;)switch(x.prev=x.next){case 0:if(!this._simulate_latency){x.next=3;break}return x.next=3,b.awrap(Object(_.P)(this._simulate_latency.latency));case 3:this.log('Online Sync Response','operation id',e.id,t.rawResponse),this.setLastSyncToken(t.lastSyncToken),this.setPaginationToken(t.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus(t.retrievedPayloads.length),n=[],r=t.allProcessedPayloads,a={},i=S(r);case 12:if((s=i()).done){x.next=25;break}if(!(o=s.value).deleted&&o.fields.includes(Je.a.Content)){x.next=16;break}return x.abrupt("continue",23);case 16:return c=a[o.items_key_id],u=c?nt(c):void 0,x.next=20,b.awrap(this.protocolService.payloadByDecryptingPayload(o,u));case 20:(l=x.sent).content_type===F.a.ItemsKey&&(a[l.uuid]=l),n.push(l);case 23:x.next=12;break;case 25:return p=this.payloadManager.getMasterCollection(),d=this.historyService.getHistoryMapCopy(),h=new Vr(t,n,p,e.payloadsSavedOrSaving,d),x.next=30,b.awrap(h.collectionsByProcessingResponse());case 30:f=x.sent,v=S(f);case 32:if((y=v()).done){x.next=41;break}return g=y.value,x.next=36,b.awrap(this.payloadManager.emitCollection(g));case 36:return m=x.sent,x.next=39,b.awrap(this.persistPayloads(m));case 39:x.next=32;break;case 41:if(!((w=t.deletedPayloads).length>0)){x.next=45;break}return x.next=45,b.awrap(this.deletePayloads(w));case 45:return x.next=47,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,t));case 47:if(!t.checkIntegrity){x.next=53;break}return x.next=50,b.awrap(this.computeDataIntegrityHash());case 50:return k=x.sent,x.next=53,b.awrap(this.state.setIntegrityHashes(k,t.integrityHash));case 53:case"end":return x.stop()}},null,this,null,Promise)}},{key:"handleNeverSyncedDeleted",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e.map(function(e){return e.payloadRepresentation({dirty:!1})}),n.next=3,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.persistPayloads(t));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistPayloads",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(0!==e.length&&!this.dealloced){n.next=2;break}return n.abrupt("return");case 2:return n.abrupt("return",this.storageService.savePayloads(e).catch(function(e){t.notifyEvent(on.a.DatabaseWriteError,e),we.a.error(e)}));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.persistPayloads(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"computeDataIntegrityHash",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:u.prev=0,e=this.itemManager.nonDeletedItems.sort(function(e,t){return t.serverUpdatedAtTimestamp-e.serverUpdatedAtTimestamp}),t=[],n=1e3,r=S(e);case 5:if((a=r()).done){u.next=14;break}if(i=a.value,s=i.serverUpdatedAtTimestamp){u.next=10;break}return u.abrupt("return",void 0);case 10:o=Math.floor(s/n),t.push(o);case 12:u.next=5;break;case 14:return c=t.join(','),u.abrupt("return",this.protocolService.crypto.sha256(c));case 18:return u.prev=18,u.t0=u.catch(0),console.error('Error computing data integrity hash',u.t0),u.abrupt("return",void 0);case 22:case"end":return u.stop()}},null,this,[[0,18]],Promise)}},{key:"resolveOutOfSync",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=new Kr(this.apiService,this.protocolService,void 0,'resolve-out-of-sync'),a.next=3,b.awrap(e.run());case 3:return t=a.sent,n=new _t(this.payloadManager.getMasterCollection(),bt.WithPayloads(t,ht.a.RemoteRetrieved),void 0,this.historyService.getHistoryMapCopy()),a.next=7,b.awrap(n.resultingCollection());case 7:return r=a.sent,a.next=10,b.awrap(this.payloadManager.emitCollection(r));case 10:return a.next=12,b.awrap(this.persistPayloads(r.payloads));case 12:return a.abrupt("return",this.sync({checkIntegrity:!0,source:$r.ResolveOutOfSync}));case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"statelessDownloadAllItems",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=new Kr(this.apiService,this.protocolService,e,t),a.next=3,b.awrap(n.run());case 3:return r=a.sent,a.abrupt("return",r.map(function(e){return nt(e)}));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_clearLastSyncDate",value:function(){this.state.lastSyncDate=void 0}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=void 0}}]),n})(R.a),ta=(function(){function e(t,n,r,a,i,s){v(this,e),this.challenge=t,this.onValidValue=n,this.onInvalidValue=r,this.onNonvalidatedSubmit=a,this.onComplete=i,this.onCancel=s,this.nonvalidatedValues=[],this.validValues=[],this.invalidValues=[],this.artifacts={}}return y(e,[{key:"complete",value:function(e){var t;e||(e=new be(this.challenge,this.validValues,this.artifacts)),null===(t=this.onComplete)||void 0===t||t.call(this,e)}},{key:"nonvalidatedSubmit",value:function(){var e,t=new be(this.challenge,this.nonvalidatedValues.slice(),this.artifacts);null===(e=this.onNonvalidatedSubmit)||void 0===e||e.call(this,t),this.nonvalidatedValues=[]}},{key:"cancel",value:function(){var e;null===(e=this.onCancel)||void 0===e||e.call(this)}},{key:"isFinished",value:function(){return this.validValues.length===this.challenge.prompts.length}},{key:"nonvalidatedPrompts",value:function(){return this.challenge.prompts.filter(function(e){return!e.validates})}},{key:"addNonvalidatedValue",value:function(e){var t=this.nonvalidatedValues,n=t.find(function(t){return t.prompt.id===e.prompt.id});n&&Object(_.M)(t,n),t.push(e),this.nonvalidatedValues.length===this.nonvalidatedPrompts().length&&this.nonvalidatedSubmit()}},{key:"setValueStatus",value:function(e,t,n){var r,a,i=t?this.validValues:this.invalidValues,s=i.find(function(t){return t.prompt.validation===e.prompt.validation});(s&&Object(_.M)(i,s),i.push(e),w(this.artifacts,n),this.isFinished())?this.complete():t?null===(r=this.onValidValue)||void 0===r||r.call(this,e):null===(a=this.onInvalidValue)||void 0===a||a.call(this,e)}}]),e})(),na=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.protocolService=r,a.challengeOperations={},a.challengeObservers={},a}return y(n,[{key:"deinit",value:function(){this.storageService=void 0,this.protocolService=void 0,this.sendChallenge=void 0,this.challengeOperations=void 0,this.challengeObservers=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"promptForChallengeResponse",value:function(e){var t=this;return new Promise(function(n){t.createOrGetChallengeOperation(e,n),t.sendChallenge(e)})}},{key:"validateChallengeValue",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.prompt.validation,t.next=t.t0===te.LocalPasscode?3:t.t0===te.AccountPassword?4:t.t0===te.Biometric?5:t.t0===te.ProtectionSessionDuration?6:7;break;case 3:return t.abrupt("return",this.protocolService.validatePasscode(e.value));case 4:return t.abrupt("return",this.protocolService.validateAccountPassword(e.value));case 5:return t.abrupt("return",{valid:!0===e.value});case 6:return t.abrupt("return",{valid:(n=e.value,'number'==typeof n&&Object.values(er).includes(n))});case 7:throw Error("Unhandled validation mode ".concat(e.prompt.validation));case 8:case"end":return t.stop()}var n},null,this,null,Promise)}},{key:"promptForCorrectPasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=new ye([new ge(te.LocalPasscode)],e,!0),a.next=3,b.awrap(this.promptForChallengeResponse(t));case 3:if(n=a.sent){a.next=6;break}return a.abrupt("return",void 0);case 6:return r=n.getValueForType(te.LocalPasscode),a.abrupt("return",r.value);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",{});case 2:if(e){n.next=8;break}return n.next=5,b.awrap(this.promptForCorrectPasscode(ne.ResaveRootKey));case 5:if(e=n.sent){n.next=8;break}return n.abrupt("return",{canceled:!0});case 8:return n.next=10,b.awrap(this.protocolService.computeWrappingKey(e));case 10:return t=n.sent,n.abrupt("return",{wrappingKey:t});case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"isPasscodeLocked",value:function(){return this.protocolService.rootKeyNeedsUnwrapping()}},{key:"addChallengeObserver",value:function(e,t){var n=this.challengeObservers[e.id]||[];return n.push(t),this.challengeObservers[e.id]=n,function(){Object(_.M)(n,t)}}},{key:"createOrGetChallengeOperation",value:function(e,t){var n=this,r=this.getChallengeOperation(e);return r||(r=new ta(e,function(t){n.onChallengeValidValue(e,t)},function(t){n.onChallengeInvalidValue(e,t)},function(r){n.onChallengeNonvalidatedSubmit(e,r),t(r)},function(r){n.onChallengeComplete(e,r),t(r)},function(){n.onChallengeCancel(e),t(void 0)}),this.challengeOperations[e.id]=r),r}},{key:"performOnObservers",value:function(e,t){for(var n,r=S(this.challengeObservers[e.id]||[]);!(n=r()).done;){t(n.value)}}},{key:"onChallengeValidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onValidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeInvalidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onInvalidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeNonvalidatedSubmit",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onNonvalidatedSubmit)||void 0===n||n.call(e,t)})}},{key:"onChallengeComplete",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onComplete)||void 0===n||n.call(e,t)})}},{key:"onChallengeCancel",value:function(e){this.performOnObservers(e,function(e){var t;null===(t=e.onCancel)||void 0===t||t.call(e)})}},{key:"getChallengeOperation",value:function(e){return this.challengeOperations[e.id]}},{key:"deleteChallengeOperation",value:function(e){delete this.challengeOperations[e.challenge.id]}},{key:"cancelChallenge",value:function(e){var t=this.challengeOperations[e.id];t.cancel(),this.deleteChallengeOperation(t)}},{key:"completeChallenge",value:function(e){var t=this.challengeOperations[e.id];t.complete(),this.deleteChallengeOperation(t)}},{key:"submitValuesForChallenge",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(0!==t.length){c.next=2;break}throw Error('Attempting to submit 0 values for challenge');case 2:n=S(t);case 3:if((r=n()).done){c.next=18;break}if((a=r.value).prompt.validates){c.next=10;break}this.getChallengeOperation(e).addNonvalidatedValue(a),c.next=16;break;case 10:return c.next=12,b.awrap(this.validateChallengeValue(a));case 12:i=c.sent,s=i.valid,o=i.artifacts,this.setValidationStatusForChallenge(e,a,s,o);case 16:c.next=3;break;case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"setValidationStatusForChallenge",value:function(e,t,n,r){var a=this.getChallengeOperation(e);a.setValueStatus(t,n,r),a.isFinished()&&(this.deleteChallengeOperation(a),delete this.challengeObservers[a.challenge.id])}}]),n})(R.a),ra=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).singletonManager=e,i.itemManager=r,i.syncService=a,i.shouldReload=!0,i.reloading=!1,i.removeItemObserver=r.addObserver(F.a.UserPrefs,function(){i.shouldReload=!0}),i.removeSyncObserver=a.addEventObserver(function(e){e===on.a.FullSyncCompleted&&i.reload()}),i}return y(n,[{key:"deinit",value:function(){var e,t;null===(e=this.removeItemObserver)||void 0===e||e.call(this),null===(t=this.removeSyncObserver)||void 0===t||t.call(this),this.singletonManager=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.LoadedDatabase_12&&(this.preferences=this.singletonManager.findSingleton(z.singletonPredicate),this.preferences&&this.notifyEvent("preferencesChanged"));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){var n,r;return null!==(n=null===(r=this.preferences)||void 0===r?void 0:r.getPref(e))&&void 0!==n?n:t}},{key:"setValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.preferences){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,b.awrap(this.itemManager.changeItem(this.preferences.uuid,function(n){n.setPref(e,t)}));case 4:this.preferences=n.sent,this.notifyEvent("preferencesChanged"),this.syncService.sync();case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"reload",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.shouldReload&&!this.reloading){t.next=2;break}return t.abrupt("return");case 2:return this.reloading=!0,t.prev=3,e=this.preferences,t.next=7,b.awrap(this.singletonManager.findOrCreateSingleton(z.singletonPredicate,F.a.UserPrefs,Object(Ke.a)({})));case 7:this.preferences=t.sent,((null===e||void 0===e?void 0:e.uuid)!==this.preferences.uuid||this.preferences.userModifiedDate>e.userModifiedDate)&&this.notifyEvent('preferencesChanged'),this.shouldReload=!1;case 10:return t.prev=10,this.reloading=!1,t.finish(10);case 13:case"end":return t.stop()}},null,this,[[3,,10,13]],Promise)}}]),n})(R.a),aa=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).settingsService=e,i.crypto=r,i.featuresService=a,i}return y(n,[{key:"saveMfaSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.updateSetting(pr.SettingName.MfaSecret,e,!0));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaActivated",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.getSensitiveSetting(pr.SettingName.MfaSecret));case 2:return e=t.sent,t.abrupt("return",null!=e&&0!=e);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.crypto.generateOtpSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.totpToken(e,Date.now(),6,30));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null!=t,!n.t0){n.next=7;break}return n.t1=t,n.next=5,b.awrap(this.getOtpToken(e));case 5:n.t2=n.sent,n.t0=n.t1===n.t2;case 7:if(n.t0){n.next=10;break}throw new Error(j.S.IncorrectMfa);case 10:return n.abrupt("return",this.saveMfaSetting(e));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.settingsService.deleteSetting(pr.SettingName.MfaSecret));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){var e,t=this.featuresService.getFeature(L.FeatureIdentifier.TwoFactorAuth);return void 0!=t&&(!0===t.no_expire||(null!==(e=t.expires_at)&&void 0!==e?e:0)>Date.now())}},{key:"deinit",value:function(){this.settingsService=void 0,this.crypto=void 0,this.featuresService=void 0,p(f(n.prototype),"deinit",this).call(this)}}]),n})(R.a);function ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(n),!0).forEach(function(t){oa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=(function(){function e(t,n,r,a,i,s,o,c,u){v(this,e);var l=arguments.length>9&&void 0!==arguments[9]&&arguments[9],p=arguments.length>10?arguments[10]:void 0;if(this.environment=t,this.platform=n,this.deviceInterface=r,this.crypto=a,this.alertService=i,this.identifier=s,this.swapClasses=o,this.defaultHost=c,this.appVersion=u,this.enableV4=l,this.webSocketUrl=p,this.eventHandlers=[],this.services=[],this.streamRemovers=[],this.serviceObservers=[],this.managedSubscribers=[],this.createdNewDatabase=!1,this.started=!1,this.launched=!1,this.dealloced=!1,this.revokingSession=!1,this.handledFullSyncStage=!1,!we.a.onLog)throw Error('SNLog.onLog must be set.');if(!we.a.onError)throw Error('SNLog.onError must be set.');if(!r)throw Error('Device Interface must be supplied.');if(!t)throw Error('Environment must be supplied when creating an application.');if(!n)throw Error('Platform must be supplied when creating an application.');if(!a)throw Error('Crypto has to be supplied when creating an application.');if(!i)throw Error('AlertService must be supplied when creating an application.');if(!s)throw Error('ApplicationIdentifier must be supplied when creating an application.');if(!o)throw Error('SwapClasses array must be supplied when creating an application.');if(!c)throw Error('defaultHost must be supplied when creating an application.');if(!u)throw Error('appVersion must be supplied when creating an application.');this.constructServices()}return y(e,[{key:"prepareForLaunch",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.setLaunchCallback(e),r.next=3,b.awrap(this.deviceInterface.openDatabase(this.identifier).catch(function(e){n.notifyEvent(At.a.LocalDatabaseReadError,e)}));case 3:return t=r.sent,this.createdNewDatabase=(null===t||void 0===t?void 0:t.isNewDatabase)||!1,r.next=7,b.awrap(this.migrationService.initialize());case 7:return r.next=9,b.awrap(this.notifyEvent(At.a.MigrationsLoaded));case 9:return r.next=11,b.awrap(this.handleStage(ve.PreparingForLaunch_0));case 11:return r.next=13,b.awrap(this.storageService.initializeFromDisk());case 13:return r.next=15,b.awrap(this.notifyEvent(At.a.StorageReady));case 15:return r.next=17,b.awrap(this.protocolService.initialize());case 17:return r.next=19,b.awrap(this.handleStage(ve.ReadyForLaunch_05));case 19:return this.started=!0,r.next=22,b.awrap(this.notifyEvent(At.a.Started));case 22:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setLaunchCallback",value:function(e){this.challengeService.sendChallenge=e.receiveChallenge}},{key:"launch",value:function(){var e,t,n,r,a,i=this,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(e=s.length>0&&void 0!==s[0]&&s[0],this.launched=!1,!(t=this.getLaunchChallenge())){o.next=11;break}return o.next=6,b.awrap(this.challengeService.promptForChallengeResponse(t));case 6:if(n=o.sent){o.next=9;break}throw Error('Launch challenge was cancelled.');case 9:return o.next=11,b.awrap(this.handleLaunchChallengeResponse(n));case 11:if(!this.storageService.isStorageWrapped()){o.next=20;break}return o.prev=12,o.next=15,b.awrap(this.storageService.decryptStorage());case 15:o.next=20;break;case 17:o.prev=17,o.t0=o.catch(12),this.alertService.alert(j.B.StorageDecryptErrorBody,j.B.StorageDecryptErrorTitle);case 20:return o.next=22,b.awrap(this.handleStage(ve.StorageDecrypted_09));case 22:return o.next=24,b.awrap(this.apiService.loadHost());case 24:return o.next=26,b.awrap(this.webSocketsService.loadWebSocketUrl());case 26:return o.next=28,b.awrap(this.sessionManager.initializeFromDisk());case 28:return this.historyManager.initializeFromDisk(),this.settingsService.initializeFromDisk(),o.next=32,b.awrap(this.featuresService.initializeFromDisk());case 32:return this.launched=!0,o.next=35,b.awrap(this.notifyEvent(At.a.Launched));case 35:return o.next=37,b.awrap(this.handleStage(ve.Launched_10));case 37:return o.next=39,b.awrap(this.syncService.getDatabasePayloads());case 39:return r=o.sent,o.next=42,b.awrap(this.handleStage(ve.LoadingDatabase_11));case 42:if(!this.createdNewDatabase){o.next=45;break}return o.next=45,b.awrap(this.syncService.onNewDatabaseCreated());case 45:if(a=this.syncService.loadDatabasePayloads(r).then(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.dealloced){e.next=2;break}throw'Application has been destroyed.';case 2:return e.next=4,b.awrap(i.handleStage(ve.LoadedDatabase_12));case 4:return i.beginAutoSyncTimer(),e.next=7,b.awrap(i.syncService.sync({mode:Jr.DownloadFirst}));case 7:case"end":return e.stop()}},null,null,null,Promise)}),!e){o.next=49;break}return o.next=49,b.awrap(a);case 49:case"end":return o.stop()}},null,this,[[12,17]],Promise)}},{key:"onStart",value:function(){}},{key:"onLaunch",value:function(){}},{key:"getLaunchChallenge",value:function(){return this.protectionService.createLaunchChallenge()}},{key:"handleLaunchChallengeResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!e.challenge.hasPromptForValidationType(te.LocalPasscode)){a.next=9;break}if(n=null===(t=e.artifacts)||void 0===t?void 0:t.wrappingKey){a.next=7;break}return r=e.getValueForType(te.LocalPasscode),a.next=6,b.awrap(this.protocolService.computeWrappingKey(r.value));case 6:n=a.sent;case 7:return a.next=9,b.awrap(this.protocolService.unwrapRootKey(n));case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval(function(){e.syncService.log('Syncing from autosync'),e.sync()},3e4)}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(this.services);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(r.handleApplicationStage(e));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(_.M)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver(function(n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:n===e&&t(e);case 1:case"end":return r.stop()}},null,null,null,Promise)},e)}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e===At.a.Started?this.onStart():e===At.a.Launched&&this.onLaunch(),n=S(this.eventHandlers.slice());case 2:if((r=n()).done){i.next=14;break}if(!(a=r.value).singleEvent||a.singleEvent!==e){i.next=9;break}return i.next=7,b.awrap(a.callback(e,t||{}));case 7:i.next=12;break;case 9:if(a.singleEvent){i.next=12;break}return i.next=12,b.awrap(a.callback(e,t||{}));case 12:i.next=2;break;case 14:this.migrationService.handleApplicationEvent(e);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date}),n.next=3,b.awrap(this.payloadManager.emitPayload(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.syncService.sync());case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"findItem",value:function(e){return this.itemManager.findItem(e)}},{key:"allItems",value:function(){return this.itemManager.items}},{key:"findItems",value:function(e){return this.itemManager.itemsMatchingPredicate(e)}},{key:"getAll",value:function(e){return this.itemManager.findItems(e)}},{key:"mergeItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.emitItemFromPayload(e.payloadRepresentation(),t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createManagedItem",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=a.length>3?a[3]:void 0,i.abrupt("return",this.itemManager.createItem(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.createTemplateItem(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createItemFromPayload",value:function(e){return nt(e)}},{key:"createPayloadFromObject",value:function(e){return Object(Ee.e)(e)}},{key:"getLastSyncDate",value:function(){return this.syncService.getLastSyncDate()}},{key:"getSyncStatus",value:function(){return this.syncService.getStatus()}},{key:"getSessions",value:function(){return this.sessionManager.getSessionsList()}},{key:"revokeSession",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeSessionRevoking());case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.sessionManager.revokeSession(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.revokeAllOtherSessions());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"userCanManageSessions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent,!Object(_.w)(e)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",Object(Q.b)(e,Q.a.V004)>=0);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUserSubscription",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.sessionManager.getSubscription());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data.subscription);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getAvailableSubscriptions());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setItemNeedsSync",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]&&n[1],r.abrupt("return",this.itemManager.setItemDirty(e.uuid,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setItemsNeedsSync",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 2:return t.next=4,b.awrap(this.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emptyTrash",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.itemManager.emptyTrash());case 2:return e.next=4,b.awrap(this.sync());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getTrashedItems",value:function(){return this.itemManager.trashedItems}},{key:"setDisplayOptions",value:function(e,t,n,r){this.itemManager.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.itemManager.setNotesDisplayCriteria(e)}},{key:"getDisplayableItems",value:function(e){return this.itemManager.getDisplayableItems(e)}},{key:"insertItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=de(e,T.c.UserInteraction),n=t.getResult(),a.next=4,b.awrap(this.itemManager.emitItemFromPayload(n));case 4:return r=a.sent,a.abrupt("return",r);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"saveItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.itemManager.findItem(e)){n.next=3;break}throw Error('Attempting to save non-inserted item');case 3:if(t.dirty){n.next=6;break}return n.next=6,b.awrap(this.itemManager.changeItem(e,void 0,T.c.Internal));case 6:return n.next=8,b.awrap(this.syncService.sync());case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,Object(_.A)(e)){s.next=5;break}throw Error('Must use uuid to change item');case 5:return s.next=7,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0,r));case 7:return s.next=9,b.awrap(this.syncService.sync(a));case 9:return s.abrupt("return",this.findItem(e));case 10:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItems",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,s.next=5,b.awrap(this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0,r));case 5:return s.next=7,b.awrap(this.syncService.sync(a));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeItem",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=!(r.length>2&&void 0!==r[2])||r[2],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid to change item');case 3:return a.next=5,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0));case 5:return a.abrupt("return",this.findItem(e));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=!(r.length>2&&void 0!==r[2])||r[2],a.abrupt("return",this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"protectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNote(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNote(e));case 2:return t=n.sent,Object(_.w)(t)||this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.authorizeProtectedActionForNotes(e,t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.itemManager.getItems(e,t)}},{key:"notesMatchingSmartTag",value:function(e){return this.itemManager.notesMatchingSmartTag(e)}},{key:"referencesForItem",value:function(e,t){var n=this.itemManager.referencesForItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"referencingForItem",value:function(e,t){var n=this.itemManager.itemsReferencingItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"duplicateItem",value:function(e,t){var n=this.itemManager.duplicateItem(e.uuid,!1,t);return this.sync(),n}},{key:"findTagByTitle",value:function(e){return this.itemManager.findTagByTitle(e)}},{key:"searchTags",value:function(e,t){return this.itemManager.searchTags(e,t)}},{key:"isValidTagParent",value:function(e,t){return this.itemManager.isValidTagParent(e,t)}},{key:"setTagParent",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.itemManager.setTagParent(e,t));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unsetTagParent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.unsetTagParent(e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getTagParent",value:function(e){return this.itemManager.getTagParent(e.uuid)}},{key:"getTagParentChain",value:function(e){return this.itemManager.getTagParentChain(e.uuid)}},{key:"getTagChildren",value:function(e){return this.itemManager.getTagChildren(e.uuid)}},{key:"getSortedTagsForNote",value:function(e){return this.itemManager.getSortedTagsForNote(e)}},{key:"findOrCreateTag",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.findOrCreateTagByTitle(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){return this.itemManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.itemManager.noteCount}},{key:"streamItems",value:function(e,t){var n=this,r=this.itemManager.addObserver(e,function(e,n,r,a,i){var s=e.concat(n).concat(r);t(s,i)}),a=this.itemManager.getItems(e);return a.length>0&&t(a),this.streamRemovers.push(r),function(){r(),Object(_.M)(n.streamRemovers,r)}}},{key:"toggleComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.componentManager.toggleComponent(e));case 2:return t.next=4,b.awrap(this.syncService.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.apiService.setHost(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.apiService.getHost()}},{key:"setCustomHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.setHost(e));case 2:return t.next=4,b.awrap(this.webSocketsService.setWebSocketUrl(void 0));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUser",value:function(){if(!this.launched)throw Error('Attempting to access user before application unlocked');return this.sessionManager.getUser()}},{key:"getUserPasswordCreationDate",value:function(){return this.protocolService.getPasswordCreatedDate()}},{key:"getProtocolEncryptionDisplayName",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getEncryptionDisplayName());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getUserVersion",value:function(){return this.protocolService.getUserVersion()}},{key:"protocolUpgradeAvailable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isEncryptionAvailable",value:function(){return this.hasAccount()||this.hasPasscode()}},{key:"upgradeProtocolVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.credentialService.performProtocolUpgrade());case 2:return(e=t.sent).success?this.hasAccount()?this.alertService.alert(j.N.SuccessAccount):this.alertService.alert(j.N.SuccessPasscodeOnly):e.error&&this.alertService.alert(j.N.Fail),t.abrupt("return",e);case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"noAccount",value:function(){return!this.hasAccount()}},{key:"hasAccount",value:function(){return this.protocolService.hasAccount()}},{key:"hasProtectionSources",value:function(){return this.protectionService.hasProtectionSources()}},{key:"areProtectionsEnabled",value:function(){return this.protectionService.areProtectionsEnabled()}},{key:"getProtectionSessionExpiryDate",value:function(){return this.protectionService.getSessionExpiryDate()}},{key:"clearProtectionSession",value:function(){return this.protectionService.clearSession()}},{key:"authorizeNoteAccess",value:function(e){return this.protectionService.authorizeNoteAccess(e)}},{key:"authorizeAutolockIntervalChange",value:function(){return this.protectionService.authorizeAutolockIntervalChange()}},{key:"authorizeCloudLinkAccess",value:function(){return this.protectionService.authorizeCloudLinkAccess()}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.protectionService.authorizeSearchingProtectedNotesText()}},{key:"importData",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if(t=d.length>1&&void 0!==d[1]&&d[1],!e.version){h.next=11;break}if(n=e.version,this.protocolService.supportedVersions().includes(n)){h.next=6;break}return h.abrupt("return",{error:j.V});case 6:return h.next=8,b.awrap(this.getUserVersion());case 8:if(!(r=h.sent)||1!==Object(Q.b)(n,r)){h.next=11;break}return h.abrupt("return",{error:j.u});case 11:if(!e.auth_params&&!e.keyParams){h.next=20;break}return i=new ye([new ge(te.None,j.F.FileAccountPassword,void 0,!0)],ne.DecryptEncryptedFile,!0),h.next=15,b.awrap(this.challengeService.promptForChallengeResponse(i));case 15:if(s=h.sent,!Object(_.w)(s)){h.next=18;break}return h.abrupt("return");case 18:this.challengeService.completeChallenge(i),a=s.values[0].value;case 20:return h.next=22,b.awrap(this.protectionService.authorizeFileImport());case 22:if(h.sent){h.next=24;break}return h.abrupt("return");case 24:return h.next=26,b.awrap(this.protocolService.payloadsByDecryptingBackupFile(e,a));case 26:return o=h.sent,c=o.filter(function(e){return!e.errorDecrypting&&e.format!==ue.a.EncryptedString}).map(function(e){return e.content_type===F.a.Component&&e.safeContent.active?Object(Ee.b)(e,{content:sa(sa({},e.safeContent),{},{active:!1})}):e}),h.next=30,b.awrap(this.payloadManager.importPayloads(c));case 30:if(u=h.sent,l=this.sync(),!t){h.next=35;break}return h.next=35,b.awrap(l);case 35:return p=this.getAll(u),h.abrupt("return",{affectedItems:p,errorCount:o.length-c.length});case 37:case"end":return h.stop()}},null,this,null,Promise)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=i.length>1&&void 0!==i[1]&&i[1],n=e===Re.b.FileEncrypted,r=e===Re.b.FileDecrypted,a=n&&t||r,s.t0=a,!s.t0){s.next=9;break}return s.next=8,b.awrap(this.protectionService.authorizeBackupCreation(n));case 8:s.t0=!s.sent;case 9:if(!s.t0){s.next=11;break}return s.abrupt("return");case 11:return s.abrupt("return",this.protocolService.createBackupFile(e));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"sync",value:function(e){return this.syncService.sync(e)}},{key:"isOutOfSync",value:function(){return this.syncService.isOutOfSync()}},{key:"resolveOutOfSync",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.storageService.setValue(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){return this.storageService.getValue(e,t)}},{key:"removeValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.storageService.removeValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getPreference",value:function(e,t){return this.preferencesService.getValue(e,t)}},{key:"setPreference",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.preferencesService.setValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"prepareForDeinit",value:function(){var e,t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e=n.length>0&&void 0!==n[0]?n[0]:0,t=Promise.all(this.services.map(function(e){return e.blockDeinit()})),0!==e){r.next=7;break}return r.next=5,b.awrap(t);case 5:r.next=9;break;case 7:return r.next=9,b.awrap(Promise.race([t,Object(_.P)(e)]));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"promptForCustomChallenge",value:function(e){var t;return null===(t=this.challengeService)||void 0===t?void 0:t.promptForChallengeResponse(e)}},{key:"addChallengeObserver",value:function(e,t){return this.challengeService.addChallengeObserver(e,t)}},{key:"submitValuesForChallenge",value:function(e,t){return this.challengeService.submitValuesForChallenge(e,t)}},{key:"cancelChallenge",value:function(e){this.challengeService.cancelChallenge(e)}},{key:"setOnDeinit",value:function(e){this.onDeinit=e}},{key:"deinit",value:function(e){var t;clearInterval(this.autoSyncInterval);for(var n,r=S(this.serviceObservers);!(n=r()).done;){(0,n.value)()}for(var a,i=S(this.managedSubscribers);!(a=i()).done;){(0,a.value)()}for(var s,o=S(this.services);!(s=o()).done;){s.value.deinit()}null===(t=this.onDeinit)||void 0===t||t.call(this,this,e),this.onDeinit=void 0,this.crypto=void 0,this.createdNewDatabase=!1,this.services.length=0,this.serviceObservers.length=0,this.managedSubscribers.length=0,this.streamRemovers.length=0,this.clearServices(),this.dealloced=!0,this.started=!1}},{key:"register",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=!(a.length>3&&void 0!==a[3])||a[3],i.abrupt("return",this.credentialService.register(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return n=s.length>2&&void 0!==s[2]&&s[2],r=s.length>3&&void 0!==s[3]&&s[3],a=!(s.length>4&&void 0!==s[4])||s[4],i=s.length>5&&void 0!==s[5]&&s[5],o.abrupt("return",this.credentialService.signIn(e,t,n,r,a,i));case 5:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeEmail",value:function(e,t,n){var r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:A.g.EmailChange,i.abrupt("return",this.credentialService.changeCredentials({currentPassword:t,newEmail:e,passcode:n,origination:r,validateNewPasswordStrength:!1}));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"changePassword",value:function(e,t,n){var r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=i.length>3&&void 0!==i[3]?i[3]:A.g.PasswordChange,a=!(i.length>4&&void 0!==i[4])||i[4],s.abrupt("return",this.credentialService.changeCredentials({currentPassword:e,newPassword:t,passcode:n,origination:r,validateNewPasswordStrength:a}));case 3:case"end":return s.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e=i.length>0&&void 0!==i[0]&&i[0],t=function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(a.credentialService.signOut());case 2:return e.next=4,b.awrap(a.notifyEvent(At.a.SignedOut));case 4:return e.next=6,b.awrap(a.prepareForDeinit());case 6:a.deinit(C.SignOut);case 7:case"end":return e.stop()}},null,null,null,Promise)},!e){s.next=6;break}return s.next=5,b.awrap(t());case 5:return s.abrupt("return");case 6:if(!((n=this.itemManager.getDirtyItems()).length>0)){s.next=17;break}return r=1===n.length,s.next=11,b.awrap(this.alertService.confirm("There ".concat(r?'is':'are'," ").concat(n.length," ").concat(r?'item':'items'," with unsynced changes. If you sign out, these changes will be lost forever. Are you sure you want to sign out?")));case 11:if(!s.sent){s.next=15;break}return s.next=15,b.awrap(t());case 15:s.next=19;break;case 17:return s.next=19,b.awrap(t());case 19:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleRevokedSession",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.revokingSession){t.next=2;break}return t.abrupt("return");case 2:return this.revokingSession=!0,e=this.alertService,t.next=6,b.awrap(this.signOut(!0));case 6:e.alert(j.R.CurrentSessionRevoked);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.protocolService.validateAccountPassword(e));case 2:return t=r.sent,n=t.valid,r.abrupt("return",n);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isStarted",value:function(){return this.started}},{key:"isLaunched",value:function(){return this.launched}},{key:"hasBiometrics",value:function(){return this.protectionService.hasBiometricsEnabled()}},{key:"enableBiometrics",value:function(){return this.protectionService.enableBiometrics()}},{key:"disableBiometrics",value:function(){return this.protectionService.disableBiometrics()}},{key:"hasPasscode",value:function(){return this.protocolService.hasPasscode()}},{key:"isLocked",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.challengeService.isPasscodeLocked());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"lock",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=500,t.next=3,b.awrap(this.prepareForDeinit(e));case 3:return t.abrupt("return",this.deinit(C.Lock));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"addPasscode",value:function(e){return this.credentialService.addPasscode(e)}},{key:"removePasscode",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.credentialService.removePasscode());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"changePasscode",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:A.g.PasscodeChange,r.abrupt("return",this.credentialService.changePasscode(e,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.storageService.getStorageEncryptionPolicy()}},{key:"setStorageEncryptionPolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setEncryptionPolicy(e));case 2:return t.abrupt("return",this.protocolService.repersistAllItems());case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableEphemeralPersistencePolicy",value:function(){return this.storageService.setPersistencePolicy(Oe.Ephemeral)}},{key:"hasPendingMigrations",value:function(){return this.migrationService.hasPendingMigrations()}},{key:"generateUuid",value:function(){return I.GenerateUuid()}},{key:"presentKeyRecoveryWizard",value:function(){return this.keyRecoveryService.processPersistedUndecryptables()}},{key:"changeDeviceInterface",value:function(e){this.deviceInterface=e;for(var t,n=S(this.services);!(t=n()).done;){var r=t.value;r.deviceInterface&&(r.deviceInterface=e)}}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.settingsService.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=r.length>2&&void 0!==r[2]&&r[2],a.abrupt("return",this.settingsService.updateSetting(e,t,n));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){return this.mfaService.isMfaFeatureAvailable()}},{key:"isMfaActivated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.isMfaActivated());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.generateMfaSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mfaService.getOtpToken(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.mfaService.enableMfa(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protectionService.authorizeMfaDisable());case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",this.mfaService.disableMfa());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"downloadExternalFeature",value:function(e){return this.featuresService.validateAndDownloadExternalFeature(e)}},{key:"getFeature",value:function(e){return this.featuresService.getFeature(e)}},{key:"getFeatureStatus",value:function(e){return this.featuresService.getFeatureStatus(e)}},{key:"getNewSubscriptionToken",value:function(){return this.apiService.getNewSubscriptionToken()}},{key:"setOfflineFeaturesCode",value:function(e){return this.featuresService.setOfflineFeaturesCode(e)}},{key:"hasOfflineRepo",value:function(){return this.featuresService.hasOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.featuresService.deleteOfflineFeatureRepo());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isThirdPartyHostUsed",value:function(){return this.apiService.isThirdPartyHostUsed()}},{key:"constructServices",value:function(){this.createPayloadManager(),this.createItemManager(),this.createStorageManager(),this.createProtocolService();var e={payloadByEncryptingPayload:this.protocolService.payloadByEncryptingPayload.bind(this.protocolService),payloadByDecryptingPayload:this.protocolService.payloadByDecryptingPayload.bind(this.protocolService)};this.storageService.encryptionDelegate=e,this.createChallengeService(),this.createHttpManager(),this.createApiService(),this.createWebSocketsService(),this.createSessionManager(),this.createHistoryManager(),this.createSyncManager(),this.createProtectionService(),this.createCredentialService(),this.createKeyRecoveryService(),this.createSingletonManager(),this.createComponentManager(),this.createActionsManager(),this.createPreferencesService(),this.createSettingsService(),this.createFeaturesService(),this.createMigrationService(),this.createMfaService()}},{key:"clearServices",value:function(){this.migrationService=void 0,this.alertService=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.sessionManager=void 0,this.syncService=void 0,this.challengeService=void 0,this.singletonManager=void 0,this.componentManager=void 0,this.protectionService=void 0,this.actionsManager=void 0,this.historyManager=void 0,this.itemManager=void 0,this.keyRecoveryService=void 0,this.preferencesService=void 0,this.featuresService=void 0,this.credentialService=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.mfaService=void 0,this.services=[]}},{key:"createFeaturesService",value:function(){var e=this;this.featuresService=new dr(this.storageService,this.apiService,this.itemManager,this.componentManager,this.webSocketsService,this.settingsService,this.credentialService,this.syncService,this.alertService,this.sessionManager,this.crypto),this.serviceObservers.push(this.featuresService.addEventObserver(function(t){switch(t){case cr.UserRolesChanged:e.notifyEvent(At.a.UserRolesChanged);break;case cr.FeaturesUpdated:e.notifyEvent(At.a.FeaturesUpdated);break;default:Object(_.f)(t)}})),this.services.push(this.featuresService)}},{key:"createWebSocketsService",value:function(){this.webSocketsService=new lr(this.storageService,this.webSocketUrl),this.services.push(this.webSocketsService)}},{key:"createMigrationService",value:function(){this.migrationService=new En({protocolService:this.protocolService,deviceInterface:this.deviceInterface,storageService:this.storageService,sessionManager:this.sessionManager,challengeService:this.challengeService,itemManager:this.itemManager,singletonManager:this.singletonManager,featuresService:this.featuresService,environment:this.environment,identifier:this.identifier}),this.services.push(this.migrationService)}},{key:"createCredentialService",value:function(){var e=this;this.credentialService=new Qe(this.sessionManager,this.syncService,this.storageService,this.itemManager,this.protocolService,this.alertService,this.challengeService,this.protectionService),this.serviceObservers.push(this.credentialService.addEventObserver(function(t){switch(t){case Ye.SignedInOrRegistered:e.notifyEvent(At.a.SignedIn);break;default:Object(_.f)(t)}})),this.services.push(this.credentialService)}},{key:"createApiService",value:function(){this.apiService=new Yt(this.httpService,this.storageService,this.defaultHost),this.services.push(this.apiService)}},{key:"createItemManager",value:function(){this.itemManager=new _r(this.payloadManager),this.services.push(this.itemManager)}},{key:"createComponentManager",value:function(){var e=this.getClass(an);this.componentManager=new e(this.itemManager,this.syncService,this.alertService,this.environment,this.platform,this.deviceInterface.timeout),this.services.push(this.componentManager)}},{key:"createHttpManager",value:function(){this.httpService=new jt(this.environment,this.appVersion),this.services.push(this.httpService)}},{key:"createPayloadManager",value:function(){this.payloadManager=new sn,this.services.push(this.payloadManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new cn(this.itemManager,this.syncService),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new Ie(this.deviceInterface,this.alertService,this.identifier,this.environment),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(){var e=this;this.protocolService=new Gn(this.itemManager,this.payloadManager,this.deviceInterface,this.storageService,this.identifier,this.crypto),this.protocolService.onKeyStatusChange(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.notifyEvent(At.a.KeyStatusChanged));case 2:case"end":return t.stop()}},null,null,null,Promise)}),this.services.push(this.protocolService)}},{key:"createKeyRecoveryService",value:function(){this.keyRecoveryService=new Mt(this.itemManager,this.payloadManager,this.apiService,this.protocolService,this.challengeService,this.alertService,this.storageService,this.syncService,this.credentialService),this.services.push(this.keyRecoveryService)}},{key:"createSessionManager",value:function(){var e=this;this.sessionManager=new Ge(this.storageService,this.apiService,this.alertService,this.protocolService,this.challengeService,this.webSocketsService),this.serviceObservers.push(this.sessionManager.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=t,n.next=n.t0===ze.Restored?3:n.t0===ze.Revoked?5:8;break;case 3:return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.sync());case 2:e.protocolService.needsNewRootKeyBasedItemsKey()&&e.protocolService.createNewDefaultItemsKey().then(function(){e.sync()});case 3:case"end":return t.stop()}},null,null,null,Promise),n.abrupt("break",9);case 5:return n.next=7,b.awrap(e.handleRevokedSession());case 7:return n.abrupt("break",9);case 8:Object(_.f)(t);case 9:case"end":return n.stop()}},null,null,null,Promise)})),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new ea(this.itemManager,this.sessionManager,this.protocolService,this.storageService,this.payloadManager,this.apiService,this.historyManager,this.deviceInterface.interval);var t=this.syncService.addEventObserver(function(t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(n=Object(At.c)(t))){r.next=9;break}return r.next=4,b.awrap(e.notifyEvent(n));case 4:if(n!==At.a.CompletedFullSync){r.next=9;break}if(e.handledFullSyncStage){r.next=9;break}return e.handledFullSyncStage=!0,r.next=9,b.awrap(e.handleStage(ve.FullSyncCompleted_13));case 9:return r.next=11,b.awrap(e.protocolService.onSyncEvent(t));case 11:case"end":return r.stop()}},null,null,null,Promise)});this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createChallengeService",value:function(){this.challengeService=new na(this.storageService,this.protocolService),this.services.push(this.challengeService)}},{key:"createProtectionService",value:function(){var e=this;this.protectionService=new ir(this.protocolService,this.challengeService,this.storageService,this.itemManager),this.serviceObservers.push(this.protectionService.addEventObserver(function(t){t===Zn.SessionExpiryDateChanged&&e.notifyEvent(At.a.ProtectionSessionExpiryDateChanged)})),this.services.push(this.protectionService)}},{key:"createHistoryManager",value:function(){this.historyManager=new nr(this.itemManager,this.storageService,this.apiService,this.protocolService,this.deviceInterface),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new hn(this.itemManager,this.alertService,this.deviceInterface,this.httpService,this.payloadManager,this.protocolService,this.syncService),this.services.push(this.actionsManager)}},{key:"createPreferencesService",value:function(){var e=this;this.preferencesService=new ra(this.singletonManager,this.itemManager,this.syncService),this.serviceObservers.push(this.preferencesService.addEventObserver(function(){e.notifyEvent(At.a.PreferencesChanged)})),this.services.push(this.preferencesService)}},{key:"createSettingsService",value:function(){this.settingsService=new hr.SNSettingsService(this.sessionManager,this.apiService),this.services.push(this.settingsService)}},{key:"createMfaService",value:function(){this.mfaService=new aa(this.settingsService,this.crypto,this.featuresService),this.services.push(this.mfaService)}},{key:"getClass",value:function(e){var t=this.swapClasses.find(function(t){return t.swap===e});return t?t.with:e}}]),e})(),ua=(function(){function e(t,n){v(this,e),this.timeout=t||setTimeout.bind(Object(_.r)()),this.interval=n||setInterval.bind(Object(_.r)())}return y(e,[{key:"deinit",value:function(){this.timeout=void 0,this.interval=void 0}},{key:"getJsonParsedRawStorageValue",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getRawStorageValue(e));case 2:if(t=n.sent,!Object(_.w)(t)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.prev=5,n.abrupt("return",JSON.parse(t));case 9:return n.prev=9,n.t0=n.catch(5),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,[[5,9]],Promise)}}]),e})(),la=(function(){function e(t,n,r){var a=this;v(this,e),this.item=n.findItem(t),r&&r(this.item),this.removeObserver=n.streamItems(this.item.content_type,function(e){var n;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:(n=e.find(function(e){return e.uuid===t}))&&(a.item=n,r&&r(a.item));case 2:case"end":return i.stop()}},null,null,null,Promise)})}return y(e,[{key:"deinit",value:function(){this.removeObserver?(this.removeObserver(),this.removeObserver=void 0):console.error('A LiveItem is attempting to be deinited more than once.')}}]),e})(),pa=n(95)}])},'object'==typeof i&&'object'==typeof a?a.exports=c():'function'==typeof define&&define.amd?define("SNLibrary",[],c):'object'==typeof i?i.SNLibrary=c():o.SNLibrary=c()},443,[12,35,22,9,11,13,7,8,249,43,279,6]);^~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:449:441081: warning: the variable "WebSocket" was not declared in function "value 1312#"__d(function(e,t,n,r,a,i,s){var o,c,u=t(s[0]),l=t(s[1]),p=t(s[2]),d=t(s[3]),h=t(s[4]),f=t(s[5]),v=t(s[6]),y=t(s[7]),g=t(s[8]),m=t(s[9]),b=t(s[10]),w=t(s[11]);function k(e){var t=x();return function(){var n,r=f(e);if(t){var a=f(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return h(this,n)}}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=P(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?O(e,t):void 0}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}o=window,c=function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&'object'==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,'default',{enumerable:!0,value:e}),2&t&&'string'!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,'a',t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=246)})([function(e,t,n){"use strict";(function(e){n.d(t,"r",function(){return y}),n.d(t,"n",function(){return g}),n.d(t,"C",function(){return k}),n.d(t,"y",function(){return x}),n.d(t,"q",function(){return P}),n.d(t,"O",function(){return O}),n.d(t,"h",function(){return C}),n.d(t,"x",function(){return D}),n.d(t,"v",function(){return _}),n.d(t,"w",function(){return E}),n.d(t,"t",function(){return R}),n.d(t,"A",function(){return I}),n.d(t,"s",function(){return M}),n.d(t,"U",function(){return A}),n.d(t,"V",function(){return j}),n.d(t,"W",function(){return T}),n.d(t,"F",function(){return K}),n.d(t,"o",function(){return F}),n.d(t,"R",function(){return L}),n.d(t,"M",function(){return U}),n.d(t,"b",function(){return N}),n.d(t,"p",function(){return V}),n.d(t,"c",function(){return B}),n.d(t,"g",function(){return W}),n.d(t,"N",function(){return H}),n.d(t,"d",function(){return z}),n.d(t,"H",function(){return q}),n.d(t,"Q",function(){return Y}),n.d(t,"K",function(){return G}),n.d(t,"j",function(){return Q}),n.d(t,"S",function(){return J}),n.d(t,"E",function(){return $}),n.d(t,"J",function(){return X}),n.d(t,"I",function(){return Z}),n.d(t,"D",function(){return ee}),n.d(t,"a",function(){return te}),n.d(t,"m",function(){return ne}),n.d(t,"L",function(){return re}),n.d(t,"l",function(){return ae}),n.d(t,"B",function(){return ie}),n.d(t,"T",function(){return se}),n.d(t,"P",function(){return oe}),n.d(t,"f",function(){return ce}),n.d(t,"z",function(){return ue}),n.d(t,"G",function(){return le}),n.d(t,"e",function(){return pe}),n.d(t,"i",function(){return ye}),n.d(t,"u",function(){return ge}),n.d(t,"k",function(){return me});var r=n(27),a=n.n(r),i=n(25),s=n.n(i),o=n(23),c=n.n(o),u=n(97),l=n.n(u),p=n(66),d=n.n(p),h=n(28),f=n.n(h),v='undefined'!=typeof Intl?new Intl.Collator('en',{numeric:!0}):void 0;function y(){return'undefined'!=typeof window?window:void 0!==e?e:null}function g(e){return Object.keys(e).map(function(t){return e[t]})}function k(){return null!==y()&&!x()&&!(document&&document.documentMode)||/Edge/.test(navigator.userAgent)&&window.crypto&&!!window.crypto.subtle}function x(){return'undefined'!=typeof navigator&&'ReactNative'===navigator.product}function P(e,t,n){return e.find(function(e){return e[t]===n})}function O(e,t){return s()(e,t)}function C(){for(var e=[],t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(var a=0,i=n;a<i.length;a++){var s=i[a];e=e.concat(s)}return e}function D(e){return null!==e&&('function'==typeof e||'object'==typeof e)}function _(e){return null!==e&&'function'==typeof e}function E(e){return null===e||void 0===e}function R(e){return!e||0===e.length}function I(e){return'string'==typeof e||e instanceof String}function M(e,t){return e>t?e:t}function A(e,t,n){return d()(e.concat(t),function(e,t){for(var r,a=S(n);!(r=a()).done;){var i=r.value;if(e[i]!==t[i])return!1}return!0})}function j(e){return f()(e)}function T(e,t){return d()(e,function(e,n){return e[t]===n[t]})}function K(e){return e[e.length-1]}function F(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;e.push(a)}}function L(e,t){for(var n,r=S(t);!(n=r()).done;){U(e,n.value)}}function U(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}function N(e,t){return!e.includes(t)&&(e.push(t),!0)}function V(e,t){a()(e,t)}function B(e,t){return e.filter(function(e){return!t.includes(e)}).concat(t.filter(function(t){return!e.includes(t)}))}function W(e,t){return!(e&&!t||!e&&t)&&(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():e instanceof String&&t instanceof String?e===t:J(e,t))}function H(e,t){e.splice(t,1)}function z(e,t){var n=e.slice();return H(n,t),n}function q(e){for(var t=[],n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];t.push(e[a])}return t}function Y(e){for(var t,n={},r=S(Object.keys(e).sort());!(t=r()).done;){var a=t.value;n[a]=e[a]}return te(n)}function G(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n];E(e[a])||(t[a]=e[a])}return t}function Q(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.sort(function(e,r){var a=e[t].getTime(),i=r[t].getTime(),s=n?1:-1;return a<i?-1*s:a>i?1*s:0})}function J(e,t){if(!e&&!t)return!0;if(!e||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var a=0,i=n;a<i.length;a++){var s=i[a];if(e[s]!==t[s])return!1}return!0}function $(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var a=r[n],i=void 0;try{i=JSON.parse(e[a])}catch(t){i=e[a]}t[a]=i}return t}function X(e,t){if(e)for(var n,r=S(t);!(n=r()).done;){delete e[n.value]}}function Z(e,t){if(!E(e)){for(var n,r=w({},e),a=S(t);!(n=a()).done;){delete r[n.value]}return r}}function ee(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(function(e,t){return 0===t?e.trim().replace(/[/]*$/g,''):e.trim().replace(/(^[/]*|[/]*$)/g,'')}).filter(function(e){return e.length}).join('/')}function te(e){return e instanceof Date?new Date(e):D(e)?JSON.parse(JSON.stringify(e)):e}function ne(e,t){if(!e||!t)throw'Attempting to deepMerge with null values';return l()(e,t,function(e,t){if(c()(e))return t}),e}function re(e,t){for(var n,r={},a=S(t);!(n=a()).done;){var i=n.value;r[i]=e[i]}return te(r)}function ae(e){for(var t,n=S(Object.getOwnPropertyNames(e));!(t=n()).done;){var r=t.value,a=e[r];a&&'object'==typeof a&&!Object.isFrozen(a)?e[r]=ae(a):e[r]=a}return Object.freeze(e)}function ie(e){try{return new URL(e),!0}catch(e){return!1}}function se(e,t){var n=t/4;return e.substring(0,n)}function oe(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return console.warn("Sleeping for ".concat(e,"ms")),t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},e)}));case 2:case"end":return t.stop()}},null,null,null,Promise)}function ce(e){throw Error('Unchecked case '+e)}function ue(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function le(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc'){case'asc':return m(e).sort(v?function(e,n){return v.compare(e[t],n[t])}:function(e,n){return e[t].localeCompare(n[t],'en',{numeric:!0})});case'desc':return m(e).sort(v?function(e,n){return v.compare(n[t],e[t])}:function(e,n){return n[t].localeCompare(e[t],'en',{numeric:!0})})}}function pe(e,t){return e.length===t.length&&(e.every(function(e){return t.includes(e)})&&t.every(function(t){return e.includes(t)}))}var de,he,fe=1e3,ve=1e3;function ye(e){switch(String(e).length){case de.Seconds:return e*ve;case de.Milliseconds:return e;case de.Microseconds:return Math.floor(e/fe);default:throw"Unhandled timestamp precision: ".concat(e)}}function ge(e){return void 0!==e.error}function me(e){if('undefined'!=typeof Intl&&Intl.DateTimeFormat&&'undefined'!=typeof navigator){if(!he){var t=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language;he=new Intl.DateTimeFormat(t,{year:'numeric',month:'short',day:'2-digit',weekday:'long',hour:'2-digit',minute:'2-digit'})}return he.format(e)}return e.toDateString()+' '+e.toLocaleTimeString()}!(function(e){e[e.Seconds=10]="Seconds",e[e.Milliseconds=13]="Milliseconds",e[e.Microseconds=16]="Microseconds"})(de||(de={}))}).call(this,n(34))},function(e,t,n){"use strict";n.d(t,"e",function(){return m}),n.d(t,"g",function(){return b}),n.d(t,"d",function(){return w}),n.d(t,"f",function(){return k}),n.d(t,"b",function(){return x}),n.d(t,"c",function(){return O}),n.d(t,"a",function(){return C});var r=n(32),a=n(4),i=n(8),s=n(0),o=n(5),c=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey,o.a.LastSyncBegan,o.a.LastSyncEnd,o.a.DuplicateOf]),u=Object.freeze([o.a.Uuid,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.Legacy003AuthHash,o.a.ErrorDecrypting,o.a.ErrorDecryptingChanged,o.a.WaitingForKey]),l=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Legacy003AuthHash,o.a.DuplicateOf]),p=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.Legacy003AuthParams,o.a.Dirty,o.a.DirtiedDate,o.a.ErrorDecrypting,o.a.WaitingForKey,o.a.DuplicateOf]),d=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ItemsKeyId,o.a.EncItemKey,o.a.Content,o.a.CreatedAt,o.a.ServerUpdatedAt,o.a.CreatedAtTimestamp,o.a.ServerUpdatedAtTimestamp,o.a.Deleted,o.a.Legacy003AuthHash,o.a.DuplicateOf]),h=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.Content,o.a.ServerUpdatedAt]),f=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),v=Object.freeze([o.a.Uuid,o.a.Content,o.a.ContentType,o.a.CreatedAt]),y=Object.freeze([o.a.Uuid,o.a.ContentType,o.a.ServerUpdatedAt,o.a.ServerUpdatedAtTimestamp,o.a.CreatedAtTimestamp,o.a.Deleted,o.a.Dirty,o.a.LastSyncEnd]),g=Object.freeze(d.slice());function m(e,t,n){return P(e,c.slice(),n,t)}function b(e,t,n,r){for(var a,i={},s=S(n||t.fields);!(a=s()).done;){var o=a.value;i[o]=t[o]}if(r)for(var c=0,u=Object.keys(r);c<u.length;c++){var l=u[c];i[l]=r[l]}return x(e,i)}function w(e,t,n){return P(e,D(t),a.a.Constructor,n)}function k(e,t,n){return P(e,_(t),t,n)}function x(e,t){return P(e,e.fields,e.source,t)}function P(e,t,n,i){for(var o,c=Object(s.L)(e,t),u=i instanceof r.a?i.fields.slice():Object.keys(i||[]),l=S(u);!(o=l()).done;){var p=o.value,d=i[p];c[p]=d?Object(s.a)(d):d}var h=Object(s.V)(t.concat(u));return new r.a(c,h,n||a.a.Constructor)}function O(e,t){return P(e,Object.keys(e),t)}function C(e,t){return P(e,u.slice(),void 0,t)}function D(e){if(e===i.b.FileEncrypted||e===i.b.FileDecrypted||e===i.b.FilePreferEncrypted)return l.slice();if(e===i.b.LocalStoragePreferEncrypted||e===i.b.LocalStorageDecrypted||e===i.b.LocalStorageEncrypted)return p.slice();if(e===i.b.Sync||e===i.b.SyncDecrypted)return d.slice();throw"No payload fields found for intent ".concat(e)}function _(e){if(e===a.a.FileImport)return l.slice();if(e===a.a.SessionHistory)return h.slice();if(e===a.a.RemoteHistory)return g.slice();if(e===a.a.ComponentRetrieved)return f.slice();if(e===a.a.ComponentCreated)return v.slice();if(e===a.a.LocalRetrieved||e===a.a.LocalChanged)return p.slice();if(e===a.a.RemoteRetrieved||e===a.a.ConflictData||e===a.a.ConflictUuid||e===a.a.RemoteRejected)return d.slice();if(e===a.a.LocalSaved||e===a.a.RemoteSaved)return y.slice();throw"No payload fields found for source ".concat(e)}},function(e,t,n){"use strict";n.d(t,"k",function(){return a}),n.d(t,"l",function(){return i}),n.d(t,"j",function(){return s}),n.d(t,"m",function(){return o}),n.d(t,"r",function(){return c}),n.d(t,"p",function(){return u}),n.d(t,"a",function(){return l}),n.d(t,"i",function(){return p}),n.d(t,"n",function(){return d}),n.d(t,"s",function(){return h}),n.d(t,"q",function(){return f}),n.d(t,"o",function(){return v}),n.d(t,"d",function(){return y}),n.d(t,"h",function(){return g}),n.d(t,"g",function(){return m}),n.d(t,"b",function(){return b}),n.d(t,"f",function(){return w}),n.d(t,"t",function(){return k}),n.d(t,"c",function(){return x}),n.d(t,"e",function(){return S}),n.d(t,"C",function(){return P}),n.d(t,"X",function(){return O}),n.d(t,"A",function(){return C}),n.d(t,"L",function(){return D}),n.d(t,"W",function(){return _}),n.d(t,"E",function(){return E}),n.d(t,"D",function(){return R}),n.d(t,"K",function(){return I}),n.d(t,"J",function(){return M}),n.d(t,"Y",function(){return A}),n.d(t,"Q",function(){return j}),n.d(t,"v",function(){return T}),n.d(t,"O",function(){return K}),n.d(t,"z",function(){return F}),n.d(t,"U",function(){return L}),n.d(t,"G",function(){return U}),n.d(t,"T",function(){return N}),n.d(t,"V",function(){return V}),n.d(t,"u",function(){return B}),n.d(t,"F",function(){return W}),n.d(t,"y",function(){return H}),n.d(t,"P",function(){return z}),n.d(t,"S",function(){return q}),n.d(t,"N",function(){return Y}),n.d(t,"H",function(){return G}),n.d(t,"w",function(){return Q}),n.d(t,"R",function(){return J}),n.d(t,"x",function(){return $}),n.d(t,"M",function(){return X}),n.d(t,"B",function(){return Z}),n.d(t,"I",function(){return ee});var r=n(13),a='A server error occurred while trying to sign in. Please try again.',i='A server error occurred while trying to register. Please try again.',s='Something went wrong while changing your credentials. Your credentials were not changed. Please try again.',o='Could not connect to server.',c='An existing registration request is already in progress.',u='An existing sign in request is already in progress.',l='An existing change credentials request is already in progress.',p='Invalid email or password.',d='A server error occurred while trying to refresh your session. Please try again.',h='Your account session is being renewed with the server. Please try your request again.',f='Too many successive server requests. Please wait a few minutes and try again.',v='Please sign in to an account in order to continue with your request.',y='Failed to get settings.',g='Failed to update settings.',m="Failed to get subscription's information.",b='Failed to access purchase flow.',w='Failed to get offline features.',k="The extension you are attempting to install comes from an \n  untrusted source. Untrusted extensions may lower the security of your data. Do you want to continue?",x="Error downloading package details. Please check the \n  extension link and try again.",S='An unknown issue occurred during offline activation. Please try again.',P='Invalid extension URL.',O='This version of the application does not support your newer account type. Please upgrade to the latest version of Standard Notes to sign in.',C='The protocol version associated with your account is outdated and no longer supported by this application. Please visit standardnotes.com/help/security for more information.',D='The encryption version for your account is outdated and requires upgrade. You may proceed with login, but are advised to perform a security update using the web or desktop application. Please visit standardnotes.com/help/security for more information.',_='Your account was created on a platform with higher security capabilities than this browser supports. If we attempted to generate your login keys here, it would take hours. Please use a browser with more up to date security capabilities, like Google Chrome or Firefox, to log in.',E='Unable to sign in due to insecure password parameters. Please visit standardnotes.com/help/security for more information.',R='Invalid password.',I='Update Recommended',M='Sign In',A="Upgrading your account's encryption version\u2026",j='Setting passcode\u2026',T='Changing passcode\u2026',K='Removing passcode\u2026',F='Do not close the application until this process completes.',L='Unknown error.';function U(e){return"Your password must be at least ".concat(e," characters in length. For your security, please choose a longer password or, ideally, a passphrase, and try again.")}function N(e,t){return"Strict Sign In has refused the server's sign-in parameters. The latest account version is ".concat(t,", but the server is reporting a version of ").concat(e," for your account. If you'd like to proceed with sign in anyway, please disable Strict Sign In and try again.")}var V='This backup file was created using a newer version of the application and cannot be imported here. Please update your application and try again.',B="This backup file was created using a newer encryption version than your account's. Please run the available encryption upgrade and try again.",W={FileAccountPassword:'File account password'},H={PasscodeRequired:'Your passcode is required to process your credentials change.',Failed:'Unable to change your credentials due to a sync error. Please try again.'},z={PasscodeRequired:'Your passcode is required in order to register for an account.'},q={PasscodeRequired:'Your passcode is required in order to sign in to your account.',IncorrectMfa:'Incorrect two-factor authentication code. Please try again.',SignInCanceledMissingMfa:'Your sign in request has been canceled.'},Y={SuccessAccount:"Your encryption version has been successfully upgraded. You may be asked to enter your credentials again on other devices you're signed into.",SuccessPasscodeOnly:'Your encryption version has been successfully upgraded.',Fail:'Unable to upgrade encryption version. Please try again.',UpgradingPasscode:'Upgrading local encryption...'},G={KeyRecoveryLoginFlowPrompt:function(e){var t,n=null===(t=e.createdDate)||void 0===t?void 0:t.toLocaleString();switch(e.origination){case r.g.EmailChange:return"Enter your account password as it was when you changed your email on ".concat(n,".");case r.g.PasswordChange:return"Enter your account password after it was changed on ".concat(n,".");case r.g.Registration:return"Enter your account password as it was when you registered ".concat(n,".");case r.g.ProtocolUpgrade:return"Enter your account password as it was when you upgraded your encryption version on ".concat(n,".");case r.g.PasscodeChange:return"Enter your application passcode after it was changed on ".concat(n,".");case r.g.PasscodeCreate:return"Enter your application passcode as it was when you created it on ".concat(n,".");default:throw Error('Unhandled KeyParamsOrigination case for KeyRecoveryLoginFlowPrompt')}},KeyRecoveryLoginFlowReason:'Your account password is required to revalidate your session.',KeyRecoveryLoginFlowInvalidPassword:'Incorrect credentials entered. Please try again.',KeyRecoveryRootKeyReplaced:'Your credentials have successfully been updated.',KeyRecoveryPasscodeRequiredTitle:'Passcode Required',KeyRecoveryPasscodeRequiredText:'You must enter your passcode in order to save your new credentials.',KeyRecoveryPasswordRequired:'Your account password is required to recover an encryption key.',KeyRecoveryKeyRecovered:'Your key has successfully been recovered.',KeyRecoveryUnableToRecover:'Unable to recover your key with the attempted password. Please try again.'},Q={Generic:'Authentication Required',Migration:'Storage Update'},J={EnterEmailAndPassword:'Please enter your account email and password.',RecoverSession:function(e){return e?"Your credentials are needed for ".concat(e," to refresh your session with the server."):'Your credentials are needed to refresh your session with the server.'},SessionRestored:'Your session has been successfully restored.',EnterMfa:'Please enter your two-factor authentication code.',MfaInputPlaceholder:'Two-factor authentication code',EmailInputPlaceholder:'Email',PasswordInputPlaceholder:'Password',KeychainRecoveryErrorTitle:'Invalid Credentials',KeychainRecoveryError:'The email or password you entered is incorrect.\n\nPlease note that this sign-in request is made against the default server. If you are using a custom server, you must uninstall the app then reinstall, and sign back into your account.',RevokeTitle:'Revoke this session?',RevokeConfirmButton:'Revoke',RevokeCancelButton:'Cancel',RevokeText:"The associated app will be signed out and all data removed from the device when it is next launched. You can sign back in on that device at any time.",CurrentSessionRevoked:"Your session has been revoked and all local data has been removed from this device."},$={UnlockApplication:'Authentication is required to unlock the application',NoteAccess:'Authentication is required to view this note',ImportFile:'Authentication is required to import a backup file',AddPasscode:'Authentication is required to add a passcode',RemovePasscode:'Authentication is required to remove your passcode',ChangePasscode:'Authentication is required to change your passcode',ChangeAutolockInterval:'Authentication is required to change autolock timer duration',RevokeSession:'Authentication is required to revoke a session',AccessCloudLink:'Authentication is required to access CloudLink',EnterAccountPassword:'Enter your account password',EnterLocalPasscode:'Enter your application passcode',EnterPasscodeForMigration:'Your application passcode is required to perform an upgrade of your local data storage structure.',EnterPasscodeForRootResave:'Enter your application passcode to continue',EnterCredentialsForProtocolUpgrade:'Enter your credentials to perform encryption upgrade',EnterCredentialsForDecryptedBackupDownload:'Enter your credentials to download a decrypted backup',AccountPasswordPlaceholder:'Account Password',LocalPasscodePlaceholder:'Application Passcode',DecryptEncryptedFile:'Enter the account password associated with the import file',ExportBackup:'Authentication is required to export a backup',DisableBiometrics:'Authentication is required to disable biometrics',UnprotectNote:'Authentication is required to unprotect a note',SearchProtectedNotesText:'Authentication is required to search protected contents',SelectProtectedNote:'Authentication is required to select a protected note',DisableMfa:'Authentication is required to disable two-factor authentication'},X={AccountPassword:'Account Password',LocalPasscode:'Application Passcode',Biometrics:'Biometrics',RememberFor:'Remember For',Mfa:'Two-factor Authentication Code'},Z={MissingSessionTitle:'Missing Session',MissingSessionBody:'We were unable to load your server session. This represents an inconsistency with your application state. Please take an opportunity to backup your data, then sign out and sign back in to resolve this issue.',StorageDecryptErrorTitle:'Storage Error',StorageDecryptErrorBody:"We were unable to decrypt your local storage. Please restart the app and try again. If you're unable to resolve this issue, and you have an account, you may try uninstalling the app then reinstalling, then signing back into your account. Otherwise, please contact help@standardnotes.org for support."},ee={Title:'Restore Keychain',Text:"We've detected that your keychain has been wiped. This can happen when restoring your device from a backup. Please enter your account password to restore your account keys."}},function(e,t,n){"use strict";n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i});var r=n(19);n.n(r);n.d(t,"a",function(){return r.ContentType});var a='org.standardnotes.sn';function i(e){var t;return(g(t={},r.ContentType.Note,'note'),g(t,r.ContentType.Tag,'tag'),g(t,r.ContentType.SmartTag,'smart tag'),g(t,r.ContentType.ActionsExtension,'action-based extension'),g(t,r.ContentType.Component,'component'),g(t,r.ContentType.Editor,'editor'),g(t,r.ContentType.Theme,'theme'),g(t,r.ContentType.ServerExtension,'server extension'),g(t,r.ContentType.FilesafeCredentials,'FileSafe credential'),g(t,r.ContentType.FilesafeFileMetadata,'FileSafe file'),g(t,r.ContentType.FilesafeIntegration,'FileSafe integration'),t)[e]}},function(e,t,n){"use strict";var r;function a(e){return[r.RemoteSaved,r.PreSyncSave].includes(e)}function i(e){return[r.RemoteRetrieved,r.ComponentRetrieved,r.RemoteActionRetrieved].includes(e)}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"c",function(){return i}),(function(e){e[e.RemoteRetrieved=1]="RemoteRetrieved",e[e.RemoteSaved=2]="RemoteSaved",e[e.LocalSaved=3]="LocalSaved",e[e.LocalRetrieved=4]="LocalRetrieved",e[e.LocalChanged=5]="LocalChanged",e[e.ComponentRetrieved=6]="ComponentRetrieved",e[e.DesktopInstalled=7]="DesktopInstalled",e[e.RemoteActionRetrieved=8]="RemoteActionRetrieved",e[e.FileImport=9]="FileImport",e[e.RemoteConflict=10]="RemoteConflict",e[e.ImportConflict=11]="ImportConflict",e[e.SavedOrSaving=12]="SavedOrSaving",e[e.DecryptedTransient=13]="DecryptedTransient",e[e.ConflictUuid=14]="ConflictUuid",e[e.ConflictData=15]="ConflictData",e[e.SessionHistory=16]="SessionHistory",e[e.Constructor=17]="Constructor",e[e.ComponentCreated=18]="ComponentCreated",e[e.PreSyncSave=19]="PreSyncSave",e[e.RemoteHistory=20]="RemoteHistory",e[e.RemoteRejected=21]="RemoteRejected"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.Uuid="uuid",e.ContentType="content_type",e.ItemsKeyId="items_key_id",e.EncItemKey="enc_item_key",e.Content="content",e.CreatedAt="created_at",e.ServerUpdatedAt="updated_at",e.CreatedAtTimestamp="created_at_timestamp",e.ServerUpdatedAtTimestamp="updated_at_timestamp",e.Deleted="deleted",e.Legacy003AuthHash="auth_hash",e.Legacy003AuthParams="auth_params",e.Dirty="dirty",e.DirtiedDate="dirtiedDate",e.WaitingForKey="waitingForKey",e.ErrorDecrypting="errorDecrypting",e.ErrorDecryptingChanged="errorDecryptingValueChanged",e.LastSyncBegan="lastSyncBegan",e.LastSyncEnd="lastSyncEnd",e.DuplicateOf="duplicate_of"})(r||(r={}))},function(e,t,n){"use strict";var r;function a(e,t){return Number(e)-Number(t)}function i(e,t){return a(e,t)>=0}function s(e,t){return a(e,t)<=0}n.d(t,"a",function(){return r}),n.d(t,"b",function(){return a}),n.d(t,"d",function(){return i}),n.d(t,"c",function(){return s}),(function(e){e.V000Base64Decrypted="000",e.V001="001",e.V002="002",e.V003="003",e.V004="004",e[e.VersionLength=3]="VersionLength"})(r||(r={}))},function(e,t,n){"use strict";(function(e){n.d(t,"c",function(){return r}),n.d(t,"a",function(){return a}),n.d(t,"e",function(){return i}),n.d(t,"d",function(){return f}),n.d(t,"b",function(){return g});var r,a,i,s=n(16),o=n(12),c=n(18),u=n(1),l=n(0),p=n(21),d=n(3),h=n(4);!(function(e){e[e.UserInteraction=1]="UserInteraction",e[e.Internal=2]="Internal",e[e.NonDirtying=3]="NonDirtying"})(r||(r={})),(function(e){e.Pinned="pinned",e.Archived="archived",e.Locked="locked",e.UserModifiedDate="client_updated_at",e.DefaultEditor="defaultEditor",e.MobileRules="mobileRules",e.NotAvailableOnMobile="notAvailableOnMobile",e.MobileActive="mobileActive",e.LastSize="lastSize",e.PrefersPlainEditor="prefersPlainEditor",e.ComponentInstallError="installError"})(a||(a={})),(function(e){e[e.KeepEarliest=1]="KeepEarliest"})(i||(i={}));var f=(function(){function t(n){var r=this;if(v(this,t),this.protected=!1,this.trashed=!1,this.pinned=!1,this.archived=!1,this.locked=!1,!n.uuid||!n.content_type)throw Error('Cannot create item without both uuid and content_type');n.format===o.a.DecryptedBareObject&&(n.enc_item_key||n.items_key_id||n.auth_hash)&&s.a.error(Error('Creating an item from a decrypted payload should not contain enc params')),this.payload=n,this.conflictOf=n.safeContent.conflict_of,this.duplicateOf=n.duplicate_of,this.createdAtString=this.created_at&&Object(l.k)(this.created_at),n.format===o.a.DecryptedBareObject?(this.userModifiedDate=new Date(this.getAppDomainValue(a.UserModifiedDate)||this.serverUpdatedAt),this.updatedAtString=Object(l.k)(this.userModifiedDate),this.protected=this.payload.safeContent.protected,this.trashed=this.payload.safeContent.trashed,this.pinned=this.getAppDomainValue(a.Pinned),this.archived=this.getAppDomainValue(a.Archived),this.locked=this.getAppDomainValue(a.Locked)):this.userModifiedDate=this.serverUpdatedAt||new Date,e(function(){Object(l.l)(r)})}return y(t,[{key:"payloadRepresentation",value:function(e){return Object(u.b)(this.payload,e)}},{key:"hasRelationshipWithItem",value:function(e){var t;return!!(null===(t=this.payload.safeContent.references)||void 0===t?void 0:t.find(function(t){return t.uuid===e.uuid}))}},{key:"getDomainData",value:function(e){var t=this.payload.safeContent.appData;if(t)return t[e]}},{key:"getAppDomainValue",value:function(e){return this.getDomainData(t.DefaultAppDomain())[e]}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['conflict_of']}},{key:"appDataContentKeysToIgnoreWhenCheckingEquality",value:function(){return[a.UserModifiedDate]}},{key:"getContentCopy",value:function(){return JSON.parse(JSON.stringify(this.content))}},{key:"strategyWhenConflictingWithItem",value:function(e,t){if(this.errorDecrypting)return c.a.KeepLeftDuplicateRight;if(this.isSingleton)return c.a.KeepLeft;if(this.deleted)return c.a.KeepRight;if(e.deleted)return this.payload.source===h.a.FileImport?c.a.KeepLeft:c.a.KeepRight;if(!m(this,e))return c.a.KeepRight;if(m(this,e,['references'])){if(t&&!m(t.itemFromPayload(),e))return c.a.KeepLeft;return e.payload.source===h.a.FileImport||Date.now()-this.userModifiedDate.getTime()<2e4?c.a.KeepLeftDuplicateRight:c.a.DuplicateLeftKeepRight}return c.a.KeepLeftMergeRefs}},{key:"isItemContentEqualWith",value:function(e){return b(this.payload.contentObject,e.payload.contentObject,this.contentKeysToIgnoreWhenCheckingEquality(),this.appDataContentKeysToIgnoreWhenCheckingEquality())}},{key:"satisfiesPredicate",value:function(e){return p.a.ItemSatisfiesPredicate(this,e)}},{key:"uuid",get:function(){return this.payload.uuid}},{key:"content",get:function(){return this.payload.content}},{key:"version",get:function(){if(this.payload.format===o.a.DecryptedBareObject)throw Error('Attempting to access version of decrypted payload');return this.payload.version}},{key:"safeContent",get:function(){return this.payload.safeContent}},{key:"references",get:function(){return this.payload.safeContent.references||[]}},{key:"deleted",get:function(){return this.payload.deleted}},{key:"content_type",get:function(){return this.payload.content_type}},{key:"created_at",get:function(){return this.payload.created_at}},{key:"serverUpdatedAt",get:function(){return this.payload.serverUpdatedAt}},{key:"serverUpdatedAtTimestamp",get:function(){return this.payload.updated_at_timestamp}},{key:"updated_at",get:function(){return this.serverUpdatedAt}},{key:"dirtiedDate",get:function(){return this.payload.dirtiedDate}},{key:"dirty",get:function(){return this.payload.dirty}},{key:"errorDecrypting",get:function(){return this.payload.errorDecrypting}},{key:"waitingForKey",get:function(){return this.payload.waitingForKey}},{key:"errorDecryptingValueChanged",get:function(){return this.payload.errorDecryptingValueChanged}},{key:"lastSyncBegan",get:function(){return this.payload.lastSyncBegan}},{key:"lastSyncEnd",get:function(){return this.payload.lastSyncEnd}},{key:"auth_hash",get:function(){return this.payload.auth_hash}},{key:"auth_params",get:function(){return this.payload.auth_params}},{key:"duplicate_of",get:function(){return this.payload.duplicate_of}},{key:"neverSynced",get:function(){return!this.serverUpdatedAt||0===this.serverUpdatedAt.getTime()}},{key:"isSingleton",get:function(){return!1}},{key:"singletonPredicate",get:function(){throw'Must override SNItem.singletonPredicate'}},{key:"singletonStrategy",get:function(){return i.KeepEarliest}},{key:"isSyncable",get:function(){return!this.errorDecrypting||!0===this.deleted}}],[{key:"DefaultAppDomain",value:function(){return d.b}}]),t})(),g=(function(){function e(t,n){v(this,e),this.item=t,this.type=n,this.payload=t.payload,this.payload.content&&(this.content=Object(l.a)(this.payload.content))}return y(e,[{key:"getUuid",value:function(){return this.payload.uuid}},{key:"getItem",value:function(){return this.item}},{key:"getResult",value:function(){if(this.type===r.NonDirtying)return Object(u.b)(this.payload,{content:this.content});this.payload.deleted||(this.type===r.UserInteraction?this.userModifiedDate=new Date:this.item.userModifiedDate||(this.userModifiedDate=new Date(this.item.serverUpdatedAt)));return Object(u.b)(this.payload,{content:this.content,dirty:!0,dirtiedDate:new Date})}},{key:"mergePayload",value:function(e){this.payload=Object(u.g)(this.payload,e),this.payload.content?this.content=Object(l.a)(this.payload.safeContent):this.content=void 0}},{key:"unsafe_setCustomContent",value:function(e){this.content=Object(l.a)(e)}},{key:"setDeleted",value:function(){this.content=void 0,this.payload=Object(u.b)(this.payload,{content:this.content,deleted:!0})}},{key:"setDomainData",value:function(e,t){this.payload.errorDecrypting||(this.content.appData||(this.content.appData={}),this.content.appData[t]=e)}},{key:"setDomainDataKey",value:function(e,t,n){if(!this.payload.errorDecrypting){this.content.appData||(this.content.appData={});var r=this.content.appData;r[n]||(r[n]={}),r[n][e]=t}}},{key:"setAppDataItem",value:function(e,t){this.setDomainDataKey(e,t,f.DefaultAppDomain())}},{key:"addItemAsRelationship",value:function(e){var t=this.content.references||[];t.find(function(t){return t.uuid===e.uuid})||t.push({uuid:e.uuid,content_type:e.content_type}),this.content.references=t}},{key:"removeItemAsRelationship",value:function(e){var t=this.content.references||[];t=t.filter(function(t){return t.uuid!==e.uuid}),this.content.references=t}},{key:"lastSyncBegan",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,lastSyncBegan:e})}},{key:"errorDecrypting",set:function(e){this.payload=Object(u.b)(this.payload,{content:this.content,errorDecrypting:e})}},{key:"updated_at",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at:e})}},{key:"updated_at_timestamp",set:function(e){this.payload=Object(u.b)(this.payload,{updated_at_timestamp:e})}},{key:"userModifiedDate",set:function(e){this.setAppDataItem(a.UserModifiedDate,e)}},{key:"conflictOf",set:function(e){this.content.conflict_of=e}},{key:"protected",set:function(e){this.content.protected=e}},{key:"trashed",set:function(e){this.content.trashed=e}},{key:"pinned",set:function(e){this.setAppDataItem(a.Pinned,e)}},{key:"archived",set:function(e){this.setAppDataItem(a.Archived,e)}},{key:"locked",set:function(e){this.setAppDataItem(a.Locked,e)}}]),e})();function m(e,t,n){return n||(n=[]),!b(e.content,t.content,e.contentKeysToIgnoreWhenCheckingEquality().concat(n),e.appDataContentKeysToIgnoreWhenCheckingEquality())}function b(e,t,n,r){if((e=Object(l.Q)(e)).appData){var a=e.appData[d.b];Object(l.J)(a,r),a?0===Object.keys(a).length&&delete e.appData:delete e.appData}if(Object(l.J)(e,n),(t=Object(l.Q)(t)).appData){var i=t.appData[d.b];Object(l.J)(i,r),i?0===Object.keys(i).length&&delete t.appData:delete t.appData}return Object(l.J)(t,n),JSON.stringify(e)===JSON.stringify(t)}}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return r}),n.d(t,"f",function(){return s}),n.d(t,"e",function(){return o}),n.d(t,"d",function(){return c}),n.d(t,"c",function(){return u});var r,a=n(3);function i(e){return e===a.a.RootKey||e===a.a.ItemsKey||e===a.a.EncryptedStorage}function s(e){return e===r.LocalStorageEncrypted||e===r.LocalStorageDecrypted||e===r.LocalStoragePreferEncrypted}function o(e){return e===r.FileEncrypted||e===r.FileDecrypted||e===r.FilePreferEncrypted}function c(e){return e===r.SyncDecrypted||e===r.LocalStorageDecrypted||e===r.FileDecrypted}function u(e){return e===r.Sync||e===r.LocalStorageEncrypted||e===r.FileEncrypted}!(function(e){e[e.Sync=0]="Sync",e[e.SyncDecrypted=1]="SyncDecrypted",e[e.LocalStorageEncrypted=2]="LocalStorageEncrypted",e[e.LocalStorageDecrypted=3]="LocalStorageDecrypted",e[e.LocalStoragePreferEncrypted=4]="LocalStoragePreferEncrypted",e[e.FileEncrypted=5]="FileEncrypted",e[e.FileDecrypted=6]="FileDecrypted",e[e.FilePreferEncrypted=7]="FilePreferEncrypted"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.FullSyncCompleted="sync:full-completed",e.SingleSyncCompleted="sync:single-completed",e.SyncWillBegin="sync:will-begin",e.DownloadFirstSyncCompleted="sync:download-first-completed",e.SyncTakingTooLong="sync:taking-too-long",e.SyncError="sync:error",e.InvalidSession="sync:invalid-session",e.MajorDataChange="major-data-change",e.LocalDataIncrementalLoad="local-data-incremental-load",e.LocalDataLoaded="local-data-loaded",e.EnterOutOfSync="enter-out-of-sync",e.ExitOutOfSync="exit-out-of-sync",e.StatusChanged="status-changed",e.DatabaseWriteError="database-write-error",e.DatabaseReadError="database-read-error"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return a});var r=n(0),a=(function(){function e(){v(this,e),this.eventObservers=[],this.loggingEnabled=!1,this.criticalPromises=[]}return y(e,[{key:"addEventObserver",value:function(e){var t=this;return this.eventObservers.push(e),function(){Object(r.M)(t.eventObservers,e)}}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:n=S(this.eventObservers);case 1:if((r=n()).done){i.next=7;break}return a=r.value,i.next=5,b.awrap(a(e,t));case 5:i.next=1;break;case 7:case"end":return i.stop()}},null,this,null,Promise)}},{key:"blockDeinit",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(Promise.all(this.criticalPromises));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.eventObservers.length=0,this.deviceInterface=void 0}},{key:"executeCriticalFunction",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e(),this.criticalPromises.push(t),n.abrupt("return",t);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"log",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(this.loggingEnabled){var a,i=new Date,s=i.toLocaleTimeString().replace(' PM','').replace(' AM',''),o="".concat(s,".").concat(i.getMilliseconds());if(n)n=n.map(function(e){return Array.isArray(e)?e.slice():e}),(a=console).log.apply(a,[o,e].concat(m(n)));else console.log(o,e)}}}]),e})()},function(e,t,n){"use strict";n.d(t,"b",function(){return i}),n.d(t,"a",function(){return s});var r=n(7),a=n(3);function i(e){return e.map(function(e){return e.uuid})}function s(e){return e.references||(e.references=[]),e.appData||(e.appData={}),e.appData[a.b]||(e.appData[a.b]={}),e.appData[a.b][r.a.UserModifiedDate]||(e.appData[a.b][r.a.UserModifiedDate]="".concat(new Date)),e}},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.EncryptedString=0]="EncryptedString",e[e.DecryptedBareObject=1]="DecryptedBareObject",e[e.DecryptedBase64String=2]="DecryptedBase64String",e[e.Deleted=3]="Deleted"})(r||(r={}))},function(e,t,n){"use strict";n.d(t,"g",function(){return r}),n.d(t,"a",function(){return p}),n.d(t,"b",function(){return d}),n.d(t,"c",function(){return h}),n.d(t,"d",function(){return f}),n.d(t,"e",function(){return g}),n.d(t,"f",function(){return b}),n.d(t,"h",function(){return w});var r,a=n(14),i=n(6),s=n(0);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){u(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e.Registration="registration",e.EmailChange="email-change",e.PasswordChange="password-change",e.ProtocolUpgrade="protocol-upgrade",e.PasscodeCreate="passcode-create",e.PasscodeChange="passcode-change"})(r||(r={}));var l=['identifier','pw_cost','pw_nonce','pw_salt','version','origination','created'];function p(e){return g(e)}function d(e){return g(e)}function h(e){return g(e)}function f(e){return g(e)}function g(e){if(e.content)throw Error('Raw key params shouldnt have content; perhaps you passed in a SNRootKeyParams object.');return new w(e)}function m(e){if(e.version)return e.version;var t=e.pw_cost,n=a.a.PbkdfCostsUsed.includes(t),r=a.b.PbkdfCostsUsed.includes(t);return n&&!r?i.a.V001:r&&!n?i.a.V002:r&&n&&e.pw_nonce&&a.b.ImprobablePbkdfCostsUsed.includes(t)?i.a.V001:i.a.V002}function b(e,t){return g({identifier:t||e.data.identifier,pw_cost:e.data.pw_cost,pw_nonce:e.data.pw_nonce,pw_salt:e.data.pw_salt,version:m(e.data),origination:e.data.origination,created:e.data.created})}var w=(function(){function e(t){v(this,e),this.content=c(c({},t),{},{origination:t.origination||r.Registration,version:t.version||m(t)})}return y(e,[{key:"compare",value:function(e){if(this.version!==e.version)return!1;if([i.a.V004,i.a.V003].includes(this.version))return this.identifier===e.identifier&&this.content004.pw_nonce===e.content003.pw_nonce;if([i.a.V002,i.a.V001].includes(this.version))return this.identifier===e.identifier&&this.content002.pw_salt===e.content001.pw_salt;throw Error('Unhandled version in KeyParams.compare')}},{key:"getPortableValue",value:function(){return Object(s.L)(this.content,l)}},{key:"isKeyParamsObject",get:function(){return!0}},{key:"identifier",get:function(){return this.content004.identifier||this.content002.email}},{key:"version",get:function(){return this.content.version}},{key:"origination",get:function(){return this.content.origination}},{key:"content001",get:function(){return this.content}},{key:"content002",get:function(){return this.content}},{key:"content003",get:function(){return this.content}},{key:"content004",get:function(){return this.content}},{key:"createdDate",get:function(){if(this.content004.created)return new Date(Number(this.content004.created))}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return i}),n.d(t,"b",function(){return s}),n.d(t,"c",function(){return r}),n.d(t,"d",function(){return a});var r,a,i=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:[3e3,5e3,1e4,6e4],PbkdfOutputLength:512,EncryptionKeyLength:256}),s=Object.freeze({SaltSeedLength:128,PbkdfMinCost:3e3,PbkdfCostsUsed:i.PbkdfCostsUsed.concat([1e5,101e3,102e3,103e3]),ImprobablePbkdfCostsUsed:[3e3,5e3],PbkdfOutputLength:768,EncryptionKeyLength:256,EncryptionIvLength:128});!(function(e){e[e.SaltSeedLength=256]="SaltSeedLength",e[e.PbkdfCost=11e4]="PbkdfCost",e[e.PbkdfOutputLength=768]="PbkdfOutputLength",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionIvLength=128]="EncryptionIvLength"})(r||(r={})),(function(e){e[e.ArgonSaltSeedLength=256]="ArgonSaltSeedLength",e[e.ArgonSaltLength=128]="ArgonSaltLength",e[e.ArgonIterations=5]="ArgonIterations",e[e.ArgonMemLimit=67108864]="ArgonMemLimit",e[e.ArgonOutputKeyBytes=64]="ArgonOutputKeyBytes",e[e.EncryptionKeyLength=256]="EncryptionKeyLength",e[e.EncryptionNonceLength=192]="EncryptionNonceLength"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"c",function(){return i}),n.d(t,"a",function(){return a});var r,a;n(22);function i(e){return e.status===r.HttpStatusExpiredAccessToken}!(function(e){e[e.LocalValidationError=10]="LocalValidationError",e[e.CanceledMfa=11]="CanceledMfa",e[e.UnknownError=12]="UnknownError",e[e.HttpStatusMinSuccess=200]="HttpStatusMinSuccess",e[e.HttpStatusNoContent=204]="HttpStatusNoContent",e[e.HttpStatusMaxSuccess=299]="HttpStatusMaxSuccess",e[e.HttpStatusExpiredAccessToken=498]="HttpStatusExpiredAccessToken",e[e.HttpStatusInvalidSession=401]="HttpStatusInvalidSession",e[e.HttpStatusForbidden=403]="HttpStatusForbidden",e[e.HttpBadRequest=400]="HttpBadRequest"})(r||(r={})),(function(e){e.ConflictingData="sync_conflict",e.UuidConflict="uuid_conflict",e.ContentTypeError="content_type_error",e.ContentError="content_error"})(a||(a={}))},function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r=(function(){function e(){v(this,e)}return y(e,null,[{key:"log",value:function(){this.onLog.apply(this,arguments)}},{key:"error",value:function(e){return this.onError(e),e}}]),e})()},function(e,t,n){"use strict";n.d(t,"a",function(){return r}),n.d(t,"c",function(){return i});var r,a=n(9);function i(e){var t;return(t={},g(t,a.a.FullSyncCompleted,r.CompletedFullSync),g(t,a.a.SingleSyncCompleted,r.CompletedIncrementalSync),g(t,a.a.SyncError,r.FailedSync),g(t,a.a.SyncTakingTooLong,r.HighLatencySync),g(t,a.a.EnterOutOfSync,r.EnteredOutOfSync),g(t,a.a.ExitOutOfSync,r.ExitedOutOfSync),g(t,a.a.LocalDataLoaded,r.LocalDataLoaded),g(t,a.a.MajorDataChange,r.MajorDataChange),g(t,a.a.LocalDataIncrementalLoad,r.LocalDataIncrementalLoad),g(t,a.a.StatusChanged,r.SyncStatusChanged),g(t,a.a.SyncWillBegin,r.WillSync),g(t,a.a.InvalidSession,r.InvalidSyncSession),g(t,a.a.DatabaseReadError,r.LocalDatabaseReadError),g(t,a.a.DatabaseWriteError,r.LocalDatabaseWriteError),t)[e]}n.d(t,"b",function(){return a.a}),(function(e){e[e.SignedIn=2]="SignedIn",e[e.SignedOut=3]="SignedOut",e[e.CompletedFullSync=5]="CompletedFullSync",e[e.FailedSync=6]="FailedSync",e[e.HighLatencySync=7]="HighLatencySync",e[e.EnteredOutOfSync=8]="EnteredOutOfSync",e[e.ExitedOutOfSync=9]="ExitedOutOfSync",e[e.Started=10]="Started",e[e.Launched=11]="Launched",e[e.LocalDataLoaded=12]="LocalDataLoaded",e[e.KeyStatusChanged=13]="KeyStatusChanged",e[e.MajorDataChange=14]="MajorDataChange",e[e.CompletedRestart=15]="CompletedRestart",e[e.LocalDataIncrementalLoad=16]="LocalDataIncrementalLoad",e[e.SyncStatusChanged=17]="SyncStatusChanged",e[e.WillSync=18]="WillSync",e[e.InvalidSyncSession=19]="InvalidSyncSession",e[e.LocalDatabaseReadError=20]="LocalDatabaseReadError",e[e.LocalDatabaseWriteError=21]="LocalDatabaseWriteError",e[e.CompletedIncrementalSync=22]="CompletedIncrementalSync",e[e.MigrationsLoaded=23]="MigrationsLoaded",e[e.StorageReady=24]="StorageReady",e[e.PreferencesChanged=25]="PreferencesChanged",e[e.ProtectionSessionExpiryDateChanged=26]="ProtectionSessionExpiryDateChanged",e[e.UserRolesChanged=27]="UserRolesChanged",e[e.FeaturesUpdated=28]="FeaturesUpdated"})(r||(r={}))},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e[e.KeepLeft=1]="KeepLeft",e[e.KeepRight=2]="KeepRight",e[e.KeepLeftDuplicateRight=3]="KeepLeftDuplicateRight",e[e.DuplicateLeftKeepRight=4]="DuplicateLeftKeepRight",e[e.KeepLeftMergeRefs=5]="KeepLeftMergeRefs"})(r||(r={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(211),t)},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(221),t)},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(0);function a(e){return e instanceof i?e:Array.isArray(e)?i.FromArray(e):i.FromJson(e)}var i=(function(){function e(t,n,r){if(v(this,e),this.keypath=t,this.operator=n,this.value=r,this.isRecursive()){var i=this.value;this.value=i.map(function(e){return a(e)})}else'true'!==this.value&&'false'!==this.value||(this.value=JSON.parse(this.value))}return y(e,[{key:"isRecursive",value:function(){return['and','or'].includes(this.operator)}},{key:"arrayRepresentation",value:function(){return[this.keypath,this.operator,this.value]}},{key:"valueAsArray",value:function(){return this.value}},{key:"keypathIncludesVerb",value:function(e){if(this.isRecursive()){for(var t,n=S(this.value);!(t=n()).done;){if(t.value.keypathIncludesVerb(e))return!0}return!1}return this.keypath.includes(e)}}],[{key:"FromJson",value:function(t){return new e(t.keypath,t.operator,t.value)}},{key:"FromArray",value:function(t){return new e(t[0],t[1],t[2])}},{key:"CompoundPredicate",value:function(t){return new e('ignored','and',t)}},{key:"ObjectSatisfiesPredicate",value:function(e,t){if((t=a(t)).isRecursive()){if('and'===t.operator){for(var n,r=S(t.valueAsArray());!(n=r()).done;){var i=n.value;if(!this.ObjectSatisfiesPredicate(e,i))return!1}return!0}if('or'===t.operator){for(var s,o=S(t.valueAsArray());!(s=o()).done;){var c=s.value;if(this.ObjectSatisfiesPredicate(e,c))return!0}return!1}}var u=t.value;if('string'==typeof u&&u.includes('.ago')&&(u=this.DateFromString(u)),'not'===t.operator)return!this.ObjectSatisfiesPredicate(e,u);var l=t.keypath.split('.').reduce(function(e,t){return e&&e[t]},e),p=[!1,'',null,void 0,NaN];return void 0===l?'!='===t.operator?!p.includes(t.value):p.includes(t.value):'='===t.operator?Array.isArray(l)?JSON.stringify(l)===JSON.stringify(u):l===u:'!='===t.operator?Array.isArray(l)?JSON.stringify(l)!==JSON.stringify(u):l!==u:'<'===t.operator?l<u:'>'===t.operator?l>u:'<='===t.operator?l<=u:'>='===t.operator?l>=u:'startsWith'===t.operator?l.startsWith(u):'in'===t.operator?-1!==u.indexOf(l):'includes'===t.operator?this.resolveIncludesPredicate(l,u):'matches'===t.operator&&new RegExp(u).test(l)}},{key:"resolveIncludesPredicate",value:function(t,n){if(Object(r.A)(n))return t.includes(n);var a;a=Array.isArray(n)?e.FromArray(n):n;for(var i,s=S(t);!(i=s()).done;){var o=i.value;if(this.ObjectSatisfiesPredicate(o,a))return!0}return!1}},{key:"ItemSatisfiesPredicate",value:function(e,t){return this.ObjectSatisfiesPredicate(e,t)}},{key:"ItemSatisfiesPredicates",value:function(e,t){for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!this.ItemSatisfiesPredicate(e,a))return!1}return!0}},{key:"DateFromString",value:function(e){var t=e.split('.'),n=t[1],r=new Date,a=parseInt(t[0]);return'days'===n?r.setDate(r.getDate()-a):'hours'===n&&r.setHours(r.getHours()-a),r}}]),e})()},function(e,t,n){"use strict";var r;n.d(t,"a",function(){return r}),(function(e){e.LastSyncToken="sync_token",e.PaginationToken="cursor_token",e.IntegrityCheck="compute_integrity",e.IntegrityResult="integrity_hash",e.SyncDlLimit="limit",e.SyncPayloads="items",e.ApiVersion="api"})(r||(r={}))},function(e,t,n){"use strict";var r=Array.isArray;e.exports=r},function(e,t,n){"use strict";var r=n(68),a='object'==typeof self&&self&&self.Object===Object&&self,i=r||a||Function('return this')();e.exports=i},function(e,t,n){"use strict";var r=n(173)(n(174));e.exports=r},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return null!=e&&('object'==t||'function'==t)}},function(e,t,n){"use strict";var r=n(48),a=n(168);e.exports=function(e,t){var n=[];if(!e||!e.length)return n;var i=-1,s=[],o=e.length;for(t=r(t,3);++i<o;){var c=e[i];t(c,i,e)&&(n.push(c),s.push(i))}return a(e,s),n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e){return e&&e.length?r(e):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(241),t)},function(e,t,n){"use strict";var r=n(110),a=n(115);e.exports=function(e,t){var n=a(e,t);return r(n)?n:void 0}},function(e,t,n){"use strict";e.exports=function(e){return null!=e&&'object'==typeof e}},function(e,t,n){"use strict";n.d(t,"a",function(){return u});var r=n(11),a=n(5),i=n(4),s=n(6),o=n(0),c=n(12),u=(function(){function e(t,n,u){if(v(this,e),this.fields=n||Object.keys(t),this.source=u||i.a.Constructor,this.uuid=t.uuid,!this.uuid&&this.fields.includes(a.a.Uuid))throw Error("uuid is null, yet this payloads fields indicate it shouldnt be. Content type: ".concat(t.content_type));this.content_type=t.content_type,t.content&&(Object(o.x)(t.content)?this.content=Object(r.a)(t.content):this.content=t.content),this.deleted=t.deleted,this.items_key_id=t.items_key_id,this.enc_item_key=t.enc_item_key,this.created_at=new Date(t.created_at||new Date),this.updated_at=new Date(t.updated_at||0),this.created_at_timestamp=t.created_at_timestamp,this.updated_at_timestamp=t.updated_at_timestamp,t.dirtiedDate&&(this.dirtiedDate=new Date(t.dirtiedDate)),this.dirty=t.dirty,this.errorDecrypting=t.errorDecrypting,this.waitingForKey=t.waitingForKey,this.errorDecryptingValueChanged=t.errorDecryptingValueChanged,this.lastSyncBegan=t.lastSyncBegan?new Date(t.lastSyncBegan):void 0,this.lastSyncEnd=t.lastSyncEnd?new Date(t.lastSyncEnd):void 0,this.auth_hash=t.auth_hash,this.auth_params=t.auth_params,this.duplicate_of=t.duplicate_of,Object(o.A)(this.content)?this.content.startsWith(s.a.V000Base64Decrypted)?this.format=c.a.DecryptedBase64String:this.format=c.a.EncryptedString:Object(o.x)(this.content)?this.format=c.a.DecryptedBareObject:this.format=c.a.Deleted,Object(o.A)(this.content)?this.version=this.content.substring(0,s.a.VersionLength):this.content&&(this.version=this.content.version),Object(o.l)(this)}return y(e,[{key:"ejected",value:function(){for(var e,t=[a.a.Legacy003AuthHash,a.a.Deleted],n=[a.a.DirtiedDate,a.a.ErrorDecrypting,a.a.ErrorDecryptingChanged,a.a.WaitingForKey,a.a.LastSyncBegan,a.a.LastSyncEnd],r={},i=S(this.fields);!(e=i()).done;){var s=e.value;if(!n.includes(s)){var c=this[s];Object(o.w)(c)&&t.includes(s)||(r[s]=c)}}return r}},{key:"safeContent",get:function(){return this.format===c.a.DecryptedBareObject?this.content:{}}},{key:"references",get:function(){return this.safeReferences}},{key:"safeReferences",get:function(){return this.safeContent.references||[]}},{key:"contentObject",get:function(){if(this.format!==c.a.DecryptedBareObject)throw Error('Attempting to access non-object content as object');return this.content}},{key:"contentString",get:function(){if(this.format===c.a.DecryptedBareObject)throw Error('Attempting to access non-string content as string');return this.content}},{key:"discardable",get:function(){return this.deleted&&!this.dirty}},{key:"serverUpdatedAt",get:function(){return this.updated_at}}]),e})()},function(e,t,n){"use strict";var r=n(40),a=n(111),i=n(112),s='[object Null]',o='[object Undefined]',c=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?o:s:c&&c in Object(e)?a(e):i(e)}},function(e,t,n){"use strict";var r;r=(function(){return this})();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,n){"use strict";var r=n(51),a=n(59);e.exports=function(e){return null!=e&&a(e.length)&&!r(e)}},function(e,t,n){"use strict";var r=n(44);e.exports=function(e){if('string'==typeof e||r(e))return e;var t=e+'';return'0'==t&&1/e==-1/0?'-0':t}},function(e,t,n){"use strict";var r=n(100),a=n(101),i=n(102),s=n(103),o=n(104);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(35);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return-1}},function(e,t,n){"use strict";var r=n(24).Symbol;e.exports=r},function(e,t,n){"use strict";var r=n(30)(Object,'create');e.exports=r},function(e,t,n){"use strict";var r=n(124);e.exports=function(e,t){var n=e.__data__;return r(t)?n['string'==typeof t?'string':'hash']:n.map}},function(e,t,n){"use strict";var r=9007199254740991,a=/^(?:0|[1-9]\d*)$/;e.exports=function(e,t){var n=typeof e;return!!(t=null==t?r:t)&&('number'==n||'symbol'!=n&&a.test(e))&&e>-1&&e%1==0&&e<t}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Symbol]';e.exports=function(e){return'symbol'==typeof e||a(e)&&r(e)==i}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(231),t)},function(e,t,n){"use strict";var r=n(96);n.d(t,"SNSettingsService",function(){return r.a});var a=n(94);n.n(a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n){r(e,t,n)});e.exports=a},function(e,t,n){"use strict";var r=n(98),a=n(154),i=n(64),s=n(23),o=n(165);e.exports=function(e){return'function'==typeof e?e:null==e?i:'object'==typeof e?s(e)?a(e[0],e[1]):r(e):o(e)}},function(e,t,n){"use strict";var r=n(38),a=n(105),i=n(106),s=n(107),o=n(108),c=n(109);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=a,u.prototype.delete=i,u.prototype.get=s,u.prototype.has=o,u.prototype.set=c,e.exports=u},function(e,t,n){"use strict";var r=n(30)(n(24),'Map');e.exports=r},function(e,t,n){"use strict";var r=n(33),a=n(26),i='[object AsyncFunction]',s='[object Function]',o='[object GeneratorFunction]',c='[object Proxy]';e.exports=function(e){if(!a(e))return!1;var t=r(e);return t==s||t==o||t==i||t==c}},function(e,t,n){"use strict";var r=n(116),a=n(123),i=n(125),s=n(126),o=n(127);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},function(e,t,n){"use strict";var r=n(75),a=n(147),i=n(36);e.exports=function(e){return i(e)?r(e):a(e)}},function(e,t,n){"use strict";var r=n(142),a=n(31),i=Object.prototype,s=i.hasOwnProperty,o=i.propertyIsEnumerable,c=r((function(){return arguments})())?r:function(e){return a(e)&&s.call(e,'callee')&&!o.call(e,'callee')};e.exports=c},function(e,t,n){"use strict";(function(e){var r=n(24),a=n(143),i=t&&!t.nodeType&&t,s=i&&'object'==typeof e&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,c=(o?o.isBuffer:void 0)||a;e.exports=c}).call(this,n(57)(e))},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";var r=n(144),a=n(145),i=n(146),s=i&&i.isTypedArray,o=s?a(s):r;e.exports=o},function(e,t,n){"use strict";var r=9007199254740991;e.exports=function(e){return'number'==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,n){"use strict";var r=Object.prototype;e.exports=function(e){var t=e&&e.constructor;return e===('function'==typeof t&&t.prototype||r)}},function(e,t,n){"use strict";var r=n(62),a=n(37);e.exports=function(e,t){for(var n=0,i=(t=r(t,e)).length;null!=e&&n<i;)e=e[a(t[n++])];return n&&n==i?e:void 0}},function(e,t,n){"use strict";var r=n(23),a=n(63),i=n(156),s=n(159);e.exports=function(e,t){return r(e)?e:a(e,t)?[e]:i(s(e))}},function(e,t,n){"use strict";var r=n(23),a=n(44),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!('number'!=n&&'symbol'!=n&&'boolean'!=n&&null!=e&&!a(e))||s.test(e)||!i.test(e)||null!=t&&e in Object(t)}},function(e,t,n){"use strict";e.exports=function(e){return e}},function(e,t,n){"use strict";var r=n(83);e.exports=function(e,t,n){'__proto__'==t&&r?r(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}},function(e,t,n){"use strict";var r=n(88);e.exports=function(e,t){return t='function'==typeof t?t:void 0,e&&e.length?r(e,void 0,t):[]}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(228),t),a(n(229),t),a(n(230),t)},function(e,t,n){"use strict";(function(t){var n='object'==typeof t&&t&&t.Object===Object&&t;e.exports=n}).call(this,n(34))},function(e,t,n){"use strict";var r=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return r.call(e)}catch(e){}try{return e+''}catch(e){}}return''}},function(e,t,n){"use strict";var r=n(128),a=n(31);e.exports=function e(t,n,i,s,o){return t===n||(null==t||null==n||!a(t)&&!a(n)?t!=t&&n!=n:r(t,n,i,s,e,o))}},function(e,t,n){"use strict";var r=n(72),a=n(131),i=n(73),s=1,o=2;e.exports=function(e,t,n,c,u,l){var p=n&s,d=e.length,h=t.length;if(d!=h&&!(p&&h>d))return!1;var f=l.get(e),v=l.get(t);if(f&&v)return f==t&&v==e;var y=-1,g=!0,m=n&o?new r:void 0;for(l.set(e,t),l.set(t,e);++y<d;){var b=e[y],w=t[y];if(c)var k=p?c(w,b,y,t,e,l):c(b,w,y,e,t,l);if(void 0!==k){if(k)continue;g=!1;break}if(m){if(!a(t,function(e,t){if(!i(m,t)&&(b===e||u(b,e,n,c,l)))return m.push(t)})){g=!1;break}}else if(b!==w&&!u(b,w,n,c,l)){g=!1;break}}return l.delete(e),l.delete(t),g}},function(e,t,n){"use strict";var r=n(52),a=n(129),i=n(130);function s(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}s.prototype.add=s.prototype.push=a,s.prototype.has=i,e.exports=s},function(e,t,n){"use strict";e.exports=function(e,t){return e.has(t)}},function(e,t,n){"use strict";var r=n(24).Uint8Array;e.exports=r},function(e,t,n){"use strict";var r=n(141),a=n(55),i=n(23),s=n(56),o=n(43),c=n(58),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=i(e),l=!n&&a(e),p=!n&&!l&&s(e),d=!n&&!l&&!p&&c(e),h=n||l||p||d,f=h?r(e.length,String):[],v=f.length;for(var y in e)!t&&!u.call(e,y)||h&&('length'==y||p&&('offset'==y||'parent'==y)||d&&('buffer'==y||'byteLength'==y||'byteOffset'==y)||o(y,v))||f.push(y);return f}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return e(t(n))}}},function(e,t,n){"use strict";var r=n(30)(n(24),'Set');e.exports=r},function(e,t,n){"use strict";var r=n(26);e.exports=function(e){return e==e&&!r(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){for(var a=e.length,i=n+(r?1:-1);r?i--:++i<a;)if(t(e[i],i,e))return i;return-1}},function(e,t,n){"use strict";var r=n(49),a=n(82),i=n(178),s=n(180),o=n(26),c=n(86),u=n(85);e.exports=function e(t,n,l,p,d){t!==n&&i(n,function(i,c){if(d||(d=new r),o(i))s(t,n,c,l,e,p,d);else{var h=p?p(u(t,c),i,c+'',t,n,d):void 0;void 0===h&&(h=i),a(t,c,h)}},c)}},function(e,t,n){"use strict";var r=n(65),a=n(35);e.exports=function(e,t,n){(void 0===n||a(e[t],n))&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(30),a=(function(){try{var e=r(Object,'defineProperty');return e({},'',{}),e}catch(e){}})();e.exports=a},function(e,t,n){"use strict";var r=n(76)(Object.getPrototypeOf,Object);e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){if(('constructor'!==t||'function'!=typeof e[t])&&'__proto__'!=t)return e[t]}},function(e,t,n){"use strict";var r=n(75),a=n(192),i=n(36);e.exports=function(e){return i(e)?r(e,!0):a(e)}},function(e,t,n){"use strict";var r=n(194),a=n(201);e.exports=function(e){return r(function(t,n){var r=-1,i=n.length,s=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(s=e.length>3&&'function'==typeof s?(i--,s):void 0,o&&a(n[0],n[1],o)&&(s=i<3?void 0:s,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,s)}return t})}},function(e,t,n){"use strict";var r=n(72),a=n(202),i=n(206),s=n(73),o=n(207),c=n(53),u=200;e.exports=function(e,t,n){var l=-1,p=a,d=e.length,h=!0,f=[],v=f;if(n)h=!1,p=i;else if(d>=u){var y=t?null:o(e);if(y)return c(y);h=!1,p=s,v=new r}else v=t?[]:f;e:for(;++l<d;){var g=e[l],m=t?t(g):g;if(g=n||0!==g?g:0,h&&m==m){for(var b=v.length;b--;)if(v[b]===m)continue e;t&&v.push(m),f.push(g)}else p(v,m,n)||(v!==f&&v.push(m),f.push(g))}return f}},function(e,t,n){"use strict";(function(e){var r=void 0!==e&&e||"undefined"!=typeof self&&self||window,a=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(a.call(setTimeout,r,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,r,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(r,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(209),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,n(34))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FeatureIdentifier=void 0,(function(e){e.AutobiographyTheme="org.standardnotes.theme-autobiography",e.BoldEditor="org.standardnotes.bold-editor",e.CloudLink="org.standardnotes.cloudlink",e.CodeEditor="org.standardnotes.code-editor",e.DailyDropboxBackup="org.standardnotes.daily-dropbox-backup",e.DailyEmailBackup="org.standardnotes.daily-email-backup",e.DailyGDriveBackup="org.standardnotes.daily-gdrive-backup",e.DailyOneDriveBackup="org.standardnotes.daily-onedrive-backup",e.DynamicTheme="org.standardnotes.theme-dynamic",e.Files="org.standardnotes.files",e.Files25GB="org.standardnotes.files-25-gb",e.Files5GB="org.standardnotes.files-5-gb",e.FileSafe="org.standardnotes.file-safe",e.FocusedTheme="org.standardnotes.theme-focus",e.FoldersComponent="org.standardnotes.folders",e.FuturaTheme="org.standardnotes.theme-futura",e.ListedCustomDomain="org.standardnotes.listed-custom-domain",e.MarkdownBasicEditor="org.standardnotes.simple-markdown-editor",e.MarkdownMathEditor="org.standardnotes.fancy-markdown-editor",e.MarkdownMinimistEditor="org.standardnotes.minimal-markdown-editor",e.MarkdownProEditor="org.standardnotes.advanced-markdown-editor",e.MidnightTheme="org.standardnotes.theme-midnight",e.NoDistractionTheme="org.standardnotes.theme-no-distraction",e.NoteHistory30Days="org.standardnotes.note-history-30",e.NoteHistory365Days="org.standardnotes.note-history-365",e.NoteHistoryUnlimited="org.standardnotes.note-history-unlimited",e.PlusEditor="org.standardnotes.plus-editor",e.SheetsEditor="org.standardnotes.standard-sheets",e.SolarizedDarkTheme="org.standardnotes.theme-solarized-dark",e.TagNesting="org.standardnotes.tag-nesting",e.TaskEditor="org.standardnotes.simple-task-editor",e.TitaniumTheme="org.standardnotes.theme-titanium",e.TokenVaultEditor="org.standardnotes.token-vault",e.TwoFactorAuth="org.standardnotes.two-factor-auth",e.TwoFactorAuthManager="org.standardnotes.mfa-link",e.FocusMode="org.standardnotes.focus-mode"})(t.FeatureIdentifier||(t.FeatureIdentifier={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentArea=void 0,(function(e){e.Editor="editor-editor",e.Themes="themes",e.TagsList="tags-list",e.EditorStack="editor-stack",e.NoteTags="note-tags",e.Rooms="rooms",e.Modal="modal",e.Any="*"})(t.ComponentArea||(t.ComponentArea={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ComponentFlag=void 0,(function(e){e.New="New",e.Deprecated="Deprecated"})(t.ComponentFlag||(t.ComponentFlag={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PermissionName=void 0,(function(e){e.AutobiographyTheme="theme:autobiography",e.BoldEditor="editor:bold",e.CloudLink="component:cloud-link",e.CodeEditor="editor:code-editor",e.ComponentFilesafe="component:filesafe",e.ComponentFolders="component:folders",e.DailyDropboxBackup="server:daily-dropbox-backup",e.DailyEmailBackup="server:daily-email-backup",e.DailyGDriveBackup="server:daily-gdrive-backup",e.DailyOneDriveBackup="server:daily-onedrive-backup",e.Files="app:files",e.Files25GB="server:files-25-gb",e.Files5GB="server:files-5-gb",e.FocusedTheme="theme:focused",e.FuturaTheme="theme:futura",e.ListedCustomDomain="listed:custom-domain",e.MarkdownBasicEditor="editor:markdown-basic",e.MarkdownMathEditor="editor:markdown-math",e.MarkdownMinimistEditor="editor:markdown-minimist",e.MarkdownProEditor="editor:markdown-pro",e.MidnightTheme="theme:midnight",e.NoteHistory30Days="server:note-history-30-days",e.NoteHistory365Days="server:note-history-365-days",e.NoteHistoryUnlimited="server:note-history-unlimited",e.PlusEditor="editor:plus",e.SheetsEditor="editor:sheets",e.SolarizedDarkTheme="theme:solarized-dark",e.TagNesting="app:tag-nesting",e.TaskEditor="editor:task-editor",e.ThemeDynamic="theme:dynamic",e.ThemeNoDistraction="theme:no-distraction",e.TitaniumTheme="theme:titanium",e.TokenVaultEditor="editor:token-vault",e.TwoFactorAuth="server:two-factor-auth",e.TwoFactorAuthManager="component:2fa-manager",e.FocusMode="app:focus-mode"})(t.PermissionName||(t.PermissionName={}))},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return i});var r=n(10),a=n(17),i=(function(t){d(r,t);var n=k(r);function r(t){var a;return v(this,r),(a=n.call(this)).application=t,e(function(){a.addAppEventObserver()}),a}return y(r,[{key:"deinit",value:function(){this.application=void 0,this.unsubApp(),this.unsubApp=void 0,p(f(r.prototype),"deinit",this).call(this)}},{key:"addAppEventObserver",value:function(){var e=this;this.application.isStarted()&&this.onAppStart(),this.application.isLaunched()&&this.onAppLaunch(),this.unsubApp=this.application.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(e.onAppEvent(t));case 2:t===a.a.Started?e.onAppStart():t===a.a.Launched?e.onAppLaunch():t===a.a.CompletedFullSync?e.onAppFullSync():t===a.a.CompletedIncrementalSync?e.onAppIncrementalSync():t===a.a.KeyStatusChanged&&e.onAppKeyChange();case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"onAppEvent",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppStart",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppLaunch",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppKeyChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}},null,null,null,Promise)}},{key:"onAppIncrementalSync",value:function(){}},{key:"onAppFullSync",value:function(){}}]),r})(r.a)}).call(this,n(89).setImmediate)},function(e,t,n){"use strict";n.d(t,"a",function(){return o});var r=n(10),a=n(2),i=n(15),s=(function(){function e(t,n){v(this,e),this.settingsApi=t,this.userProvider=n}return y(e,[{key:"isReadyForModification",value:function(){return null!=this.getUser()}},{key:"getUser",value:function(){return this.userProvider.getUser()}},{key:"listSettings",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.settingsApi.listSettings(this.userUuid));case 2:if(e=o.sent,t=e.error,n=e.data,null==t){o.next=7;break}throw new Error(t.message);case 7:if(null!=n&&null!=n.settings){o.next=9;break}return o.abrupt("return",{});case 9:for(r={},a=S(n.settings);!(i=a()).done;)s=i.value,r[s.name]=s.value;return o.abrupt("return",r);case 12:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){var t,n,r,a;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((a=s.sent).status!==i.b.HttpBadRequest){s.next=5;break}return s.abrupt("return",null);case 5:if(null==a.error){s.next=7;break}throw new Error(a.error.message);case 7:return s.abrupt("return",null!==(t=null===a||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:null===(r=n.setting)||void 0===r?void 0:r.value)&&void 0!==t?t:null);case 8:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.settingsApi.getSetting(this.userUuid,e));case 2:if((r=a.sent).status!==i.b.HttpBadRequest){a.next=5;break}return a.abrupt("return",!1);case 5:if(null==r.error){a.next=7;break}throw new Error(r.error.message);case 7:return a.abrupt("return",null!==(t=null===(n=r.data)||void 0===n?void 0:n.success)&&void 0!==t&&t);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){var r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.settingsApi.updateSetting(this.userUuid,e,t,n));case 2:if(r=i.sent,null==(a=r.error)){i.next=6;break}throw new Error(a.message);case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.settingsApi.deleteSetting(this.userUuid,e));case 2:if(t=r.sent,null==(n=t.error)){r.next=6;break}throw new Error(n.message);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.settingsApi=void 0,this.userProvider=void 0}},{key:"userUuid",get:function(){var e=this.getUser();if(null==e||null==e.uuid)throw new Error(a.o);return e.uuid}}]),e})(),o=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).sessionManager=e,a.apiService=r,a}return y(n,[{key:"initializeFromDisk",value:function(){this._provider=new s(this.apiService,this.sessionManager)}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._provider.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this._provider.updateSetting(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._provider.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){var e;null===(e=this._provider)||void 0===e||e.deinit(),this._provider=void 0,this.sessionManager=void 0,this.apiService=void 0}}]),n})(r.a)},function(e,t,n){"use strict";var r=n(81),a=n(87)(function(e,t,n,a){r(e,t,n,a)});e.exports=a},function(e,t,n){"use strict";var r=n(99),a=n(153),i=n(79);e.exports=function(e){var t=a(e);return 1==t.length&&t[0][2]?i(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},function(e,t,n){"use strict";var r=n(49),a=n(70);e.exports=function(e,t,n,i){var s=n.length,o=s,c=!i;if(null==e)return!o;for(e=Object(e);s--;){var u=n[s];if(c&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++s<o;){var l=(u=n[s])[0],p=e[l],d=u[1];if(c&&u[2]){if(void 0===p&&!(l in e))return!1}else{var h=new r;if(i)var f=i(p,d,l,e,t,h);if(!(void 0===f?a(d,p,3,i,h):f))return!1}}return!0}},function(e,t,n){"use strict";e.exports=function(){this.__data__=[],this.size=0}},function(e,t,n){"use strict";var r=n(39),a=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0||(n==t.length-1?t.pop():a.call(t,n,1),--this.size,0))}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e){return r(this.__data__,e)>-1}},function(e,t,n){"use strict";var r=n(39);e.exports=function(e,t){var n=this.__data__,a=r(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}},function(e,t,n){"use strict";var r=n(38);e.exports=function(){this.__data__=new r,this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.get(e)}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";var r=n(38),a=n(50),i=n(52);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!a||s.length<199)return s.push([e,t]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(e,t),this.size=n.size,this}},function(e,t,n){"use strict";var r=n(51),a=n(113),i=n(26),s=n(69),o=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,l=c.toString,p=u.hasOwnProperty,d=RegExp('^'+l.call(p).replace(/[\\^$.*+?()[\]{}|]/g,'\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,'$1.*?')+'$');e.exports=function(e){return!(!i(e)||a(e))&&(r(e)?d:o).test(s(e))}},function(e,t,n){"use strict";var r=n(40),a=Object.prototype,i=a.hasOwnProperty,s=a.toString,o=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0}catch(e){}var r=s.call(e);return t?e[o]=n:delete e[o],r}},function(e,t,n){"use strict";var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,n){"use strict";var r,a=n(114),i=(r=/[^.]+$/.exec(a&&a.keys&&a.keys.IE_PROTO||''))?'Symbol(src)_1.'+r:'';e.exports=function(e){return!!i&&i in e}},function(e,t,n){"use strict";var r=n(24)['__core-js_shared__'];e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return null==e?void 0:e[t]}},function(e,t,n){"use strict";var r=n(117),a=n(38),i=n(50);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||a),string:new r}}},function(e,t,n){"use strict";var r=n(118),a=n(119),i=n(120),s=n(121),o=n(122);function c(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}c.prototype.clear=r,c.prototype.delete=a,c.prototype.get=i,c.prototype.has=s,c.prototype.set=o,e.exports=c},function(e,t,n){"use strict";var r=n(41);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},function(e,t,n){"use strict";e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__',i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return n===a?void 0:n}return i.call(t,e)?t[e]:void 0}},function(e,t,n){"use strict";var r=n(41),a=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:a.call(t,e)}},function(e,t,n){"use strict";var r=n(41),a='__lodash_hash_undefined__';e.exports=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=r&&void 0===t?a:t,this}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t,n){"use strict";e.exports=function(e){var t=typeof e;return'string'==t||'number'==t||'symbol'==t||'boolean'==t?'__proto__'!==e:null===e}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).get(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e){return r(this,e).has(e)}},function(e,t,n){"use strict";var r=n(42);e.exports=function(e,t){var n=r(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}},function(e,t,n){"use strict";var r=n(49),a=n(71),i=n(132),s=n(134),o=n(149),c=n(23),u=n(56),l=n(58),p=1,d='[object Arguments]',h='[object Array]',f='[object Object]',v=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,y,g,m){var b=c(e),w=c(t),k=b?h:o(e),x=w?h:o(t),S=(k=k==d?f:k)==f,P=(x=x==d?f:x)==f,O=k==x;if(O&&u(e)){if(!u(t))return!1;b=!0,S=!1}if(O&&!S)return m||(m=new r),b||l(e)?a(e,t,n,y,g,m):i(e,t,k,n,y,g,m);if(!(n&p)){var C=S&&v.call(e,'__wrapped__'),D=P&&v.call(t,'__wrapped__');if(C||D){var _=C?e.value():e,E=D?t.value():t;return m||(m=new r),g(_,E,n,y,m)}}return!!O&&(m||(m=new r),s(e,t,n,y,g,m))}},function(e,t,n){"use strict";var r='__lodash_hash_undefined__';e.exports=function(e){return this.__data__.set(e,r),this}},function(e,t,n){"use strict";e.exports=function(e){return this.__data__.has(e)}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},function(e,t,n){"use strict";var r=n(40),a=n(74),i=n(35),s=n(71),o=n(133),c=n(53),u=1,l=2,p='[object Boolean]',d='[object Date]',h='[object Error]',f='[object Map]',v='[object Number]',y='[object RegExp]',g='[object Set]',m='[object String]',b='[object Symbol]',w='[object ArrayBuffer]',k='[object DataView]',x=r?r.prototype:void 0,S=x?x.valueOf:void 0;e.exports=function(e,t,n,r,x,P,O){switch(n){case k:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!P(new a(e),new a(t)));case p:case d:case v:return i(+e,+t);case h:return e.name==t.name&&e.message==t.message;case y:case m:return e==t+'';case f:var C=o;case g:var D=r&u;if(C||(C=c),e.size!=t.size&&!D)return!1;var _=O.get(e);if(_)return _==t;r|=l,O.set(e,t);var E=s(C(e),C(t),r,x,P,O);return O.delete(e),E;case b:if(S)return S.call(e)==S.call(t)}return!1}},function(e,t,n){"use strict";e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},function(e,t,n){"use strict";var r=n(135),a=1,i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,s,o,c){var u=n&a,l=r(e),p=l.length;if(p!=r(t).length&&!u)return!1;for(var d=p;d--;){var h=l[d];if(!(u?h in t:i.call(t,h)))return!1}var f=c.get(e),v=c.get(t);if(f&&v)return f==t&&v==e;var y=!0;c.set(e,t),c.set(t,e);for(var g=u;++d<p;){var m=e[h=l[d]],b=t[h];if(s)var w=u?s(b,m,h,t,e,c):s(m,b,h,e,t,c);if(!(void 0===w?m===b||o(m,b,n,s,c):w)){y=!1;break}g||(g='constructor'==h)}if(y&&!g){var k=e.constructor,x=t.constructor;k!=x&&'constructor'in e&&'constructor'in t&&!('function'==typeof k&&k instanceof k&&'function'==typeof x&&x instanceof x)&&(y=!1)}return c.delete(e),c.delete(t),y}},function(e,t,n){"use strict";var r=n(136),a=n(138),i=n(54);e.exports=function(e){return r(e,i,a)}},function(e,t,n){"use strict";var r=n(137),a=n(23);e.exports=function(e,t,n){var i=t(e);return a(e)?i:r(i,n(e))}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];return e}},function(e,t,n){"use strict";var r=n(139),a=n(140),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(e){return null==e?[]:(e=Object(e),r(s(e),function(t){return i.call(e,t)}))}:a;e.exports=o},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=0,i=[];++n<r;){var s=e[n];t(s,n,e)&&(i[a++]=s)}return i}},function(e,t,n){"use strict";e.exports=function(){return[]}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},function(e,t,n){"use strict";var r=n(33),a=n(31),i='[object Arguments]';e.exports=function(e){return a(e)&&r(e)==i}},function(e,t,n){"use strict";e.exports=function(){return!1}},function(e,t,n){"use strict";var r=n(33),a=n(59),i=n(31),s={};s['[object Float32Array]']=s['[object Float64Array]']=s['[object Int8Array]']=s['[object Int16Array]']=s['[object Int32Array]']=s['[object Uint8Array]']=s['[object Uint8ClampedArray]']=s['[object Uint16Array]']=s['[object Uint32Array]']=!0,s['[object Arguments]']=s['[object Array]']=s['[object ArrayBuffer]']=s['[object Boolean]']=s['[object DataView]']=s['[object Date]']=s['[object Error]']=s['[object Function]']=s['[object Map]']=s['[object Number]']=s['[object Object]']=s['[object RegExp]']=s['[object Set]']=s['[object String]']=s['[object WeakMap]']=!1,e.exports=function(e){return i(e)&&a(e.length)&&!!s[r(e)]}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e(t)}}},function(e,t,n){"use strict";(function(e){var r=n(68),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a&&r.process,o=(function(){try{var e=i&&i.require&&i.require('util').types;return e||s&&s.binding&&s.binding('util')}catch(e){}})();e.exports=o}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(60),a=n(148),i=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return a(e);var t=[];for(var n in Object(e))i.call(e,n)&&'constructor'!=n&&t.push(n);return t}},function(e,t,n){"use strict";var r=n(76)(Object.keys,Object);e.exports=r},function(e,t,n){"use strict";var r=n(150),a=n(50),i=n(151),s=n(77),o=n(152),c=n(33),u=n(69),l=u(r),p=u(a),d=u(i),h=u(s),f=u(o),v=c;(r&&"[object DataView]"!=v(new r(new ArrayBuffer(1)))||a&&"[object Map]"!=v(new a)||i&&"[object Promise]"!=v(i.resolve())||s&&"[object Set]"!=v(new s)||o&&"[object WeakMap]"!=v(new o))&&(v=function(e){var t=c(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):'';if(r)switch(r){case l:return"[object DataView]";case p:return"[object Map]";case d:return"[object Promise]";case h:return"[object Set]";case f:return"[object WeakMap]"}return t}),e.exports=v},function(e,t,n){"use strict";var r=n(30)(n(24),'DataView');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'Promise');e.exports=r},function(e,t,n){"use strict";var r=n(30)(n(24),'WeakMap');e.exports=r},function(e,t,n){"use strict";var r=n(78),a=n(54);e.exports=function(e){for(var t=a(e),n=t.length;n--;){var i=t[n],s=e[i];t[n]=[i,s,r(s)]}return t}},function(e,t,n){"use strict";var r=n(70),a=n(155),i=n(162),s=n(63),o=n(78),c=n(79),u=n(37);e.exports=function(e,t){return s(e)&&o(t)?c(u(e),t):function(n){var s=a(n,e);return void 0===s&&s===t?i(n,e):r(t,s,3)}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e,t,n){var a=null==e?void 0:r(e,t);return void 0===a?n:a}},function(e,t,n){"use strict";var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/\\(\\)?/g,i=n(157)(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(''),e.replace(r,function(e,n,r,i){t.push(r?i.replace(a,'$1'):n||e)}),t});e.exports=i},function(e,t,n){"use strict";var r=n(158),a=500;e.exports=function(e){var t=r(e,function(e){return n.size===a&&n.clear(),e}),n=t.cache;return t}},function(e,t,n){"use strict";var r=n(52),a='Expected a function';function i(e,t){if('function'!=typeof e||null!=t&&'function'!=typeof t)throw new TypeError(a);var n=function n(){var r=arguments,a=t?t.apply(this,r):r[0],i=n.cache;if(i.has(a))return i.get(a);var s=e.apply(this,r);return n.cache=i.set(a,s)||i,s};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},function(e,t,n){"use strict";var r=n(160);e.exports=function(e){return null==e?'':r(e)}},function(e,t,n){"use strict";var r=n(40),a=n(161),i=n(23),s=n(44),o=r?r.prototype:void 0,c=o?o.toString:void 0;e.exports=function e(t){if('string'==typeof t)return t;if(i(t))return a(t,e)+'';if(s(t))return c?c.call(t):'';var n=t+'';return'0'==n&&1/t==-1/0?'-0':n}},function(e,t,n){"use strict";e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,a=Array(r);++n<r;)a[n]=t(e[n],n,e);return a}},function(e,t,n){"use strict";var r=n(163),a=n(164);e.exports=function(e,t){return null!=e&&a(e,t,r)}},function(e,t,n){"use strict";e.exports=function(e,t){return null!=e&&t in Object(e)}},function(e,t,n){"use strict";var r=n(62),a=n(55),i=n(23),s=n(43),o=n(59),c=n(37);e.exports=function(e,t,n){for(var u=-1,l=(t=r(t,e)).length,p=!1;++u<l;){var d=c(t[u]);if(!(p=null!=e&&n(e,d)))break;e=e[d]}return p||++u!=l?p:!!(l=null==e?0:e.length)&&o(l)&&s(d,l)&&(i(e)||a(e))}},function(e,t,n){"use strict";var r=n(166),a=n(167),i=n(63),s=n(37);e.exports=function(e){return i(e)?r(s(e)):a(e)}},function(e,t,n){"use strict";e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},function(e,t,n){"use strict";var r=n(61);e.exports=function(e){return function(t){return r(t,e)}}},function(e,t,n){"use strict";var r=n(169),a=n(43),i=Array.prototype.splice;e.exports=function(e,t){for(var n=e?t.length:0,s=n-1;n--;){var o=t[n];if(n==s||o!==c){var c=o;a(o)?i.call(e,o,1):r(e,o)}}return e}},function(e,t,n){"use strict";var r=n(62),a=n(170),i=n(171),s=n(37);e.exports=function(e,t){return t=r(t,e),null==(e=i(e,t))||delete e[s(a(t))]}},function(e,t,n){"use strict";e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},function(e,t,n){"use strict";var r=n(61),a=n(172);e.exports=function(e,t){return t.length<2?e:r(e,a(t,0,-1))}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(n=n>a?a:n)<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(a);++r<a;)i[r]=e[r+t];return i}},function(e,t,n){"use strict";var r=n(48),a=n(36),i=n(54);e.exports=function(e){return function(t,n,s){var o=Object(t);if(!a(t)){var c=r(n,3);t=i(t),n=function(e){return c(o[e],e,o)}}var u=e(t,n,s);return u>-1?o[c?t[u]:u]:void 0}}},function(e,t,n){"use strict";var r=n(80),a=n(48),i=n(175),s=Math.max;e.exports=function(e,t,n){var o=null==e?0:e.length;if(!o)return-1;var c=null==n?0:i(n);return c<0&&(c=s(o+c,0)),r(e,a(t,3),c)}},function(e,t,n){"use strict";var r=n(176);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},function(e,t,n){"use strict";var r=n(177),a=1/0,i=1.7976931348623157e308;e.exports=function(e){return e?(e=r(e))===a||e===-1/0?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}},function(e,t,n){"use strict";var r=n(26),a=n(44),i=NaN,s=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if('number'==typeof e)return e;if(a(e))return i;if(r(e)){var t='function'==typeof e.valueOf?e.valueOf():e;e=r(t)?t+'':t}if('string'!=typeof e)return 0===e?e:+e;e=e.replace(s,'');var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):o.test(e)?i:+e}},function(e,t,n){"use strict";var r=n(179)();e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return function(t,n,r){for(var a=-1,i=Object(t),s=r(t),o=s.length;o--;){var c=s[e?o:++a];if(!1===n(i[c],c,i))break}return t}}},function(e,t,n){"use strict";var r=n(82),a=n(181),i=n(182),s=n(184),o=n(185),c=n(55),u=n(23),l=n(187),p=n(56),d=n(51),h=n(26),f=n(188),v=n(58),y=n(85),g=n(189);e.exports=function(e,t,n,m,b,w,k){var x=y(e,n),S=y(t,n),P=k.get(S);if(P)r(e,n,P);else{var O=w?w(x,S,n+'',e,t,k):void 0,C=void 0===O;if(C){var D=u(S),_=!D&&p(S),E=!D&&!_&&v(S);O=S,D||_||E?u(x)?O=x:l(x)?O=s(x):_?(C=!1,O=a(S,!0)):E?(C=!1,O=i(S,!0)):O=[]:f(S)||c(S)?(O=x,c(x)?O=g(x):h(x)&&!d(x)||(O=o(S))):C=!1}C&&(k.set(S,O),b(O,S,m,w,k),k.delete(S)),r(e,n,O)}}},function(e,t,n){"use strict";(function(e){var r=n(24),a=t&&!t.nodeType&&t,i=a&&'object'==typeof e&&e&&!e.nodeType&&e,s=i&&i.exports===a?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}}).call(this,n(57)(e))},function(e,t,n){"use strict";var r=n(183);e.exports=function(e,t){var n=t?r(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}},function(e,t,n){"use strict";var r=n(74);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t,n){"use strict";e.exports=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}},function(e,t,n){"use strict";var r=n(186),a=n(84),i=n(60);e.exports=function(e){return'function'!=typeof e.constructor||i(e)?{}:r(a(e))}},function(e,t,n){"use strict";var r=n(26),a=Object.create,i=(function(){function e(){}return function(t){if(!r(t))return{};if(a)return a(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}})();e.exports=i},function(e,t,n){"use strict";var r=n(36),a=n(31);e.exports=function(e){return a(e)&&r(e)}},function(e,t,n){"use strict";var r=n(33),a=n(84),i=n(31),s='[object Object]',o=Function.prototype,c=Object.prototype,u=o.toString,l=c.hasOwnProperty,p=u.call(Object);e.exports=function(e){if(!i(e)||r(e)!=s)return!1;var t=a(e);if(null===t)return!0;var n=l.call(t,'constructor')&&t.constructor;return'function'==typeof n&&n instanceof n&&u.call(n)==p}},function(e,t,n){"use strict";var r=n(190),a=n(86);e.exports=function(e){return r(e,a(e))}},function(e,t,n){"use strict";var r=n(191),a=n(65);e.exports=function(e,t,n,i){var s=!n;n||(n={});for(var o=-1,c=t.length;++o<c;){var u=t[o],l=i?i(n[u],e[u],u,n,e):void 0;void 0===l&&(l=e[u]),s?a(n,u,l):r(n,u,l)}return n}},function(e,t,n){"use strict";var r=n(65),a=n(35),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n){var s=e[t];i.call(e,t)&&a(s,n)&&(void 0!==n||t in e)||r(e,t,n)}},function(e,t,n){"use strict";var r=n(26),a=n(60),i=n(193),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=a(e),n=[];for(var o in e)('constructor'!=o||!t&&s.call(e,o))&&n.push(o);return n}},function(e,t,n){"use strict";e.exports=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}},function(e,t,n){"use strict";var r=n(64),a=n(195),i=n(197);e.exports=function(e,t){return i(a(e,t,r),e+'')}},function(e,t,n){"use strict";var r=n(196),a=Math.max;e.exports=function(e,t,n){return t=a(void 0===t?e.length-1:t,0),function(){for(var i=arguments,s=-1,o=a(i.length-t,0),c=Array(o);++s<o;)c[s]=i[t+s];s=-1;for(var u=Array(t+1);++s<t;)u[s]=i[s];return u[t]=n(c),r(e,this,u)}}},function(e,t,n){"use strict";e.exports=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}},function(e,t,n){"use strict";var r=n(198),a=n(200)(r);e.exports=a},function(e,t,n){"use strict";var r=n(199),a=n(83),i=n(64),s=a?function(e,t){return a(e,'toString',{configurable:!0,enumerable:!1,value:r(t),writable:!0})}:i;e.exports=s},function(e,t,n){"use strict";e.exports=function(e){return function(){return e}}},function(e,t,n){"use strict";var r=800,a=16,i=Date.now;e.exports=function(e){var t=0,n=0;return function(){var s=i(),o=a-(s-n);if(n=s,o>0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){"use strict";var r=n(35),a=n(36),i=n(43),s=n(26);e.exports=function(e,t,n){if(!s(n))return!1;var o=typeof t;return!!('number'==o?a(n)&&i(t,n.length):'string'==o&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";var r=n(203);e.exports=function(e,t){return!(null==e||!e.length)&&r(e,t,0)>-1}},function(e,t,n){"use strict";var r=n(80),a=n(204),i=n(205);e.exports=function(e,t,n){return t==t?i(e,t,n):r(e,a,n)}},function(e,t,n){"use strict";e.exports=function(e){return e!=e}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=n-1,a=e.length;++r<a;)if(e[r]===t)return r;return-1}},function(e,t,n){"use strict";e.exports=function(e,t,n){for(var r=-1,a=null==e?0:e.length;++r<a;)if(n(t,e[r]))return!0;return!1}},function(e,t,n){"use strict";var r=n(77),a=n(208),i=n(53),s=r&&1/i(new r([,-0]))[1]==1/0?function(e){return new r(e)}:a;e.exports=s},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";(function(e,t){!(function(e,n){if(!e.setImmediate){var r,a,i,s,o,c=1,u={},l=!1,p=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){v(e)})}:!(function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}})()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){v(e.data)},r=function(e){i.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(a=p.documentElement,r=function(e){var t=p.createElement("script");t.onreadystatechange=function(){v(e),t.onreadystatechange=null,a.removeChild(t),t=null},a.appendChild(t)}):r=function(e){setTimeout(v,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&v(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),r=function(t){e.postMessage(s+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var a={callback:e,args:t};return u[c]=a,r(c),c++},d.clearImmediate=h}function h(e){delete u[e]}function f(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(n,r)}}function v(e){if(l)setTimeout(v,0,e);else{var t=u[e];if(t){l=!0;try{f(t)}finally{h(e),l=!1}}}}})("undefined"==typeof self?void 0===e?this:e:self)}).call(this,n(34),n(210))},function(e,t,n){"use strict";var r,a,i=e.exports={};function s(){throw new Error('setTimeout has not been defined')}function o(){throw new Error('clearTimeout has not been defined')}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(a===clearTimeout)return clearTimeout(e);if((a===o||!a)&&clearTimeout)return a=clearTimeout,clearTimeout(e);try{return a(e)}catch(t){try{return a.call(null,e)}catch(t){return a.call(this,e)}}}!(function(){try{r='function'==typeof setTimeout?setTimeout:s}catch(e){r=s}try{a='function'==typeof clearTimeout?clearTimeout:o}catch(e){a=o}})();var l,p=[],d=!1,h=-1;function f(){d&&l&&(d=!1,l.length?p=l.concat(p):h=-1,p.length&&v())}function v(){if(!d){var e=c(f);d=!0;for(var t=p.length;t;){for(l=p,p=[];++h<t;)l&&l[h].run();h=-1,t=p.length}l=null,d=!1,u(e)}}function y(e,t){this.fun=e,this.array=t}function g(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new y(e,t)),1!==p.length||d||c(v)},y.prototype.run=function(){this.fun.apply(null,this.array)},i.title='browser',i.browser=!0,i.env={},i.argv=[],i.version='',i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(e){return[]},i.binding=function(e){throw new Error('process.binding is not supported')},i.cwd=function(){return'/'},i.chdir=function(e){throw new Error('process.chdir is not supported')},i.umask=function(){return 0}},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(212),t),a(n(213),t),a(n(218),t),a(n(219),t),a(n(220),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContentType=void 0,(function(e){e.Any="*",e.Item="SF|Item",e.RootKey="SN|RootKey|NoSync",e.ItemsKey="SN|ItemsKey",e.EncryptedStorage="SN|EncryptedStorage",e.Privileges="SN|Privileges",e.Note="Note",e.Tag="Tag",e.SmartTag="SN|SmartTag",e.Component="SN|Component",e.Editor="SN|Editor",e.ActionsExtension="Extension",e.UserPrefs="SN|UserPreferences",e.HistorySession="SN|HistorySession",e.Theme="SN|Theme",e.ServerExtension="SF|Extension",e.FilesafeCredentials="SN|FileSafe|Credentials",e.FilesafeFileMetadata="SN|FileSafe|FileMetadata",e.FilesafeIntegration="SN|FileSafe|Integration",e.ExtensionRepo="SN|ExtensionRepo",e.Unknown="Unknown"})(t.ContentType||(t.ContentType={}))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.ContentDecoder=void 0;var n=(function(){function t(){v(this,t)}return y(t,[{key:"decode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;try{var r=n>0?t.substring(n):t,a=e.from(r,'base64').toString();return JSON.parse(a)}catch(e){return{}}}},{key:"encode",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=JSON.stringify(t),a=e.from(r).toString('base64');return a.padStart(a.length+n,'0')}}]),t})();t.ContentDecoder=n}).call(this,n(214).Buffer)},function(e,t,n){"use strict";(function(e){var r=n(215),a=n(216),i=n(217);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()<t)throw new RangeError('Invalid typed array length');return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,n){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,n);if('number'==typeof e){if('string'==typeof t)throw new Error('If encoding is specified then the first argument must be a string');return d(this,e)}return u(this,e,t,n)}function u(e,t,n,r){if('number'==typeof t)throw new TypeError('"value" argument must not be a number');return'undefined'!=typeof ArrayBuffer&&t instanceof ArrayBuffer?v(e,t,n,r):'string'==typeof t?h(e,t,n):y(e,t)}function l(e){if('number'!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function p(e,t,n,r){return l(t),t<=0?o(e,t):void 0!==n?'string'==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function d(e,t){if(l(t),e=o(e,t<0?0:0|g(t)),!c.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t,n){if('string'==typeof n&&''!==n||(n='utf8'),!c.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|m(t,n),a=(e=o(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}function f(e,t){var n=t.length<0?0:0|g(t.length);e=o(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function v(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError('\'offset\' is out of bounds');if(t.byteLength<n+(r||0))throw new RangeError('\'length\' is out of bounds');return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=f(e,t),e}function y(e,t){if(c.isBuffer(t)){var n=0|g(t.length);return 0===(e=o(e,n)).length?e:(t.copy(e,0,0,n),e)}if(t){if('undefined'!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||'length'in t)return'number'!=typeof t.length||(r=t.length)!=r?o(e,0):f(e,t);if('Buffer'===t.type&&i(t.data))return f(e,t.data)}var r;throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')}function g(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+' bytes');return 0|e}function m(e,t){if(c.isBuffer(e))return e.length;if('undefined'!=typeof ArrayBuffer&&'function'==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;'string'!=typeof e&&(e=''+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case'ascii':case'latin1':case'binary':return n;case'utf8':case'utf-8':case void 0:return G(e).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return 2*n;case'hex':return n>>>1;case'base64':return $(e).length;default:if(r)return G(e).length;t=(''+t).toLowerCase(),r=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return'';if((void 0===n||n>this.length)&&(n=this.length),n<=0)return'';if((n>>>=0)<=(t>>>=0))return'';for(e||(e='utf8');;)switch(e){case'hex':return T(this,t,n);case'utf8':case'utf-8':return R(this,t,n);case'ascii':return A(this,t,n);case'latin1':case'binary':return j(this,t,n);case'base64':return E(this,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return K(this,t,n);default:if(r)throw new TypeError('Unknown encoding: '+e);e=(e+'').toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,t,n,r,a){if(0===e.length)return-1;if('string'==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if('string'==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:x(e,t,n,r,a);if('number'==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&'function'==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):x(e,[t],n,r,a);throw new TypeError('val must be string, number or Buffer')}function x(e,t,n,r,a){var i,s=1,o=e.length,c=t.length;if(void 0!==r&&('ucs2'===(r=String(r).toLowerCase())||'ucs-2'===r||'utf16le'===r||'utf-16le'===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var l=-1;for(i=n;i<o;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>o&&(n=o-c),i=n;i>=0;i--){for(var p=!0,d=0;d<c;d++)if(u(e,i+d)!==u(t,d)){p=!1;break}if(p)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError('Invalid hex string');r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function P(e,t,n,r){return X(G(t,e.length-n),e,n,r)}function O(e,t,n,r){return X(Q(t),e,n,r)}function C(e,t,n,r){return O(e,t,n,r)}function D(e,t,n,r){return X($(t),e,n,r)}function _(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,c,u=e[a],l=null,p=u>239?4:u>223?3:u>191?2:1;if(a+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[a+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,p=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),a+=p}return M(r)}t.Buffer=c,t.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:(function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&'function'==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}})(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,n){return u(null,e,t,n)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,'undefined'!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,n){return p(null,e,t,n)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError('Arguments must be Buffers');if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case'hex':case'utf8':case'utf-8':case'ascii':case'latin1':case'binary':case'base64':case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return!0;default:return!1}},c.concat=function(e,t){if(!i(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=c.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var s=e[n];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,a),a+=s.length}return r},c.byteLength=m,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError('Buffer size must be a multiple of 16-bits');for(var t=0;t<e;t+=2)w(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError('Buffer size must be a multiple of 32-bits');for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError('Buffer size must be a multiple of 64-bits');for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?'':0===arguments.length?R(this,0,e):b.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e='',n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString('hex',0,n).match(/.{2}/g).join(' '),this.length>n&&(e+=' ... ')),'<Buffer '+e+'>'},c.prototype.compare=function(e,t,n,r,a){if(!c.isBuffer(e))throw new TypeError('Argument must be a Buffer');if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError('out of range index');if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,s=n-t,o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),p=0;p<o;++p)if(u[p]!==l[p]){i=u[p],s=l[p];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},c.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},c.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},c.prototype.write=function(e,t,n,r){if(void 0===t)r='utf8',n=this.length,t=0;else if(void 0===n&&'string'==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');t|=0,isFinite(n)?(n|=0,void 0===r&&(r='utf8')):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError('Attempt to write outside buffer bounds');r||(r='utf8');for(var i=!1;;)switch(r){case'hex':return S(this,e,t,n);case'utf8':case'utf-8':return P(this,e,t,n);case'ascii':return O(this,e,t,n);case'latin1':case'binary':return C(this,e,t,n);case'base64':return D(this,e,t,n);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return _(this,e,t,n);default:if(i)throw new TypeError('Unknown encoding: '+r);r=(''+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);for(var n='',r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=I));return n}function A(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function j(e,t,n){var r='';n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function T(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a='',i=t;i<n;++i)a+=Y(e[i]);return a}function K(e,t,n){for(var r=e.slice(t,n),a='',i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError('offset is not uint');if(e+t>n)throw new RangeError('Trying to access beyond buffer length')}function L(e,t,n,r,a,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError('Index out of range')}function U(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function V(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError('Index out of range');if(n<0)throw new RangeError('Index out of range')}function B(e,t,n,r,i){return i||V(e,0,n,4),a.write(e,t,n,r,23,4),n+4}function W(e,t,n,r,i){return i||V(e,0,n,8),a.write(e,t,n,r,52,8),n+8}c.prototype.slice=function(e,t){var n,r=this.length;if(e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=c.prototype;else{var a=t-e;n=new c(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},c.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},c.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},c.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},c.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},c.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||L(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},c.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);L(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},c.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):U(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):U(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,n){return B(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return B(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return W(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return W(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError('targetStart out of bounds');if(n<0||n>=this.length)throw new RangeError('sourceStart out of bounds');if(r<0)throw new RangeError('sourceEnd out of bounds');r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},c.prototype.fill=function(e,t,n,r){if('string'==typeof e){if('string'==typeof t?(r=t,t=0,n=this.length):'string'==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&'string'!=typeof r)throw new TypeError('encoding must be a string');if('string'==typeof r&&!c.isEncoding(r))throw new TypeError('Unknown encoding: '+r)}else'number'==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError('Out of range index');if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),'number'==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=c.isBuffer(e)?e:G(new c(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var H=/[^+\/0-9A-Za-z-_]/g;function z(e){if((e=q(e).replace(H,'')).length<2)return'';for(;e.length%4!=0;)e+='=';return e}function q(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,'')}function Y(e){return e<16?'0'+e.toString(16):e.toString(16)}function G(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error('Invalid code point');if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Q(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function J(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}function $(e){return r.toByteArray(z(e))}function X(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}}).call(this,n(34))},function(e,t,n){"use strict";t.byteLength=function(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=u(e),s=r[0],o=r[1],c=new i(l(e,s,o)),p=0,d=o>0?s-4:s;for(n=0;n<d;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],c[p++]=t>>16&255,c[p++]=t>>8&255,c[p++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,c[p++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,c[p++]=t>>8&255,c[p++]=255&t);return c},t.fromByteArray=function(e){for(var t,n=e.length,a=n%3,i=[],s=0,o=n-a;s<o;s+=16383)i.push(p(e,s,s+16383>o?o:s+16383));1===a?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+'==')):2===a&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+'='));return i.join('')};for(var r=[],a=[],i='undefined'!=typeof Uint8Array?Uint8Array:Array,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',o=0,c=s.length;o<c;++o)r[o]=s[o],a[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error('Invalid string. Length must be a multiple of 4');var n=e.indexOf('=');return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){return 3*(t+n)/4-n}function p(e,t,n){for(var a,i,s=[],o=t;o<n;o+=3)a=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),s.push(r[(i=a)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join('')}a['-'.charCodeAt(0)]=62,a['_'.charCodeAt(0)]=63},function(e,t,n){"use strict";t.read=function(e,t,n,r,a){var i,s,o=8*a-r-1,c=(1<<o)-1,u=c>>1,l=-7,p=n?a-1:0,d=n?-1:1,h=e[t+p];for(p+=d,i=h&(1<<-l)-1,h>>=-l,l+=o;l>0;i=256*i+e[t+p],p+=d,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+p],p+=d,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,r),i-=u}return(h?-1:1)*s*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var s,o,c,u=8*i-a-1,l=(1<<u)-1,p=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,f=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+p>=1?d/c:d*Math.pow(2,1-p))*c>=2&&(s++,c/=2),s+p>=l?(o=0,s=l):s+p>=1?(o=(t*c-1)*Math.pow(2,a),s+=p):(o=t*Math.pow(2,p-1)*Math.pow(2,a),s=0));a>=8;e[n+h]=255&o,h+=f,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[n+h]=255&s,h+=f,s/=256,u-=8);e[n+h-f]|=128*v}},function(e,t,n){"use strict";var r={}.toString;e.exports=Array.isArray||function(e){return'[object Array]'==r.call(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTag=void 0,(function(e){e.MfaInvalid="mfa-invalid",e.MfaRequired="mfa-required",e.RefreshTokenInvalid="invalid-refresh-token",e.RefreshTokenExpired="expired-refresh-token",e.AccessTokenExpired="expired-access-token",e.ParametersInvalid="invalid-parameters",e.RevokedSession="revoked-session",e.AuthInvalid="invalid-auth"})(t.ErrorTag||(t.ErrorTag={}))},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(222),t),a(n(90),t),a(n(223),t),a(n(225),t),a(n(93),t),a(n(91),t),a(n(92),t),a(n(226),t),a(n(227),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Features=void 0;for(var a,i=n(19),s=n(91),o=n(92),c=n(93),u=n(90),l=[],p=function(e){var t=e.identifier,n=e.permission_name,r=e.content_type,a=e.area,l=e.flags,p=Object.values(c.PermissionName),d=Object.values(u.FeatureIdentifier),h=Object.values(i.ContentType),f=Object.values(s.ComponentArea),v=Object.values(o.ComponentFlag);if(!d.includes(t))throw Error("Invalid feature identifier ".concat(t));if(!p.includes(n))throw Error("Invalid permission name ".concat(n));if(r&&!h.includes(r))throw Error("Invalid feature content type ".concat(r));if(a&&!f.includes(a))throw Error("Invalid feature area ".concat(a));if(l&&l.some(function(e){return!v.includes(e)}))throw Error("Invalid feature flag ".concat(l))},d=S(r(n(224)).default);!(a=d()).done;){var h=a.value;p(h),l.push(h)}t.Features=l},function(e){e.exports=JSON.parse("[{\"name\":\"Midnight\",\"identifier\":\"org.standardnotes.theme-midnight\",\"permission_name\":\"theme:midnight\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Elegant utilitarianism.\",\"url\":\"#{url_prefix}/themes/midnight\",\"download_url\":\"https://github.com/standardnotes/midnight-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/midnight\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#086DD6\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#086DD6\"}},{\"name\":\"Futura\",\"identifier\":\"org.standardnotes.theme-futura\",\"permission_name\":\"theme:futura\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Calm and relaxed. Take some time off.\",\"url\":\"#{url_prefix}/themes/futura\",\"download_url\":\"https://github.com/standardnotes/futura-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/futura\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#fca429\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#fca429\"}},{\"name\":\"Solarized Dark\",\"identifier\":\"org.standardnotes.theme-solarized-dark\",\"permission_name\":\"theme:solarized-dark\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.3\",\"description\":\"The perfect theme for any time.\",\"url\":\"#{url_prefix}/themes/solarized-dark\",\"download_url\":\"https://github.com/standardnotes/solarized-dark-theme/archive/1.2.3.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/solarized-dark\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#2AA198\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#2AA198\"}},{\"name\":\"Autobiography\",\"identifier\":\"org.standardnotes.theme-autobiography\",\"permission_name\":\"theme:autobiography\",\"content_type\":\"SN|Theme\",\"version\":\"1.0.1\",\"description\":\"A theme for writers and readers.\",\"url\":\"#{url_prefix}/themes/autobiography\",\"download_url\":\"https://github.com/standardnotes/autobiography-theme/archive/1.0.1.zip\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg\",\"flags\":[\"New\"],\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#9D7441\",\"foreground_color\":\"#ECE4DB\",\"border_color\":\"#9D7441\"}},{\"name\":\"Focus\",\"identifier\":\"org.standardnotes.theme-focus\",\"permission_name\":\"theme:focused\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.5\",\"description\":\"For when you need to go in.\",\"url\":\"#{url_prefix}/themes/focus\",\"download_url\":\"https://github.com/standardnotes/focus-theme/archive/1.2.5.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/focused\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#a464c2\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#a464c2\"}},{\"identifier\":\"org.standardnotes.theme-titanium\",\"permission_name\":\"theme:titanium\",\"name\":\"Titanium\",\"content_type\":\"SN|Theme\",\"version\":\"1.2.4\",\"description\":\"Light on the eyes, heavy on the spirit.\",\"url\":\"#{url_prefix}/themes/titanium\",\"download_url\":\"https://github.com/standardnotes/titanium-theme/archive/1.2.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/titanium\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg\",\"dock_icon\":{\"type\":\"circle\",\"background_color\":\"#6e2b9e\",\"foreground_color\":\"#ffffff\",\"border_color\":\"#6e2b9e\"}},{\"identifier\":\"org.standardnotes.theme-dynamic\",\"name\":\"Dynamic\",\"permission_name\":\"theme:dynamic\",\"content_type\":\"SN|Theme\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.0.0\",\"description\":\"A smart theme that minimizes the tags and notes panels when they are not in use.\",\"url\":\"#{url_prefix}/themes/dynamic\",\"download_url\":\"https://github.com/standardnotes/dynamic-theme/archive/1.0.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/dynamic\"},{\"identifier\":\"org.standardnotes.theme-no-distraction\",\"name\":\"No Distraction\",\"content_type\":\"SN|Theme\",\"permission_name\":\"theme:no-distraction\",\"layerable\":true,\"no_mobile\":true,\"version\":\"1.2.2\",\"description\":\"A theme for focusing on your writing.\",\"url\":\"#{url_prefix}/themes/no-distraction\",\"download_url\":\"https://github.com/standardnotes/no-distraction-theme/archive/1.2.2.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/no-distraction\",\"dock_icon\":{\"type\":\"svg\",\"source\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" viewBox=\\\"0 0 512 512\\\"><path d=\\\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\\\"/></svg>\"}},{\"name\":\"Bold Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.bold-editor\",\"permission_name\":\"editor:bold\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.2.9\",\"description\":\"A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.\",\"url\":\"#{url_prefix}/components/bold-editor\",\"marketing_url\":\"\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg\",\"download_url\":\"https://github.com/standardnotes/bold-editor/archive/1.2.9.zip\"},{\"name\":\"Plus Editor\",\"note_type\":\"rich-text\",\"file_type\":\"html\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.plus-editor\",\"permission_name\":\"editor:plus\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.5.0\",\"description\":\"From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.\",\"url\":\"#{url_prefix}/components/plus-editor\",\"download_url\":\"https://github.com/standardnotes/plus-editor/archive/1.5.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/plus-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg\"},{\"name\":\"Markdown Basic\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.simple-markdown-editor\",\"permission_name\":\"editor:markdown-basic\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A Markdown editor with dynamic split-pane preview.\",\"url\":\"#{url_prefix}/components/simple-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/markdown-basic/archive/1.4.0.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg\"},{\"name\":\"Markdown Pro\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.advanced-markdown-editor\",\"permission_name\":\"editor:markdown-pro\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.14\",\"description\":\"A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.\",\"url\":\"#{url_prefix}/components/advanced-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/advanced-markdown-editor/archive/1.3.14.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/advanced-markdown\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg\"},{\"name\":\"Markdown Minimist\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.minimal-markdown-editor\",\"permission_name\":\"editor:markdown-minimist\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F\",\"url\":\"#{url_prefix}/components/minimal-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/minimal-markdown-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/minimal-markdown-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg\"},{\"name\":\"Markdown Math\",\"note_type\":\"markdown\",\"file_type\":\"md\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.fancy-markdown-editor\",\"permission_name\":\"editor:markdown-math\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.4\",\"description\":\"A beautiful split-pane Markdown editor with synced-scroll, LaTeX support, and colorful syntax.\",\"url\":\"#{url_prefix}/components/fancy-markdown-editor\",\"download_url\":\"https://github.com/standardnotes/math-editor/archive/1.3.4.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/math-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg\"},{\"name\":\"Task Editor\",\"note_type\":\"task\",\"file_type\":\"md\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.simple-task-editor\",\"permission_name\":\"editor:task-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.7\",\"description\":\"A great way to manage short-term and long-term to-do\\\"s. You can mark tasks as completed, change their order, and edit the text naturally in place.\",\"url\":\"#{url_prefix}/components/simple-task-editor\",\"download_url\":\"https://github.com/standardnotes/simple-task-editor/archive/1.3.7.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/simple-task-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg\"},{\"name\":\"Code Editor\",\"note_type\":\"code\",\"file_type\":\"txt\",\"interchangeable\":true,\"identifier\":\"org.standardnotes.code-editor\",\"permission_name\":\"editor:code-editor\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.3.8\",\"description\":\"Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.\",\"url\":\"#{url_prefix}/components/code-editor\",\"download_url\":\"https://github.com/standardnotes/code-editor/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/code-editor\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg\"},{\"name\":\"TokenVault\",\"note_type\":\"authentication\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.token-vault\",\"permission_name\":\"editor:token-vault\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"2.0.6\",\"description\":\"Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.\",\"url\":\"#{url_prefix}/components/token-vault\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/token-vault/archive/2.0.6.zip\",\"thumbnail_url\":\"https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png\",\"flags\":[\"New\"]},{\"name\":\"Secure Spreadsheets\",\"note_type\":\"spreadsheet\",\"file_type\":\"json\",\"interchangeable\":false,\"identifier\":\"org.standardnotes.standard-sheets\",\"permission_name\":\"editor:sheets\",\"content_type\":\"SN|Component\",\"area\":\"editor-editor\",\"version\":\"1.4.0\",\"description\":\"A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.\",\"url\":\"#{url_prefix}/components/standard-sheets\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/secure-spreadsheets/archive/1.4.0.zip\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png\"},{\"identifier\":\"org.standardnotes.file-safe\",\"name\":\"FileSafe\",\"permission_name\":\"component:filesafe\",\"content_type\":\"SN|Component\",\"area\":\"editor-stack\",\"version\":\"2.0.10\",\"description\":\"Encrypted attachments for your notes using your Dropbox, Google Drive, or WebDAV server. Limited to 50MB per file.\",\"url\":\"#{url_prefix}/components/filesafe\",\"download_url\":\"https://github.com/standardnotes/filesafe-client/archive/2.0.10.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/filesafe\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/FileSafe-banner.png\"},{\"identifier\":\"org.standardnotes.folders\",\"name\":\"Folders\",\"content_type\":\"SN|Component\",\"permission_name\":\"component:folders\",\"area\":\"tags-list\",\"version\":\"1.3.8\",\"description\":\"Create nested folders with easy drag and drop.\",\"url\":\"#{url_prefix}/components/folders\",\"download_url\":\"https://github.com/standardnotes/folders-component/archive/1.3.8.zip\",\"marketing_url\":\"https://standardnotes.com/extensions/folders\",\"thumbnail_url\":\"https://s3.amazonaws.com/standard-notes/screenshots/models/components/folders.jpg\"},{\"name\":\"2FA Manager\",\"identifier\":\"org.standardnotes.mfa-link\",\"permission_name\":\"component:2fa-manager\",\"content_type\":\"SN|Component\",\"description\":\"Configure two-factor authentication to add an extra level of security to your account.\",\"version\":\"1.2.4\",\"url\":\"#{url_prefix}/components/mfa-link\",\"marketing_url\":\"\",\"download_url\":\"https://github.com/standardnotes/mfa-link/archive/1.2.4.zip\",\"area\":\"modal\",\"no_expire\":true,\"deletion_warning\":\"Deleting 2FA Manager will not disable 2FA from your account. To disable 2FA, first open 2FA Manager, then follow the prompts.\",\"deprecated\":true},{\"name\":\"\",\"identifier\":\"org.standardnotes.two-factor-auth\",\"permission_name\":\"server:two-factor-auth\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-unlimited\",\"permission_name\":\"server:note-history-unlimited\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-365\",\"permission_name\":\"server:note-history-365-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.note-history-30\",\"permission_name\":\"server:note-history-30-days\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-email-backup\",\"permission_name\":\"server:daily-email-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-dropbox-backup\",\"permission_name\":\"server:daily-dropbox-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-gdrive-backup\",\"permission_name\":\"server:daily-gdrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.daily-onedrive-backup\",\"permission_name\":\"server:daily-onedrive-backup\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-25-gb\",\"permission_name\":\"server:files-25-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files-5-gb\",\"permission_name\":\"server:files-5-gb\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Tag Nesting\",\"identifier\":\"org.standardnotes.tag-nesting\",\"permission_name\":\"app:tag-nesting\",\"description\":\"Create nested tags with easy drag and drop.\",\"version\":\"0.1.0\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"\",\"identifier\":\"org.standardnotes.files\",\"permission_name\":\"app:files\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"CloudLink\",\"identifier\":\"org.standardnotes.cloudlink\",\"permission_name\":\"component:cloud-link\",\"content_type\":\"SN|Component\",\"description\":\"Manage and install cloud backups, including Note History, Dropbox, Google Drive, OneDrive, and Daily Email Backups.\",\"version\":\"1.2.3\",\"url\":\"#{url_prefix}/components/cloudlink\",\"marketing_url\":\"\",\"download_url\":\"\",\"area\":\"modal\"},{\"name\":\"Listed Custom Domain\",\"identifier\":\"org.standardnotes.listed-custom-domain\",\"permission_name\":\"listed:custom-domain\",\"description\":\"\",\"version\":\"\",\"url\":\"\",\"marketing_url\":\"\",\"download_url\":\"\"},{\"name\":\"Focus Mode\",\"identifier\":\"org.standardnotes.focus-mode\",\"permission_name\":\"app:focus-mode\"}]")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NoteType=void 0,(function(e){e.Authentication="authentication",e.Code="code",e.Markdown="markdown",e.RichText="rich-text",e.Spreadsheet="spreadsheet",e.Task="task"})(t.NoteType||(t.NoteType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.timingSafeEqual=void 0,t.timingSafeEqual=function(e,t){var n=String(e),r=String(t),a=n.length,i=0;a!==r.length&&(r=n,i=1);for(var s=0;s<a;s++)i|=n.charCodeAt(s)^r.charCodeAt(s);return 0===i}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(232),t),a(n(233),t),a(n(234),t),a(n(235),t),a(n(236),t),a(n(237),t),a(n(238),t),a(n(239),t),a(n(240),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RoleName=void 0,(function(e){e.BasicUser="BASIC_USER",e.CoreUser="CORE_USER",e.PlusUser="PLUS_USER",e.ProUser="PRO_USER"})(t.RoleName||(t.RoleName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionName=void 0,(function(e){e.CorePlan="CORE_PLAN",e.PlusPlan="PLUS_PLAN",e.ProPlan="PRO_PLAN"})(t.SubscriptionName||(t.SubscriptionName={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),a(n(242),t),a(n(243),t),a(n(244),t),a(n(245),t)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EmailBackupFrequency=void 0,(function(e){e.Daily="daily",e.Weekly="weekly"})(t.EmailBackupFrequency||(t.EmailBackupFrequency={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedBackupsEmailsOption||(t.MuteFailedBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MuteFailedCloudBackupsEmailsOption=void 0,(function(e){e.Muted="muted",e.NotMuted="not_muted"})(t.MuteFailedCloudBackupsEmailsOption||(t.MuteFailedCloudBackupsEmailsOption={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingName=void 0,(function(e){e.MfaSecret="MFA_SECRET",e.ExtensionKey="EXTENSION_KEY",e.EmailBackup="EMAIL_BACKUP",e.MuteFailedBackupsEmails="MUTE_FAILED_BACKUPS_EMAILS",e.MuteFailedCloudBackupsEmails="MUTE_FAILED_CLOUD_BACKUPS_EMAILS"})(t.SettingName||(t.SettingName={}))},function(e,t,n){"use strict";var r;n.r(t),n.d(t,"SnjsVersion",function(){return h}),n.d(t,"isRightVersionGreaterThanLeft",function(){return x}),n.d(t,"compareSemVersions",function(){return P}),n.d(t,"SNApplicationGroup",function(){return M}),n.d(t,"DeinitSource",function(){return C}),n.d(t,"KeyParamsOrigination",function(){return A.g}),n.d(t,"KeyRecoveryStrings",function(){return j.H}),n.d(t,"SessionStrings",function(){return j.R}),n.d(t,"SNApplication",function(){return ca}),n.d(t,"SNProtocolService",function(){return Gn}),n.d(t,"KeyMode",function(){return Bn}),n.d(t,"SNProtocolOperator001",function(){return An}),n.d(t,"SNProtocolOperator002",function(){return Fn}),n.d(t,"SNProtocolOperator003",function(){return Ln}),n.d(t,"SNProtocolOperator004",function(){return Wn}),n.d(t,"SNRootKey",function(){return Ve}),n.d(t,"SNRootKeyParams",function(){return A.h}),n.d(t,"DeviceInterface",function(){return ua}),n.d(t,"SNItem",function(){return T.d}),n.d(t,"ItemMutator",function(){return T.b}),n.d(t,"AppDataField",function(){return T.a}),n.d(t,"SNItemsKey",function(){return J}),n.d(t,"SNPredicate",function(){return H.a}),n.d(t,"SNNote",function(){return le}),n.d(t,"NoteMutator",function(){return pe}),n.d(t,"SNTag",function(){return oe}),n.d(t,"TagMutator",function(){return ce}),n.d(t,"SNSmartTag",function(){return et}),n.d(t,"SNActionsExtension",function(){return ie}),n.d(t,"ActionsExtensionMutator",function(){return se}),n.d(t,"Action",function(){return ae}),n.d(t,"SNTheme",function(){return B}),n.d(t,"ThemeMutator",function(){return W}),n.d(t,"SNComponent",function(){return N}),n.d(t,"ComponentAction",function(){return E}),n.d(t,"ComponentMutator",function(){return V}),n.d(t,"SNEditor",function(){return Ze}),n.d(t,"SNUserPrefs",function(){return z}),n.d(t,"UserPrefsMutator",function(){return G}),n.d(t,"PrefKey",function(){return U}),n.d(t,"MutationType",function(){return T.c}),n.d(t,"ComponentArea",function(){return L.ComponentArea}),n.d(t,"LiveItem",function(){return la}),n.d(t,"FeatureStatus",function(){return ur}),n.d(t,"SNComponentManager",function(){return an}),n.d(t,"HistoryEntry",function(){return Qn}),n.d(t,"PayloadManager",function(){return sn}),n.d(t,"ItemManager",function(){return _r}),n.d(t,"SNHttpService",function(){return jt}),n.d(t,"ChallengeService",function(){return na}),n.d(t,"PureService",function(){return R.a}),n.d(t,"ApplicationService",function(){return pa.a}),n.d(t,"SNStorageService",function(){return Ie}),n.d(t,"StoragePersistencePolicies",function(){return Oe}),n.d(t,"StorageEncryptionPolicies",function(){return Ce}),n.d(t,"StorageValueModes",function(){return De}),n.d(t,"ValueModesKeys",function(){return _e}),n.d(t,"Challenge",function(){return ye}),n.d(t,"ChallengeReason",function(){return ne}),n.d(t,"ChallengeResponse",function(){return be}),n.d(t,"ChallengeValidation",function(){return te}),n.d(t,"ChallengeValue",function(){return me}),n.d(t,"ChallengePrompt",function(){return ge}),n.d(t,"SNSyncService",function(){return ea}),n.d(t,"SyncSources",function(){return $r}),n.d(t,"SyncModes",function(){return Jr}),n.d(t,"SyncQueueStrategy",function(){return Qr}),n.d(t,"SNCredentialService",function(){return Qe}),n.d(t,"SyncResponse",function(){return Br}),n.d(t,"SyncResponseResolver",function(){return Vr}),n.d(t,"SyncOpStatus",function(){return fr}),n.d(t,"SortPayloadsByRecentAndContentPriority",function(){return Mr}),n.d(t,"SyncUpDownLimit",function(){return Wr}),n.d(t,"SNSessionManager",function(){return Ge}),n.d(t,"SessionEvent",function(){return ze}),n.d(t,"SNMigrationService",function(){return En}),n.d(t,"ButtonType",function(){return St}),n.d(t,"SNHistoryManager",function(){return nr}),n.d(t,"SNProtectionService",function(){return ir}),n.d(t,"SNSingletonManager",function(){return cn}),n.d(t,"SNApiService",function(){return Yt}),n.d(t,"addIfUnique",function(){return _.b}),n.d(t,"arrayByDifference",function(){return _.c}),n.d(t,"Copy",function(){return _.a}),n.d(t,"dateSorted",function(){return _.j}),n.d(t,"deepMerge",function(){return _.m}),n.d(t,"dictToArray",function(){return _.n}),n.d(t,"extendArray",function(){return _.o}),n.d(t,"filterFromArray",function(){return _.p}),n.d(t,"findInArray",function(){return _.q}),n.d(t,"getGlobalScope",function(){return _.r}),n.d(t,"greaterOfTwoDates",function(){return _.s}),n.d(t,"isNullOrUndefined",function(){return _.w}),n.d(t,"isSameDay",function(){return _.z}),n.d(t,"jsonParseEmbeddedKeys",function(){return _.E}),n.d(t,"naturalSort",function(){return _.G}),n.d(t,"omitInPlace",function(){return _.J}),n.d(t,"omitUndefinedCopy",function(){return _.K}),n.d(t,"removeFromArray",function(){return _.M}),n.d(t,"removeFromIndex",function(){return _.N}),n.d(t,"subtractFromArray",function(){return _.R}),n.d(t,"topLevelCompare",function(){return _.S}),n.d(t,"truncateHexString",function(){return _.T}),n.d(t,"uniqueArrayByKey",function(){return _.W}),n.d(t,"uniqCombineObjArrays",function(){return _.U}),n.d(t,"convertTimestampToMilliseconds",function(){return _.i}),n.d(t,"arraysEqual",function(){return _.e}),n.d(t,"isValidUrl",function(){return _.B}),n.d(t,"dateToLocalizedString",function(){return _.k}),n.d(t,"Uuid",function(){return I}),n.d(t,"EncryptionIntent",function(){return Re.b}),n.d(t,"isLocalStorageIntent",function(){return Re.f}),n.d(t,"isFileIntent",function(){return Re.e}),n.d(t,"isDecryptedIntent",function(){return Re.d}),n.d(t,"intentRequiresEncryption",function(){return Re.c}),n.d(t,"ContentTypeUsesRootKeyEncryption",function(){return Re.a}),n.d(t,"ContentType",function(){return F.a}),n.d(t,"displayStringForContentType",function(){return F.c}),n.d(t,"CreateItemFromPayload",function(){return nt}),n.d(t,"Uuids",function(){return Ke.b}),n.d(t,"FillItemContent",function(){return Ke.a}),n.d(t,"ApplicationEvent",function(){return At.a}),n.d(t,"Environment",function(){return he}),n.d(t,"Platform",function(){return fe}),n.d(t,"isEnvironmentWebOrDesktop",function(){return Se}),n.d(t,"isEnvironmentMobile",function(){return Pe}),n.d(t,"platformFromString",function(){return ke}),n.d(t,"environmentFromString",function(){return xe}),n.d(t,"SyncEvent",function(){return on.a}),n.d(t,"MutableCollection",function(){return mt}),n.d(t,"ImmutablePayloadCollection",function(){return bt}),n.d(t,"ItemCollection",function(){return gn}),n.d(t,"CollectionSort",function(){return dn}),n.d(t,"CreateMaxPayloadFromAnyObject",function(){return Ee.e}),n.d(t,"CreateSourcedPayloadFromObject",function(){return Ee.f}),n.d(t,"CreateIntentPayloadFromObject",function(){return Ee.d}),n.d(t,"CreateEncryptionParameters",function(){return Ee.c}),n.d(t,"PayloadByMerging",function(){return Ee.g}),n.d(t,"CopyPayload",function(){return Ee.b}),n.d(t,"PayloadSource",function(){return ht.a}),n.d(t,"isPayloadSourceRetrieved",function(){return ht.c}),n.d(t,"isPayloadSourceInternalChange",function(){return ht.b}),n.d(t,"DeltaOutOfSync",function(){return _t}),n.d(t,"ProtocolVersion",function(){return Q.a}),n.d(t,"PayloadFormat",function(){return ue.a}),n.d(t,"PurePayload",function(){return ft.a}),n.d(t,"PayloadField",function(){return Je.a}),n.d(t,"NotesDisplayCriteria",function(){return br}),n.d(t,"notesMatchingCriteria",function(){return wr}),n.d(t,"StorageKey",function(){return o}),n.d(t,"RawStorageKey",function(){return s}),n.d(t,"NonwrappedStorageKey",function(){return c}),n.d(t,"namespacedKey",function(){return O}),n.d(t,"BaseMigration",function(){return _n}),n.d(t,"ProtectionSessionDurations",function(){return ar}),n.d(t,"SNLog",function(){return we.a}),n.d(t,"Features",function(){return L.Features}),n.d(t,"FeatureIdentifier",function(){return L.FeatureIdentifier}),n.d(t,"RoleName",function(){return sr.RoleName}),n.d(t,"SettingName",function(){return pr.SettingName}),n.d(t,"Migration2_20_0",function(){return Pn}),n.d(t,"ApplicationStage",function(){return ve});var a={};n.r(a),n.d(a,"Migration2_0_0",function(){return kn}),n.d(a,"Migration2_0_15",function(){return xn}),n.d(a,"Migration2_7_0",function(){return Sn}),n.d(a,"Migration2_20_0",function(){return Pn});var i={};n.r(i),n.d(i,"StorageReader2_0_0",function(){return On}),n.d(i,"StorageReader1_0_0",function(){return vn});var s,o,c,h="2.20.3";function x(e,t){return-1===P(e,t)}function P(e,t){for(var n=e.split('.'),r=t.split('.'),a=0;a<r.length;a++){var i=Number(~~r[a]),s=Number(~~n[a]);if(i>s)return-1;if(i<s)return 1}return 0}function O(e,t){return e?"".concat(e,"-").concat(t):t}!(function(e){e.StorageObject="storage",e.DescriptorRecord="descriptors",e.SnjsVersion="snjs_version"})(s||(s={})),(function(e){e.RootKeyParams="ROOT_KEY_PARAMS",e.WrappedRootKey="WRAPPED_ROOT_KEY",e.RootKeyWrapperKeyParams="ROOT_KEY_WRAPPER_KEY_PARAMS",e.Session="session",e.User="user",e.ServerHost="server",e.LegacyUuid="uuid",e.LastSyncToken="syncToken",e.PaginationToken="cursorToken",e.BiometricsState="biometrics_state",e.MobilePasscodeTiming="passcode_timing",e.MobileBiometricsTiming="biometrics_timing",e.MobilePasscodeKeyboardType="passcodeKeyboardType",e.MobilePreferences="preferences",e.MobileScreenshotPrivacyEnabled="screenshotPrivacy_enabled",e.ProtectionExpirey="SessionExpiresAtKey",e.ProtectionSessionLength="SessionLengthKey",e.SessionHistoryPersistable="sessionHistory_persist",e.SessionHistoryRevisions="sessionHistory_revisions",e.SessionHistoryOptimize="sessionHistory_autoOptimize",e.KeyRecoveryUndecryptableItems="key_recovery_undecryptable",e.StorageEncryptionPolicy="storage_policy",e.WebSocketUrl="webSocket_url",e.UserRoles="user_roles",e.UserFeatures="user_features"})(o||(o={})),(function(e){e.MobileFirstRun="first_run"})(c||(c={}));var C,D={WebPasscodeParamsKey:'offlineParams',MobilePasscodeParamsKey:'pc_params',AllAccountKeyParamsKey:'auth_params',WebEncryptedStorageKey:'encryptedStorage',MobileWrappedRootKeyKey:'encrypted_account_keys',MobileBiometricsPrefs:'biometrics_prefs',AllMigrations:'migrations',MobileThemesCache:'ThemePreferencesKey',MobileLightTheme:'lightTheme',MobileDarkTheme:'darkTheme',MobileLastExportDate:'LastExportDateKey',MobileDoNotWarnUnsupportedEditors:'DoNotShowAgainUnsupportedEditorsKey',MobileOptionsState:'options',MobilePasscodeKeyboardType:'passcodeKeyboardType'},_=n(0);!(function(e){e[e.SignOut=1]="SignOut",e[e.Lock=2]="Lock",e[e.AppGroupUnload=3]="AppGroupUnload"})(C||(C={}));var E,R=n(10),I=(function(){function e(){v(this,e)}return y(e,null,[{key:"SetGenerators",value:function(e,t){this.syncUuidFunc=t,this.asyncUuidFunc=e}},{key:"canGenSync",value:function(){return!Object(_.w)(this.syncUuidFunc)}},{key:"GenerateUuid",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.syncUuidFunc){e.next=4;break}return e.abrupt("return",this.syncUuidFunc());case 4:return e.abrupt("return",this.asyncUuidFunc());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"GenerateUuidSynchronously",value:function(){return this.syncUuidFunc()}}]),e})(),M=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).deviceInterface=e,r.changeObservers=[],r.applications=[],r.onApplicationDeinit=function(e,t){var n=t!==C.AppGroupUnload;if(r.primaryApplication===e&&(r.primaryApplication=void 0),Object(_.M)(r.applications,e),t===C.SignOut){if(r.removeDescriptor(r.descriptorForApplication(e)),n){var a=r.getDescriptors();return 0===a.length?r.addNewApplication():r.loadApplicationForDescriptor(a[0])}}else if(t===C.Lock&&n){var i=r.descriptorForApplication(e);return r.loadApplicationForDescriptor(i)}},r}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.deviceInterface.deinit(),this.deviceInterface=void 0}},{key:"initialize",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.callback=e,r.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(s.DescriptorRecord));case 3:if(this.descriptorRecord=r.sent,this.descriptorRecord){r.next=7;break}return r.next=7,b.awrap(this.createDescriptorRecord());case 7:if(t=this.findPrimaryDescriptor()){r.next=10;break}throw Error('No primary application descriptor found. Ensure migrations have been run.');case 10:n=this.buildApplication(t),this.applications.push(n),this.setPrimaryApplication(n,!1);case 13:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createDescriptorRecord",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:t=g({},e='standardnotes',{identifier:e,label:'Main Application',primary:!0}),this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(t)),this.descriptorRecord=t,this.persistDescriptors();case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getApplications",value:function(){return this.applications}},{key:"getDescriptors",value:function(){return Object.values(this.descriptorRecord)}},{key:"findPrimaryDescriptor",value:function(){for(var e,t=S(this.getDescriptors());!(e=t()).done;){var n=e.value;if(n.primary)return n}}},{key:"addApplicationChangeObserver",value:function(e){var t=this;return this.changeObservers.push(e),this.primaryApplication&&e(),function(){Object(_.M)(t.changeObservers,e)}}},{key:"notifyObserversOfAppChange",value:function(){for(var e,t=S(this.changeObservers);!(e=t()).done;){(0,e.value)()}}},{key:"setPrimaryApplication",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=!(r.length>1&&void 0!==r[1])||r[1],this.primaryApplication!==e){a.next=3;break}return a.abrupt("return");case 3:if(this.applications.includes(e)){a.next=5;break}throw Error('Application must be inserted before attempting to switch to it');case 5:if(this.primaryApplication&&this.primaryApplication.deinit(C.AppGroupUnload),this.primaryApplication=e,n=this.descriptorForApplication(e),this.setDescriptorAsPrimary(n),this.notifyObserversOfAppChange(),!t){a.next=13;break}return a.next=13,b.awrap(this.persistDescriptors());case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setDescriptorAsPrimary",value:function(e){for(var t,n=S(this.getDescriptors());!(t=n()).done;){var r=t.value;r.primary=r===e}}},{key:"persistDescriptors",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:this.deviceInterface.setRawStorageValue(s.DescriptorRecord,JSON.stringify(this.descriptorRecord));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"renameDescriptor",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e.label=t,n.next=3,b.awrap(this.persistDescriptors());case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"removeDescriptor",value:function(e){return delete this.descriptorRecord[e.identifier],this.persistDescriptors()}},{key:"descriptorForApplication",value:function(e){return this.descriptorRecord[e.identifier]}},{key:"addNewApplication",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(I.GenerateUuid());case 2:return t=i.sent,n=this.getDescriptors().length+1,r={identifier:t,label:e||"Application ".concat(n),primary:!1},a=this.buildApplication(r),this.applications.push(a),this.descriptorRecord[t]=r,i.next=10,b.awrap(this.setPrimaryApplication(a));case 10:return i.next=12,b.awrap(this.persistDescriptors());case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"applicationForDescriptor",value:function(e){return this.applications.find(function(t){return t.identifier===e.identifier})}},{key:"loadApplicationForDescriptor",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=this.applicationForDescriptor(e))||(t=this.buildApplication(e),this.applications.push(t)),n.next=4,b.awrap(this.setPrimaryApplication(t));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"buildApplication",value:function(e){var t=this.callback.applicationCreator(e,this.deviceInterface);return t.setOnDeinit(this.onApplicationDeinit),t}}]),n})(R.a),A=n(13),j=n(2),T=n(7),K=n(18),F=n(3),L=n(20);!(function(e){e.SetSize="set-size",e.StreamItems="stream-items",e.StreamContextItem="stream-context-item",e.SaveItems="save-items",e.SelectItem="select-item",e.AssociateItem="associate-item",e.DeassociateItem="deassociate-item",e.ClearSelection="clear-selection",e.CreateItem="create-item",e.CreateItems="create-items",e.DeleteItems="delete-items",e.SetComponentData="set-component-data",e.InstallLocalComponent="install-local-component",e.ToggleActivateComponent="toggle-activate-component",e.RequestPermissions="request-permissions",e.PresentConflictResolution="present-conflict-resolution",e.DuplicateItem="duplicate-item",e.ComponentRegistered="component-registered",e.ActivateThemes="themes",e.Reply="reply",e.SaveSuccess="save-success",e.SaveError="save-error",e.ThemesActivated="themes-activated",e.KeyDown="key-down",e.KeyUp="key-up",e.Click="click"})(E||(E={}));var U,N=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).permissions=[],r.componentData=r.payload.safeContent.componentData||{},Object(_.B)(r.payload.safeContent.hosted_url)?r.hosted_url=r.payload.safeContent.hosted_url:Object(_.B)(r.payload.safeContent.url)?r.hosted_url=r.payload.safeContent.url:Object(_.B)(r.payload.safeContent.legacy_url)&&(r.hosted_url=r.payload.safeContent.legacy_url),r.local_url=r.payload.safeContent.local_url,r.valid_until=new Date(r.payload.safeContent.valid_until||0),r.offlineOnly=r.payload.safeContent.offlineOnly,r.name=r.payload.safeContent.name,r.area=r.payload.safeContent.area,r.package_info=r.payload.safeContent.package_info||{},r.permissions=r.payload.safeContent.permissions||[],r.active=r.payload.safeContent.active,r.autoupdateDisabled=r.payload.safeContent.autoupdateDisabled,r.disassociatedItemIds=r.payload.safeContent.disassociatedItemIds||[],r.associatedItemIds=r.payload.safeContent.associatedItemIds||[],r.isMobileDefault=r.payload.safeContent.isMobileDefault,r.legacy_url=r.payload.safeContent.hosted_url?void 0:r.payload.safeContent.url,r}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"isEditor",value:function(){return this.area===L.ComponentArea.Editor}},{key:"isTheme",value:function(){return this.content_type===F.a.Theme||this.area===L.ComponentArea.Themes}},{key:"isDefaultEditor",value:function(){return!0===this.getAppDomainValue(T.a.DefaultEditor)}},{key:"getLastSize",value:function(){return this.getAppDomainValue(T.a.LastSize)}},{key:"acceptsThemes",value:function(){var e;return null===(e=this.payload.safeContent.package_info)||void 0===e?void 0:e.acceptsThemes}},{key:"getClientDataKey",value:function(){return this.legacy_url?this.legacy_url:this.uuid}},{key:"hasValidHostedUrl",value:function(){return void 0!=(this.hosted_url||this.legacy_url)}},{key:"contentKeysToIgnoreWhenCheckingEquality",value:function(){return['active','disassociatedItemIds','associatedItemIds'].concat(p(f(n.prototype),"contentKeysToIgnoreWhenCheckingEquality",this).call(this))}},{key:"isAssociative",value:function(){return n.associativeAreas().includes(this.area)}},{key:"isExplicitlyEnabledForItem",value:function(e){return-1!==this.associatedItemIds.indexOf(e)}},{key:"isExplicitlyDisabledForItem",value:function(e){return-1!==this.disassociatedItemIds.indexOf(e)}},{key:"isExpired",get:function(){return this.valid_until.getTime()>0&&this.valid_until<=new Date}},{key:"identifier",get:function(){return this.package_info.identifier}},{key:"isDeprecated",get:function(){var e,t=null!==(e=this.package_info.flags)&&void 0!==e?e:[];return(t=t.map(function(e){return e.toLowerCase()})).includes(L.ComponentFlag.Deprecated)}}],[{key:"associativeAreas",value:function(){return[L.ComponentArea.Editor]}}]),n})(T.d),V=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"associateWithItem",value:function(e){var t=this.typedContent.associatedItemIds||[];Object(_.b)(t,e),this.typedContent.associatedItemIds=t}},{key:"disassociateWithItem",value:function(e){var t=this.typedContent.disassociatedItemIds||[];Object(_.b)(t,e),this.typedContent.disassociatedItemIds=t}},{key:"removeAssociatedItemId",value:function(e){Object(_.M)(this.typedContent.associatedItemIds||[],e)}},{key:"removeDisassociatedItemId",value:function(e){Object(_.M)(this.typedContent.disassociatedItemIds||[],e)}},{key:"setLastSize",value:function(e){this.setAppDataItem(T.a.LastSize,e)}},{key:"typedContent",get:function(){return this.content}},{key:"active",set:function(e){this.typedContent.active=e}},{key:"isMobileDefault",set:function(e){this.typedContent.isMobileDefault=e}},{key:"defaultEditor",set:function(e){this.setAppDataItem(T.a.DefaultEditor,e)}},{key:"componentData",set:function(e){this.typedContent.componentData=e}},{key:"package_info",set:function(e){this.typedContent.package_info=e}},{key:"local_url",set:function(e){this.typedContent.local_url=e}},{key:"hosted_url",set:function(e){this.typedContent.hosted_url=e}},{key:"valid_until",set:function(e){this.typedContent.valid_until=e}},{key:"permissions",set:function(e){this.typedContent.permissions=e}}]),n})(T.b),B=(function(e){d(n,N);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).area=L.ComponentArea.Themes,e}return y(n,[{key:"isLayerable",value:function(){return this.package_info&&this.package_info.layerable}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"getMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)||{constants:{},rules:{}}}},{key:"hasMobileRules",value:function(){return this.getAppDomainValue(T.a.MobileRules)}},{key:"getNotAvailOnMobile",value:function(){return this.getAppDomainValue(T.a.NotAvailableOnMobile)}},{key:"isMobileActive",value:function(){return this.getAppDomainValue(T.a.MobileActive)}}]),n})(),W=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setMobileRules",value:function(e){this.setAppDataItem(T.a.MobileRules,e)}},{key:"setNotAvailOnMobile",value:function(e){this.setAppDataItem(T.a.NotAvailableOnMobile,e)}},{key:"setMobileActive",value:function(e){this.setAppDataItem(T.a.MobileActive,e)}},{key:"local_url",set:function(e){this.content.local_url=e}}]),n})(T.b),H=n(21);!(function(e){e.TagsPanelWidth="tagsPanelWidth",e.NotesPanelWidth="notesPanelWidth",e.EditorWidth="editorWidth",e.EditorLeft="editorLeft",e.EditorMonospaceEnabled="monospaceFont",e.EditorSpellcheck="spellcheck",e.EditorResizersEnabled="marginResizersEnabled",e.SortNotesBy="sortBy",e.SortNotesReverse="sortReverse",e.NotesShowArchived="showArchived",e.NotesShowTrashed="showTrashed",e.NotesHideProtected="hideProtected",e.NotesHidePinned="hidePinned",e.NotesHideNotePreview="hideNotePreview",e.NotesHideDate="hideDate",e.NotesHideTags="hideTags"})(U||(U={}));var z=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getPref",value:function(e){return this.getAppDomainValue(e)}},{key:"isSingleton",get:function(){return!0}},{key:"singletonPredicate",get:function(){return n.singletonPredicate}}]),n})(T.d);z.singletonPredicate=new H.a('content_type','=',F.a.UserPrefs);var q,Y,G=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"setPref",value:function(e,t){this.setAppDataItem(e,t)}}]),n})(T.b),Q=n(6),J=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}},{key:"keyVersion",get:function(){return this.payload.safeContent.version}},{key:"isItemsKey",get:function(){return!0}},{key:"isDefault",get:function(){return this.payload.safeContent.isDefault}},{key:"itemsKey",get:function(){return this.payload.safeContent.itemsKey}},{key:"dataAuthenticationKey",get:function(){if(this.keyVersion===Q.a.V004)throw'Attempting to access legacy data authentication key.';return this.payload.safeContent.dataAuthenticationKey}}]),n})(T.d),$=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"isDefault",set:function(e){this.content.isDefault=e}}]),n})(T.b),X=n(47),Z=n.n(X);!(function(e){e.Encrypted="encrypted",e.Decrypted="decrypted"})(q||(q={})),(function(e){e.Get="get",e.Render="render",e.Show="show",e.Post="post",e.Nested="nested"})(Y||(Y={}));var ee=Number.MIN_SAFE_INTEGER;var te,ne,re,ae=function e(t){var n,r,a;v(this,e),this.id=((ee+=1)===Number.MAX_SAFE_INTEGER&&(ee=Number.MIN_SAFE_INTEGER),ee),Z()(this,t),this.running=null!==(n=t.running)&&void 0!==n&&n,this.error=null!==(r=t.error)&&void 0!==r&&r,this.lastExecuted&&(this.lastExecuted=new Date(this.lastExecuted)),this.subactions=null===(a=t.subactions)||void 0===a?void 0:a.map(function(t){return new e(t)})},ie=(function(e){d(n,N);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).actions=[],r.description=e.safeContent.description,r.url=e.safeContent.hosted_url||e.safeContent.url,r.supported_types=e.safeContent.supported_types,r.deprecation=e.safeContent.deprecation,e.safeContent.actions&&(r.actions=e.safeContent.actions.map(function(e){return new ae(e)})),r}return y(n,[{key:"actionsWithContextForItem",value:function(e){return this.actions.filter(function(t){return t.context===e.content_type||'Item'===t.context})}},{key:"strategyWhenConflictingWithItem",value:function(e,t){return this.errorDecrypting?p(f(n.prototype),"strategyWhenConflictingWithItem",this).call(this,e,t):K.a.KeepLeft}}]),n})(),se=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"description",set:function(e){this.content.description=e}},{key:"supported_types",set:function(e){this.content.supported_types=e}},{key:"actions",set:function(e){this.content.actions=e}},{key:"deprecation",set:function(e){this.content.deprecation=e}}]),n})(T.b),oe=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).title=r.payload.safeContent.title,r}return y(n,[{key:"noteReferences",get:function(){return this.payload.safeReferences.filter(function(e){return e.content_type===F.a.Note})}},{key:"noteCount",get:function(){return this.noteReferences.length}},{key:"isSmartTag",get:function(){return this.content_type===F.a.SmartTag}},{key:"isSystemSmartTag",get:function(){return this.payload.safeContent.isSystemTag}},{key:"isAllTag",get:function(){return this.payload.safeContent.isAllTag}},{key:"isTrashTag",get:function(){return this.payload.safeContent.isTrashTag}},{key:"isArchiveTag",get:function(){return this.payload.safeContent.isArchiveTag}},{key:"parentId",get:function(){var e=this.payload.safeContent.references.find(function(e){return e.content_type===F.a.Tag});return null===e||void 0===e?void 0:e.uuid}}],[{key:"arrayToDisplayString",value:function(e){return e.sort(function(e,t){return e.title>t.title?1:-1}).map(function(e){return'#'+e.title}).join(' ')}}]),n})(T.d),ce=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"makeChildOf",value:function(e){var t=this.typedContent.references.filter(function(e){return e.content_type!==F.a.Tag});t.push({content_type:F.a.Tag,uuid:e.uuid}),this.typedContent.references=t}},{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}}]),n})(T.b),ue=n(12),le=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).text='',r.hidePreview=!1,r.title=r.payload.safeContent.title,r.text=r.payload.safeContent.text,r.preview_plain=r.payload.safeContent.preview_plain,r.preview_html=r.payload.safeContent.preview_html,r.hidePreview=r.payload.safeContent.hidePreview,e.format===ue.a.DecryptedBareObject&&(r.prefersPlainEditor=r.getAppDomainValue(T.a.PrefersPlainEditor)),Object(_.w)(r.payload.safeContent.mobilePrefersPlainEditor)||(r.mobilePrefersPlainEditor=r.payload.safeContent.mobilePrefersPlainEditor),r}return y(n,[{key:"safeText",value:function(){return this.text||''}},{key:"safeTitle",value:function(){return this.title||''}}]),n})(T.d),pe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"typedContent",get:function(){return this.content}},{key:"title",set:function(e){this.typedContent.title=e}},{key:"text",set:function(e){this.typedContent.text=e}},{key:"hidePreview",set:function(e){this.typedContent.hidePreview=e}},{key:"preview_plain",set:function(e){this.typedContent.preview_plain=e}},{key:"preview_html",set:function(e){this.typedContent.preview_html=e}},{key:"prefersPlainEditor",set:function(e){this.setAppDataItem(T.a.PrefersPlainEditor,e)}}]),n})(T.b);function de(e,t){switch(e.content_type){case F.a.Note:return new pe(e,t);case F.a.Tag:return new ce(e,t);case F.a.Component:return new V(e,t);case F.a.ActionsExtension:return new se(e,t);case F.a.ItemsKey:return new $(e,t);case F.a.UserPrefs:return new G(e,t);case F.a.Theme:return new W(e,t);default:return new T.b(e,t)}}!(function(e){e[e.None=0]="None",e[e.LocalPasscode=1]="LocalPasscode",e[e.AccountPassword=2]="AccountPassword",e[e.Biometric=3]="Biometric",e[e.ProtectionSessionDuration=4]="ProtectionSessionDuration"})(te||(te={})),(function(e){e[e.ApplicationUnlock=1]="ApplicationUnlock",e[e.ResaveRootKey=2]="ResaveRootKey",e[e.ProtocolUpgrade=3]="ProtocolUpgrade",e[e.Migration=4]="Migration",e[e.Custom=5]="Custom",e[e.AccessProtectedNote=6]="AccessProtectedNote",e[e.ImportFile=7]="ImportFile",e[e.AddPasscode=8]="AddPasscode",e[e.RemovePasscode=9]="RemovePasscode",e[e.ChangePasscode=10]="ChangePasscode",e[e.ChangeAutolockInterval=11]="ChangeAutolockInterval",e[e.CreateDecryptedBackupWithProtectedItems=12]="CreateDecryptedBackupWithProtectedItems",e[e.RevokeSession=13]="RevokeSession",e[e.AccessCloudLink=14]="AccessCloudLink",e[e.DecryptEncryptedFile=15]="DecryptEncryptedFile",e[e.ExportBackup=16]="ExportBackup",e[e.DisableBiometrics=17]="DisableBiometrics",e[e.UnprotectNote=18]="UnprotectNote",e[e.SearchProtectedNotesText=19]="SearchProtectedNotesText",e[e.SelectProtectedNote=20]="SelectProtectedNote",e[e.DisableMfa=21]="DisableMfa"})(ne||(ne={})),(function(e){e.Alphanumeric="default",e.Numeric="numeric"})(re||(re={}));var he,fe,ve,ye=(function(){function e(t,n,r,a,i){v(this,e),this.prompts=t,this.reason=n,this.cancelable=r,this._heading=a,this._subheading=i,this.id=Math.random(),Object.freeze(this)}return y(e,[{key:"hasPromptForValidationType",value:function(e){for(var t,n=S(this.prompts);!(t=n()).done;){if(t.value.validation===e)return!0}return!1}},{key:"modalTitle",get:function(){switch(this.reason){case ne.Migration:return j.w.Migration;default:return j.w.Generic}}},{key:"heading",get:function(){if(this._heading)return this._heading;switch(this.reason){case ne.ApplicationUnlock:return j.x.UnlockApplication;case ne.Migration:return j.x.EnterLocalPasscode;case ne.ResaveRootKey:return j.x.EnterPasscodeForRootResave;case ne.ProtocolUpgrade:return j.x.EnterCredentialsForProtocolUpgrade;case ne.AccessProtectedNote:return j.x.NoteAccess;case ne.ImportFile:return j.x.ImportFile;case ne.AddPasscode:return j.x.AddPasscode;case ne.RemovePasscode:return j.x.RemovePasscode;case ne.ChangePasscode:return j.x.ChangePasscode;case ne.ChangeAutolockInterval:return j.x.ChangeAutolockInterval;case ne.CreateDecryptedBackupWithProtectedItems:return j.x.EnterCredentialsForDecryptedBackupDownload;case ne.RevokeSession:return j.x.RevokeSession;case ne.AccessCloudLink:return j.x.AccessCloudLink;case ne.DecryptEncryptedFile:return j.x.DecryptEncryptedFile;case ne.ExportBackup:return j.x.ExportBackup;case ne.DisableBiometrics:return j.x.DisableBiometrics;case ne.UnprotectNote:return j.x.UnprotectNote;case ne.SearchProtectedNotesText:return j.x.SearchProtectedNotesText;case ne.SelectProtectedNote:return j.x.SelectProtectedNote;case ne.DisableMfa:return j.x.DisableMfa;case ne.Custom:return'';default:return Object(_.f)(this.reason)}}},{key:"subheading",get:function(){if(this._subheading)return this._subheading;switch(this.reason){case ne.Migration:return j.x.EnterPasscodeForMigration;default:return}}}]),e})(),ge=function e(t,n,r){v(this,e);var a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;switch(this.validation=t,this.secureTextEntry=a,this.keyboardType=i,this.initialValue=s,this.id=Math.random(),this.validation){case te.AccountPassword:this.title=null!==n&&void 0!==n?n:j.M.AccountPassword,this.placeholder=null!==r&&void 0!==r?r:j.M.AccountPassword,this.validates=!0;break;case te.LocalPasscode:this.title=null!==n&&void 0!==n?n:j.M.LocalPasscode,this.placeholder=null!==r&&void 0!==r?r:j.M.LocalPasscode,this.validates=!0;break;case te.Biometric:this.title=null!==n&&void 0!==n?n:j.M.Biometrics,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.ProtectionSessionDuration:this.title=null!==n&&void 0!==n?n:j.M.RememberFor,this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!0;break;case te.None:this.title=null!==n&&void 0!==n?n:'',this.placeholder=null!==r&&void 0!==r?r:'',this.validates=!1;break;default:Object(_.f)(this.validation)}Object.freeze(this)},me=function e(t,n){v(this,e),this.prompt=t,this.value=n,Object.freeze(this)},be=(function(){function e(t,n,r){v(this,e),this.challenge=t,this.values=n,this.artifacts=r,Object.freeze(this)}return y(e,[{key:"getValueForType",value:function(e){var t=this.values.find(function(t){return t.prompt.validation===e});if(Object(_.w)(t))throw Error('Could not find value for validation type '+e);return t}},{key:"getDefaultValue",value:function(){if(this.values.length>1)throw Error('Attempting to retrieve default response value when more than one value exists');return this.values[0]}}]),e})(),we=n(16);function ke(e){return{'mac-web':fe.MacWeb,'mac-desktop':fe.MacDesktop,'linux-web':fe.LinuxWeb,'linux-desktop':fe.LinuxDesktop,'windows-web':fe.WindowsWeb,'windows-desktop':fe.WindowsDesktop,ios:fe.Ios,android:fe.Android}[e]}function xe(e){return{web:he.Web,desktop:he.Desktop,mobile:he.Mobile}[e]}function Se(e){return e===he.Web||e===he.Desktop}function Pe(e){return e===he.Mobile}!(function(e){e[e.Web=1]="Web",e[e.Desktop=2]="Desktop",e[e.Mobile=3]="Mobile"})(he||(he={})),(function(e){e[e.Ios=1]="Ios",e[e.Android=2]="Android",e[e.MacWeb=3]="MacWeb",e[e.MacDesktop=4]="MacDesktop",e[e.WindowsWeb=5]="WindowsWeb",e[e.WindowsDesktop=6]="WindowsDesktop",e[e.LinuxWeb=7]="LinuxWeb",e[e.LinuxDesktop=8]="LinuxDesktop"})(fe||(fe={})),(function(e){e[e.PreparingForLaunch_0=0]="PreparingForLaunch_0",e[e.ReadyForLaunch_05=.5]="ReadyForLaunch_05",e[e.StorageDecrypted_09=.9]="StorageDecrypted_09",e[e.Launched_10=1]="Launched_10",e[e.LoadingDatabase_11=1.1]="LoadingDatabase_11",e[e.LoadedDatabase_12=1.2]="LoadedDatabase_12",e[e.FullSyncCompleted_13=1.3]="FullSyncCompleted_13",e[e.SignedIn_30=3]="SignedIn_30"})(ve||(ve={}));var Oe,Ce,De,_e,Ee=n(1),Re=n(8);!(function(e){e[e.Default=1]="Default",e[e.Ephemeral=2]="Ephemeral"})(Oe||(Oe={})),(function(e){e[e.Default=1]="Default",e[e.Disabled=2]="Disabled"})(Ce||(Ce={})),(function(e){e[e.Default=1]="Default",e[e.Nonwrapped=2]="Nonwrapped"})(De||(De={})),(function(e){e.Wrapped="wrapped",e.Unwrapped="unwrapped",e.Nonwrapped="nonwrapped"})(_e||(_e={}));var Ie=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).alertService=r,s.identifier=a,s.environment=i,s.storagePersistable=!1,s.needsPersist=!1,s.deviceInterface=e,s.setPersistencePolicy(Oe.Default),s.setEncryptionPolicy(Ce.Default,!1),s}return y(n,[{key:"deinit",value:function(){this.deviceInterface=void 0,this.encryptionDelegate=void 0,this.storagePersistable=!1,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:if(e!==ve.Launched_10){r.next=7;break}this.storagePersistable=!0,this.needsPersist&&this.persistValuesToDisk(),r.next=12;break;case 7:if(e!==ve.StorageDecrypted_09){r.next=12;break}return r.next=10,b.awrap(this.getValue(o.StorageEncryptionPolicy));case 10:(t=r.sent)&&this.setEncryptionPolicy(t,!1);case 12:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setPersistencePolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.persistencePolicy=e,this.persistencePolicy!==Oe.Ephemeral){t.next=6;break}return t.next=4,b.awrap(this.deviceInterface.removeAllRawStorageValues());case 4:return t.next=6,b.awrap(this.clearAllPayloads());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setEncryptionPolicy",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],e!==Ce.Disabled||this.environment===he.Mobile){r.next=3;break}throw Error('Disabling storage encryption is only available on mobile.');case 3:if(this.encryptionPolicy=e,!t){r.next=7;break}return r.next=7,b.awrap(this.setValue(o.StorageEncryptionPolicy,e));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.persistencePolicy===Oe.Ephemeral}},{key:"initializeFromDisk",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getRawStorageValue(this.getPersistenceKey()));case 2:e=n.sent,t=e?JSON.parse(e):void 0,this.setInitialValues(t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setInitialValues",value:function(e){e||(e=this.defaultValuesObject()),e[_e.Unwrapped]||(e[_e.Unwrapped]={}),this.values=e}},{key:"isStorageWrapped",value:function(){var e=this.values[_e.Wrapped];return!Object(_.w)(e)&&Object.keys(e).length>0}},{key:"canDecryptWithKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.values[_e.Wrapped],r.next=3,b.awrap(this.decryptWrappedValue(t,e));case 3:return n=r.sent,r.abrupt("return",!n.errorDecrypting);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"decryptWrappedValue",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(null!==e&&void 0!==e&&e.content_type){a.next=2;break}throw Error('Attempting to decrypt nonexistent wrapped value');case 2:return n=Object(Ee.e)(e,{content_type:F.a.EncryptedStorage}),a.next=5,b.awrap(this.encryptionDelegate.payloadByDecryptingPayload(n,t));case 5:return r=a.sent,a.abrupt("return",r);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptStorage",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.values[_e.Wrapped],n.next=3,b.awrap(this.decryptWrappedValue(e));case 3:if(!(t=n.sent).errorDecrypting){n.next=6;break}throw we.a.error(Error('Unable to decrypt storage.'));case 6:this.values[_e.Unwrapped]=Object(_.a)(t.contentObject);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistValuesToDisk",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.storagePersistable){t.next=3;break}return this.needsPersist=!0,t.abrupt("return");case 3:if(this.persistencePolicy!==Oe.Ephemeral){t.next=5;break}return t.abrupt("return");case 5:return this.needsPersist=!1,t.next=8,b.awrap(this.immediatelyPersistValuesToDisk());case 8:e=t.sent,this.values[_e.Wrapped]=e[_e.Wrapped];case 10:case"end":return t.stop()}},null,this,null,Promise)}},{key:"immediatelyPersistValuesToDisk",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(e.generatePersistableValues());case 2:return n=r.sent,r.next=5,b.awrap(null===(t=e.deviceInterface)||void 0===t?void 0:t.setRawStorageValue(e.getPersistenceKey(),JSON.stringify(n)));case 5:return r.abrupt("return",n);case 6:case"end":return r.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generatePersistableValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=w({},this.values),n=t[_e.Unwrapped],i.t0=Object(Ee.e),i.next=5,b.awrap(I.GenerateUuid());case 5:return i.t1=i.sent,i.t2=n,i.t3=F.a.EncryptedStorage,i.t4={uuid:i.t1,content:i.t2,content_type:i.t3},r=(0,i.t0)(i.t4),i.next=12,b.awrap(null===(e=this.encryptionDelegate)||void 0===e?void 0:e.payloadByEncryptingPayload(r,Re.b.LocalStoragePreferEncrypted));case 12:return(a=i.sent)&&(t[_e.Wrapped]=a.ejected(),t[_e.Unwrapped]=void 0),i.abrupt("return",t);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=r.length>2&&void 0!==r[2]?r[2]:De.Default,this.values){a.next=3;break}throw Error("Attempting to set storage key ".concat(e," before loading local storage."));case 3:return this.values[this.domainKeyForMode(n)][e]=t,a.abrupt("return",this.persistValuesToDisk());case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:De.Default,n=arguments.length>2?arguments[2]:void 0;if(!this.values)throw Error("Attempting to get storage key ".concat(e," before loading local storage."));if(!this.values[this.domainKeyForMode(t)])throw Error("Storage domain mode not available ".concat(t," for key ").concat(e));var r=this.values[this.domainKeyForMode(t)][e];return Object(_.w)(r)?n:r}},{key:"removeValue",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:De.Default,this.values){a.next=3;break}throw Error("Attempting to remove storage key ".concat(e," before loading local storage."));case 3:if(null===(n=this.values[this.domainKeyForMode(t)])||void 0===n||!n[e]){a.next=7;break}return delete n[e],a.abrupt("return",this.persistValuesToDisk());case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.encryptionPolicy}},{key:"getPersistenceKey",value:function(){return O(this.identifier,s.StorageObject)}},{key:"defaultValuesObject",value:function(e,t,r){return n.defaultValuesObject(e,t,r)}},{key:"domainKeyForMode",value:function(e){if(e===De.Default)return _e.Unwrapped;if(e===De.Nonwrapped)return _e.Nonwrapped;throw Error('Invalid mode')}},{key:"clearValues",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.setInitialValues(),e.next=3,b.awrap(this.immediatelyPersistValuesToDisk());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAllRawPayloads",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getAllRawDatabasePayloads(this.identifier));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"savePayload",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.savePayloads([e]));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"savePayloads",value:function(e){var t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.persistencePolicy!==Oe.Ephemeral){o.next=2;break}return o.abrupt("return");case 2:t=[],n=S(e);case 4:if((r=n()).done){o.next=19;break}if(!(a=r.value).discardable){o.next=11;break}return o.next=9,b.awrap(this.deletePayloadWithId(a.uuid));case 9:o.next=17;break;case 11:if(a.uuid){o.next=13;break}throw Error('Attempting to persist payload with no uuid');case 13:return o.next=15,b.awrap(this.encryptionDelegate.payloadByEncryptingPayload(a,this.encryptionPolicy===Ce.Default?Re.b.LocalStoragePreferEncrypted:Re.b.LocalStorageDecrypted));case 15:i=o.sent,t.push(i.ejected());case 17:o.next=4;break;case 19:return o.abrupt("return",this.executeCriticalFunction(function(){var e;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",null===(e=s.deviceInterface)||void 0===e?void 0:e.saveRawDatabasePayloads(t,s.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 20:case"end":return o.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(e);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(this.deletePayloadWithId(r.uuid));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deletePayloadWithId",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.deviceInterface.removeRawDatabasePayloadWithId(e,t.identifier));case 1:case"end":return n.stop()}},null,null,null,Promise)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"clearAllPayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.deviceInterface.removeAllRawDatabasePayloads(e.identifier));case 1:case"end":return t.stop()}},null,null,null,Promise)}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"clearAllData",value:function(){var e=this;return this.executeCriticalFunction(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.clearValues());case 2:return t.next=4,b.awrap(e.clearAllPayloads());case 4:return t.next=6,b.awrap(e.deviceInterface.removeRawStorageValue(O(e.identifier,s.SnjsVersion)));case 6:return t.next=8,b.awrap(e.deviceInterface.removeRawStorageValue(e.getPersistenceKey()));case 8:case"end":return t.stop()}},null,null,null,Promise)})}}],[{key:"defaultValuesObject",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return g(e={},_e.Wrapped,t),g(e,_e.Unwrapped,n),g(e,_e.Nonwrapped,r),e}}]),n})(R.a),Me=(function(){function e(){v(this,e)}return y(e,null,[{key:"FromRawStorageValue",value:function(e){if(e.jwt)return new Ae(e.jwt);var t=e;return new je(t.accessToken,t.accessExpiration,t.refreshToken,t.refreshExpiration)}}]),e})(),Ae=(function(e){d(n,Me);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).jwt=e,r}return y(n,[{key:"canExpire",value:function(){return!1}},{key:"authorizationValue",get:function(){return this.jwt}}]),n})(),je=(function(e){d(n,Me);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).accessToken=e,s.accessExpiration=r,s.refreshToken=a,s.refreshExpiration=i,s}return y(n,[{key:"getExpireAt",value:function(){return this.accessExpiration||0}},{key:"canExpire",value:function(){return!0}},{key:"isExpired",value:function(){return this.getExpireAt()<Date.now()}},{key:"authorizationValue",get:function(){return this.accessToken}}],[{key:"FromApiResponse",value:function(e){var t=e.data.session.access_token,r=e.data.session.refresh_token;return new n(t,e.data.session.access_expiration,r,e.data.session.refresh_expiration)}}]),n})(),Te=n(15),Ke=n(11),Fe=n(67);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ve=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this,e)).keyParams=r,a}return y(n,[{key:"compare",value:function(e){if(this.keyVersion!==e.keyVersion)return!1;var t=!(!this.serverPassword||!e.serverPassword);return Object(Fe.timingSafeEqual)(this.masterKey,e.masterKey)&&(!t||Object(Fe.timingSafeEqual)(this.serverPassword,e.serverPassword))}},{key:"persistableValueWhenWrapping",value:function(){var e=this.getKeychainValue();return e.keyParams=this.keyParams.getPortableValue(),e}},{key:"getKeychainValue",value:function(){var e={version:this.keyVersion};return this.masterKey&&(e.masterKey=this.masterKey),this.dataAuthenticationKey&&(e.dataAuthenticationKey=this.dataAuthenticationKey),e}},{key:"typedContent",get:function(){return this.safeContent}},{key:"keyVersion",get:function(){if(!this.payload.safeContent.version)throw'Attempting to create key without version.';return this.payload.safeContent.version}},{key:"isRootKey",get:function(){return!0}},{key:"itemsKey",get:function(){return this.masterKey}},{key:"masterKey",get:function(){return this.payload.safeContent.masterKey}},{key:"serverPassword",get:function(){return this.payload.safeContent.serverPassword}},{key:"dataAuthenticationKey",get:function(){return this.payload.safeContent.dataAuthenticationKey}}],[{key:"Create",value:function(e,t){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t){s.next=4;break}return s.next=3,b.awrap(I.GenerateUuid());case 3:t=s.sent;case 4:if(e.version||(e.dataAuthenticationKey?e.version=Q.a.V002:e.version=Q.a.V001),r=Object(Ee.e)({uuid:t,content_type:F.a.RootKey,content:Object(Ke.a)(e)}),a=e.keyParams){s.next=9;break}throw Error('Attempting to create root key without key params');case 9:return i=a instanceof A.h?a:new A.h(a),s.abrupt("return",new n(r,i));case 11:case"end":return s.stop()}},null,null,null,Promise)}},{key:"ExpandedCopy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=e.typedContent,a.next=3,b.awrap(this.Create(Ue(Ue({},n),{},{keyParams:t||n.keyParams})));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(T.d);function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach(function(t){He(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ze,qe=function(e){return e.trim().toLowerCase()};!(function(e){e.Restored="SessionRestored",e.Revoked="SessionRevoked"})(ze||(ze={}));var Ye,Ge=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).storageService=e,c.apiService=r,c.alertService=a,c.protocolService=i,c.challengeService=s,c.webSocketsService=o,c.isSessionRenewChallengePresented=!1,r.setInvalidSessionObserver(function(e){e?c.notifyEvent(ze.Revoked):c.reauthenticateInvalidSession()}),c}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.alertService=void 0,this.challengeService=void 0,this.webSocketsService=void 0,this.user=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.storageService.getValue(o.User));case 2:if(this.user=r.sent,this.user){r.next=8;break}return r.next=6,b.awrap(this.storageService.getValue(o.LegacyUuid));case 6:(e=r.sent)&&(this.user={uuid:e,email:e});case 8:return r.next=10,b.awrap(this.storageService.getValue(o.Session));case 10:if(!(t=r.sent)){r.next=16;break}return n=Me.FromRawStorageValue(t),r.next=15,b.awrap(this.setSession(n,!1));case 15:this.webSocketsService.startWebSocketConnection(n.authorizationValue);case 16:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=!(n.length>1&&void 0!==n[1])||n[1],r.next=3,b.awrap(this.apiService.setSession(e,t));case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"online",value:function(){return!this.offline()}},{key:"offline",value:function(){return Object(_.w)(this.apiService.getSession())}},{key:"getUser",value:function(){return this.user}},{key:"getSession",value:function(){return this.apiService.getSession()}},{key:"signOut",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.user=void 0,!(e=this.apiService.getSession())||!e.canExpire()){t.next=6;break}return t.next=5,b.awrap(this.apiService.signOut());case 5:this.webSocketsService.closeWebSocketConnection();case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isSignedIn",value:function(){return void 0!=this.getUser()}},{key:"isSignedIntoFirstPartyServer",value:function(){return this.isSignedIn()&&!this.apiService.isThirdPartyHostUsed()}},{key:"reauthenticateInvalidSession",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=!(i.length>0&&void 0!==i[0])||i[0],n=i.length>1?i[1]:void 0,!this.isSessionRenewChallengePresented){s.next=4;break}return s.abrupt("return");case 4:return this.isSessionRenewChallengePresented=!0,r=new ye([new ge(te.None,void 0,j.R.EmailInputPlaceholder,!1),new ge(te.None,void 0,j.R.PasswordInputPlaceholder)],ne.Custom,t,j.R.EnterEmailAndPassword,j.R.RecoverSession(null===(e=this.getUser())||void 0===e?void 0:e.email)),s.abrupt("return",new Promise(function(e){a.challengeService.addChallengeObserver(r,{onCancel:function(){a.isSessionRenewChallengePresented=!1},onComplete:function(){a.isSessionRenewChallengePresented=!1},onNonvalidatedSubmit:function(t){var i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return i=t.values[0].value,s=t.values[1].value,u.next=4,b.awrap(a.protocolService.getAccountKeyParams());case 4:return o=u.sent,u.next=7,b.awrap(a.signIn(i,s,!1,a.storageService.isEphemeralSession(),null===o||void 0===o?void 0:o.version));case 7:(c=u.sent).response.error?(a.challengeService.setValidationStatusForChallenge(r,t.values[1],!1),null===n||void 0===n||n(c.response)):(e(),a.challengeService.completeChallenge(r),a.notifyEvent(ze.Restored),a.alertService.alert(j.R.SessionRestored));case 9:case"end":return u.stop()}},null,null,null,Promise)}}),a.challengeService.promptForChallengeResponse(r)}));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSubscription",value:function(){return this.apiService.getSubscription(this.user.uuid)}},{key:"promptForMfaValue",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=new ye([new ge(te.None,j.M.Mfa,j.R.MfaInputPlaceholder,!1,re.Numeric)],ne.Custom,!0,j.R.EnterMfa),n.next=3,b.awrap(this.challengeService.promptForChallengeResponse(e));case 3:if(!(t=n.sent)){n.next=7;break}return this.challengeService.completeChallenge(e),n.abrupt("return",t.values[0].value);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"register",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(t.length<8)){u.next=2;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.G(8))});case 2:return u.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(r=u.sent,a=r.wrappingKey,!r.canceled){u.next=9;break}return u.abrupt("return",{response:this.apiService.createErrorResponse(j.P.PasscodeRequired,Te.b.LocalValidationError)});case 9:return e=qe(e),u.next=12,b.awrap(this.protocolService.createRootKey(e,t,A.g.Registration));case 12:return i=u.sent,s=i.serverPassword,o=i.keyParams,u.next=17,b.awrap(this.apiService.register(e,s,o,n));case 17:if((c=u.sent).error||!c.data){u.next=21;break}return u.next=21,b.awrap(this.handleSuccessAuthResponse(c,i,a));case 21:return u.abrupt("return",{response:c,rootKey:i});case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"retrieveKeyParams",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.apiService.getAccountKeyParams(e,t,n));case 2:if(!(r=c.sent).error&&!Object(_.w)(r.data)){c.next=17;break}if(!n){c.next=7;break}return c.next=7,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 7:if(null===(a=r.error)||void 0===a||null===(i=a.payload)||void 0===i||!i.mfa_key){c.next=16;break}return c.next=10,b.awrap(this.promptForMfaValue());case 10:if(s=c.sent){c.next=13;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa)});case 13:return c.abrupt("return",this.retrieveKeyParams(e,r.error.payload.mfa_key,s));case 16:return c.abrupt("return",{response:r});case 17:if((o=Object(A.f)(r,e))&&o.version){c.next=20;break}return c.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 20:return c.abrupt("return",{keyParams:o,response:r,mfaKeyPath:t,mfaCode:n});case 21:case"end":return c.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=o.length>2&&void 0!==o[2]&&o[2],r=o.length>3&&void 0!==o[3]&&o[3],a=o.length>4?o[4]:void 0,c.next=5,b.awrap(this.performSignIn(e,t,n,r,a));case 5:if(!(i=c.sent).response.error||i.response.error.status===Te.b.LocalValidationError||i.response.error.status===Te.b.CanceledMfa){c.next=15;break}if((s=qe(e))===e){c.next=12;break}return c.abrupt("return",this.performSignIn(s,t,n,r,a));case 12:return c.abrupt("return",i);case 13:c.next=16;break;case 15:return c.abrupt("return",i);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"performSignIn",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=arguments;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return n=p.length>2&&void 0!==p[2]&&p[2],r=p.length>3&&void 0!==p[3]&&p[3],a=p.length>4?p[4]:void 0,d.next=5,b.awrap(this.retrieveKeyParams(e));case 5:if(!(i=d.sent).response.error){d.next=8;break}return d.abrupt("return",{response:i.response});case 8:if(s=i.keyParams,this.protocolService.supportedVersions().includes(s.version)){d.next=15;break}if(!this.protocolService.isVersionNewerThanLibraryVersion(s.version)){d.next=14;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.X)});case 14:return d.abrupt("return",{response:this.apiService.createErrorResponse(j.A)});case 15:if(!this.protocolService.isProtocolVersionOutdated(s.version)){d.next=25;break}if(o=this.protocolService.costMinimumForVersion(s.version),!(s.content002.pw_cost<o)){d.next=19;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.E)});case 19:return c=j.L,d.next=22,b.awrap(this.alertService.confirm(c,j.K,j.J));case 22:if(d.sent){d.next=25;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.i)});case 25:if(this.protocolService.platformSupportsKeyDerivation(s)){d.next=27;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.W)});case 27:if(n&&(a=this.protocolService.getLatestVersion()),Object(_.w)(a)){d.next=31;break}if(Object(Q.d)(s.version,a)){d.next=31;break}return d.abrupt("return",{response:this.apiService.createErrorResponse(j.T(s.version,a))});case 31:return d.next=33,b.awrap(this.protocolService.computeRootKey(t,s));case 33:return u=d.sent,d.next=36,b.awrap(this.bypassChecksAndSignInWithRootKey(e,u,i.mfaKeyPath,i.mfaCode,r));case 36:return l=d.sent,d.abrupt("return",{response:l});case 38:case"end":return d.stop()}},null,this,null,Promise)}},{key:"bypassChecksAndSignInWithRootKey",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return a=d.length>4&&void 0!==d[4]&&d[4],h.next=3,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 3:if(i=h.sent,s=i.wrappingKey,!i.canceled){h.next=8;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.PasscodeRequired,Te.b.LocalValidationError));case 8:return h.next=10,b.awrap(this.apiService.signIn(e,t.serverPassword,n,r,a));case 10:if((o=h.sent).error||!o.data){h.next=20;break}return h.next=14,b.awrap(Ve.ExpandedCopy(t,o.data.key_params));case 14:return c=h.sent,h.next=17,b.awrap(this.handleSuccessAuthResponse(o,c,s));case 17:return h.abrupt("return",o);case 20:if(null===(u=o.error)||void 0===u||null===(l=u.payload)||void 0===l||!l.mfa_key){h.next=32;break}if(!r){h.next=24;break}return h.next=24,b.awrap(this.alertService.alert(j.S.IncorrectMfa));case 24:return h.next=26,b.awrap(this.promptForMfaValue());case 26:if(p=h.sent){h.next=29;break}return h.abrupt("return",this.apiService.createErrorResponse(j.S.SignInCanceledMissingMfa,Te.b.CanceledMfa));case 29:return h.abrupt("return",this.bypassChecksAndSignInWithRootKey(e,t,o.error.payload.mfa_key,p));case 32:return h.abrupt("return",o);case 33:case"end":return h.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=this.user.uuid,r.next=3,b.awrap(this.apiService.changeCredentials({userUuid:t,currentServerPassword:e.currentServerPassword,newServerPassword:e.newRootKey.serverPassword,newKeyParams:e.newRootKey.keyParams,newEmail:e.newEmail}));case 3:return n=r.sent,r.abrupt("return",this.processChangeCredentialsResponse(n,e.newRootKey,e.wrappingKey));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getSessionsList());case 2:if(!(e=t.sent).error&&!Object(_.w)(e.data)){t.next=5;break}return t.abrupt("return",e);case 5:return e.data=e.data.map(function(e){return We(We({},e),{},{updated_at:new Date(e.updated_at)})}).sort(function(e,t){return e.updated_at<t.updated_at?1:-1}),t.abrupt("return",e);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeSession",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.deleteSession(e));case 2:return t=n.sent,n.abrupt("return",t);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.getSessionsList());case 2:if(void 0==(e=s.sent).error&&void 0!=e.data){s.next=5;break}throw new Error(null!==(t=null===(n=e.error)||void 0===n?void 0:n.message)&&void 0!==t?t:j.m);case 5:return r=e.data,a=r.filter(function(e){return!e.current}),s.next=9,b.awrap(Promise.all(a.map(function(e){return i.revokeSession(e.uuid)})));case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"processChangeCredentialsResponse",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.error||!e.data){a.next=3;break}return a.next=3,b.awrap(this.handleSuccessAuthResponse(e,t,n));case 3:return a.abrupt("return",{response:e,keyParams:null===(r=e.data)||void 0===r?void 0:r.key_params});case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleSuccessAuthResponse",value:function(e,t,n){var r,a,i,s;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,b.awrap(this.protocolService.setRootKey(t,n));case 2:return r=e.data,a=r.user,this.user=a,c.next=7,b.awrap(this.storageService.setValue(o.User,a));case 7:if(this.apiService.setHost(this.apiService.getHost()),!r.token){c.next=15;break}return i=new Ae(r.token),c.next=12,b.awrap(this.setSession(i));case 12:this.webSocketsService.startWebSocketConnection(i.authorizationValue),c.next=20;break;case 15:if(!r.session){c.next=20;break}return s=je.FromApiResponse(e),c.next=19,b.awrap(this.setSession(s));case 19:this.webSocketsService.startWebSocketConnection(s.authorizationValue);case 20:case"end":return c.stop()}},null,this,null,Promise)}}]),n})(R.a);!(function(e){e.SignedInOrRegistered="SignedInOrRegistered"})(Ye||(Ye={}));var Qe=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).sessionManager=e,l.syncService=r,l.storageService=a,l.itemManager=i,l.protocolService=s,l.alertService=o,l.challengeService=c,l.protectionService=u,l.signingIn=!1,l.registering=!1,l}return y(n,[{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.sessionManager=void 0,this.syncService=void 0,this.storageService=void 0,this.itemManager=void 0,this.protocolService=void 0,this.alertService=void 0,this.challengeService=void 0,this.protectionService=void 0}},{key:"register",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=!(i.length>3&&void 0!==i[3])||i[3],!this.protocolService.hasAccount()){s.next=4;break}throw Error('Tried to register when an account already exists.');case 4:if(!this.registering){s.next=6;break}throw Error('Already registering.');case 6:return this.registering=!0,s.prev=7,this.lockSyncing(),s.next=11,b.awrap(this.sessionManager.register(e,t,n));case 11:if((a=s.sent).response.error){s.next=32;break}return this.syncService.resetSyncState(),s.next=16,b.awrap(this.storageService.setPersistencePolicy(n?Oe.Ephemeral:Oe.Default));case 16:if(!r){s.next=21;break}return s.next=19,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 19:s.next=24;break;case 21:return this.itemManager.removeAllItemsFromMemory(),s.next=24,b.awrap(this.clearDatabase());case 24:return s.next=26,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 26:return this.unlockSyncing(),s.next=29,b.awrap(this.syncService.downloadFirstSync(300));case 29:this.protocolService.decryptErroredItems(),s.next=33;break;case 32:this.unlockSyncing();case 33:return s.abrupt("return",a.response);case 34:return s.prev=34,this.registering=!1,s.finish(34);case 37:case"end":return s.stop()}},null,this,[[7,,34,37]],Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s,o,c=this,u=arguments;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],r=u.length>3&&void 0!==u[3]&&u[3],a=!(u.length>4&&void 0!==u[4])||u[4],i=u.length>5&&void 0!==u[5]&&u[5],!this.protocolService.hasAccount()){l.next=6;break}throw Error('Tried to sign in when an account already exists.');case 6:if(!this.signingIn){l.next=8;break}throw Error('Already signing in.');case 8:return this.signingIn=!0,l.prev=9,this.lockSyncing(),l.next=13,b.awrap(this.sessionManager.signIn(e,t,n,r));case 13:if((s=l.sent).response.error){l.next=37;break}return this.syncService.resetSyncState(),l.next=18,b.awrap(this.storageService.setPersistencePolicy(r?Oe.Ephemeral:Oe.Default));case 18:if(!a){l.next=23;break}return l.next=21,b.awrap(this.syncService.markAllItemsAsNeedingSync());case 21:l.next=26;break;case 23:return this.itemManager.removeAllItemsFromMemory(),l.next=26,b.awrap(this.clearDatabase());case 26:return l.next=28,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 28:if(this.unlockSyncing(),o=this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0,awaitAll:i}).then(function(){i||c.protocolService.decryptErroredItems()}),!i){l.next=35;break}return l.next=33,b.awrap(o);case 33:return l.next=35,b.awrap(this.protocolService.decryptErroredItems());case 35:l.next=38;break;case 37:this.unlockSyncing();case 38:return l.abrupt("return",s.response);case 39:return l.prev=39,this.signingIn=!1,l.finish(39);case 42:case"end":return l.stop()}},null,this,[[9,,39,42]],Promise)}},{key:"correctiveSignIn",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.lockSyncing(),n.next=3,b.awrap(this.sessionManager.bypassChecksAndSignInWithRootKey(e.keyParams.identifier,e));case 3:if((t=n.sent).error){n.next=10;break}return n.next=7,b.awrap(this.notifyEvent(Ye.SignedInOrRegistered));case 7:this.unlockSyncing(),this.syncService.downloadFirstSync(1e3,{checkIntegrity:!0}),this.protocolService.decryptErroredItems();case 10:return this.unlockSyncing(),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeCredentials",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.performCredentialsChange(e));case 2:return(t=n.sent).error&&this.alertService.alert(t.error.message),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.sessionManager.signOut());case 2:return e.next=4,b.awrap(this.protocolService.clearLocalKeyState());case 4:return e.next=6,b.awrap(this.storageService.clearAllData());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performProtocolUpgrade",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return e=this.protocolService.hasPasscode(),t=this.protocolService.hasAccount(),n=[],e&&n.push(new ge(te.LocalPasscode,void 0,j.x.LocalPasscodePlaceholder)),t&&n.push(new ge(te.AccountPassword,void 0,j.x.AccountPasswordPlaceholder)),r=new ye(n,ne.ProtocolUpgrade,!0),p.next=8,b.awrap(this.challengeService.promptForChallengeResponse(r));case 8:if(a=p.sent){p.next=11;break}return p.abrupt("return",{canceled:!0});case 11:return p.next=13,b.awrap(this.alertService.blockingDialog(j.z,j.Y));case 13:if(i=p.sent,p.prev=14,e&&(o=a.getValueForType(te.LocalPasscode),s=o.value),!t){p.next=24;break}return c=a.getValueForType(te.AccountPassword),u=c.value,p.next=21,b.awrap(this.changeCredentials({currentPassword:u,newPassword:u,passcode:s,origination:A.g.ProtocolUpgrade,validateNewPasswordStrength:!1}));case 21:if(null===(l=p.sent)||void 0===l||!l.error){p.next=24;break}return p.abrupt("return",{error:l.error});case 24:if(!e){p.next=29;break}return p.next=27,b.awrap(this.removePasscodeWithoutWarning());case 27:return p.next=29,b.awrap(this.setPasscodeWithoutWarning(s,A.g.ProtocolUpgrade));case 29:return p.abrupt("return",{success:!0});case 32:return p.prev=32,p.t0=p.catch(14),p.abrupt("return",{error:p.t0});case 35:return p.prev=35,i(),p.finish(35);case 38:case"end":return p.stop()}},null,this,[[14,32,35,38]],Promise)}},{key:"addPasscode",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e.length<1)){n.next=2;break}return n.abrupt("return",!1);case 2:return n.next=4,b.awrap(this.protectionService.authorizeAddingPasscode());case 4:if(n.sent){n.next=6;break}return n.abrupt("return",!1);case 6:return n.next=8,b.awrap(this.alertService.blockingDialog(j.z,j.Q));case 8:return t=n.sent,n.prev=9,n.next=12,b.awrap(this.setPasscodeWithoutWarning(e,A.g.PasscodeCreate));case 12:return n.abrupt("return",!0);case 13:return n.prev=13,t(),n.finish(13);case 16:case"end":return n.stop()}},null,this,[[9,,13,16]],Promise)}},{key:"removePasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeRemovingPasscode());case 2:if(t.sent){t.next=4;break}return t.abrupt("return",!1);case 4:return t.next=6,b.awrap(this.alertService.blockingDialog(j.z,j.O));case 6:return e=t.sent,t.prev=7,t.next=10,b.awrap(this.removePasscodeWithoutWarning());case 10:return t.abrupt("return",!0);case 11:return t.prev=11,e(),t.finish(11);case 14:case"end":return t.stop()}},null,this,[[7,,11,14]],Promise)}},{key:"changePasscode",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]?r[1]:A.g.PasscodeChange,!(e.length<1)){a.next=3;break}return a.abrupt("return",!1);case 3:return a.next=5,b.awrap(this.protectionService.authorizeChangingPasscode());case 5:if(a.sent){a.next=7;break}return a.abrupt("return",!1);case 7:return a.next=9,b.awrap(this.alertService.blockingDialog(j.z,t===A.g.ProtocolUpgrade?j.N.UpgradingPasscode:j.v));case 9:return n=a.sent,a.prev=10,a.next=13,b.awrap(this.removePasscodeWithoutWarning());case 13:return a.next=15,b.awrap(this.setPasscodeWithoutWarning(e,t));case 15:return a.abrupt("return",!0);case 16:return a.prev=16,n(),a.finish(16);case 19:case"end":return a.stop()}},null,this,[[10,,16,19]],Promise)}},{key:"setPasscodeWithoutWarning",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(I.GenerateUuid());case 2:return n=a.sent,a.next=5,b.awrap(this.protocolService.createRootKey(n,e,t));case 5:return r=a.sent,a.next=8,b.awrap(this.protocolService.setNewRootKeyWrapper(r));case 8:return a.next=10,b.awrap(this.rewriteItemsKeys());case 10:return a.next=12,b.awrap(this.syncService.sync());case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"removePasscodeWithoutWarning",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protocolService.removeRootKeyWrapper());case 2:return e.next=4,b.awrap(this.rewriteItemsKeys());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"rewriteItemsKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.itemsKeys(),t=e.map(function(e){return e.payloadRepresentation()}),n.next=4,b.awrap(this.storageService.deletePayloads(t));case 4:return n.next=6,b.awrap(this.syncService.persistPayloads(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"lockSyncing",value:function(){this.syncService.lockSyncing()}},{key:"unlockSyncing",value:function(){this.syncService.unlockSyncing()}},{key:"clearDatabase",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.clearAllPayloads());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"performCredentialsChange",value:function(e){var t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(this.challengeService.getWrappingKeyIfApplicable(e.passcode));case 2:if(t=u.sent,n=t.wrappingKey,!t.canceled){u.next=7;break}return u.abrupt("return",{error:Error(j.y.PasscodeRequired)});case 7:if(void 0===e.newPassword||!e.validateNewPasswordStrength){u.next=10;break}if(!(e.newPassword.length<8)){u.next=10;break}return u.abrupt("return",{error:Error(Object(j.G)(8))});case 10:return u.next=12,b.awrap(this.protocolService.validateAccountPassword(e.currentPassword));case 12:if(u.sent.valid){u.next=15;break}return u.abrupt("return",{error:Error(j.D)});case 15:return r=this.sessionManager.getUser(),a=r.email,u.next=19,b.awrap(this.recomputeRootKeysForCredentialChange({currentPassword:e.currentPassword,currentEmail:a,origination:e.origination,newEmail:e.newEmail,newPassword:e.newPassword}));case 19:return i=u.sent,this.lockSyncing(),u.next=23,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.currentRootKey.serverPassword,newRootKey:i.newRootKey,wrappingKey:n,newEmail:e.newEmail}));case 23:if(s=u.sent,this.unlockSyncing(),s.response.error){u.next=45;break}return u.next=28,b.awrap(this.protocolService.createNewItemsKeyWithRollback());case 28:return o=u.sent,u.next=31,b.awrap(this.protocolService.reencryptItemsKeys());case 31:return u.next=33,b.awrap(this.syncService.sync({awaitAll:!0}));case 33:if(c=this.protocolService.getDefaultItemsKey(),!c.neverSynced){u.next=45;break}return u.next=38,b.awrap(this.sessionManager.changeCredentials({currentServerPassword:i.newRootKey.serverPassword,newRootKey:i.currentRootKey,wrappingKey:n}));case 38:return u.next=40,b.awrap(this.protocolService.reencryptItemsKeys());case 40:return u.next=42,b.awrap(o());case 42:return u.next=44,b.awrap(this.syncService.sync({awaitAll:!0}));case 44:return u.abrupt("return",{error:Error(j.y.Failed)});case 45:return u.abrupt("return",s.response);case 46:case"end":return u.stop()}},null,this,null,Promise)}},{key:"recomputeRootKeysForCredentialChange",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.t0=b,i.t1=this.protocolService,i.t2=e.currentPassword,i.next=5,b.awrap(this.protocolService.getRootKeyParams());case 5:return i.t3=i.sent,i.t4=i.t1.computeRootKey.call(i.t1,i.t2,i.t3),i.next=9,i.t0.awrap.call(i.t0,i.t4);case 9:return r=i.sent,i.next=12,b.awrap(this.protocolService.createRootKey(null!==(t=e.newEmail)&&void 0!==t?t:e.currentEmail,null!==(n=e.newPassword)&&void 0!==n?n:e.currentPassword,e.origination));case 12:return a=i.sent,i.abrupt("return",{currentRootKey:r,newRootKey:a});case 14:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),Je=n(5),$e=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",get:function(){return this.payload.safeContent.migratedToUserSetting}},{key:"migratedToOfflineEntitlements",get:function(){return this.payload.safeContent.migratedToOfflineEntitlements}},{key:"onlineUrl",get:function(){return this.payload.safeContent.url}},{key:"offlineFeaturesUrl",get:function(){return this.payload.safeContent.offlineFeaturesUrl}},{key:"offlineKey",get:function(){return this.payload.safeContent.offlineKey}}]),n})(T.d),Xe=(function(e){d(n,e);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"migratedToUserSetting",set:function(e){this.content.migratedToUserSetting=e}},{key:"migratedToOfflineEntitlements",set:function(e){this.content.migratedToOfflineEntitlements=e}},{key:"offlineFeaturesUrl",set:function(e){this.content.offlineFeaturesUrl=e}},{key:"offlineKey",set:function(e){this.content.offlineKey=e}}]),n})(T.b),Ze=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).notes=[],r.data={},r.url=e.safeContent.url,r.name=e.safeContent.name,r.data=e.safeContent.data||{},r.isDefault=e.safeContent.default,r.systemEditor=e.safeContent.systemEditor,r}return n})(T.d),et=(function(e){d(n,oe);var t=k(n);function n(e){var r;return v(this,n),r=t.call(this,e),e.safeContent.predicate&&(r.predicate=H.a.FromJson(e.safeContent.predicate)),r}return n})(),tt=(g(r={},F.a.Note,le),g(r,F.a.Tag,oe),g(r,F.a.ItemsKey,J),g(r,F.a.SmartTag,et),g(r,F.a.ActionsExtension,ie),g(r,F.a.Editor,Ze),g(r,F.a.Theme,B),g(r,F.a.Component,N),g(r,F.a.UserPrefs,z),g(r,F.a.ExtensionRepo,$e),r);function nt(e){return new(tt[e.content_type]||T.d)(e)}var rt=n(27),at=n.n(rt);function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function st(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach(function(t){ot(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ot(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ct=g({},F.a.Note,function(e,t,n){var r=n.all(F.a.Component).map(function(e){return nt(e)}).filter(function(e){return e.area===L.ComponentArea.Editor}).find(function(t){return t.isExplicitlyEnabledForItem(e.uuid)});if(r){var a=new V(r,T.c.Internal);return a.associateWithItem(t.uuid),[a.getResult()]}});function ut(e,t,n,r){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(!e.errorDecrypting){p.next=2;break}throw Error('Attempting to duplicate errored payload');case 2:return a=[],p.next=5,b.awrap(I.GenerateUuid());case 5:return p.t0=p.sent,p.t1=new Date,p.t2=e.uuid,(i={uuid:p.t0,dirty:!0,dirtiedDate:p.t1,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:p.t2}).content=st(st({},e.safeContent),r),n&&(i.content.conflict_of=e.uuid),s=Object(Ee.b)(e,i),a.push(s),o=t.elementsReferencingElement(e),c=pt(o,[{uuid:s.uuid,content_type:s.content_type}]),Object(_.o)(a,c),(u=ct[e.content_type])&&(l=u(e,s,t))&&Object(_.o)(a,l),p.abrupt("return",a);case 19:case"end":return p.stop()}},null,null,null,Promise)}function lt(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=[],u.t0=Object(Ee.b),u.t1=e,u.next=5,b.awrap(I.GenerateUuid());case 5:return u.t2=u.sent,u.t3=new Date,u.t4=e.uuid,u.t5={uuid:u.t2,dirty:!0,dirtiedDate:u.t3,lastSyncBegan:null,lastSyncEnd:null,duplicate_of:u.t4},r=(0,u.t0)(u.t1,u.t5),n.push(r),a=t.elementsReferencingElement(e),i=pt(a,[{uuid:r.uuid,content_type:r.content_type}],[e.uuid]),Object(_.o)(n,i),e.content_type===F.a.ItemsKey&&(s=t.all().filter(function(t){return t.items_key_id===e.uuid}),(o=s.map(function(e){return Object(Ee.b)(e,{items_key_id:r.uuid})})).length>0&&Object(_.o)(n,o)),c=Object(Ee.b)(e,{deleted:!0,dirty:!1,content:void 0}),n.push(c),u.abrupt("return",n);case 18:case"end":return u.stop()}},null,null,null,Promise)}function pt(e,t,n){for(var r,a=[],i=S(e);!(r=i()).done;){var s=r.value,o=s.contentObject.references.slice();if(t)for(var c,u=S(t);!(c=u()).done;){var l=c.value;o.push(l)}if(n)for(var p,d=S(n);!(p=d()).done;){var h=p.value;at()(o,{uuid:h})}var f=Object(Ee.b)(s,{dirty:!0,dirtiedDate:new Date,content:st(st({},s.safeContent),{},{references:o})});a.push(f)}return a}function dt(e,t){var n=nt(e),r=nt(t);return n.isItemContentEqualWith(r)}var ht=n(4),ft=n(32),vt=(function(){function e(t,n,r,a){v(this,e),this.baseCollection=t,this.applyCollection=n,this.relatedCollectionSet=r,this.historyMap=a}return y(e,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:throw'Must override PayloadDelta.resultingCollection.';case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"findBasePayload",value:function(e){return this.baseCollection.find(e)}},{key:"findRelatedPayload",value:function(e,t){var n,r=null===(n=this.relatedCollectionSet)||void 0===n?void 0:n.collectionForSource(t);return null===r||void 0===r?void 0:r.find(e)}}]),e})(),yt=function(e){return e[0]},gt=(function(){function e(){v(this,e),this.directMap={},this.inverseMap={}}return y(e,[{key:"makeCopy",value:function(){var t=new e;return t.directMap=w({},this.directMap),t.inverseMap=w({},this.inverseMap),t}},{key:"getDirectRelationships",value:function(e){return this.directMap[e]||[]}},{key:"getInverseRelationships",value:function(e){return this.inverseMap[e]||[]}},{key:"establishRelationship",value:function(e,t){this.establishDirectRelationship(e,t),this.establishInverseRelationship(e,t)}},{key:"deestablishRelationship",value:function(e,t){this.deestablishDirectRelationship(e,t),this.deestablishInverseRelationship(e,t)}},{key:"setAllRelationships",value:function(e,t){var n=this.directMap[e]||[];this.directMap[e]=t;for(var r,a=S(n);!(r=a()).done;){var i=r.value;this.deestablishInverseRelationship(e,i)}for(var s,o=S(t);!(s=o()).done;){var c=s.value;this.establishInverseRelationship(e,c)}}},{key:"removeFromMap",value:function(e){for(var t,n=S(this.directMap[e]||[]);!(t=n()).done;){var r=t.value;Object(_.M)(this.inverseMap[r]||[],e)}delete this.directMap[e];for(var a,i=S(this.inverseMap[e]||[]);!(a=i()).done;){var s=a.value;Object(_.M)(this.directMap[s]||[],e)}delete this.inverseMap[e]}},{key:"establishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.b)(n,t),this.directMap[e]=n}},{key:"establishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.b)(n,e),this.inverseMap[t]=n}},{key:"deestablishDirectRelationship",value:function(e,t){var n=this.directMap[e]||[];Object(_.M)(n,t),this.directMap[e]=n}},{key:"deestablishInverseRelationship",value:function(e,t){var n=this.inverseMap[t]||[];Object(_.M)(n,e),this.inverseMap[t]=n}}]),e})(),mt=(function(){function e(){v(this,e);var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;this.map={},this.typedMap={},this.dirtyIndex=new Set,this.invalidsIndex=new Set,this.nondeletedIndex=new Set,t?(this.map=n,this.typedMap=r,this.referenceMap=a,this.conflictMap=i):(this.referenceMap=new gt,this.conflictMap=new gt)}return y(e,[{key:"uuids",value:function(){return Object.keys(this.map)}},{key:"all",value:function(e){var t=this;if(e){if(Array.isArray(e)){for(var n,r=[],a=S(e);!(n=a()).done;){var i=n.value;Object(_.o)(r,this.typedMap[i]||[])}return r}var s;return(null===(s=this.typedMap[e])||void 0===s?void 0:s.slice())||[]}return Object.keys(this.map).map(function(e){return t.map[e]})}},{key:"find",value:function(e){return this.map[e]}},{key:"dirtyElements",value:function(){var e=Array.from(this.dirtyIndex);return this.findAll(e)}},{key:"invalidElements",value:function(){var e=Array.from(this.invalidsIndex);return this.findAll(e)}},{key:"nondeletedElements",value:function(){var e=Array.from(this.nondeletedIndex);return this.findAll(e)}},{key:"findAll",value:function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[],a=S(e);!(t=a()).done;){var i=t.value,s=this.map[i];(s||n)&&r.push(s)}return r}},{key:"set",value:function(e){if(0!==(e=Array.isArray(e)?e:[e]).length)for(var t,n=S(e);!(t=n()).done;){var r=t.value;if(this.map[r.uuid]=r,this.setToTypedMap(r),r.dirty?this.dirtyIndex.add(r.uuid):this.dirtyIndex.delete(r.uuid),r.errorDecrypting||r.waitingForKey?this.invalidsIndex.add(r.uuid):this.invalidsIndex.delete(r.uuid),r.deleted)this.referenceMap.removeFromMap(r.uuid),this.nondeletedIndex.delete(r.uuid);else{this.nondeletedIndex.add(r.uuid);var a=r.safeContent.conflict_of;a&&this.conflictMap.establishRelationship(a,r.uuid),this.referenceMap.setAllRelationships(r.uuid,r.references.map(function(e){return e.uuid}))}}else console.warn('Attempting to set 0 elements onto collection')}},{key:"discard",value:function(e){for(var t,n=S(e=Array.isArray(e)?e:[e]);!(t=n()).done;){var r=t.value;this.conflictMap.removeFromMap(r.uuid),this.referenceMap.removeFromMap(r.uuid),this.deleteFromTypedMap(r),delete this.map[r.uuid]}}},{key:"setToTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),t.push(e),this.typedMap[e.content_type]=t}},{key:"deleteFromTypedMap",value:function(e){var t=this.typedMap[e.content_type]||[];at()(t,{uuid:e.uuid}),this.typedMap[e.content_type]=t}},{key:"uuidsThatReferenceUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getInverseRelationships(e)}},{key:"elementsReferencingElement",value:function(e,t){var n=this.uuidsThatReferenceUuid(e.uuid),r=this.findAll(n);return t?r.filter(function(e){return e.content_type===t}):r}},{key:"uuidReferencesForUuid",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');return this.referenceMap.getDirectRelationships(e)}},{key:"referencesForElement",value:function(e){var t=this.referenceMap.getDirectRelationships(e.uuid);return this.findAll(t)}},{key:"conflictsOf",value:function(e){var t=this.conflictMap.getDirectRelationships(e);return this.findAll(t)}}]),e})(),bt=(function(e){d(n,mt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"mutableCopy",value:function(){var e=w({},this.map),t=w({},this.typedMap),n=this.referenceMap.makeCopy(),r=this.conflictMap.makeCopy();return new mt(!0,e,t,n,r)}},{key:"payloads",get:function(){return this.all()}}],[{key:"WithPayloads",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,r=new n;return r.source=t,e.length>0&&r.set(e),Object.freeze(r),r}},{key:"FromCollection",value:function(e){var t=new n(!0,Object.freeze(w({},e.map)),Object.freeze(w({},e.typedMap)),Object.freeze(e.referenceMap.makeCopy()),Object.freeze(e.conflictMap.makeCopy()));return Object.freeze(t),t}}]),n})();function wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?wt(Object(n),!0).forEach(function(t){xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var St,Pt,Ot,Ct=(function(){function e(t,n,r,a,i){v(this,e),this.baseCollection=t,this.basePayload=n,this.applyPayload=r,this.source=a,this.historyMap=i}return y(e,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return t=nt(this.basePayload),n=nt(this.applyPayload),r=(null===(e=this.historyMap)||void 0===e?void 0:e[this.basePayload.uuid])||[],a=yt(r),i=t.strategyWhenConflictingWithItem(n,a),o.next=7,b.awrap(this.payloadsByHandlingStrategy(i));case 7:return s=o.sent,o.abrupt("return",bt.WithPayloads(s,this.source));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingStrategy",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if((t=this.baseCollection.conflictsOf(this.applyPayload.uuid)[0])&&dt(t,this.applyPayload)&&(e=K.a.KeepLeft),e!==K.a.KeepLeft){y.next=7;break}return n=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),r=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),a=Object(Ee.b)(this.basePayload,{updated_at:n,updated_at_timestamp:r,dirty:!0,dirtiedDate:new Date}),y.abrupt("return",[a]);case 7:if(e!==K.a.KeepRight){y.next=10;break}return i=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",[i]);case 10:if(e!==K.a.KeepLeftDuplicateRight){y.next=18;break}return s=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),o=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),c=Object(Ee.b)(this.basePayload,{updated_at:s,updated_at_timestamp:o,dirty:!0,dirtiedDate:new Date}),y.next=16,b.awrap(ut(this.applyPayload,this.baseCollection,!0));case 16:return u=y.sent,y.abrupt("return",[c].concat(u));case 18:if(e!==K.a.DuplicateLeftKeepRight){y.next=24;break}return y.next=21,b.awrap(ut(this.basePayload,this.baseCollection,!0));case 21:return l=y.sent,p=Object(Ee.g)(this.applyPayload,this.basePayload,[Je.a.LastSyncBegan],{lastSyncEnd:new Date}),y.abrupt("return",l.concat([p]));case 24:if(e!==K.a.KeepLeftMergeRefs){y.next=30;break}return d=Object(_.U)(this.basePayload.contentObject.references,this.applyPayload.contentObject.references,['uuid','content_type']),h=Object(_.s)(this.basePayload.serverUpdatedAt,this.applyPayload.serverUpdatedAt),f=Math.max(this.basePayload.updated_at_timestamp,this.applyPayload.updated_at_timestamp),v=Object(Ee.b)(this.basePayload,{updated_at:h,updated_at_timestamp:f,dirty:!0,dirtiedDate:new Date,content:kt(kt({},this.basePayload.safeContent),{},{references:d})}),y.abrupt("return",[v]);case 30:throw Error('Unhandled strategy');case 31:case"end":return y.stop()}},null,this,null,Promise)}}]),e})(),Dt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}return r=n.value,s.next=6,b.awrap(this.payloadsByHandlingPayload(r,e));case 6:a=s.sent,i=a.map(function(e){return Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date,deleted:!1})}),Object(_.o)(e,i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.FileImport));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"payloadsByHandlingPayload",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if((n=t.find(function(t){return t.contentObject.conflict_of===e.uuid}))||(n=t.find(function(t){return t.uuid===e.uuid})),n||(n=this.findBasePayload(e.uuid)),n){i.next=5;break}return i.abrupt("return",[e]);case 5:return r=new Ct(this.baseCollection,n,e,ht.a.FileImport),i.next=8,b.awrap(r.resultingCollection());case 8:return a=i.sent,i.abrupt("return",a.all());case 10:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(),_t=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=17;break}if(r=n.value,e.push(r),a=this.findBasePayload(r.uuid)){s.next=8;break}return s.abrupt("continue",15);case 8:if(!dt(r,a)){s.next=11;break}return s.abrupt("continue",15);case 11:return s.next=13,b.awrap(ut(a,this.baseCollection,!0));case 13:i=s.sent,Object(_.o)(e,i);case 15:s.next=2;break;case 17:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 18:case"end":return s.stop()}},null,this,null,Promise)}}]),n})(),Et=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.applyCollection.source!==ht.a.ConflictUuid){e.next=4;break}return e.abrupt("return",this.collectionsByHandlingUuidConflicts());case 4:if(this.applyCollection.source!==ht.a.ConflictData){e.next=8;break}return e.abrupt("return",this.collectionsByHandlingDataConflicts());case 8:throw"Unhandled conflict type ".concat(this.applyCollection.source);case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingDataConflicts",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){u.next=19;break}if(r=n.value,a=this.findBasePayload(r.uuid)){u.next=8;break}return e.push(r),u.abrupt("continue",17);case 8:if((i=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient))||r.deleted){u.next=11;break}throw'Unable to find decrypted counterpart for data conflict.';case 11:return s=new Ct(this.baseCollection,a,i||r,ht.a.ConflictData,this.historyMap),u.next=14,b.awrap(s.resultingCollection());case 14:o=u.sent,c=o.all(),Object(_.o)(e,c);case 17:u.next=2;break;case 19:return u.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"collectionsByHandlingUuidConflicts",value:function(){var e,t,n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:e=[],t=this.baseCollection.mutableCopy(),n=function(n){var r,a,i;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(r=e.find(function(e){return e.uuid===n.uuid}),a=r||s.findRelatedPayload(n.uuid,ht.a.DecryptedTransient)){o.next=6;break}return we.a.error(Error('Cannot find decrypted payload in conflict handling')),console.error('Unable to find decrypted counterpart for payload',n),o.abrupt("return","continue");case 6:return o.next=8,b.awrap(lt(a,bt.FromCollection(t)));case 8:i=o.sent,t.set(i),Object(_.p)(e,function(e){return Object(Ke.b)(i).includes(e.uuid)}),Object(_.o)(e,i);case 12:case"end":return o.stop()}},null,null,null,Promise)},r=S(this.applyCollection.all());case 4:if((a=r()).done){o.next=13;break}return i=a.value,o.next=8,b.awrap(n(i));case 8:if("continue"!==o.sent){o.next=11;break}return o.abrupt("continue",11);case 11:o.next=4;break;case 13:return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRetrieved));case 14:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Rt=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y;return b.async(function(g){for(;;)switch(g.prev=g.next){case 0:e=[],t=[],n=S(this.applyCollection.all());case 3:if((r=n()).done){g.next=22;break}if(a=r.value,i=this.findRelatedPayload(a.uuid,ht.a.SavedOrSaving),s=this.findRelatedPayload(a.uuid,ht.a.DecryptedTransient)){g.next=12;break}if(a.deleted){g.next=10;break}throw'Cannot find decrypted for non-deleted payload.';case 10:return e.push(a),g.abrupt("continue",20);case 12:if(!i){g.next=15;break}return t.push(s),g.abrupt("continue",20);case 15:if(null===(o=this.findBasePayload(a.uuid))||void 0===o||!o.dirty||o.errorDecrypting){g.next=19;break}return t.push(s),g.abrupt("continue",20);case 19:e.push(s);case 20:g.next=3;break;case 22:c=[],u=0,l=t;case 24:if(!(u<l.length)){g.next=41;break}if(p=l[u],d=this.findRelatedPayload(p.uuid,ht.a.DecryptedTransient)){g.next=29;break}return g.abrupt("continue",38);case 29:if(h=this.findBasePayload(p.uuid)){g.next=32;break}return g.abrupt("continue",38);case 32:return f=new Ct(this.baseCollection,h,d,ht.a.ConflictData),g.next=35,b.awrap(f.resultingCollection());case 35:v=g.sent,y=v.all(),Object(_.o)(c,y);case 38:u++,g.next=24;break;case 41:return g.abrupt("return",bt.WithPayloads(e.concat(c),ht.a.RemoteRetrieved));case 42:case"end":return g.stop()}},null,this,null,Promise)}}]),n})(),It=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:for(e=[],t=S(this.applyCollection.all());!(n=t()).done;)r=n.value,a=this.findBasePayload(r.uuid),i=a?a.deleted:r.deleted,s=Object(Ee.f)(r,ht.a.RemoteSaved,{lastSyncEnd:new Date,deleted:i,dirty:i}),e.push(s);return o.abrupt("return",bt.WithPayloads(e,ht.a.RemoteSaved));case 3:case"end":return o.stop()}},null,this,null,Promise)}}]),n})(),Mt=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l){var p;return v(this,n),(p=t.call(this)).itemManager=e,p.payloadManager=r,p.apiService=a,p.protocolService=i,p.challengeService=s,p.alertService=o,p.storageService=c,p.syncService=u,p.credentialService=l,p.decryptionQueue=[],p.isProcessingQueue=!1,p.removeItemObserver=p.itemManager.addObserver([F.a.ItemsKey],function(e,t,n,r,a){if(a!==ht.a.LocalChanged){var i=e.concat(t).filter(function(e){return e.errorDecrypting});i.length>0&&p.handleUndecryptableItemsKeys(i),r.length>0&&p.handleIgnoredItemsKeys(r)}}),p}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.apiService=void 0,this.protocolService=void 0,this.challengeService=void 0,this.alertService=void 0,this.credentialService=void 0,this.syncService=void 0,this.storageService=void 0,this.removeItemObserver(),this.removeItemObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:p(f(n.prototype),"handleApplicationStage",this).call(this,e),e===ve.LoadedDatabase_12&&this.processPersistedUndecryptables();case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleIgnoredItemsKeys",value:function(e){var t=this,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(!(n.length>1&&void 0!==n[1])||n[1])){r.next=4;break}return r.next=4,b.awrap(this.saveToUndecryptables(e));case 4:return r.next=6,b.awrap(this.addKeysToQueue(e,function(e,n){n.success&&t.removeFromUndecryptables(e)}));case 6:return r.next=8,b.awrap(this.beginProcessingQueue());case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"handleUndecryptableItemsKeys",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.addKeysToQueue(e));case 2:return t.next=4,b.awrap(this.beginProcessingQueue());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"processPersistedUndecryptables",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getUndecryptables());case 2:if(e=r.sent,0!==(t=Object.values(e)).length){r.next=6;break}return r.abrupt("return");case 6:return n=t.map(function(e){return Object(Ee.e)(e)}).map(function(e){return nt(e)}),r.abrupt("return",this.handleIgnoredItemsKeys(n,!1));case 8:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getUndecryptables",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.KeyRecoveryUndecryptableItems,De.Default,{}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"persistUndecryptables",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.KeyRecoveryUndecryptableItems,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"saveToUndecryptables",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.getUndecryptables());case 2:for(t=i.sent,n=S(e);!(r=n()).done;)a=r.value,t[a.uuid]=a.payload.ejected();return i.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return i.stop()}},null,this,null,Promise)}},{key:"removeFromUndecryptables",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getUndecryptables());case 2:return delete(t=n.sent)[e.uuid],n.next=6,b.awrap(this.persistUndecryptables(t));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getClientKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getAccountKeyParams());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"serverKeyParamsAreSafe",value:function(e){return Object(Q.d)(this.serverParams.version,e.version)}},{key:"performServerSignIn",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(e),j.H.KeyRecoveryLoginFlowReason),i.next=3,b.awrap(this.challengeService.promptForChallengeResponse(t));case 3:if(n=i.sent){i.next=6;break}return i.abrupt("return",void 0);case 6:return this.challengeService.completeChallenge(t),r=n.values[0].value,i.next=10,b.awrap(this.protocolService.computeRootKey(r,e));case 10:return a=i.sent,i.next=13,b.awrap(this.credentialService.correctiveSignIn(a));case 13:if(i.sent.error){i.next=19;break}return this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced),i.abrupt("return",a);case 19:return i.next=21,b.awrap(this.alertService.alert(j.H.KeyRecoveryLoginFlowInvalidPassword));case 21:return i.abrupt("return",this.performServerSignIn(e));case 22:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",void 0);case 2:return n.next=4,b.awrap(this.challengeService.getWrappingKeyIfApplicable());case 4:if(e=n.sent,t=e.wrappingKey,!e.canceled){n.next=11;break}return n.next=10,b.awrap(this.alertService.alert(j.H.KeyRecoveryPasscodeRequiredText,j.H.KeyRecoveryPasscodeRequiredTitle));case 10:return n.abrupt("return",this.getWrappingKeyIfApplicable());case 11:return n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"addKeysToQueue",value:function(e,t){var n,r,a,i,s=this;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:n=function(e){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(s.protocolService.getKeyEmbeddedKeyParams(e));case 2:if(n=i.sent){i.next=5;break}return i.abrupt("return","continue");case 5:r={key:e,keyParams:n,callback:t},a=new Promise(function(e){r.resolve=e}),r.promise=a,s.decryptionQueue.push(r);case 9:case"end":return i.stop()}},null,null,null,Promise)},r=S(e);case 2:if((a=r()).done){o.next=11;break}return i=a.value,o.next=6,b.awrap(n(i));case 6:if("continue"!==o.sent){o.next=9;break}return o.abrupt("continue",9);case 9:o.next=2;break;case 11:case"end":return o.stop()}},null,null,null,Promise)}},{key:"readdQueueItem",value:function(e){var t=new Promise(function(t){e.resolve=t});e.promise=t,this.decryptionQueue.unshift(e)}},{key:"beginProcessingQueue",value:function(){var e,t,n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(!this.isProcessingQueue){c.next=2;break}return c.abrupt("return");case 2:return this.isProcessingQueue=!0,c.next=5,b.awrap(this.getClientKeyParams());case 5:if(e=c.sent,this.serverParams||!e){c.next=11;break}return c.next=9,b.awrap(this.apiService.getAccountKeyParams(e.identifier));case 9:!(t=c.sent).error&&t.data&&(this.serverParams=Object(A.f)(t));case 11:if(n=this.protocolService.hasAccount(),r=this.protocolService.hasPasscode(),a=!n&&!r,i=this.decryptionQueue[0],!a){c.next=24;break}return c.next=18,b.awrap(this.performServerSignIn(i.keyParams));case 18:if(!(s=c.sent)){c.next=24;break}return c.next=22,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(s,!0));case 22:Object(_.M)(this.decryptionQueue,i),i=this.decryptionQueue[0];case 24:if(!i){c.next=31;break}return this.popQueueItem(i),c.next=28,b.awrap(i.promise);case 28:i=this.decryptionQueue[0],c.next=24;break;case 31:this.queuePromise.then(function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(o.isProcessingQueue=!1,!o.serverParams){n.next=9;break}return n.next=4,b.awrap(o.getClientKeyParams());case 4:if(e=n.sent,t=e&&!o.serverParams.compare(e),!o.serverKeyParamsAreSafe(e)||!t){n.next=9;break}return n.next=9,b.awrap(o.performServerSignIn(o.serverParams));case 9:o.syncService.isOutOfSync()&&o.syncService.sync({checkIntegrity:!0});case 10:case"end":return n.stop()}},null,null,null,Promise)});case 32:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueItem",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P;return b.async(function(O){for(;;)switch(O.prev=O.next){case 0:if(e.resolve){O.next=2;break}throw Error('Attempting to pop queue element with no resolve function');case 2:return Object(_.M)(this.decryptionQueue,e),t=e.keyParams,n=e.key,r=e.resolve,a=!1,O.next=9,b.awrap(this.getClientKeyParams());case 9:return i=O.sent,this.serverParams&&i&&!i.compare(this.serverParams)&&t.compare(this.serverParams)&&this.serverKeyParamsAreSafe(this.serverParams)&&(s=Object(_.j)(this.itemManager.nonErroredItemsForContentType(F.a.ItemsKey),Je.a.CreatedAt,!1)[0],o=!Object(_.w)(s),c=n.created_at>(null===s||void 0===s?void 0:s.created_at),a=!o||c),u=new ye([new ge(te.None,void 0,void 0,!0)],ne.Custom,!0,j.H.KeyRecoveryLoginFlowPrompt(t),j.H.KeyRecoveryPasswordRequired),O.next=14,b.awrap(this.challengeService.promptForChallengeResponse(u));case 14:if(l=O.sent){O.next=20;break}return r(d={success:!1}),null===(p=e.callback)||void 0===p||p.call(e,n,d),O.abrupt("return");case 20:return h=l.values[0].value,O.next=23,b.awrap(this.protocolService.computeRootKey(h,t));case 23:return f=O.sent,O.next=26,b.awrap(this.protocolService.payloadByDecryptingPayload(n.payload,f));case 26:if(v=O.sent,this.challengeService.completeChallenge(u),v.errorDecrypting){O.next=38;break}return O.next=31,b.awrap(this.handleDecryptionOfAllKeysMatchingCorrectRootKey(f,a,[v]));case 31:for(g=O.sent,r(m={success:!0}),null===(y=e.callback)||void 0===y||y.call(e,n,m),w=S(g);!(k=w()).done;)(x=k.value).resolve(m),null===(P=x.callback)||void 0===P||P.call(x,x.key,m);O.next=42;break;case 38:return O.next=40,b.awrap(this.alertService.alert(j.H.KeyRecoveryUnableToRecover));case 40:this.readdQueueItem(e),r({success:!1});case 42:case"end":return O.stop()}},null,this,null,Promise)}},{key:"handleDecryptionOfAllKeysMatchingCorrectRootKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:[],!t){c.next=7;break}return c.next=4,b.awrap(this.getWrappingKeyIfApplicable());case 4:return r=c.sent,c.next=7,b.awrap(this.protocolService.setRootKey(e,r));case 7:return a=this.popQueueForKeyParams(e.keyParams),c.next=10,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a.map(function(e){return e.key.payload}),e));case 10:return i=c.sent,s=n.concat(i),this.payloadManager.emitPayloads(s,ht.a.DecryptedTransient),c.next=15,b.awrap(this.storageService.savePayloads(s));case 15:return t?this.alertService.alert(j.H.KeyRecoveryRootKeyReplaced):this.alertService.alert(j.H.KeyRecoveryKeyRecovered),c.abrupt("return",a);case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"popQueueForKeyParams",value:function(e){for(var t,n=[],r=[],a=S(this.decryptionQueue);!(t=a()).done;){var i=t.value;i.keyParams.compare(e)?n.push(i):r.push(i)}return this.decryptionQueue=r,n}},{key:"queuePromise",get:function(){return Promise.all(this.decryptionQueue.map(function(e){return e.promise}))}}]),n})(R.a),At=n(17);!(function(e){e[e.Info=0]="Info",e[e.Danger=1]="Danger"})(St||(St={})),(function(e){e.Get="GET",e.Post="POST",e.Put="PUT",e.Patch="PATCH",e.Delete="DELETE"})(Pt||(Pt={})),(function(e){e.RevokedSession="revoked-session"})(Ot||(Ot={}));var jt=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).environment=e,a.appVersion=r,a}return y(n,[{key:"getAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Get,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"postAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Post,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"putAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Put,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"patchAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Patch,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteAbsolute",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.runHttp({url:e,params:t,verb:Pt.Delete,authentication:n}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"runHttp",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=this.createXmlRequest(e),n.abrupt("return",this.runRequest(t,e.verb,e.params));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createXmlRequest",value:function(e){var t=new XMLHttpRequest;e.params&&e.verb===Pt.Get&&Object.keys(e.params).length>0&&(e.url=this.urlForUrlAndParams(e.url,e.params)),t.open(e.verb,e.url,!0),t.setRequestHeader('Content-type','application/json'),t.setRequestHeader('X-SNJS-Version',h);var n="".concat(he[this.environment],"-").concat(this.appVersion);return t.setRequestHeader('X-Application-Version',n),e.authentication&&t.setRequestHeader('Authorization','Bearer '+e.authentication),e.customHeaders&&e.customHeaders.length>0&&e.customHeaders.forEach(function(e){var n=e.key,r=e.value;t.setRequestHeader(n,r)}),t}},{key:"runRequest",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",new Promise(function(a,i){e.onreadystatechange=function(){r.stateChangeHandlerForRequest(e,a,i)},t===Pt.Post||t===Pt.Put||t===Pt.Patch||t===Pt.Delete?e.send(JSON.stringify(n)):e.send()}));case 1:case"end":return a.stop()}},null,null,null,Promise)}},{key:"stateChangeHandlerForRequest",value:function(e,t,n){if(4===e.readyState){var r=e.status,a={status:r};try{if(r!==Te.b.HttpStatusNoContent){var i=JSON.parse(e.responseText);i.data||(a.data=i),w(a,i)}}catch(e){console.error(e)}r>=Te.b.HttpStatusMinSuccess&&r<=Te.b.HttpStatusMaxSuccess?t(a):(r===Te.b.HttpStatusForbidden?a.error={message:j.q,status:r}:Object(_.w)(a.error)&&(Object(_.w)(a.data)||Object(_.w)(a.data.error)?a.error={message:j.U,status:r}:a.error=a.data.error),n(a))}}},{key:"urlForUrlAndParams",value:function(e,t){var n=Object.keys(t).map(function(e){return e+'='+encodeURIComponent(t[e])}).join('&');return e.includes('?')?e+'&'+n:e+'?'+n}}]),n})(R.a),Tt=n(22),Kt=['api.standardnotes.com','api-dev.standardnotes.com','sync.standardnotes.org'],Ft=['api-dev.standardnotes.com','api.standardnotes.com','extensions.standardnotes.com','extensions.standardnotes.org','features.standardnotes.com'],Lt='localhost';function Ut(e){try{var t=new URL(e).host;return t.startsWith(Lt)||Kt.includes(t)}catch(e){return!1}}var Nt=['listed.to'];function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(n),!0).forEach(function(t){Wt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ht,zt={keyParams:'/v1/login-params',register:'/v1/users',signIn:'/v1/login',changeCredentials:function(e){return"/v1/users/".concat(e,"/attributes/credentials")},sync:'/v1/items',signOut:'/v1/logout',refreshSession:'/v1/sessions/refresh',sessions:'/v1/sessions',session:function(e){return"/v1/sessions/".concat(e)},itemRevisions:function(e){return"/v1/items/".concat(e,"/revisions")},itemRevision:function(e,t){return"/v1/items/".concat(e,"/revisions/").concat(t)},userFeatures:function(e){return"/v1/users/".concat(e,"/features")},settings:function(e){return"/v1/users/".concat(e,"/settings")},setting:function(e,t){return"/v1/users/".concat(e,"/settings/").concat(t)},subscription:function(e){return"/v1/users/".concat(e,"/subscription")},purchase:'/v1/purchase',subscriptionTokens:'/v1/subscription-tokens',offlineFeatures:'/v1/offline/features'},qt={subscriptions:'/v2/subscriptions'};!(function(e){e.MetaReceived="MetaReceived"})(Ht||(Ht={}));var Yt=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).httpService=e,i.storageService=r,i.host=a,i.registering=!1,i.authenticating=!1,i.changing=!1,i.refreshingSession=!1,i}return y(n,[{key:"deinit",value:function(){this.httpService=void 0,this.storageService=void 0,this.invalidSessionObserver=void 0,this.session=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"setInvalidSessionObserver",value:function(e){this.invalidSessionObserver=e}},{key:"loadHost",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ServerHost));case 2:e=t.sent,this.host=e||this.host||window._default_sync_server;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.host=e,t.next=3,b.awrap(this.storageService.setValue(o.ServerHost,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.host}},{key:"isThirdPartyHostUsed",value:function(){return!Ut(this.getHost()||'')}},{key:"setSession",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=!(n.length>1&&void 0!==n[1])||n[1],this.session=e,!t){r.next=5;break}return r.next=5,b.awrap(this.storageService.setValue(o.Session,e));case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getSession",value:function(){return this.session}},{key:"params",value:function(e){var t=Z()(e,g({},Tt.a.ApiVersion,this.apiVersion));return t}},{key:"createErrorResponse",value:function(e,t){return{error:{message:e,status:t}}}},{key:"errorResponseWithFallbackMessage",value:function(e,t){var n,r,a;null!==(n=e.error)&&void 0!==n&&n.message||(e.error=Bt(Bt({},e.error),{},{status:null!==(r=null===(a=e.error)||void 0===a?void 0:a.status)&&void 0!==r?r:Te.b.UnknownError,message:t}));return e}},{key:"processMetaObject",value:function(e){e.auth&&e.auth.userUuid&&e.auth.roles&&this.notifyEvent(Ht.MetaReceived,{userUuid:e.auth.userUuid,userRoles:e.auth.roles})}},{key:"processResponse",value:function(e){e.meta&&this.processMetaObject(e.meta)}},{key:"request",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,b.awrap(this.httpService.runHttp(e));case 3:return t=n.sent,this.processResponse(t),n.abrupt("return",t);case 8:return n.prev=8,n.t0=n.catch(0),n.abrupt("return",this.errorResponseWithFallbackMessage(n.t0,e.fallbackErrorMessage));case 11:case"end":return n.stop()}},null,this,[[0,8]],Promise)}},{key:"getAccountKeyParams",value:function(e,t,n){var r,a=this.params({email:e});return t&&n&&(a[t]=n),this.request({verb:Pt.Get,url:Object(_.D)(this.host,zt.keyParams),fallbackErrorMessage:j.k,params:a,authentication:null===(r=this.session)||void 0===r?void 0:r.authorizationValue})}},{key:"register",value:function(e,t,n,r){var a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(!this.registering){o.next=2;break}return o.abrupt("return",this.createErrorResponse(j.r));case 2:return this.registering=!0,a=Object(_.D)(this.host,zt.register),i=this.params(Bt({password:t,email:e,ephemeral:r},n.getPortableValue())),o.next=7,b.awrap(this.request({verb:Pt.Post,url:a,fallbackErrorMessage:j.l,params:i}));case 7:return s=o.sent,this.registering=!1,o.abrupt("return",s);case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t,n,r){var a,i,s,o,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=c.length>4&&void 0!==c[4]&&c[4],!this.authenticating){u.next=3;break}return u.abrupt("return",this.createErrorResponse(j.p));case 3:return this.authenticating=!0,i=Object(_.D)(this.host,zt.signIn),s=this.params({email:e,password:t,ephemeral:a}),n&&r&&(s[n]=r),u.next=9,b.awrap(this.request({verb:Pt.Post,url:i,params:s,fallbackErrorMessage:j.k}));case 9:return o=u.sent,this.authenticating=!1,u.abrupt("return",o);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e=Object(_.D)(this.host,zt.signOut);return this.httpService.postAbsolute(e,void 0,this.session.authorizationValue).catch(function(e){return e})}},{key:"changeCredentials",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.changing){s.next=2;break}return s.abrupt("return",this.createErrorResponse(j.a));case 2:if(!(t=this.preprocessingError())){s.next=5;break}return s.abrupt("return",t);case 5:return this.changing=!0,n=Object(_.D)(this.host,zt.changeCredentials(e.userUuid)),r=this.params(Bt({current_password:e.currentServerPassword,new_password:e.newServerPassword,new_email:e.newEmail},e.newKeyParams.getPortableValue())),s.next=10,b.awrap(this.httpService.putAbsolute(n,r,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Object(Te.c)(e)){t.next=2;break}return t.abrupt("return",i.refreshSessionThenRetryRequest({verb:Pt.Put,url:n,params:r}));case 2:return t.abrupt("return",i.errorResponseWithFallbackMessage(e,j.j));case 3:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return a=s.sent,this.processResponse(a),this.changing=!1,s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"sync",value:function(e,t,n,r){var a,i,s,o,c,u,l,p,d=this,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:if(i=h.length>4&&void 0!==h[4]&&h[4],s=h.length>5?h[5]:void 0,o=h.length>6?h[6]:void 0,!(c=this.preprocessingError())){f.next=6;break}return f.abrupt("return",c);case 6:return u=Object(_.D)(this.host,zt.sync),l=this.params((g(a={},Tt.a.SyncPayloads,e.map(function(e){return e.ejected()})),g(a,Tt.a.LastSyncToken,t),g(a,Tt.a.PaginationToken,n),g(a,Tt.a.IntegrityCheck,i),g(a,Tt.a.SyncDlLimit,r),g(a,"content_type",s),g(a,"event",o),a)),f.next=10,b.awrap(this.httpService.postAbsolute(u,l,this.session.authorizationValue).catch(function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(d.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){t.next=3;break}return t.abrupt("return",d.refreshSessionThenRetryRequest({verb:Pt.Post,url:u,params:l}));case 3:return t.abrupt("return",d.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return t.stop()}},null,null,null,Promise)}));case 10:return p=f.sent,this.processResponse(p),f.abrupt("return",p);case 13:case"end":return f.stop()}},null,this,null,Promise)}},{key:"refreshSessionThenRetryRequest",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.refreshSession());case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=7;break}return n.abrupt("return",t);case 7:return n.abrupt("return",this.httpService.runHttp(Bt(Bt({},e),{},{authentication:this.session.authorizationValue})).catch(function(e){return e}));case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"refreshSession",value:function(){var e,t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(e=this.preprocessingError())){s.next=3;break}return s.abrupt("return",e);case 3:return this.refreshingSession=!0,t=Object(_.D)(this.host,zt.refreshSession),n=this.session,r=this.params({access_token:n.accessToken,refresh_token:n.refreshToken}),s.next=9,b.awrap(this.httpService.postAbsolute(t,r).then(function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=je.FromApiResponse(e),n.next=3,b.awrap(i.setSession(t));case 3:return i.processResponse(e),n.abrupt("return",e);case 5:case"end":return n.stop()}},null,null,null,Promise)}).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),i.errorResponseWithFallbackMessage(e,j.n)}));case 9:return a=s.sent,this.refreshingSession=!1,s.abrupt("return",a);case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSessionsList",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e=this.preprocessingError())){a.next=3;break}return a.abrupt("return",e);case 3:return t=Object(_.D)(this.host,zt.sessions),a.next=6,b.awrap(this.httpService.getAbsolute(t,{},this.session.authorizationValue).catch(function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(r.preprocessAuthenticatedErrorResponse(e),!Object(Te.c)(e)){n.next=3;break}return n.abrupt("return",r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}));case 3:return n.abrupt("return",r.errorResponseWithFallbackMessage(e,j.m));case 4:case"end":return n.stop()}},null,null,null,Promise)}));case 6:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSession",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.session(e)),i.next=6,b.awrap(this.httpService.deleteAbsolute(n,{uuid:e},this.session.authorizationValue).catch(function(e){var t=e;return a.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?a.refreshSessionThenRetryRequest({verb:Pt.Delete,url:n}):a.errorResponseWithFallbackMessage(t,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getItemRevisions",value:function(e){var t,n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(t=this.preprocessingError())){i.next=3;break}return i.abrupt("return",t);case 3:return n=Object(_.D)(this.host,zt.itemRevisions(e)),i.next=6,b.awrap(this.httpService.getAbsolute(n,void 0,this.session.authorizationValue).catch(function(e){return a.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?a.refreshSessionThenRetryRequest({verb:Pt.Get,url:n}):a.errorResponseWithFallbackMessage(e,j.m)}));case 6:return r=i.sent,this.processResponse(r),i.abrupt("return",r);case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"getRevision",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(n=this.preprocessingError())){s.next=3;break}return s.abrupt("return",n);case 3:return r=Object(_.D)(this.host,zt.itemRevision(t,e.uuid)),s.next=6,b.awrap(this.httpService.getAbsolute(r,void 0,this.session.authorizationValue).catch(function(e){return i.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?i.refreshSessionThenRetryRequest({verb:Pt.Get,url:r}):i.errorResponseWithFallbackMessage(e,j.m)}));case 6:return a=s.sent,this.processResponse(a),s.abrupt("return",a);case 9:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getUserFeatures",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=Object(_.D)(this.host,zt.userFeatures(e)),a.next=3,b.awrap(this.httpService.getAbsolute(t,void 0,this.session.authorizationValue).catch(function(e){return r.preprocessAuthenticatedErrorResponse(e),Object(Te.c)(e)?r.refreshSessionThenRetryRequest({verb:Pt.Get,url:t}):r.errorResponseWithFallbackMessage(e,j.m)}));case 3:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"tokenRefreshableRequest",value:function(e){var t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(t=this.preprocessingError())){a.next=3;break}return a.abrupt("return",t);case 3:return a.next=5,b.awrap(this.httpService.runHttp(e).catch(function(t){return r.preprocessAuthenticatedErrorResponse(t),Object(Te.c)(t)?r.refreshSessionThenRetryRequest(e):r.errorResponseWithFallbackMessage(t,e.fallbackErrorMessage)}));case 5:return n=a.sent,this.processResponse(n),a.abrupt("return",n);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"listSettings",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.settings(e)),fallbackErrorMessage:j.d,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue}));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t,n,r){var a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return i={name:t,value:n,sensitive:r},s.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Put,url:Object(_.D)(this.host,zt.settings(e)),authentication:null===(a=this.session)||void 0===a?void 0:a.authorizationValue,fallbackErrorMessage:j.h,params:i}));case 2:case"end":return s.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.tokenRefreshableRequest({verb:Pt.Get,url:Object(_.D)(this.host,zt.setting(e,t.toLowerCase())),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.d}));case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.tokenRefreshableRequest({verb:Pt.Delete,url:Object(_.D)(this.host,zt.setting(e,t)),authentication:null===(n=this.session)||void 0===n?void 0:n.authorizationValue,fallbackErrorMessage:j.h}));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"downloadFeatureUrl",value:function(e){return this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.k})}},{key:"getSubscription",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscription(e)),a.next=3,b.awrap(this.request({verb:Pt.Get,url:n,authentication:null===(t=this.session)||void 0===t?void 0:t.authorizationValue,fallbackErrorMessage:j.g}));case 3:return r=a.sent,a.abrupt("return",r);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=Object(_.D)(this.host,qt.subscriptions),n.next=3,b.awrap(this.request({verb:Pt.Get,url:e,fallbackErrorMessage:j.g}));case 3:return t=n.sent,n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getNewSubscriptionToken",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=Object(_.D)(this.host,zt.subscriptionTokens),a.next=3,b.awrap(this.request({verb:Pt.Post,url:n,authentication:null===(e=this.session)||void 0===e?void 0:e.authorizationValue,fallbackErrorMessage:j.b}));case 3:return r=a.sent,a.abrupt("return",null===(t=r.data)||void 0===t?void 0:t.token);case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"downloadOfflineFeaturesFromRepo",value:function(e){var t,n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,n=e.offlineFeaturesUrl,r=e.offlineKey,a=new URL(n),i=a.host,Ft.includes(i)){o.next=6;break}return o.abrupt("return",{error:'This offline features host is not in the trusted allowlist.'});case 6:return o.next=8,b.awrap(this.request({verb:Pt.Get,url:n,fallbackErrorMessage:j.f,customHeaders:[{key:'x-offline-token',value:r}]}));case 8:return s=o.sent,o.abrupt("return",{features:(null===(t=s.data)||void 0===t?void 0:t.features)||[]});case 12:return o.prev=12,o.t0=o.catch(0),o.abrupt("return",{error:j.e});case 15:case"end":return o.stop()}},null,this,[[0,12]],Promise)}},{key:"preprocessingError",value:function(){return this.refreshingSession?this.createErrorResponse(j.s):this.session?void 0:this.createErrorResponse(j.o)}},{key:"preprocessAuthenticatedErrorResponse",value:function(e){var t,n;e.status===Te.b.HttpStatusInvalidSession&&this.session&&(null===(t=this.invalidSessionObserver)||void 0===t||t.call(this,(null===(n=e.error)||void 0===n?void 0:n.tag)===Ot.RevokedSession))}},{key:"apiVersion",get:function(){return"20200115"}}]),n})(R.a),Gt=n(25),Qt=n.n(Gt),Jt=n(28),$t=n.n(Jt);function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach(function(t){en(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function en(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tn,nn=Object.freeze([F.a.ActionsExtension,F.a.Component,F.a.Editor,F.a.ExtensionRepo,F.a.FilesafeCredentials,F.a.FilesafeFileMetadata,F.a.FilesafeIntegration,F.a.ServerExtension,F.a.SmartTag,F.a.Tag,F.a.Theme]),rn='org.standardnotes.sn.components';!(function(e){e.Shift="Shift",e.Ctrl="Control",e.Meta="Meta"})(tn||(tn={}));var an=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).componentState={},c.streamObservers=[],c.contextStreamObservers=[],c.permissionDialogs=[],c.handlers=[],c.templateComponents=[],c.detectFocusChange=function(){for(var e,t=function(e){if(document.activeElement===e)return c.timeout(function(){for(var t,n=c.findComponent(e.dataset.componentId),r=S(c.handlers);!(t=r()).done;){var a=t.value;a.focusHandler&&a.focusHandler(n,!0)}}),"break"},n=S(c.allComponentIframes());!(e=n()).done;){if("break"===t(e.value))break}},c.onWindowMessage=function(e){e.data.sessionKey&&(c.log('Component manager received message',e.data),c.handleMessage(c.componentForSessionKey(e.data.sessionKey),e.data))},c.timeout=o||setTimeout.bind(window),c.itemManager=e,c.syncService=r,c.alertService=a,c.environment=i,c.platform=s,c.configureForGeneralUsage(),i!==he.Mobile&&c.configureForNonMobileUsage(),c}return y(n,[{key:"componentsForArea",value:function(e){return this.components.filter(function(t){return t.area===e})}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.streamObservers.length=0,this.contextStreamObservers.length=0,this.permissionDialogs.length=0,this.templateComponents.length=0,this.handlers.length=0,this.itemManager=void 0,this.syncService=void 0,this.alertService=void 0,this.removeItemObserver(),this.removeItemObserver=null,window&&!this.isMobile&&(window.removeEventListener('focus',this.detectFocusChange,!0),window.removeEventListener('blur',this.detectFocusChange,!0),window.removeEventListener('message',this.onWindowMessage))}},{key:"setDesktopManager",value:function(e){this.desktopManager=e,this.configureForDesktop()}},{key:"configureForGeneralUsage",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n,r,a,i,s){var o=Object(_.h)(t,n,r),c=o.filter(function(e){return e.content_type===F.a.Component||e.content_type===F.a.Theme});c.length>0&&i!==ht.a.RemoteSaved&&e.isDesktop&&e.desktopManager.syncComponentsInstallation(c),c.filter(function(e){return e.isTheme()}).length>0&&e.postActiveThemesToAllComponents();for(var u,l=S(c);!(u=l()).done;){var p=u.value;if(!p.isEditor()){var d=!!e.iframeForComponent(p.uuid);!p.active&&d&&e.deactivateComponent(p.uuid)}}e.notifyStreamObservers(o,i,s)})}},{key:"notifyStreamObservers",value:function(e,t,n){for(var r,a=this,i=function(t){if(n&&n===t.componentUuid)return"continue";var r=e.filter(function(e){return-1!==t.contentTypes.indexOf(e.content_type)});if(0===r.length)return"continue";var i=[{name:E.StreamItems,content_types:t.contentTypes.sort()}];a.runWithPermissions(t.componentUuid,i,function(){a.sendItemsInReply(t.componentUuid,r,t.originalMessage)})},s=S(this.streamObservers);!(r=s()).done;)i(r.value);for(var o,c=[{name:E.StreamContextItem}],u=function(r){if(n&&n===r.componentUuid)return"continue";for(var i,s=S(a.handlers);!(i=s()).done;){var o=i.value;if((o.areas.includes(r.area)||o.areas.includes(L.ComponentArea.Any))&&o.contextRequestHandler){var u=o.contextRequestHandler(r.componentUuid);if(u)if("continue"===(function(){var n=Qt()(e,{uuid:u.uuid});if(n){if(n.deleted)return"continue";a.runWithPermissions(r.componentUuid,c,function(){a.sendContextItemInReply(r.componentUuid,n,r.originalMessage,t)})}})())continue}}},l=S(this.contextStreamObservers);!(o=l()).done;)u(o.value)}},{key:"isNativeExtension",value:function(e){var t=[window._extensions_manager_location],n=e.hosted_url,r=e.local_url&&e.local_url.replace("sn://",'');return t.includes(n)||t.includes(r)}},{key:"configureForNonMobileUsage",value:function(){window.addEventListener?window.addEventListener('focus',this.detectFocusChange,!0):window.attachEvent('onfocusout',this.detectFocusChange),window.addEventListener?window.addEventListener('blur',this.detectFocusChange,!0):window.attachEvent('onblur',this.detectFocusChange),window.addEventListener('message',this.onWindowMessage)}},{key:"configureForDesktop",value:function(){var e=this;this.desktopManager.registerUpdateObserver(function(t){t.active&&t.isTheme()&&e.postActiveThemesToAllComponents()})}},{key:"postActiveThemesToAllComponents",value:function(){for(var e,t=S(this.components);!(e=t()).done;){var n=e.value;this.findOrCreateDataForComponent(n.uuid).window&&this.postActiveThemesToComponent(n)}}},{key:"getActiveThemes",value:function(){if(this.environment===he.Mobile)throw Error('getActiveThemes must be handled separately by mobile');return this.componentsForArea(L.ComponentArea.Themes).filter(function(e){return e.active})}},{key:"urlsForActiveThemes",value:function(){for(var e,t=[],n=S(this.getActiveThemes());!(e=n()).done;){var r=e.value,a=this.urlForComponent(r);a&&t.push(a)}return t}},{key:"postActiveThemesToComponent",value:function(e){var t={themes:this.urlsForActiveThemes()},n={action:E.ActivateThemes,data:t};this.sendMessageToComponent(e,n)}},{key:"findComponent",value:function(e){return this.templateComponents.find(function(t){return t.uuid===e})||this.itemManager.findItem(e)}},{key:"addTemporaryTemplateComponent",value:function(e){this.templateComponents.push(e)}},{key:"removeTemporaryTemplateComponent",value:function(e){this.templateComponents=this.templateComponents.filter(function(t){return t.uuid!==e.uuid})}},{key:"contextItemDidChangeInArea",value:function(e){for(var t,n=S(this.handlers);!(t=n()).done;){var r=t.value;if(r.areas.includes(e)||r.areas.includes(L.ComponentArea.Any))for(var a,i=S(this.contextStreamObservers.filter(function(t){return t.area===e}));!(a=i()).done;){var s=a.value;if(r.contextRequestHandler){var o=r.contextRequestHandler(s.componentUuid);o&&this.sendContextItemInReply(s.componentUuid,o,s.originalMessage)}}}}},{key:"isComponentHidden",value:function(e){return!0===this.findOrCreateDataForComponent(e.uuid).hidden}},{key:"setComponentHidden",value:function(e,t){var n=this.findOrCreateDataForComponent(e.uuid);if(t)n.hidden=!0;else if(n.hidden){n.hidden=!1;var r=Qt()(this.contextStreamObservers,{identifier:e.uuid});r&&this.handleStreamContextItemMessage(e,r.originalMessage);var a=Qt()(this.streamObservers,{identifier:e.uuid});a&&this.handleStreamItemsMessage(e,a.originalMessage)}}},{key:"jsonForItem",value:function(e,t,n){var r=n===ht.a.RemoteSaved||n===ht.a.LocalSaved||n===ht.a.PreSyncSave,a=(e.getDomainData(rn)||{})[t.getClientDataKey()]||{},i={uuid:e.uuid,content_type:e.content_type,created_at:e.created_at,updated_at:e.serverUpdatedAt,deleted:e.deleted,isMetadataUpdate:r,content:e.content,clientData:a};return this.responseItemsByRemovingPrivateProperties([i],t)[0]}},{key:"sendItemsInReply",value:function(e,t,n,r){var a=this,i=this.findComponent(e);this.log('Component manager send items in reply',i,t,n);var s={},o=t.map(function(e){return a.jsonForItem(e,i,r)});s.items=o,this.replyToMessage(i,n,s)}},{key:"sendContextItemInReply",value:function(e,t,n,r){var a=this.findComponent(e);this.log('Component manager send context item in reply','component:',a,'item: ',t,'originalMessage: ',n);var i={item:this.jsonForItem(t,a,r)};this.replyToMessage(a,n,i)}},{key:"replyToMessage",value:function(e,t,n){var r={action:E.Reply,original:t,data:n};this.sendMessageToComponent(e,r)}},{key:"sendMessageToComponent",value:function(e,t){var n,r=[E.ComponentRegistered,E.ActivateThemes],a=this.findOrCreateDataForComponent(e.uuid);if(!a.hidden||r.includes(t.action))if(a.window||t.action!==E.Reply){this.log('Component manager send message to component',e,'message: ',t);var i=this.urlForComponent(e);i&&a.window?(i.startsWith('http')||i.startsWith('file')||(i=window.location.href+i),null===(n=a.window)||void 0===n||n.postMessage(this.isMobile?JSON.stringify(t):t,i)):this.alertService.alert("Standard Notes is trying to communicate with ".concat(e.name,", ")+'but an error is occurring. Please restart this extension and try again.')}else this.log('Component has been deallocated in between message send and reply',e,t);else this.log('Component disabled for current item, ignoring messages.',e.name)}},{key:"urlForComponent",value:function(e){if(e.offlineOnly&&!this.isDesktop)return null;if(e.offlineOnly||this.isDesktop&&e.local_url)return e.local_url&&e.local_url.replace("sn://",this.desktopManager.getExtServerHost());var t=e.hosted_url||e.legacy_url;if(!t)return null;if(this.isMobile){var n=this.platform===fe.Ios?"localhost":"10.0.2.2";t=t.replace("localhost",n).replace("sn.local",n)}return t}},{key:"componentForUrl",value:function(e){return this.components.filter(function(t){return t.hosted_url===e||t.legacy_url===e})[0]}},{key:"sessionKeyForComponent",value:function(e){return this.findOrCreateDataForComponent(e.uuid).sessionKey}},{key:"componentForSessionKey",value:function(e){for(var t,n=this,r=function(r){var a=n.componentState[r];if((null===a||void 0===a?void 0:a.sessionKey)===e)return t=n.components.find(function(e){return e.uuid===r}),"break"},a=0,i=Object.keys(this.componentState);a<i.length;a++){if("break"===r(i[a]))break}if(!t)for(var s,o=S(this.handlers);!(s=o()).done;){var c=s.value;if(c.componentForSessionKeyHandler&&(t=c.componentForSessionKeyHandler(e)))break}return t}},{key:"handleMessage",value:function(e,t){var n=this;if(!e)return this.log('Component not defined for message, returning',t),void this.alertService.alert("An extension is trying to communicate with Standard Notes, but there is an error establishing a bridge. Please restart the app and try again.");var r=[E.SaveItems,E.AssociateItem,E.DeassociateItem,E.CreateItem,E.CreateItems,E.DeleteItems,E.SetComponentData];if(this.getReadonlyStateForComponent(e).readonly&&r.includes(t.action))this.alertService.alert("The extension ".concat(e.name," is trying to save, but it is in a locked state and cannot accept changes."));else{if(t.action===E.StreamItems)this.handleStreamItemsMessage(e,t);else if(t.action===E.StreamContextItem)this.handleStreamContextItemMessage(e,t);else if(t.action===E.SetComponentData)this.handleSetComponentDataMessage(e,t);else if(t.action===E.DeleteItems)this.handleDeleteItemsMessage(e,t);else if(t.action===E.CreateItems||t.action===E.CreateItem)this.handleCreateItemsMessage(e,t);else if(t.action===E.SaveItems)this.handleSaveItemsMessage(e,t);else if(t.action===E.ToggleActivateComponent){var a=this.itemManager.findItem(t.data.uuid);this.handleToggleComponentMessage(a)}else t.action===E.RequestPermissions?this.handleRequestPermissionsMessage(e,t):t.action===E.InstallLocalComponent?this.handleInstallLocalComponentMessage(e,t):t.action===E.DuplicateItem&&this.handleDuplicateItemMessage(e,t);for(var i,s=function(r){r.actionHandler&&(r.areas.includes(e.area)||r.areas.includes(L.ComponentArea.Any))&&n.timeout(function(){r.actionHandler(e,t.action,t.data)})},o=S(this.handlers);!(i=o()).done;){s(i.value)}}}},{key:"responseItemsByRemovingPrivateProperties",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&this.isNativeExtension(t))return e;var r=['autoupdateDisabled','permissions','active'];return n&&(r=r.concat(['hosted_url','local_url'])),e.map(function(e){var t=r.slice();if(n&&e.content_type!==F.a.ServerExtension&&t.push('url'),!e.content||Object(_.A)(e.content))return e;for(var a={},i=0,s=Object.entries(e.content);i<s.length;i++){var o=s[i],c=l(o,2),u=c[0],p=c[1];t.includes(u)||(a[u]=p)}return Zt(Zt({},e),{},{content:a})})}},{key:"handleStreamItemsMessage",value:function(e,t){var n=this,r=t.data.content_types.filter(function(e){return nn.includes(e)}).sort(),a=[{name:E.StreamItems,content_types:r}];this.runWithPermissions(e.uuid,a,function(){Qt()(n.streamObservers,{identifier:e.uuid})||n.streamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t,contentTypes:r});for(var a,i=[],s=S(r);!(a=s()).done;){var o=a.value;Object(_.o)(i,n.itemManager.nonErroredItemsForContentType(o))}n.sendItemsInReply(e.uuid,i,t)})}},{key:"handleStreamContextItemMessage",value:function(e,t){var n=this,r=[{name:E.StreamContextItem}];this.runWithPermissions(e.uuid,r,function(){Qt()(n.contextStreamObservers,{identifier:e.uuid})||n.contextStreamObservers.push({identifier:e.uuid,componentUuid:e.uuid,area:e.area,originalMessage:t});for(var r,a=S(n.handlersForArea(e.area));!(r=a()).done;){var i=r.value;if(i.contextRequestHandler){var s=i.contextRequestHandler(e.uuid);s&&n.sendContextItemInReply(e.uuid,s,t)}}})}},{key:"isItemIdWithinComponentContextJurisdiction",value:function(e,t){return this.itemIdsInContextJurisdictionForComponent(t).includes(e)}},{key:"itemIdsInContextJurisdictionForComponent",value:function(e){for(var t,n=[],r=S(this.handlersForArea(e.area));!(t=r()).done;){var a=t.value;if(a.contextRequestHandler){var i=a.contextRequestHandler(e.uuid);i&&n.push(i.uuid)}}return n}},{key:"handlersForArea",value:function(e){return this.handlers.filter(function(t){return t.areas.includes(e)})}},{key:"handleSaveItemsMessage",value:function(e,t){for(var n,r=this,a=t.data.items,i=[],s=this.itemIdsInContextJurisdictionForComponent(e),o=a.slice(),c=S(a.slice());!(n=c()).done;){var u=n.value;if(s.includes(u.uuid)){i.push({name:E.StreamContextItem}),Object(_.M)(o,u);break}}if(o.length>0){var l=$t()(o.map(function(e){return e.content_type})).sort();i.push({name:E.StreamItems,content_types:l})}this.runWithPermissions(e.uuid,i,function(){var n,i,s,o,c,u,l,p,d,h,f,v,y,g,m;return b.async(function(k){for(;;)switch(k.prev=k.next){case 0:a=r.responseItemsByRemovingPrivateProperties(a,e,!0),n=Object(Ke.b)(a),i=r.itemManager.findItems(n,!0),s=0,o=0,c=S(i);case 6:if((u=c()).done){k.next=13;break}if(l=u.value){k.next=10;break}return k.abrupt("continue",11);case 10:l.locked&&(at()(a,{uuid:l.uuid}),s++,l.content_type===F.a.Note&&o++);case 11:k.next=6;break;case 13:if(1!==o){k.next=18;break}return r.alertService.alert('The note you are attempting to save has editing disabled','Note has Editing Disabled'),k.abrupt("return");case 18:if(!(s>0)){k.next=23;break}return p=1===s?'item':o===s?'notes':'items',d=1===s?'has':'have',r.alertService.alert("".concat(s," ").concat(p," you are attempting to save ").concat(d," editing disabled."),'Items have Editing Disabled'),k.abrupt("return");case 23:h=a.map(function(e){return Object(Ee.f)(e,ht.a.ComponentRetrieved)}),f=S(h);case 25:if((v=f()).done){k.next=38;break}if(y=v.value,g=r.itemManager.findItem(y.uuid)){k.next=34;break}return m=nt(y),k.next=32,b.awrap(r.itemManager.insertItem(m));case 32:k.next=36;break;case 34:if(y.content_type===g.content_type){k.next=36;break}throw Error('Extension is trying to modify content type of item.');case 36:k.next=25;break;case 38:return k.next=40,b.awrap(r.itemManager.changeItems(n,function(t){var n=Object(_.O)(h,{uuid:t.getUuid()});t.mergePayload(n);var r=Object(_.O)(a,{uuid:t.getUuid()});if(r.clientData){var i=Object(_.a)(t.getItem().getDomainData(rn)||{});i[e.getClientDataKey()]=r.clientData,t.setDomainData(i,rn)}},T.c.UserInteraction,ht.a.ComponentRetrieved,e.uuid));case 40:r.syncService.sync().then(function(){var n=w({},t);n.action=E.SaveSuccess,r.replyToMessage(e,t,{}),r.handleMessage(e,n)}).catch(function(){var n=w({},t);n.action=E.SaveError,r.replyToMessage(e,t,{error:E.SaveError}),r.handleMessage(e,n)});case 41:case"end":return k.stop()}},null,null,null,Promise)})}},{key:"handleDuplicateItemMessage",value:function(e,t){var n=this,r=t.data.item,a=this.itemManager.findItem(r.uuid),i=[{name:E.StreamItems,content_types:[a.content_type]}];this.runWithPermissions(e.uuid,i,function(){var r;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(n.itemManager.duplicateItem(a.uuid));case 2:r=i.sent,n.syncService.sync(),n.replyToMessage(e,t,{item:n.jsonForItem(r,e)});case 5:case"end":return i.stop()}},null,null,null,Promise)})}},{key:"handleCreateItemsMessage",value:function(e,t){var n=this,r=t.data.item?[t.data.item]:t.data.items,a=$t()(r.map(function(e){return e.content_type})),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:r=n.responseItemsByRemovingPrivateProperties(r,e),a=[],i=function(t){var r,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(t.uuid){o.next=4;break}return o.next=3,b.awrap(I.GenerateUuid());case 3:t.uuid=o.sent;case 4:return r=Object(Ee.f)(t,ht.a.ComponentCreated),i=nt(r),o.next=8,b.awrap(n.itemManager.insertItem(i));case 8:return s=o.sent,o.next=11,b.awrap(n.itemManager.changeItem(s.uuid,function(n){if(t.clientData){var r=Object(_.a)(s.getDomainData(rn)||{});r[e.getClientDataKey()]=t.clientData,n.setDomainData(r,rn)}},T.c.UserInteraction,ht.a.ComponentCreated,e.uuid));case 11:a.push(s);case 12:case"end":return o.stop()}},null,null,null,Promise)},s=S(r);case 4:if((o=s()).done){l.next=10;break}return c=o.value,l.next=8,b.awrap(i(c));case 8:l.next=4;break;case 10:n.syncService.sync(),u=t.action===E.CreateItem?{item:n.jsonForItem(a[0],e)}:{items:a.map(function(t){return n.jsonForItem(t,e)})},n.replyToMessage(e,t,u);case 13:case"end":return l.stop()}},null,null,null,Promise)})}},{key:"handleDeleteItemsMessage",value:function(e,t){var n=this,r=t.data.items.filter(function(e){return nn.includes(e.content_type)}),a=$t()(r.map(function(e){return e.content_type})).sort(),i=[{name:E.StreamItems,content_types:a}];this.runWithPermissions(e.uuid,i,function(){var a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return i=1===(a=r).length?'item':'items',s=null,p.next=5,b.awrap(n.alertService.confirm("Are you sure you want to delete ".concat(a.length," ").concat(i,"?")));case 5:if(!p.sent){p.next=25;break}o=S(a);case 8:if((c=o()).done){p.next=21;break}if(u=c.value,l=n.itemManager.findItem(u.uuid)){p.next=14;break}return n.alertService.alert('The item you are trying to delete cannot be found.'),p.abrupt("continue",19);case 14:if(![F.a.Component,F.a.Theme].includes(l.content_type)){p.next=17;break}return p.next=17,b.awrap(n.deactivateComponent(l.uuid));case 17:return p.next=19,b.awrap(n.itemManager.setItemToBeDeleted(l.uuid,ht.a.ComponentRetrieved));case 19:p.next=8;break;case 21:n.syncService.sync(),s={deleted:!0},p.next=26;break;case 25:s={deleted:!1};case 26:n.replyToMessage(e,t,s);case 27:case"end":return p.stop()}},null,null,null,Promise)})}},{key:"handleRequestPermissionsMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,t.data.permissions,function(){n.replyToMessage(e,t,{approved:!0})})}},{key:"handleSetComponentDataMessage",value:function(e,t){var n=this;this.runWithPermissions(e.uuid,[],function(){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(n.itemManager.changeComponent(e.uuid,function(e){e.componentData=t.data.componentData}));case 2:n.syncService.sync();case 3:case"end":return r.stop()}},null,null,null,Promise)})}},{key:"handleToggleComponentMessage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.toggleComponent(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"toggleComponent",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.area!==L.ComponentArea.Modal){s.next=4;break}this.openModalComponent(e),s.next=29;break;case 4:if(!e.active){s.next=9;break}return s.next=7,b.awrap(this.deactivateComponent(e.uuid));case 7:s.next=29;break;case 9:if(e.content_type!==F.a.Theme){s.next=27;break}return t=e,n=this.getActiveThemes(),s.next=14,b.awrap(this.activateComponent(e.uuid));case 14:if(t.isLayerable()){s.next=25;break}return s.next=17,b.awrap(Object(_.P)(10));case 17:r=S(n);case 18:if((a=r()).done){s.next=25;break}if(!(i=a.value)||i.isLayerable()){s.next=23;break}return s.next=23,b.awrap(this.deactivateComponent(i.uuid));case 23:s.next=18;break;case 25:s.next=29;break;case 27:return s.next=29,b.awrap(this.activateComponent(e.uuid));case 29:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleInstallLocalComponentMessage",value:function(e,t){if(this.isNativeExtension(e)){var n=this.itemManager.findItem(t.data.uuid);this.desktopManager.installComponent(n)}}},{key:"runWithPermissions",value:function(e,t,n){var r=this.findComponent(e);t=Object(_.a)(t);for(var a,i=r.permissions,s=function(e){var n=i.find(function(t){return t.name===e.name});if(!n)return"continue";var r=e.content_types;if(!r)return Object(_.p)(t,e),"continue";for(var a,s=S(n.content_types);!(a=s()).done;){var o=a.value;Object(_.M)(r,o)}0===r.length&&Object(_.p)(t,e)},o=S(t.slice());!(a=o()).done;)s(a.value);t.length>0?this.promptForPermissions(r,t,function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:e&&n();case 1:case"end":return t.stop()}},null,null,null,Promise)}):n()}},{key:"promptForPermissions",value:function(e,t,n){var r=this,a={component:e,permissions:t,permissionsString:this.permissionsStringForPermissions(t,e),actionBlock:n,callback:function(n){var i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(i=r.findComponent(e.uuid),!n){p.next=9;break}for(r.log('Changing component to expand permissions',e),s=Object(_.a)(i.permissions),o=function(e){var t=s.find(function(t){return t.name===e.name});if(t){var n=t.content_types||[];t.content_types=$t()(n.concat(e.content_types))}else s.push(e)},c=S(t);!(u=c()).done;)l=u.value,o(l);return p.next=8,b.awrap(r.itemManager.changeItem(e.uuid,function(e){e.permissions=s}));case 8:r.syncService.sync();case 9:r.permissionDialogs=r.permissionDialogs.filter(function(r){if(r===a)return r.actionBlock&&r.actionBlock(n),!1;var i;return!!(r.component!==e||r.permissions!==t&&(i=t,r.permissions.some(function(e){return!i.find(function(t){return JSON.stringify(t)===JSON.stringify(e)})})))||(n&&r.actionBlock&&r.actionBlock(n),!1)}),r.permissionDialogs.length>0&&r.presentPermissionsDialog(r.permissionDialogs[0]);case 11:case"end":return p.stop()}},null,null,null,Promise)}},i=Qt()(this.permissionDialogs,{component:e});this.permissionDialogs.push(a),i?this.log('Existing dialog, not presenting.'):this.presentPermissionsDialog(a)}},{key:"presentPermissionsDialog",value:function(e){throw'Must override SNComponentManager.presentPermissionsDialog'}},{key:"openModalComponent",value:function(e){throw'Must override SNComponentManager.openModalComponent'}},{key:"registerHandler",value:function(e){var t=this;return this.handlers.push(e),function(){var n=Qt()(t.handlers,{identifier:e.identifier});n?Object(_.M)(t.handlers,n):t.log('Attempting to deregister non-existing handler')}}},{key:"findOrCreateDataForComponent",value:function(e){var t=this.componentState[e];return t||(t={},this.componentState[e]=t),t}},{key:"setReadonlyStateForComponent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.findOrCreateDataForComponent(e.uuid);r.readonly=t,r.lockReadonly=n}},{key:"getReadonlyStateForComponent",value:function(e){var t=this.findOrCreateDataForComponent(e.uuid);return{readonly:t.readonly,lockReadonly:t.lockReadonly}}},{key:"registerComponentWindow",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return(n=this.findOrCreateDataForComponent(e.uuid)).window===t&&this.log('Web > componentManager','attempting to re-register same component window.'),this.log('Web > componentManager > registerComponentWindow','component: ',e,'window: ',t),n.window=t,r.next=6,b.awrap(I.GenerateUuid());case 6:n.sessionKey=r.sent,this.sendMessageToComponent(e,{action:E.ComponentRegistered,sessionKey:n.sessionKey,componentData:e.componentData,data:{uuid:e.uuid,environment:(s=this.environment,o=void 0,(g(o={},he.Web,'web'),g(o,he.Desktop,'desktop'),g(o,he.Mobile,'mobile'),o)[s]),platform:(a=this.platform,i=void 0,(g(i={},fe.MacWeb,'mac-web'),g(i,fe.MacDesktop,'mac-desktop'),g(i,fe.LinuxWeb,'linux-web'),g(i,fe.LinuxDesktop,'linux-desktop'),g(i,fe.WindowsWeb,'windows-web'),g(i,fe.WindowsDesktop,'windows-desktop'),g(i,fe.Ios,'ios'),g(i,fe.Android,'android'),i)[a]),activeThemeUrls:this.urlsForActiveThemes()}}),this.postActiveThemesToComponent(e),this.desktopManager&&this.desktopManager.notifyComponentActivation(e);case 10:case"end":return r.stop()}var a,i,s,o},null,this,null,Promise)}},{key:"activateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Activating component',e),(t=this.findComponent(e)).active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!0}));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"onComponentIframeDestroyed",value:function(e){this.deregisterComponent(e)}},{key:"deregisterComponent",value:function(e){this.log('Degregistering component',e),delete this.componentState[e],this.streamObservers=this.streamObservers.filter(function(t){return t.componentUuid!==e}),this.contextStreamObservers=this.contextStreamObservers.filter(function(t){return t.componentUuid!==e});var t=this.findComponent(e);(null===t||void 0===t?void 0:t.area)===L.ComponentArea.Themes&&this.postActiveThemesToAllComponents()}},{key:"deactivateComponent",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.log('Deactivating component',e),null===(t=this.findComponent(e))||void 0===t||!t.active){n.next=5;break}return n.next=5,b.awrap(this.itemManager.changeComponent(t.uuid,function(e){e.active=!1}));case 5:this.findOrCreateDataForComponent(e).sessionKey=void 0,this.deregisterComponent(e);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deleteComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e));case 2:this.syncService.sync();case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isComponentActive",value:function(e){return e.active}},{key:"allComponentIframes",value:function(){return this.isMobile?[]:Array.from(document.getElementsByTagName('iframe'))}},{key:"iframeForComponent",value:function(e){for(var t,n=S(this.allComponentIframes());!(t=n()).done;){var r=t.value;if(r.dataset.componentId===e)return r}}},{key:"handleSetSizeEvent",value:function(e,t){var n=function(e,n){var r=Object(_.A)(n.width)?n.width:"".concat(t.width,"px"),a=Object(_.A)(n.height)?n.height:"".concat(t.height,"px");e&&e.setAttribute('style',"width:".concat(r,"; height:").concat(a,";"))};if(e.area===L.ComponentArea.Rooms||e.area===L.ComponentArea.Modal){var r=e.area===L.ComponentArea.Rooms?'inner':'outer',a=document.getElementById("component-content-".concat(r,"-").concat(e.uuid));a&&n(a,t)}else{var i=this.iframeForComponent(e.uuid);if(!i)return;if(n(i,t),e.area===L.ComponentArea.EditorStack){var s=i.parentElement;s&&n(s,t)}}}},{key:"editorForNote",value:function(e){for(var t,n,r=S(this.componentsForArea(L.ComponentArea.Editor));!(t=r()).done;){var a=t.value;if(a.isExplicitlyEnabledForItem(e.uuid))return a}return this.isMobile?e.mobilePrefersPlainEditor||(n=this.getDefaultEditor()):e.prefersPlainEditor||(n=this.getDefaultEditor()),n&&!n.isExplicitlyDisabledForItem(e.uuid)?n:void 0}},{key:"getDefaultEditor",value:function(){var e=this.componentsForArea(L.ComponentArea.Editor);return this.isMobile?e.filter(function(e){return e.isMobileDefault})[0]:e.filter(function(e){return e.isDefaultEditor()})[0]}},{key:"permissionsStringForPermissions",value:function(e,t){if(0===e.length)return'.';var n=[],r=[];return e.forEach(function(e){switch(e.name){case E.StreamItems:if(!e.content_types)return;e.content_types.forEach(function(e){var t=Object(F.c)(e);t?n.push("".concat(t,"s")):n.push("items of type ".concat(e))});break;case E.StreamContextItem:var a,i=(g(a={},L.ComponentArea.EditorStack,'working note'),g(a,L.ComponentArea.NoteTags,'working note'),g(a,L.ComponentArea.Editor,'working note'),a);r.push(i[t.area])}}),n=$t()(n),r=$t()(r),0===n.length&&0===r.length?'.':n.concat(r).join(', ')+'.'}},{key:"isDesktop",get:function(){return this.environment===he.Desktop}},{key:"isMobile",get:function(){return this.environment===he.Mobile}},{key:"components",get:function(){var e=this.itemManager.getDisplayableItems(F.a.Component),t=this.itemManager.getDisplayableItems(F.a.Theme);return e.concat(t)}}]),n})(R.a),sn=(function(e){d(n,e);var t=k(n);function n(){var e;return v(this,n),(e=t.call(this)).changeObservers=[],e.emitQueue=[],e.overwriteProtection=[F.a.ItemsKey],e.collection=new mt,e}return y(n,[{key:"getMasterCollection",value:function(){return bt.FromCollection(this.collection)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.changeObservers.length=0,this.resetState()}},{key:"resetState",value:function(){this.collection=new mt}},{key:"find",value:function(e){return this.collection.findAll(e)}},{key:"emitCollection",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.emitPayloads(e.all(),e.source,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"emitPayload",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.emitPayloads([e],t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitPayloads",value:function(e,t,n){var r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return 0===e.length&&console.warn('Attempting to emit 0 payloads.'),a.abrupt("return",new Promise(function(a){r.emitQueue.push({payloads:e,source:t,sourceKey:n,resolve:a}),1===r.emitQueue.length&&r.popQueue()}));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"popQueue",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=this.emitQueue[0],t=this.mergePayloadsOntoMaster(e.payloads),n=t.changed,r=t.inserted,a=t.discarded,i=t.ignored,this.notifyChangeObservers(n,r,a,i,e.source,e.sourceKey),Object(_.M)(this.emitQueue,e),e.resolve(n.concat(r,a)),this.emitQueue.length>0&&this.popQueue();case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"mergePayloadsOntoMaster",value:function(e){for(var t,n=[],r=[],a=[],i=[],s=S(e);!(t=s()).done;){var o=t.value;if(o.uuid&&o.content_type){var c=this.collection.find(o.uuid);if(o.errorDecrypting&&c&&!c.errorDecrypting&&this.overwriteProtection.includes(o.content_type))i.push(o);else{var u=c?Object(Ee.g)(c,o):o;u.discardable?(this.collection.discard(u),a.push(u)):(this.collection.set(u),c?n.push(u):r.push(u))}}else console.error('Payload is corrupt:',o)}return{changed:n,inserted:r,discarded:a,ignored:i}}},{key:"addObserver",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;Array.isArray(e)||(e=[e]);var a={types:e,priority:r,callback:t};return this.changeObservers.push(a),function(){Object(_.M)(n.changeObservers,a)}}},{key:"notifyChangeObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return t.includes(F.a.Any)?e.slice():e.slice().filter(function(e){return t.includes(e.content_type)})},c=S(this.changeObservers.slice().sort(function(e,t){return e.priority<t.priority?-1:1}));!(s=c()).done;){var u=s.value;u.callback(o(e,u.types),o(t,u.types),o(n,u.types),o(r,u.types),a,i)}}},{key:"importPayloads",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new Dt(this.getMasterCollection(),bt.WithPayloads(e,ht.a.FileImport),void 0),r.next=3,b.awrap(t.resultingCollection());case 3:return n=r.sent,r.next=6,b.awrap(this.emitCollection(n));case 6:return r.abrupt("return",Object(Ke.b)(n.payloads));case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removePayloadLocally",value:function(e){this.collection.discard(e)}}]),n})(R.a),on=n(9),cn=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).itemManager=e,a.syncService=r,a.resolveQueue=[],a.registeredPredicates=[],a.itemManager=e,a.syncService=r,a.addObservers(),a}return y(n,[{key:"deinit",value:function(){this.syncService=void 0,this.itemManager=void 0,this.resolveQueue.length=0,this.registeredPredicates.length=0,this.removeItemObserver(),this.removeItemObserver=void 0,this.removeSyncObserver(),this.removeSyncObserver=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"popResolveQueue",value:function(){var e=this.resolveQueue.slice();return this.resolveQueue=[],e}},{key:"addObservers",value:function(){var e=this;this.removeItemObserver=this.itemManager.addObserver(F.a.Any,function(t,n){if(t.length>0){var r=t.filter(function(e){return e.errorDecryptingValueChanged});r.length>0&&(e.resolveQueue=e.resolveQueue.concat(r))}n.length>0&&(e.resolveQueue=e.resolveQueue.concat(n))}),this.removeSyncObserver=this.syncService.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==on.a.DownloadFirstSyncCompleted&&t!==on.a.FullSyncCompleted){n.next=3;break}return n.next=3,b.awrap(e.resolveSingletonsForItems(e.popResolveQueue(),t));case 3:case"end":return n.stop()}},null,null,null,Promise)})}},{key:"registerPredicate",value:function(e){this.registeredPredicates.push(e)}},{key:"validItemsMatchingPredicate",value:function(e){return this.itemManager.itemsMatchingPredicate(e).filter(function(e){return!e.errorDecrypting})}},{key:"resolveSingletonsForItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p=this;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:n=function(e){for(var t,n=S(p.registeredPredicates);!(t=n()).done;){var r=t.value;if(e.satisfiesPredicate(r))return p.validItemsMatchingPredicate(r)}},r=function(e){return e.isSingleton?p.validItemsMatchingPredicate(e.singletonPredicate):null},a=function(e){var t=r(e);return t&&t.length>0?t:n(e)},i=[],s=S(e);case 5:if((o=s()).done){d.next=17;break}if(c=o.value,!i.includes(c)){d.next=9;break}return d.abrupt("continue",15);case 9:if(u=a(c),Object(_.o)(i,u||[]),u&&!(u.length<=1)){d.next=13;break}return d.abrupt("continue",15);case 13:return d.next=15,b.awrap(this.handleStrategy(u,c.singletonStrategy));case 15:d.next=5;break;case 17:if(!(i.length>0&&t===on.a.FullSyncCompleted)){d.next=20;break}return d.next=20,b.awrap(null===(l=this.syncService)||void 0===l?void 0:l.sync());case 20:case"end":return d.stop()}},null,this,null,Promise)}},{key:"handleStrategy",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t===T.e.KeepEarliest){a.next=2;break}throw'Unhandled singleton strategy';case 2:return n=e.sort(function(e,t){return e.errorDecrypting?1:t.errorDecrypting?-1:e.created_at<t.created_at?-1:1}),r=Object(_.d)(n,0),a.next=6,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(r)));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"findSingleton",value:function(e){var t=this.validItemsMatchingPredicate(e);if(t.length>0)return t[0]}},{key:"findOrCreateSingleton",value:function(e,t,n){var r,a,i,s,o,c,u,l=this;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(r=this.findSingleton(e),Object(_.w)(r)){p.next=3;break}return p.abrupt("return",r);case 3:if(this.syncService.getLastSyncDate()){p.next=13;break}return i=this.itemManager.addObserver(t,function(t,n){if(n.length>0){var r=l.itemManager.subItemsMatchingPredicates(n,[e]);r.length>0&&(a=r[0])}}),p.next=7,b.awrap(this.syncService.sync());case 7:if(i(),!a){p.next=10;break}return p.abrupt("return",a);case 10:if(!((s=this.validItemsMatchingPredicate(e)).length>0)){p.next=13;break}return p.abrupt("return",s[0]);case 13:if(!(o=this.itemManager.itemsMatchingPredicate(e).filter(function(e){return e.errorDecrypting})).length){p.next=17;break}return p.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(o)));case 17:return p.t0=Object(Ee.e),p.next=20,b.awrap(I.GenerateUuid());case 20:return p.t1=p.sent,p.t2=t,p.t3=n,p.t4=new Date,p.t5={uuid:p.t1,content_type:p.t2,content:p.t3,dirty:!0,dirtiedDate:p.t4},c=(0,p.t0)(p.t5),p.next=28,b.awrap(this.itemManager.emitItemFromPayload(c));case 28:return u=p.sent,this.syncService.sync(),p.abrupt("return",u);case 31:case"end":return p.stop()}},null,this,null,Promise)}}]),n})(R.a);function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach(function(t){pn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dn,hn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c){var u;return v(this,n),(u=t.call(this)).itemManager=e,u.alertService=r,u.previousPasswords=[],u.itemManager=e,u.alertService=r,u.deviceInterface=a,u.httpService=i,u.payloadManager=s,u.protocolService=o,u.syncService=c,u.previousPasswords=[],u}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.alertService=void 0,this.deviceInterface=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.syncService=void 0,this.previousPasswords.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"getExtensions",value:function(){return this.itemManager.nonErroredItemsForContentType(F.a.ActionsExtension)}},{key:"extensionsInContextOfItem",value:function(e){return this.getExtensions().filter(function(t){return t.supported_types.includes(e.content_type)||t.actionsWithContextForItem(e).length>0})}},{key:"loadExtensionInContextOfItem",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n={content_type:t.content_type,item_uuid:t.uuid},u.next=3,b.awrap(this.httpService.getAbsolute(e.url,n).catch(function(e){return console.error('Error loading extension',e),null}));case 3:if(r=u.sent){u.next=6;break}return u.abrupt("return");case 6:return a=r.description||e.description,i=r.supported_types||e.supported_types,s=r.actions?r.actions.map(function(e){return new ae(e)}):[],(o=new se(e,T.c.UserInteraction)).deprecation=r.deprecation,o.description=a,o.supported_types=i,o.actions=s,c=o.getResult(),u.abrupt("return",nt(c));case 16:case"end":return u.stop()}},null,this,null,Promise)}},{key:"runAction",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:a.t0=e.verb,a.next='get'===a.t0?3:'render'===a.t0?7:'show'===a.t0?11:'post'===a.t0?15:19;break;case 3:return a.next=5,b.awrap(this.handleGetAction(e,n));case 5:return r=a.sent,a.abrupt("break",20);case 7:return a.next=9,b.awrap(this.handleRenderAction(e,n));case 9:return r=a.sent,a.abrupt("break",20);case 11:return a.next=13,b.awrap(this.handleShowAction(e));case 13:return r=a.sent,a.abrupt("break",20);case 15:return a.next=17,b.awrap(this.handlePostAction(e,t));case 17:return r=a.sent,a.abrupt("break",20);case 19:return a.abrupt("break",20);case 20:return a.abrupt("return",r);case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleGetAction",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.alertService.confirm("Are you sure you want to replace the current note contents with this action's results?"));case 2:if(!n.sent){n.next=7;break}return n.abrupt("return",this.runConfirmedGetAction(e,t));case 7:return n.abrupt("return",{error:{status:1,message:'Action canceled by user.'}});case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"runConfirmedGetAction",value:function(e,t){var n,r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.httpService.getAbsolute(e.url).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return a.alertService.alert(t.message),{error:t}}));case 2:if(!(n=i.sent).error){i.next=5;break}return i.abrupt("return",n);case 5:return i.next=7,b.awrap(this.payloadByDecryptingResponse(n,t));case 7:return r=i.sent,i.next=10,b.awrap(this.payloadManager.emitPayload(Object(Ee.b)(r,{dirty:!0,dirtiedDate:new Date}),ht.a.RemoteActionRetrieved));case 10:return this.syncService.sync(),i.abrupt("return",ln(ln({},n),{},{item:n.item}));case 12:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleRenderAction",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.httpService.getAbsolute(e.url).then(function(e){var n,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(r.payloadByDecryptingResponse(e,t));case 2:if(!(n=i.sent)){i.next=6;break}return a=nt(n),i.abrupt("return",ln(ln({},e),{},{item:a}));case 6:case"end":return i.stop()}},null,null,null,Promise)}).catch(function(e){var t=e&&e.error||{message:'An issue occurred while processing this action. Please try again.'};return r.alertService.alert(t.message),{error:t}}));case 2:return n=a.sent,a.abrupt("return",n);case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingResponse",value:function(e,t,n){var r,a,i,s,o,c,u,l,p,d,h,f=arguments;return b.async(function(v){for(;;)switch(v.prev=v.next){case 0:return r=f.length>3&&void 0!==f[3]?f[3]:[],a=Object(Ee.e)(e.item),v.next=4,b.awrap(this.protocolService.payloadByDecryptingPayload(a,n));case 4:if((i=v.sent).errorDecrypting){v.next=7;break}return v.abrupt("return",i);case 7:if(s=e.keyParams||e.auth_params){v.next=11;break}return this.alertService.alert("We were unable to decrypt this revision using your current keys, and this revision is missing metadata that would allow us to try different keys to decrypt it. This can likely be fixed with some manual intervention. Please email hello@standardnotes.org for assistance."),v.abrupt("return",void 0);case 11:o=this.protocolService.createKeyParams(s),c=S(this.previousPasswords);case 13:if((u=c()).done){v.next=30;break}if(l=u.value,!r.includes(l)){v.next=17;break}return v.abrupt("continue",28);case 17:return r.push(l),v.next=20,b.awrap(this.protocolService.computeRootKey(l,o));case 20:if(p=v.sent){v.next=23;break}return v.abrupt("continue",28);case 23:return v.next=25,b.awrap(this.payloadByDecryptingResponse(e,t,p,r));case 25:if(!(d=v.sent)){v.next=28;break}return v.abrupt("return",d);case 28:v.next=13;break;case 30:return v.next=32,b.awrap(t());case 32:if(h=v.sent,!this.previousPasswords.includes(h)){v.next=35;break}return v.abrupt("return",void 0);case 35:return this.previousPasswords.push(h),v.abrupt("return",this.payloadByDecryptingResponse(e,t,n));case 37:case"end":return v.stop()}},null,this,null,Promise)}},{key:"handlePostAction",value:function(e,t){var n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=e.access_type===q.Decrypted,s.next=3,b.awrap(this.outgoingPayloadForItem(t,n));case 3:return r=s.sent,a={items:[r]},s.abrupt("return",this.httpService.postAbsolute(e.url,a).then(function(e){return e}).catch(function(e){return console.error('Action error response:',e),i.alertService.alert('An issue occurred while processing this action. Please try again.'),e}));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleShowAction",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.deviceInterface.openUrl(e.url),t.abrupt("return",{});case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"outgoingPayloadForItem",value:function(e){var t,n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=a.length>1&&void 0!==a[1]&&a[1],n=t?Re.b.FileDecrypted:Re.b.FileEncrypted,i.next=4,b.awrap(this.protocolService.payloadByEncryptingPayload(e.payloadRepresentation(),n));case 4:return r=i.sent,i.abrupt("return",r.ejected());case 6:case"end":return i.stop()}},null,this,null,Promise)}}]),n})(R.a),fn=(function(){function e(t,n,r){v(this,e),this.deviceInterface=t,this.identifier=n,this.environment=r}return y(e,null,[{key:"version",value:function(){throw Error('Must override')}}]),e})(),vn=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.deviceInterface.getJsonParsedRawStorageValue(D.AllAccountKeyParamsKey));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getRawKeychainValue());case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getRawStorageValue('mk'));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Pe(this.environment)){n.next=7;break}return n.next=3,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 3:return e=n.sent,n.abrupt("return",!Object(_.w)(e));case 7:return n.next=9,b.awrap(this.deviceInterface.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 9:return t=n.sent,n.abrupt("return",!Object(_.w)(t));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!!Pe(this.environment)}}],[{key:"version",value:function(){return"1.0.0"}}]),n})(),yn=(function(){function e(t){v(this,e),this.services=t,this.stageHandlers={},this.registerStageHandlers()}return y(e,[{key:"registerStageHandler",value:function(e,t){this.stageHandlers[e]=t}},{key:"markDone",value:function(){var e;null===(e=this.onDoneHandler)||void 0===e||e.call(this),this.onDoneHandler=void 0}},{key:"promptForPasscodeUntilCorrect",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=new ye([new ge(te.None)],ne.Migration,!1),r.abrupt("return",new Promise(function(r){n.services.challengeService.addChallengeObserver(t,{onNonvalidatedSubmit:function(a){var i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return i=a.values[0],s=i.value,o.next=4,b.awrap(e(s));case 4:o.sent?(n.services.challengeService.completeChallenge(t),r(s)):n.services.challengeService.setValidationStatusForChallenge(t,i,!1);case 6:case"end":return o.stop()}},null,null,null,Promise)}}),n.services.challengeService.promptForChallengeResponse(t)}));case 2:case"end":return r.stop()}},null,null,null,Promise)}},{key:"onDone",value:function(e){this.onDoneHandler=e}},{key:"handleStage",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!(t=this.stageHandlers[e])){n.next=4;break}return n.next=4,b.awrap(t());case 4:case"end":return n.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){throw'Must override'}}]),e})();!(function(e){e.CreatedAt="created_at",e.UpdatedAt="userModifiedDate",e.Title="title"})(dn||(dn={}));var gn=(function(e){d(n,mt);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).displaySortBy={},e.displayFilter={},e.filteredMap={},e.sortedMap={},e}return y(n,[{key:"set",value:function(e){e=Object(_.W)(Array.isArray(e)?e:[e],'uuid'),p(f(n.prototype),"set",this).call(this,e),this.filterSortElements(e)}},{key:"discard",value:function(e){e=Array.isArray(e)?e:[e],p(f(n.prototype),"discard",this).call(this,e),this.filterSortElements(e)}},{key:"setDisplayOptions",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dn.CreatedAt,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:'asc',r=arguments.length>3?arguments[3]:void 0,a=this.displaySortBy[e],i=this.displayFilter[e];if(!a||a.key!==t||a.dir!==n||i||r){this.displaySortBy[e]=t?{key:t,dir:n}:void 0,this.displayFilter[e]=r,this.filteredMap[e]={},this.sortedMap[e]=[];var s=this.all(e);s.length>0&&this.filterSortElements(s)}}},{key:"displayElements",value:function(e){var t=this.sortedMap[e];if(!t)throw Error("Attempting to access display elements for\n        non-configured content type ".concat(e));return t.slice()}},{key:"filterSortElements",value:function(e){if(0!==Object.keys(this.displaySortBy).length){for(var t,n=new Set,r=S(e);!(t=r()).done;){var a=t.value,i=a.content_type,s=this.displaySortBy[i];if(s){var o=this.displayFilter[i],c=this.filteredMap[i],u=this.sortedMap[i],l=c[a.uuid],p=Object(_.w)(l)?void 0:u[l];if(!(a.deleted||!this.map[a.uuid])&&(!o||o(a)))if(Object(_.w)(p))u.push(a),n.add(i);else{var d=p.errorDecrypting?void 0:p[s.key],h=a[s.key];u[l]=a;var f=p.pinned!==a.pinned;Object(_.g)(d,h)&&!f||n.add(i)}else Object(_.w)(l)||(delete c[a.uuid],u[l]=void 0,n.add(i))}}for(var v,y=S(n.values());!(v=y()).done;){var g=v.value;this.resortContentType(g)}}}},{key:"resortContentType",value:function(e){for(var t,n=this.sortedMap[e],r=this.displaySortBy[e],a=this.filteredMap[e],i=function e(t,n){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t)return-1;if(!n)return 1;if(!a){if(t.pinned&&n.pinned)return e(t,n,!0);if(t.pinned)return-1;if(n.pinned)return 1}var i=t[r.key]||'',s=n[r.key]||'',o=1;return'asc'===r.dir&&(o*=-1),r.key===dn.Title?o*i.localeCompare(s,'en',{numeric:!0}):i>s?-1*o:i<s?1*o:0},s=[],o=0,c=S(n.sort(function(e,t){return i(e,t)}));!(t=c()).done;){var u=t.value;u&&(s.push(u),a[u.uuid]=o,o++)}this.sortedMap[e]=s}}]),n})();function mn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(n),!0).forEach(function(t){wn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var kn=(function(e){d(n,yn);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this,e)).legacyReader=new vn(r.services.deviceInterface,r.services.identifier,r.services.environment),r}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!Se(e.services.environment)){t.next=5;break}return t.next=3,b.awrap(e.migrateStorageStructureForWebDesktop());case 3:t.next=8;break;case 5:if(!Pe(e.services.environment)){t.next=8;break}return t.next=8,b.awrap(e.migrateStorageStructureForMobile());case 8:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.StorageDecrypted_09,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.migrateArbitraryRawStorageToManagedStorageAllPlatforms());case 2:if(!Pe(e.services.environment)){t.next=5;break}return t.next=5,b.awrap(e.migrateMobilePreferences());case 5:return t.next=7,b.awrap(e.migrateSessionStorage());case 7:return t.next=9,b.awrap(e.deleteLegacyStorageValues());case 9:case"end":return t.stop()}},null,null,null,Promise)}),this.registerStageHandler(ve.LoadingDatabase_11,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createDefaultItemsKeyForAllPlatforms());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"migrateStorageStructureForWebDesktop",value:function(){var e,t,n,r,a,i,s,c,u,l,p,d,h,f,v,y,m,w,k,x,S;return b.async(function(P){for(;;)switch(P.prev=P.next){case 0:return t=this.services.deviceInterface,g(e={},_e.Wrapped,{}),g(e,_e.Unwrapped,{}),g(e,_e.Nonwrapped,{}),n=e,P.next=4,b.awrap(this.legacyReader.getAccountKeyParams());case 4:return(r=P.sent)&&(n.nonwrapped[o.RootKeyParams]=r),P.next=8,b.awrap(t.getJsonParsedRawStorageValue(D.WebEncryptedStorageKey));case 8:if(!(a=P.sent)){P.next=37;break}return i=Object(Ee.e)(a),P.next=13,b.awrap(this.webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage(i));case 13:if(s=P.sent,c=s.key,u=s.decryptedStoragePayload,l=s.keyParams,n.nonwrapped[o.RootKeyWrapperKeyParams]=l.getPortableValue(),p=Object(_.a)(u.contentObject.storage),d=Object(_.E)(p),h=d[D.AllAccountKeyParamsKey],n.nonwrapped[o.RootKeyParams]=h,f=c,!!Object(_.w)(d.mk)){P.next=32;break}return P.next=27,b.awrap(this.webDesktopHelperExtractAndWrapAccountKeysFromValueStore(c,h,d));case 27:v=P.sent,y=v.accountKey,m=v.wrappedKey,f=y,n.nonwrapped[o.WrappedRootKey]=m;case 32:return P.next=34,b.awrap(this.webDesktopHelperEncryptStorage(f,u,d));case 34:n.wrapped=P.sent,P.next=55;break;case 37:return P.next=39,b.awrap(this.services.deviceInterface.getRawStorageValue('ak'));case 39:return w=P.sent,P.next=42,b.awrap(this.services.deviceInterface.getRawStorageValue('mk'));case 42:if(k=P.sent,!w&&!k){P.next=55;break}if(P.t0=null===r||void 0===r?void 0:r.version,P.t0){P.next=49;break}return P.next=48,b.awrap(this.getFallbackRootKeyVersion());case 48:P.t0=P.sent;case 49:return x=P.t0,P.next=52,b.awrap(Ve.Create({masterKey:k,dataAuthenticationKey:w,version:x,keyParams:r}));case 52:return S=P.sent,P.next=55,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(S.getKeychainValue(),this.services.identifier));case 55:return P.next=57,b.awrap(this.allPlatformHelperSetStorageStructure(n));case 57:case"end":return P.stop()}},null,this,null,Promise)}},{key:"allPlatformHelperSetStorageStructure",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return(t=Ie.defaultValuesObject(e.wrapped,e.unwrapped,e.nonwrapped))[_e.Unwrapped]=void 0,n.next=4,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.StorageObject),JSON.stringify(t)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperGetPasscodeKeyAndDecryptEncryptedStorage",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.WebPasscodeParamsKey));case 2:return t=s.sent,n=this.services.protocolService.createKeyParams(t),s.next=6,b.awrap(this.promptForPasscodeUntilCorrect(function(t){return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(i.services.protocolService.computeRootKey(t,n));case 2:return a=s.sent,s.next=5,b.awrap(i.services.protocolService.payloadByDecryptingPayload(e,a));case 5:return r=s.sent,s.abrupt("return",!r.errorDecrypting);case 7:case"end":return s.stop()}},null,null,null,Promise)}));case 6:return s.abrupt("return",{decryptedStoragePayload:r,key:a,keyParams:n});case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperExtractAndWrapAccountKeysFromValueStore",value:function(e,t,n){var r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.t0=null===t||void 0===t?void 0:t.version,c.t0){c.next=5;break}return c.next=4,b.awrap(this.getFallbackRootKeyVersion());case 4:c.t0=c.sent;case 5:return a=c.t0,c.next=8,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:a,keyParams:t}));case 8:if(i=c.sent,delete n.mk,delete n.pw,delete n.ak,s=Object(Ee.e)(i),!e){c.next=17;break}return c.next=16,b.awrap(this.services.protocolService.payloadByEncryptingPayload(s,Re.b.LocalStorageEncrypted,e));case 16:o=c.sent;case 17:return c.abrupt("return",{accountKey:i,wrappedKey:null===(r=o)||void 0===r?void 0:r.ejected()});case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"webDesktopHelperEncryptStorage",value:function(e,t,n){var r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.services.protocolService.payloadByEncryptingPayload(Object(Ee.b)(t,{content_type:F.a.EncryptedStorage,content:n}),Re.b.LocalStoragePreferEncrypted,e));case 2:return r=a.sent,a.abrupt("return",r.ejected());case 4:case"end":return a.stop()}},null,this,null,Promise)}},{key:"migrateStorageStructureForMobile",value:function(){var e,t,n,r,a,i,s,u,l,p,d,h,f,v,y,m,w,k,x,S,P,O,C,E,R=this;return b.async(function(M){for(;;)switch(M.prev=M.next){case 0:return M.next=2,b.awrap(this.services.deviceInterface.getRawKeychainValue());case 2:return n=M.sent,M.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileWrappedRootKeyKey));case 5:if(M.t0=M.sent,M.t0){M.next=8;break}M.t0=null===n||void 0===n?void 0:n.encryptedAccountKeys;case 8:return r=M.t0,M.next=11,b.awrap(this.legacyReader.getAccountKeyParams());case 11:return a=M.sent,M.next=14,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobilePasscodeParamsKey));case 14:return i=M.sent,M.next=17,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(c.MobileFirstRun));case 17:return s=M.sent,g(t={},_e.Nonwrapped,(g(e={},o.WrappedRootKey,r),g(e,o.RootKeyWrapperKeyParams,Object(_.I)(i,['hash'])),g(e,o.RootKeyParams,a),g(e,c.MobileFirstRun,s),e)),g(t,_e.Unwrapped,{}),g(t,_e.Wrapped,{}),u=t,M.next=21,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileBiometricsPrefs));case 21:return(l=M.sent)&&(u.nonwrapped[o.BiometricsState]=l.enabled,u.nonwrapped[o.MobileBiometricsTiming]=l.timing),M.next=25,b.awrap(this.services.deviceInterface.getRawStorageValue(D.MobilePasscodeKeyboardType));case 25:if((p=M.sent)&&(u.nonwrapped[o.MobilePasscodeKeyboardType]=p),!i){M.next=75;break}if(h=this.services.protocolService.createKeyParams(i),f=function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(R.promptForPasscodeUntilCorrect(function(t){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return u.next=2,b.awrap(R.services.protocolService.computeRootKey(t,h));case 2:if(e=u.sent,!(i=null===n||void 0===n?void 0:null===(a=n.offline)||void 0===a?void 0:a.pw)){u.next=8;break}return u.abrupt("return",e.serverPassword===i);case 8:if(!r){u.next=15;break}return u.next=11,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),e));case 11:return s=u.sent,u.abrupt("return",!s.errorDecrypting);case 15:return u.next=17,b.awrap(R.services.deviceInterface.getAllRawDatabasePayloads(R.services.identifier));case 17:if(o=u.sent[0]){u.next=20;break}throw Error('Passcode only migration aborting due to missing keychain.offline.pw');case 20:return u.next=22,b.awrap(R.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(o),e));case 22:return c=u.sent,u.abrupt("return",!c.errorDecrypting);case 24:case"end":return u.stop()}},null,null,null,Promise)}));case 2:return t.abrupt("return",e);case 3:case"end":return t.stop()}},null,null,null,Promise)},u.nonwrapped[o.MobilePasscodeTiming]=null===n||void 0===n?void 0:null===(d=n.offline)||void 0===d?void 0:d.timing,!r){M.next=55;break}return M.next=34,b.awrap(f());case 34:return v=M.sent,M.next=37,b.awrap(this.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(r),v));case 37:if(y=M.sent,m=y.contentObject.accountKeys,M.t1=m.version||(null===a||void 0===a?void 0:a.version),M.t1){M.next=44;break}return M.next=43,b.awrap(this.getFallbackRootKeyVersion());case 43:M.t1=M.sent;case 44:return w=M.t1,k=Object(Ee.b)(y,{content:{masterKey:m.mk,dataAuthenticationKey:m.ak,version:w,keyParams:a,accountKeys:void 0}}),M.next=48,b.awrap(this.services.protocolService.payloadByEncryptingPayload(k,Re.b.LocalStoragePreferEncrypted,v));case 48:return x=M.sent,u.nonwrapped[o.WrappedRootKey]=x.ejected(),m.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",m.jwt),M.next=53,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 53:M.next=73;break;case 55:if(r){M.next=73;break}return M.next=58,b.awrap(f());case 58:return S=M.sent,M.t2=Object(Ee.e),M.next=62,b.awrap(I.GenerateUuid());case 62:return M.t3=M.sent,M.t4=Object(Ke.a)(u.unwrapped),M.t5=F.a.EncryptedStorage,M.t6={uuid:M.t3,content:M.t4,content_type:M.t5},P=(0,M.t2)(M.t6),M.next=69,b.awrap(this.services.protocolService.payloadByEncryptingPayload(P,Re.b.LocalStoragePreferEncrypted,S));case 69:return O=M.sent,u.wrapped=O.ejected(),M.next=73,b.awrap(this.services.deviceInterface.clearRawKeychainValue());case 73:M.next=89;break;case 75:if(!!Object(_.w)(null===n||void 0===n?void 0:n.mk)){M.next=89;break}if(M.t7=n.version||(null===a||void 0===a?void 0:a.version),M.t7){M.next=82;break}return M.next=81,b.awrap(this.getFallbackRootKeyVersion());case 81:M.t7=M.sent;case 82:return C=M.t7,M.next=85,b.awrap(Ve.Create({masterKey:n.mk,dataAuthenticationKey:n.ak,version:C,keyParams:a}));case 85:return E=M.sent,M.next=88,b.awrap(this.services.deviceInterface.setNamespacedKeychainValue(E.getKeychainValue(),this.services.identifier));case 88:n.jwt&&this.services.deviceInterface.setRawStorageValue("jwt",n.jwt);case 89:return M.next=91,b.awrap(this.allPlatformHelperSetStorageStructure(u));case 91:case"end":return M.stop()}},null,this,null,Promise)}},{key:"getFallbackRootKeyVersion",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.services.deviceInterface.getAllRawDatabasePayloads(this.services.identifier));case 2:if(e=n.sent[0]){n.next=5;break}return n.abrupt("return",Q.a.V002);case 5:return t=Object(Ee.e)(e),n.abrupt("return",t.version||Q.a.V002);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateArbitraryRawStorageToManagedStorageAllPlatforms",value:function(){var e,t,n,r,a,i,s,o,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getAllRawStorageKeyValues());case 2:e=p.sent,t=Object(_.H)(D),n=function(e){try{return JSON.parse(e)}catch(t){return e}},r=this.services.identifier,a=S(e);case 7:if((i=a()).done){p.next=20;break}if(s=i.value,o=s.key,c=s.value,u=r&&r.length>0&&o.startsWith(r),!t.includes(o)&&!u){p.next=14;break}return p.abrupt("continue",18);case 14:if(Object(_.w)(c)){p.next=18;break}return l=n(c),p.next=18,b.awrap(this.services.storageService.setValue(o,l));case 18:p.next=7;break;case 20:case"end":return p.stop()}},null,this,null,Promise)}},{key:"deleteLegacyStorageValues",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e=['mk','ak','pw','encryptionKey','authKey','jwt','ephemeral','cachedThemes'],t=[].concat(m(Object(_.H)(o)),m(Object(_.H)(D)),e),n=S(t);case 3:if((r=n()).done){i.next=9;break}return a=r.value,i.next=7,b.awrap(this.services.deviceInterface.removeRawStorageValue(a));case 7:i.next=3;break;case 9:case"end":return i.stop()}},null,this,null,Promise)}},{key:"migrateMobilePreferences",value:function(){var e,t,n,r,a,i,s,c,u,l;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileLastExportDate));case 2:return e=p.sent,p.next=5,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileDoNotWarnUnsupportedEditors));case 5:return t=p.sent,p.next=8,b.awrap(this.services.deviceInterface.getJsonParsedRawStorageValue(D.MobileOptionsState));case 8:return n=p.sent,r={},n&&(u=n.sortBy,r={sortBy:'updated_at'===u||'client_updated_at'===u?dn.UpdatedAt:u,sortReverse:null!==(a=n.sortReverse)&&void 0!==a&&a,hideNotePreview:null!==(i=n.hidePreviews)&&void 0!==i&&i,hideDate:null!==(s=n.hideDates)&&void 0!==s&&s,hideTags:null!==(c=n.hideTags)&&void 0!==c&&c}),l=bn(bn({},r),{},{lastExportDate:null!==e&&void 0!==e?e:void 0,doNotShowAgainUnsupportedEditors:null!==t&&void 0!==t&&t}),p.next=14,b.awrap(this.services.storageService.setValue(o.MobilePreferences,l));case 14:case"end":return p.stop()}},null,this,null,Promise)}},{key:"migrateSessionStorage",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return e='user',i.next=3,b.awrap(this.services.storageService.getValue("jwt"));case 3:return t=i.sent,i.next=6,b.awrap(this.services.storageService.getValue(e));case 6:if(n=i.sent,t||n&&(t=n.jwt),t){i.next=15;break}if(!!Object(_.w)(n)){i.next=14;break}t='junk-value',i.next=15;break;case 14:return i.abrupt("return");case 15:return r=new Ae(t),i.next=18,b.awrap(this.services.storageService.setValue(o.Session,r));case 18:if(!Pe(this.services.environment)){i.next=25;break}return i.next=21,b.awrap(this.services.storageService.getValue(e));case 21:if(!(a=i.sent)||!a.server){i.next=25;break}return i.next=25,b.awrap(this.services.storageService.setValue(o.ServerHost,a.server));case 25:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createDefaultItemsKeyForAllPlatforms",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(e=this.services.protocolService.getRootKey())){i.next=18;break}return i.next=4,b.awrap(this.services.protocolService.getRootKeyParams());case 4:return t=i.sent,n=Q.a.V001,i.t0=Object(Ee.e),i.next=9,b.awrap(I.GenerateUuid());case 9:return i.t1=i.sent,i.t2=F.a.ItemsKey,i.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t.version||n}),i.t4=new Date,i.t5={uuid:i.t1,content_type:i.t2,content:i.t3,dirty:!0,dirtiedDate:i.t4},r=(0,i.t0)(i.t5),a=nt(r),i.next=18,b.awrap(this.services.itemManager.emitItemFromPayload(a.payloadRepresentation(),ht.a.LocalChanged));case 18:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return"2.0.0"}}]),n})(),xn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.createNewDefaultItemsKeyIfNecessary());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"createNewDefaultItemsKeyIfNecessary",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.services.protocolService.needsNewRootKeyBasedItemsKey()){e.next=3;break}return e.next=3,b.awrap(this.services.protocolService.createNewDefaultItemsKey());case 3:case"end":return e.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.0.15'}}]),n})(),Sn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.FullSyncCompleted_13,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteBatchManagerSingleton());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteBatchManagerSingleton",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e='org.standardnotes.batch-manager',t=H.a.CompoundPredicate([new H.a('content_type','=',F.a.Component),new H.a('package_info.identifier','=',e)]),!(n=this.services.singletonManager.findSingleton(t))){r.next=6;break}return r.next=6,b.awrap(this.services.itemManager.setItemToBeDeleted(n.uuid));case 6:case"end":return r.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.7.0'}}]),n})(),Pn=(function(e){d(n,yn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.LoadedDatabase_12,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.deleteMfaItems());case 2:e.markDone();case 3:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"deleteMfaItems",value:function(){var e,t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e='SF|MFA',t=this.services.itemManager.getItems(e),n=S(t);case 3:if((r=n()).done){i.next=10;break}return a=r.value,this.services.itemManager.removeItemLocally(a),i.next=8,b.awrap(this.services.storageService.deletePayloadWithId(a.uuid));case 8:i.next=3;break;case 10:case"end":return i.stop()}},null,this,null,Promise)}}],[{key:"version",value:function(){return'2.20.0'}}]),n})(),On=(function(e){d(n,fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getStorage",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=O(this.identifier,s.StorageObject),r.next=3,b.awrap(this.deviceInterface.getRawStorageValue(e));case 3:return t=r.sent,n=t?JSON.parse(t):void 0,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getNonWrappedValue",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getStorage());case 2:if(n=r.sent){r.next=5;break}return r.abrupt("return",void 0);case 5:return r.abrupt("return",null===(t=n[_e.Nonwrapped])||void 0===t?void 0:t[e]);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.getNonWrappedValue(o.RootKeyParams));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"hasNonWrappedAccountKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getNonWrappedValue(o.WrappedRootKey));case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"usesKeychain",value:function(){return!0}}],[{key:"version",value:function(){return"2.0.0"}}]),n})();function Cn(e){for(var t,n=S(Object.values(i).sort(function(e,t){return-1*P(e.version(),t.version())}));!(t=n()).done;){var r=t.value;if(r.version()===e)return r;if(x(r.version(),e))return r}throw Error("Cannot find reader for version ".concat(e))}function Dn(e,t,n,r){return new(Cn(e))(t,n,r)}var _n=(function(e){d(n,yn);var t=k(n);function n(){var e;return v(this,n),(e=t.apply(this,arguments)).didPreRun=!1,e}return y(n,[{key:"preRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storeVersionNumber());case 2:this.didPreRun=!0;case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"registerStageHandlers",value:function(){var e=this;this.registerStageHandler(ve.PreparingForLaunch_0,function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.needsKeychainRepair());case 2:if(!t.sent){t.next=5;break}return t.next=5,b.awrap(e.repairMissingKeychain());case 5:e.markDone();case 6:case"end":return t.stop()}},null,null,null,Promise)})}},{key:"getStoredVersion",value:function(){var e=O(this.services.identifier,s.SnjsVersion);return this.services.deviceInterface.getRawStorageValue(e)}},{key:"storeVersionNumber",value:function(){var e,t,n,r,a,i,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return e=O(this.services.identifier,s.SnjsVersion),c.next=3,b.awrap(this.getStoredVersion());case 3:if(c.sent){c.next=38;break}t=!1,n=0,r=['migrations','ephemeral','user','cachedThemes','syncToken','encryptedStorage'];case 8:if(!(n<r.length)){c.next=19;break}return a=r[n],c.next=12,b.awrap(this.services.deviceInterface.getRawStorageValue(a));case 12:if(!c.sent){c.next=16;break}return t=!0,c.abrupt("break",19);case 16:n++,c.next=8;break;case 19:if(!t){c.next=24;break}return c.next=22,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"1.0.0"));case 22:c.next=38;break;case 24:return i=O(this.services.identifier,"last_migration_timestamp"),c.next=27,b.awrap(this.services.deviceInterface.getRawStorageValue(i));case 27:if(o=c.sent,!!Object(_.w)(o)){c.next=36;break}return c.next=32,b.awrap(this.services.deviceInterface.setRawStorageValue(e,"2.0.0"));case 32:return c.next=34,b.awrap(this.services.deviceInterface.removeRawStorageValue("last_migration_timestamp"));case 34:c.next=38;break;case 36:return c.next=38,b.awrap(this.services.deviceInterface.setRawStorageValue(e,h));case 38:case"end":return c.stop()}},null,this,null,Promise)}},{key:"loadReader",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.reader){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,b.awrap(this.getStoredVersion());case 4:e=t.sent,this.reader=Dn(e,this.services.deviceInterface,this.services.identifier,this.services.environment);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"needsKeychainRepair",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.didPreRun){t.next=2;break}throw Error('Attempting to access specialized function before prerun');case 2:if(this.reader){t.next=5;break}return t.next=5,b.awrap(this.loadReader());case 5:if(this.reader.usesKeychain){t.next=8;break}return t.abrupt("return",!1);case 8:return t.next=10,b.awrap(this.reader.getAccountKeyParams());case 10:if(e=t.sent,!Object(_.w)(e)){t.next=14;break}return t.abrupt("return",!1);case 14:return t.next=16,b.awrap(this.reader.hasPasscode());case 16:if(!t.sent){t.next=19;break}return t.abrupt("return",!1);case 19:return t.next=21,b.awrap(this.reader.hasNonWrappedAccountKeys());case 21:if(!t.sent){t.next=24;break}return t.abrupt("return",!1);case 24:return t.abrupt("return",!0);case 25:case"end":return t.stop()}},null,this,null,Promise)}},{key:"repairMissingKeychain",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getStoredVersion());case 2:return e=a.sent,a.next=5,b.awrap(this.reader.getAccountKeyParams());case 5:return t=a.sent,n=new ye([new ge(te.None,void 0,j.R.PasswordInputPlaceholder,!0)],ne.Custom,!1,j.I.Title,j.I.Text),a.abrupt("return",new Promise(function(a){r.services.challengeService.addChallengeObserver(n,{onNonvalidatedSubmit:function(i){var s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:return s=i.values[0].value,o=r.services.protocolService.createKeyParams(t),d.next=4,b.awrap(r.services.protocolService.computeRootKey(s,o));case 4:return c=d.sent,d.next=7,b.awrap(r.services.deviceInterface.getAllRawDatabasePayloads(r.services.identifier));case 7:if(u=d.sent,(l=u.find(function(e){var t=Object(Ee.e)(e);return Object(Re.a)(t.content_type)}))||(l=u[0]),l){d.next=12;break}throw we.a.error(Error('Attempting keychain recovery validation but no items present.'));case 12:return d.next=14,b.awrap(r.services.protocolService.payloadByDecryptingPayload(Object(Ee.e)(l),c));case 14:if(!d.sent.errorDecrypting){d.next=19;break}r.services.challengeService.setValidationStatusForChallenge(n,i.values[0],!1),d.next=29;break;case 19:if("1.0.0"!==e){d.next=24;break}return d.next=22,b.awrap(r.services.deviceInterface.legacy_setRawKeychainValue({mk:c.masterKey,ak:c.dataAuthenticationKey,version:o.version}));case 22:d.next=27;break;case 24:return p=c.getKeychainValue(),d.next=27,b.awrap(r.services.deviceInterface.setNamespacedKeychainValue(p,r.services.identifier));case 27:a(),r.services.challengeService.completeChallenge(n);case 29:case"end":return d.stop()}},null,null,null,Promise)}}),r.services.challengeService.promptForChallengeResponse(n)}));case 8:case"end":return a.stop()}},null,this,null,Promise)}}]),n})(),En=(function(e){d(n,e);var t=k(n);function n(e){var r;return v(this,n),(r=t.call(this)).services=e,r}return y(n,[{key:"deinit",value:function(){this.services=void 0,this.activeMigrations&&(this.activeMigrations.length=0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.runBaseMigrationPreRun());case 2:return r.t0=b,r.t1=n,r.next=6,b.awrap(this.getStoredSnjsVersion());case 6:return r.t2=r.sent,r.t3=r.t1.getRequiredMigrations.call(r.t1,r.t2),r.next=10,r.t0.awrap.call(r.t0,r.t3);case 10:if(e=r.sent,this.activeMigrations=this.instantiateMigrationClasses(e),!(this.activeMigrations.length>0)){r.next=17;break}Object(_.F)(this.activeMigrations).onDone(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(t.markMigrationsAsDone());case 2:case"end":return e.stop()}},null,null,null,Promise)}),r.next=19;break;case 17:return r.next=19,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 19:case"end":return r.stop()}},null,this,null,Promise)}},{key:"markMigrationsAsDone",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.services.deviceInterface.setRawStorageValue(O(this.services.identifier,s.SnjsVersion),h));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"runBaseMigrationPreRun",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.baseMigration=new _n(this.services),e.next=3,b.awrap(this.baseMigration.preRun());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:return t.next=4,b.awrap(this.handleStage(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleApplicationEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.a.SignedIn){t.next=3;break}return t.next=3,b.awrap(this.handleStage(ve.SignedIn_30));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPendingMigrations",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=b,t.t1=n,t.next=4,b.awrap(this.getStoredSnjsVersion());case 4:return t.t2=t.sent,t.t3=t.t1.getRequiredMigrations.call(t.t1,t.t2),t.next=8,t.t0.awrap.call(t.t0,t.t3);case 8:if(e=t.sent,t.t4=e.length>0,t.t4){t.next=14;break}return t.next=13,b.awrap(this.baseMigration.needsKeychainRepair());case 13:t.t4=t.sent;case 14:return t.abrupt("return",t.t4);case 15:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getStoredSnjsVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.services.deviceInterface.getRawStorageValue(O(this.services.identifier,s.SnjsVersion)));case 2:if(e=t.sent){t.next=5;break}throw we.a.error(Error('Snjs version missing from storage, run base migration.'));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"instantiateMigrationClasses",value:function(e){var t=this;return e.map(function(e){return new e(t.services)})}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.baseMigration.handleStage(e));case 2:t=S(this.activeMigrations);case 3:if((n=t()).done){a.next=9;break}return r=n.value,a.next=7,b.awrap(r.handleStage(e));case 7:a.next=3;break;case 9:case"end":return a.stop()}},null,this,null,Promise)}}],[{key:"getRequiredMigrations",value:function(e){var t,n,r,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:t=[],n=Object.keys(a).map(function(e){return a[e]}).sort(function(e,t){return P(e.version(),t.version())}),r=S(n);case 3:if((i=r()).done){c.next=11;break}if(s=i.value,(o=s.version())!==e){c.next=8;break}return c.abrupt("continue",9);case 8:x(e,o)&&t.push(s);case 9:c.next=3;break;case 11:return c.abrupt("return",t);case 12:case"end":return c.stop()}},null,null,null,Promise)}}]),n})(R.a),Rn=n(14),In=(function(){function e(t){v(this,e),this.crypto=t}return y(e,[{key:"firstHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(0,e.length/2));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"secondHalfOfKey",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.substring(e.length/2,e.length));case 1:case"end":return t.stop()}},null,null,null,Promise)}},{key:"splitKey",value:function(e,t){for(var n=e.length/t,r=[],a=0;a<t;a++){var i=e.slice(n*a,n*(a+1));r.push(i)}return r}},{key:"createItemsKey",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.generateNewItemsKeyContent());case 2:return e=n.sent,n.t0=Object(Ee.e),n.next=6,b.awrap(I.GenerateUuid());case 6:return n.t1=n.sent,n.t2=F.a.ItemsKey,n.t3=Object(Ke.a)(e),n.t4={uuid:n.t1,content_type:n.t2,content:n.t3},t=(0,n.t0)(n.t4),n.abrupt("return",nt(t));case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,n){var r,a,i;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t!==ue.a.DecryptedBareObject){n.next=4;break}return n.abrupt("return",Object(Ee.c)({content:e.content}));case 4:if(t!==ue.a.DecryptedBase64String){n.next=13;break}return r=JSON.stringify(e.content),n.next=8,b.awrap(this.crypto.base64Encode(r));case 8:return a=n.sent,i=Q.a.V000Base64Decrypted+a,n.abrupt("return",Object(Ee.c)({content:i}));case 13:throw"Must override generateEncryptedParameters to handle format ".concat(t,".");case 14:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var n,r,a,i;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if((n=e.format)!==ue.a.DecryptedBareObject){t.next=5;break}return t.abrupt("return",e);case 5:if(n!==ue.a.DecryptedBase64String){t.next=20;break}return r=e.contentString.substring(Q.a.VersionLength,e.contentString.length),t.prev=7,t.next=10,b.awrap(this.crypto.base64Decode(r));case 10:i=t.sent,a=JSON.parse(i),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),a=e.content;case 17:return t.abrupt("return",Object(Ee.a)(e,{content:a}));case 20:throw Error("Must override generateDecryptedParameters to handle format ".concat(n,"."));case 21:case"end":return t.stop()}},null,this,[[7,14]],Promise)}}]),e})(),Mn='00000000000000000000000000000000',An=(function(e){d(n,In);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'AES-256'}},{key:"generateNewItemsKeyContent",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=Rn.a.EncryptionKeyLength,r.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=r.sent,n={itemsKey:t,version:Q.a.V001},r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Rn.a.PbkdfMinCost,o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.a.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+'SN'+a));case 6:return i=o.sent,s=Object(A.a)({email:e,pw_cost:r,pw_nonce:a,pw_salt:i,version:Q.a.V001,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",void 0);case 1:case"end":return e.stop()}},null,null,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcDecrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"encryptString",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.crypto.aes256CbcEncrypt(e,Mn,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c,u,l;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){d.next=2;break}return d.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){d.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r){d.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return d.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.a.EncryptionKeyLength));case 8:return a=d.sent,d.next=11,b.awrap(this.encryptString(a,r.itemsKey));case 11:return i=d.sent,d.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=d.sent,d.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=d.sent,d.next=20,b.awrap(this.encryptString(JSON.stringify(e.content),s));case 20:return c=d.sent,u=r.keyVersion+c,d.next=24,b.awrap(this.crypto.hmac256(u,o));case 24:return l=d.sent,d.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:u,enc_item_key:i,auth_hash:l}));case 26:case"end":return d.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){l.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:return a=e.enc_item_key,a=this.version+a,i=this.encryptionComponentsFromString(a,t.itemsKey),l.next=11,b.awrap(this.decryptString(i.ciphertext,i.key));case 11:if(s=l.sent){l.next=15;break}return console.error('Error decrypting parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 15:return l.next=17,b.awrap(this.firstHalfOfKey(s));case 17:return o=l.sent,c=this.encryptionComponentsFromString(e.contentString,o),l.next=21,b.awrap(this.decryptString(c.ciphertext,c.key));case 21:if(u=l.sent){l.next=26;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 27:case"end":return l.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString",value:function(e,t){var n=e.substring(0,Q.a.VersionLength);return{ciphertext:e.substring(Q.a.VersionLength,e.length),version:n,key:t}}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content001.pw_salt,t.content001.pw_cost,Rn.a.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,2),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],version:Q.a.V001,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V001}}]),n})();function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach(function(t){Kn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fn=(function(e){d(n,An);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.b.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V002},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return r=Object(_.F)(Rn.b.PbkdfCostsUsed),o.next=3,b.awrap(this.crypto.generateRandomKey(Rn.b.SaltSeedLength));case 3:return a=o.sent,o.next=6,b.awrap(this.crypto.unsafeSha1(e+':'+a));case 6:return i=o.sent,s=Object(A.b)({email:e,pw_nonce:a,pw_cost:r,pw_salt:i,version:Q.a.V002,origination:n,created:"".concat(Date.now())}),o.abrupt("return",this.deriveKey(t,s));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"decryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcDecrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptString002",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.crypto.aes256CbcEncrypt(e,n,t));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"encryptTextParams",value:function(e,t,n,r,a,i){var s,o,c,u,l,p,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,b.awrap(this.crypto.generateRandomKey(Rn.b.EncryptionIvLength));case 2:return s=h.sent,h.next=5,b.awrap(this.encryptString002(e,t,s));case 5:return o=h.sent,c=[a,r,s,o].join(':'),h.next=9,b.awrap(this.crypto.hmac256(c,n));case 9:if(u=h.sent,l=[a,u,r,s,o],!i){h.next=16;break}return h.next=14,b.awrap(this.crypto.base64Encode(JSON.stringify(i.content)));case 14:p=h.sent,l.push(p);case 16:return d=l.join(':'),h.abrupt("return",d);case 18:case"end":return h.stop()}},null,this,null,Promise)}},{key:"decryptTextParams",value:function(e,t,n,r,a,i){var s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n){o.next=2;break}throw'Attempting to decryptTextParams with null encryptionKey';case 2:return o.next=4,b.awrap(this.crypto.hmac256(e,i));case 4:if(s=o.sent,!1!==this.crypto.timingSafeEqual(a,s)){o.next=8;break}return we.a.error(Error('Auth hash does not match.')),o.abrupt("return",null);case 8:return o.abrupt("return",this.decryptString002(t,n,r));case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(t=this.encryptionComponentsFromString002(e.enc_item_key),n=t.keyParams){i.next=4;break}return i.abrupt("return",void 0);case 4:return i.t0=JSON,i.next=7,b.awrap(this.crypto.base64Decode(n));case 7:return i.t1=i.sent,r=i.t0.parse.call(i.t0,i.t1),a=Tn({},r),i.abrupt("return",a);case 11:case"end":return i.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(r&&r.itemsKey){u.next=6;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 6:return u.next=8,b.awrap(this.crypto.generateRandomKey(2*Rn.b.EncryptionKeyLength));case 8:return a=u.sent,u.next=11,b.awrap(this.encryptTextParams(a,r.itemsKey,r.dataAuthenticationKey,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 11:return i=u.sent,u.next=14,b.awrap(this.firstHalfOfKey(a));case 14:return s=u.sent,u.next=17,b.awrap(this.secondHalfOfKey(a));case 17:return o=u.sent,u.next=20,b.awrap(this.encryptTextParams(JSON.stringify(e.content),s,o,e.uuid,r.keyVersion,r instanceof Ve?r.keyParams:void 0));case 20:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:c,enc_item_key:i}));case 22:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u,l,d;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){h.next=3;break}return h.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.enc_item_key){h.next=6;break}return we.a.error(Error('Missing item encryption key, skipping decryption.')),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 6:if(t&&t.itemsKey){h.next=8;break}throw Error('Attempting to generateDecryptedParameters with no itemsKey.');case 8:return a=e.enc_item_key,i=this.encryptionComponentsFromString002(a,t.itemsKey,t.dataAuthenticationKey),h.next=12,b.awrap(this.decryptTextParams(i.ciphertextToAuth,i.contentCiphertext,i.encryptionKey,i.iv,i.authHash,i.authKey));case 12:if(s=h.sent){h.next=16;break}return console.error('Error decrypting item_key parameters',e),h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 16:return h.next=18,b.awrap(this.firstHalfOfKey(s));case 18:return o=h.sent,h.next=21,b.awrap(this.secondHalfOfKey(s));case 21:return c=h.sent,u=this.encryptionComponentsFromString002(e.contentString,o,c),h.next=25,b.awrap(this.decryptTextParams(u.ciphertextToAuth,u.contentCiphertext,u.encryptionKey,u.iv,u.authHash,u.authKey));case 25:if(l=h.sent){h.next=30;break}return h.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 30:return h.prev=30,h.t0=JSON,h.next=34,b.awrap(this.crypto.base64Decode(u.keyParams));case 34:h.t1=h.sent,d=h.t0.parse.call(h.t0,h.t1),h.next=40;break;case 38:h.prev=38,h.t2=h.catch(30);case 40:return h.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(l),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,auth_params:d,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 41:case"end":return h.stop()}},null,this,[[30,38]],Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.pbkdf2(e,t.content002.pw_salt,t.content002.pw_cost,Rn.b.PbkdfOutputLength));case 2:return n=i.sent,r=this.splitKey(n,3),i.next=6,b.awrap(Ve.Create({serverPassword:r[0],masterKey:r[1],dataAuthenticationKey:r[2],version:Q.a.V002,keyParams:t.getPortableValue()}));case 6:return a=i.sent,i.abrupt("return",a);case 8:case"end":return i.stop()}},null,this,null,Promise)}},{key:"encryptionComponentsFromString002",value:function(e,t,n){var r=e.split(':');return{encryptionVersion:r[0],authHash:r[1],uuid:r[2],iv:r[3],contentCiphertext:r[4],keyParams:r[5],ciphertextToAuth:[r[0],r[2],r[3],r[4]].join(':'),encryptionKey:t,authKey:n}}},{key:"version",get:function(){return Q.a.V002}}]),n})(),Ln=(function(e){d(n,Fn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"generateNewItemsKeyContent",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=Rn.c.EncryptionKeyLength,a.next=3,b.awrap(this.crypto.generateRandomKey(e));case 3:return t=a.sent,a.next=6,b.awrap(this.crypto.generateRandomKey(e));case 6:return n=a.sent,r={itemsKey:t,dataAuthenticationKey:n,version:Q.a.V003},a.abrupt("return",r);case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deriveKey",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.generateSalt(t.content003.identifier,Q.a.V003,Rn.c.PbkdfCost,t.content003.pw_nonce));case 2:return n=s.sent,s.next=5,b.awrap(this.crypto.pbkdf2(e,n,Rn.c.PbkdfCost,Rn.c.PbkdfOutputLength));case 5:return r=s.sent,a=this.splitKey(r,3),s.next=9,b.awrap(Ve.Create({serverPassword:a[0],masterKey:a[1],dataAuthenticationKey:a[2],version:Q.a.V003,keyParams:t.getPortableValue()}));case 9:return i=s.sent,s.abrupt("return",i);case 11:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V003,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.c.SaltSeedLength));case 3:return a=s.sent,i=Object(A.c)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"generateSalt",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.crypto.sha256([e,'SF',t,n,r].join(':')));case 2:return a=i.sent,i.abrupt("return",a);case 4:case"end":return i.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V003}}]),n})();function Un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Un(Object(n),!0).forEach(function(t){Vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Un(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Bn,Wn=(function(e){d(n,Ln);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"getEncryptionDisplayName",value:function(){return'XChaCha20-Poly1305'}},{key:"generateNewItemsKeyContent",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 2:return e=n.sent,t={itemsKey:e,version:Q.a.V004},n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"generateSalt004",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.crypto.sha256([e,t].join(":")));case 2:return n=r.sent,r.abrupt("return",Object(_.T)(n,Rn.d.ArgonSaltLength));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"computeRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.deriveKey(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n){var r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=Q.a.V004,s.next=3,b.awrap(this.crypto.generateRandomKey(Rn.d.ArgonSaltSeedLength));case 3:return a=s.sent,i=Object(A.d)({identifier:e,pw_nonce:a,version:r,origination:n,created:"".concat(Date.now())}),s.abrupt("return",this.deriveKey(t,i));case 6:case"end":return s.stop()}},null,this,null,Promise)}},{key:"encryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n){a.next=2;break}throw'encryptString null nonce';case 2:if(t){a.next=4;break}throw'encryptString null rawKey';case 4:return a.t0=this.crypto,a.t1=e,a.t2=n,a.t3=t,a.next=10,b.awrap(this.authenticatedDataToString(r));case 10:return a.t4=a.sent,a.abrupt("return",a.t0.xchacha20Encrypt.call(a.t0,a.t1,a.t2,a.t3,a.t4));case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"decryptString004",value:function(e,t,n,r){return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt("return",this.crypto.xchacha20Decrypt(e,n,t,r));case 1:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateEncryptedProtocolString",value:function(e,t,n){var r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionNonceLength));case 2:return r=o.sent,a=Q.a.V004,o.next=6,b.awrap(this.encryptString004(e,t,r,n));case 6:return i=o.sent,o.t0=a,o.t1=r,o.t2=i,o.next=12,b.awrap(this.authenticatedDataToString(n));case 12:return o.t3=o.sent,s=[o.t0,o.t1,o.t2,o.t3],o.abrupt("return",s.join(":"));case 15:case"end":return o.stop()}},null,this,null,Promise)}},{key:"getPayloadAuthenticatedData",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e.format===ue.a.EncryptedString){a.next=2;break}throw Error('Attempting to get embedded key params of already decrypted item');case 2:return t=this.deconstructEncryptedPayloadString(e.enc_item_key),n=t.rawAuthenticatedData,a.next=6,b.awrap(this.stringToAuthenticatedData(n));case 6:return r=a.sent,a.abrupt("return",r);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"generateAuthenticatedDataForPayload",value:function(e,t){var n={u:e.uuid,v:Q.a.V004};if(Object(Re.a)(e.content_type))return Nn(Nn({},n),{},{kp:t.keyParams.content});if(!(t instanceof J))throw Error('Attempting to use non-items key for regular item.');return n}},{key:"authenticatedDataToString",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.base64Encode(JSON.stringify(Object(_.Q)(Object(_.K)(e)))));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"stringToAuthenticatedData",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=JSON,r.next=3,b.awrap(this.crypto.base64Decode(e));case 3:return r.t1=r.sent,n=r.t0.parse.call(r.t0,r.t1),r.abrupt("return",Object(_.Q)(Nn(Nn({},n),t)));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"generateEncryptedParameters",value:function(e,t,r){var a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:if(t!==ue.a.DecryptedBareObject&&t!==ue.a.DecryptedBase64String){u.next=2;break}return u.abrupt("return",p(f(n.prototype),"generateEncryptedParameters",this).call(this,e,t,r));case 2:if(t===ue.a.EncryptedString){u.next=4;break}throw"Unsupport format for generateEncryptedParameters ".concat(t);case 4:if(e.uuid){u.next=6;break}throw'payload.uuid cannot be null';case 6:if(r&&r.itemsKey){u.next=8;break}throw'Attempting to generateEncryptedParameters with no itemsKey.';case 8:return u.next=10,b.awrap(this.crypto.generateRandomKey(Rn.d.EncryptionKeyLength));case 10:return a=u.sent,i=JSON.stringify(e.content),s=this.generateAuthenticatedDataForPayload(e,r),u.next=15,b.awrap(this.generateEncryptedProtocolString(i,a,s));case 15:return o=u.sent,u.next=18,b.awrap(this.generateEncryptedProtocolString(a,r.itemsKey,s));case 18:return c=u.sent,u.abrupt("return",Object(Ee.c)({uuid:e.uuid,items_key_id:r instanceof J?r.uuid:void 0,content:o,enc_item_key:c}));case 20:case"end":return u.stop()}},null,this,null,Promise)}},{key:"generateDecryptedParameters",value:function(e,t){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if((r=e.format)!==ue.a.DecryptedBareObject&&r!==ue.a.DecryptedBase64String){l.next=3;break}return l.abrupt("return",p(f(n.prototype),"generateDecryptedParameters",this).call(this,e,t));case 3:if(e.uuid){l.next=5;break}throw'encryptedParameters.uuid cannot be null';case 5:if(t&&t.itemsKey){l.next=7;break}throw'Attempting to generateDecryptedParameters with no itemsKey.';case 7:return a=this.deconstructEncryptedPayloadString(e.enc_item_key),l.next=10,b.awrap(this.stringToAuthenticatedData(a.rawAuthenticatedData,{u:e.uuid,v:e.version}));case 10:return i=l.sent,l.next=13,b.awrap(this.authenticatedDataToString(i));case 13:return s=l.sent,l.next=16,b.awrap(this.decryptString004(a.ciphertext,t.itemsKey,a.nonce,s));case 16:if(o=l.sent){l.next=20;break}return console.error('Error decrypting itemKey parameters',e),l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 20:return c=this.deconstructEncryptedPayloadString(e.contentString),l.next=23,b.awrap(this.decryptString004(c.ciphertext,o,c.nonce,s));case 23:if(u=l.sent){l.next=28;break}return l.abrupt("return",Object(Ee.a)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 28:return l.abrupt("return",Object(Ee.a)(e,{content:JSON.parse(u),items_key_id:void 0,enc_item_key:void 0,auth_hash:void 0,errorDecrypting:!1,errorDecryptingValueChanged:!0===e.errorDecrypting,waitingForKey:!1}));case 29:case"end":return l.stop()}},null,this,null,Promise)}},{key:"deconstructEncryptedPayloadString",value:function(e){var t=e.split(":");return{version:t[0],nonce:t[1],ciphertext:t[2],rawAuthenticatedData:t[3]}}},{key:"deriveKey",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.generateSalt004(t.content004.identifier,t.content004.pw_nonce));case 2:return n=o.sent,o.next=5,b.awrap(this.crypto.argon2(e,n,Rn.d.ArgonIterations,Rn.d.ArgonMemLimit,Rn.d.ArgonOutputKeyBytes));case 5:return r=o.sent,a=this.splitKey(r,2),i=a[0],s=a[1],o.abrupt("return",Ve.Create({masterKey:i,serverPassword:s,version:Q.a.V004,keyParams:t.getPortableValue()}));case 10:case"end":return o.stop()}},null,this,null,Promise)}},{key:"version",get:function(){return Q.a.V004}}]),n})();function Hn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(n),!0).forEach(function(t){qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!(function(e){e[e.RootKeyNone=0]="RootKeyNone",e[e.RootKeyOnly=1]="RootKeyOnly",e[e.RootKeyPlusWrapper=2]="RootKeyPlusWrapper",e[e.WrapperOnly=3]="WrapperOnly"})(Bn||(Bn={}));var Yn=Q.a.V003,Gn=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o){var c;return v(this,n),(c=t.call(this)).itemManager=e,c.payloadManager=r,c.storageService=i,c.identifier=s,c.operators={},c.keyMode=Bn.RootKeyNone,c.keyObservers=[],c.itemManager=e,c.payloadManager=r,c.deviceInterface=a,c.storageService=i,c.crypto=o,Object(_.y)()?I.SetGenerators(c.crypto.generateUUID,void 0):I.SetGenerators(c.crypto.generateUUID,c.crypto.generateUUIDSync),Object.defineProperty(u(c),'rootKey',{enumerable:!1,writable:!0}),c.removeItemsObserver=c.itemManager.addObserver([F.a.ItemsKey],function(e,t){e.concat(t).length>0&&c.decryptErroredItems()}),c}return y(n,[{key:"deinit",value:function(){this.itemManager=void 0,this.payloadManager=void 0,this.deviceInterface=void 0,this.storageService=void 0,this.crypto.deinit(),this.crypto=void 0,this.operators={},this.keyObservers.length=0,this.removeItemsObserver(),this.removeItemsObserver=null,this.rootKey=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initialize",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:return e=a.sent,a.next=5,b.awrap(this.getAccountKeyParams());case 5:return t=a.sent,a.next=8,b.awrap(this.hasRootKeyWrapper());case 8:if(n=a.sent,r=!Object(_.w)(e)||!Object(_.w)(t),!n||!r){a.next=14;break}this.keyMode=Bn.RootKeyPlusWrapper,a.next=27;break;case 14:if(!n||r){a.next=18;break}this.keyMode=Bn.WrapperOnly,a.next=27;break;case 18:if(n||!r){a.next=22;break}this.keyMode=Bn.RootKeyOnly,a.next=27;break;case 22:if(n||r){a.next=26;break}this.keyMode=Bn.RootKeyNone,a.next=27;break;case 26:throw'Invalid key mode condition';case 27:if(this.keyMode!==Bn.RootKeyOnly){a.next=33;break}return a.next=30,b.awrap(this.getRootKeyFromKeychain());case 30:return this.rootKey=a.sent,a.next=33,b.awrap(this.notifyObserversOfKeyChange());case 33:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getEncryptionSourceVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.hasAccount()){t.next=4;break}return t.abrupt("return",this.getUserVersion());case 4:if(!this.hasPasscode()){t.next=9;break}return t.next=7,b.awrap(this.getRootKeyWrapperKeyParams());case 7:return e=t.sent,t.abrupt("return",e.version);case 9:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getEncryptionDisplayName",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getEncryptionSourceVersion());case 2:if(!(e=t.sent)){t.next=5;break}return t.abrupt("return",this.operatorForVersion(e).getEncryptionDisplayName());case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLatestVersion",value:function(){return Q.a.V004}},{key:"hasAccount",value:function(){switch(this.keyMode){case Bn.RootKeyNone:case Bn.WrapperOnly:return!1;case Bn.RootKeyOnly:case Bn.RootKeyPlusWrapper:return!0;default:throw Error("Unhandled keyMode value '".concat(this.keyMode,"'."))}}},{key:"getUserVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getAccountKeyParams());case 2:return e=t.sent,t.abrupt("return",null===e||void 0===e?void 0:e.version);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"upgradeAvailable",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.accountUpgradeAvailable());case 2:return e=n.sent,n.next=5,b.awrap(this.passcodeUpgradeAvailable());case 5:return t=n.sent,n.abrupt("return",e||t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"accountUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"passcodeUpgradeAvailable",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",e.version!==this.getLatestVersion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"platformSupportsKeyDerivation",value:function(e){return Object(Q.b)(e.version,Q.a.V004)>=0||(!!Object(_.C)()||Object(_.y)())}},{key:"supportedVersions",value:function(){return[Q.a.V001,Q.a.V002,Q.a.V003,Q.a.V004]}},{key:"isVersionNewerThanLibraryVersion",value:function(e){var t=this.getLatestVersion();return 1===Object(Q.b)(e,t)}},{key:"isProtocolVersionOutdated",value:function(e){var t,n=(g(t={},Q.a.V001,Date.parse('2018-01-01')),g(t,Q.a.V002,Date.parse('2020-01-01')),t)[e];return!!n&&(new Date).getTime()>n}},{key:"costMinimumForVersion",value:function(e){if(Object(Q.b)(e,Q.a.V003)>=0)throw'Cost minimums only apply to versions <= 002';if(e===Q.a.V001)return Rn.a.PbkdfMinCost;if(e===Q.a.V002)return Rn.b.PbkdfMinCost;throw"Invalid version for cost minimum: ".concat(e)}},{key:"createOperatorForLatestVersion",value:function(){return this.createOperatorForVersion(this.getLatestVersion())}},{key:"createOperatorForVersion",value:function(e){if(e===Q.a.V001)return new An(this.crypto);if(e===Q.a.V002)return new Fn(this.crypto);if(e===Q.a.V003)return new Ln(this.crypto);if(e===Q.a.V004)return new Wn(this.crypto);if(e===Q.a.V000Base64Decrypted)return this.createOperatorForLatestVersion();throw Error("Unable to find operator for version ".concat(e))}},{key:"operatorForVersion",value:function(e){var t=e,n=this.operators[t];return n||(n=this.createOperatorForVersion(e),this.operators[t]=n),n}},{key:"defaultOperator",value:function(){return this.operatorForVersion(this.getLatestVersion())}},{key:"computeRootKey",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=t.version,r=this.operatorForVersion(n),a.abrupt("return",r.computeRootKey(e,t));case 3:case"end":return a.stop()}},null,this,null,Promise)}},{key:"createRootKey",value:function(e,t,n,r){var a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return a=r?this.operatorForVersion(r):this.defaultOperator(),i.abrupt("return",a.createRootKey(e,t,n));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"payloadContentFormatForIntent",value:function(e,t){if(t){if(e===Re.b.Sync||e===Re.b.FileEncrypted||e===Re.b.FilePreferEncrypted||e===Re.b.LocalStorageEncrypted||e===Re.b.LocalStoragePreferEncrypted)return ue.a.EncryptedString;throw'Unhandled encrypted case in protocolService.payloadContentFormatForIntent.'}if(e===Re.b.LocalStorageDecrypted||e===Re.b.LocalStoragePreferEncrypted||e===Re.b.FileDecrypted||e===Re.b.FilePreferEncrypted)return ue.a.DecryptedBareObject;if(e===Re.b.SyncDecrypted)return ue.a.DecryptedBase64String;throw'Unhandled decrypted case in protocolService.payloadContentFormatForIntent.'}},{key:"payloadByEncryptingPayload",value:function(e,t,n){var r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(!e.errorDecrypting){l.next=2;break}return l.abrupt("return",e);case 2:if(!e.deleted){l.next=4;break}return l.abrupt("return",e);case 4:if(!Object(_.w)(t)){l.next=6;break}throw Error('Attempting to encrypt payload with null intent');case 6:if(n||Object(Re.d)(t)){l.next=10;break}return l.next=9,b.awrap(this.keyToUseForEncryptionOfPayload(e,t));case 9:n=l.sent;case 10:if(n||!Object(Re.c)(t)){l.next=12;break}throw Error('Attempting to generate encrypted payload with no key.');case 12:if(e.format===ue.a.DecryptedBareObject){l.next=14;break}throw Error('Attempting to encrypt already encrypted payload.');case 14:if(e.content){l.next=16;break}throw Error('Attempting to encrypt payload with no content.');case 16:if(e.uuid){l.next=18;break}throw Error('Attempting to encrypt payload with no uuid.');case 18:if(!(null!==(r=n)&&void 0!==r&&r.errorDecrypting||null!==(a=n)&&void 0!==a&&a.waitingForKey)){l.next=20;break}throw Error('Attempting to encrypt payload with encrypted key.');case 20:return i=n?n.keyVersion:this.getLatestVersion(),s=this.payloadContentFormatForIntent(t,n),o=this.operatorForVersion(i),l.next=25,b.awrap(o.generateEncryptedParameters(e,s,n));case 25:if(c=l.sent){l.next=28;break}throw'Unable to generate encryption parameters';case 28:return u=Object(Ee.d)(e,t,c),l.abrupt("return",u);case 30:case"end":return l.stop()}},null,this,null,Promise)}},{key:"payloadsByEncryptingPayloads",value:function(e,t,n){var r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){u.next=11;break}return s=i.value,o=Object(_.v)(t)?t(s):t,u.next=7,b.awrap(this.payloadByEncryptingPayload(s,o,n));case 7:c=u.sent,r.push(c);case 9:u.next=2;break;case 11:return u.abrupt("return",r);case 12:case"end":return u.stop()}},null,this,null,Promise)}},{key:"payloadByDecryptingPayload",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content){c.next=3;break}return we.a.error(Error('Attempting to decrypt payload that has no content.')),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0}));case 3:if((r=e.format)!==ue.a.DecryptedBareObject){c.next=6;break}return c.abrupt("return",e);case 6:if(t||r!==ue.a.EncryptedString){c.next=10;break}if(t=this.keyToUseForDecryptionOfPayload(e)){c.next=10;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 10:if(null===(n=t)||void 0===n||!n.errorDecrypting){c.next=12;break}return c.abrupt("return",Object(Ee.e)(e,{waitingForKey:!0,errorDecrypting:!0}));case 12:return a=e.version,i=e.source,s=this.operatorForVersion(a),c.prev=15,c.next=18,b.awrap(s.generateDecryptedParameters(e,t));case 18:return o=c.sent,c.abrupt("return",Object(Ee.e)(e,o,i));case 22:return c.prev=22,c.t0=c.catch(15),console.error('Error decrypting payload',e,c.t0),c.abrupt("return",Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting}));case 26:case"end":return c.stop()}},null,this,[[15,22]],Promise)}},{key:"payloadsByDecryptingPayloads",value:function(e,t){var n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=function(e){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e){n.next=2;break}return n.abrupt("return",e);case 2:if(!0!==e.deleted||!Object(_.w)(e.content)){n.next=4;break}return n.abrupt("return",e);case 4:if(Object(_.A)(e.content)){n.next=7;break}return n.abrupt("return",e);case 7:return n.abrupt("return",r.payloadByDecryptingPayload(e,t));case 8:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",Promise.all(e.map(function(e){return n(e)})));case 2:case"end":return a.stop()}},null,null,null,Promise)}},{key:"decryptErroredItems",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==(e=this.itemManager.invalidItems.filter(function(e){return e.content_type!==F.a.ItemsKey})).length){r.next=3;break}return r.abrupt("return");case 3:return t=e.map(function(e){return e.payloadRepresentation()}),r.next=6,b.awrap(this.payloadsByDecryptingPayloads(t));case 6:return n=r.sent,r.next=9,b.awrap(this.payloadManager.emitPayloads(n,ht.a.LocalChanged));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsByDecryptingBackupFile",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v=this;return b.async(function(y){for(;;)switch(y.prev=y.next){case 0:if(n=e.keyParams||e.auth_params,r=e.items,a=r.map(function(e){return Object(Ee.f)(e,ht.a.FileImport)}),i=[],!n){y.next=28;break}return s=this.createKeyParams(n),y.next=8,b.awrap(this.computeRootKey(t,s));case 8:return o=y.sent,c=a.filter(function(e){return e.content_type===F.a.ItemsKey}),y.next=12,b.awrap(this.payloadsByDecryptingPayloads(c,o));case 12:u=y.sent,l=u.map(function(e){return nt(e)}),Object(_.o)(i,u),p=function(e){var t,n,r,a;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(e.content_type!==F.a.ItemsKey){c.next=2;break}return c.abrupt("return","continue");case 2:return c.prev=2,e.items_key_id&&(t=v.itemsKeyForPayload(e)),t||(n=u.find(function(t){return e.items_key_id===t.uuid}),r=e.version,n?t=nt(n):Object(Q.d)(s.version,Q.a.V004)?t=v.defaultItemsKeyForItemVersion(r,l):Object(Q.b)(r,Q.a.V003)<=0&&(t=o)),c.next=7,b.awrap(v.payloadByDecryptingPayload(e,t));case 7:a=c.sent,i.push(a),c.next=15;break;case 11:c.prev=11,c.t0=c.catch(2),i.push(Object(Ee.e)(e,{errorDecrypting:!0,errorDecryptingValueChanged:!e.errorDecrypting})),console.error('Error decrypting payload',e,c.t0);case 15:case"end":return c.stop()}},null,null,[[2,11]],Promise)},d=S(a);case 17:if((h=d()).done){y.next=26;break}return f=h.value,y.next=21,b.awrap(p(f));case 21:if("continue"!==y.sent){y.next=24;break}return y.abrupt("continue",24);case 24:y.next=17;break;case 26:y.next=29;break;case 28:i=a;case 29:return y.abrupt("return",i);case 30:case"end":return y.stop()}},null,this,null,Promise)}},{key:"createKeyParams",value:function(e){return Object(A.e)(e)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return t=this.itemManager.items,e===Re.b.FileDecrypted&&(t=t.filter(function(e){return e.content_type!==F.a.ItemsKey})),n=Promise.all(t.map(function(t){if(t.errorDecrypting)return t.payload.ejected();var n=Object(Ee.f)(t.payload,ht.a.FileImport);return i.payloadByEncryptingPayload(n,e).then(function(e){return e.ejected()})})),s.t0=this.getLatestVersion(),s.next=6,b.awrap(n);case 6:if(s.t1=s.sent,r={version:s.t0,items:s.t1},e!==Re.b.FileEncrypted){s.next=13;break}return s.next=11,b.awrap(this.getRootKeyParams());case 11:a=s.sent,r.keyParams=null===a||void 0===a?void 0:a.getPortableValue();case 13:return s.abrupt("return",r);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"onKeyStatusChange",value:function(e){var t=this;return this.keyObservers.push(e),function(){Object(_.M)(t.keyObservers,e)}}},{key:"notifyObserversOfKeyChange",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:e=S(this.keyObservers);case 1:if((t=e()).done){r.next=7;break}return n=t.value,r.next=5,b.awrap(n());case 5:r.next=1;break;case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getRootKeyFromKeychain",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.deviceInterface.getNamespacedKeychainValue(this.identifier));case 2:if(e=n.sent,!Object(_.w)(e)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.t0=b,n.t1=Ve,n.t2=zn,n.t3=zn({},e),n.t4={},n.next=12,b.awrap(this.getRootKeyParams());case 12:return n.t5=n.sent,n.t6={keyParams:n.t5},n.t7=(0,n.t2)(n.t3,n.t4,n.t6),n.t8=n.t1.Create.call(n.t1,n.t7),n.next=18,n.t0.awrap.call(n.t0,n.t8);case 18:return t=n.sent,n.abrupt("return",t);case 20:case"end":return n.stop()}},null,this,null,Promise)}},{key:"saveRootKeyToKeychain",value:function(){var e,t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Object(_.w)(this.rootKey)){n.next=2;break}throw'Attempting to non-existent root key to the keychain.';case 2:if(this.keyMode===Bn.RootKeyOnly){n.next=4;break}throw'Should not be persisting wrapped key to keychain.';case 4:return e=this.rootKey.getKeychainValue(),n.abrupt("return",this.executeCriticalFunction(function(){return t.deviceInterface.setNamespacedKeychainValue(e,t.identifier)}));case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"hasRootKeyWrapper",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return e=t.sent,t.abrupt("return",!Object(_.w)(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"hasPasscode",value:function(){return this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper}},{key:"rootKeyNeedsUnwrapping",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.hasRootKeyWrapper());case 2:if(e.t0=e.sent,!e.t0){e.next=5;break}e.t0=Object(_.w)(this.rootKey);case 5:return e.abrupt("return",e.t0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyWrapperKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getWrappedRootKey",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.storageService.getValue(o.WrappedRootKey,De.Nonwrapped));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getRootKeyParams",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode!==Bn.WrapperOnly){e.next=4;break}return e.abrupt("return",this.getRootKeyWrapperKeyParams());case 4:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){e.next=8;break}return e.abrupt("return",this.getAccountKeyParams());case 8:if(this.keyMode!==Bn.RootKeyNone){e.next=12;break}return e.abrupt("return",void 0);case 12:throw"Unhandled key mode for getRootKeyParams ".concat(this.keyMode);case 13:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getAccountKeyParams",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.RootKeyParams,De.Nonwrapped));case 2:if(e=t.sent){t.next=5;break}return t.abrupt("return",void 0);case 5:return t.abrupt("return",this.createKeyParams(e));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateWrappingKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getWrappedRootKey());case 2:if(t=a.sent,this.keyMode!==Bn.WrapperOnly){a.next=7;break}return a.abrupt("return",this.storageService.canDecryptWithKey(e));case 7:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){a.next=15;break}return n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:return r=a.sent,a.abrupt("return",!r.errorDecrypting);case 15:throw'Unhandled case in validateWrappingKey';case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"computeWrappingKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=r.sent,r.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=r.sent,r.abrupt("return",n);case 7:case"end":return r.stop()}},null,this,null,Promise)}},{key:"unwrapRootKey",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.keyMode!==Bn.WrapperOnly){a.next=3;break}return this.rootKey=e,a.abrupt("return");case 3:if(this.keyMode===Bn.RootKeyPlusWrapper){a.next=5;break}throw'Invalid key mode condition for unwrapping.';case 5:return a.next=7,b.awrap(this.getWrappedRootKey());case 7:return t=a.sent,n=Object(Ee.e)(t),a.next=11,b.awrap(this.payloadByDecryptingPayload(n,e));case 11:if(!(r=a.sent).errorDecrypting){a.next=16;break}throw Error('Unable to decrypt root key with provided wrapping key.');case 16:return a.next=18,b.awrap(Ve.Create(r.contentObject,r.uuid));case 18:return this.rootKey=a.sent,a.next=21,b.awrap(this.notifyObserversOfKeyChange());case 21:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setNewRootKeyWrapper",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.keyMode!==Bn.RootKeyNone){t.next=4;break}this.keyMode=Bn.WrapperOnly,t.next=9;break;case 4:if(this.keyMode!==Bn.RootKeyOnly){t.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,t.next=9;break;case 8:throw Error('Attempting to set wrapper on already wrapped key.');case 9:return t.next=11,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 11:if(this.keyMode!==Bn.WrapperOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){t.next=26;break}if(this.keyMode!==Bn.WrapperOnly){t.next=18;break}return this.rootKey=e,t.next=16,b.awrap(this.reencryptItemsKeys());case 16:t.next=20;break;case 18:return t.next=20,b.awrap(this.wrapAndPersistRootKey(e));case 20:return t.next=22,b.awrap(this.storageService.setValue(o.RootKeyWrapperKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 22:return t.next=24,b.awrap(this.notifyObserversOfKeyChange());case 24:t.next=27;break;case 26:throw Error('Invalid keyMode on setNewRootKeyWrapper');case 27:case"end":return t.stop()}},null,this,null,Promise)}},{key:"wrapAndPersistRootKey",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=Object(Ee.e)(this.rootKey,{content:this.rootKey.persistableValueWhenWrapping()}),r.next=3,b.awrap(this.payloadByEncryptingPayload(t,Re.b.LocalStorageEncrypted,e));case 3:return n=r.sent,r.next=6,b.awrap(this.storageService.setValue(o.WrappedRootKey,n.ejected(),De.Nonwrapped));case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"removeRootKeyWrapper",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.keyMode===Bn.WrapperOnly||this.keyMode===Bn.RootKeyPlusWrapper){e.next=2;break}throw Error('Attempting to remove root key wrapper on unwrapped key.');case 2:return this.keyMode===Bn.WrapperOnly?(this.keyMode=Bn.RootKeyNone,this.rootKey=void 0):this.keyMode===Bn.RootKeyPlusWrapper&&(this.keyMode=Bn.RootKeyOnly),e.next=5,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 5:return e.next=7,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 7:if(this.keyMode!==Bn.RootKeyOnly){e.next=10;break}return e.next=10,b.awrap(this.saveRootKeyToKeychain());case 10:return e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setRootKey",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.keyParams){n.next=2;break}throw Error('keyParams must be supplied if setting root key.');case 2:if(this.rootKey!==e){n.next=4;break}throw Error('Attempting to set root key as same current value.');case 4:if(this.keyMode!==Bn.WrapperOnly){n.next=8;break}this.keyMode=Bn.RootKeyPlusWrapper,n.next=16;break;case 8:if(this.keyMode!==Bn.RootKeyNone){n.next=12;break}this.keyMode=Bn.RootKeyOnly,n.next=16;break;case 12:if(this.keyMode!==Bn.RootKeyOnly&&this.keyMode!==Bn.RootKeyPlusWrapper){n.next=15;break}n.next=16;break;case 15:throw Error("Unhandled key mode for setNewRootKey ".concat(this.keyMode));case 16:return this.rootKey=e,n.next=19,b.awrap(this.storageService.setValue(o.RootKeyParams,e.keyParams.getPortableValue(),De.Nonwrapped));case 19:if(this.keyMode!==Bn.RootKeyOnly){n.next=24;break}return n.next=22,b.awrap(this.saveRootKeyToKeychain());case 22:n.next=29;break;case 24:if(this.keyMode!==Bn.RootKeyPlusWrapper){n.next=29;break}if(t){n.next=27;break}throw Error('wrappingKey must be supplied');case 27:return n.next=29,b.awrap(this.wrapAndPersistRootKey(t));case 29:return n.next=31,b.awrap(this.notifyObserversOfKeyChange());case 31:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getRootKey",value:function(){return this.rootKey}},{key:"clearLocalKeyState",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.deviceInterface.clearNamespacedKeychainValue(this.identifier));case 2:return e.next=4,b.awrap(this.storageService.removeValue(o.WrappedRootKey,De.Nonwrapped));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.RootKeyWrapperKeyParams,De.Nonwrapped));case 6:return e.next=8,b.awrap(this.storageService.removeValue(o.RootKeyParams,De.Nonwrapped));case 8:return this.keyMode=Bn.RootKeyNone,this.rootKey=void 0,e.next=12,b.awrap(this.notifyObserversOfKeyChange());case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:if(n=a.sent,!(r=this.rootKey.compare(n))){a.next=11;break}return a.abrupt("return",{valid:r,artifacts:{rootKey:n}});case 11:return a.abrupt("return",{valid:!1});case 12:case"end":return a.stop()}},null,this,null,Promise)}},{key:"validatePasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,b.awrap(this.getRootKeyWrapperKeyParams());case 2:return t=a.sent,a.next=5,b.awrap(this.computeRootKey(e,t));case 5:return n=a.sent,a.next=8,b.awrap(this.validateWrappingKey(n));case 8:if(!(r=a.sent)){a.next=13;break}return a.abrupt("return",{valid:r,artifacts:{wrappingKey:n}});case 13:return a.abrupt("return",{valid:!1});case 14:case"end":return a.stop()}},null,this,null,Promise)}},{key:"keyToUseForEncryptionOfPayload",value:function(e,t){var n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Object(_.w)(t)){s.next=2;break}throw'Intent must be supplied when looking up key for encryption of item.';case 2:if(!Object(Re.a)(e.content_type)){s.next=13;break}if(n=this.getRootKey()){s.next=10;break}if(!Object(Re.c)(t)){s.next=9;break}throw Error('Root key encryption is required but no root key is available.');case 9:return s.abrupt("return",void 0);case 10:return s.abrupt("return",n);case 13:return r=this.getDefaultItemsKey(),s.next=16,b.awrap(this.getUserVersion());case 16:if(!(a=s.sent)||a===(null===r||void 0===r?void 0:r.keyVersion)){s.next=22;break}return i=this.latestItemsKeys(),s.abrupt("return",i.find(function(e){return e.keyVersion===a}));case 22:return s.abrupt("return",r);case 23:case"end":return s.stop()}},null,this,null,Promise)}},{key:"keyToUseForDecryptionOfPayload",value:function(e){if(Object(Re.a)(e.content_type))return this.getRootKey();if(e.items_key_id)return this.itemsKeyForPayload(e);var t=e.version;if(t!==this.getLatestVersion())return this.defaultItemsKeyForItemVersion(t);we.a.error(Error('No associated key found for item encrypted with latest protocol version.'))}},{key:"onSyncEvent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e!==At.b.FullSyncCompleted){t.next=3;break}return t.next=3,b.awrap(this.handleFullSyncCompletion());case 3:if(e!==At.b.DownloadFirstSyncCompleted){t.next=6;break}return t.next=6,b.awrap(this.handleDownloadFirstSyncCompletion());case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"handleDownloadFirstSyncCompletion",value:function(){var e,t,n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.hasAccount()){c.next=2;break}return c.abrupt("return");case 2:if(e=this.latestItemsKeys(),t=e.filter(function(e){return e.neverSynced}),n=e.filter(function(e){return!e.neverSynced}),r=n.find(function(e){return e.isDefault}),!!Object(_.w)(r)){c.next=12;break}return c.next=10,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(t)));case 10:c.next=21;break;case 12:if(!(a=this.getRootKey())){c.next=21;break}if(!((i=t.filter(function(e){return e.keyVersion!==a.keyVersion})).length>0)){c.next=18;break}return c.next=18,b.awrap(this.itemManager.setItemsToBeDeleted(Object(Ke.b)(i)));case 18:if(0!==this.latestItemsKeys().length){c.next=21;break}return c.next=21,b.awrap(this.createNewDefaultItemsKey());case 21:return c.next=23,b.awrap(this.getUserVersion());case 23:if(s=c.sent,o=this.latestItemsKeys().find(function(e){return e.keyVersion===s}),!Object(_.w)(o)){c.next=28;break}return c.next=28,b.awrap(this.createNewDefaultItemsKey());case 28:this.syncUnsycnedItemsKeys();case 29:case"end":return c.stop()}},null,this,null,Promise)}},{key:"handleFullSyncCompletion",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getDefaultItemsKey()){e.next=6;break}return e.next=4,b.awrap(this.createNewDefaultItemsKey());case 4:if(this.keyMode!==Bn.WrapperOnly){e.next=6;break}return e.abrupt("return",this.repersistAllItems());case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"syncUnsycnedItemsKeys",value:function(){if(this.hasAccount()){var e=this.latestItemsKeys().filter(function(e){return e.neverSynced&&!e.dirty&&!e.deleted});e.length>0&&this.itemManager.setItemsDirty(Object(Ke.b)(e))}}},{key:"repersistAllItems",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e)}),n.abrupt("return",this.storageService.savePayloads(t));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"latestItemsKeys",value:function(){return this.itemManager.itemsKeys()}},{key:"itemsKeyForPayload",value:function(e){return this.latestItemsKeys().find(function(t){return t.uuid===e.items_key_id||t.duplicateOf===e.items_key_id})}},{key:"getDefaultItemsKey",value:function(){var e=this.latestItemsKeys();if(1===e.length)return e[0];var t=e.filter(function(e){return e.isDefault});if(t.length>1){var n=t.filter(function(e){return!e.neverSynced});if(n.length,n.length>0)return n[0]}return t[0]}},{key:"getKeyEmbeddedKeyParams",value:function(e){var t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e.payload.format!==ue.a.DecryptedBareObject){s.next=2;break}return s.abrupt("return",void 0);case 2:return t=e.version,n=this.operatorForVersion(t),s.next=6,b.awrap(n.getPayloadAuthenticatedData(e.payload));case 6:if(r=s.sent){s.next=9;break}return s.abrupt("return",void 0);case 9:if(!Object(Q.c)(t,Q.a.V003)){s.next=14;break}return a=r,s.abrupt("return",this.createKeyParams(a));case 14:return i=r.kp,s.abrupt("return",this.createKeyParams(i));case 16:case"end":return s.stop()}},null,this,null,Promise)}},{key:"reencryptItemsKeys",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!((e=this.latestItemsKeys()).length>0)){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"defaultItemsKeyForItemVersion",value:function(e,t){var n=t||this.latestItemsKeys(),r=n.find(function(t){return t.isDefault&&t.keyVersion===e});return r||n.find(function(t){return t.keyVersion===e})}},{key:"needsNewRootKeyBasedItemsKey",value:function(){if(!this.hasAccount())return!1;var e=this.getRootKey();if(!e)return!1;if(Object(Q.b)(e.keyVersion,Yn)>0)return!1;var t=this.getDefaultItemsKey();return!t||t.itemsKey!==e.itemsKey}},{key:"createNewDefaultItemsKey",value:function(){var e,t,n,r,a,i,s,o,c,u;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e=this.getRootKey(),t=e?e.keyVersion:this.getLatestVersion(),!(Object(Q.b)(t,Yn)<=0)){l.next=14;break}return l.t0=Object(Ee.e),l.next=6,b.awrap(I.GenerateUuid());case 6:l.t1=l.sent,l.t2=F.a.ItemsKey,l.t3=Object(Ke.a)({itemsKey:e.masterKey,dataAuthenticationKey:e.dataAuthenticationKey,version:t}),l.t4={uuid:l.t1,content_type:l.t2,content:l.t3},r=(0,l.t0)(l.t4),n=nt(r),l.next=17;break;case 14:return l.next=16,b.awrap(this.operatorForVersion(t).createItemsKey());case 16:n=l.sent;case 17:a=this.latestItemsKeys(),i=a.filter(function(e){return e.isDefault}),s=S(i);case 20:if((o=s()).done){l.next=26;break}return c=o.value,l.next=24,b.awrap(this.itemManager.changeItemsKey(c.uuid,function(e){e.isDefault=!1}));case 24:l.next=20;break;case 26:return l.next=28,b.awrap(this.itemManager.insertItem(n));case 28:return u=l.sent,l.next=31,b.awrap(this.itemManager.changeItemsKey(u.uuid,function(e){e.isDefault=!0}));case 31:return l.abrupt("return",u);case 32:case"end":return l.stop()}},null,this,null,Promise)}},{key:"createNewItemsKeyWithRollback",value:function(){var e,t,n,r=this;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=this.getDefaultItemsKey(),a.next=3,b.awrap(this.createNewDefaultItemsKey());case 3:return t=a.sent,n=function(){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(Promise.all([r.itemManager.setItemToBeDeleted(t.uuid),r.itemManager.changeItem(e.uuid,function(e){e.isDefault=!0})]));case 2:case"end":return n.stop()}},null,null,null,Promise)},a.abrupt("return",n);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getPasswordCreatedDate",value:function(){var e=this.getRootKey();return e?e.keyParams.createdDate:void 0}}]),n})(R.a),Qn=(function(){function e(t,n){v(this,e),this.defaultContentKeyToDiffOn='text',this.payload=Object(Ee.b)(t),this.previousEntry=n,this.hasPreviousEntry=!Object(_.w)(n);var r=this.payload.content[this.defaultContentKeyToDiffOn];this.textCharDiffLength=r?n?r.length-n.payload.content[this.defaultContentKeyToDiffOn].length:this.payload.content[this.defaultContentKeyToDiffOn].length:0}return y(e,[{key:"itemFromPayload",value:function(){return nt(this.payload)}},{key:"isSameAsEntry",value:function(e){if(!e)return!1;var t=this.itemFromPayload(),n=e.itemFromPayload();return!(t.userModifiedDate.getTime()!==n.userModifiedDate.getTime())&&t.isItemContentEqualWith(n)}},{key:"isDiscardable",value:function(){return!1}},{key:"operationVector",value:function(){return void 0!==this.textCharDiffLength?this.hasPreviousEntry&&0!==this.textCharDiffLength?this.textCharDiffLength<0?-1:1:0:1}},{key:"deltaSize",value:function(){return void 0!==this.textCharDiffLength?Math.abs(this.textCharDiffLength):1}}]),e})(),Jn=(function(e){d(n,Qn);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"previewTitle",value:function(){return this.payload.updated_at.getTime()>0?this.payload.updated_at.toLocaleString():this.payload.created_at.toLocaleString()}},{key:"previewSubTitle",value:function(){return this.hasPreviousEntry?this.textCharDiffLength<0?"".concat(-1*this.textCharDiffLength," characters removed"):this.textCharDiffLength>0?"".concat(this.textCharDiffLength," characters added"):'Title or metadata changed':"".concat(this.textCharDiffLength," characters loaded")}},{key:"isDiscardable",value:function(){return Object(_.t)(this.payload.safeContent.text)}}]),n})();function $n(e,t){return new(Xn(e[Je.a.ContentType]))(e,t)}function Xn(e){switch(e){case F.a.Note:return Jn;default:return Qn}}var Zn,er,tr=20,nr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s){var o;return v(this,n),(o=t.call(this)).itemManager=e,o.storageService=r,o.apiService=a,o.protocolService=i,o.deviceInterface=s,o.persistable=!1,o.autoOptimize=!1,o.historyStaging={},o.history={},o.historyTypes=[F.a.Note],o.itemRevisionThreshold=tr,o.removeChangeObserver=o.itemManager.addObserver(o.historyTypes,function(e,t){o.recordNewHistoryForItems(e.concat(t))}),o}return y(n,[{key:"deinit",value:function(){this.cancelPendingPersist(),this.itemManager=void 0,this.storageService=void 0,this.history=void 0,this.removeChangeObserver&&(this.removeChangeObserver(),this.removeChangeObserver=void 0),p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.SessionHistoryPersistable));case 2:return this.persistable=e.sent,e.next=5,b.awrap(this.getPersistedHistory());case 5:return this.history=e.sent,e.next=8,b.awrap(this.storageService.getValue(o.SessionHistoryOptimize,void 0,!0));case 8:this.autoOptimize=e.sent;case 9:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPersistedHistory",value:function(){var e,t,n,r,a,i,s,c,u,p,d,h,f,v,y,g;return b.async(function(m){for(;;)switch(m.prev=m.next){case 0:return e={},m.next=3,b.awrap(this.storageService.getValue(o.SessionHistoryRevisions));case 3:if(t=m.sent){m.next=6;break}return m.abrupt("return",e);case 6:for(n=0,r=Object.entries(t);n<r.length;n++){for(a=r[n],i=l(a,2),s=i[0],c=i[1],u=c.slice().reverse(),p=[],d=S(u);!(h=d()).done;)f=h.value,v=Object(Ee.f)(f.payload,ht.a.SessionHistory),y=yt(p),g=$n(v,y),p.unshift(g);e[s]=p}return m.abrupt("return",e);case 8:case"end":return m.stop()}},null,this,null,Promise)}},{key:"recordNewHistoryForItems",value:function(e){for(var t,n=!1,r=S(e);!(t=r()).done;){var a=t.value;if(this.historyTypes.includes(a.content_type)){var i=a.payload;if(!a.deleted&&i.format===ue.a.DecryptedBareObject){var s=this.history[a.uuid]||[],o=yt(s),c=$n(Object(Ee.f)(a,ht.a.SessionHistory),o);if(!c.isDiscardable()){var u=this.historyStaging[a.uuid];this.historyStaging[a.uuid]=c,u&&(u.isSameAsEntry(c)||o&&u.isSameAsEntry(o)||(s.unshift(u),this.history[a.uuid]=s,this.autoOptimize&&this.optimizeHistoryForItem(a.uuid),n=!0))}}}}n&&this.saveToDisk()}},{key:"isDiskEnabled",value:function(){return this.persistable}},{key:"isAutoOptimizeEnabled",value:function(){return this.autoOptimize}},{key:"cancelPendingPersist",value:function(){this.saveTimeout&&('cancel'in this.deviceInterface.timeout?this.deviceInterface.timeout.cancel(this.saveTimeout):clearTimeout(this.saveTimeout))}},{key:"saveToDisk",value:function(){var e=this;if(this.persistable){this.cancelPendingPersist();var t=this.persistableHistoryValue();this.saveTimeout=this.deviceInterface.timeout(function(){e.storageService.setValue(o.SessionHistoryRevisions,t)},2e3)}}},{key:"persistableHistoryValue",value:function(){for(var e={},t=0,n=Object.entries(this.history);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1].map(function(e){return{payload:e.payload}});e[i]=s}return e}},{key:"setSessionItemRevisionThreshold",value:function(e){this.itemRevisionThreshold=e}},{key:"sessionHistoryForItem",value:function(e){return this.history[e.uuid]||[]}},{key:"clearHistoryForItem",value:function(e){delete this.history[e.uuid],this.saveToDisk()}},{key:"clearAllHistory",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.history={},e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 2:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleDiskSaving",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.persistable=!this.persistable,!this.persistable){e.next=6;break}this.storageService.setValue(o.SessionHistoryPersistable,!0),this.saveToDisk(),e.next=8;break;case 6:return this.storageService.setValue(o.SessionHistoryPersistable,!1),e.abrupt("return",this.storageService.removeValue(o.SessionHistoryRevisions));case 8:case"end":return e.stop()}},null,this,null,Promise)}},{key:"toggleAutoOptimize",value:function(){this.autoOptimize=!this.autoOptimize,this.autoOptimize?this.storageService.setValue(o.SessionHistoryOptimize,!0):this.storageService.setValue(o.SessionHistoryOptimize,!1)}},{key:"getHistoryMapCopy",value:function(){for(var e=w({},this.history),t=0,n=Object.entries(e);t<n.length;t++){var r=n[t],a=l(r,2),i=a[0],s=a[1];e[i]=s.slice()}return Object.freeze(e)}},{key:"remoteHistoryForItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.getItemRevisions(e.uuid));case 2:if(!(t=n.sent).error&&!Object(_.w)(t.data)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.abrupt("return",t.data);case 6:case"end":return n.stop()}},null,this,null,Promise)}},{key:"fetchRemoteRevision",value:function(e,t){var n,r,a,i,s;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,b.awrap(this.apiService.getRevision(t,e));case 2:if(!(n=o.sent).error&&!Object(_.w)(n.data)){o.next=5;break}return o.abrupt("return",void 0);case 5:return r=n.data,a=Object(Ee.e)(r,{uuid:r.item_uuid}),i=Object(Ee.f)(a,ht.a.RemoteHistory),o.next=10,b.awrap(this.protocolService.payloadByDecryptingPayload(i));case 10:if(!(s=o.sent).errorDecrypting){o.next=13;break}return o.abrupt("return",void 0);case 13:return o.abrupt("return",new Qn(s));case 14:case"end":return o.stop()}},null,this,null,Promise)}},{key:"optimizeHistoryForItem",value:function(e){var t=this.history[e]||[];if(!(t.length<=this.itemRevisionThreshold)){for(var n=function(e){return e.deltaSize()>25},r=[],a=function(e,a,i){if(i){if(r.unshift(e),n(e)&&-1===e.operationVector()){var s=t[a+1];s&&r.unshift(s)}}else Object(_.M)(r,e)},i=t.length-1;i>=0;i--){var s=t[i];a(s,i,0===i||i===t.length-1||n(s))}var o=t.filter(function(e){return r.includes(e)});this.history[e]=o}}}]),n})(R.a);!(function(e){e.SessionExpiryDateChanged="SessionExpiryDateChanged"})(Zn||(Zn={})),(function(e){e[e.None=0]="None",e[e.FiveMinutes=300]="FiveMinutes",e[e.OneHour=3600]="OneHour",e[e.OneWeek=604800]="OneWeek"})(er||(er={}));var rr,ar=[{valueInSeconds:er.None,label:"Don't Remember"},{valueInSeconds:er.FiveMinutes,label:'5 Minutes'},{valueInSeconds:er.OneHour,label:'1 Hour'},{valueInSeconds:er.OneWeek,label:'1 Week'}],ir=(function(e){d(n,e);var t=k(n);function n(e,r,a,i){var s;return v(this,n),(s=t.call(this)).protocolService=e,s.challengeService=r,s.storageService=a,s.itemManager=i,s.sessionExpiryTimeout=-1,s}return y(n,[{key:"deinit",value:function(){this.protocolService=void 0,this.challengeService=void 0,this.storageService=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return e===ve.LoadedDatabase_12&&this.updateSessionExpiryTimer(this.getSessionExpiryDate()),Promise.resolve()}},{key:"hasProtectionSources",value:function(){return this.protocolService.hasAccount()||this.protocolService.hasPasscode()||this.hasBiometricsEnabled()}},{key:"areProtectionsEnabled",value:function(){return this.hasProtectionSources()&&this.getSessionExpiryDate()<=new Date}},{key:"hasBiometricsEnabled",value:function(){var e=this.storageService.getValue(o.BiometricsState,De.Nonwrapped);return Boolean(e)}},{key:"enableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to enable biometrics when they already are enabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.storageService.setValue(o.BiometricsState,!0,De.Nonwrapped));case 5:return e.abrupt("return",!0);case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"disableBiometrics",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasBiometricsEnabled()){e.next=3;break}return we.a.onError(Error('Tried to disable biometrics when they already are disabled.')),e.abrupt("return",!1);case 3:return e.next=5,b.awrap(this.validateOrRenewSession(ne.DisableBiometrics));case 5:if(!e.sent){e.next=11;break}return e.next=8,b.awrap(this.storageService.setValue(o.BiometricsState,!1,De.Nonwrapped));case 8:return e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}},null,this,null,Promise)}},{key:"createLaunchChallenge",value:function(){var e=[];return this.hasBiometricsEnabled()&&e.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&e.push(new ge(te.LocalPasscode)),e.length>0?new ye(e,ne.ApplicationUnlock,!1):void 0}},{key:"protectNote",value:function(e){return this.itemManager.changeItem(e.uuid,function(e){e.protected=!0})}},{key:"unprotectNote",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.validateOrRenewSession(ne.UnprotectNote));case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.itemManager.changeItem(e.uuid,function(e){e.protected=!1}));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:r=[],a=S(e);case 2:if((i=a()).done){c.next=15;break}if(s=i.value,(o=s.protected&&this.areProtectionsEnabled())&&!n&&(n=this.validateOrRenewSession(t)),c.t0=!o,c.t0){c.next=11;break}return c.next=10,b.awrap(n);case 10:c.t0=c.sent;case 11:if(!c.t0){c.next=13;break}r.push(s);case 13:c.next=2;break;case 15:return c.abrupt("return",r);case 16:case"end":return c.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){return this.itemManager.changeItems(Object(Ke.b)(e),function(e){e.protected=!0})}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.authorizeProtectedActionForNotes(e,ne.UnprotectNote));case 2:return t=n.sent,n.abrupt("return",this.itemManager.changeItems(Object(Ke.b)(t),function(e){e.protected=!1}));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeNoteAccess",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.protected){t.next=2;break}return t.abrupt("return",!0);case 2:return t.abrupt("return",this.validateOrRenewSession(ne.AccessProtectedNote));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeAddingPasscode",value:function(){return this.validateOrRenewSession(ne.AddPasscode)}},{key:"authorizeChangingPasscode",value:function(){return this.validateOrRenewSession(ne.ChangePasscode)}},{key:"authorizeRemovingPasscode",value:function(){return this.validateOrRenewSession(ne.RemovePasscode)}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.validateOrRenewSession(ne.SearchProtectedNotesText)}},{key:"authorizeFileImport",value:function(){return this.validateOrRenewSession(ne.ImportFile)}},{key:"authorizeBackupCreation",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.validateOrRenewSession(ne.ExportBackup,{fallBackToAccountPassword:e}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"authorizeMfaDisable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.DisableMfa,{requireAccountPassword:!0}));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeAutolockIntervalChange",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.ChangeAutolockInterval));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeSessionRevoking",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.validateOrRenewSession(ne.RevokeSession));case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"authorizeCloudLinkAccess",value:function(){return this.validateOrRenewSession(ne.AccessCloudLink)}},{key:"validateOrRenewSession",value:function(e){var t,n,r,a,i,s,o,c,u,l=arguments;return b.async(function(p){for(;;)switch(p.prev=p.next){case 0:if(t=l.length>1&&void 0!==l[1]?l[1]:{},n=t.fallBackToAccountPassword,r=void 0===n||n,a=t.requireAccountPassword,i=void 0!==a&&a,!(this.getSessionExpiryDate()>new Date)){p.next=3;break}return p.abrupt("return",!0);case 3:if(s=[],this.hasBiometricsEnabled()&&s.push(new ge(te.Biometric)),this.protocolService.hasPasscode()&&s.push(new ge(te.LocalPasscode)),!i){p.next=10;break}if(this.protocolService.hasAccount()){p.next=9;break}throw Error('Requiring account password for challenge with no account');case 9:s.push(new ge(te.AccountPassword));case 10:if(0!==s.length){p.next=16;break}if(!r||!this.protocolService.hasAccount()){p.next=15;break}s.push(new ge(te.AccountPassword)),p.next=16;break;case 15:return p.abrupt("return",!0);case 16:return p.t0=s,p.t1=ge,p.t2=te.ProtectionSessionDuration,p.t3=void 0,p.t4=void 0,p.t5=void 0,p.t6=void 0,p.next=25,b.awrap(this.getSessionLength());case 25:return p.t7=p.sent,p.t8=new p.t1(p.t2,p.t3,p.t4,p.t5,p.t6,p.t7),p.t0.push.call(p.t0,p.t8),p.next=30,b.awrap(this.challengeService.promptForChallengeResponse(new ye(s,e,!0)));case 30:if(!(o=p.sent)){p.next=42;break}if(u=null===(c=o.values.find(function(e){return e.prompt.validation===te.ProtectionSessionDuration}))||void 0===c?void 0:c.value,!Object(_.w)(u)){p.next=37;break}we.a.error(Error('No valid protection session length found. Got '+u)),p.next=39;break;case 37:return p.next=39,b.awrap(this.setSessionLength(u));case 39:return p.abrupt("return",!0);case 42:return p.abrupt("return",!1);case 43:case"end":return p.stop()}},null,this,null,Promise)}},{key:"getSessionExpiryDate",value:function(){var e=this.storageService.getValue(o.ProtectionExpirey);return e?new Date(e):new Date}},{key:"clearSession",value:function(){return this.setSessionExpiryDate(new Date)}},{key:"setSessionExpiryDate",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setValue(o.ProtectionExpirey,e));case 2:this.notifyEvent(Zn.SessionExpiryDateChanged);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSessionLength",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.ProtectionSessionLength));case 2:if(!(e=t.sent)){t.next=7;break}return t.abrupt("return",e);case 7:return t.abrupt("return",er.None);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setSessionLength",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.storageService.setValue(o.ProtectionSessionLength,e));case 2:return(t=new Date).setSeconds(t.getSeconds()+e),n.next=6,b.awrap(this.setSessionExpiryDate(t));case 6:this.updateSessionExpiryTimer(t);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"updateSessionExpiryTimer",value:function(e){var t=this,n=e.getTime();if(n>Date.now()){clearTimeout(this.sessionExpiryTimeout),this.sessionExpiryTimeout=setTimeout(function(){t.setSessionExpiryDate(new Date)},n-Date.now())}}}]),n})(R.a),sr=n(45),or=n(19);!(function(e){e.UserRoleMessageReceived="WebSocketMessageReceived"})(rr||(rr={}));var cr,ur,lr=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.webSocketUrl=r,a}return y(n,[{key:"setWebSocketUrl",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.webSocketUrl=e,t.next=3,b.awrap(this.storageService.setValue(o.WebSocketUrl,e));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadWebSocketUrl",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.getValue(o.WebSocketUrl));case 2:e=t.sent,this.webSocketUrl=e||this.webSocketUrl||window._websocket_url;case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"startWebSocketConnection",value:function(e){if(this.webSocketUrl)try{this.webSocket=new WebSocket("".concat(this.webSocketUrl,"?authToken=Bearer+").concat(e)),this.webSocket.onmessage=this.onWebSocketMessage.bind(this),this.webSocket.onclose=this.onWebSocketClose.bind(this)}catch(e){console.error('Error starting WebSocket connection',e)}}},{key:"closeWebSocketConnection",value:function(){var e;null===(e=this.webSocket)||void 0===e||e.close()}},{key:"onWebSocketMessage",value:function(e){var t=JSON.parse(e.data);this.notifyEvent(rr.UserRoleMessageReceived,t)}},{key:"onWebSocketClose",value:function(){this.webSocket=void 0}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.storageService=void 0,this.closeWebSocketConnection()}}]),n})(R.a),pr=n(29);!(function(e){e.UserRolesChanged="UserRolesChanged",e.FeaturesUpdated="FeaturesUpdated"})(cr||(cr={})),(function(e){e.NoUserSubscription="NoUserSubscription",e.NotInCurrentPlan="NotInCurrentPlan",e.InCurrentPlanButExpired="InCurrentPlanButExpired",e.Entitled="Entitled"})(ur||(ur={}));var dr=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u,l,p,d){var h;return v(this,n),(h=t.call(this)).storageService=e,h.apiService=r,h.itemManager=a,h.componentManager=i,h.webSocketsService=s,h.settingsService=o,h.credentialService=c,h.syncService=u,h.alertService=l,h.sessionManager=p,h.crypto=d,h.deinited=!1,h.roles=[],h.features=[],h.needsInitialFeaturesUpdate=!0,h.completedSuccessfulFeaturesRetrieval=!1,h.removeApiServiceObserver=r.addEventObserver(function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(e!==Ht.MetaReceived){a.next=6;break}if(h.syncService.completedOnlineDownloadFirstSync){a.next=3;break}return a.abrupt("return");case 3:return n=t.userUuid,r=t.userRoles,a.next=6,b.awrap(h.updateRoles(n,r.map(function(e){return e.name})));case 6:case"end":return a.stop()}},null,null,null,Promise)}),h.removeWebSocketsServiceObserver=s.addEventObserver(function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:if(e!==rr.UserRoleMessageReceived){i.next=6;break}return n=t.payload,r=n.userUuid,a=n.currentRoles,i.next=4,b.awrap(h.setRoles(a));case 4:return i.next=6,b.awrap(h.updateFeatures(r));case 6:case"end":return i.stop()}},null,null,null,Promise)}),h.removefeatureReposObserver=h.itemManager.addObserver(or.ContentType.ExtensionRepo,function(e,t,n,r,a){var i,s;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(i=[ht.a.Constructor,ht.a.LocalRetrieved,ht.a.RemoteRetrieved,ht.a.FileImport],!a||!i.includes(a)){n.next=10;break}if(s=[].concat(m(e),m(t)).filter(function(e){return!e.deleted}),!h.sessionManager.isSignedIntoFirstPartyServer()){n.next=8;break}return n.next=6,b.awrap(h.migrateFeatureRepoToUserSetting(s));case 6:n.next=10;break;case 8:return n.next=10,b.awrap(h.migrateFeatureRepoToOfflineEntitlements(s));case 10:case"end":return n.stop()}},null,null,null,Promise)}),h.removeSignInObserver=h.credentialService.addEventObserver(function(e){if(e===Ye.SignedInOrRegistered){var t=h.itemManager.getItems(or.ContentType.ExtensionRepo);h.apiService.isThirdPartyHostUsed()||h.migrateFeatureRepoToUserSetting(t)}}),h}return y(n,[{key:"handleApplicationStage",value:function(e){var t;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.FullSyncCompleted_13&&(t=this.getOfflineRepo())&&this.downloadOfflineFeatures(t);case 3:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setOfflineFeaturesCode",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,t=e.replace(/\s/g,''),i.next=4,b.awrap(this.crypto.base64Decode(t));case 4:if(n=i.sent,r=this.parseOfflineEntitlementsCode(n),!Object(_.u)(r)){i.next=8;break}return i.abrupt("return",r);case 8:return i.next=10,b.awrap(this.itemManager.createItem(or.ContentType.ExtensionRepo,Object(Ke.a)({offlineFeaturesUrl:r.featuresUrl,offlineKey:r.extensionKey,migratedToOfflineEntitlements:!0}),!0));case 10:return a=i.sent,this.syncService.sync(),i.abrupt("return",this.downloadOfflineFeatures(a));case 15:return i.prev=15,i.t0=i.catch(0),i.abrupt("return",{error:j.e});case 18:case"end":return i.stop()}},null,this,[[0,15]],Promise)}},{key:"getOfflineRepo",value:function(){return this.itemManager.getItems(or.ContentType.ExtensionRepo).filter(function(e){return e.migratedToOfflineEntitlements})[0]}},{key:"hasOfflineRepo",value:function(){return void 0!=this.getOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e=this.getOfflineRepo())){t.next=4;break}return t.next=4,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 4:return t.next=6,b.awrap(this.storageService.removeValue(o.UserFeatures));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"parseOfflineEntitlementsCode",value:function(e){try{var t=JSON.parse(e);return{featuresUrl:t.featuresUrl,extensionKey:t.extensionKey}}catch(e){return{error:j.e}}}},{key:"downloadOfflineFeatures",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.apiService.downloadOfflineFeaturesFromRepo(e));case 2:if(t=n.sent,!Object(_.u)(t)){n.next=5;break}return n.abrupt("return",t);case 5:return n.next=7,b.awrap(this.didDownloadFeatures(t.features));case 7:return n.next=9,b.awrap(this.mapFeaturesToItems(t.features));case 9:case"end":return n.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToUserSetting",value:function(){var e,t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:[],t=S(e);case 2:if((n=t()).done){c.next=17;break}if(!(r=n.value).migratedToUserSetting){c.next=6;break}return c.abrupt("continue",15);case 6:if(!r.onlineUrl){c.next=15;break}if(a=r.onlineUrl,!((i=a.match(/\w{32,64}/))&&i.length>0)){c.next=15;break}return s=i[0],c.next=13,b.awrap(this.settingsService.updateSetting(pr.SettingName.ExtensionKey,s,!0));case 13:return c.next=15,b.awrap(this.itemManager.changeFeatureRepo(r.uuid,function(e){e.migratedToUserSetting=!0}));case 15:c.next=2;break;case 17:case"end":return c.stop()}},null,this,null,Promise)}},{key:"migrateFeatureRepoToOfflineEntitlements",value:function(){var e,t,n,r,a,i,s,o=this,c=arguments;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:e=c.length>0&&void 0!==c[0]?c[0]:[],t=S(e);case 2:if((n=t()).done){u.next=17;break}if(!(r=n.value).migratedToOfflineEntitlements){u.next=6;break}return u.abrupt("continue",15);case 6:if(!r.onlineUrl){u.next=15;break}if(a=r.onlineUrl,i=new URL(a),i.origin.includes("https://extensions.standardnotes.org")){u.next=11;break}return u.abrupt("continue",15);case 11:if(!((s=a.match(/\w{32,64}/))&&s.length>0)){u.next=15;break}return u.next=15,b.awrap((function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=s[0],n.next=3,b.awrap(o.itemManager.changeFeatureRepo(r.uuid,function(t){t.offlineFeaturesUrl="https://api.standardnotes.com/v1/offline/features",t.offlineKey=e,t.migratedToOfflineEntitlements=!0}));case 3:return t=n.sent,n.next=6,b.awrap(o.downloadOfflineFeatures(t));case 6:case"end":return n.stop()}},null,null,null,Promise)})());case 15:u.next=2;break;case 17:case"end":return u.stop()}},null,null,null,Promise)}},{key:"initializeFromDisk",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.storageService.getValue(o.UserRoles,void 0,[]));case 2:return this.roles=e.sent,e.next=5,b.awrap(this.storageService.getValue(o.UserFeatures,void 0,[]));case 5:this.features=e.sent;case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"updateRoles",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.haveRolesChanged(t)&&!this.needsInitialFeaturesUpdate){n.next=7;break}return this.needsInitialFeaturesUpdate=!1,n.next=5,b.awrap(this.setRoles(t));case 5:return n.next=7,b.awrap(this.updateFeatures(e));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"setRoles",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.roles=e,Object(_.e)(this.roles,e)||this.notifyEvent(cr.UserRolesChanged),t.next=4,b.awrap(this.storageService.setValue(o.UserRoles,this.roles));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"didDownloadFeatures",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.features=e,this.completedSuccessfulFeaturesRetrieval=!0,this.notifyEvent(cr.FeaturesUpdated),t.next=5,b.awrap(this.storageService.setValue(o.UserFeatures,this.features));case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getFeature",value:function(e){return this.features.find(function(t){return t.identifier===e})}},{key:"hasPaidOnlineOrOfflineSubscription",value:function(){if(this.sessionManager.isSignedIntoFirstPartyServer()){var e=this.roles,t=[sr.RoleName.BasicUser];return e.some(function(e){return!t.includes(e)})}return this.hasOfflineRepo()}},{key:"getFeatureStatus",value:function(e){if(void 0==L.Features.find(function(t){return t.identifier===e})){var t=this.itemManager.components.find(function(t){return t.identifier===e});return null!==t&&void 0!==t&&t.isExpired?ur.InCurrentPlanButExpired:ur.Entitled}if(this.hasPaidOnlineOrOfflineSubscription()&&!this.completedSuccessfulFeaturesRetrieval)return ur.Entitled;if(!this.hasPaidOnlineOrOfflineSubscription())return ur.NoUserSubscription;var n=this.features.find(function(t){return t.identifier===e});return n?n.expires_at&&new Date(n.expires_at).getTime()<(new Date).getTime()?this.roles.includes(n.role_name)?ur.InCurrentPlanButExpired:ur.NotInCurrentPlan:ur.Entitled:ur.NotInCurrentPlan}},{key:"haveRolesChanged",value:function(e){var t=this;return e.some(function(e){return!t.roles.includes(e)})||this.roles.some(function(t){return!e.includes(t)})}},{key:"updateFeatures",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.apiService.getUserFeatures(e));case 2:if((t=r.sent).error||!t.data||this.deinited){r.next=10;break}return(n=t.data.features).forEach(function(e){e.expires_at&&(e.expires_at=Object(_.i)(e.expires_at))}),r.next=8,b.awrap(this.didDownloadFeatures(n));case 8:return r.next=10,b.awrap(this.mapFeaturesToItems(n));case 10:case"end":return r.stop()}},null,this,null,Promise)}},{key:"componentContentForFeatureDescription",value:function(e){var t={area:e.area,hosted_url:e.url,name:e.name,package_info:e,valid_until:new Date(e.expires_at||0)};return Object(Ke.a)(t)}},{key:"mapFeaturesToItems",value:function(e){var t,n,r,a,i,s,o,c,u=this;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:t=this.itemManager.getItems([or.ContentType.Component,or.ContentType.Theme]),n=[],r=new Date,a=!1,i=function(e){var i,s,o,c;return b.async(function(l){for(;;)switch(l.prev=l.next){case 0:if(e.content_type){l.next=2;break}return l.abrupt("return","continue");case 2:if(!e.url||Object(_.B)(e.url)){l.next=5;break}return l.abrupt("return","continue");case 5:if(i=new Date(e.expires_at||0).getTime()<r.getTime(),s=t.find(function(t){return!!t.safeContent.package_info&&(t.safeContent.package_info.identifier===e.identifier&&!t.deleted)}),o=s,!s){l.next=21;break}if(c=new Date(e.expires_at||0),!(e.url!==s.hosted_url||e.version!==s.package_info.version||c.getTime()!==s.valid_until.getTime())){l.next=18;break}return l.next=14,b.awrap(u.itemManager.changeComponent(s.uuid,function(t){t.hosted_url=e.url,t.package_info=e,t.valid_until=c}));case 14:o=l.sent,a=!0,l.next=19;break;case 18:o=s;case 19:l.next=26;break;case 21:if(i&&e.content_type!==or.ContentType.Component){l.next=26;break}return l.next=24,b.awrap(u.itemManager.createItem(e.content_type,u.componentContentForFeatureDescription(e),!0));case 24:o=l.sent,a=!0;case 26:i&&o&&(e.content_type===or.ContentType.Component?u.componentManager.setReadonlyStateForComponent(o,i):(n.push(o.uuid),a=!0));case 27:case"end":return l.stop()}},null,null,null,Promise)},s=S(e);case 6:if((o=s()).done){l.next=15;break}return c=o.value,l.next=10,b.awrap(i(c));case 10:if("continue"!==l.sent){l.next=13;break}return l.abrupt("continue",13);case 13:l.next=6;break;case 15:return l.next=17,b.awrap(this.itemManager.setItemsToBeDeleted(n));case 17:a&&this.syncService.sync();case 18:case"end":return l.stop()}},null,this,null,Promise)}},{key:"validateAndDownloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return t=e,i.prev=1,i.next=4,b.awrap(this.crypto.base64Decode(e));case 4:t=i.sent,i.next=9;break;case 7:i.prev=7,i.t0=i.catch(1);case 9:if(i.prev=9,n=[].concat(Ft,Nt),r=new URL(t),a=r.host,n.includes(a)){i.next=20;break}return i.next=15,b.awrap(this.alertService.confirm(j.t,'Install extension from an untrusted source?','Proceed to install',St.Danger,'Cancel'));case 15:if(!i.sent){i.next=18;break}return i.abrupt("return",this.downloadExternalFeature(t));case 18:i.next=21;break;case 20:return i.abrupt("return",this.downloadExternalFeature(t));case 21:i.next=26;break;case 23:i.prev=23,i.t1=i.catch(9),this.alertService.alert(j.C);case 26:case"end":return i.stop()}},null,this,[[1,7],[9,23]],Promise)}},{key:"downloadExternalFeature",value:function(e){var t,n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,b.awrap(this.apiService.downloadFeatureUrl(e));case 2:if(!(t=i.sent).error){i.next=7;break}return i.next=6,b.awrap(this.alertService.alert(j.c));case 6:return i.abrupt("return",void 0);case 7:if((n=t.data).content_type){i.next=10;break}return i.abrupt("return");case 10:return r=this.componentContentForFeatureDescription(n),i.next=13,b.awrap(this.itemManager.createTemplateItem(n.content_type,r));case 13:return a=i.sent,i.abrupt("return",a);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){p(f(n.prototype),"deinit",this).call(this),this.removeSignInObserver(),this.removeSignInObserver=void 0,this.removeApiServiceObserver(),this.removeApiServiceObserver=void 0,this.removeWebSocketsServiceObserver(),this.removeWebSocketsServiceObserver=void 0,this.removefeatureReposObserver(),this.removefeatureReposObserver=void 0,this.roles=void 0,this.storageService=void 0,this.apiService=void 0,this.itemManager=void 0,this.componentManager=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.credentialService=void 0,this.syncService=void 0,this.alertService=void 0,this.sessionManager=void 0,this.crypto=void 0,this.deinited=!0}}]),n})(R.a),hr=n(46),fr=(function(){function e(t,n){v(this,e),this.completedUpload=0,this.totalUpload=0,this.downloaded=0,this.databaseLoadCurrent=0,this.databaseLoadTotal=0,this.databaseLoadDone=!1,this.syncing=!1,this.interval=t,this.receiver=n}return y(e,[{key:"deinit",value:function(){this.stopTimingMonitor()}},{key:"setUploadStatus",value:function(e,t){this.completedUpload=e,this.totalUpload=t,this.receiver(on.a.StatusChanged)}},{key:"setDownloadStatus",value:function(e){this.downloaded+=e,this.receiver(on.a.StatusChanged)}},{key:"setDatabaseLoadStatus",value:function(e,t,n){this.databaseLoadCurrent=e,this.databaseLoadTotal=t,this.databaseLoadDone=n,n?this.receiver(on.a.LocalDataLoaded):this.receiver(on.a.LocalDataIncrementalLoad)}},{key:"getStats",value:function(){return{uploadCompletionCount:this.completedUpload,uploadTotalCount:this.totalUpload,downloadCount:this.downloaded,localDataDone:this.databaseLoadDone,localDataCurrent:this.databaseLoadCurrent,localDataTotal:this.databaseLoadTotal}}},{key:"setDidBegin",value:function(){this.syncing=!0,this.syncStart=new Date}},{key:"setDidEnd",value:function(){this.syncing=!1,this.syncEnd=new Date}},{key:"startTimingMonitor",value:function(){var e=this;this.timingMonitor&&this.stopTimingMonitor(),this.timingMonitor=this.interval(function(){e.secondsSinceSyncStart>5&&(e.receiver(on.a.SyncTakingTooLong),e.stopTimingMonitor())},500)}},{key:"stopTimingMonitor",value:function(){Object.prototype.hasOwnProperty.call(this.interval,'cancel')?this.interval.cancel(this.timingMonitor):clearInterval(this.timingMonitor),this.timingMonitor=null}},{key:"hasError",value:function(){return!!this.error}},{key:"setError",value:function(e){this.error=e}},{key:"clearError",value:function(){this.error=null}},{key:"reset",value:function(){this.downloaded=0,this.completedUpload=0,this.totalUpload=0,this.syncing=!1,this.error=null,this.stopTimingMonitor(),this.receiver(on.a.StatusChanged)}},{key:"syncInProgress",get:function(){return!0===this.syncing}},{key:"secondsSinceSyncStart",get:function(){return((new Date).getTime()-this.syncStart.getTime())/1e3}}]),e})();function vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mr,br=(function(){function e(){v(this,e),this.tags=[],this.includePinned=!0,this.includeProtected=!0,this.includeTrashed=!1,this.includeArchived=!1}return y(e,[{key:"computeFilters",value:function(e){for(var t,n=this,r=this.tags.filter(function(e){return!e.isSmartTag}),a=this.tags.filter(function(e){return e.isSmartTag}),i=a.filter(function(e){return e.isSystemSmartTag}),s=a.filter(function(e){return!e.isSystemSmartTag}),o=!1,c=!1,u=[],l=S(i);!(t=l()).done;){var p=t.value;p.isArchiveTag?(u.push(function(e){return e.archived&&!e.deleted}),o=!0):p.isTrashTag&&(u.push(function(e){return e.trashed&&!e.deleted}),c=!0)}if(s.length>0){var d=H.a.CompoundPredicate(s.map(function(e){return e.predicate}));u.push(function(t){if(d.keypathIncludesVerb('tags')){var n=yr(yr(yr({},t),t.payload),{},{tags:e.elementsReferencingElement(t,F.a.Tag)});return H.a.ObjectSatisfiesPredicate(n,d)}return H.a.ObjectSatisfiesPredicate(t,d)})}else if(r.length>0)for(var h,f=function(e){u.push(function(t){return e.hasRelationshipWithItem(t)})},v=S(r);!(h=v()).done;){f(h.value)}return this.searchQuery&&u.push(function(t){return xr(t,n.searchQuery,e)}),this.includePinned||u.push(function(e){return!e.pinned}),this.includeProtected||u.push(function(e){return!e.protected}),this.includeTrashed||c||u.push(function(e){return!e.trashed}),this.includeArchived||o||c||u.push(function(e){return!e.archived}),u}}],[{key:"Create",value:function(t){var n=new e;return w(n,t),Object.freeze(n)}},{key:"Copy",value:function(t,n){var r=new e;return w(r,t),w(r,n),Object.freeze(r)}}]),e})();function wr(e,t){var n=e.computeFilters(t);return t.displayElements(F.a.Note).filter(function(e){return kr(e,n)})}function kr(e,t){for(var n,r=S(t);!(n=r()).done;){if(!(0,n.value)(e))return!1}return!0}function xr(e,t,n){var r=n.elementsReferencingElement(e,F.a.Tag).some(function(e){return Pr(e,t.query)!==mr.None});if(e.protected&&!t.includeProtectedNoteText){var a=Sr(e,t.query);return a===mr.Title||a===mr.TitleAndText||r}return Sr(e,t.query)!==mr.None||r}function Sr(e,t){if(0===t.length)return mr.TitleAndText;var n=e.safeTitle().toLowerCase(),r=e.safeText().toLowerCase(),a=t.toLowerCase(),i=a.split(' '),s=Or(a);if(s)return(n.includes(s)?mr.Title:mr.None)+(r.includes(s)?mr.Text:mr.None);if(Cr(a))return e.uuid===a?mr.Uuid:mr.None;var o=i.every(function(e){return n.indexOf(e)>=0}),c=i.every(function(e){return r.indexOf(e)>=0});return(o?mr.Title:0)+(c?mr.Text:0)}function Pr(e,t){if(0===t.length)return mr.None;var n=e.title.toLowerCase(),r=t.toLowerCase(),a=r.split(' '),i=Or(r);return i?n.includes(i)?mr.Title:mr.None:a.every(function(e){return n.indexOf(e)>=0})?mr.Title:mr.None}function Or(e){var t=e.match(/"(.*?)"/);return t?t[1]:null}function Cr(e){return!!e.match(/\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b/)}!(function(e){e[e.None=0]="None",e[e.Title=1]="Title",e[e.Text=2]="Text",e[e.TitleAndText=3]="TitleAndText",e[e.Uuid=5]="Uuid"})(mr||(mr={}));var Dr=(function(){function e(t){v(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:br.Create({});this.collection=t,this.criteria=n,this.displayedNotes=[],this.needsRebuilding=!0}return y(e,[{key:"setCriteria",value:function(e){this.criteria=e,this.collection.setDisplayOptions(F.a.Note,e.sortProperty,e.sortDirection),this.needsRebuilding=!0}},{key:"notesMatchingSmartTag",value:function(e){var t;return wr((t=e,br.Create({tags:[t]})),this.collection)}},{key:"rebuildList",value:function(){var e=this,t=br.Copy(this.criteria,{tags:this.criteria.tags.map(function(t){return t.isSystemSmartTag?t:e.collection.find(t.uuid)})});this.displayedNotes=wr(t,this.collection)}},{key:"setNeedsRebuilding",value:function(){this.needsRebuilding=!0}},{key:"displayElements",value:function(){return this.needsRebuilding&&(this.rebuildList(),this.needsRebuilding=!1),this.displayedNotes.slice()}}]),e})(),_r=(function(e){d(n,e);var t=k(n);function n(e){var r,a,i,s;return v(this,n),(r=t.call(this)).payloadManager=e,r.observers=[],r.payloadManager=e,r.systemSmartTags=(a=Object(Ee.e)({uuid:Er,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'All notes',isSystemTag:!0,isAllTag:!0})}),i=Object(Ee.e)({uuid:Rr,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Archived',isSystemTag:!0,isArchiveTag:!0})}),s=Object(Ee.e)({uuid:Ir,content_type:F.a.SmartTag,content:Object(Ke.a)({title:'Trash',isSystemTag:!0,isTrashTag:!0})}),[nt(a),nt(i),nt(s)]),r.createCollection(),r.unsubChangeObserver=r.payloadManager.addObserver(F.a.Any,r.setPayloads.bind(u(r))),r}return y(n,[{key:"createCollection",value:function(){this.collection=new gn,this.collection.setDisplayOptions(F.a.Note,dn.CreatedAt,'dsc'),this.collection.setDisplayOptions(F.a.Tag,dn.Title,'dsc'),this.collection.setDisplayOptions(F.a.ItemsKey,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Component,dn.CreatedAt,'asc'),this.collection.setDisplayOptions(F.a.Theme,dn.Title,'asc'),this.collection.setDisplayOptions(F.a.SmartTag,dn.Title,'asc'),this.notesView=new Dr(this.collection)}},{key:"setDisplayOptions",value:function(e,t,n,r){e===F.a.Note&&console.warn("Called setDisplayOptions with ContentType.Note. setNotesDisplayCriteria should be used instead."),this.collection.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.notesView.setCriteria(e)}},{key:"getDisplayableItems",value:function(e){return e===F.a.Note?this.notesView.displayElements():this.collection.displayElements(e)}},{key:"deinit",value:function(){this.unsubChangeObserver(),this.unsubChangeObserver=void 0,this.payloadManager=void 0,this.collection=void 0,this.notesView=void 0}},{key:"resetState",value:function(){this.createCollection()}},{key:"findItem",value:function(e){return this.collection.find(e)}},{key:"findItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.collection.findAll(e,t)}},{key:"itemsKeys",value:function(){return this.collection.displayElements(F.a.ItemsKey)}},{key:"addObserver",value:function(e,t){var n=this;Array.isArray(e)||(e=[e]);var r={contentType:e,callback:t};return this.observers.push(r),function(){Object(_.M)(n.observers,r)}}},{key:"itemsReferencingItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.collection.uuidsThatReferenceUuid(e);return this.findItems(t)}},{key:"referencesForItem",value:function(e){if(!Object(_.A)(e))throw Error('Must use uuid string');var t=this.findItem(e).references.map(function(e){return e.uuid});return this.findItems(t)}},{key:"setPayloads",value:function(e,t,n,r,a,i){var s=e.map(function(e){return nt(e)}),o=t.map(function(e){return nt(e)}),c=r.map(function(e){return nt(e)}),u=s.concat(o);u.length>0&&this.collection.set(u);for(var l,p=n.map(function(e){return nt(e)}),d=S(p);!(l=d()).done;){var h=l.value;this.collection.discard(h)}this.notesView.setNeedsRebuilding(),this.notifyObservers(s,o,p,c,a,i)}},{key:"notifyObservers",value:function(e,t,n,r,a,i){for(var s,o=function(e,t){return e.filter(function(e){return t.includes(F.a.Any)||t.includes(e.content_type)})},c=S(this.observers.slice());!(s=c()).done;){var u=s.value,l=o(e,u.contentType),p=o(t,u.contentType),d=o(n,u.contentType),h=o(r,u.contentType);0===l.length&&0===p.length&&0===d.length&&0===h.length||u.callback(l,p,d,h,a,i)}}},{key:"changeItem",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(n=s.length>2&&void 0!==s[2]?s[2]:T.c.UserInteraction,r=s.length>3&&void 0!==s[3]?s[3]:ht.a.LocalChanged,a=s.length>4?s[4]:void 0,Object(_.A)(e)){o.next=5;break}throw Error('Invalid uuid for changeItem');case 5:return o.next=7,b.awrap(this.changeItems([e],t,n,r,a));case 7:return i=o.sent,o.abrupt("return",i[0]);case 9:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h=arguments;return b.async(function(f){for(;;)switch(f.prev=f.next){case 0:n=h.length>2&&void 0!==h[2]?h[2]:T.c.UserInteraction,r=h.length>3&&void 0!==h[3]?h[3]:ht.a.LocalChanged,a=h.length>4?h[4]:void 0,i=this.findItems(e,!0),s=[],o=S(i);case 6:if((c=o()).done){f.next=16;break}if(u=c.value){f.next=10;break}throw Error('Attempting to change non-existant item');case 10:l=de(u,n),t&&t(l),p=l.getResult(),s.push(p);case 14:f.next=6;break;case 16:return f.next=18,b.awrap(this.payloadManager.emitPayloads(s,r,a));case 18:return d=this.findItems(s.map(function(e){return e.uuid})),f.abrupt("return",d);case 20:case"end":return f.stop()}},null,this,null,Promise)}},{key:"changeNote",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant note');case 6:return s=new pe(i,n),c.abrupt("return",this.applyTransform(s,t,r,a));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeTag",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant tag');case 6:return s=new ce(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeComponent",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant component');case 6:return s=new V(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeFeatureRepo",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant repo');case 6:return s=new Xe(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeActionsExtension",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant extension');case 6:return s=new se(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"changeItemsKey",value:function(e,t){var n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(n=o.length>2&&void 0!==o[2]?o[2]:T.c.UserInteraction,r=o.length>3&&void 0!==o[3]?o[3]:ht.a.LocalChanged,a=o.length>4?o[4]:void 0,i=this.findItem(e)){c.next=6;break}throw Error('Attempting to change non-existant itemsKey');case 6:return s=new $(i,n),c.next=9,b.awrap(this.applyTransform(s,t,r,a));case 9:return c.abrupt("return",this.findItem(e));case 10:case"end":return c.stop()}},null,this,null,Promise)}},{key:"applyTransform",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:ht.a.LocalChanged,r=i.length>3?i[3]:void 0,t(e),a=e.getResult(),s.abrupt("return",this.payloadManager.emitPayload(a,n,r));case 5:case"end":return s.stop()}},null,this,null,Promise)}},{key:"setItemDirty",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(t=r.length>1&&void 0!==r[1]&&r[1],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return a.next=5,b.awrap(this.setItemsDirty([e],t));case 5:return n=a.sent,a.abrupt("return",n[0]);case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemsDirty",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=n.length>1&&void 0!==n[1]&&n[1],Object(_.A)(e[0])){r.next=3;break}throw Error('Must use uuid when setting item dirty');case 3:return r.abrupt("return",this.changeItems(e,void 0,t?T.c.UserInteraction:T.c.Internal));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getDirtyItems",value:function(){return this.collection.dirtyElements().filter(function(e){return e.isSyncable})}},{key:"duplicateItem",value:function(e){var t,n,r,a,i,s,o=arguments;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return t=o.length>1&&void 0!==o[1]&&o[1],n=o.length>2?o[2]:void 0,r=this.findItem(e),a=Object(Ee.e)(r),c.next=6,b.awrap(ut(a,this.payloadManager.getMasterCollection(),t,n));case 6:return i=c.sent,c.next=9,b.awrap(this.payloadManager.emitPayloads(i,ht.a.LocalChanged));case 9:return s=this.findItem(i[0].uuid),c.abrupt("return",s);case 11:case"end":return c.stop()}},null,this,null,Promise)}},{key:"createItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=i.length>2&&void 0!==i[2]&&i[2],r=i.length>3?i[3]:void 0,e){s.next=4;break}throw'Attempting to create item with no contentType';case 4:return s.t0=Object(Ee.e),s.next=7,b.awrap(I.GenerateUuid());case 7:return s.t1=s.sent,s.t2=e,s.t3=t?Object(Ke.a)(t):void 0,s.t4=n,s.t5={uuid:s.t1,content_type:s.t2,content:s.t3,dirty:s.t4},s.t6=r,a=(0,s.t0)(s.t5,s.t6),s.next=16,b.awrap(this.payloadManager.emitPayload(a,ht.a.Constructor));case 16:return s.abrupt("return",this.findItem(a.uuid));case 17:case"end":return s.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.t0=Object(Ee.e),r.next=3,b.awrap(I.GenerateUuid());case 3:return r.t1=r.sent,r.t2=e,r.t3=Object(Ke.a)(t||{}),r.t4={uuid:r.t1,content_type:r.t2,content:r.t3},n=(0,r.t0)(r.t4),r.abrupt("return",nt(n));case 9:case"end":return r.stop()}},null,null,null,Promise)}},{key:"insertItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemFromPayload(e.payload));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"insertItems",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.emitItemsFromPayloads(e.map(function(e){return e.payload})));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emitItemFromPayload",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:ht.a.Constructor,r.next=3,b.awrap(this.payloadManager.emitPayload(e,t));case 3:return r.abrupt("return",this.findItem(e.uuid));case 4:case"end":return r.stop()}},null,this,null,Promise)}},{key:"emitItemsFromPayloads",value:function(e){var t,n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:ht.a.Constructor,a.next=3,b.awrap(this.payloadManager.emitPayloads(e,t));case 3:return n=Object(Ke.b)(e),a.abrupt("return",this.findItems(n));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"setItemToBeDeleted",value:function(e,t){var n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this.collection.uuidsThatReferenceUuid(e),r=this.findItem(e),u.next=4,b.awrap(this.changeItem(e,function(e){e.setDeleted()},void 0,t));case 4:a=u.sent,i=S(n);case 6:if((s=i()).done){u.next=14;break}if(o=s.value,!(c=this.findItem(o))){u.next=12;break}return u.next=12,b.awrap(this.changeItem(c.uuid,function(e){e.removeItemAsRelationship(r)}));case 12:u.next=6;break;case 14:return u.abrupt("return",a);case 15:case"end":return u.stop()}},null,this,null,Promise)}},{key:"setItemsToBeDeleted",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",Promise.all(e.map(function(e){return t.setItemToBeDeleted(e)})));case 1:case"end":return n.stop()}},null,null,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.collection.all(e);return t?n.filter(function(e){return!e.errorDecrypting&&!e.waitingForKey}):n}},{key:"nonErroredItemsForContentType",value:function(e){return this.collection.all(e).filter(function(e){return!e.errorDecrypting&&!e.waitingForKey})}},{key:"itemsMatchingPredicate",value:function(e){return this.itemsMatchingPredicates([e])}},{key:"itemsMatchingPredicates",value:function(e){return this.subItemsMatchingPredicates(this.items,e)}},{key:"subItemsMatchingPredicates",value:function(e,t){return e.filter(function(e){if(e.deleted)return!1;for(var n,r=S(t);!(n=r()).done;){var a=n.value;if(!e.satisfiesPredicate(a))return!1}return!0})}},{key:"findTagByTitle",value:function(e){var t=e.toLowerCase();return this.tags.find(function(e){return e.title.toLowerCase()===t})}},{key:"searchTags",value:function(e,t){var n=this;return Object(_.G)(this.tags.filter(function(r){var a=new RegExp("^".concat(e,"|").concat(".").concat(e),'i').test(r.title),i=!!t&&n.itemsReferencingItem(t.uuid).some(function(e){return(null===e||void 0===e?void 0:e.uuid)===r.uuid});return a&&!i}),'title')}},{key:"getTagParent",value:function(e){var t=this.findItem(e).parentId;if(t)return this.findItem(t)}},{key:"getTagParentChain",value:function(e){for(var t=this.findItem(e).parentId,n=[];t;){var r=this.findItem(t);n.unshift(r),t=r.parentId}return n}},{key:"getTagChildren",value:function(e){var t=this.findItem(e);return this.collection.elementsReferencingElement(t)}},{key:"isTagAncestor",value:function(e,t){for(var n=this.findItem(t).parentId;n;){if(n===e)return!0;n=this.findItem(n).parentId}return!1}},{key:"isValidTagParent",value:function(e,t){return e!==t&&!this.isTagAncestor(t,e)}},{key:"setTagParent",value:function(e,t){if(e.uuid===t.uuid)throw new Error('can not set a tag parent of itself');if(this.isTagAncestor(t.uuid,e.uuid))throw new Error('can not set a tag ancestor of itself');return this.changeTag(t.uuid,function(t){t.makeChildOf(e)})}},{key:"unsetTagParent",value:function(e){var t=this.getTagParent(e.uuid);return t?this.changeTag(e.uuid,function(e){e.removeItemAsRelationship(t)}):Promise.resolve(e)}},{key:"addTagToNote",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.changeItem(t.uuid,function(t){t.addItemAsRelationship(e)}));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getSortedTagsForNote",value:function(e){return Object(_.G)(this.itemsReferencingItem(e.uuid).filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===F.a.Tag}),'title')}},{key:"findOrCreateTagByTitle",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.findTagByTitle(e),n.t0=t,n.t0){n.next=6;break}return n.next=5,b.awrap(this.createItem(F.a.Tag,Object(Ke.a)({title:e}),!0));case 5:n.t0=n.sent;case 6:return n.abrupt("return",n.t0);case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"notesMatchingSmartTag",value:function(e){return this.notesView.notesMatchingSmartTag(e)}},{key:"emptyTrash",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.trashedItems,t.abrupt("return",this.setItemsToBeDeleted(Object(Ke.b)(e)));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){var e=this.collection.displayElements(F.a.SmartTag);return this.systemSmartTags.concat(e)}},{key:"removeAllItemsFromMemory",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Object(Ke.b)(this.items),t.next=3,b.awrap(this.changeItems(e,function(e){e.setDeleted()},T.c.NonDirtying));case 3:this.resetState(),this.payloadManager.resetState();case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"removeItemLocally",value:function(e){this.collection.discard(e),this.payloadManager.removePayloadLocally(e.payload)}},{key:"items",get:function(){return this.collection.all()}},{key:"nonDeletedItems",get:function(){return this.collection.nondeletedElements()}},{key:"invalidItems",get:function(){return this.collection.invalidElements()}},{key:"notes",get:function(){return this.notesView.displayElements()}},{key:"tags",get:function(){return this.collection.displayElements(F.a.Tag)}},{key:"components",get:function(){return this.collection.displayElements(F.a.Component)}},{key:"trashSmartTag",get:function(){return this.systemSmartTags.find(function(e){return e.isTrashTag})}},{key:"trashedItems",get:function(){return this.notesMatchingSmartTag(this.trashSmartTag)}},{key:"noteCount",get:function(){return this.collection.all(F.a.Note).length}}]),n})(R.a),Er='all-notes',Rr='archived-notes',Ir='trashed-notes';function Mr(e,t){return e.sort(function(e,n){var r=new Date(n.serverUpdatedAt).getTime()-new Date(e.serverUpdatedAt).getTime(),a=0,i=0;return t&&(a=t.indexOf(e.content_type),i=t.indexOf(n.content_type),-1===a&&(a=t.length),-1===i&&(i=t.length)),a===i?r:a<i?-1:1})}var Ar=(function(){function e(t,n){v(this,e),this.discordance=0,this.outOfSync=!1,this.receiver=t,this.maxDiscordance=n,this.reset()}return y(e,[{key:"isOutOfSync",value:function(){return this.outOfSync}},{key:"reset",value:function(){this.lastPreSyncSave=void 0,this.lastSyncDate=void 0,this.discordance=0,this.outOfSync=!1}},{key:"getLastClientIntegrityHash",value:function(){return this.lastClientHash}},{key:"clearIntegrityHashes",value:function(){this.lastClientHash=void 0,this.lastServerHash=void 0}},{key:"setIntegrityHashes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.lastClientHash=e,this.lastServerHash=t,!t||0===t.length||!e||e===t?(this.outOfSync&&(this.outOfSync=!1,this.receiver(on.a.ExitOutOfSync)),this.discordance=0):(this.discordance++,this.discordance>=this.maxDiscordance&&!this.outOfSync&&(this.outOfSync=!0,this.receiver(on.a.EnterOutOfSync)));case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"needsSync",get:function(){return this.discordance>0&&this.discordance<this.maxDiscordance}}]),e})(),jr=Object.freeze([F.a.ServerExtension]);function Tr(e){return e.filter(function(e){var t=![ue.a.DecryptedBareObject,ue.a.DecryptedBase64String].includes(e.format),n=jr.includes(e.content_type),r=t||n;return r||console.error('Filtering disallowed payload',e),r})}var Kr=(function(){function e(t,n,r,a,i){v(this,e),this.apiService=t,this.protocolService=n,this.contentType=r,this.customEvent=a,this.limit=i,this.progress={retrievedPayloads:[]}}return y(e,[{key:"run",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.next=2,b.awrap(this.apiService.sync([],this.progress.lastSyncToken,this.progress.paginationToken,this.limit||500,!1,this.contentType,this.customEvent));case 2:return r=s.sent,a=Tr(r.data.retrieved_items.map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)})),s.next=6,b.awrap(this.protocolService.payloadsByDecryptingPayloads(a));case 6:if(i=s.sent,this.progress.retrievedPayloads=this.progress.retrievedPayloads.concat(i),this.progress.lastSyncToken=null===(e=r.data)||void 0===e?void 0:e.sync_token,this.progress.paginationToken=null===(t=r.data)||void 0===t?void 0:t.cursor_token,null===(n=r.data)||void 0===n||!n.cursor_token){s.next=14;break}return s.abrupt("return",this.run());case 14:return s.abrupt("return",this.progress.retrievedPayloads);case 15:case"end":return s.stop()}},null,this,null,Promise)}}]),e})(),Fr=(function(e){d(n,vt);var t=k(n);function n(){return v(this,n),t.apply(this,arguments)}return y(n,[{key:"resultingCollection",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:e=[],t=S(this.applyCollection.all());case 2:if((n=t()).done){s.next=11;break}if(r=n.value,a=this.findRelatedPayload(r.uuid,ht.a.DecryptedTransient)){s.next=7;break}throw'Unable to find decrypted counterpart for rejected payload.';case 7:i=Object(Ee.f)(a,ht.a.RemoteRejected,{lastSyncEnd:new Date,dirty:!1}),e.push(i);case 9:s.next=2;break;case 11:return s.abrupt("return",bt.WithPayloads(e,ht.a.RemoteRejected));case 12:case"end":return s.stop()}},null,this,null,Promise)}}]),n})();function Lr(e){if(e===ht.a.RemoteRetrieved)return Rt;if(e===ht.a.RemoteSaved)return It;if(e===ht.a.ConflictData||e===ht.a.ConflictUuid)return Et;if(e===ht.a.RemoteRejected)return Fr;throw"No delta class found for source ".concat(ht.a[e])}var Ur,Nr=(function(){function e(t){v(this,e),this.collections=t,Object.freeze(this)}return y(e,[{key:"collectionForSource",value:function(e){return this.collections.find(function(t){return t.source===e})}}]),e})(),Vr=(function(){function e(t,n,r,a,i){v(this,e),this.response=t,this.baseCollection=r,this.historyMap=i,this.relatedCollectionSet=new Nr([bt.WithPayloads(n,ht.a.DecryptedTransient),bt.WithPayloads(a,ht.a.SavedOrSaving)])}return y(e,[{key:"collectionsByProcessingResponse",value:function(){var e,t,n,r,a,i;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return e=[],s.next=3,b.awrap(this.collectionByProcessingPayloads(this.response.retrievedPayloads,ht.a.RemoteRetrieved));case 3:return(t=s.sent).all().length>0&&e.push(t),s.next=7,b.awrap(this.collectionByProcessingPayloads(this.response.savedPayloads,ht.a.RemoteSaved));case 7:if((n=s.sent).all().length>0&&e.push(n),!(this.response.uuidConflictPayloads.length>0)){s.next=14;break}return s.next=12,b.awrap(this.collectionByProcessingPayloads(this.response.uuidConflictPayloads,ht.a.ConflictUuid));case 12:(r=s.sent).all().length>0&&e.push(r);case 14:if(!(this.response.dataConflictPayloads.length>0)){s.next=19;break}return s.next=17,b.awrap(this.collectionByProcessingPayloads(this.response.dataConflictPayloads,ht.a.ConflictData));case 17:(a=s.sent).all().length>0&&e.push(a);case 19:if(!(this.response.rejectedPayloads.length>0)){s.next=24;break}return s.next=22,b.awrap(this.collectionByProcessingPayloads(this.response.rejectedPayloads,ht.a.RemoteRejected));case 22:(i=s.sent).all().length>0&&e.push(i);case 24:return s.abrupt("return",e);case 25:case"end":return s.stop()}},null,this,null,Promise)}},{key:"collectionByProcessingPayloads",value:function(e,t){var n,r,a,i,s,o=this;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:return n=bt.WithPayloads(Tr(e),t),r=Lr(t),a=new r(this.baseCollection,n,this.relatedCollectionSet,this.historyMap),c.next=5,b.awrap(a.resultingCollection());case 5:return i=c.sent,s=i.all().map(function(e){var t=o.finalDirtyStateForPayload(e);return Object(Ee.b)(e,{dirty:t,dirtiedDate:t?new Date:void 0})}),c.abrupt("return",bt.WithPayloads(s,t));case 8:case"end":return c.stop()}},null,this,null,Promise)}},{key:"finalDirtyStateForPayload",value:function(e){var t=this.baseCollection.find(e.uuid);return t?!t.dirtiedDate||e.dirtiedDate&&e.dirtiedDate>t.dirtiedDate?e.dirty:!e.discardable&&t.dirtiedDate>=t.lastSyncBegan:e.dirty}}]),e})(),Br=(function(){function e(t){var n,r;v(this,e),this.rawResponse=t,this.savedPayloads=this.filterRawItemArray(null===(n=t.data)||void 0===n?void 0:n.saved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteSaved)}),this.retrievedPayloads=this.filterRawItemArray(null===(r=t.data)||void 0===r?void 0:r.retrieved_items).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRetrieved)}),this.dataConflictPayloads=this.filterRawItemArray(this.rawDataConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictData)}),this.uuidConflictPayloads=this.filterRawItemArray(this.rawUuidConflictItems).map(function(e){return Object(Ee.f)(e,ht.a.ConflictUuid)}),this.rejectedPayloads=this.filterRawItemArray(this.rawRejectedPayloads).map(function(e){return Object(Ee.f)(e,ht.a.RemoteRejected)}),this.deletedPayloads=this.allProcessedPayloads.filter(function(e){return e.discardable}),Object(_.l)(this)}return y(e,[{key:"filterRawItemArray",value:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return!!e.uuid})}},{key:"error",get:function(){var e;return this.rawResponse.error||(null===(e=this.rawResponse.data)||void 0===e?void 0:e.error)}},{key:"status",get:function(){return this.rawResponse.status}},{key:"lastSyncToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.LastSyncToken]}},{key:"paginationToken",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.PaginationToken]}},{key:"integrityHash",get:function(){var e;return null===(e=this.rawResponse.data)||void 0===e?void 0:e[Tt.a.IntegrityResult]}},{key:"checkIntegrity",get:function(){return this.integrityHash&&!this.paginationToken}},{key:"numberOfItemsInvolved",get:function(){return this.allProcessedPayloads.length}},{key:"allProcessedPayloads",get:function(){return this.savedPayloads.concat(this.retrievedPayloads).concat(this.dataConflictPayloads).concat(this.uuidConflictPayloads).concat(this.rejectedPayloads)}},{key:"rawUuidConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.UuidConflict}).map(function(e){return e.unsaved_item||e.item})}},{key:"rawDataConflictItems",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ConflictingData}).map(function(e){return e.server_item||e.item})}},{key:"rawRejectedPayloads",get:function(){return this.rawConflictObjects.filter(function(e){return e.type===Te.a.ContentTypeError||e.type===Te.a.ContentError}).map(function(e){return e.unsaved_item})}},{key:"rawConflictObjects",get:function(){var e,t,n=(null===(e=this.rawResponse.data)||void 0===e?void 0:e.conflicts)||[],r=(null===(t=this.rawResponse.data)||void 0===t?void 0:t.unsaved)||[];return n.concat(r)}},{key:"hasError",get:function(){return!Object(_.w)(this.rawResponse.error)}}]),e})();!(function(e){e[e.Response=1]="Response",e[e.StatusChanged=2]="StatusChanged"})(Ur||(Ur={}));var Wr=150,Hr=(function(){function e(t,n,r,a,i,s){v(this,e),this.payloads=t,this.receiver=n,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.id=Math.random(),this.responses=[],this.payloads=t,this.lastSyncToken=r,this.paginationToken=a,this.checkIntegrity=i,this.apiService=s,this.receiver=n,this.pendingPayloads=t.slice()}return y(e,[{key:"popPayloads",value:function(e){var t=this.pendingPayloads.slice(0,e);return Object(_.R)(this.pendingPayloads,t),t}},{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.receiver(Ur.StatusChanged,void 0,{completedUploadCount:this.totalUploadCount-this.pendingUploadCount,totalUploadCount:this.totalUploadCount}));case 2:return e=this.popPayloads(this.upLimit),r.next=5,b.awrap(this.apiService.sync(e,this.lastSyncToken,this.paginationToken,this.downLimit,this.checkIntegrity,void 0,void 0));case 5:return t=r.sent,n=new Br(t),this.responses.push(n),this.lastSyncToken=n.lastSyncToken,this.paginationToken=n.paginationToken,r.next=12,b.awrap(this.receiver(Ur.Response,n));case 12:if(this.done){r.next=14;break}return r.abrupt("return",this.run());case 14:case"end":return r.stop()}},null,this,null,Promise)}},{key:"payloadsSavedOrSaving",get:function(){return Object(_.c)(this.payloads,this.pendingPayloads)}},{key:"done",get:function(){return 0===this.pendingPayloads.length&&!this.paginationToken}},{key:"pendingUploadCount",get:function(){return this.pendingPayloads.length}},{key:"totalUploadCount",get:function(){return this.payloads.length}},{key:"upLimit",get:function(){return Wr}},{key:"downLimit",get:function(){return Wr}},{key:"numberOfItemsInvolved",get:function(){for(var e,t=0,n=S(this.responses);!(e=n()).done;){t+=e.value.numberOfItemsInvolved}return t}}]),e})(),zr=(function(){function e(t,n){v(this,e),this.payloads=t,this.receiver=n}return y(e,[{key:"run",value:function(){var e,t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return e=this.payloads.map(function(e){return Object(Ee.f)(e,ht.a.LocalSaved,{dirty:!1,lastSyncEnd:new Date})}),t=Object(_.a)(e),n=new Br({data:{saved_items:t}}),r.next=5,b.awrap(this.receiver(Ur.Response,n));case 5:case"end":return r.stop()}},null,this,null,Promise)}}]),e})();function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){Gr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Qr,Jr,$r,Xr=5,Zr=15;!(function(e){e[e.ResolveOnNext=1]="ResolveOnNext",e[e.ForceSpawnNew=2]="ForceSpawnNew"})(Qr||(Qr={})),(function(e){e[e.Default=1]="Default",e[e.DownloadFirst=2]="DownloadFirst"})(Jr||(Jr={})),(function(e){e[e.External=1]="External",e[e.SpawnQueue=2]="SpawnQueue",e[e.ResolveQueue=3]="ResolveQueue",e[e.MoreDirtyItems=4]="MoreDirtyItems",e[e.AfterDownloadFirst=5]="AfterDownloadFirst",e[e.IntegrityCheck=6]="IntegrityCheck",e[e.ResolveOutOfSync=7]="ResolveOutOfSync"})($r||($r={}));var ea=(function(e){d(n,e);var t=k(n);function n(e,r,a,i,s,o,c,u){var l;return v(this,n),(l=t.call(this)).itemManager=e,l.sessionManager=r,l.protocolService=a,l.storageService=i,l.payloadManager=s,l.apiService=o,l.historyService=c,l.resolveQueue=[],l.spawnQueue=[],l.completedOnlineDownloadFirstSync=!1,l.majorChangeThreshold=Zr,l.maxDiscordance=Xr,l.locked=!1,l.databaseLoaded=!1,l.syncLock=!1,l.dealloced=!1,l.localLoadPriorty=[F.a.ItemsKey,F.a.UserPrefs,F.a.Component,F.a.Theme],l.itemManager=e,l.sessionManager=r,l.protocolService=a,l.payloadManager=s,l.storageService=i,l.apiService=o,l.interval=u,l.initializeStatus(),l.initializeState(),l}return y(n,[{key:"onNewDatabaseCreated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.getLastSyncToken());case 2:if(!e.sent){e.next=5;break}return e.next=5,b.awrap(this.clearSyncPositionTokens());case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"deinit",value:function(){this.dealloced=!0,this.sessionManager=void 0,this.itemManager=void 0,this.protocolService=void 0,this.payloadManager=void 0,this.storageService=void 0,this.apiService=void 0,this.interval=void 0,this.state.reset(),this.opStatus.reset(),this.state=void 0,this.opStatus=void 0,this.resolveQueue.length=0,this.spawnQueue.length=0,p(f(n.prototype),"deinit",this).call(this)}},{key:"initializeStatus",value:function(){var e=this;this.opStatus=new fr(this.interval,function(t){e.notifyEvent(t)})}},{key:"initializeState",value:function(){var e=this;this.state=new Ar(function(t){t===on.a.EnterOutOfSync?e.notifyEvent(on.a.EnterOutOfSync):t===on.a.ExitOutOfSync&&e.notifyEvent(on.a.ExitOutOfSync)},this.maxDiscordance)}},{key:"lockSyncing",value:function(){this.locked=!0}},{key:"unlockSyncing",value:function(){this.locked=!1}},{key:"isOutOfSync",value:function(){return this.state.isOutOfSync()}},{key:"getLastSyncDate",value:function(){return this.state.lastSyncDate}},{key:"getStatus",value:function(){return this.opStatus}},{key:"resetSyncState",value:function(){this.state.reset()}},{key:"isDatabaseLoaded",value:function(){return this.databaseLoaded}},{key:"getDatabasePayloads",value:function(){var e=this;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.storageService.getAllRawPayloads().catch(function(t){throw e.notifyEvent(on.a.DatabaseReadError,t),t}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"loadDatabasePayloads",value:function(e){var t,n,r,a,i,s,o,c,u,l,p;return b.async(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.databaseLoaded){d.next=2;break}throw'Attempting to initialize already initialized local database.';case 2:if(0!==e.length){d.next=6;break}return this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0),d.abrupt("return");case 6:return t=e.map(function(e){try{return Object(Ee.e)(e)}catch(e){return void console.error('Creating payload failed',e)}}).filter(function(e){return!Object(_.w)(e)}),n=Mr(t,this.localLoadPriorty),r=n.filter(function(e){return e.content_type===F.a.ItemsKey}),Object(_.R)(n,r),d.next=12,b.awrap(this.protocolService.payloadsByDecryptingPayloads(r));case 12:return a=d.sent,d.next=15,b.awrap(this.payloadManager.emitPayloads(a,ht.a.LocalRetrieved));case 15:i=n.length,s=100,o=Math.ceil(i/s),c=0;case 19:if(!(c<o)){d.next=32;break}return u=c*s,l=n.slice(u,u+s),d.next=24,b.awrap(this.protocolService.payloadsByDecryptingPayloads(l));case 24:return p=d.sent,d.next=27,b.awrap(this.payloadManager.emitPayloads(p,ht.a.LocalRetrieved));case 27:this.notifyEvent(on.a.LocalDataIncrementalLoad),this.opStatus.setDatabaseLoadStatus(u,i,!1);case 29:c++,d.next=19;break;case 32:this.databaseLoaded=!0,this.opStatus.setDatabaseLoadStatus(0,0,!0);case 34:case"end":return d.stop()}},null,this,null,Promise)}},{key:"setLastSyncToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return this.syncToken=e,t.abrupt("return",this.storageService.setValue(o.LastSyncToken,e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setPaginationToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.cursorToken=e,!e){t.next=5;break}return t.abrupt("return",this.storageService.setValue(o.PaginationToken,e));case 5:return t.abrupt("return",this.storageService.removeValue(o.PaginationToken));case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getLastSyncToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.syncToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.LastSyncToken));case 3:this.syncToken=e.sent;case 4:return e.abrupt("return",this.syncToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getPaginationToken",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cursorToken){e.next=4;break}return e.next=3,b.awrap(this.storageService.getValue(o.PaginationToken));case 3:this.cursorToken=e.sent;case 4:return e.abrupt("return",this.cursorToken);case 5:case"end":return e.stop()}},null,this,null,Promise)}},{key:"clearSyncPositionTokens",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return this.syncToken=void 0,this.cursorToken=void 0,e.next=4,b.awrap(this.storageService.removeValue(o.LastSyncToken));case 4:return e.next=6,b.awrap(this.storageService.removeValue(o.PaginationToken));case 6:case"end":return e.stop()}},null,this,null,Promise)}},{key:"itemsNeedingSync",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.itemManager.getDirtyItems(),t.abrupt("return",e);case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"alternateUuidForItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=this.itemManager.findItem(e),n=Object(Ee.e)(t),a.next=4,b.awrap(lt(n,this.payloadManager.getMasterCollection()));case 4:return r=a.sent,a.next=7,b.awrap(this.payloadManager.emitPayloads(r,ht.a.LocalChanged));case 7:return a.next=9,b.awrap(this.persistPayloads(r));case 9:return a.abrupt("return",this.itemManager.findItem(r[0].uuid));case 10:case"end":return a.stop()}},null,this,null,Promise)}},{key:"markAllItemsAsNeedingSync",value:function(){var e,t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return this.log('Marking all items as needing sync'),e=this.itemManager.items,t=e.map(function(e){return Object(Ee.e)(e,{dirty:!0,dirtiedDate:new Date})}),n.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 5:return n.next=7,b.awrap(this.persistPayloads(t));case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"popPayloadsNeedingPreSyncSave",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.state.lastPreSyncSave){r.next=3;break}return r.abrupt("return",e);case 3:return n=e.filter(function(e){return!e.dirtiedDate||e.dirtiedDate>t}),this.state.lastPreSyncSave=new Date,r.abrupt("return",n);case 6:case"end":return r.stop()}},null,this,null,Promise)}},{key:"queueStrategyResolveOnNext",value:function(){var e=this;return new Promise(function(t,n){e.resolveQueue.push({resolve:t,reject:n})})}},{key:"queueStrategyForceSpawnNew",value:function(e){var t=this;return new Promise(function(n,r){t.spawnQueue.push({resolve:n,reject:r,options:e})})}},{key:"popSpawnQueue",value:function(){if(0===this.spawnQueue.length)return null;var e=this.spawnQueue[0];return Object(_.N)(this.spawnQueue,0),this.log('Syncing again from spawn queue'),this.sync(Yr({queueStrategy:Qr.ForceSpawnNew,source:$r.SpawnQueue},e.options)).then(function(){e.resolve()}).catch(function(){e.reject()})}},{key:"payloadsByPreparingForServer",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.protocolService.payloadsByEncryptingPayloads(e,function(e){return jr.includes(e.content_type)?Re.b.SyncDecrypted:Re.b.Sync}));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"downloadFirstSync",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:n=5,r=0;case 2:if(!(r<n)){a.next=14;break}return a.next=5,b.awrap(this.sync(Yr({mode:Jr.DownloadFirst,queueStrategy:Qr.ForceSpawnNew},t)).catch(console.error));case 5:if(!this.completedOnlineDownloadFirstSync){a.next=9;break}return a.abrupt("return");case 9:return a.next=11,b.awrap(Object(_.P)(e));case 11:r++,a.next=2;break;case 14:console.error("Failed downloadFirstSync after ".concat(n," tries"));case 15:case"end":return a.stop()}},null,this,null,Promise)}},{key:"awaitCurrentSyncs",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.lastSyncInvokationPromise);case 2:return e.next=4,b.awrap(this.currentSyncRequestPromise);case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"sync",value:function(){var e,t=arguments;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},this.lastSyncInvokationPromise=this.performSync(e),n.abrupt("return",this.lastSyncInvokationPromise);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"performSync",value:function(){var e,t,n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k,x,P=this,O=arguments;return b.async(function(C){for(;;)switch(C.prev=C.next){case 0:if(e=O.length>0&&void 0!==O[0]?O[0]:{},!this.locked){C.next=4;break}return this.log('Sync Locked'),C.abrupt("return");case 4:return t=function(){return P.syncLock},n=function(){P.syncLock=!0},r=function(){P.syncLock=!1},a=this.opStatus.syncInProgress,i=this.databaseLoaded,(s=!t())&&i&&!a&&n(),e.source||(e.source=$r.External),C.next=14,b.awrap(this.itemsNeedingSync());case 14:return o=C.sent,c=new Date,u=o.filter(function(e){return e.neverSynced&&e.deleted}),Object(_.R)(o,u),l=o.map(function(e){return e.payloadRepresentation()}),C.next=21,b.awrap(this.popPayloadsNeedingPreSyncSave(l));case 21:return p=C.sent,C.next=24,b.awrap(this.persistPayloads(p));case 24:if(d=this.resolveQueue.slice(),h=Object(_.w)(e.queueStrategy)?Qr.ResolveOnNext:e.queueStrategy,!a&&i&&s){C.next=37;break}if(this.log(s?a?'Attempting to sync while existing sync in progress.':'Attempting to sync before local database has loaded.':'Another function call has begun preparing for sync.'),h!==Qr.ResolveOnNext){C.next=32;break}return C.abrupt("return",this.queueStrategyResolveOnNext());case 32:if(h!==Qr.ForceSpawnNew){C.next=36;break}return C.abrupt("return",this.queueStrategyForceSpawnNew({mode:e.mode,checkIntegrity:e.checkIntegrity,source:e.source}));case 36:throw Error("Unhandled timing strategy ".concat(h));case 37:if(!this.dealloced){C.next=39;break}return C.abrupt("return");case 39:return this.opStatus.setDidBegin(),C.next=42,b.awrap(this.notifyEvent(on.a.SyncWillBegin));case 42:if(Object(_.R)(this.resolveQueue,d),!(o.length>0)){C.next=46;break}return C.next=46,b.awrap(this.itemManager.changeItems(Object(Ke.b)(o),function(e){e.lastSyncBegan=c},T.c.NonDirtying,ht.a.PreSyncSave));case 46:if(this.protocolService.hasAccount()!==this.sessionManager.online()&&this.handleInvalidSessionState(),f=this.sessionManager.online(),D=e.mode,v=f&&!P.completedOnlineDownloadFirstSync?Jr.DownloadFirst:Object(_.w)(D)?Jr.Default:D,y=[],v!==Jr.Default){C.next=63;break}if(!f||this.completedOnlineDownloadFirstSync){C.next=54;break}throw Error('Attempting to default mode sync without having completed initial.');case 54:if(!f){C.next=60;break}return C.next=57,b.awrap(this.payloadsByPreparingForServer(l));case 57:y=C.sent,C.next=61;break;case 60:y=l;case 61:C.next=64;break;case 63:v===Jr.DownloadFirst&&(y=[]);case 64:if(!f){C.next=70;break}return C.next=67,b.awrap(this.syncOnlineOperation(y,e.checkIntegrity,e.source,v));case 67:g=C.sent,C.next=73;break;case 70:return C.next=72,b.awrap(this.syncOfflineOperation(y,e.source,v));case 72:g=C.sent;case 73:return this.currentSyncRequestPromise=g.run(),C.next=76,b.awrap(this.currentSyncRequestPromise);case 76:if(!this.dealloced){C.next=78;break}return C.abrupt("return");case 78:if(this.opStatus.setDidEnd(),r(),!this.opStatus.hasError()){C.next=82;break}return C.abrupt("return");case 82:if(this.opStatus.reset(),this.state.lastSyncDate=new Date,g instanceof Hr&&g.numberOfItemsInvolved>=this.majorChangeThreshold&&this.notifyEvent(on.a.MajorDataChange),!(u.length>0)){C.next=88;break}return C.next=88,b.awrap(this.handleNeverSyncedDeleted(u));case 88:if(v===Jr.DownloadFirst){C.next=91;break}return C.next=91,b.awrap(this.notifyEvent(on.a.FullSyncCompleted,{source:e.source}));case 91:if(v!==Jr.DownloadFirst){C.next=99;break}return f&&(this.completedOnlineDownloadFirstSync=!0),C.next=95,b.awrap(this.notifyEvent(on.a.DownloadFirstSyncCompleted));case 95:return C.next=97,b.awrap(this.sync({source:$r.AfterDownloadFirst,checkIntegrity:!0,awaitAll:e.awaitAll}));case 97:C.next=125;break;case 99:if(this.popSpawnQueue()||!(this.resolveQueue.length>0)){C.next=107;break}if(this.log('Syncing again from resolve queue'),m=this.sync({source:$r.ResolveQueue,checkIntegrity:e.checkIntegrity}),!e.awaitAll){C.next=105;break}return C.next=105,b.awrap(m);case 105:C.next=125;break;case 107:return C.next=109,b.awrap(this.itemsNeedingSync());case 109:if(C.t0=C.sent.length,!(C.t0>0)){C.next=115;break}return C.next=113,b.awrap(this.sync({source:$r.MoreDirtyItems,checkIntegrity:e.checkIntegrity,awaitAll:e.awaitAll}));case 113:C.next=125;break;case 115:if(!(g instanceof Hr&&g.checkIntegrity)){C.next=124;break}if(!this.state.needsSync||!g.done){C.next=122;break}if(this.log('Syncing again from integrity check'),w=this.sync({checkIntegrity:!0,queueStrategy:Qr.ForceSpawnNew,source:$r.IntegrityCheck,awaitAll:e.awaitAll}),!e.awaitAll){C.next=122;break}return C.next=122,b.awrap(w);case 122:C.next=125;break;case 124:this.state.clearIntegrityHashes();case 125:for(k=S(d);!(x=k()).done;)x.value.resolve();case 126:case"end":return C.stop()}var D},null,this,null,Promise)}},{key:"handleInvalidSessionState",value:function(){we.a.error(Error('Session missing while attempting to sync.')),this.sessionManager.reauthenticateInvalidSession()}},{key:"syncOnlineOperation",value:function(e,t,n,r){var a,i=this;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return s.t0=Hr,s.t1=e,s.t2=function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=e,r.next=r.t0===Ur.Response?3:r.t0===Ur.StatusChanged?13:15;break;case 3:if(!i.dealloced){r.next=5;break}return r.abrupt("return");case 5:if(!t.hasError){r.next=10;break}return r.next=8,b.awrap(i.handleErrorServerResponse(t));case 8:r.next=12;break;case 10:return r.next=12,b.awrap(i.handleSuccessServerResponse(a,t));case 12:return r.abrupt("break",15);case 13:return i.opStatus.setUploadStatus(n.completedUploadCount,n.totalUploadCount),r.abrupt("break",15);case 15:case"end":return r.stop()}},null,null,null,Promise)},s.next=5,b.awrap(this.getLastSyncToken());case 5:return s.t3=s.sent,s.next=8,b.awrap(this.getPaginationToken());case 8:return s.t4=s.sent,s.t5=t,s.t6=this.apiService,a=new s.t0(s.t1,s.t2,s.t3,s.t4,s.t5,s.t6),this.log('Syncing online user','source:',n,'operation id',a.id,'integrity check',t,'mode:',r,'payloads:',e),s.abrupt("return",a);case 14:case"end":return s.stop()}},null,this,null,Promise)}},{key:"syncOfflineOperation",value:function(e,t,n){var r,a=this;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return this.log('Syncing offline user','source:',t,'mode:',n,'payloads:',e),r=new zr(e,function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(!a.dealloced){n.next=2;break}return n.abrupt("return");case 2:if(e!==Ur.Response){n.next=5;break}return n.next=5,b.awrap(a.handleOfflineResponse(t));case 5:case"end":return n.stop()}},null,null,null,Promise)}),i.abrupt("return",r);case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"handleOfflineResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.log('Offline Sync Response',e.rawResponse),!((t=e.savedPayloads).length>0)){a.next=8;break}return a.next=5,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalSaved));case 5:return n=this.payloadManager.find(Object(Ke.b)(t)),a.next=8,b.awrap(this.persistPayloads(n));case 8:if(!((r=e.deletedPayloads).length>0)){a.next=12;break}return a.next=12,b.awrap(this.deletePayloads(r));case 12:return this.opStatus.clearError(),this.opStatus.setDownloadStatus(e.retrievedPayloads.length),a.next=16,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,e));case 16:case"end":return a.stop()}},null,this,null,Promise)}},{key:"handleErrorServerResponse",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:this.log('Sync Error',e),401===e.status&&this.notifyEvent(on.a.InvalidSession),null===(t=this.opStatus)||void 0===t||t.setError(e.error),this.notifyEvent(on.a.SyncError,e.error);case 4:case"end":return n.stop()}},null,this,null,Promise)}},{key:"handleSuccessServerResponse",value:function(e,t){var n,r,a,i,s,o,c,u,l,p,d,h,f,v,y,g,m,w,k;return b.async(function(x){for(;;)switch(x.prev=x.next){case 0:if(!this._simulate_latency){x.next=3;break}return x.next=3,b.awrap(Object(_.P)(this._simulate_latency.latency));case 3:this.log('Online Sync Response','operation id',e.id,t.rawResponse),this.setLastSyncToken(t.lastSyncToken),this.setPaginationToken(t.paginationToken),this.opStatus.clearError(),this.opStatus.setDownloadStatus(t.retrievedPayloads.length),n=[],r=t.allProcessedPayloads,a={},i=S(r);case 12:if((s=i()).done){x.next=25;break}if(!(o=s.value).deleted&&o.fields.includes(Je.a.Content)){x.next=16;break}return x.abrupt("continue",23);case 16:return c=a[o.items_key_id],u=c?nt(c):void 0,x.next=20,b.awrap(this.protocolService.payloadByDecryptingPayload(o,u));case 20:(l=x.sent).content_type===F.a.ItemsKey&&(a[l.uuid]=l),n.push(l);case 23:x.next=12;break;case 25:return p=this.payloadManager.getMasterCollection(),d=this.historyService.getHistoryMapCopy(),h=new Vr(t,n,p,e.payloadsSavedOrSaving,d),x.next=30,b.awrap(h.collectionsByProcessingResponse());case 30:f=x.sent,v=S(f);case 32:if((y=v()).done){x.next=41;break}return g=y.value,x.next=36,b.awrap(this.payloadManager.emitCollection(g));case 36:return m=x.sent,x.next=39,b.awrap(this.persistPayloads(m));case 39:x.next=32;break;case 41:if(!((w=t.deletedPayloads).length>0)){x.next=45;break}return x.next=45,b.awrap(this.deletePayloads(w));case 45:return x.next=47,b.awrap(this.notifyEvent(on.a.SingleSyncCompleted,t));case 47:if(!t.checkIntegrity){x.next=53;break}return x.next=50,b.awrap(this.computeDataIntegrityHash());case 50:return k=x.sent,x.next=53,b.awrap(this.state.setIntegrityHashes(k,t.integrityHash));case 53:case"end":return x.stop()}},null,this,null,Promise)}},{key:"handleNeverSyncedDeleted",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=e.map(function(e){return e.payloadRepresentation({dirty:!1})}),n.next=3,b.awrap(this.payloadManager.emitPayloads(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.persistPayloads(t));case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"persistPayloads",value:function(e){var t=this;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(0!==e.length&&!this.dealloced){n.next=2;break}return n.abrupt("return");case 2:return n.abrupt("return",this.storageService.savePayloads(e).catch(function(e){t.notifyEvent(on.a.DatabaseWriteError,e),we.a.error(e)}));case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"deletePayloads",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.persistPayloads(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"computeDataIntegrityHash",value:function(){var e,t,n,r,a,i,s,o,c;return b.async(function(u){for(;;)switch(u.prev=u.next){case 0:u.prev=0,e=this.itemManager.nonDeletedItems.sort(function(e,t){return t.serverUpdatedAtTimestamp-e.serverUpdatedAtTimestamp}),t=[],n=1e3,r=S(e);case 5:if((a=r()).done){u.next=14;break}if(i=a.value,s=i.serverUpdatedAtTimestamp){u.next=10;break}return u.abrupt("return",void 0);case 10:o=Math.floor(s/n),t.push(o);case 12:u.next=5;break;case 14:return c=t.join(','),u.abrupt("return",this.protocolService.crypto.sha256(c));case 18:return u.prev=18,u.t0=u.catch(0),console.error('Error computing data integrity hash',u.t0),u.abrupt("return",void 0);case 22:case"end":return u.stop()}},null,this,[[0,18]],Promise)}},{key:"resolveOutOfSync",value:function(){var e,t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return e=new Kr(this.apiService,this.protocolService,void 0,'resolve-out-of-sync'),a.next=3,b.awrap(e.run());case 3:return t=a.sent,n=new _t(this.payloadManager.getMasterCollection(),bt.WithPayloads(t,ht.a.RemoteRetrieved),void 0,this.historyService.getHistoryMapCopy()),a.next=7,b.awrap(n.resultingCollection());case 7:return r=a.sent,a.next=10,b.awrap(this.payloadManager.emitCollection(r));case 10:return a.next=12,b.awrap(this.persistPayloads(r.payloads));case 12:return a.abrupt("return",this.sync({checkIntegrity:!0,source:$r.ResolveOutOfSync}));case 13:case"end":return a.stop()}},null,this,null,Promise)}},{key:"statelessDownloadAllItems",value:function(e,t){var n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=new Kr(this.apiService,this.protocolService,e,t),a.next=3,b.awrap(n.run());case 3:return r=a.sent,a.abrupt("return",r.map(function(e){return nt(e)}));case 5:case"end":return a.stop()}},null,this,null,Promise)}},{key:"ut_setDatabaseLoaded",value:function(e){this.databaseLoaded=e}},{key:"ut_clearLastSyncDate",value:function(){this.state.lastSyncDate=void 0}},{key:"ut_beginLatencySimulator",value:function(e){this._simulate_latency={latency:e||1e3,enabled:!0}}},{key:"ut_endLatencySimulator",value:function(){this._simulate_latency=void 0}}]),n})(R.a),ta=(function(){function e(t,n,r,a,i,s){v(this,e),this.challenge=t,this.onValidValue=n,this.onInvalidValue=r,this.onNonvalidatedSubmit=a,this.onComplete=i,this.onCancel=s,this.nonvalidatedValues=[],this.validValues=[],this.invalidValues=[],this.artifacts={}}return y(e,[{key:"complete",value:function(e){var t;e||(e=new be(this.challenge,this.validValues,this.artifacts)),null===(t=this.onComplete)||void 0===t||t.call(this,e)}},{key:"nonvalidatedSubmit",value:function(){var e,t=new be(this.challenge,this.nonvalidatedValues.slice(),this.artifacts);null===(e=this.onNonvalidatedSubmit)||void 0===e||e.call(this,t),this.nonvalidatedValues=[]}},{key:"cancel",value:function(){var e;null===(e=this.onCancel)||void 0===e||e.call(this)}},{key:"isFinished",value:function(){return this.validValues.length===this.challenge.prompts.length}},{key:"nonvalidatedPrompts",value:function(){return this.challenge.prompts.filter(function(e){return!e.validates})}},{key:"addNonvalidatedValue",value:function(e){var t=this.nonvalidatedValues,n=t.find(function(t){return t.prompt.id===e.prompt.id});n&&Object(_.M)(t,n),t.push(e),this.nonvalidatedValues.length===this.nonvalidatedPrompts().length&&this.nonvalidatedSubmit()}},{key:"setValueStatus",value:function(e,t,n){var r,a,i=t?this.validValues:this.invalidValues,s=i.find(function(t){return t.prompt.validation===e.prompt.validation});(s&&Object(_.M)(i,s),i.push(e),w(this.artifacts,n),this.isFinished())?this.complete():t?null===(r=this.onValidValue)||void 0===r||r.call(this,e):null===(a=this.onInvalidValue)||void 0===a||a.call(this,e)}}]),e})(),na=(function(e){d(n,e);var t=k(n);function n(e,r){var a;return v(this,n),(a=t.call(this)).storageService=e,a.protocolService=r,a.challengeOperations={},a.challengeObservers={},a}return y(n,[{key:"deinit",value:function(){this.storageService=void 0,this.protocolService=void 0,this.sendChallenge=void 0,this.challengeOperations=void 0,this.challengeObservers=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"promptForChallengeResponse",value:function(e){var t=this;return new Promise(function(n){t.createOrGetChallengeOperation(e,n),t.sendChallenge(e)})}},{key:"validateChallengeValue",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e.prompt.validation,t.next=t.t0===te.LocalPasscode?3:t.t0===te.AccountPassword?4:t.t0===te.Biometric?5:t.t0===te.ProtectionSessionDuration?6:7;break;case 3:return t.abrupt("return",this.protocolService.validatePasscode(e.value));case 4:return t.abrupt("return",this.protocolService.validateAccountPassword(e.value));case 5:return t.abrupt("return",{valid:!0===e.value});case 6:return t.abrupt("return",{valid:(n=e.value,'number'==typeof n&&Object.values(er).includes(n))});case 7:throw Error("Unhandled validation mode ".concat(e.prompt.validation));case 8:case"end":return t.stop()}var n},null,this,null,Promise)}},{key:"promptForCorrectPasscode",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=new ye([new ge(te.LocalPasscode)],e,!0),a.next=3,b.awrap(this.promptForChallengeResponse(t));case 3:if(n=a.sent){a.next=6;break}return a.abrupt("return",void 0);case 6:return r=n.getValueForType(te.LocalPasscode),a.abrupt("return",r.value);case 8:case"end":return a.stop()}},null,this,null,Promise)}},{key:"getWrappingKeyIfApplicable",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.protocolService.hasPasscode()){n.next=2;break}return n.abrupt("return",{});case 2:if(e){n.next=8;break}return n.next=5,b.awrap(this.promptForCorrectPasscode(ne.ResaveRootKey));case 5:if(e=n.sent){n.next=8;break}return n.abrupt("return",{canceled:!0});case 8:return n.next=10,b.awrap(this.protocolService.computeWrappingKey(e));case 10:return t=n.sent,n.abrupt("return",{wrappingKey:t});case 12:case"end":return n.stop()}},null,this,null,Promise)}},{key:"isPasscodeLocked",value:function(){return this.protocolService.rootKeyNeedsUnwrapping()}},{key:"addChallengeObserver",value:function(e,t){var n=this.challengeObservers[e.id]||[];return n.push(t),this.challengeObservers[e.id]=n,function(){Object(_.M)(n,t)}}},{key:"createOrGetChallengeOperation",value:function(e,t){var n=this,r=this.getChallengeOperation(e);return r||(r=new ta(e,function(t){n.onChallengeValidValue(e,t)},function(t){n.onChallengeInvalidValue(e,t)},function(r){n.onChallengeNonvalidatedSubmit(e,r),t(r)},function(r){n.onChallengeComplete(e,r),t(r)},function(){n.onChallengeCancel(e),t(void 0)}),this.challengeOperations[e.id]=r),r}},{key:"performOnObservers",value:function(e,t){for(var n,r=S(this.challengeObservers[e.id]||[]);!(n=r()).done;){t(n.value)}}},{key:"onChallengeValidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onValidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeInvalidValue",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onInvalidValue)||void 0===n||n.call(e,t)})}},{key:"onChallengeNonvalidatedSubmit",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onNonvalidatedSubmit)||void 0===n||n.call(e,t)})}},{key:"onChallengeComplete",value:function(e,t){this.performOnObservers(e,function(e){var n;null===(n=e.onComplete)||void 0===n||n.call(e,t)})}},{key:"onChallengeCancel",value:function(e){this.performOnObservers(e,function(e){var t;null===(t=e.onCancel)||void 0===t||t.call(e)})}},{key:"getChallengeOperation",value:function(e){return this.challengeOperations[e.id]}},{key:"deleteChallengeOperation",value:function(e){delete this.challengeOperations[e.challenge.id]}},{key:"cancelChallenge",value:function(e){var t=this.challengeOperations[e.id];t.cancel(),this.deleteChallengeOperation(t)}},{key:"completeChallenge",value:function(e){var t=this.challengeOperations[e.id];t.complete(),this.deleteChallengeOperation(t)}},{key:"submitValuesForChallenge",value:function(e,t){var n,r,a,i,s,o;return b.async(function(c){for(;;)switch(c.prev=c.next){case 0:if(0!==t.length){c.next=2;break}throw Error('Attempting to submit 0 values for challenge');case 2:n=S(t);case 3:if((r=n()).done){c.next=18;break}if((a=r.value).prompt.validates){c.next=10;break}this.getChallengeOperation(e).addNonvalidatedValue(a),c.next=16;break;case 10:return c.next=12,b.awrap(this.validateChallengeValue(a));case 12:i=c.sent,s=i.valid,o=i.artifacts,this.setValidationStatusForChallenge(e,a,s,o);case 16:c.next=3;break;case 18:case"end":return c.stop()}},null,this,null,Promise)}},{key:"setValidationStatusForChallenge",value:function(e,t,n,r){var a=this.getChallengeOperation(e);a.setValueStatus(t,n,r),a.isFinished()&&(this.deleteChallengeOperation(a),delete this.challengeObservers[a.challenge.id])}}]),n})(R.a),ra=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).singletonManager=e,i.itemManager=r,i.syncService=a,i.shouldReload=!0,i.reloading=!1,i.removeItemObserver=r.addObserver(F.a.UserPrefs,function(){i.shouldReload=!0}),i.removeSyncObserver=a.addEventObserver(function(e){e===on.a.FullSyncCompleted&&i.reload()}),i}return y(n,[{key:"deinit",value:function(){var e,t;null===(e=this.removeItemObserver)||void 0===e||e.call(this),null===(t=this.removeSyncObserver)||void 0===t||t.call(this),this.singletonManager=void 0,this.itemManager=void 0,p(f(n.prototype),"deinit",this).call(this)}},{key:"handleApplicationStage",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(p(f(n.prototype),"handleApplicationStage",this).call(this,e));case 2:e===ve.LoadedDatabase_12&&(this.preferences=this.singletonManager.findSingleton(z.singletonPredicate),this.preferences&&this.notifyEvent("preferencesChanged"));case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){var n,r;return null!==(n=null===(r=this.preferences)||void 0===r?void 0:r.getPref(e))&&void 0!==n?n:t}},{key:"setValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(this.preferences){n.next=2;break}return n.abrupt("return");case 2:return n.next=4,b.awrap(this.itemManager.changeItem(this.preferences.uuid,function(n){n.setPref(e,t)}));case 4:this.preferences=n.sent,this.notifyEvent("preferencesChanged"),this.syncService.sync();case 7:case"end":return n.stop()}},null,this,null,Promise)}},{key:"reload",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(this.shouldReload&&!this.reloading){t.next=2;break}return t.abrupt("return");case 2:return this.reloading=!0,t.prev=3,e=this.preferences,t.next=7,b.awrap(this.singletonManager.findOrCreateSingleton(z.singletonPredicate,F.a.UserPrefs,Object(Ke.a)({})));case 7:this.preferences=t.sent,((null===e||void 0===e?void 0:e.uuid)!==this.preferences.uuid||this.preferences.userModifiedDate>e.userModifiedDate)&&this.notifyEvent('preferencesChanged'),this.shouldReload=!1;case 10:return t.prev=10,this.reloading=!1,t.finish(10);case 13:case"end":return t.stop()}},null,this,[[3,,10,13]],Promise)}}]),n})(R.a),aa=(function(e){d(n,e);var t=k(n);function n(e,r,a){var i;return v(this,n),(i=t.call(this)).settingsService=e,i.crypto=r,i.featuresService=a,i}return y(n,[{key:"saveMfaSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.updateSetting(pr.SettingName.MfaSecret,e,!0));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaActivated",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.settingsService.getSensitiveSetting(pr.SettingName.MfaSecret));case 2:return e=t.sent,t.abrupt("return",null!=e&&0!=e);case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.crypto.generateOtpSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.crypto.totpToken(e,Date.now(),6,30));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(n.t0=null!=t,!n.t0){n.next=7;break}return n.t1=t,n.next=5,b.awrap(this.getOtpToken(e));case 5:n.t2=n.sent,n.t0=n.t1===n.t2;case 7:if(n.t0){n.next=10;break}throw new Error(j.S.IncorrectMfa);case 10:return n.abrupt("return",this.saveMfaSetting(e));case 11:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.settingsService.deleteSetting(pr.SettingName.MfaSecret));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){var e,t=this.featuresService.getFeature(L.FeatureIdentifier.TwoFactorAuth);return void 0!=t&&(!0===t.no_expire||(null!==(e=t.expires_at)&&void 0!==e?e:0)>Date.now())}},{key:"deinit",value:function(){this.settingsService=void 0,this.crypto=void 0,this.featuresService=void 0,p(f(n.prototype),"deinit",this).call(this)}}]),n})(R.a);function ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(n),!0).forEach(function(t){oa(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=(function(){function e(t,n,r,a,i,s,o,c,u){v(this,e);var l=arguments.length>9&&void 0!==arguments[9]&&arguments[9],p=arguments.length>10?arguments[10]:void 0;if(this.environment=t,this.platform=n,this.deviceInterface=r,this.crypto=a,this.alertService=i,this.identifier=s,this.swapClasses=o,this.defaultHost=c,this.appVersion=u,this.enableV4=l,this.webSocketUrl=p,this.eventHandlers=[],this.services=[],this.streamRemovers=[],this.serviceObservers=[],this.managedSubscribers=[],this.createdNewDatabase=!1,this.started=!1,this.launched=!1,this.dealloced=!1,this.revokingSession=!1,this.handledFullSyncStage=!1,!we.a.onLog)throw Error('SNLog.onLog must be set.');if(!we.a.onError)throw Error('SNLog.onError must be set.');if(!r)throw Error('Device Interface must be supplied.');if(!t)throw Error('Environment must be supplied when creating an application.');if(!n)throw Error('Platform must be supplied when creating an application.');if(!a)throw Error('Crypto has to be supplied when creating an application.');if(!i)throw Error('AlertService must be supplied when creating an application.');if(!s)throw Error('ApplicationIdentifier must be supplied when creating an application.');if(!o)throw Error('SwapClasses array must be supplied when creating an application.');if(!c)throw Error('defaultHost must be supplied when creating an application.');if(!u)throw Error('appVersion must be supplied when creating an application.');this.constructServices()}return y(e,[{key:"prepareForLaunch",value:function(e){var t,n=this;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return this.setLaunchCallback(e),r.next=3,b.awrap(this.deviceInterface.openDatabase(this.identifier).catch(function(e){n.notifyEvent(At.a.LocalDatabaseReadError,e)}));case 3:return t=r.sent,this.createdNewDatabase=(null===t||void 0===t?void 0:t.isNewDatabase)||!1,r.next=7,b.awrap(this.migrationService.initialize());case 7:return r.next=9,b.awrap(this.notifyEvent(At.a.MigrationsLoaded));case 9:return r.next=11,b.awrap(this.handleStage(ve.PreparingForLaunch_0));case 11:return r.next=13,b.awrap(this.storageService.initializeFromDisk());case 13:return r.next=15,b.awrap(this.notifyEvent(At.a.StorageReady));case 15:return r.next=17,b.awrap(this.protocolService.initialize());case 17:return r.next=19,b.awrap(this.handleStage(ve.ReadyForLaunch_05));case 19:return this.started=!0,r.next=22,b.awrap(this.notifyEvent(At.a.Started));case 22:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setLaunchCallback",value:function(e){this.challengeService.sendChallenge=e.receiveChallenge}},{key:"launch",value:function(){var e,t,n,r,a,i=this,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:if(e=s.length>0&&void 0!==s[0]&&s[0],this.launched=!1,!(t=this.getLaunchChallenge())){o.next=11;break}return o.next=6,b.awrap(this.challengeService.promptForChallengeResponse(t));case 6:if(n=o.sent){o.next=9;break}throw Error('Launch challenge was cancelled.');case 9:return o.next=11,b.awrap(this.handleLaunchChallengeResponse(n));case 11:if(!this.storageService.isStorageWrapped()){o.next=20;break}return o.prev=12,o.next=15,b.awrap(this.storageService.decryptStorage());case 15:o.next=20;break;case 17:o.prev=17,o.t0=o.catch(12),this.alertService.alert(j.B.StorageDecryptErrorBody,j.B.StorageDecryptErrorTitle);case 20:return o.next=22,b.awrap(this.handleStage(ve.StorageDecrypted_09));case 22:return o.next=24,b.awrap(this.apiService.loadHost());case 24:return o.next=26,b.awrap(this.webSocketsService.loadWebSocketUrl());case 26:return o.next=28,b.awrap(this.sessionManager.initializeFromDisk());case 28:return this.historyManager.initializeFromDisk(),this.settingsService.initializeFromDisk(),o.next=32,b.awrap(this.featuresService.initializeFromDisk());case 32:return this.launched=!0,o.next=35,b.awrap(this.notifyEvent(At.a.Launched));case 35:return o.next=37,b.awrap(this.handleStage(ve.Launched_10));case 37:return o.next=39,b.awrap(this.syncService.getDatabasePayloads());case 39:return r=o.sent,o.next=42,b.awrap(this.handleStage(ve.LoadingDatabase_11));case 42:if(!this.createdNewDatabase){o.next=45;break}return o.next=45,b.awrap(this.syncService.onNewDatabaseCreated());case 45:if(a=this.syncService.loadDatabasePayloads(r).then(function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i.dealloced){e.next=2;break}throw'Application has been destroyed.';case 2:return e.next=4,b.awrap(i.handleStage(ve.LoadedDatabase_12));case 4:return i.beginAutoSyncTimer(),e.next=7,b.awrap(i.syncService.sync({mode:Jr.DownloadFirst}));case 7:case"end":return e.stop()}},null,null,null,Promise)}),!e){o.next=49;break}return o.next=49,b.awrap(a);case 49:case"end":return o.stop()}},null,this,[[12,17]],Promise)}},{key:"onStart",value:function(){}},{key:"onLaunch",value:function(){}},{key:"getLaunchChallenge",value:function(){return this.protectionService.createLaunchChallenge()}},{key:"handleLaunchChallengeResponse",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(!e.challenge.hasPromptForValidationType(te.LocalPasscode)){a.next=9;break}if(n=null===(t=e.artifacts)||void 0===t?void 0:t.wrappingKey){a.next=7;break}return r=e.getValueForType(te.LocalPasscode),a.next=6,b.awrap(this.protocolService.computeWrappingKey(r.value));case 6:n=a.sent;case 7:return a.next=9,b.awrap(this.protocolService.unwrapRootKey(n));case 9:case"end":return a.stop()}},null,this,null,Promise)}},{key:"beginAutoSyncTimer",value:function(){var e=this;this.autoSyncInterval=this.deviceInterface.interval(function(){e.syncService.log('Syncing from autosync'),e.sync()},3e4)}},{key:"handleStage",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:t=S(this.services);case 1:if((n=t()).done){a.next=7;break}return r=n.value,a.next=5,b.awrap(r.handleApplicationStage(e));case 5:a.next=1;break;case 7:case"end":return a.stop()}},null,this,null,Promise)}},{key:"addEventObserver",value:function(e,t){var n=this,r={callback:e,singleEvent:t};return this.eventHandlers.push(r),function(){Object(_.M)(n.eventHandlers,r)}}},{key:"addSingleEventObserver",value:function(e,t){return this.addEventObserver(function(n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:n===e&&t(e);case 1:case"end":return r.stop()}},null,null,null,Promise)},e)}},{key:"notifyEvent",value:function(e,t){var n,r,a;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:e===At.a.Started?this.onStart():e===At.a.Launched&&this.onLaunch(),n=S(this.eventHandlers.slice());case 2:if((r=n()).done){i.next=14;break}if(!(a=r.value).singleEvent||a.singleEvent!==e){i.next=9;break}return i.next=7,b.awrap(a.callback(e,t||{}));case 7:i.next=12;break;case 9:if(a.singleEvent){i.next=12;break}return i.next=12,b.awrap(a.callback(e,t||{}));case 12:i.next=2;break;case 14:this.migrationService.handleApplicationEvent(e);case 15:case"end":return i.stop()}},null,this,null,Promise)}},{key:"isDatabaseLoaded",value:function(){return this.syncService.isDatabaseLoaded()}},{key:"savePayload",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return t=Object(Ee.b)(e,{dirty:!0,dirtiedDate:new Date}),n.next=3,b.awrap(this.payloadManager.emitPayload(t,ht.a.LocalChanged));case 3:return n.next=5,b.awrap(this.syncService.sync());case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"findItem",value:function(e){return this.itemManager.findItem(e)}},{key:"allItems",value:function(){return this.itemManager.items}},{key:"findItems",value:function(e){return this.itemManager.itemsMatchingPredicate(e)}},{key:"getAll",value:function(e){return this.itemManager.findItems(e)}},{key:"mergeItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.emitItemFromPayload(e.payloadRepresentation(),t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createManagedItem",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=a.length>3?a[3]:void 0,i.abrupt("return",this.itemManager.createItem(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"createTemplateItem",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.itemManager.createTemplateItem(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"createItemFromPayload",value:function(e){return nt(e)}},{key:"createPayloadFromObject",value:function(e){return Object(Ee.e)(e)}},{key:"getLastSyncDate",value:function(){return this.syncService.getLastSyncDate()}},{key:"getSyncStatus",value:function(){return this.syncService.getStatus()}},{key:"getSessions",value:function(){return this.sessionManager.getSessionsList()}},{key:"revokeSession",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.protectionService.authorizeSessionRevoking());case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.sessionManager.revokeSession(e));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"revokeAllOtherSessions",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.sessionManager.revokeAllOtherSessions());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"userCanManageSessions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.getUserVersion());case 2:if(e=t.sent,!Object(_.w)(e)){t.next=5;break}return t.abrupt("return",!1);case 5:return t.abrupt("return",Object(Q.b)(e,Q.a.V004)>=0);case 6:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUserSubscription",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.sessionManager.getSubscription());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data.subscription);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getAvailableSubscriptions",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.getAvailableSubscriptions());case 2:if(!(e=t.sent).error){t.next=5;break}throw new Error(e.error.message);case 5:if(!e.data){t.next=7;break}return t.abrupt("return",e.data);case 7:return t.abrupt("return",void 0);case 8:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setItemNeedsSync",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]&&n[1],r.abrupt("return",this.itemManager.setItemDirty(e.uuid,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"setItemsNeedsSync",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.setItemsDirty(Object(Ke.b)(e)));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"deleteItem",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.setItemToBeDeleted(e.uuid));case 2:return t.next=4,b.awrap(this.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"emptyTrash",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.itemManager.emptyTrash());case 2:return e.next=4,b.awrap(this.sync());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getTrashedItems",value:function(){return this.itemManager.trashedItems}},{key:"setDisplayOptions",value:function(e,t,n,r){this.itemManager.setDisplayOptions(e,t,n,r)}},{key:"setNotesDisplayCriteria",value:function(e){this.itemManager.setNotesDisplayCriteria(e)}},{key:"getDisplayableItems",value:function(e){return this.itemManager.getDisplayableItems(e)}},{key:"insertItem",value:function(e){var t,n,r;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return t=de(e,T.c.UserInteraction),n=t.getResult(),a.next=4,b.awrap(this.itemManager.emitItemFromPayload(n));case 4:return r=a.sent,a.abrupt("return",r);case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"saveItem",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:if(t=this.itemManager.findItem(e)){n.next=3;break}throw Error('Attempting to save non-inserted item');case 3:if(t.dirty){n.next=6;break}return n.next=6,b.awrap(this.itemManager.changeItem(e,void 0,T.c.Internal));case 6:return n.next=8,b.awrap(this.syncService.sync());case 8:case"end":return n.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItem",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,Object(_.A)(e)){s.next=5;break}throw Error('Must use uuid to change item');case 5:return s.next=7,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0,r));case 7:return s.next=9,b.awrap(this.syncService.sync(a));case 9:return s.abrupt("return",this.findItem(e));case 10:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeAndSaveItems",value:function(e,t){var n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return n=!(i.length>2&&void 0!==i[2])||i[2],r=i.length>3?i[3]:void 0,a=i.length>4?i[4]:void 0,s.next=5,b.awrap(this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0,r));case 5:return s.next=7,b.awrap(this.syncService.sync(a));case 7:case"end":return s.stop()}},null,this,null,Promise)}},{key:"changeItem",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:if(n=!(r.length>2&&void 0!==r[2])||r[2],Object(_.A)(e)){a.next=3;break}throw Error('Must use uuid to change item');case 3:return a.next=5,b.awrap(this.itemManager.changeItems([e],t,n?T.c.UserInteraction:void 0));case 5:return a.abrupt("return",this.findItem(e));case 6:case"end":return a.stop()}},null,this,null,Promise)}},{key:"changeItems",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=!(r.length>2&&void 0!==r[2])||r[2],a.abrupt("return",this.itemManager.changeItems(e,t,n?T.c.UserInteraction:void 0));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"protectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNote(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNote",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNote(e));case 2:return t=n.sent,Object(_.w)(t)||this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"authorizeProtectedActionForNotes",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.authorizeProtectedActionForNotes(e,t));case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}},null,this,null,Promise)}},{key:"protectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.protectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unprotectNotes",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.protectionService.unprotectNotes(e));case 2:return t=n.sent,this.syncService.sync(),n.abrupt("return",t);case 5:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getItems",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.itemManager.getItems(e,t)}},{key:"notesMatchingSmartTag",value:function(e){return this.itemManager.notesMatchingSmartTag(e)}},{key:"referencesForItem",value:function(e,t){var n=this.itemManager.referencesForItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"referencingForItem",value:function(e,t){var n=this.itemManager.itemsReferencingItem(e.uuid);return t&&(n=n.filter(function(e){return(null===e||void 0===e?void 0:e.content_type)===t})),n}},{key:"duplicateItem",value:function(e,t){var n=this.itemManager.duplicateItem(e.uuid,!1,t);return this.sync(),n}},{key:"findTagByTitle",value:function(e){return this.itemManager.findTagByTitle(e)}},{key:"searchTags",value:function(e,t){return this.itemManager.searchTags(e,t)}},{key:"isValidTagParent",value:function(e,t){return this.itemManager.isValidTagParent(e,t)}},{key:"setTagParent",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.itemManager.setTagParent(e,t));case 2:case"end":return n.stop()}},null,this,null,Promise)}},{key:"unsetTagParent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.itemManager.unsetTagParent(e));case 2:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getTagParent",value:function(e){return this.itemManager.getTagParent(e.uuid)}},{key:"getTagParentChain",value:function(e){return this.itemManager.getTagParentChain(e.uuid)}},{key:"getTagChildren",value:function(e){return this.itemManager.getTagChildren(e.uuid)}},{key:"getSortedTagsForNote",value:function(e){return this.itemManager.getSortedTagsForNote(e)}},{key:"findOrCreateTag",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.itemManager.findOrCreateTagByTitle(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSmartTags",value:function(){return this.itemManager.getSmartTags()}},{key:"getNoteCount",value:function(){return this.itemManager.noteCount}},{key:"streamItems",value:function(e,t){var n=this,r=this.itemManager.addObserver(e,function(e,n,r,a,i){var s=e.concat(n).concat(r);t(s,i)}),a=this.itemManager.getItems(e);return a.length>0&&t(a),this.streamRemovers.push(r),function(){r(),Object(_.M)(n.streamRemovers,r)}}},{key:"toggleComponent",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.componentManager.toggleComponent(e));case 2:return t.next=4,b.awrap(this.syncService.sync());case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"setHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.apiService.setHost(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getHost",value:function(){return this.apiService.getHost()}},{key:"setCustomHost",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.apiService.setHost(e));case 2:return t.next=4,b.awrap(this.webSocketsService.setWebSocketUrl(void 0));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getUser",value:function(){if(!this.launched)throw Error('Attempting to access user before application unlocked');return this.sessionManager.getUser()}},{key:"getUserPasswordCreationDate",value:function(){return this.protocolService.getPasswordCreatedDate()}},{key:"getProtocolEncryptionDisplayName",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.getEncryptionDisplayName());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getUserVersion",value:function(){return this.protocolService.getUserVersion()}},{key:"protocolUpgradeAvailable",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.protocolService.upgradeAvailable());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isEncryptionAvailable",value:function(){return this.hasAccount()||this.hasPasscode()}},{key:"upgradeProtocolVersion",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.credentialService.performProtocolUpgrade());case 2:return(e=t.sent).success?this.hasAccount()?this.alertService.alert(j.N.SuccessAccount):this.alertService.alert(j.N.SuccessPasscodeOnly):e.error&&this.alertService.alert(j.N.Fail),t.abrupt("return",e);case 5:case"end":return t.stop()}},null,this,null,Promise)}},{key:"noAccount",value:function(){return!this.hasAccount()}},{key:"hasAccount",value:function(){return this.protocolService.hasAccount()}},{key:"hasProtectionSources",value:function(){return this.protectionService.hasProtectionSources()}},{key:"areProtectionsEnabled",value:function(){return this.protectionService.areProtectionsEnabled()}},{key:"getProtectionSessionExpiryDate",value:function(){return this.protectionService.getSessionExpiryDate()}},{key:"clearProtectionSession",value:function(){return this.protectionService.clearSession()}},{key:"authorizeNoteAccess",value:function(e){return this.protectionService.authorizeNoteAccess(e)}},{key:"authorizeAutolockIntervalChange",value:function(){return this.protectionService.authorizeAutolockIntervalChange()}},{key:"authorizeCloudLinkAccess",value:function(){return this.protectionService.authorizeCloudLinkAccess()}},{key:"authorizeSearchingProtectedNotesText",value:function(){return this.protectionService.authorizeSearchingProtectedNotesText()}},{key:"importData",value:function(e){var t,n,r,a,i,s,o,c,u,l,p,d=arguments;return b.async(function(h){for(;;)switch(h.prev=h.next){case 0:if(t=d.length>1&&void 0!==d[1]&&d[1],!e.version){h.next=11;break}if(n=e.version,this.protocolService.supportedVersions().includes(n)){h.next=6;break}return h.abrupt("return",{error:j.V});case 6:return h.next=8,b.awrap(this.getUserVersion());case 8:if(!(r=h.sent)||1!==Object(Q.b)(n,r)){h.next=11;break}return h.abrupt("return",{error:j.u});case 11:if(!e.auth_params&&!e.keyParams){h.next=20;break}return i=new ye([new ge(te.None,j.F.FileAccountPassword,void 0,!0)],ne.DecryptEncryptedFile,!0),h.next=15,b.awrap(this.challengeService.promptForChallengeResponse(i));case 15:if(s=h.sent,!Object(_.w)(s)){h.next=18;break}return h.abrupt("return");case 18:this.challengeService.completeChallenge(i),a=s.values[0].value;case 20:return h.next=22,b.awrap(this.protectionService.authorizeFileImport());case 22:if(h.sent){h.next=24;break}return h.abrupt("return");case 24:return h.next=26,b.awrap(this.protocolService.payloadsByDecryptingBackupFile(e,a));case 26:return o=h.sent,c=o.filter(function(e){return!e.errorDecrypting&&e.format!==ue.a.EncryptedString}).map(function(e){return e.content_type===F.a.Component&&e.safeContent.active?Object(Ee.b)(e,{content:sa(sa({},e.safeContent),{},{active:!1})}):e}),h.next=30,b.awrap(this.payloadManager.importPayloads(c));case 30:if(u=h.sent,l=this.sync(),!t){h.next=35;break}return h.next=35,b.awrap(l);case 35:return p=this.getAll(u),h.abrupt("return",{affectedItems:p,errorCount:o.length-c.length});case 37:case"end":return h.stop()}},null,this,null,Promise)}},{key:"createBackupFile",value:function(e){var t,n,r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(t=i.length>1&&void 0!==i[1]&&i[1],n=e===Re.b.FileEncrypted,r=e===Re.b.FileDecrypted,a=n&&t||r,s.t0=a,!s.t0){s.next=9;break}return s.next=8,b.awrap(this.protectionService.authorizeBackupCreation(n));case 8:s.t0=!s.sent;case 9:if(!s.t0){s.next=11;break}return s.abrupt("return");case 11:return s.abrupt("return",this.protocolService.createBackupFile(e));case 12:case"end":return s.stop()}},null,this,null,Promise)}},{key:"isEphemeralSession",value:function(){return this.storageService.isEphemeralSession()}},{key:"sync",value:function(e){return this.syncService.sync(e)}},{key:"isOutOfSync",value:function(){return this.syncService.isOutOfSync()}},{key:"resolveOutOfSync",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.syncService.resolveOutOfSync());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"setValue",value:function(e,t,n){return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",this.storageService.setValue(e,t,n));case 1:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getValue",value:function(e,t){return this.storageService.getValue(e,t)}},{key:"removeValue",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.storageService.removeValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"getPreference",value:function(e,t){return this.preferencesService.getValue(e,t)}},{key:"setPreference",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.preferencesService.setValue(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"prepareForDeinit",value:function(){var e,t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(e=n.length>0&&void 0!==n[0]?n[0]:0,t=Promise.all(this.services.map(function(e){return e.blockDeinit()})),0!==e){r.next=7;break}return r.next=5,b.awrap(t);case 5:r.next=9;break;case 7:return r.next=9,b.awrap(Promise.race([t,Object(_.P)(e)]));case 9:case"end":return r.stop()}},null,this,null,Promise)}},{key:"promptForCustomChallenge",value:function(e){var t;return null===(t=this.challengeService)||void 0===t?void 0:t.promptForChallengeResponse(e)}},{key:"addChallengeObserver",value:function(e,t){return this.challengeService.addChallengeObserver(e,t)}},{key:"submitValuesForChallenge",value:function(e,t){return this.challengeService.submitValuesForChallenge(e,t)}},{key:"cancelChallenge",value:function(e){this.challengeService.cancelChallenge(e)}},{key:"setOnDeinit",value:function(e){this.onDeinit=e}},{key:"deinit",value:function(e){var t;clearInterval(this.autoSyncInterval);for(var n,r=S(this.serviceObservers);!(n=r()).done;){(0,n.value)()}for(var a,i=S(this.managedSubscribers);!(a=i()).done;){(0,a.value)()}for(var s,o=S(this.services);!(s=o()).done;){s.value.deinit()}null===(t=this.onDeinit)||void 0===t||t.call(this,this,e),this.onDeinit=void 0,this.crypto=void 0,this.createdNewDatabase=!1,this.services.length=0,this.serviceObservers.length=0,this.managedSubscribers.length=0,this.streamRemovers.length=0,this.clearServices(),this.dealloced=!0,this.started=!1}},{key:"register",value:function(e,t){var n,r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return n=a.length>2&&void 0!==a[2]&&a[2],r=!(a.length>3&&void 0!==a[3])||a[3],i.abrupt("return",this.credentialService.register(e,t,n,r));case 3:case"end":return i.stop()}},null,this,null,Promise)}},{key:"signIn",value:function(e,t){var n,r,a,i,s=arguments;return b.async(function(o){for(;;)switch(o.prev=o.next){case 0:return n=s.length>2&&void 0!==s[2]&&s[2],r=s.length>3&&void 0!==s[3]&&s[3],a=!(s.length>4&&void 0!==s[4])||s[4],i=s.length>5&&void 0!==s[5]&&s[5],o.abrupt("return",this.credentialService.signIn(e,t,n,r,a,i));case 5:case"end":return o.stop()}},null,this,null,Promise)}},{key:"changeEmail",value:function(e,t,n){var r,a=arguments;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:A.g.EmailChange,i.abrupt("return",this.credentialService.changeCredentials({currentPassword:t,newEmail:e,passcode:n,origination:r,validateNewPasswordStrength:!1}));case 2:case"end":return i.stop()}},null,this,null,Promise)}},{key:"changePassword",value:function(e,t,n){var r,a,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:return r=i.length>3&&void 0!==i[3]?i[3]:A.g.PasswordChange,a=!(i.length>4&&void 0!==i[4])||i[4],s.abrupt("return",this.credentialService.changeCredentials({currentPassword:e,newPassword:t,passcode:n,origination:r,validateNewPasswordStrength:a}));case 3:case"end":return s.stop()}},null,this,null,Promise)}},{key:"signOut",value:function(){var e,t,n,r,a=this,i=arguments;return b.async(function(s){for(;;)switch(s.prev=s.next){case 0:if(e=i.length>0&&void 0!==i[0]&&i[0],t=function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(a.credentialService.signOut());case 2:return e.next=4,b.awrap(a.notifyEvent(At.a.SignedOut));case 4:return e.next=6,b.awrap(a.prepareForDeinit());case 6:a.deinit(C.SignOut);case 7:case"end":return e.stop()}},null,null,null,Promise)},!e){s.next=6;break}return s.next=5,b.awrap(t());case 5:return s.abrupt("return");case 6:if(!((n=this.itemManager.getDirtyItems()).length>0)){s.next=17;break}return r=1===n.length,s.next=11,b.awrap(this.alertService.confirm("There ".concat(r?'is':'are'," ").concat(n.length," ").concat(r?'item':'items'," with unsynced changes. If you sign out, these changes will be lost forever. Are you sure you want to sign out?")));case 11:if(!s.sent){s.next=15;break}return s.next=15,b.awrap(t());case 15:s.next=19;break;case 17:return s.next=19,b.awrap(t());case 19:case"end":return s.stop()}},null,this,null,Promise)}},{key:"handleRevokedSession",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.revokingSession){t.next=2;break}return t.abrupt("return");case 2:return this.revokingSession=!0,e=this.alertService,t.next=6,b.awrap(this.signOut(!0));case 6:e.alert(j.R.CurrentSessionRevoked);case 7:case"end":return t.stop()}},null,this,null,Promise)}},{key:"validateAccountPassword",value:function(e){var t,n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,b.awrap(this.protocolService.validateAccountPassword(e));case 2:return t=r.sent,n=t.valid,r.abrupt("return",n);case 5:case"end":return r.stop()}},null,this,null,Promise)}},{key:"isStarted",value:function(){return this.started}},{key:"isLaunched",value:function(){return this.launched}},{key:"hasBiometrics",value:function(){return this.protectionService.hasBiometricsEnabled()}},{key:"enableBiometrics",value:function(){return this.protectionService.enableBiometrics()}},{key:"disableBiometrics",value:function(){return this.protectionService.disableBiometrics()}},{key:"hasPasscode",value:function(){return this.protocolService.hasPasscode()}},{key:"isLocked",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.started){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.challengeService.isPasscodeLocked());case 3:case"end":return e.stop()}},null,this,null,Promise)}},{key:"lock",value:function(){var e;return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return e=500,t.next=3,b.awrap(this.prepareForDeinit(e));case 3:return t.abrupt("return",this.deinit(C.Lock));case 4:case"end":return t.stop()}},null,this,null,Promise)}},{key:"addPasscode",value:function(e){return this.credentialService.addPasscode(e)}},{key:"removePasscode",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.credentialService.removePasscode());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"changePasscode",value:function(e){var t,n=arguments;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:return t=n.length>1&&void 0!==n[1]?n[1]:A.g.PasscodeChange,r.abrupt("return",this.credentialService.changePasscode(e,t));case 2:case"end":return r.stop()}},null,this,null,Promise)}},{key:"getStorageEncryptionPolicy",value:function(){return this.storageService.getStorageEncryptionPolicy()}},{key:"setStorageEncryptionPolicy",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(this.storageService.setEncryptionPolicy(e));case 2:return t.abrupt("return",this.protocolService.repersistAllItems());case 3:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableEphemeralPersistencePolicy",value:function(){return this.storageService.setPersistencePolicy(Oe.Ephemeral)}},{key:"hasPendingMigrations",value:function(){return this.migrationService.hasPendingMigrations()}},{key:"generateUuid",value:function(){return I.GenerateUuid()}},{key:"presentKeyRecoveryWizard",value:function(){return this.keyRecoveryService.processPersistedUndecryptables()}},{key:"changeDeviceInterface",value:function(e){this.deviceInterface=e;for(var t,n=S(this.services);!(t=n()).done;){var r=t.value;r.deviceInterface&&(r.deviceInterface=e)}}},{key:"listSettings",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.settingsService.listSettings());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"getSensitiveSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.getSensitiveSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"updateSetting",value:function(e,t){var n,r=arguments;return b.async(function(a){for(;;)switch(a.prev=a.next){case 0:return n=r.length>2&&void 0!==r[2]&&r[2],a.abrupt("return",this.settingsService.updateSetting(e,t,n));case 2:case"end":return a.stop()}},null,this,null,Promise)}},{key:"deleteSetting",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.settingsService.deleteSetting(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"isMfaFeatureAvailable",value:function(){return this.mfaService.isMfaFeatureAvailable()}},{key:"isMfaActivated",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.isMfaActivated());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"generateMfaSecret",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mfaService.generateMfaSecret());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"getOtpToken",value:function(e){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.mfaService.getOtpToken(e));case 1:case"end":return t.stop()}},null,this,null,Promise)}},{key:"enableMfa",value:function(e,t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this.mfaService.enableMfa(e,t));case 1:case"end":return n.stop()}},null,this,null,Promise)}},{key:"disableMfa",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b.awrap(this.protectionService.authorizeMfaDisable());case 2:if(!e.sent){e.next=4;break}return e.abrupt("return",this.mfaService.disableMfa());case 4:case"end":return e.stop()}},null,this,null,Promise)}},{key:"downloadExternalFeature",value:function(e){return this.featuresService.validateAndDownloadExternalFeature(e)}},{key:"getFeature",value:function(e){return this.featuresService.getFeature(e)}},{key:"getFeatureStatus",value:function(e){return this.featuresService.getFeatureStatus(e)}},{key:"getNewSubscriptionToken",value:function(){return this.apiService.getNewSubscriptionToken()}},{key:"setOfflineFeaturesCode",value:function(e){return this.featuresService.setOfflineFeaturesCode(e)}},{key:"hasOfflineRepo",value:function(){return this.featuresService.hasOfflineRepo()}},{key:"deleteOfflineFeatureRepo",value:function(){return b.async(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.featuresService.deleteOfflineFeatureRepo());case 1:case"end":return e.stop()}},null,this,null,Promise)}},{key:"isThirdPartyHostUsed",value:function(){return this.apiService.isThirdPartyHostUsed()}},{key:"constructServices",value:function(){this.createPayloadManager(),this.createItemManager(),this.createStorageManager(),this.createProtocolService();var e={payloadByEncryptingPayload:this.protocolService.payloadByEncryptingPayload.bind(this.protocolService),payloadByDecryptingPayload:this.protocolService.payloadByDecryptingPayload.bind(this.protocolService)};this.storageService.encryptionDelegate=e,this.createChallengeService(),this.createHttpManager(),this.createApiService(),this.createWebSocketsService(),this.createSessionManager(),this.createHistoryManager(),this.createSyncManager(),this.createProtectionService(),this.createCredentialService(),this.createKeyRecoveryService(),this.createSingletonManager(),this.createComponentManager(),this.createActionsManager(),this.createPreferencesService(),this.createSettingsService(),this.createFeaturesService(),this.createMigrationService(),this.createMfaService()}},{key:"clearServices",value:function(){this.migrationService=void 0,this.alertService=void 0,this.httpService=void 0,this.payloadManager=void 0,this.protocolService=void 0,this.storageService=void 0,this.apiService=void 0,this.sessionManager=void 0,this.syncService=void 0,this.challengeService=void 0,this.singletonManager=void 0,this.componentManager=void 0,this.protectionService=void 0,this.actionsManager=void 0,this.historyManager=void 0,this.itemManager=void 0,this.keyRecoveryService=void 0,this.preferencesService=void 0,this.featuresService=void 0,this.credentialService=void 0,this.webSocketsService=void 0,this.settingsService=void 0,this.mfaService=void 0,this.services=[]}},{key:"createFeaturesService",value:function(){var e=this;this.featuresService=new dr(this.storageService,this.apiService,this.itemManager,this.componentManager,this.webSocketsService,this.settingsService,this.credentialService,this.syncService,this.alertService,this.sessionManager,this.crypto),this.serviceObservers.push(this.featuresService.addEventObserver(function(t){switch(t){case cr.UserRolesChanged:e.notifyEvent(At.a.UserRolesChanged);break;case cr.FeaturesUpdated:e.notifyEvent(At.a.FeaturesUpdated);break;default:Object(_.f)(t)}})),this.services.push(this.featuresService)}},{key:"createWebSocketsService",value:function(){this.webSocketsService=new lr(this.storageService,this.webSocketUrl),this.services.push(this.webSocketsService)}},{key:"createMigrationService",value:function(){this.migrationService=new En({protocolService:this.protocolService,deviceInterface:this.deviceInterface,storageService:this.storageService,sessionManager:this.sessionManager,challengeService:this.challengeService,itemManager:this.itemManager,singletonManager:this.singletonManager,featuresService:this.featuresService,environment:this.environment,identifier:this.identifier}),this.services.push(this.migrationService)}},{key:"createCredentialService",value:function(){var e=this;this.credentialService=new Qe(this.sessionManager,this.syncService,this.storageService,this.itemManager,this.protocolService,this.alertService,this.challengeService,this.protectionService),this.serviceObservers.push(this.credentialService.addEventObserver(function(t){switch(t){case Ye.SignedInOrRegistered:e.notifyEvent(At.a.SignedIn);break;default:Object(_.f)(t)}})),this.services.push(this.credentialService)}},{key:"createApiService",value:function(){this.apiService=new Yt(this.httpService,this.storageService,this.defaultHost),this.services.push(this.apiService)}},{key:"createItemManager",value:function(){this.itemManager=new _r(this.payloadManager),this.services.push(this.itemManager)}},{key:"createComponentManager",value:function(){var e=this.getClass(an);this.componentManager=new e(this.itemManager,this.syncService,this.alertService,this.environment,this.platform,this.deviceInterface.timeout),this.services.push(this.componentManager)}},{key:"createHttpManager",value:function(){this.httpService=new jt(this.environment,this.appVersion),this.services.push(this.httpService)}},{key:"createPayloadManager",value:function(){this.payloadManager=new sn,this.services.push(this.payloadManager)}},{key:"createSingletonManager",value:function(){this.singletonManager=new cn(this.itemManager,this.syncService),this.services.push(this.singletonManager)}},{key:"createStorageManager",value:function(){this.storageService=new Ie(this.deviceInterface,this.alertService,this.identifier,this.environment),this.services.push(this.storageService)}},{key:"createProtocolService",value:function(){var e=this;this.protocolService=new Gn(this.itemManager,this.payloadManager,this.deviceInterface,this.storageService,this.identifier,this.crypto),this.protocolService.onKeyStatusChange(function(){return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.notifyEvent(At.a.KeyStatusChanged));case 2:case"end":return t.stop()}},null,null,null,Promise)}),this.services.push(this.protocolService)}},{key:"createKeyRecoveryService",value:function(){this.keyRecoveryService=new Mt(this.itemManager,this.payloadManager,this.apiService,this.protocolService,this.challengeService,this.alertService,this.storageService,this.syncService,this.credentialService),this.services.push(this.keyRecoveryService)}},{key:"createSessionManager",value:function(){var e=this;this.sessionManager=new Ge(this.storageService,this.apiService,this.alertService,this.protocolService,this.challengeService,this.webSocketsService),this.serviceObservers.push(this.sessionManager.addEventObserver(function(t){return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=t,n.next=n.t0===ze.Restored?3:n.t0===ze.Revoked?5:8;break;case 3:return b.async(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b.awrap(e.sync());case 2:e.protocolService.needsNewRootKeyBasedItemsKey()&&e.protocolService.createNewDefaultItemsKey().then(function(){e.sync()});case 3:case"end":return t.stop()}},null,null,null,Promise),n.abrupt("break",9);case 5:return n.next=7,b.awrap(e.handleRevokedSession());case 7:return n.abrupt("break",9);case 8:Object(_.f)(t);case 9:case"end":return n.stop()}},null,null,null,Promise)})),this.services.push(this.sessionManager)}},{key:"createSyncManager",value:function(){var e=this;this.syncService=new ea(this.itemManager,this.sessionManager,this.protocolService,this.storageService,this.payloadManager,this.apiService,this.historyManager,this.deviceInterface.interval);var t=this.syncService.addEventObserver(function(t){var n;return b.async(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(n=Object(At.c)(t))){r.next=9;break}return r.next=4,b.awrap(e.notifyEvent(n));case 4:if(n!==At.a.CompletedFullSync){r.next=9;break}if(e.handledFullSyncStage){r.next=9;break}return e.handledFullSyncStage=!0,r.next=9,b.awrap(e.handleStage(ve.FullSyncCompleted_13));case 9:return r.next=11,b.awrap(e.protocolService.onSyncEvent(t));case 11:case"end":return r.stop()}},null,null,null,Promise)});this.serviceObservers.push(t),this.services.push(this.syncService)}},{key:"createChallengeService",value:function(){this.challengeService=new na(this.storageService,this.protocolService),this.services.push(this.challengeService)}},{key:"createProtectionService",value:function(){var e=this;this.protectionService=new ir(this.protocolService,this.challengeService,this.storageService,this.itemManager),this.serviceObservers.push(this.protectionService.addEventObserver(function(t){t===Zn.SessionExpiryDateChanged&&e.notifyEvent(At.a.ProtectionSessionExpiryDateChanged)})),this.services.push(this.protectionService)}},{key:"createHistoryManager",value:function(){this.historyManager=new nr(this.itemManager,this.storageService,this.apiService,this.protocolService,this.deviceInterface),this.services.push(this.historyManager)}},{key:"createActionsManager",value:function(){this.actionsManager=new hn(this.itemManager,this.alertService,this.deviceInterface,this.httpService,this.payloadManager,this.protocolService,this.syncService),this.services.push(this.actionsManager)}},{key:"createPreferencesService",value:function(){var e=this;this.preferencesService=new ra(this.singletonManager,this.itemManager,this.syncService),this.serviceObservers.push(this.preferencesService.addEventObserver(function(){e.notifyEvent(At.a.PreferencesChanged)})),this.services.push(this.preferencesService)}},{key:"createSettingsService",value:function(){this.settingsService=new hr.SNSettingsService(this.sessionManager,this.apiService),this.services.push(this.settingsService)}},{key:"createMfaService",value:function(){this.mfaService=new aa(this.settingsService,this.crypto,this.featuresService),this.services.push(this.mfaService)}},{key:"getClass",value:function(e){var t=this.swapClasses.find(function(t){return t.swap===e});return t?t.with:e}}]),e})(),ua=(function(){function e(t,n){v(this,e),this.timeout=t||setTimeout.bind(Object(_.r)()),this.interval=n||setInterval.bind(Object(_.r)())}return y(e,[{key:"deinit",value:function(){this.timeout=void 0,this.interval=void 0}},{key:"getJsonParsedRawStorageValue",value:function(e){var t;return b.async(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,b.awrap(this.getRawStorageValue(e));case 2:if(t=n.sent,!Object(_.w)(t)){n.next=5;break}return n.abrupt("return",void 0);case 5:return n.prev=5,n.abrupt("return",JSON.parse(t));case 9:return n.prev=9,n.t0=n.catch(5),n.abrupt("return",t);case 12:case"end":return n.stop()}},null,this,[[5,9]],Promise)}}]),e})(),la=(function(){function e(t,n,r){var a=this;v(this,e),this.item=n.findItem(t),r&&r(this.item),this.removeObserver=n.streamItems(this.item.content_type,function(e){var n;return b.async(function(i){for(;;)switch(i.prev=i.next){case 0:(n=e.find(function(e){return e.uuid===t}))&&(a.item=n,r&&r(a.item));case 2:case"end":return i.stop()}},null,null,null,Promise)})}return y(e,[{key:"deinit",value:function(){this.removeObserver?(this.removeObserver(),this.removeObserver=void 0):console.error('A LiveItem is attempting to be deinited more than once.')}}]),e})(),pa=n(95)}])},'object'==typeof i&&'object'==typeof a?a.exports=c():'function'==typeof define&&define.amd?define("SNLibrary",[],c):'object'==typeof i?i.SNLibrary=c():o.SNLibrary=c()},443,[12,35,22,9,11,13,7,8,249,43,279,6]);^~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:552:188: warning: the variable "atob" was not declared in function "t 63#"__d(function(g,r,i,a,m,e,d){var n,t,o,u,f=r(d[0]);n='undefined'!=typeof self?self:'undefined'!=typeof window?window:void 0!==g?g:this,t=function(){'use strict';var n,t='function'==typeof atob,o='function'==typeof btoa,u='function'==typeof Buffer,c='function'==typeof TextDecoder?new TextDecoder:void 0,s='function'==typeof TextEncoder?new TextEncoder:void 0,h=f('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='),l=(n={},h.forEach(function(t,o){return n[t]=o}),n),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,A=String.fromCharCode.bind(String),p='function'==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n};return new Uint8Array(Array.prototype.slice.call(n,0).map(t))},b=function(n){return n.replace(/[+\/]/g,function(n){return'+'==n?'-':'_'}).replace(/=+$/m,'')},B=function(n){return n.replace(/[^A-Za-z0-9\+\/]/g,'')},x=function(n){for(var t,o,u,f,c='',s=n.length%3,l=0;l<n.length;){if((o=n.charCodeAt(l++))>255||(u=n.charCodeAt(l++))>255||(f=n.charCodeAt(l++))>255)throw new TypeError('invalid character found');c+=h[(t=o<<16|u<<8|f)>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}return s?c.slice(0,s-3)+"===".substring(s):c},C=o?function(n){return btoa(n)}:u?function(n){return Buffer.from(n,'binary').toString('base64')}:x,v=u?function(n){return Buffer.from(n).toString('base64')}:function(n){for(var t=[],o=0,u=n.length;o<u;o+=4096)t.push(A.apply(null,n.subarray(o,o+4096)));return C(t.join(''))},U=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(v(n)):v(n)},F=function(n){if(n.length<2)return(t=n.charCodeAt(0))<128?n:t<2048?A(192|t>>>6)+A(128|63&t):A(224|t>>>12&15)+A(128|t>>>6&63)+A(128|63&t);var t=65536+1024*(n.charCodeAt(0)-55296)+(n.charCodeAt(1)-56320);return A(240|t>>>18&7)+A(128|t>>>12&63)+A(128|t>>>6&63)+A(128|63&t)},w=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=function(n){return n.replace(w,F)},E=u?function(n){return Buffer.from(n,'utf8').toString('base64')}:s?function(n){return v(s.encode(n))}:function(n){return C(S(n))},D=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(E(n)):E(n)},R=function(n){return D(n,!0)},T=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,j=function(n){switch(n.length){case 4:var t=((7&n.charCodeAt(0))<<18|(63&n.charCodeAt(1))<<12|(63&n.charCodeAt(2))<<6|63&n.charCodeAt(3))-65536;return A(55296+(t>>>10))+A(56320+(1023&t));case 3:return A((15&n.charCodeAt(0))<<12|(63&n.charCodeAt(1))<<6|63&n.charCodeAt(2));default:return A((31&n.charCodeAt(0))<<6|63&n.charCodeAt(1))}},z=function(n){return n.replace(T,j)},I=function(n){if(n=n.replace(/\s+/g,''),!y.test(n))throw new TypeError('malformed base64.');n+='=='.slice(2-(3&n.length));for(var t,o,u,f='',c=0;c<n.length;)t=l[n.charAt(c++)]<<18|l[n.charAt(c++)]<<12|(o=l[n.charAt(c++)])<<6|(u=l[n.charAt(c++)]),f+=64===o?A(t>>16&255):64===u?A(t>>16&255,t>>8&255):A(t>>16&255,t>>8&255,255&t);return f},O=t?function(n){return atob(B(n))}:u?function(n){return Buffer.from(n,'base64').toString('binary')}:I,P=u?function(n){return p(Buffer.from(n,'base64'))}:function(n){return p(O(n),function(n){return n.charCodeAt(0)})},Z=function(n){return P(_(n))},L=u?function(n){return Buffer.from(n,'base64').toString('utf8')}:c?function(n){return c.decode(P(n))}:function(n){return z(O(n))},_=function(n){return B(n.replace(/[-_]/g,function(n){return'-'==n?'+':'/'}))},k=function(n){return L(_(n))},M=function(n){return{value:n,enumerable:!1,writable:!0,configurable:!0}},N=function(){var n=function(n,t){return Object.defineProperty(String.prototype,n,M(t))};n('fromBase64',function(){return k(this)}),n('toBase64',function(n){return D(this,n)}),n('toBase64URI',function(){return D(this,!0)}),n('toBase64URL',function(){return D(this,!0)}),n('toUint8Array',function(){return Z(this)})},V=function(){var n=function(n,t){return Object.defineProperty(Uint8Array.prototype,n,M(t))};n('toBase64',function(n){return U(this,n)}),n('toBase64URI',function(){return U(this,!0)}),n('toBase64URL',function(){return U(this,!0)})},$={version:"3.5.2",VERSION:"3.5.2",atob:O,atobPolyfill:I,btoa:C,btoaPolyfill:x,fromBase64:k,toBase64:D,encode:D,encodeURI:R,encodeURL:R,utob:S,btou:z,decode:k,fromUint8Array:U,toUint8Array:Z,extendString:N,extendUint8Array:V,extendBuiltins:function(){N(),V()},Base64:{}};return Object.keys($).forEach(function(n){return $.Base64[n]=$[n]}),$},'object'==typeof e&&void 0!==m?m.exports=t():'function'==typeof define&&define.amd?define(t):(o=n.Base64,(u=t()).noConflict=function(){return n.Base64=o,u},n.Meteor&&(Base64=u),n.Base64=u)},546,[43]);^~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:552:214: warning: the variable "btoa" was not declared in function "t 63#"__d(function(g,r,i,a,m,e,d){var n,t,o,u,f=r(d[0]);n='undefined'!=typeof self?self:'undefined'!=typeof window?window:void 0!==g?g:this,t=function(){'use strict';var n,t='function'==typeof atob,o='function'==typeof btoa,u='function'==typeof Buffer,c='function'==typeof TextDecoder?new TextDecoder:void 0,s='function'==typeof TextEncoder?new TextEncoder:void 0,h=f('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='),l=(n={},h.forEach(function(t,o){return n[t]=o}),n),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,A=String.fromCharCode.bind(String),p='function'==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n};return new Uint8Array(Array.prototype.slice.call(n,0).map(t))},b=function(n){return n.replace(/[+\/]/g,function(n){return'+'==n?'-':'_'}).replace(/=+$/m,'')},B=function(n){return n.replace(/[^A-Za-z0-9\+\/]/g,'')},x=function(n){for(var t,o,u,f,c='',s=n.length%3,l=0;l<n.length;){if((o=n.charCodeAt(l++))>255||(u=n.charCodeAt(l++))>255||(f=n.charCodeAt(l++))>255)throw new TypeError('invalid character found');c+=h[(t=o<<16|u<<8|f)>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}return s?c.slice(0,s-3)+"===".substring(s):c},C=o?function(n){return btoa(n)}:u?function(n){return Buffer.from(n,'binary').toString('base64')}:x,v=u?function(n){return Buffer.from(n).toString('base64')}:function(n){for(var t=[],o=0,u=n.length;o<u;o+=4096)t.push(A.apply(null,n.subarray(o,o+4096)));return C(t.join(''))},U=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(v(n)):v(n)},F=function(n){if(n.length<2)return(t=n.charCodeAt(0))<128?n:t<2048?A(192|t>>>6)+A(128|63&t):A(224|t>>>12&15)+A(128|t>>>6&63)+A(128|63&t);var t=65536+1024*(n.charCodeAt(0)-55296)+(n.charCodeAt(1)-56320);return A(240|t>>>18&7)+A(128|t>>>12&63)+A(128|t>>>6&63)+A(128|63&t)},w=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=function(n){return n.replace(w,F)},E=u?function(n){return Buffer.from(n,'utf8').toString('base64')}:s?function(n){return v(s.encode(n))}:function(n){return C(S(n))},D=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(E(n)):E(n)},R=function(n){return D(n,!0)},T=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,j=function(n){switch(n.length){case 4:var t=((7&n.charCodeAt(0))<<18|(63&n.charCodeAt(1))<<12|(63&n.charCodeAt(2))<<6|63&n.charCodeAt(3))-65536;return A(55296+(t>>>10))+A(56320+(1023&t));case 3:return A((15&n.charCodeAt(0))<<12|(63&n.charCodeAt(1))<<6|63&n.charCodeAt(2));default:return A((31&n.charCodeAt(0))<<6|63&n.charCodeAt(1))}},z=function(n){return n.replace(T,j)},I=function(n){if(n=n.replace(/\s+/g,''),!y.test(n))throw new TypeError('malformed base64.');n+='=='.slice(2-(3&n.length));for(var t,o,u,f='',c=0;c<n.length;)t=l[n.charAt(c++)]<<18|l[n.charAt(c++)]<<12|(o=l[n.charAt(c++)])<<6|(u=l[n.charAt(c++)]),f+=64===o?A(t>>16&255):64===u?A(t>>16&255,t>>8&255):A(t>>16&255,t>>8&255,255&t);return f},O=t?function(n){return atob(B(n))}:u?function(n){return Buffer.from(n,'base64').toString('binary')}:I,P=u?function(n){return p(Buffer.from(n,'base64'))}:function(n){return p(O(n),function(n){return n.charCodeAt(0)})},Z=function(n){return P(_(n))},L=u?function(n){return Buffer.from(n,'base64').toString('utf8')}:c?function(n){return c.decode(P(n))}:function(n){return z(O(n))},_=function(n){return B(n.replace(/[-_]/g,function(n){return'-'==n?'+':'/'}))},k=function(n){return L(_(n))},M=function(n){return{value:n,enumerable:!1,writable:!0,configurable:!0}},N=function(){var n=function(n,t){return Object.defineProperty(String.prototype,n,M(t))};n('fromBase64',function(){return k(this)}),n('toBase64',function(n){return D(this,n)}),n('toBase64URI',function(){return D(this,!0)}),n('toBase64URL',function(){return D(this,!0)}),n('toUint8Array',function(){return Z(this)})},V=function(){var n=function(n,t){return Object.defineProperty(Uint8Array.prototype,n,M(t))};n('toBase64',function(n){return U(this,n)}),n('toBase64URI',function(){return U(this,!0)}),n('toBase64URL',function(){return U(this,!0)})},$={version:"3.5.2",VERSION:"3.5.2",atob:O,atobPolyfill:I,btoa:C,btoaPolyfill:x,fromBase64:k,toBase64:D,encode:D,encodeURI:R,encodeURL:R,utob:S,btou:z,decode:k,fromUint8Array:U,toUint8Array:Z,extendString:N,extendUint8Array:V,extendBuiltins:function(){N(),V()},Base64:{}};return Object.keys($).forEach(function(n){return $.Base64[n]=$[n]}),$},'object'==typeof e&&void 0!==m?m.exports=t():'function'==typeof define&&define.amd?define(t):(o=n.Base64,(u=t()).noConflict=function(){return n.Base64=o,u},n.Meteor&&(Base64=u),n.Base64=u)},546,[43]);^~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:552:240: warning: the variable "Buffer" was not declared in function "t 63#"__d(function(g,r,i,a,m,e,d){var n,t,o,u,f=r(d[0]);n='undefined'!=typeof self?self:'undefined'!=typeof window?window:void 0!==g?g:this,t=function(){'use strict';var n,t='function'==typeof atob,o='function'==typeof btoa,u='function'==typeof Buffer,c='function'==typeof TextDecoder?new TextDecoder:void 0,s='function'==typeof TextEncoder?new TextEncoder:void 0,h=f('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='),l=(n={},h.forEach(function(t,o){return n[t]=o}),n),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,A=String.fromCharCode.bind(String),p='function'==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n};return new Uint8Array(Array.prototype.slice.call(n,0).map(t))},b=function(n){return n.replace(/[+\/]/g,function(n){return'+'==n?'-':'_'}).replace(/=+$/m,'')},B=function(n){return n.replace(/[^A-Za-z0-9\+\/]/g,'')},x=function(n){for(var t,o,u,f,c='',s=n.length%3,l=0;l<n.length;){if((o=n.charCodeAt(l++))>255||(u=n.charCodeAt(l++))>255||(f=n.charCodeAt(l++))>255)throw new TypeError('invalid character found');c+=h[(t=o<<16|u<<8|f)>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}return s?c.slice(0,s-3)+"===".substring(s):c},C=o?function(n){return btoa(n)}:u?function(n){return Buffer.from(n,'binary').toString('base64')}:x,v=u?function(n){return Buffer.from(n).toString('base64')}:function(n){for(var t=[],o=0,u=n.length;o<u;o+=4096)t.push(A.apply(null,n.subarray(o,o+4096)));return C(t.join(''))},U=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(v(n)):v(n)},F=function(n){if(n.length<2)return(t=n.charCodeAt(0))<128?n:t<2048?A(192|t>>>6)+A(128|63&t):A(224|t>>>12&15)+A(128|t>>>6&63)+A(128|63&t);var t=65536+1024*(n.charCodeAt(0)-55296)+(n.charCodeAt(1)-56320);return A(240|t>>>18&7)+A(128|t>>>12&63)+A(128|t>>>6&63)+A(128|63&t)},w=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=function(n){return n.replace(w,F)},E=u?function(n){return Buffer.from(n,'utf8').toString('base64')}:s?function(n){return v(s.encode(n))}:function(n){return C(S(n))},D=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(E(n)):E(n)},R=function(n){return D(n,!0)},T=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,j=function(n){switch(n.length){case 4:var t=((7&n.charCodeAt(0))<<18|(63&n.charCodeAt(1))<<12|(63&n.charCodeAt(2))<<6|63&n.charCodeAt(3))-65536;return A(55296+(t>>>10))+A(56320+(1023&t));case 3:return A((15&n.charCodeAt(0))<<12|(63&n.charCodeAt(1))<<6|63&n.charCodeAt(2));default:return A((31&n.charCodeAt(0))<<6|63&n.charCodeAt(1))}},z=function(n){return n.replace(T,j)},I=function(n){if(n=n.replace(/\s+/g,''),!y.test(n))throw new TypeError('malformed base64.');n+='=='.slice(2-(3&n.length));for(var t,o,u,f='',c=0;c<n.length;)t=l[n.charAt(c++)]<<18|l[n.charAt(c++)]<<12|(o=l[n.charAt(c++)])<<6|(u=l[n.charAt(c++)]),f+=64===o?A(t>>16&255):64===u?A(t>>16&255,t>>8&255):A(t>>16&255,t>>8&255,255&t);return f},O=t?function(n){return atob(B(n))}:u?function(n){return Buffer.from(n,'base64').toString('binary')}:I,P=u?function(n){return p(Buffer.from(n,'base64'))}:function(n){return p(O(n),function(n){return n.charCodeAt(0)})},Z=function(n){return P(_(n))},L=u?function(n){return Buffer.from(n,'base64').toString('utf8')}:c?function(n){return c.decode(P(n))}:function(n){return z(O(n))},_=function(n){return B(n.replace(/[-_]/g,function(n){return'-'==n?'+':'/'}))},k=function(n){return L(_(n))},M=function(n){return{value:n,enumerable:!1,writable:!0,configurable:!0}},N=function(){var n=function(n,t){return Object.defineProperty(String.prototype,n,M(t))};n('fromBase64',function(){return k(this)}),n('toBase64',function(n){return D(this,n)}),n('toBase64URI',function(){return D(this,!0)}),n('toBase64URL',function(){return D(this,!0)}),n('toUint8Array',function(){return Z(this)})},V=function(){var n=function(n,t){return Object.defineProperty(Uint8Array.prototype,n,M(t))};n('toBase64',function(n){return U(this,n)}),n('toBase64URI',function(){return U(this,!0)}),n('toBase64URL',function(){return U(this,!0)})},$={version:"3.5.2",VERSION:"3.5.2",atob:O,atobPolyfill:I,btoa:C,btoaPolyfill:x,fromBase64:k,toBase64:D,encode:D,encodeURI:R,encodeURL:R,utob:S,btou:z,decode:k,fromUint8Array:U,toUint8Array:Z,extendString:N,extendUint8Array:V,extendBuiltins:function(){N(),V()},Base64:{}};return Object.keys($).forEach(function(n){return $.Base64[n]=$[n]}),$},'object'==typeof e&&void 0!==m?m.exports=t():'function'==typeof define&&define.amd?define(t):(o=n.Base64,(u=t()).noConflict=function(){return n.Base64=o,u},n.Meteor&&(Base64=u),n.Base64=u)},546,[43]);^~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:552:268: warning: the variable "TextDecoder" was not declared in function "t 63#"__d(function(g,r,i,a,m,e,d){var n,t,o,u,f=r(d[0]);n='undefined'!=typeof self?self:'undefined'!=typeof window?window:void 0!==g?g:this,t=function(){'use strict';var n,t='function'==typeof atob,o='function'==typeof btoa,u='function'==typeof Buffer,c='function'==typeof TextDecoder?new TextDecoder:void 0,s='function'==typeof TextEncoder?new TextEncoder:void 0,h=f('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='),l=(n={},h.forEach(function(t,o){return n[t]=o}),n),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,A=String.fromCharCode.bind(String),p='function'==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n};return new Uint8Array(Array.prototype.slice.call(n,0).map(t))},b=function(n){return n.replace(/[+\/]/g,function(n){return'+'==n?'-':'_'}).replace(/=+$/m,'')},B=function(n){return n.replace(/[^A-Za-z0-9\+\/]/g,'')},x=function(n){for(var t,o,u,f,c='',s=n.length%3,l=0;l<n.length;){if((o=n.charCodeAt(l++))>255||(u=n.charCodeAt(l++))>255||(f=n.charCodeAt(l++))>255)throw new TypeError('invalid character found');c+=h[(t=o<<16|u<<8|f)>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}return s?c.slice(0,s-3)+"===".substring(s):c},C=o?function(n){return btoa(n)}:u?function(n){return Buffer.from(n,'binary').toString('base64')}:x,v=u?function(n){return Buffer.from(n).toString('base64')}:function(n){for(var t=[],o=0,u=n.length;o<u;o+=4096)t.push(A.apply(null,n.subarray(o,o+4096)));return C(t.join(''))},U=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(v(n)):v(n)},F=function(n){if(n.length<2)return(t=n.charCodeAt(0))<128?n:t<2048?A(192|t>>>6)+A(128|63&t):A(224|t>>>12&15)+A(128|t>>>6&63)+A(128|63&t);var t=65536+1024*(n.charCodeAt(0)-55296)+(n.charCodeAt(1)-56320);return A(240|t>>>18&7)+A(128|t>>>12&63)+A(128|t>>>6&63)+A(128|63&t)},w=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=function(n){return n.replace(w,F)},E=u?function(n){return Buffer.from(n,'utf8').toString('base64')}:s?function(n){return v(s.encode(n))}:function(n){return C(S(n))},D=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(E(n)):E(n)},R=function(n){return D(n,!0)},T=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,j=function(n){switch(n.length){case 4:var t=((7&n.charCodeAt(0))<<18|(63&n.charCodeAt(1))<<12|(63&n.charCodeAt(2))<<6|63&n.charCodeAt(3))-65536;return A(55296+(t>>>10))+A(56320+(1023&t));case 3:return A((15&n.charCodeAt(0))<<12|(63&n.charCodeAt(1))<<6|63&n.charCodeAt(2));default:return A((31&n.charCodeAt(0))<<6|63&n.charCodeAt(1))}},z=function(n){return n.replace(T,j)},I=function(n){if(n=n.replace(/\s+/g,''),!y.test(n))throw new TypeError('malformed base64.');n+='=='.slice(2-(3&n.length));for(var t,o,u,f='',c=0;c<n.length;)t=l[n.charAt(c++)]<<18|l[n.charAt(c++)]<<12|(o=l[n.charAt(c++)])<<6|(u=l[n.charAt(c++)]),f+=64===o?A(t>>16&255):64===u?A(t>>16&255,t>>8&255):A(t>>16&255,t>>8&255,255&t);return f},O=t?function(n){return atob(B(n))}:u?function(n){return Buffer.from(n,'base64').toString('binary')}:I,P=u?function(n){return p(Buffer.from(n,'base64'))}:function(n){return p(O(n),function(n){return n.charCodeAt(0)})},Z=function(n){return P(_(n))},L=u?function(n){return Buffer.from(n,'base64').toString('utf8')}:c?function(n){return c.decode(P(n))}:function(n){return z(O(n))},_=function(n){return B(n.replace(/[-_]/g,function(n){return'-'==n?'+':'/'}))},k=function(n){return L(_(n))},M=function(n){return{value:n,enumerable:!1,writable:!0,configurable:!0}},N=function(){var n=function(n,t){return Object.defineProperty(String.prototype,n,M(t))};n('fromBase64',function(){return k(this)}),n('toBase64',function(n){return D(this,n)}),n('toBase64URI',function(){return D(this,!0)}),n('toBase64URL',function(){return D(this,!0)}),n('toUint8Array',function(){return Z(this)})},V=function(){var n=function(n,t){return Object.defineProperty(Uint8Array.prototype,n,M(t))};n('toBase64',function(n){return U(this,n)}),n('toBase64URI',function(){return U(this,!0)}),n('toBase64URL',function(){return U(this,!0)})},$={version:"3.5.2",VERSION:"3.5.2",atob:O,atobPolyfill:I,btoa:C,btoaPolyfill:x,fromBase64:k,toBase64:D,encode:D,encodeURI:R,encodeURL:R,utob:S,btou:z,decode:k,fromUint8Array:U,toUint8Array:Z,extendString:N,extendUint8Array:V,extendBuiltins:function(){N(),V()},Base64:{}};return Object.keys($).forEach(function(n){return $.Base64[n]=$[n]}),$},'object'==typeof e&&void 0!==m?m.exports=t():'function'==typeof define&&define.amd?define(t):(o=n.Base64,(u=t()).noConflict=function(){return n.Base64=o,u},n.Meteor&&(Base64=u),n.Base64=u)},546,[43]);^~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:552:324: warning: the variable "TextEncoder" was not declared in function "t 63#"__d(function(g,r,i,a,m,e,d){var n,t,o,u,f=r(d[0]);n='undefined'!=typeof self?self:'undefined'!=typeof window?window:void 0!==g?g:this,t=function(){'use strict';var n,t='function'==typeof atob,o='function'==typeof btoa,u='function'==typeof Buffer,c='function'==typeof TextDecoder?new TextDecoder:void 0,s='function'==typeof TextEncoder?new TextEncoder:void 0,h=f('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='),l=(n={},h.forEach(function(t,o){return n[t]=o}),n),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,A=String.fromCharCode.bind(String),p='function'==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n};return new Uint8Array(Array.prototype.slice.call(n,0).map(t))},b=function(n){return n.replace(/[+\/]/g,function(n){return'+'==n?'-':'_'}).replace(/=+$/m,'')},B=function(n){return n.replace(/[^A-Za-z0-9\+\/]/g,'')},x=function(n){for(var t,o,u,f,c='',s=n.length%3,l=0;l<n.length;){if((o=n.charCodeAt(l++))>255||(u=n.charCodeAt(l++))>255||(f=n.charCodeAt(l++))>255)throw new TypeError('invalid character found');c+=h[(t=o<<16|u<<8|f)>>18&63]+h[t>>12&63]+h[t>>6&63]+h[63&t]}return s?c.slice(0,s-3)+"===".substring(s):c},C=o?function(n){return btoa(n)}:u?function(n){return Buffer.from(n,'binary').toString('base64')}:x,v=u?function(n){return Buffer.from(n).toString('base64')}:function(n){for(var t=[],o=0,u=n.length;o<u;o+=4096)t.push(A.apply(null,n.subarray(o,o+4096)));return C(t.join(''))},U=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(v(n)):v(n)},F=function(n){if(n.length<2)return(t=n.charCodeAt(0))<128?n:t<2048?A(192|t>>>6)+A(128|63&t):A(224|t>>>12&15)+A(128|t>>>6&63)+A(128|63&t);var t=65536+1024*(n.charCodeAt(0)-55296)+(n.charCodeAt(1)-56320);return A(240|t>>>18&7)+A(128|t>>>12&63)+A(128|t>>>6&63)+A(128|63&t)},w=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,S=function(n){return n.replace(w,F)},E=u?function(n){return Buffer.from(n,'utf8').toString('base64')}:s?function(n){return v(s.encode(n))}:function(n){return C(S(n))},D=function(n){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?b(E(n)):E(n)},R=function(n){return D(n,!0)},T=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,j=function(n){switch(n.length){case 4:var t=((7&n.charCodeAt(0))<<18|(63&n.charCodeAt(1))<<12|(63&n.charCodeAt(2))<<6|63&n.charCodeAt(3))-65536;return A(55296+(t>>>10))+A(56320+(1023&t));case 3:return A((15&n.charCodeAt(0))<<12|(63&n.charCodeAt(1))<<6|63&n.charCodeAt(2));default:return A((31&n.charCodeAt(0))<<6|63&n.charCodeAt(1))}},z=function(n){return n.replace(T,j)},I=function(n){if(n=n.replace(/\s+/g,''),!y.test(n))throw new TypeError('malformed base64.');n+='=='.slice(2-(3&n.length));for(var t,o,u,f='',c=0;c<n.length;)t=l[n.charAt(c++)]<<18|l[n.charAt(c++)]<<12|(o=l[n.charAt(c++)])<<6|(u=l[n.charAt(c++)]),f+=64===o?A(t>>16&255):64===u?A(t>>16&255,t>>8&255):A(t>>16&255,t>>8&255,255&t);return f},O=t?function(n){return atob(B(n))}:u?function(n){return Buffer.from(n,'base64').toString('binary')}:I,P=u?function(n){return p(Buffer.from(n,'base64'))}:function(n){return p(O(n),function(n){return n.charCodeAt(0)})},Z=function(n){return P(_(n))},L=u?function(n){return Buffer.from(n,'base64').toString('utf8')}:c?function(n){return c.decode(P(n))}:function(n){return z(O(n))},_=function(n){return B(n.replace(/[-_]/g,function(n){return'-'==n?'+':'/'}))},k=function(n){return L(_(n))},M=function(n){return{value:n,enumerable:!1,writable:!0,configurable:!0}},N=function(){var n=function(n,t){return Object.defineProperty(String.prototype,n,M(t))};n('fromBase64',function(){return k(this)}),n('toBase64',function(n){return D(this,n)}),n('toBase64URI',function(){return D(this,!0)}),n('toBase64URL',function(){return D(this,!0)}),n('toUint8Array',function(){return Z(this)})},V=function(){var n=function(n,t){return Object.defineProperty(Uint8Array.prototype,n,M(t))};n('toBase64',function(n){return U(this,n)}),n('toBase64URI',function(){return U(this,!0)}),n('toBase64URL',function(){return U(this,!0)})},$={version:"3.5.2",VERSION:"3.5.2",atob:O,atobPolyfill:I,btoa:C,btoaPolyfill:x,fromBase64:k,toBase64:D,encode:D,encodeURI:R,encodeURL:R,utob:S,btou:z,decode:k,fromUint8Array:U,toUint8Array:Z,extendString:N,extendUint8Array:V,extendBuiltins:function(){N(),V()},Base64:{}};return Object.keys($).forEach(function(n){return $.Base64[n]=$[n]}),$},'object'==typeof e&&void 0!==m?m.exports=t():'function'==typeof define&&define.amd?define(t):(o=n.Base64,(u=t()).noConflict=function(){return n.Base64=o,u},n.Meteor&&(Base64=u),n.Base64=u)},546,[43]);^~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:604:1682: warning: the variable "SC_DISABLE_SPEEDY" was not declared in anonymous function " 4631#"__d(function(e,t,r,n,s,i,o){'use strict';function a(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(i,'__esModule',{value:!0});var u=a(t(o[0])),c=t(o[1]),h=t(o[2]),f=a(h);t(o[3]);var l=a(t(o[4])),p=a(t(o[5])),d=a(t(o[6])),w=a(t(o[7])),m=/(a)(d)/gi,v=52,g=function(e){return String.fromCharCode(e+(e>25?39:97))};function y(e){var t,r='';for(t=Math.abs(e);t>v;t=t/v|0)r=g(t%v)+r;return(g(t%v)+r).replace(m,'$1-$2')}var b=5381,k=function(e,t){for(var r=t.length;r;)e=33*e^t.charCodeAt(--r);return e};function C(e){return e.displayName||e.name||'Component'}function S(e){return'function'==typeof e}var A=function(e){return null!==e&&'object'==typeof e&&'[object Object]'===(e.toString?e.toString():Object.prototype.toString.call(e))&&!c.typeOf(e)};function x(e){return e&&'string'==typeof e.styledComponentId}function E(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 R(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e}function N(){return(N=Object.assign||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}).apply(this,arguments)}function P(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function _(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}var O='undefined'!=typeof process&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||'data-styled',I='undefined'!=typeof window&&'HTMLElement'in window,U=Boolean('boolean'==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:'undefined'!=typeof process&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&''!==process.env.REACT_APP_SC_DISABLE_SPEEDY?'false'!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:'undefined'!=typeof process&&void 0!==process.env.SC_DISABLE_SPEEDY&&''!==process.env.SC_DISABLE_SPEEDY&&('false'!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY)),T=Object.freeze([]),B=Object.freeze({});function j(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw new Error("An error occurred. See https://git.io/JUIaE#"+e+" for more information."+(r.length>0?" Args: "+r.join(', '):''))}var D=512,z=(function(){function e(e){this.groupSizes=new Uint32Array(D),this.length=D,this.tag=e}var t=e.prototype;return t.indexOfGroup=function(e){for(var t=0,r=0;r<e;r++)t+=this.groupSizes[r];return t},t.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var r=this.groupSizes,n=r.length,s=n;e>=s;)(s<<=1)<0&&j(16,""+e);this.groupSizes=new Uint32Array(s),this.groupSizes.set(r),this.length=s;for(var i=n;i<s;i++)this.groupSizes[i]=0}for(var o=this.indexOfGroup(e+1),a=0,u=t.length;a<u;a++)this.tag.insertRule(o,t[a])&&(this.groupSizes[e]++,o++)},t.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],r=this.indexOfGroup(e),n=r+t;this.groupSizes[e]=0;for(var s=r;s<n;s++)this.tag.deleteRule(r)}},t.getGroup=function(e){var t='';if(e>=this.length||0===this.groupSizes[e])return t;for(var r=this.groupSizes[e],n=this.indexOfGroup(e),s=n+r,i=n;i<s;i++)t+=this.tag.getRule(i)+"/*!sc*/\n";return t},e})(),F=new Map,M=new Map,V=1,L=function(e){if(F.has(e))return F.get(e);for(;M.has(V);)V++;var t=V++;return F.set(e,t),M.set(t,e),t},$=function(e){return M.get(e)},Y=function(e,t){F.set(e,t),M.set(t,e)},W="style["+O+"][data-styled-version=\"5.2.1\"]",G=new RegExp("^"+O+"\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"),J=function(e){for(var t=e.getTag(),r=t.length,n='',s=0;s<r;s++){var i=$(s);if(void 0!==i){var o=e.names.get(i),a=t.getGroup(s);if(void 0!==o&&0!==a.length){var u=O+".g"+s+"[id=\""+i+"\"]",c='';void 0!==o&&o.forEach(function(e){e.length>0&&(c+=e+",")}),n+=""+a+u+"{content:\""+c+"\"}/*!sc*/\n"}}}return n},q=function(e,t,r){for(var n,s=r.split(','),i=0,o=s.length;i<o;i++)(n=s[i])&&e.registerName(t,n)},H=function(e,t){for(var r=t.innerHTML.split("/*!sc*/\n"),n=[],s=0,i=r.length;s<i;s++){var o=r[s].trim();if(o){var a=o.match(G);if(a){var u=0|parseInt(a[1],10),c=a[2];0!==u&&(Y(c,u),q(e,c,a[3]),e.getTag().insertRules(u,n)),n.length=0}else n.push(o)}}},Z=function(e){for(var t=document.querySelectorAll(W),r=0,n=t.length;r<n;r++){var s=t[r];s&&"active"!==s.getAttribute(O)&&(H(e,s),s.parentNode&&s.parentNode.removeChild(s))}},K=function(e){for(var t=e.childNodes,r=t.length;r>=0;r--){var n=t[r];if(n&&1===n.nodeType&&n.hasAttribute(O))return n}},Q=function(e){var t=document.head,r=e||t,n=document.createElement('style'),s=K(r),i=void 0!==s?s.nextSibling:null;n.setAttribute(O,"active"),n.setAttribute("data-styled-version","5.2.1");var o='undefined'!=typeof __webpack_nonce__?__webpack_nonce__:null;return o&&n.setAttribute('nonce',o),r.insertBefore(n,i),n},X=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,r=0,n=t.length;r<n;r++){var s=t[r];if(s.ownerNode===e)return s}j(17)},ee=(function(){function e(e){var t=this.element=Q(e);t.appendChild(document.createTextNode('')),this.sheet=X(t),this.length=0}var t=e.prototype;return t.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},t.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},t.getRule=function(e){var t=this.sheet.cssRules[e];return void 0!==t&&'string'==typeof t.cssText?t.cssText:''},e})(),te=(function(){function e(e){var t=this.element=Q(e);this.nodes=t.childNodes,this.length=0}var t=e.prototype;return t.insertRule=function(e,t){if(e<=this.length&&e>=0){var r=document.createTextNode(t),n=this.nodes[e];return this.element.insertBefore(r,n||null),this.length++,!0}return!1},t.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.getRule=function(e){return e<this.length?this.nodes[e].textContent:''},e})(),re=(function(){function e(e){this.rules=[],this.length=0}var t=e.prototype;return t.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},t.deleteRule=function(e){this.rules.splice(e,1),this.length--},t.getRule=function(e){return e<this.length?this.rules[e]:''},e})(),ne=I,se={isServer:!I,useCSSOMInjection:!U},ie=(function(){function e(e,t,r){void 0===e&&(e=B),void 0===t&&(t={}),this.options=N({},se,{},e),this.gs=t,this.names=new Map(r),!this.options.isServer&&I&&ne&&(ne=!1,Z(this))}e.registerId=function(e){return L(e)};var t=e.prototype;return t.reconstructWithOptions=function(t,r){return void 0===r&&(r=!0),new e(N({},this.options,{},t),this.gs,r&&this.names||void 0)},t.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},t.getTag=function(){return this.tag||(this.tag=(t=this.options,r=t.isServer,n=t.useCSSOMInjection,s=t.target,e=r?new re(s):n?new ee(s):new te(s),new z(e)));var e,t,r,n,s},t.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},t.registerName=function(e,t){if(L(e),this.names.has(e))this.names.get(e).add(t);else{var r=new Set;r.add(t),this.names.set(e,r)}},t.insertRules=function(e,t,r){this.registerName(e,t),this.getTag().insertRules(L(e),r)},t.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},t.clearRules=function(e){this.getTag().clearGroup(L(e)),this.clearNames(e)},t.clearTag=function(){this.tag=void 0},t.toString=function(){return J(this)},e})();function oe(e){function t(t){if(t)try{e(t+"}")}catch(e){}}return function(r,n,s,i,o,a,u,c,h,f){switch(r){case 1:if(0===h&&64===n.charCodeAt(0))return e(n+";"),'';break;case 2:if(0===c)return n+"/*|*/";break;case 3:switch(c){case 102:case 112:return e(s[0]+n),'';default:return n+(0===f?"/*|*/":'')}case-2:n.split("/*|*/}").forEach(t)}}}var ae=/^\s*\/\/.*$/gm,ue=[':','[','.','#'];f.createContext().Consumer,f.createContext().Consumer,new ie;var ce=(function(e){var t,r,n,s,i=void 0===e?B:e,o=i.options,a=void 0===o?B:o,u=i.plugins,c=void 0===u?T:u,h=new l(a),f=[],p=oe(function(e){f.push(e)}),d=function(e,n,i){return 0===n&&ue.includes(i[r.length])||i.match(s)?e:"."+t};function w(e,i,o,a){void 0===a&&(a='&');var u=e.replace(ae,''),c=i&&o?o+" "+i+" { "+u+" }":u;return t=a,r=i,n=new RegExp("\\"+r+"\\b",'g'),s=new RegExp("(\\"+r+"\\b){2,}"),h(o||!i?'':i,c)}return h.use([].concat(c,[function(e,t,s){2===e&&s.length&&s[0].lastIndexOf(r)>0&&(s[0]=s[0].replace(n,d))},p,function(e){if(-2===e){var t=f;return f=[],t}}])),w.hash=c.length?c.reduce(function(e,t){return t.name||j(15),k(e,t.name)},b).toString():'',w})(),he=(function(){function e(e,t){var r=this;this.inject=function(e,t){void 0===t&&(t=ce);var n=r.name+t.hash;e.hasNameForId(r.id,n)||e.insertRules(r.id,n,t(r.rules,n,'@keyframes'))},this.toString=function(){return j(12,String(r.name))},this.name=e,this.id="sc-keyframes-"+e,this.rules=t}return e.prototype.getName=function(e){return void 0===e&&(e=ce),this.name+e.hash},e})(),fe=/([A-Z])/,le=/([A-Z])/g,pe=/^ms-/,de=function(e){return"-"+e.toLowerCase()};function we(e){return fe.test(e)?e.replace(le,de).replace(pe,'-ms-'):e}var me=function(e){return void 0===e||null===e||!1===e||''===e},ve=function e(t,r){var n,s,i=[];for(var o in t)t.hasOwnProperty(o)&&!me(t[o])&&(A(t[o])?i.push.apply(i,e(t[o],o)):S(t[o])?i.push(we(o)+":",t[o],';'):i.push(we(o)+": "+(n=o,null==(s=t[o])||'boolean'==typeof s||''===s?'':'number'!=typeof s||0===s||n in p?String(s).trim():s+"px")+";"));return r?[r+" {"].concat(i,['}']):i};function ge(e,t,r,n){if(Array.isArray(e)){for(var s,i=[],o=0,a=e.length;o<a;o+=1)''!==(s=ge(e[o],t,r,n))&&(Array.isArray(s)?i.push.apply(i,s):i.push(s));return i}return me(e)?'':x(e)?"."+e.styledComponentId:S(e)?'function'!=typeof(u=e)||u.prototype&&u.prototype.isReactComponent||!t?e:ge(e(t),t,r,n):e instanceof he?r?(e.inject(r,n),e.getName(n)):e:A(e)?ve(e):e.toString();var u}var ye={};function be(e){ye[e]||(ye[e]=!0,'undefined'!=typeof console&&console.warn&&console.warn(e))}var ke="'".charCodeAt(0),Ce='"'.charCodeAt(0),Se='\\'.charCodeAt(0),Ae='/'.charCodeAt(0),xe='\n'.charCodeAt(0),Ee=' '.charCodeAt(0),Re='\f'.charCodeAt(0),Ne='\t'.charCodeAt(0),Pe='\r'.charCodeAt(0),_e='['.charCodeAt(0),Oe=']'.charCodeAt(0),Ie='('.charCodeAt(0),Ue=')'.charCodeAt(0),Te='{'.charCodeAt(0),Be='}'.charCodeAt(0),je=';'.charCodeAt(0),De='*'.charCodeAt(0),ze=':'.charCodeAt(0),Fe='@'.charCodeAt(0),Me=/[ \n\t\r\f\{\(\)'"\\;/\[\]#]/g,Ve=/[ \n\t\r\f\(\)\{\}:;@!'"\\\]\[#]|\/(?=\*)/g,Le=/.[\\\/\("'\n]/;function $e(e,t){void 0===t&&(t={});var r,n,s,i,o,a,u,c,h,f,l,p,d,w=[],m=e.css.valueOf(),v=t.ignoreErrors,g=m.length,y=-1,b=1,k=0;function C(t){throw e.error("Unclosed "+t,b,k-y)}for(;k<g;){switch(((r=m.charCodeAt(k))===xe||r===Re||r===Pe&&m.charCodeAt(k+1)!==xe)&&(y=k,b+=1),r){case xe:case Ee:case Ne:case Pe:case Re:n=k;do{n+=1,(r=m.charCodeAt(n))===xe&&(y=n,b+=1)}while(r===Ee||r===xe||r===Ne||r===Pe||r===Re);w.push(['space',m.slice(k,n)]),k=n-1;break;case _e:w.push(['[','[',b,k-y]);break;case Oe:w.push([']',']',b,k-y]);break;case Te:w.push(['{','{',b,k-y]);break;case Be:w.push(['}','}',b,k-y]);break;case ze:w.push([':',':',b,k-y]);break;case je:w.push([';',';',b,k-y]);break;case Ie:if(p=w.length?w[w.length-1][1]:'',d=m.charCodeAt(k+1),'url'===p&&d!==ke&&d!==Ce&&d!==Ee&&d!==xe&&d!==Ne&&d!==Re&&d!==Pe){n=k;do{if(f=!1,-1===(n=m.indexOf(')',n+1))){if(v){n=k;break}C('bracket')}for(l=n;m.charCodeAt(l-1)===Se;)l-=1,f=!f}while(f);w.push(['brackets',m.slice(k,n+1),b,k-y,b,n-y]),k=n}else n=m.indexOf(')',k+1),a=m.slice(k,n+1),-1===n||Le.test(a)?w.push(['(','(',b,k-y]):(w.push(['brackets',a,b,k-y,b,n-y]),k=n);break;case Ue:w.push([')',')',b,k-y]);break;case ke:case Ce:s=r===ke?"'":'"',n=k;do{if(f=!1,-1===(n=m.indexOf(s,n+1))){if(v){n=k+1;break}C('quote')}for(l=n;m.charCodeAt(l-1)===Se;)l-=1,f=!f}while(f);(o=(i=(a=m.slice(k,n+1)).split('\n')).length-1)>0?(c=b+o,h=n-i[o].length):(c=b,h=y),w.push(['string',m.slice(k,n+1),b,k-y,c,n-h]),y=h,b=c,k=n;break;case Fe:Me.lastIndex=k+1,Me.test(m),n=0===Me.lastIndex?m.length-1:Me.lastIndex-2,w.push(['at-word',m.slice(k,n+1),b,k-y,b,n-y]),k=n;break;case Se:for(n=k,u=!0;m.charCodeAt(n+1)===Se;)n+=1,u=!u;r=m.charCodeAt(n+1),u&&r!==Ae&&r!==Ee&&r!==xe&&r!==Ne&&r!==Pe&&r!==Re&&(n+=1),w.push(['word',m.slice(k,n+1),b,k-y,b,n-y]),k=n;break;default:r===Ae&&m.charCodeAt(k+1)===De?(0===(n=m.indexOf('*/',k+2)+1)&&(v?n=m.length:C('comment')),(o=(i=(a=m.slice(k,n+1)).split('\n')).length-1)>0?(c=b+o,h=n-i[o].length):(c=b,h=y),w.push(['comment',a,b,k-y,c,n-h]),y=h,b=c,k=n):(Ve.lastIndex=k+1,Ve.test(m),n=0===Ve.lastIndex?m.length-1:Ve.lastIndex-2,w.push(['word',m.slice(k,n+1),b,k-y,b,n-y]),k=n)}k++}return w}var Ye={brackets:[36,39],string:[31,39],'at-word':[31,39],comment:[90,39],'{':[32,39],'}':[32,39],':':[1,22],';':[1,22],'(':[1,22],')':[1,22]};function We(e){return"\x1b["+e+"m"}function Ge(e){var t=[];return $e(new wt(e),{ignoreErrors:!0}).forEach(function(e){var r=Ye[e[0]];r?t.push(e[1].split(/\r?\n/).map(function(e){return We(r[0])+e+We(r[1])}).join('\n')):t.push(e[1])}),t.join('')}var Je=(function(){function e(t,r,n,s,i,o){this.name='CssSyntaxError',this.reason=t,i&&(this.file=i),s&&(this.source=s),o&&(this.plugin=o),void 0!==r&&void 0!==n&&(this.line=r,this.column=n),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}var t=e.prototype;return t.setMessage=function(){this.message=this.plugin?this.plugin+": ":'',this.message+=this.file?this.file:'<css input>',void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},t.showSourceCode=function(e){var t=this;if(!this.source)return'';var r=this.source;void 0===e&&(e=d),e&&(r=Ge(r));var n=r.split(/\r?\n/),s=Math.max(this.line-3,0),i=Math.min(this.line+2,n.length),o=String(i).length;return n.slice(s,i).map(function(e,r){var n=s+1+r,i=" "+(" "+n).slice(-o)+" | ";return n===t.line?">"+i+e+"\n "+(i.replace(/\d/g,' ')+e.slice(0,t.column-1).replace(/[^\t]/g,' '))+"^":" "+i+e}).join('\n')},t.toString=function(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e},R(e,[{key:"generated",get:function(){return be('CssSyntaxError#generated is deprecated. Use input instead.'),this.input}}]),e})(),qe={colon:': ',indent:'    ',beforeDecl:'\n',beforeRule:'\n',beforeOpen:' ',beforeClose:'\n',beforeComment:'\n',after:'\n',emptyBody:'',commentLeft:' ',commentRight:' '};var He=(function(){function e(e){this.builder=e}var t=e.prototype;return t.stringify=function(e,t){this[e.type](e,t)},t.root=function(e){this.body(e),e.raws.after&&this.builder(e.raws.after)},t.comment=function(e){var t=this.raw(e,'left','commentLeft'),r=this.raw(e,'right','commentRight');this.builder("/*"+t+e.text+r+"*/",e)},t.decl=function(e,t){var r=this.raw(e,'between','colon'),n=e.prop+r+this.rawValue(e,'value');e.important&&(n+=e.raws.important||' !important'),t&&(n+=';'),this.builder(n,e)},t.rule=function(e){this.block(e,this.rawValue(e,'selector'))},t.atrule=function(e,t){var r="@"+e.name,n=e.params?this.rawValue(e,'params'):'';if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=' '),e.nodes)this.block(e,r+n);else{var s=(e.raws.between||'')+(t?';':'');this.builder(r+n+s,e)}},t.body=function(e){for(var t=e.nodes.length-1;t>0&&'comment'===e.nodes[t].type;)t-=1;for(var r=this.raw(e,'semicolon'),n=0;n<e.nodes.length;n++){var s=e.nodes[n],i=this.raw(s,'before');i&&this.builder(i),this.stringify(s,t!==n||r)}},t.block=function(e,t){var r,n=this.raw(e,'between','beforeOpen');this.builder(t+n+"{",e,'start'),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,'after')):r=this.raw(e,'after','emptyBody'),r&&this.builder(r),this.builder('}',e,'end')},t.raw=function(e,t,r){var n;if(r||(r=t),t&&void 0!==(n=e.raws[t]))return n;var s=e.parent;if('before'===r&&(!s||'root'===s.type&&s.first===e))return'';if(!s)return qe[r];var i=e.root();if(i.rawCache||(i.rawCache={}),void 0!==i.rawCache[r])return i.rawCache[r];if('before'===r||'after'===r)return this.beforeAfter(e,r);var o,a="raw"+((o=r)[0].toUpperCase()+o.slice(1));return this[a]?n=this[a](i,e):i.walk(function(e){if(void 0!==(n=e.raws[t]))return!1}),void 0===n&&(n=qe[r]),i.rawCache[r]=n,n},t.rawSemicolon=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length&&'decl'===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t},t.rawEmptyBody=function(e){var t;return e.walk(function(e){if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t},t.rawIndent=function(e){return e.raws.indent?e.raws.indent:(e.walk(function(r){var n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){var s=r.raws.before.split('\n');return t=(t=s[s.length-1]).replace(/[^\s]/g,''),!1}}),t);var t},t.rawBeforeComment=function(e,t){var r;return e.walkComments(function(e){if(void 0!==e.raws.before)return-1!==(r=e.raws.before).indexOf('\n')&&(r=r.replace(/[^\n]+$/,'')),!1}),void 0===r&&(r=this.raw(t,null,'beforeDecl')),r},t.rawBeforeDecl=function(e,t){var r;return e.walkDecls(function(e){if(void 0!==e.raws.before)return-1!==(r=e.raws.before).indexOf('\n')&&(r=r.replace(/[^\n]+$/,'')),!1}),void 0===r&&(r=this.raw(t,null,'beforeRule')),r},t.rawBeforeRule=function(e){var t;return e.walk(function(r){if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return-1!==(t=r.raws.before).indexOf('\n')&&(t=t.replace(/[^\n]+$/,'')),!1}),t},t.rawBeforeClose=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return-1!==(t=e.raws.after).indexOf('\n')&&(t=t.replace(/[^\n]+$/,'')),!1}),t},t.rawBeforeOpen=function(e){var t;return e.walk(function(e){if('decl'!==e.type&&void 0!==(t=e.raws.between))return!1}),t},t.rawColon=function(e){var t;return e.walkDecls(function(e){if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,''),!1}),t},t.beforeAfter=function(e,t){var r;r='decl'===e.type?this.raw(e,null,'beforeDecl'):'comment'===e.type?this.raw(e,null,'beforeComment'):'before'===t?this.raw(e,null,'beforeRule'):this.raw(e,null,'beforeClose');for(var n=e.parent,s=0;n&&'root'!==n.type;)s+=1,n=n.parent;if(-1!==r.indexOf('\n')){var i=this.raw(e,null,'indent');if(i.length)for(var o=0;o<s;o++)r+=i}return r},t.rawValue=function(e,t){var r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r},e})();function Ze(e,t){new He(t).stringify(e)}var Ke=function e(t,r){var n=new t.constructor;for(var s in t)if(t.hasOwnProperty(s)){var i=t[s],o=typeof i;'parent'===s&&'object'===o?r&&(n[s]=r):'source'===s?n[s]=i:i instanceof Array?n[s]=i.map(function(t){return e(t,n)}):'before'!==s&&'after'!==s&&'between'!==s&&'semicolon'!==s&&('object'===o&&null!==i&&(i=e(i)),n[s]=i)}return n},Qe=(function(){function e(e){for(var t in void 0===e&&(e={}),this.raws={},e)this[t]=e[t]}var t=e.prototype;return t.error=function(e,t){if(void 0===t&&(t={}),this.source){var r=this.positionBy(t);return this.source.input.error(e,r.line,r.column,t)}return new Je(e)},t.warn=function(e,t,r){var n={node:this};for(var s in r)n[s]=r[s];return e.warn(t,n)},t.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},t.toString=function(e){void 0===e&&(e=Ze),e.stringify&&(e=e.stringify);var t='';return e(this,function(e){t+=e}),t},t.clone=function(e){void 0===e&&(e={});var t=Ke(this);for(var r in e)t[r]=e[r];return t},t.cloneBefore=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t},t.cloneAfter=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t},t.replaceWith=function(){var e=this;if(this.parent){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(function(t){e.parent.insertBefore(e,t)}),this.remove()}return this},t.moveTo=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.append(this),this},t.moveBefore=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.parent.insertBefore(e,this),this},t.moveAfter=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.parent.insertAfter(e,this),this},t.next=function(){var e=this.parent.index(this);return this.parent.nodes[e+1]},t.prev=function(){var e=this.parent.index(this);return this.parent.nodes[e-1]},t.toJSON=function(){var e={};for(var t in this)if(this.hasOwnProperty(t)&&'parent'!==t){var r=this[t];r instanceof Array?e[t]=r.map(function(e){return'object'==typeof e&&e.toJSON?e.toJSON():e}):'object'==typeof r&&r.toJSON?e[t]=r.toJSON():e[t]=r}return e},t.raw=function(e,t){return(new He).raw(this,e,t)},t.root=function(){for(var e=this;e.parent;)e=e.parent;return e},t.cleanRaws=function(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between},t.positionInside=function(e){for(var t=this.toString(),r=this.source.start.column,n=this.source.start.line,s=0;s<e;s++)'\n'===t[s]?(r=1,n+=1):r+=1;return{line:n,column:r}},t.positionBy=function(e){var t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){var r=this.toString().indexOf(e.word);-1!==r&&(t=this.positionInside(r))}return t},t.removeSelf=function(){return be('Node#removeSelf is deprecated. Use Node#remove.'),this.remove()},t.replace=function(e){return be('Node#replace is deprecated. Use Node#replaceWith'),this.replaceWith(e)},t.style=function(e,t){return be('Node#style() is deprecated. Use Node#raw()'),this.raw(e,t)},t.cleanStyles=function(e){return be('Node#cleanStyles() is deprecated. Use Node#cleanRaws()'),this.cleanRaws(e)},R(e,[{key:"before",get:function(){return be('Node#before is deprecated. Use Node#raws.before'),this.raws.before},set:function(e){be('Node#before is deprecated. Use Node#raws.before'),this.raws.before=e}},{key:"between",get:function(){return be('Node#between is deprecated. Use Node#raws.between'),this.raws.between},set:function(e){be('Node#between is deprecated. Use Node#raws.between'),this.raws.between=e}}]),e})(),Xe=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='decl',r}return P(t,e),R(t,[{key:"_value",get:function(){return be('Node#_value was deprecated. Use Node#raws.value'),this.raws.value},set:function(e){be('Node#_value was deprecated. Use Node#raws.value'),this.raws.value=e}},{key:"_important",get:function(){return be('Node#_important was deprecated. Use Node#raws.important'),this.raws.important},set:function(e){be('Node#_important was deprecated. Use Node#raws.important'),this.raws.important=e}}]),t})(Qe),et=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='comment',r}return P(t,e),R(t,[{key:"left",get:function(){return be('Comment#left was deprecated. Use Comment#raws.left'),this.raws.left},set:function(e){be('Comment#left was deprecated. Use Comment#raws.left'),this.raws.left=e}},{key:"right",get:function(){return be('Comment#right was deprecated. Use Comment#raws.right'),this.raws.right},set:function(e){be('Comment#right was deprecated. Use Comment#raws.right'),this.raws.right=e}}]),t})(Qe),tt=(function(){function e(e){this.input=e,this.pos=0,this.root=new pt,this.current=this.root,this.spaces='',this.semicolon=!1,this.root.source={input:e,start:{line:1,column:1}}}var t=e.prototype;return t.tokenize=function(){this.tokens=$e(this.input)},t.loop=function(){for(var e;this.pos<this.tokens.length;){switch((e=this.tokens[this.pos])[0]){case'space':case';':this.spaces+=e[1];break;case'}':this.end(e);break;case'comment':this.comment(e);break;case'at-word':this.atrule(e);break;case'{':this.emptyRule(e);break;default:this.other()}this.pos+=1}this.endFile()},t.comment=function(e){var t=new et;this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]};var r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text='',t.raws.left=r,t.raws.right='';else{var n=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},t.emptyRule=function(e){var t=new at;this.init(t,e[2],e[3]),t.selector='',t.raws.between='',this.current=t},t.other=function(){for(var e,t=!1,r=null,n=!1,s=null,i=[],o=this.pos;this.pos<this.tokens.length;){if('('===(r=(e=this.tokens[this.pos])[0])||'['===r)s||(s=e),i.push('('===r?')':']');else if(0===i.length){if(';'===r){if(n)return void this.decl(this.tokens.slice(o,this.pos+1));break}if('{'===r)return void this.rule(this.tokens.slice(o,this.pos+1));if('}'===r){this.pos-=1,t=!0;break}':'===r&&(n=!0)}else r===i[i.length-1]&&(i.pop(),0===i.length&&(s=null));this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,t=!0),i.length>0&&this.unclosedBracket(s),t&&n){for(;this.pos>o&&('space'===(e=this.tokens[this.pos][0])||'comment'===e);)this.pos-=1;this.decl(this.tokens.slice(o,this.pos+1))}else this.unknownWord(o)},t.rule=function(e){e.pop();var t=new at;this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesFromEnd(e),this.raw(t,'selector',e),this.current=t},t.decl=function(e){var t=new Xe;this.init(t);var r,n=e[e.length-1];for(';'===n[0]&&(this.semicolon=!0,e.pop()),n[4]?t.source.end={line:n[4],column:n[5]}:t.source.end={line:n[2],column:n[3]};'word'!==e[0][0];)t.raws.before+=e.shift()[1];for(t.source.start={line:e[0][2],column:e[0][3]},t.prop='';e.length;){var s=e[0][0];if(':'===s||'space'===s||'comment'===s)break;t.prop+=e.shift()[1]}for(t.raws.between='';e.length;){if(':'===(r=e.shift())[0]){t.raws.between+=r[1];break}t.raws.between+=r[1]}'_'!==t.prop[0]&&'*'!==t.prop[0]||(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesFromStart(e),this.precheckMissedSemicolon(e);for(var i=e.length-1;i>0;i--){if('!important'===(r=e[i])[1]){t.important=!0;var o=this.stringFrom(e,i);' !important'!==(o=this.spacesFromEnd(e)+o)&&(t.raws.important=o);break}if('important'===r[1]){for(var a=e.slice(0),u='',c=i;c>0;c--){var h=a[c][0];if(0===u.trim().indexOf('!')&&'space'!==h)break;u=a.pop()[1]+u}0===u.trim().indexOf('!')&&(t.important=!0,t.raws.important=u,e=a)}if('space'!==r[0]&&'comment'!==r[0])break}this.raw(t,'value',e),-1!==t.value.indexOf(':')&&this.checkMissedSemicolon(e)},t.atrule=function(e){var t=new it;t.name=e[1].slice(1),''===t.name&&this.unnamedAtrule(t,e),this.init(t,e[2],e[3]);var r=!1,n=!1,s=[];for(this.pos+=1;this.pos<this.tokens.length;){if(';'===(e=this.tokens[this.pos])[0]){t.source.end={line:e[2],column:e[3]},this.semicolon=!0;break}if('{'===e[0]){n=!0;break}if('}'===e[0]){this.end(e);break}s.push(e),this.pos+=1}this.pos===this.tokens.length&&(r=!0),t.raws.between=this.spacesFromEnd(s),s.length?(t.raws.afterName=this.spacesFromStart(s),this.raw(t,'params',s),r&&(e=s[s.length-1],t.source.end={line:e[4],column:e[5]},this.spaces=t.raws.between,t.raws.between='')):(t.raws.afterName='',t.params=''),n&&(t.nodes=[],this.current=t)},t.end=function(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||'')+this.spaces,this.spaces='',this.current.parent?(this.current.source.end={line:e[2],column:e[3]},this.current=this.current.parent):this.unexpectedClose(e)},t.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||'')+this.spaces},t.init=function(e,t,r){this.current.push(e),e.source={start:{line:t,column:r},input:this.input},e.raws.before=this.spaces,this.spaces='','comment'!==e.type&&(this.semicolon=!1)},t.raw=function(e,t,r){for(var n,s,i=r.length,o='',a=!0,u=0;u<i;u+=1)'comment'===(s=(n=r[u])[0])||'space'===s&&u===i-1?a=!1:o+=n[1];if(!a){var c=r.reduce(function(e,t){return e+t[1]},'');e.raws[t]={value:o,raw:c}}e[t]=o},t.spacesFromEnd=function(e){for(var t,r='';e.length&&('space'===(t=e[e.length-1][0])||'comment'===t);)r=e.pop()[1]+r;return r},t.spacesFromStart=function(e){for(var t,r='';e.length&&('space'===(t=e[0][0])||'comment'===t);)r+=e.shift()[1];return r},t.stringFrom=function(e,t){for(var r='',n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r},t.colon=function(e){for(var t,r,n,s=0,i=0;i<e.length;i++){if('('===(r=(t=e[i])[0]))s+=1;else if(')'===r)s-=1;else if(0===s&&':'===r){if(n){if('word'===n[0]&&'progid'===n[1])continue;return i}this.doubleColon(t)}n=t}return!1},t.unclosedBracket=function(e){throw this.input.error('Unclosed bracket',e[2],e[3])},t.unknownWord=function(e){var t=this.tokens[e];throw this.input.error('Unknown word',t[2],t[3])},t.unexpectedClose=function(e){throw this.input.error('Unexpected }',e[2],e[3])},t.unclosedBlock=function(){var e=this.current.source.start;throw this.input.error('Unclosed block',e.line,e.column)},t.doubleColon=function(e){throw this.input.error('Double colon',e[2],e[3])},t.unnamedAtrule=function(e,t){throw this.input.error('At-rule without name',t[2],t[3])},t.precheckMissedSemicolon=function(e){},t.checkMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){for(var r,n=0,s=t-1;s>=0&&('space'===(r=e[s])[0]||2!==(n+=1));s--);throw this.input.error('Missed semicolon',r[2],r[3])}},e})();function rt(e,t){if(t&&t.safe)throw new Error("Option safe was removed. Use parser: require(\"postcss-safe-parser\")");var r=new wt(e,t),n=new tt(r);try{n.tokenize(),n.loop()}catch(e){throw'CssSyntaxError'===e.name&&t&&t.from&&(/\.scss$/i.test(t.from)?e.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.less$/i.test(t.from)&&(e.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),e}return n.root}function nt(e){return e.map(function(e){return e.nodes&&(e.nodes=nt(e.nodes)),delete e.source,e})}var st=(function(e){function t(){return e.apply(this,arguments)||this}P(t,e);var r=t.prototype;return r.push=function(e){return e.parent=this,this.nodes.push(e),this},r.each=function(e){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var t=this.lastEach;if(this.indexes[t]=0,this.nodes){for(var r,n;this.indexes[t]<this.nodes.length&&(r=this.indexes[t],!1!==(n=e(this.nodes[r],r)));)this.indexes[t]+=1;return delete this.indexes[t],n}},r.walk=function(e){return this.each(function(t,r){var n=e(t,r);return!1!==n&&t.walk&&(n=t.walk(e)),n})},r.walkDecls=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('decl'===r.type&&e.test(r.prop))return t(r,n)}):this.walk(function(r,n){if('decl'===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('decl'===e.type)return t(e,r)}))},r.walkRules=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('rule'===r.type&&e.test(r.selector))return t(r,n)}):this.walk(function(r,n){if('rule'===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('rule'===e.type)return t(e,r)}))},r.walkAtRules=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('atrule'===r.type&&e.test(r.name))return t(r,n)}):this.walk(function(r,n){if('atrule'===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('atrule'===e.type)return t(e,r)}))},r.walkComments=function(e){return this.walk(function(t,r){if('comment'===t.type)return e(t,r)})},r.append=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach(function(t){e.normalize(t,e.last).forEach(function(t){return e.nodes.push(t)})}),this},r.prepend=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return(r=r.reverse()).forEach(function(t){var r=e.normalize(t,e.first,'prepend').reverse();for(var n in r.forEach(function(t){return e.nodes.unshift(t)}),e.indexes)e.indexes[n]=e.indexes[n]+r.length}),this},r.cleanRaws=function(t){e.prototype.cleanRaws.call(this,t),this.nodes&&this.nodes.forEach(function(e){return e.cleanRaws(t)})},r.insertBefore=function(e,t){var r,n=this,s=0===(e=this.index(e))&&'prepend',i=this.normalize(t,this.nodes[e],s).reverse();for(var o in i.forEach(function(t){return n.nodes.splice(e,0,t)}),this.indexes)r=this.indexes[o],e<=r&&(this.indexes[o]=r+i.length);return this},r.insertAfter=function(e,t){var r=this;e=this.index(e);var n,s=this.normalize(t,this.nodes[e]).reverse();for(var i in s.forEach(function(t){return r.nodes.splice(e+1,0,t)}),this.indexes)n=this.indexes[i],e<n&&(this.indexes[i]=n+s.length);return this},r.remove=function(t){return void 0!==t?(be("Container#remove is deprecated. Use Container#removeChild"),this.removeChild(t)):e.prototype.remove.call(this),this},r.removeChild=function(e){var t;for(var r in e=this.index(e),this.nodes[e].parent=void 0,this.nodes.splice(e,1),this.indexes)(t=this.indexes[r])>=e&&(this.indexes[r]=t-1);return this},r.removeAll=function(){return this.nodes.forEach(function(e){return e.parent=void 0}),this.nodes=[],this},r.replaceValues=function(e,t,r){return r||(r=t,t={}),this.walkDecls(function(n){t.props&&-1===t.props.indexOf(n.prop)||t.fast&&-1===n.value.indexOf(t.fast)||(n.value=n.value.replace(e,r))}),this},r.every=function(e){return this.nodes.every(e)},r.some=function(e){return this.nodes.some(e)},r.index=function(e){return'number'==typeof e?e:this.nodes.indexOf(e)},r.normalize=function(e,t){var r=this;if('string'==typeof e)e=nt(rt(e).nodes);else if(!Array.isArray(e))if('root'===e.type)e=e.nodes;else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error('Value field is missed in node creation');'string'!=typeof e.value&&(e.value=String(e.value)),e=[new Xe(e)]}else if(e.selector)e=[new at(e)];else if(e.name)e=[new it(e)];else{if(!e.text)throw new Error('Unknown node type in node creation');e=[new et(e)]}return e.map(function(e){return void 0===e.raws&&(e=r.rebuild(e)),e.parent&&(e=e.clone()),void 0===e.raws.before&&t&&void 0!==t.raws.before&&(e.raws.before=t.raws.before.replace(/[^\s]/g,'')),e.parent=r,e})},r.rebuild=function(e,t){var r,n=this;for(var s in'root'===e.type?r=new pt:'atrule'===e.type?r=new it:'rule'===e.type?r=new at:'decl'===e.type?r=new Xe:'comment'===e.type&&(r=new et),e)'nodes'===s?r.nodes=e.nodes.map(function(e){return n.rebuild(e,r)}):'parent'===s&&t?r.parent=t:e.hasOwnProperty(s)&&(r[s]=e[s]);return r},r.eachInside=function(e){return be("Container#eachInside is deprecated. Use Container#walk instead."),this.walk(e)},r.eachDecl=function(e,t){return be("Container#eachDecl is deprecated. Use Container#walkDecls instead."),this.walkDecls(e,t)},r.eachRule=function(e,t){return be("Container#eachRule is deprecated. Use Container#walkRules instead."),this.walkRules(e,t)},r.eachAtRule=function(e,t){return be("Container#eachAtRule is deprecated. Use Container#walkAtRules instead."),this.walkAtRules(e,t)},r.eachComment=function(e){return be("Container#eachComment is deprecated. Use Container#walkComments instead."),this.walkComments(e)},R(t,[{key:"first",get:function(){if(this.nodes)return this.nodes[0]}},{key:"last",get:function(){if(this.nodes)return this.nodes[this.nodes.length-1]}},{key:"semicolon",get:function(){return be('Node#semicolon is deprecated. Use Node#raws.semicolon'),this.raws.semicolon},set:function(e){be('Node#semicolon is deprecated. Use Node#raws.semicolon'),this.raws.semicolon=e}},{key:"after",get:function(){return be('Node#after is deprecated. Use Node#raws.after'),this.raws.after},set:function(e){be('Node#after is deprecated. Use Node#raws.after'),this.raws.after=e}}]),t})(Qe),it=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='atrule',r}P(t,e);var r=t.prototype;return r.append=function(){var t;this.nodes||(this.nodes=[]);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.prototype.append).call.apply(t,[this].concat(n))},r.prepend=function(){var t;this.nodes||(this.nodes=[]);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.prototype.prepend).call.apply(t,[this].concat(n))},R(t,[{key:"afterName",get:function(){return be('AtRule#afterName was deprecated. Use AtRule#raws.afterName'),this.raws.afterName},set:function(e){be('AtRule#afterName was deprecated. Use AtRule#raws.afterName'),this.raws.afterName=e}},{key:"_params",get:function(){return be('AtRule#_params was deprecated. Use AtRule#raws.params'),this.raws.params},set:function(e){be('AtRule#_params was deprecated. Use AtRule#raws.params'),this.raws.params=e}}]),t})(st),ot={split:function(e,t,r){for(var n=[],s='',i=!1,o=0,a=!1,u=!1,c=0;c<e.length;c++){var h=e[c];a?u?u=!1:'\\'===h?u=!0:h===a&&(a=!1):'"'===h||"'"===h?a=h:'('===h?o+=1:')'===h?o>0&&(o-=1):0===o&&-1!==t.indexOf(h)&&(i=!0),i?(''!==s&&n.push(s.trim()),s='',i=!1):s+=h}return(r||''!==s)&&n.push(s.trim()),n},space:function(e){return ot.split(e,[' ','\n','\t'])},comma:function(e){return ot.split(e,[','],!0)}},at=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='rule',r.nodes||(r.nodes=[]),r}return P(t,e),R(t,[{key:"selectors",get:function(){return ot.comma(this.selector)},set:function(e){var t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw('between','beforeOpen');this.selector=e.join(r)}},{key:"_selector",get:function(){return be('Rule#_selector is deprecated. Use Rule#raws.selector'),this.raws.selector},set:function(e){be('Rule#_selector is deprecated. Use Rule#raws.selector'),this.raws.selector=e}}]),t})(st),ut=(function(){function e(e,t){if(void 0===t&&(t={}),this.type='warning',this.text=e,t.node&&t.node.source){var r=t.node.positionBy(t);this.line=r.line,this.column=r.column}for(var n in t)this[n]=t[n]}return e.prototype.toString=function(){return this.node?this.node.error(this.text,{plugin:this.plugin,index:this.index,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},e})(),ct=(function(){function e(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}var t=e.prototype;return t.toString=function(){return this.css},t.warn=function(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var r=new ut(e,t);return this.messages.push(r),r},t.warnings=function(){return this.messages.filter(function(e){return'warning'===e.type})},R(e,[{key:"content",get:function(){return this.css}}]),e})();function ht(e){return'object'==typeof e&&'function'==typeof e.then}var ft=(function(){function e(t,r,n){var s;if(this.stringified=!1,this.processed=!1,'object'==typeof r&&'root'===r.type)s=r;else if(r instanceof e||r instanceof ct)s=r.root,r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{var i=rt;n.syntax&&(i=n.syntax.parse),n.parser&&(i=n.parser),i.parse&&(i=i.parse);try{s=i(r,n)}catch(e){this.error=e}}this.result=new ct(t,s,n)}var t=e.prototype;return t.warnings=function(){return this.sync().warnings()},t.toString=function(){return this.css},t.then=function(e,t){return this.async().then(e,t)},t.catch=function(e){return this.async().catch(e)},t.handleError=function(e,t){try{if(this.error=e,'CssSyntaxError'!==e.name||e.plugin){if(t.postcssVersion){var r=t.postcssPlugin,n=t.postcssVersion,s=this.result.processor.version,i=n.split('.'),o=s.split('.');(i[0]!==o[0]||parseInt(i[1])>parseInt(o[1]))&&be("Your current PostCSS version is "+s+", but "+r+" uses "+n+". Perhaps this is the source of the error below.")}}else e.plugin=t.postcssPlugin,e.setMessage()}catch(e){console&&console.error&&console.error(e)}},t.asyncTick=function(e,t){var r=this;if(this.plugin>=this.processor.plugins.length)return this.processed=!0,e();try{var n=this.processor.plugins[this.plugin],s=this.run(n);this.plugin+=1,ht(s)?s.then(function(){r.asyncTick(e,t)}).catch(function(e){r.handleError(e,n),r.processed=!0,t(e)}):this.asyncTick(e,t)}catch(e){this.processed=!0,t(e)}},t.async=function(){var e=this;return this.processed?new Promise(function(t,r){e.error?r(e.error):t(e.stringify())}):this.processing?this.processing:(this.processing=new Promise(function(t,r){if(e.error)return r(e.error);e.plugin=0,e.asyncTick(t,r)}).then(function(){return e.processed=!0,e.stringify()}),this.processing)},t.sync=function(){var e=this;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw new Error('Use process(css).then(cb) to work with async plugins');if(this.error)throw this.error;return this.result.processor.plugins.forEach(function(t){if(ht(e.run(t)))throw new Error('Use process(css).then(cb) to work with async plugins')}),this.result},t.run=function(e){this.result.lastPlugin=e;try{return e(this.result.root,this.result)}catch(t){throw this.handleError(t,e),t}},t.stringify=function(){if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=Ze;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var r='';return t(this.root,function(e){r+=e}),this.result.css=r,this.result},R(e,[{key:"processor",get:function(){return this.result.processor}},{key:"opts",get:function(){return this.result.opts}},{key:"css",get:function(){return this.stringify().css}},{key:"content",get:function(){return this.stringify().content}},{key:"map",get:function(){return this.stringify().map}},{key:"root",get:function(){return this.sync().root}},{key:"messages",get:function(){return this.sync().messages}}]),e})(),lt=(function(){function e(e){void 0===e&&(e=[]),this.version='5.2.0',this.plugins=this.normalize(e)}var t=e.prototype;return t.use=function(e){return this.plugins=this.plugins.concat(this.normalize([e])),this},t.process=function(e,t){return void 0===t&&(t={}),new ft(this,e,t)},t.normalize=function(e){var t=[];return e.forEach(function(e){if(e.postcss&&(e=e.postcss),'object'==typeof e&&Array.isArray(e.plugins))t=t.concat(e.plugins);else{if('function'!=typeof e)throw new Error(e+" is not a PostCSS plugin");t.push(e)}}),t},e})(),pt=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='root',r.nodes||(r.nodes=[]),r}P(t,e);var r=t.prototype;return r.removeChild=function(t){return 0===(t=this.index(t))&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[t].raws.before),e.prototype.removeChild.call(this,t)},r.normalize=function(t,r,n){var s=e.prototype.normalize.call(this,t);return r&&('prepend'===n?this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before:this.first!==r&&s.forEach(function(e){e.raws.before=r.raws.before})),s},r.toResult=function(e){return void 0===e&&(e={}),new ft(new lt,this,e).stringify()},r.remove=function(e){be('Root#remove is deprecated. Use Root#removeChild'),this.removeChild(e)},r.prevMap=function(){return be('Root#prevMap is deprecated. Use Root#source.input.map'),this.source.input.map},t})(st),dt=0,wt=(function(){function e(e,t){void 0===t&&(t={}),this.css=e.toString(),"\ufeff"!==this.css[0]&&"\ufffe"!==this.css[0]||(this.css=this.css.slice(1)),t.from&&(/^\w+:\/\//.test(t.from)?this.file=t.from:this.file=path.resolve(t.from)),this.file||(dt+=1,this.id="<input css "+dt+">"),this.map&&(this.map.file=this.from)}var t=e.prototype;return t.error=function(e,t,r,n){var s;void 0===n&&(n={});var i=this.origin(t,r);return(s=i?new Je(e,i.line,i.column,i.source,i.file,n.plugin):new Je(e,t,r,this.css,this.file,n.plugin)).input={line:t,column:r,source:this.css},this.file&&(s.input.file=this.file),s},t.origin=function(e,t){if(!this.map)return!1;var r=this.map.consumer(),n=r.originalPositionFor({line:e,column:t});if(!n.source)return!1;var s={file:this.mapResolve(n.source),line:n.line,column:n.column},i=r.sourceContentFor(n.source);return i&&(s.source=i),s},t.mapResolve=function(e){return/^\w+:\/\//.test(e)?e:path.resolve(this.map.consumer().sourceRoot||'.',e)},R(e,[{key:"from",get:function(){return this.file||this.id}}]),e})(),mt=(function(e){function t(){return e.apply(this,arguments)||this}P(t,e);var r=t.prototype;return r.tokenize=function(){this.tokens=$e(this.input,{ignoreErrors:!0})},r.comment=function(e){var t=new et;this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]};var r=e[1].slice(2);if('*/'===r.slice(-2)&&(r=r.slice(0,-2)),/^\s*$/.test(r))t.text='',t.raws.left=r,t.raws.right='';else{var n=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},r.unclosedBracket=function(){},r.unknownWord=function(e){var t=this.tokens.slice(e,this.pos+1);this.spaces+=t.map(function(e){return e[1]}).join('')},r.unexpectedClose=function(){this.current.raws.after+='}'},r.doubleColon=function(){},r.unnamedAtrule=function(e){e.name=''},r.precheckMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){var r;for(r=t-1;r>=0&&'word'!==e[r][0];r--);for(r-=1;r>=0;r--)if('space'!==e[r][0]){r+=1;break}var n=e.splice(r,e.length-r);this.decl(n)}},r.checkMissedSemicolon=function(){},r.endFile=function(){for(this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||'')+this.spaces;this.current.parent;)this.current=this.current.parent,this.current.raws.after=''},t})(tt);var vt={},gt=function(e){return'function'==typeof e||'object'==typeof e&&null!==e&&!Array.isArray(e)},yt=function(e){return'__proto__'!==e&&'constructor'!==e&&'prototype'!==e};function bt(e,t,r){var n=e[r];gt(t)&&gt(n)?kt(n,t):e[r]=t}function kt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var s=0,i=r;s<i.length;s++){var o=i[s];if(gt(o))for(var a in o)yt(a)&&bt(e,o[a],a)}return e}var Ct=function(e,t,r){return void 0===r&&(r=B),e.theme!==r.theme&&e.theme||t||r.theme};function St(e){return'string'==typeof e&&!0}function At(e){return St(e)?"styled."+e:"Styled("+C(e)+")"}var xt=f.createContext(),Et=xt.Consumer;function Rt(e,t){return e?S(e)?e(t):Array.isArray(e)||'object'!=typeof e?j(8):t?N({},t,{},e):e:j(14)}var Nt=function(){return!0},Pt=(function(e){function t(){for(var t,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.call.apply(e,[this].concat(n))||this).attrs={},t}P(t,e);var r=t.prototype;return r.render=function(){var e=this;return f.createElement(Et,null,function(t){var r,n=e.props,s=n.$as,i=n.as,o=n.forwardedComponent,a=n.forwardedAs,u=n.forwardedRef,c=n.style,f=void 0===c?[]:c,l=_(n,["$as","as","forwardedComponent","forwardedAs","forwardedRef","style"]),p=o.defaultProps,d=o.target,w=o.shouldForwardProp,m=e.attrs.$as||e.attrs.as||s||i||d,v=e.generateAndInjectStyles(Ct(e.props,t,p)||B,e.props),g=St(m),y=e.attrs!==l?N({},l,{},e.attrs):l,b=w||g&&Nt,k={};for(r in y)'$'!==r[0]&&'as'!==r&&('forwardedAs'===r?k.as=l[r]:b&&!b(r,Nt)||(k[r]=y[r]));return k.style=[v].concat(f),u&&(k.ref=u),a&&(k.as=a),h.createElement(m,k)})},r.buildExecutionContext=function(e,t,r){var n=this,s=N({},t,{theme:e});return r.length?(this.attrs={},r.forEach(function(e){var t,r,i=e;for(r in S(i)&&(i=i(s)),i)t=i[r],n.attrs[r]=t,s[r]=t}),s):s},r.generateAndInjectStyles=function(e,t){var r=t.forwardedComponent.inlineStyle,n=this.buildExecutionContext(e,t,t.forwardedComponent.attrs);return r.generateStyleObject(n)},r.setNativeProps=function(e){void 0!==this.root&&this.root.setNativeProps(e)},t})(h.Component),_t=function(e,t){for(var r=[e[0]],n=0,s=t.length;n<s;n+=1)r.push(t[n],e[n+1]);return r};function Ot(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return S(e)||A(e)?ge(_t(T,[e].concat(r))):0===r.length&&1===e.length&&"string"==typeof e[0]?e:ge(_t(e,r))}function It(e,t,r){if(void 0===r&&(r=B),!c.isValidElementType(t))return j(1,String(t));var n=function(){return e(t,r,Ot.apply(void 0,arguments))};return n.withConfig=function(n){return It(e,t,N({},r,{},n))},n.attrs=function(n){return It(e,t,N({},r,{attrs:Array.prototype.concat(r.attrs,n).filter(Boolean)}))},n}var Ut,Tt=t(o[8]),Bt=(function(e){return function t(r,n,s){var i=n.attrs,o=void 0===i?T:i,a=n.displayName,u=void 0===a?At(r):a,c=n.ParentComponent,h=void 0===c?Pt:c,l=!St(r),p=x(r),d=f.forwardRef(function(e,t){return f.createElement(h,N({},e,{forwardedComponent:d,forwardedRef:t}))}),m=p&&r.attrs?Array.prototype.concat(r.attrs,o).filter(Boolean):o,v=n.shouldForwardProp;return p&&r.shouldForwardProp&&(v=v?function(e,t){return r.shouldForwardProp(e,t)&&n.shouldForwardProp(e,t)}:r.shouldForwardProp),d.attrs=m,d.displayName=u,d.shouldForwardProp=v,d.inlineStyle=new e(p?r.inlineStyle.rules.concat(s):s),d.styledComponentId='StyledNativeComponent',d.target=p?r.target:r,d.withComponent=function(e){n.displayName,n.componentId;var r=N({},_(n,["displayName","componentId"]),{attrs:m,ParentComponent:h});return t(e,r,s)},Object.defineProperty(d,'defaultProps',{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=p?kt({},r.defaultProps,e):e}}),l&&w(d,r,{attrs:!0,displayName:!0,shouldForwardProp:!0,inlineStyle:!0,styledComponentId:!0,target:!0,withComponent:!0}),d}})((Ut=Tt.StyleSheet,(function(){function e(e){this.rules=e}return e.prototype.generateStyleObject=function(e){var t,r,n,s=ge(this.rules,e).join(''),i=y(k(b,s)>>>0);if(!vt[i]){var o=[];(r=new wt(s,t),(n=new mt(r)).tokenize(),n.loop(),n.root).each(function(e){'decl'===e.type&&o.push([e.prop,e.value])});var a=u(o,['borderRadius','borderWidth','borderColor','borderStyle']),c=Ut.create({generated:a});vt[i]=c.generated}return vt[i]},e})())),jt=function(e){return It(Bt,e)};"ActivityIndicator ActivityIndicatorIOS ART Button DatePickerIOS DrawerLayoutAndroid\n Image ImageBackground ImageEditor ImageStore KeyboardAvoidingView ListView MapView Modal NavigatorIOS\n Picker PickerIOS ProgressBarAndroid ProgressViewIOS ScrollView SegmentedControlIOS Slider\n SliderIOS SnapshotViewIOS Switch RecyclerViewBackedScrollView RefreshControl SafeAreaView StatusBar\n SwipeableListView SwitchAndroid SwitchIOS TabBarIOS Text TextInput ToastAndroid ToolbarAndroid\n Touchable TouchableHighlight TouchableNativeFeedback TouchableOpacity TouchableWithoutFeedback\n View ViewPagerAndroid WebView FlatList SectionList VirtualizedList Pressable".split(/\s+/m).forEach(function(e){return Object.defineProperty(jt,e,{enumerable:!0,configurable:!1,get:function(){return jt(Tt[e])}})}),i.ThemeConsumer=Et,i.ThemeContext=xt,i.ThemeProvider=function(e){var t=h.useContext(xt),r=h.useMemo(function(){return Rt(e.theme,t)},[e.theme,t]);return e.children?f.createElement(xt.Provider,{value:r},e.children):null},i.css=Ot,i.default=jt,i.isStyledComponent=x,i.useTheme=function(){return h.useContext(xt)},i.withTheme=function(e){var t=f.forwardRef(function(t,r){var n=h.useContext(xt),s=e.defaultProps,i=Ct(t,n,s);return f.createElement(e,N({},t,{theme:i,ref:r}))});return w(t,e),t.displayName="WithTheme("+C(e)+")",t}},598,[599,405,14,608,609,610,611,404,17]);^~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:604:4780: warning: the variable "__webpack_nonce__" was not declared in function "Q 7#"__d(function(e,t,r,n,s,i,o){'use strict';function a(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(i,'__esModule',{value:!0});var u=a(t(o[0])),c=t(o[1]),h=t(o[2]),f=a(h);t(o[3]);var l=a(t(o[4])),p=a(t(o[5])),d=a(t(o[6])),w=a(t(o[7])),m=/(a)(d)/gi,v=52,g=function(e){return String.fromCharCode(e+(e>25?39:97))};function y(e){var t,r='';for(t=Math.abs(e);t>v;t=t/v|0)r=g(t%v)+r;return(g(t%v)+r).replace(m,'$1-$2')}var b=5381,k=function(e,t){for(var r=t.length;r;)e=33*e^t.charCodeAt(--r);return e};function C(e){return e.displayName||e.name||'Component'}function S(e){return'function'==typeof e}var A=function(e){return null!==e&&'object'==typeof e&&'[object Object]'===(e.toString?e.toString():Object.prototype.toString.call(e))&&!c.typeOf(e)};function x(e){return e&&'string'==typeof e.styledComponentId}function E(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 R(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e}function N(){return(N=Object.assign||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}).apply(this,arguments)}function P(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function _(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}var O='undefined'!=typeof process&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||'data-styled',I='undefined'!=typeof window&&'HTMLElement'in window,U=Boolean('boolean'==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:'undefined'!=typeof process&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&''!==process.env.REACT_APP_SC_DISABLE_SPEEDY?'false'!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:'undefined'!=typeof process&&void 0!==process.env.SC_DISABLE_SPEEDY&&''!==process.env.SC_DISABLE_SPEEDY&&('false'!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY)),T=Object.freeze([]),B=Object.freeze({});function j(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw new Error("An error occurred. See https://git.io/JUIaE#"+e+" for more information."+(r.length>0?" Args: "+r.join(', '):''))}var D=512,z=(function(){function e(e){this.groupSizes=new Uint32Array(D),this.length=D,this.tag=e}var t=e.prototype;return t.indexOfGroup=function(e){for(var t=0,r=0;r<e;r++)t+=this.groupSizes[r];return t},t.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var r=this.groupSizes,n=r.length,s=n;e>=s;)(s<<=1)<0&&j(16,""+e);this.groupSizes=new Uint32Array(s),this.groupSizes.set(r),this.length=s;for(var i=n;i<s;i++)this.groupSizes[i]=0}for(var o=this.indexOfGroup(e+1),a=0,u=t.length;a<u;a++)this.tag.insertRule(o,t[a])&&(this.groupSizes[e]++,o++)},t.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],r=this.indexOfGroup(e),n=r+t;this.groupSizes[e]=0;for(var s=r;s<n;s++)this.tag.deleteRule(r)}},t.getGroup=function(e){var t='';if(e>=this.length||0===this.groupSizes[e])return t;for(var r=this.groupSizes[e],n=this.indexOfGroup(e),s=n+r,i=n;i<s;i++)t+=this.tag.getRule(i)+"/*!sc*/\n";return t},e})(),F=new Map,M=new Map,V=1,L=function(e){if(F.has(e))return F.get(e);for(;M.has(V);)V++;var t=V++;return F.set(e,t),M.set(t,e),t},$=function(e){return M.get(e)},Y=function(e,t){F.set(e,t),M.set(t,e)},W="style["+O+"][data-styled-version=\"5.2.1\"]",G=new RegExp("^"+O+"\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"),J=function(e){for(var t=e.getTag(),r=t.length,n='',s=0;s<r;s++){var i=$(s);if(void 0!==i){var o=e.names.get(i),a=t.getGroup(s);if(void 0!==o&&0!==a.length){var u=O+".g"+s+"[id=\""+i+"\"]",c='';void 0!==o&&o.forEach(function(e){e.length>0&&(c+=e+",")}),n+=""+a+u+"{content:\""+c+"\"}/*!sc*/\n"}}}return n},q=function(e,t,r){for(var n,s=r.split(','),i=0,o=s.length;i<o;i++)(n=s[i])&&e.registerName(t,n)},H=function(e,t){for(var r=t.innerHTML.split("/*!sc*/\n"),n=[],s=0,i=r.length;s<i;s++){var o=r[s].trim();if(o){var a=o.match(G);if(a){var u=0|parseInt(a[1],10),c=a[2];0!==u&&(Y(c,u),q(e,c,a[3]),e.getTag().insertRules(u,n)),n.length=0}else n.push(o)}}},Z=function(e){for(var t=document.querySelectorAll(W),r=0,n=t.length;r<n;r++){var s=t[r];s&&"active"!==s.getAttribute(O)&&(H(e,s),s.parentNode&&s.parentNode.removeChild(s))}},K=function(e){for(var t=e.childNodes,r=t.length;r>=0;r--){var n=t[r];if(n&&1===n.nodeType&&n.hasAttribute(O))return n}},Q=function(e){var t=document.head,r=e||t,n=document.createElement('style'),s=K(r),i=void 0!==s?s.nextSibling:null;n.setAttribute(O,"active"),n.setAttribute("data-styled-version","5.2.1");var o='undefined'!=typeof __webpack_nonce__?__webpack_nonce__:null;return o&&n.setAttribute('nonce',o),r.insertBefore(n,i),n},X=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,r=0,n=t.length;r<n;r++){var s=t[r];if(s.ownerNode===e)return s}j(17)},ee=(function(){function e(e){var t=this.element=Q(e);t.appendChild(document.createTextNode('')),this.sheet=X(t),this.length=0}var t=e.prototype;return t.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},t.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},t.getRule=function(e){var t=this.sheet.cssRules[e];return void 0!==t&&'string'==typeof t.cssText?t.cssText:''},e})(),te=(function(){function e(e){var t=this.element=Q(e);this.nodes=t.childNodes,this.length=0}var t=e.prototype;return t.insertRule=function(e,t){if(e<=this.length&&e>=0){var r=document.createTextNode(t),n=this.nodes[e];return this.element.insertBefore(r,n||null),this.length++,!0}return!1},t.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.getRule=function(e){return e<this.length?this.nodes[e].textContent:''},e})(),re=(function(){function e(e){this.rules=[],this.length=0}var t=e.prototype;return t.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},t.deleteRule=function(e){this.rules.splice(e,1),this.length--},t.getRule=function(e){return e<this.length?this.rules[e]:''},e})(),ne=I,se={isServer:!I,useCSSOMInjection:!U},ie=(function(){function e(e,t,r){void 0===e&&(e=B),void 0===t&&(t={}),this.options=N({},se,{},e),this.gs=t,this.names=new Map(r),!this.options.isServer&&I&&ne&&(ne=!1,Z(this))}e.registerId=function(e){return L(e)};var t=e.prototype;return t.reconstructWithOptions=function(t,r){return void 0===r&&(r=!0),new e(N({},this.options,{},t),this.gs,r&&this.names||void 0)},t.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},t.getTag=function(){return this.tag||(this.tag=(t=this.options,r=t.isServer,n=t.useCSSOMInjection,s=t.target,e=r?new re(s):n?new ee(s):new te(s),new z(e)));var e,t,r,n,s},t.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},t.registerName=function(e,t){if(L(e),this.names.has(e))this.names.get(e).add(t);else{var r=new Set;r.add(t),this.names.set(e,r)}},t.insertRules=function(e,t,r){this.registerName(e,t),this.getTag().insertRules(L(e),r)},t.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},t.clearRules=function(e){this.getTag().clearGroup(L(e)),this.clearNames(e)},t.clearTag=function(){this.tag=void 0},t.toString=function(){return J(this)},e})();function oe(e){function t(t){if(t)try{e(t+"}")}catch(e){}}return function(r,n,s,i,o,a,u,c,h,f){switch(r){case 1:if(0===h&&64===n.charCodeAt(0))return e(n+";"),'';break;case 2:if(0===c)return n+"/*|*/";break;case 3:switch(c){case 102:case 112:return e(s[0]+n),'';default:return n+(0===f?"/*|*/":'')}case-2:n.split("/*|*/}").forEach(t)}}}var ae=/^\s*\/\/.*$/gm,ue=[':','[','.','#'];f.createContext().Consumer,f.createContext().Consumer,new ie;var ce=(function(e){var t,r,n,s,i=void 0===e?B:e,o=i.options,a=void 0===o?B:o,u=i.plugins,c=void 0===u?T:u,h=new l(a),f=[],p=oe(function(e){f.push(e)}),d=function(e,n,i){return 0===n&&ue.includes(i[r.length])||i.match(s)?e:"."+t};function w(e,i,o,a){void 0===a&&(a='&');var u=e.replace(ae,''),c=i&&o?o+" "+i+" { "+u+" }":u;return t=a,r=i,n=new RegExp("\\"+r+"\\b",'g'),s=new RegExp("(\\"+r+"\\b){2,}"),h(o||!i?'':i,c)}return h.use([].concat(c,[function(e,t,s){2===e&&s.length&&s[0].lastIndexOf(r)>0&&(s[0]=s[0].replace(n,d))},p,function(e){if(-2===e){var t=f;return f=[],t}}])),w.hash=c.length?c.reduce(function(e,t){return t.name||j(15),k(e,t.name)},b).toString():'',w})(),he=(function(){function e(e,t){var r=this;this.inject=function(e,t){void 0===t&&(t=ce);var n=r.name+t.hash;e.hasNameForId(r.id,n)||e.insertRules(r.id,n,t(r.rules,n,'@keyframes'))},this.toString=function(){return j(12,String(r.name))},this.name=e,this.id="sc-keyframes-"+e,this.rules=t}return e.prototype.getName=function(e){return void 0===e&&(e=ce),this.name+e.hash},e})(),fe=/([A-Z])/,le=/([A-Z])/g,pe=/^ms-/,de=function(e){return"-"+e.toLowerCase()};function we(e){return fe.test(e)?e.replace(le,de).replace(pe,'-ms-'):e}var me=function(e){return void 0===e||null===e||!1===e||''===e},ve=function e(t,r){var n,s,i=[];for(var o in t)t.hasOwnProperty(o)&&!me(t[o])&&(A(t[o])?i.push.apply(i,e(t[o],o)):S(t[o])?i.push(we(o)+":",t[o],';'):i.push(we(o)+": "+(n=o,null==(s=t[o])||'boolean'==typeof s||''===s?'':'number'!=typeof s||0===s||n in p?String(s).trim():s+"px")+";"));return r?[r+" {"].concat(i,['}']):i};function ge(e,t,r,n){if(Array.isArray(e)){for(var s,i=[],o=0,a=e.length;o<a;o+=1)''!==(s=ge(e[o],t,r,n))&&(Array.isArray(s)?i.push.apply(i,s):i.push(s));return i}return me(e)?'':x(e)?"."+e.styledComponentId:S(e)?'function'!=typeof(u=e)||u.prototype&&u.prototype.isReactComponent||!t?e:ge(e(t),t,r,n):e instanceof he?r?(e.inject(r,n),e.getName(n)):e:A(e)?ve(e):e.toString();var u}var ye={};function be(e){ye[e]||(ye[e]=!0,'undefined'!=typeof console&&console.warn&&console.warn(e))}var ke="'".charCodeAt(0),Ce='"'.charCodeAt(0),Se='\\'.charCodeAt(0),Ae='/'.charCodeAt(0),xe='\n'.charCodeAt(0),Ee=' '.charCodeAt(0),Re='\f'.charCodeAt(0),Ne='\t'.charCodeAt(0),Pe='\r'.charCodeAt(0),_e='['.charCodeAt(0),Oe=']'.charCodeAt(0),Ie='('.charCodeAt(0),Ue=')'.charCodeAt(0),Te='{'.charCodeAt(0),Be='}'.charCodeAt(0),je=';'.charCodeAt(0),De='*'.charCodeAt(0),ze=':'.charCodeAt(0),Fe='@'.charCodeAt(0),Me=/[ \n\t\r\f\{\(\)'"\\;/\[\]#]/g,Ve=/[ \n\t\r\f\(\)\{\}:;@!'"\\\]\[#]|\/(?=\*)/g,Le=/.[\\\/\("'\n]/;function $e(e,t){void 0===t&&(t={});var r,n,s,i,o,a,u,c,h,f,l,p,d,w=[],m=e.css.valueOf(),v=t.ignoreErrors,g=m.length,y=-1,b=1,k=0;function C(t){throw e.error("Unclosed "+t,b,k-y)}for(;k<g;){switch(((r=m.charCodeAt(k))===xe||r===Re||r===Pe&&m.charCodeAt(k+1)!==xe)&&(y=k,b+=1),r){case xe:case Ee:case Ne:case Pe:case Re:n=k;do{n+=1,(r=m.charCodeAt(n))===xe&&(y=n,b+=1)}while(r===Ee||r===xe||r===Ne||r===Pe||r===Re);w.push(['space',m.slice(k,n)]),k=n-1;break;case _e:w.push(['[','[',b,k-y]);break;case Oe:w.push([']',']',b,k-y]);break;case Te:w.push(['{','{',b,k-y]);break;case Be:w.push(['}','}',b,k-y]);break;case ze:w.push([':',':',b,k-y]);break;case je:w.push([';',';',b,k-y]);break;case Ie:if(p=w.length?w[w.length-1][1]:'',d=m.charCodeAt(k+1),'url'===p&&d!==ke&&d!==Ce&&d!==Ee&&d!==xe&&d!==Ne&&d!==Re&&d!==Pe){n=k;do{if(f=!1,-1===(n=m.indexOf(')',n+1))){if(v){n=k;break}C('bracket')}for(l=n;m.charCodeAt(l-1)===Se;)l-=1,f=!f}while(f);w.push(['brackets',m.slice(k,n+1),b,k-y,b,n-y]),k=n}else n=m.indexOf(')',k+1),a=m.slice(k,n+1),-1===n||Le.test(a)?w.push(['(','(',b,k-y]):(w.push(['brackets',a,b,k-y,b,n-y]),k=n);break;case Ue:w.push([')',')',b,k-y]);break;case ke:case Ce:s=r===ke?"'":'"',n=k;do{if(f=!1,-1===(n=m.indexOf(s,n+1))){if(v){n=k+1;break}C('quote')}for(l=n;m.charCodeAt(l-1)===Se;)l-=1,f=!f}while(f);(o=(i=(a=m.slice(k,n+1)).split('\n')).length-1)>0?(c=b+o,h=n-i[o].length):(c=b,h=y),w.push(['string',m.slice(k,n+1),b,k-y,c,n-h]),y=h,b=c,k=n;break;case Fe:Me.lastIndex=k+1,Me.test(m),n=0===Me.lastIndex?m.length-1:Me.lastIndex-2,w.push(['at-word',m.slice(k,n+1),b,k-y,b,n-y]),k=n;break;case Se:for(n=k,u=!0;m.charCodeAt(n+1)===Se;)n+=1,u=!u;r=m.charCodeAt(n+1),u&&r!==Ae&&r!==Ee&&r!==xe&&r!==Ne&&r!==Pe&&r!==Re&&(n+=1),w.push(['word',m.slice(k,n+1),b,k-y,b,n-y]),k=n;break;default:r===Ae&&m.charCodeAt(k+1)===De?(0===(n=m.indexOf('*/',k+2)+1)&&(v?n=m.length:C('comment')),(o=(i=(a=m.slice(k,n+1)).split('\n')).length-1)>0?(c=b+o,h=n-i[o].length):(c=b,h=y),w.push(['comment',a,b,k-y,c,n-h]),y=h,b=c,k=n):(Ve.lastIndex=k+1,Ve.test(m),n=0===Ve.lastIndex?m.length-1:Ve.lastIndex-2,w.push(['word',m.slice(k,n+1),b,k-y,b,n-y]),k=n)}k++}return w}var Ye={brackets:[36,39],string:[31,39],'at-word':[31,39],comment:[90,39],'{':[32,39],'}':[32,39],':':[1,22],';':[1,22],'(':[1,22],')':[1,22]};function We(e){return"\x1b["+e+"m"}function Ge(e){var t=[];return $e(new wt(e),{ignoreErrors:!0}).forEach(function(e){var r=Ye[e[0]];r?t.push(e[1].split(/\r?\n/).map(function(e){return We(r[0])+e+We(r[1])}).join('\n')):t.push(e[1])}),t.join('')}var Je=(function(){function e(t,r,n,s,i,o){this.name='CssSyntaxError',this.reason=t,i&&(this.file=i),s&&(this.source=s),o&&(this.plugin=o),void 0!==r&&void 0!==n&&(this.line=r,this.column=n),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}var t=e.prototype;return t.setMessage=function(){this.message=this.plugin?this.plugin+": ":'',this.message+=this.file?this.file:'<css input>',void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},t.showSourceCode=function(e){var t=this;if(!this.source)return'';var r=this.source;void 0===e&&(e=d),e&&(r=Ge(r));var n=r.split(/\r?\n/),s=Math.max(this.line-3,0),i=Math.min(this.line+2,n.length),o=String(i).length;return n.slice(s,i).map(function(e,r){var n=s+1+r,i=" "+(" "+n).slice(-o)+" | ";return n===t.line?">"+i+e+"\n "+(i.replace(/\d/g,' ')+e.slice(0,t.column-1).replace(/[^\t]/g,' '))+"^":" "+i+e}).join('\n')},t.toString=function(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e},R(e,[{key:"generated",get:function(){return be('CssSyntaxError#generated is deprecated. Use input instead.'),this.input}}]),e})(),qe={colon:': ',indent:'    ',beforeDecl:'\n',beforeRule:'\n',beforeOpen:' ',beforeClose:'\n',beforeComment:'\n',after:'\n',emptyBody:'',commentLeft:' ',commentRight:' '};var He=(function(){function e(e){this.builder=e}var t=e.prototype;return t.stringify=function(e,t){this[e.type](e,t)},t.root=function(e){this.body(e),e.raws.after&&this.builder(e.raws.after)},t.comment=function(e){var t=this.raw(e,'left','commentLeft'),r=this.raw(e,'right','commentRight');this.builder("/*"+t+e.text+r+"*/",e)},t.decl=function(e,t){var r=this.raw(e,'between','colon'),n=e.prop+r+this.rawValue(e,'value');e.important&&(n+=e.raws.important||' !important'),t&&(n+=';'),this.builder(n,e)},t.rule=function(e){this.block(e,this.rawValue(e,'selector'))},t.atrule=function(e,t){var r="@"+e.name,n=e.params?this.rawValue(e,'params'):'';if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=' '),e.nodes)this.block(e,r+n);else{var s=(e.raws.between||'')+(t?';':'');this.builder(r+n+s,e)}},t.body=function(e){for(var t=e.nodes.length-1;t>0&&'comment'===e.nodes[t].type;)t-=1;for(var r=this.raw(e,'semicolon'),n=0;n<e.nodes.length;n++){var s=e.nodes[n],i=this.raw(s,'before');i&&this.builder(i),this.stringify(s,t!==n||r)}},t.block=function(e,t){var r,n=this.raw(e,'between','beforeOpen');this.builder(t+n+"{",e,'start'),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,'after')):r=this.raw(e,'after','emptyBody'),r&&this.builder(r),this.builder('}',e,'end')},t.raw=function(e,t,r){var n;if(r||(r=t),t&&void 0!==(n=e.raws[t]))return n;var s=e.parent;if('before'===r&&(!s||'root'===s.type&&s.first===e))return'';if(!s)return qe[r];var i=e.root();if(i.rawCache||(i.rawCache={}),void 0!==i.rawCache[r])return i.rawCache[r];if('before'===r||'after'===r)return this.beforeAfter(e,r);var o,a="raw"+((o=r)[0].toUpperCase()+o.slice(1));return this[a]?n=this[a](i,e):i.walk(function(e){if(void 0!==(n=e.raws[t]))return!1}),void 0===n&&(n=qe[r]),i.rawCache[r]=n,n},t.rawSemicolon=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length&&'decl'===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t},t.rawEmptyBody=function(e){var t;return e.walk(function(e){if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t},t.rawIndent=function(e){return e.raws.indent?e.raws.indent:(e.walk(function(r){var n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){var s=r.raws.before.split('\n');return t=(t=s[s.length-1]).replace(/[^\s]/g,''),!1}}),t);var t},t.rawBeforeComment=function(e,t){var r;return e.walkComments(function(e){if(void 0!==e.raws.before)return-1!==(r=e.raws.before).indexOf('\n')&&(r=r.replace(/[^\n]+$/,'')),!1}),void 0===r&&(r=this.raw(t,null,'beforeDecl')),r},t.rawBeforeDecl=function(e,t){var r;return e.walkDecls(function(e){if(void 0!==e.raws.before)return-1!==(r=e.raws.before).indexOf('\n')&&(r=r.replace(/[^\n]+$/,'')),!1}),void 0===r&&(r=this.raw(t,null,'beforeRule')),r},t.rawBeforeRule=function(e){var t;return e.walk(function(r){if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return-1!==(t=r.raws.before).indexOf('\n')&&(t=t.replace(/[^\n]+$/,'')),!1}),t},t.rawBeforeClose=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return-1!==(t=e.raws.after).indexOf('\n')&&(t=t.replace(/[^\n]+$/,'')),!1}),t},t.rawBeforeOpen=function(e){var t;return e.walk(function(e){if('decl'!==e.type&&void 0!==(t=e.raws.between))return!1}),t},t.rawColon=function(e){var t;return e.walkDecls(function(e){if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,''),!1}),t},t.beforeAfter=function(e,t){var r;r='decl'===e.type?this.raw(e,null,'beforeDecl'):'comment'===e.type?this.raw(e,null,'beforeComment'):'before'===t?this.raw(e,null,'beforeRule'):this.raw(e,null,'beforeClose');for(var n=e.parent,s=0;n&&'root'!==n.type;)s+=1,n=n.parent;if(-1!==r.indexOf('\n')){var i=this.raw(e,null,'indent');if(i.length)for(var o=0;o<s;o++)r+=i}return r},t.rawValue=function(e,t){var r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r},e})();function Ze(e,t){new He(t).stringify(e)}var Ke=function e(t,r){var n=new t.constructor;for(var s in t)if(t.hasOwnProperty(s)){var i=t[s],o=typeof i;'parent'===s&&'object'===o?r&&(n[s]=r):'source'===s?n[s]=i:i instanceof Array?n[s]=i.map(function(t){return e(t,n)}):'before'!==s&&'after'!==s&&'between'!==s&&'semicolon'!==s&&('object'===o&&null!==i&&(i=e(i)),n[s]=i)}return n},Qe=(function(){function e(e){for(var t in void 0===e&&(e={}),this.raws={},e)this[t]=e[t]}var t=e.prototype;return t.error=function(e,t){if(void 0===t&&(t={}),this.source){var r=this.positionBy(t);return this.source.input.error(e,r.line,r.column,t)}return new Je(e)},t.warn=function(e,t,r){var n={node:this};for(var s in r)n[s]=r[s];return e.warn(t,n)},t.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},t.toString=function(e){void 0===e&&(e=Ze),e.stringify&&(e=e.stringify);var t='';return e(this,function(e){t+=e}),t},t.clone=function(e){void 0===e&&(e={});var t=Ke(this);for(var r in e)t[r]=e[r];return t},t.cloneBefore=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t},t.cloneAfter=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t},t.replaceWith=function(){var e=this;if(this.parent){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(function(t){e.parent.insertBefore(e,t)}),this.remove()}return this},t.moveTo=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.append(this),this},t.moveBefore=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.parent.insertBefore(e,this),this},t.moveAfter=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.parent.insertAfter(e,this),this},t.next=function(){var e=this.parent.index(this);return this.parent.nodes[e+1]},t.prev=function(){var e=this.parent.index(this);return this.parent.nodes[e-1]},t.toJSON=function(){var e={};for(var t in this)if(this.hasOwnProperty(t)&&'parent'!==t){var r=this[t];r instanceof Array?e[t]=r.map(function(e){return'object'==typeof e&&e.toJSON?e.toJSON():e}):'object'==typeof r&&r.toJSON?e[t]=r.toJSON():e[t]=r}return e},t.raw=function(e,t){return(new He).raw(this,e,t)},t.root=function(){for(var e=this;e.parent;)e=e.parent;return e},t.cleanRaws=function(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between},t.positionInside=function(e){for(var t=this.toString(),r=this.source.start.column,n=this.source.start.line,s=0;s<e;s++)'\n'===t[s]?(r=1,n+=1):r+=1;return{line:n,column:r}},t.positionBy=function(e){var t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){var r=this.toString().indexOf(e.word);-1!==r&&(t=this.positionInside(r))}return t},t.removeSelf=function(){return be('Node#removeSelf is deprecated. Use Node#remove.'),this.remove()},t.replace=function(e){return be('Node#replace is deprecated. Use Node#replaceWith'),this.replaceWith(e)},t.style=function(e,t){return be('Node#style() is deprecated. Use Node#raw()'),this.raw(e,t)},t.cleanStyles=function(e){return be('Node#cleanStyles() is deprecated. Use Node#cleanRaws()'),this.cleanRaws(e)},R(e,[{key:"before",get:function(){return be('Node#before is deprecated. Use Node#raws.before'),this.raws.before},set:function(e){be('Node#before is deprecated. Use Node#raws.before'),this.raws.before=e}},{key:"between",get:function(){return be('Node#between is deprecated. Use Node#raws.between'),this.raws.between},set:function(e){be('Node#between is deprecated. Use Node#raws.between'),this.raws.between=e}}]),e})(),Xe=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='decl',r}return P(t,e),R(t,[{key:"_value",get:function(){return be('Node#_value was deprecated. Use Node#raws.value'),this.raws.value},set:function(e){be('Node#_value was deprecated. Use Node#raws.value'),this.raws.value=e}},{key:"_important",get:function(){return be('Node#_important was deprecated. Use Node#raws.important'),this.raws.important},set:function(e){be('Node#_important was deprecated. Use Node#raws.important'),this.raws.important=e}}]),t})(Qe),et=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='comment',r}return P(t,e),R(t,[{key:"left",get:function(){return be('Comment#left was deprecated. Use Comment#raws.left'),this.raws.left},set:function(e){be('Comment#left was deprecated. Use Comment#raws.left'),this.raws.left=e}},{key:"right",get:function(){return be('Comment#right was deprecated. Use Comment#raws.right'),this.raws.right},set:function(e){be('Comment#right was deprecated. Use Comment#raws.right'),this.raws.right=e}}]),t})(Qe),tt=(function(){function e(e){this.input=e,this.pos=0,this.root=new pt,this.current=this.root,this.spaces='',this.semicolon=!1,this.root.source={input:e,start:{line:1,column:1}}}var t=e.prototype;return t.tokenize=function(){this.tokens=$e(this.input)},t.loop=function(){for(var e;this.pos<this.tokens.length;){switch((e=this.tokens[this.pos])[0]){case'space':case';':this.spaces+=e[1];break;case'}':this.end(e);break;case'comment':this.comment(e);break;case'at-word':this.atrule(e);break;case'{':this.emptyRule(e);break;default:this.other()}this.pos+=1}this.endFile()},t.comment=function(e){var t=new et;this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]};var r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text='',t.raws.left=r,t.raws.right='';else{var n=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},t.emptyRule=function(e){var t=new at;this.init(t,e[2],e[3]),t.selector='',t.raws.between='',this.current=t},t.other=function(){for(var e,t=!1,r=null,n=!1,s=null,i=[],o=this.pos;this.pos<this.tokens.length;){if('('===(r=(e=this.tokens[this.pos])[0])||'['===r)s||(s=e),i.push('('===r?')':']');else if(0===i.length){if(';'===r){if(n)return void this.decl(this.tokens.slice(o,this.pos+1));break}if('{'===r)return void this.rule(this.tokens.slice(o,this.pos+1));if('}'===r){this.pos-=1,t=!0;break}':'===r&&(n=!0)}else r===i[i.length-1]&&(i.pop(),0===i.length&&(s=null));this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,t=!0),i.length>0&&this.unclosedBracket(s),t&&n){for(;this.pos>o&&('space'===(e=this.tokens[this.pos][0])||'comment'===e);)this.pos-=1;this.decl(this.tokens.slice(o,this.pos+1))}else this.unknownWord(o)},t.rule=function(e){e.pop();var t=new at;this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesFromEnd(e),this.raw(t,'selector',e),this.current=t},t.decl=function(e){var t=new Xe;this.init(t);var r,n=e[e.length-1];for(';'===n[0]&&(this.semicolon=!0,e.pop()),n[4]?t.source.end={line:n[4],column:n[5]}:t.source.end={line:n[2],column:n[3]};'word'!==e[0][0];)t.raws.before+=e.shift()[1];for(t.source.start={line:e[0][2],column:e[0][3]},t.prop='';e.length;){var s=e[0][0];if(':'===s||'space'===s||'comment'===s)break;t.prop+=e.shift()[1]}for(t.raws.between='';e.length;){if(':'===(r=e.shift())[0]){t.raws.between+=r[1];break}t.raws.between+=r[1]}'_'!==t.prop[0]&&'*'!==t.prop[0]||(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesFromStart(e),this.precheckMissedSemicolon(e);for(var i=e.length-1;i>0;i--){if('!important'===(r=e[i])[1]){t.important=!0;var o=this.stringFrom(e,i);' !important'!==(o=this.spacesFromEnd(e)+o)&&(t.raws.important=o);break}if('important'===r[1]){for(var a=e.slice(0),u='',c=i;c>0;c--){var h=a[c][0];if(0===u.trim().indexOf('!')&&'space'!==h)break;u=a.pop()[1]+u}0===u.trim().indexOf('!')&&(t.important=!0,t.raws.important=u,e=a)}if('space'!==r[0]&&'comment'!==r[0])break}this.raw(t,'value',e),-1!==t.value.indexOf(':')&&this.checkMissedSemicolon(e)},t.atrule=function(e){var t=new it;t.name=e[1].slice(1),''===t.name&&this.unnamedAtrule(t,e),this.init(t,e[2],e[3]);var r=!1,n=!1,s=[];for(this.pos+=1;this.pos<this.tokens.length;){if(';'===(e=this.tokens[this.pos])[0]){t.source.end={line:e[2],column:e[3]},this.semicolon=!0;break}if('{'===e[0]){n=!0;break}if('}'===e[0]){this.end(e);break}s.push(e),this.pos+=1}this.pos===this.tokens.length&&(r=!0),t.raws.between=this.spacesFromEnd(s),s.length?(t.raws.afterName=this.spacesFromStart(s),this.raw(t,'params',s),r&&(e=s[s.length-1],t.source.end={line:e[4],column:e[5]},this.spaces=t.raws.between,t.raws.between='')):(t.raws.afterName='',t.params=''),n&&(t.nodes=[],this.current=t)},t.end=function(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||'')+this.spaces,this.spaces='',this.current.parent?(this.current.source.end={line:e[2],column:e[3]},this.current=this.current.parent):this.unexpectedClose(e)},t.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||'')+this.spaces},t.init=function(e,t,r){this.current.push(e),e.source={start:{line:t,column:r},input:this.input},e.raws.before=this.spaces,this.spaces='','comment'!==e.type&&(this.semicolon=!1)},t.raw=function(e,t,r){for(var n,s,i=r.length,o='',a=!0,u=0;u<i;u+=1)'comment'===(s=(n=r[u])[0])||'space'===s&&u===i-1?a=!1:o+=n[1];if(!a){var c=r.reduce(function(e,t){return e+t[1]},'');e.raws[t]={value:o,raw:c}}e[t]=o},t.spacesFromEnd=function(e){for(var t,r='';e.length&&('space'===(t=e[e.length-1][0])||'comment'===t);)r=e.pop()[1]+r;return r},t.spacesFromStart=function(e){for(var t,r='';e.length&&('space'===(t=e[0][0])||'comment'===t);)r+=e.shift()[1];return r},t.stringFrom=function(e,t){for(var r='',n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r},t.colon=function(e){for(var t,r,n,s=0,i=0;i<e.length;i++){if('('===(r=(t=e[i])[0]))s+=1;else if(')'===r)s-=1;else if(0===s&&':'===r){if(n){if('word'===n[0]&&'progid'===n[1])continue;return i}this.doubleColon(t)}n=t}return!1},t.unclosedBracket=function(e){throw this.input.error('Unclosed bracket',e[2],e[3])},t.unknownWord=function(e){var t=this.tokens[e];throw this.input.error('Unknown word',t[2],t[3])},t.unexpectedClose=function(e){throw this.input.error('Unexpected }',e[2],e[3])},t.unclosedBlock=function(){var e=this.current.source.start;throw this.input.error('Unclosed block',e.line,e.column)},t.doubleColon=function(e){throw this.input.error('Double colon',e[2],e[3])},t.unnamedAtrule=function(e,t){throw this.input.error('At-rule without name',t[2],t[3])},t.precheckMissedSemicolon=function(e){},t.checkMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){for(var r,n=0,s=t-1;s>=0&&('space'===(r=e[s])[0]||2!==(n+=1));s--);throw this.input.error('Missed semicolon',r[2],r[3])}},e})();function rt(e,t){if(t&&t.safe)throw new Error("Option safe was removed. Use parser: require(\"postcss-safe-parser\")");var r=new wt(e,t),n=new tt(r);try{n.tokenize(),n.loop()}catch(e){throw'CssSyntaxError'===e.name&&t&&t.from&&(/\.scss$/i.test(t.from)?e.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.less$/i.test(t.from)&&(e.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),e}return n.root}function nt(e){return e.map(function(e){return e.nodes&&(e.nodes=nt(e.nodes)),delete e.source,e})}var st=(function(e){function t(){return e.apply(this,arguments)||this}P(t,e);var r=t.prototype;return r.push=function(e){return e.parent=this,this.nodes.push(e),this},r.each=function(e){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var t=this.lastEach;if(this.indexes[t]=0,this.nodes){for(var r,n;this.indexes[t]<this.nodes.length&&(r=this.indexes[t],!1!==(n=e(this.nodes[r],r)));)this.indexes[t]+=1;return delete this.indexes[t],n}},r.walk=function(e){return this.each(function(t,r){var n=e(t,r);return!1!==n&&t.walk&&(n=t.walk(e)),n})},r.walkDecls=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('decl'===r.type&&e.test(r.prop))return t(r,n)}):this.walk(function(r,n){if('decl'===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('decl'===e.type)return t(e,r)}))},r.walkRules=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('rule'===r.type&&e.test(r.selector))return t(r,n)}):this.walk(function(r,n){if('rule'===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('rule'===e.type)return t(e,r)}))},r.walkAtRules=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('atrule'===r.type&&e.test(r.name))return t(r,n)}):this.walk(function(r,n){if('atrule'===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('atrule'===e.type)return t(e,r)}))},r.walkComments=function(e){return this.walk(function(t,r){if('comment'===t.type)return e(t,r)})},r.append=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach(function(t){e.normalize(t,e.last).forEach(function(t){return e.nodes.push(t)})}),this},r.prepend=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return(r=r.reverse()).forEach(function(t){var r=e.normalize(t,e.first,'prepend').reverse();for(var n in r.forEach(function(t){return e.nodes.unshift(t)}),e.indexes)e.indexes[n]=e.indexes[n]+r.length}),this},r.cleanRaws=function(t){e.prototype.cleanRaws.call(this,t),this.nodes&&this.nodes.forEach(function(e){return e.cleanRaws(t)})},r.insertBefore=function(e,t){var r,n=this,s=0===(e=this.index(e))&&'prepend',i=this.normalize(t,this.nodes[e],s).reverse();for(var o in i.forEach(function(t){return n.nodes.splice(e,0,t)}),this.indexes)r=this.indexes[o],e<=r&&(this.indexes[o]=r+i.length);return this},r.insertAfter=function(e,t){var r=this;e=this.index(e);var n,s=this.normalize(t,this.nodes[e]).reverse();for(var i in s.forEach(function(t){return r.nodes.splice(e+1,0,t)}),this.indexes)n=this.indexes[i],e<n&&(this.indexes[i]=n+s.length);return this},r.remove=function(t){return void 0!==t?(be("Container#remove is deprecated. Use Container#removeChild"),this.removeChild(t)):e.prototype.remove.call(this),this},r.removeChild=function(e){var t;for(var r in e=this.index(e),this.nodes[e].parent=void 0,this.nodes.splice(e,1),this.indexes)(t=this.indexes[r])>=e&&(this.indexes[r]=t-1);return this},r.removeAll=function(){return this.nodes.forEach(function(e){return e.parent=void 0}),this.nodes=[],this},r.replaceValues=function(e,t,r){return r||(r=t,t={}),this.walkDecls(function(n){t.props&&-1===t.props.indexOf(n.prop)||t.fast&&-1===n.value.indexOf(t.fast)||(n.value=n.value.replace(e,r))}),this},r.every=function(e){return this.nodes.every(e)},r.some=function(e){return this.nodes.some(e)},r.index=function(e){return'number'==typeof e?e:this.nodes.indexOf(e)},r.normalize=function(e,t){var r=this;if('string'==typeof e)e=nt(rt(e).nodes);else if(!Array.isArray(e))if('root'===e.type)e=e.nodes;else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error('Value field is missed in node creation');'string'!=typeof e.value&&(e.value=String(e.value)),e=[new Xe(e)]}else if(e.selector)e=[new at(e)];else if(e.name)e=[new it(e)];else{if(!e.text)throw new Error('Unknown node type in node creation');e=[new et(e)]}return e.map(function(e){return void 0===e.raws&&(e=r.rebuild(e)),e.parent&&(e=e.clone()),void 0===e.raws.before&&t&&void 0!==t.raws.before&&(e.raws.before=t.raws.before.replace(/[^\s]/g,'')),e.parent=r,e})},r.rebuild=function(e,t){var r,n=this;for(var s in'root'===e.type?r=new pt:'atrule'===e.type?r=new it:'rule'===e.type?r=new at:'decl'===e.type?r=new Xe:'comment'===e.type&&(r=new et),e)'nodes'===s?r.nodes=e.nodes.map(function(e){return n.rebuild(e,r)}):'parent'===s&&t?r.parent=t:e.hasOwnProperty(s)&&(r[s]=e[s]);return r},r.eachInside=function(e){return be("Container#eachInside is deprecated. Use Container#walk instead."),this.walk(e)},r.eachDecl=function(e,t){return be("Container#eachDecl is deprecated. Use Container#walkDecls instead."),this.walkDecls(e,t)},r.eachRule=function(e,t){return be("Container#eachRule is deprecated. Use Container#walkRules instead."),this.walkRules(e,t)},r.eachAtRule=function(e,t){return be("Container#eachAtRule is deprecated. Use Container#walkAtRules instead."),this.walkAtRules(e,t)},r.eachComment=function(e){return be("Container#eachComment is deprecated. Use Container#walkComments instead."),this.walkComments(e)},R(t,[{key:"first",get:function(){if(this.nodes)return this.nodes[0]}},{key:"last",get:function(){if(this.nodes)return this.nodes[this.nodes.length-1]}},{key:"semicolon",get:function(){return be('Node#semicolon is deprecated. Use Node#raws.semicolon'),this.raws.semicolon},set:function(e){be('Node#semicolon is deprecated. Use Node#raws.semicolon'),this.raws.semicolon=e}},{key:"after",get:function(){return be('Node#after is deprecated. Use Node#raws.after'),this.raws.after},set:function(e){be('Node#after is deprecated. Use Node#raws.after'),this.raws.after=e}}]),t})(Qe),it=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='atrule',r}P(t,e);var r=t.prototype;return r.append=function(){var t;this.nodes||(this.nodes=[]);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.prototype.append).call.apply(t,[this].concat(n))},r.prepend=function(){var t;this.nodes||(this.nodes=[]);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.prototype.prepend).call.apply(t,[this].concat(n))},R(t,[{key:"afterName",get:function(){return be('AtRule#afterName was deprecated. Use AtRule#raws.afterName'),this.raws.afterName},set:function(e){be('AtRule#afterName was deprecated. Use AtRule#raws.afterName'),this.raws.afterName=e}},{key:"_params",get:function(){return be('AtRule#_params was deprecated. Use AtRule#raws.params'),this.raws.params},set:function(e){be('AtRule#_params was deprecated. Use AtRule#raws.params'),this.raws.params=e}}]),t})(st),ot={split:function(e,t,r){for(var n=[],s='',i=!1,o=0,a=!1,u=!1,c=0;c<e.length;c++){var h=e[c];a?u?u=!1:'\\'===h?u=!0:h===a&&(a=!1):'"'===h||"'"===h?a=h:'('===h?o+=1:')'===h?o>0&&(o-=1):0===o&&-1!==t.indexOf(h)&&(i=!0),i?(''!==s&&n.push(s.trim()),s='',i=!1):s+=h}return(r||''!==s)&&n.push(s.trim()),n},space:function(e){return ot.split(e,[' ','\n','\t'])},comma:function(e){return ot.split(e,[','],!0)}},at=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='rule',r.nodes||(r.nodes=[]),r}return P(t,e),R(t,[{key:"selectors",get:function(){return ot.comma(this.selector)},set:function(e){var t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw('between','beforeOpen');this.selector=e.join(r)}},{key:"_selector",get:function(){return be('Rule#_selector is deprecated. Use Rule#raws.selector'),this.raws.selector},set:function(e){be('Rule#_selector is deprecated. Use Rule#raws.selector'),this.raws.selector=e}}]),t})(st),ut=(function(){function e(e,t){if(void 0===t&&(t={}),this.type='warning',this.text=e,t.node&&t.node.source){var r=t.node.positionBy(t);this.line=r.line,this.column=r.column}for(var n in t)this[n]=t[n]}return e.prototype.toString=function(){return this.node?this.node.error(this.text,{plugin:this.plugin,index:this.index,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},e})(),ct=(function(){function e(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}var t=e.prototype;return t.toString=function(){return this.css},t.warn=function(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var r=new ut(e,t);return this.messages.push(r),r},t.warnings=function(){return this.messages.filter(function(e){return'warning'===e.type})},R(e,[{key:"content",get:function(){return this.css}}]),e})();function ht(e){return'object'==typeof e&&'function'==typeof e.then}var ft=(function(){function e(t,r,n){var s;if(this.stringified=!1,this.processed=!1,'object'==typeof r&&'root'===r.type)s=r;else if(r instanceof e||r instanceof ct)s=r.root,r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{var i=rt;n.syntax&&(i=n.syntax.parse),n.parser&&(i=n.parser),i.parse&&(i=i.parse);try{s=i(r,n)}catch(e){this.error=e}}this.result=new ct(t,s,n)}var t=e.prototype;return t.warnings=function(){return this.sync().warnings()},t.toString=function(){return this.css},t.then=function(e,t){return this.async().then(e,t)},t.catch=function(e){return this.async().catch(e)},t.handleError=function(e,t){try{if(this.error=e,'CssSyntaxError'!==e.name||e.plugin){if(t.postcssVersion){var r=t.postcssPlugin,n=t.postcssVersion,s=this.result.processor.version,i=n.split('.'),o=s.split('.');(i[0]!==o[0]||parseInt(i[1])>parseInt(o[1]))&&be("Your current PostCSS version is "+s+", but "+r+" uses "+n+". Perhaps this is the source of the error below.")}}else e.plugin=t.postcssPlugin,e.setMessage()}catch(e){console&&console.error&&console.error(e)}},t.asyncTick=function(e,t){var r=this;if(this.plugin>=this.processor.plugins.length)return this.processed=!0,e();try{var n=this.processor.plugins[this.plugin],s=this.run(n);this.plugin+=1,ht(s)?s.then(function(){r.asyncTick(e,t)}).catch(function(e){r.handleError(e,n),r.processed=!0,t(e)}):this.asyncTick(e,t)}catch(e){this.processed=!0,t(e)}},t.async=function(){var e=this;return this.processed?new Promise(function(t,r){e.error?r(e.error):t(e.stringify())}):this.processing?this.processing:(this.processing=new Promise(function(t,r){if(e.error)return r(e.error);e.plugin=0,e.asyncTick(t,r)}).then(function(){return e.processed=!0,e.stringify()}),this.processing)},t.sync=function(){var e=this;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw new Error('Use process(css).then(cb) to work with async plugins');if(this.error)throw this.error;return this.result.processor.plugins.forEach(function(t){if(ht(e.run(t)))throw new Error('Use process(css).then(cb) to work with async plugins')}),this.result},t.run=function(e){this.result.lastPlugin=e;try{return e(this.result.root,this.result)}catch(t){throw this.handleError(t,e),t}},t.stringify=function(){if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=Ze;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var r='';return t(this.root,function(e){r+=e}),this.result.css=r,this.result},R(e,[{key:"processor",get:function(){return this.result.processor}},{key:"opts",get:function(){return this.result.opts}},{key:"css",get:function(){return this.stringify().css}},{key:"content",get:function(){return this.stringify().content}},{key:"map",get:function(){return this.stringify().map}},{key:"root",get:function(){return this.sync().root}},{key:"messages",get:function(){return this.sync().messages}}]),e})(),lt=(function(){function e(e){void 0===e&&(e=[]),this.version='5.2.0',this.plugins=this.normalize(e)}var t=e.prototype;return t.use=function(e){return this.plugins=this.plugins.concat(this.normalize([e])),this},t.process=function(e,t){return void 0===t&&(t={}),new ft(this,e,t)},t.normalize=function(e){var t=[];return e.forEach(function(e){if(e.postcss&&(e=e.postcss),'object'==typeof e&&Array.isArray(e.plugins))t=t.concat(e.plugins);else{if('function'!=typeof e)throw new Error(e+" is not a PostCSS plugin");t.push(e)}}),t},e})(),pt=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='root',r.nodes||(r.nodes=[]),r}P(t,e);var r=t.prototype;return r.removeChild=function(t){return 0===(t=this.index(t))&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[t].raws.before),e.prototype.removeChild.call(this,t)},r.normalize=function(t,r,n){var s=e.prototype.normalize.call(this,t);return r&&('prepend'===n?this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before:this.first!==r&&s.forEach(function(e){e.raws.before=r.raws.before})),s},r.toResult=function(e){return void 0===e&&(e={}),new ft(new lt,this,e).stringify()},r.remove=function(e){be('Root#remove is deprecated. Use Root#removeChild'),this.removeChild(e)},r.prevMap=function(){return be('Root#prevMap is deprecated. Use Root#source.input.map'),this.source.input.map},t})(st),dt=0,wt=(function(){function e(e,t){void 0===t&&(t={}),this.css=e.toString(),"\ufeff"!==this.css[0]&&"\ufffe"!==this.css[0]||(this.css=this.css.slice(1)),t.from&&(/^\w+:\/\//.test(t.from)?this.file=t.from:this.file=path.resolve(t.from)),this.file||(dt+=1,this.id="<input css "+dt+">"),this.map&&(this.map.file=this.from)}var t=e.prototype;return t.error=function(e,t,r,n){var s;void 0===n&&(n={});var i=this.origin(t,r);return(s=i?new Je(e,i.line,i.column,i.source,i.file,n.plugin):new Je(e,t,r,this.css,this.file,n.plugin)).input={line:t,column:r,source:this.css},this.file&&(s.input.file=this.file),s},t.origin=function(e,t){if(!this.map)return!1;var r=this.map.consumer(),n=r.originalPositionFor({line:e,column:t});if(!n.source)return!1;var s={file:this.mapResolve(n.source),line:n.line,column:n.column},i=r.sourceContentFor(n.source);return i&&(s.source=i),s},t.mapResolve=function(e){return/^\w+:\/\//.test(e)?e:path.resolve(this.map.consumer().sourceRoot||'.',e)},R(e,[{key:"from",get:function(){return this.file||this.id}}]),e})(),mt=(function(e){function t(){return e.apply(this,arguments)||this}P(t,e);var r=t.prototype;return r.tokenize=function(){this.tokens=$e(this.input,{ignoreErrors:!0})},r.comment=function(e){var t=new et;this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]};var r=e[1].slice(2);if('*/'===r.slice(-2)&&(r=r.slice(0,-2)),/^\s*$/.test(r))t.text='',t.raws.left=r,t.raws.right='';else{var n=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},r.unclosedBracket=function(){},r.unknownWord=function(e){var t=this.tokens.slice(e,this.pos+1);this.spaces+=t.map(function(e){return e[1]}).join('')},r.unexpectedClose=function(){this.current.raws.after+='}'},r.doubleColon=function(){},r.unnamedAtrule=function(e){e.name=''},r.precheckMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){var r;for(r=t-1;r>=0&&'word'!==e[r][0];r--);for(r-=1;r>=0;r--)if('space'!==e[r][0]){r+=1;break}var n=e.splice(r,e.length-r);this.decl(n)}},r.checkMissedSemicolon=function(){},r.endFile=function(){for(this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||'')+this.spaces;this.current.parent;)this.current=this.current.parent,this.current.raws.after=''},t})(tt);var vt={},gt=function(e){return'function'==typeof e||'object'==typeof e&&null!==e&&!Array.isArray(e)},yt=function(e){return'__proto__'!==e&&'constructor'!==e&&'prototype'!==e};function bt(e,t,r){var n=e[r];gt(t)&&gt(n)?kt(n,t):e[r]=t}function kt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var s=0,i=r;s<i.length;s++){var o=i[s];if(gt(o))for(var a in o)yt(a)&&bt(e,o[a],a)}return e}var Ct=function(e,t,r){return void 0===r&&(r=B),e.theme!==r.theme&&e.theme||t||r.theme};function St(e){return'string'==typeof e&&!0}function At(e){return St(e)?"styled."+e:"Styled("+C(e)+")"}var xt=f.createContext(),Et=xt.Consumer;function Rt(e,t){return e?S(e)?e(t):Array.isArray(e)||'object'!=typeof e?j(8):t?N({},t,{},e):e:j(14)}var Nt=function(){return!0},Pt=(function(e){function t(){for(var t,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.call.apply(e,[this].concat(n))||this).attrs={},t}P(t,e);var r=t.prototype;return r.render=function(){var e=this;return f.createElement(Et,null,function(t){var r,n=e.props,s=n.$as,i=n.as,o=n.forwardedComponent,a=n.forwardedAs,u=n.forwardedRef,c=n.style,f=void 0===c?[]:c,l=_(n,["$as","as","forwardedComponent","forwardedAs","forwardedRef","style"]),p=o.defaultProps,d=o.target,w=o.shouldForwardProp,m=e.attrs.$as||e.attrs.as||s||i||d,v=e.generateAndInjectStyles(Ct(e.props,t,p)||B,e.props),g=St(m),y=e.attrs!==l?N({},l,{},e.attrs):l,b=w||g&&Nt,k={};for(r in y)'$'!==r[0]&&'as'!==r&&('forwardedAs'===r?k.as=l[r]:b&&!b(r,Nt)||(k[r]=y[r]));return k.style=[v].concat(f),u&&(k.ref=u),a&&(k.as=a),h.createElement(m,k)})},r.buildExecutionContext=function(e,t,r){var n=this,s=N({},t,{theme:e});return r.length?(this.attrs={},r.forEach(function(e){var t,r,i=e;for(r in S(i)&&(i=i(s)),i)t=i[r],n.attrs[r]=t,s[r]=t}),s):s},r.generateAndInjectStyles=function(e,t){var r=t.forwardedComponent.inlineStyle,n=this.buildExecutionContext(e,t,t.forwardedComponent.attrs);return r.generateStyleObject(n)},r.setNativeProps=function(e){void 0!==this.root&&this.root.setNativeProps(e)},t})(h.Component),_t=function(e,t){for(var r=[e[0]],n=0,s=t.length;n<s;n+=1)r.push(t[n],e[n+1]);return r};function Ot(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return S(e)||A(e)?ge(_t(T,[e].concat(r))):0===r.length&&1===e.length&&"string"==typeof e[0]?e:ge(_t(e,r))}function It(e,t,r){if(void 0===r&&(r=B),!c.isValidElementType(t))return j(1,String(t));var n=function(){return e(t,r,Ot.apply(void 0,arguments))};return n.withConfig=function(n){return It(e,t,N({},r,{},n))},n.attrs=function(n){return It(e,t,N({},r,{attrs:Array.prototype.concat(r.attrs,n).filter(Boolean)}))},n}var Ut,Tt=t(o[8]),Bt=(function(e){return function t(r,n,s){var i=n.attrs,o=void 0===i?T:i,a=n.displayName,u=void 0===a?At(r):a,c=n.ParentComponent,h=void 0===c?Pt:c,l=!St(r),p=x(r),d=f.forwardRef(function(e,t){return f.createElement(h,N({},e,{forwardedComponent:d,forwardedRef:t}))}),m=p&&r.attrs?Array.prototype.concat(r.attrs,o).filter(Boolean):o,v=n.shouldForwardProp;return p&&r.shouldForwardProp&&(v=v?function(e,t){return r.shouldForwardProp(e,t)&&n.shouldForwardProp(e,t)}:r.shouldForwardProp),d.attrs=m,d.displayName=u,d.shouldForwardProp=v,d.inlineStyle=new e(p?r.inlineStyle.rules.concat(s):s),d.styledComponentId='StyledNativeComponent',d.target=p?r.target:r,d.withComponent=function(e){n.displayName,n.componentId;var r=N({},_(n,["displayName","componentId"]),{attrs:m,ParentComponent:h});return t(e,r,s)},Object.defineProperty(d,'defaultProps',{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=p?kt({},r.defaultProps,e):e}}),l&&w(d,r,{attrs:!0,displayName:!0,shouldForwardProp:!0,inlineStyle:!0,styledComponentId:!0,target:!0,withComponent:!0}),d}})((Ut=Tt.StyleSheet,(function(){function e(e){this.rules=e}return e.prototype.generateStyleObject=function(e){var t,r,n,s=ge(this.rules,e).join(''),i=y(k(b,s)>>>0);if(!vt[i]){var o=[];(r=new wt(s,t),(n=new mt(r)).tokenize(),n.loop(),n.root).each(function(e){'decl'===e.type&&o.push([e.prop,e.value])});var a=u(o,['borderRadius','borderWidth','borderColor','borderStyle']),c=Ut.create({generated:a});vt[i]=c.generated}return vt[i]},e})())),jt=function(e){return It(Bt,e)};"ActivityIndicator ActivityIndicatorIOS ART Button DatePickerIOS DrawerLayoutAndroid\n Image ImageBackground ImageEditor ImageStore KeyboardAvoidingView ListView MapView Modal NavigatorIOS\n Picker PickerIOS ProgressBarAndroid ProgressViewIOS ScrollView SegmentedControlIOS Slider\n SliderIOS SnapshotViewIOS Switch RecyclerViewBackedScrollView RefreshControl SafeAreaView StatusBar\n SwipeableListView SwitchAndroid SwitchIOS TabBarIOS Text TextInput ToastAndroid ToolbarAndroid\n Touchable TouchableHighlight TouchableNativeFeedback TouchableOpacity TouchableWithoutFeedback\n View ViewPagerAndroid WebView FlatList SectionList VirtualizedList Pressable".split(/\s+/m).forEach(function(e){return Object.defineProperty(jt,e,{enumerable:!0,configurable:!1,get:function(){return jt(Tt[e])}})}),i.ThemeConsumer=Et,i.ThemeContext=xt,i.ThemeProvider=function(e){var t=h.useContext(xt),r=h.useMemo(function(){return Rt(e.theme,t)},[e.theme,t]);return e.children?f.createElement(xt.Provider,{value:r},e.children):null},i.css=Ot,i.default=jt,i.isStyledComponent=x,i.useTheme=function(){return h.useContext(xt)},i.withTheme=function(e){var t=f.forwardRef(function(t,r){var n=h.useContext(xt),s=e.defaultProps,i=Ct(t,n,s);return f.createElement(e,N({},t,{theme:i,ref:r}))});return w(t,e),t.displayName="WithTheme("+C(e)+")",t}},598,[599,405,14,608,609,610,611,404,17]);^~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/android/app/build/generated/assets/react/prod/release/index.android.bundle:604:42476: warning: the variable "path" was not declared in function "e 60#"__d(function(e,t,r,n,s,i,o){'use strict';function a(e){return e&&'object'==typeof e&&'default'in e?e.default:e}Object.defineProperty(i,'__esModule',{value:!0});var u=a(t(o[0])),c=t(o[1]),h=t(o[2]),f=a(h);t(o[3]);var l=a(t(o[4])),p=a(t(o[5])),d=a(t(o[6])),w=a(t(o[7])),m=/(a)(d)/gi,v=52,g=function(e){return String.fromCharCode(e+(e>25?39:97))};function y(e){var t,r='';for(t=Math.abs(e);t>v;t=t/v|0)r=g(t%v)+r;return(g(t%v)+r).replace(m,'$1-$2')}var b=5381,k=function(e,t){for(var r=t.length;r;)e=33*e^t.charCodeAt(--r);return e};function C(e){return e.displayName||e.name||'Component'}function S(e){return'function'==typeof e}var A=function(e){return null!==e&&'object'==typeof e&&'[object Object]'===(e.toString?e.toString():Object.prototype.toString.call(e))&&!c.typeOf(e)};function x(e){return e&&'string'==typeof e.styledComponentId}function E(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 R(e,t,r){return t&&E(e.prototype,t),r&&E(e,r),e}function N(){return(N=Object.assign||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}).apply(this,arguments)}function P(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function _(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(s[r]=e[r]);return s}var O='undefined'!=typeof process&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||'data-styled',I='undefined'!=typeof window&&'HTMLElement'in window,U=Boolean('boolean'==typeof SC_DISABLE_SPEEDY?SC_DISABLE_SPEEDY:'undefined'!=typeof process&&void 0!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&''!==process.env.REACT_APP_SC_DISABLE_SPEEDY?'false'!==process.env.REACT_APP_SC_DISABLE_SPEEDY&&process.env.REACT_APP_SC_DISABLE_SPEEDY:'undefined'!=typeof process&&void 0!==process.env.SC_DISABLE_SPEEDY&&''!==process.env.SC_DISABLE_SPEEDY&&('false'!==process.env.SC_DISABLE_SPEEDY&&process.env.SC_DISABLE_SPEEDY)),T=Object.freeze([]),B=Object.freeze({});function j(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];throw new Error("An error occurred. See https://git.io/JUIaE#"+e+" for more information."+(r.length>0?" Args: "+r.join(', '):''))}var D=512,z=(function(){function e(e){this.groupSizes=new Uint32Array(D),this.length=D,this.tag=e}var t=e.prototype;return t.indexOfGroup=function(e){for(var t=0,r=0;r<e;r++)t+=this.groupSizes[r];return t},t.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var r=this.groupSizes,n=r.length,s=n;e>=s;)(s<<=1)<0&&j(16,""+e);this.groupSizes=new Uint32Array(s),this.groupSizes.set(r),this.length=s;for(var i=n;i<s;i++)this.groupSizes[i]=0}for(var o=this.indexOfGroup(e+1),a=0,u=t.length;a<u;a++)this.tag.insertRule(o,t[a])&&(this.groupSizes[e]++,o++)},t.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],r=this.indexOfGroup(e),n=r+t;this.groupSizes[e]=0;for(var s=r;s<n;s++)this.tag.deleteRule(r)}},t.getGroup=function(e){var t='';if(e>=this.length||0===this.groupSizes[e])return t;for(var r=this.groupSizes[e],n=this.indexOfGroup(e),s=n+r,i=n;i<s;i++)t+=this.tag.getRule(i)+"/*!sc*/\n";return t},e})(),F=new Map,M=new Map,V=1,L=function(e){if(F.has(e))return F.get(e);for(;M.has(V);)V++;var t=V++;return F.set(e,t),M.set(t,e),t},$=function(e){return M.get(e)},Y=function(e,t){F.set(e,t),M.set(t,e)},W="style["+O+"][data-styled-version=\"5.2.1\"]",G=new RegExp("^"+O+"\\.g(\\d+)\\[id=\"([\\w\\d-]+)\"\\].*?\"([^\"]*)"),J=function(e){for(var t=e.getTag(),r=t.length,n='',s=0;s<r;s++){var i=$(s);if(void 0!==i){var o=e.names.get(i),a=t.getGroup(s);if(void 0!==o&&0!==a.length){var u=O+".g"+s+"[id=\""+i+"\"]",c='';void 0!==o&&o.forEach(function(e){e.length>0&&(c+=e+",")}),n+=""+a+u+"{content:\""+c+"\"}/*!sc*/\n"}}}return n},q=function(e,t,r){for(var n,s=r.split(','),i=0,o=s.length;i<o;i++)(n=s[i])&&e.registerName(t,n)},H=function(e,t){for(var r=t.innerHTML.split("/*!sc*/\n"),n=[],s=0,i=r.length;s<i;s++){var o=r[s].trim();if(o){var a=o.match(G);if(a){var u=0|parseInt(a[1],10),c=a[2];0!==u&&(Y(c,u),q(e,c,a[3]),e.getTag().insertRules(u,n)),n.length=0}else n.push(o)}}},Z=function(e){for(var t=document.querySelectorAll(W),r=0,n=t.length;r<n;r++){var s=t[r];s&&"active"!==s.getAttribute(O)&&(H(e,s),s.parentNode&&s.parentNode.removeChild(s))}},K=function(e){for(var t=e.childNodes,r=t.length;r>=0;r--){var n=t[r];if(n&&1===n.nodeType&&n.hasAttribute(O))return n}},Q=function(e){var t=document.head,r=e||t,n=document.createElement('style'),s=K(r),i=void 0!==s?s.nextSibling:null;n.setAttribute(O,"active"),n.setAttribute("data-styled-version","5.2.1");var o='undefined'!=typeof __webpack_nonce__?__webpack_nonce__:null;return o&&n.setAttribute('nonce',o),r.insertBefore(n,i),n},X=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,r=0,n=t.length;r<n;r++){var s=t[r];if(s.ownerNode===e)return s}j(17)},ee=(function(){function e(e){var t=this.element=Q(e);t.appendChild(document.createTextNode('')),this.sheet=X(t),this.length=0}var t=e.prototype;return t.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},t.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},t.getRule=function(e){var t=this.sheet.cssRules[e];return void 0!==t&&'string'==typeof t.cssText?t.cssText:''},e})(),te=(function(){function e(e){var t=this.element=Q(e);this.nodes=t.childNodes,this.length=0}var t=e.prototype;return t.insertRule=function(e,t){if(e<=this.length&&e>=0){var r=document.createTextNode(t),n=this.nodes[e];return this.element.insertBefore(r,n||null),this.length++,!0}return!1},t.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.getRule=function(e){return e<this.length?this.nodes[e].textContent:''},e})(),re=(function(){function e(e){this.rules=[],this.length=0}var t=e.prototype;return t.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},t.deleteRule=function(e){this.rules.splice(e,1),this.length--},t.getRule=function(e){return e<this.length?this.rules[e]:''},e})(),ne=I,se={isServer:!I,useCSSOMInjection:!U},ie=(function(){function e(e,t,r){void 0===e&&(e=B),void 0===t&&(t={}),this.options=N({},se,{},e),this.gs=t,this.names=new Map(r),!this.options.isServer&&I&&ne&&(ne=!1,Z(this))}e.registerId=function(e){return L(e)};var t=e.prototype;return t.reconstructWithOptions=function(t,r){return void 0===r&&(r=!0),new e(N({},this.options,{},t),this.gs,r&&this.names||void 0)},t.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},t.getTag=function(){return this.tag||(this.tag=(t=this.options,r=t.isServer,n=t.useCSSOMInjection,s=t.target,e=r?new re(s):n?new ee(s):new te(s),new z(e)));var e,t,r,n,s},t.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},t.registerName=function(e,t){if(L(e),this.names.has(e))this.names.get(e).add(t);else{var r=new Set;r.add(t),this.names.set(e,r)}},t.insertRules=function(e,t,r){this.registerName(e,t),this.getTag().insertRules(L(e),r)},t.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},t.clearRules=function(e){this.getTag().clearGroup(L(e)),this.clearNames(e)},t.clearTag=function(){this.tag=void 0},t.toString=function(){return J(this)},e})();function oe(e){function t(t){if(t)try{e(t+"}")}catch(e){}}return function(r,n,s,i,o,a,u,c,h,f){switch(r){case 1:if(0===h&&64===n.charCodeAt(0))return e(n+";"),'';break;case 2:if(0===c)return n+"/*|*/";break;case 3:switch(c){case 102:case 112:return e(s[0]+n),'';default:return n+(0===f?"/*|*/":'')}case-2:n.split("/*|*/}").forEach(t)}}}var ae=/^\s*\/\/.*$/gm,ue=[':','[','.','#'];f.createContext().Consumer,f.createContext().Consumer,new ie;var ce=(function(e){var t,r,n,s,i=void 0===e?B:e,o=i.options,a=void 0===o?B:o,u=i.plugins,c=void 0===u?T:u,h=new l(a),f=[],p=oe(function(e){f.push(e)}),d=function(e,n,i){return 0===n&&ue.includes(i[r.length])||i.match(s)?e:"."+t};function w(e,i,o,a){void 0===a&&(a='&');var u=e.replace(ae,''),c=i&&o?o+" "+i+" { "+u+" }":u;return t=a,r=i,n=new RegExp("\\"+r+"\\b",'g'),s=new RegExp("(\\"+r+"\\b){2,}"),h(o||!i?'':i,c)}return h.use([].concat(c,[function(e,t,s){2===e&&s.length&&s[0].lastIndexOf(r)>0&&(s[0]=s[0].replace(n,d))},p,function(e){if(-2===e){var t=f;return f=[],t}}])),w.hash=c.length?c.reduce(function(e,t){return t.name||j(15),k(e,t.name)},b).toString():'',w})(),he=(function(){function e(e,t){var r=this;this.inject=function(e,t){void 0===t&&(t=ce);var n=r.name+t.hash;e.hasNameForId(r.id,n)||e.insertRules(r.id,n,t(r.rules,n,'@keyframes'))},this.toString=function(){return j(12,String(r.name))},this.name=e,this.id="sc-keyframes-"+e,this.rules=t}return e.prototype.getName=function(e){return void 0===e&&(e=ce),this.name+e.hash},e})(),fe=/([A-Z])/,le=/([A-Z])/g,pe=/^ms-/,de=function(e){return"-"+e.toLowerCase()};function we(e){return fe.test(e)?e.replace(le,de).replace(pe,'-ms-'):e}var me=function(e){return void 0===e||null===e||!1===e||''===e},ve=function e(t,r){var n,s,i=[];for(var o in t)t.hasOwnProperty(o)&&!me(t[o])&&(A(t[o])?i.push.apply(i,e(t[o],o)):S(t[o])?i.push(we(o)+":",t[o],';'):i.push(we(o)+": "+(n=o,null==(s=t[o])||'boolean'==typeof s||''===s?'':'number'!=typeof s||0===s||n in p?String(s).trim():s+"px")+";"));return r?[r+" {"].concat(i,['}']):i};function ge(e,t,r,n){if(Array.isArray(e)){for(var s,i=[],o=0,a=e.length;o<a;o+=1)''!==(s=ge(e[o],t,r,n))&&(Array.isArray(s)?i.push.apply(i,s):i.push(s));return i}return me(e)?'':x(e)?"."+e.styledComponentId:S(e)?'function'!=typeof(u=e)||u.prototype&&u.prototype.isReactComponent||!t?e:ge(e(t),t,r,n):e instanceof he?r?(e.inject(r,n),e.getName(n)):e:A(e)?ve(e):e.toString();var u}var ye={};function be(e){ye[e]||(ye[e]=!0,'undefined'!=typeof console&&console.warn&&console.warn(e))}var ke="'".charCodeAt(0),Ce='"'.charCodeAt(0),Se='\\'.charCodeAt(0),Ae='/'.charCodeAt(0),xe='\n'.charCodeAt(0),Ee=' '.charCodeAt(0),Re='\f'.charCodeAt(0),Ne='\t'.charCodeAt(0),Pe='\r'.charCodeAt(0),_e='['.charCodeAt(0),Oe=']'.charCodeAt(0),Ie='('.charCodeAt(0),Ue=')'.charCodeAt(0),Te='{'.charCodeAt(0),Be='}'.charCodeAt(0),je=';'.charCodeAt(0),De='*'.charCodeAt(0),ze=':'.charCodeAt(0),Fe='@'.charCodeAt(0),Me=/[ \n\t\r\f\{\(\)'"\\;/\[\]#]/g,Ve=/[ \n\t\r\f\(\)\{\}:;@!'"\\\]\[#]|\/(?=\*)/g,Le=/.[\\\/\("'\n]/;function $e(e,t){void 0===t&&(t={});var r,n,s,i,o,a,u,c,h,f,l,p,d,w=[],m=e.css.valueOf(),v=t.ignoreErrors,g=m.length,y=-1,b=1,k=0;function C(t){throw e.error("Unclosed "+t,b,k-y)}for(;k<g;){switch(((r=m.charCodeAt(k))===xe||r===Re||r===Pe&&m.charCodeAt(k+1)!==xe)&&(y=k,b+=1),r){case xe:case Ee:case Ne:case Pe:case Re:n=k;do{n+=1,(r=m.charCodeAt(n))===xe&&(y=n,b+=1)}while(r===Ee||r===xe||r===Ne||r===Pe||r===Re);w.push(['space',m.slice(k,n)]),k=n-1;break;case _e:w.push(['[','[',b,k-y]);break;case Oe:w.push([']',']',b,k-y]);break;case Te:w.push(['{','{',b,k-y]);break;case Be:w.push(['}','}',b,k-y]);break;case ze:w.push([':',':',b,k-y]);break;case je:w.push([';',';',b,k-y]);break;case Ie:if(p=w.length?w[w.length-1][1]:'',d=m.charCodeAt(k+1),'url'===p&&d!==ke&&d!==Ce&&d!==Ee&&d!==xe&&d!==Ne&&d!==Re&&d!==Pe){n=k;do{if(f=!1,-1===(n=m.indexOf(')',n+1))){if(v){n=k;break}C('bracket')}for(l=n;m.charCodeAt(l-1)===Se;)l-=1,f=!f}while(f);w.push(['brackets',m.slice(k,n+1),b,k-y,b,n-y]),k=n}else n=m.indexOf(')',k+1),a=m.slice(k,n+1),-1===n||Le.test(a)?w.push(['(','(',b,k-y]):(w.push(['brackets',a,b,k-y,b,n-y]),k=n);break;case Ue:w.push([')',')',b,k-y]);break;case ke:case Ce:s=r===ke?"'":'"',n=k;do{if(f=!1,-1===(n=m.indexOf(s,n+1))){if(v){n=k+1;break}C('quote')}for(l=n;m.charCodeAt(l-1)===Se;)l-=1,f=!f}while(f);(o=(i=(a=m.slice(k,n+1)).split('\n')).length-1)>0?(c=b+o,h=n-i[o].length):(c=b,h=y),w.push(['string',m.slice(k,n+1),b,k-y,c,n-h]),y=h,b=c,k=n;break;case Fe:Me.lastIndex=k+1,Me.test(m),n=0===Me.lastIndex?m.length-1:Me.lastIndex-2,w.push(['at-word',m.slice(k,n+1),b,k-y,b,n-y]),k=n;break;case Se:for(n=k,u=!0;m.charCodeAt(n+1)===Se;)n+=1,u=!u;r=m.charCodeAt(n+1),u&&r!==Ae&&r!==Ee&&r!==xe&&r!==Ne&&r!==Pe&&r!==Re&&(n+=1),w.push(['word',m.slice(k,n+1),b,k-y,b,n-y]),k=n;break;default:r===Ae&&m.charCodeAt(k+1)===De?(0===(n=m.indexOf('*/',k+2)+1)&&(v?n=m.length:C('comment')),(o=(i=(a=m.slice(k,n+1)).split('\n')).length-1)>0?(c=b+o,h=n-i[o].length):(c=b,h=y),w.push(['comment',a,b,k-y,c,n-h]),y=h,b=c,k=n):(Ve.lastIndex=k+1,Ve.test(m),n=0===Ve.lastIndex?m.length-1:Ve.lastIndex-2,w.push(['word',m.slice(k,n+1),b,k-y,b,n-y]),k=n)}k++}return w}var Ye={brackets:[36,39],string:[31,39],'at-word':[31,39],comment:[90,39],'{':[32,39],'}':[32,39],':':[1,22],';':[1,22],'(':[1,22],')':[1,22]};function We(e){return"\x1b["+e+"m"}function Ge(e){var t=[];return $e(new wt(e),{ignoreErrors:!0}).forEach(function(e){var r=Ye[e[0]];r?t.push(e[1].split(/\r?\n/).map(function(e){return We(r[0])+e+We(r[1])}).join('\n')):t.push(e[1])}),t.join('')}var Je=(function(){function e(t,r,n,s,i,o){this.name='CssSyntaxError',this.reason=t,i&&(this.file=i),s&&(this.source=s),o&&(this.plugin=o),void 0!==r&&void 0!==n&&(this.line=r,this.column=n),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}var t=e.prototype;return t.setMessage=function(){this.message=this.plugin?this.plugin+": ":'',this.message+=this.file?this.file:'<css input>',void 0!==this.line&&(this.message+=":"+this.line+":"+this.column),this.message+=": "+this.reason},t.showSourceCode=function(e){var t=this;if(!this.source)return'';var r=this.source;void 0===e&&(e=d),e&&(r=Ge(r));var n=r.split(/\r?\n/),s=Math.max(this.line-3,0),i=Math.min(this.line+2,n.length),o=String(i).length;return n.slice(s,i).map(function(e,r){var n=s+1+r,i=" "+(" "+n).slice(-o)+" | ";return n===t.line?">"+i+e+"\n "+(i.replace(/\d/g,' ')+e.slice(0,t.column-1).replace(/[^\t]/g,' '))+"^":" "+i+e}).join('\n')},t.toString=function(){var e=this.showSourceCode();return e&&(e="\n\n"+e+"\n"),this.name+": "+this.message+e},R(e,[{key:"generated",get:function(){return be('CssSyntaxError#generated is deprecated. Use input instead.'),this.input}}]),e})(),qe={colon:': ',indent:'    ',beforeDecl:'\n',beforeRule:'\n',beforeOpen:' ',beforeClose:'\n',beforeComment:'\n',after:'\n',emptyBody:'',commentLeft:' ',commentRight:' '};var He=(function(){function e(e){this.builder=e}var t=e.prototype;return t.stringify=function(e,t){this[e.type](e,t)},t.root=function(e){this.body(e),e.raws.after&&this.builder(e.raws.after)},t.comment=function(e){var t=this.raw(e,'left','commentLeft'),r=this.raw(e,'right','commentRight');this.builder("/*"+t+e.text+r+"*/",e)},t.decl=function(e,t){var r=this.raw(e,'between','colon'),n=e.prop+r+this.rawValue(e,'value');e.important&&(n+=e.raws.important||' !important'),t&&(n+=';'),this.builder(n,e)},t.rule=function(e){this.block(e,this.rawValue(e,'selector'))},t.atrule=function(e,t){var r="@"+e.name,n=e.params?this.rawValue(e,'params'):'';if(void 0!==e.raws.afterName?r+=e.raws.afterName:n&&(r+=' '),e.nodes)this.block(e,r+n);else{var s=(e.raws.between||'')+(t?';':'');this.builder(r+n+s,e)}},t.body=function(e){for(var t=e.nodes.length-1;t>0&&'comment'===e.nodes[t].type;)t-=1;for(var r=this.raw(e,'semicolon'),n=0;n<e.nodes.length;n++){var s=e.nodes[n],i=this.raw(s,'before');i&&this.builder(i),this.stringify(s,t!==n||r)}},t.block=function(e,t){var r,n=this.raw(e,'between','beforeOpen');this.builder(t+n+"{",e,'start'),e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,'after')):r=this.raw(e,'after','emptyBody'),r&&this.builder(r),this.builder('}',e,'end')},t.raw=function(e,t,r){var n;if(r||(r=t),t&&void 0!==(n=e.raws[t]))return n;var s=e.parent;if('before'===r&&(!s||'root'===s.type&&s.first===e))return'';if(!s)return qe[r];var i=e.root();if(i.rawCache||(i.rawCache={}),void 0!==i.rawCache[r])return i.rawCache[r];if('before'===r||'after'===r)return this.beforeAfter(e,r);var o,a="raw"+((o=r)[0].toUpperCase()+o.slice(1));return this[a]?n=this[a](i,e):i.walk(function(e){if(void 0!==(n=e.raws[t]))return!1}),void 0===n&&(n=qe[r]),i.rawCache[r]=n,n},t.rawSemicolon=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length&&'decl'===e.last.type&&void 0!==(t=e.raws.semicolon))return!1}),t},t.rawEmptyBody=function(e){var t;return e.walk(function(e){if(e.nodes&&0===e.nodes.length&&void 0!==(t=e.raws.after))return!1}),t},t.rawIndent=function(e){return e.raws.indent?e.raws.indent:(e.walk(function(r){var n=r.parent;if(n&&n!==e&&n.parent&&n.parent===e&&void 0!==r.raws.before){var s=r.raws.before.split('\n');return t=(t=s[s.length-1]).replace(/[^\s]/g,''),!1}}),t);var t},t.rawBeforeComment=function(e,t){var r;return e.walkComments(function(e){if(void 0!==e.raws.before)return-1!==(r=e.raws.before).indexOf('\n')&&(r=r.replace(/[^\n]+$/,'')),!1}),void 0===r&&(r=this.raw(t,null,'beforeDecl')),r},t.rawBeforeDecl=function(e,t){var r;return e.walkDecls(function(e){if(void 0!==e.raws.before)return-1!==(r=e.raws.before).indexOf('\n')&&(r=r.replace(/[^\n]+$/,'')),!1}),void 0===r&&(r=this.raw(t,null,'beforeRule')),r},t.rawBeforeRule=function(e){var t;return e.walk(function(r){if(r.nodes&&(r.parent!==e||e.first!==r)&&void 0!==r.raws.before)return-1!==(t=r.raws.before).indexOf('\n')&&(t=t.replace(/[^\n]+$/,'')),!1}),t},t.rawBeforeClose=function(e){var t;return e.walk(function(e){if(e.nodes&&e.nodes.length>0&&void 0!==e.raws.after)return-1!==(t=e.raws.after).indexOf('\n')&&(t=t.replace(/[^\n]+$/,'')),!1}),t},t.rawBeforeOpen=function(e){var t;return e.walk(function(e){if('decl'!==e.type&&void 0!==(t=e.raws.between))return!1}),t},t.rawColon=function(e){var t;return e.walkDecls(function(e){if(void 0!==e.raws.between)return t=e.raws.between.replace(/[^\s:]/g,''),!1}),t},t.beforeAfter=function(e,t){var r;r='decl'===e.type?this.raw(e,null,'beforeDecl'):'comment'===e.type?this.raw(e,null,'beforeComment'):'before'===t?this.raw(e,null,'beforeRule'):this.raw(e,null,'beforeClose');for(var n=e.parent,s=0;n&&'root'!==n.type;)s+=1,n=n.parent;if(-1!==r.indexOf('\n')){var i=this.raw(e,null,'indent');if(i.length)for(var o=0;o<s;o++)r+=i}return r},t.rawValue=function(e,t){var r=e[t],n=e.raws[t];return n&&n.value===r?n.raw:r},e})();function Ze(e,t){new He(t).stringify(e)}var Ke=function e(t,r){var n=new t.constructor;for(var s in t)if(t.hasOwnProperty(s)){var i=t[s],o=typeof i;'parent'===s&&'object'===o?r&&(n[s]=r):'source'===s?n[s]=i:i instanceof Array?n[s]=i.map(function(t){return e(t,n)}):'before'!==s&&'after'!==s&&'between'!==s&&'semicolon'!==s&&('object'===o&&null!==i&&(i=e(i)),n[s]=i)}return n},Qe=(function(){function e(e){for(var t in void 0===e&&(e={}),this.raws={},e)this[t]=e[t]}var t=e.prototype;return t.error=function(e,t){if(void 0===t&&(t={}),this.source){var r=this.positionBy(t);return this.source.input.error(e,r.line,r.column,t)}return new Je(e)},t.warn=function(e,t,r){var n={node:this};for(var s in r)n[s]=r[s];return e.warn(t,n)},t.remove=function(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this},t.toString=function(e){void 0===e&&(e=Ze),e.stringify&&(e=e.stringify);var t='';return e(this,function(e){t+=e}),t},t.clone=function(e){void 0===e&&(e={});var t=Ke(this);for(var r in e)t[r]=e[r];return t},t.cloneBefore=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertBefore(this,t),t},t.cloneAfter=function(e){void 0===e&&(e={});var t=this.clone(e);return this.parent.insertAfter(this,t),t},t.replaceWith=function(){var e=this;if(this.parent){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach(function(t){e.parent.insertBefore(e,t)}),this.remove()}return this},t.moveTo=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.append(this),this},t.moveBefore=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.parent.insertBefore(e,this),this},t.moveAfter=function(e){return this.cleanRaws(this.root()===e.root()),this.remove(),e.parent.insertAfter(e,this),this},t.next=function(){var e=this.parent.index(this);return this.parent.nodes[e+1]},t.prev=function(){var e=this.parent.index(this);return this.parent.nodes[e-1]},t.toJSON=function(){var e={};for(var t in this)if(this.hasOwnProperty(t)&&'parent'!==t){var r=this[t];r instanceof Array?e[t]=r.map(function(e){return'object'==typeof e&&e.toJSON?e.toJSON():e}):'object'==typeof r&&r.toJSON?e[t]=r.toJSON():e[t]=r}return e},t.raw=function(e,t){return(new He).raw(this,e,t)},t.root=function(){for(var e=this;e.parent;)e=e.parent;return e},t.cleanRaws=function(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between},t.positionInside=function(e){for(var t=this.toString(),r=this.source.start.column,n=this.source.start.line,s=0;s<e;s++)'\n'===t[s]?(r=1,n+=1):r+=1;return{line:n,column:r}},t.positionBy=function(e){var t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){var r=this.toString().indexOf(e.word);-1!==r&&(t=this.positionInside(r))}return t},t.removeSelf=function(){return be('Node#removeSelf is deprecated. Use Node#remove.'),this.remove()},t.replace=function(e){return be('Node#replace is deprecated. Use Node#replaceWith'),this.replaceWith(e)},t.style=function(e,t){return be('Node#style() is deprecated. Use Node#raw()'),this.raw(e,t)},t.cleanStyles=function(e){return be('Node#cleanStyles() is deprecated. Use Node#cleanRaws()'),this.cleanRaws(e)},R(e,[{key:"before",get:function(){return be('Node#before is deprecated. Use Node#raws.before'),this.raws.before},set:function(e){be('Node#before is deprecated. Use Node#raws.before'),this.raws.before=e}},{key:"between",get:function(){return be('Node#between is deprecated. Use Node#raws.between'),this.raws.between},set:function(e){be('Node#between is deprecated. Use Node#raws.between'),this.raws.between=e}}]),e})(),Xe=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='decl',r}return P(t,e),R(t,[{key:"_value",get:function(){return be('Node#_value was deprecated. Use Node#raws.value'),this.raws.value},set:function(e){be('Node#_value was deprecated. Use Node#raws.value'),this.raws.value=e}},{key:"_important",get:function(){return be('Node#_important was deprecated. Use Node#raws.important'),this.raws.important},set:function(e){be('Node#_important was deprecated. Use Node#raws.important'),this.raws.important=e}}]),t})(Qe),et=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='comment',r}return P(t,e),R(t,[{key:"left",get:function(){return be('Comment#left was deprecated. Use Comment#raws.left'),this.raws.left},set:function(e){be('Comment#left was deprecated. Use Comment#raws.left'),this.raws.left=e}},{key:"right",get:function(){return be('Comment#right was deprecated. Use Comment#raws.right'),this.raws.right},set:function(e){be('Comment#right was deprecated. Use Comment#raws.right'),this.raws.right=e}}]),t})(Qe),tt=(function(){function e(e){this.input=e,this.pos=0,this.root=new pt,this.current=this.root,this.spaces='',this.semicolon=!1,this.root.source={input:e,start:{line:1,column:1}}}var t=e.prototype;return t.tokenize=function(){this.tokens=$e(this.input)},t.loop=function(){for(var e;this.pos<this.tokens.length;){switch((e=this.tokens[this.pos])[0]){case'space':case';':this.spaces+=e[1];break;case'}':this.end(e);break;case'comment':this.comment(e);break;case'at-word':this.atrule(e);break;case'{':this.emptyRule(e);break;default:this.other()}this.pos+=1}this.endFile()},t.comment=function(e){var t=new et;this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]};var r=e[1].slice(2,-2);if(/^\s*$/.test(r))t.text='',t.raws.left=r,t.raws.right='';else{var n=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},t.emptyRule=function(e){var t=new at;this.init(t,e[2],e[3]),t.selector='',t.raws.between='',this.current=t},t.other=function(){for(var e,t=!1,r=null,n=!1,s=null,i=[],o=this.pos;this.pos<this.tokens.length;){if('('===(r=(e=this.tokens[this.pos])[0])||'['===r)s||(s=e),i.push('('===r?')':']');else if(0===i.length){if(';'===r){if(n)return void this.decl(this.tokens.slice(o,this.pos+1));break}if('{'===r)return void this.rule(this.tokens.slice(o,this.pos+1));if('}'===r){this.pos-=1,t=!0;break}':'===r&&(n=!0)}else r===i[i.length-1]&&(i.pop(),0===i.length&&(s=null));this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,t=!0),i.length>0&&this.unclosedBracket(s),t&&n){for(;this.pos>o&&('space'===(e=this.tokens[this.pos][0])||'comment'===e);)this.pos-=1;this.decl(this.tokens.slice(o,this.pos+1))}else this.unknownWord(o)},t.rule=function(e){e.pop();var t=new at;this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesFromEnd(e),this.raw(t,'selector',e),this.current=t},t.decl=function(e){var t=new Xe;this.init(t);var r,n=e[e.length-1];for(';'===n[0]&&(this.semicolon=!0,e.pop()),n[4]?t.source.end={line:n[4],column:n[5]}:t.source.end={line:n[2],column:n[3]};'word'!==e[0][0];)t.raws.before+=e.shift()[1];for(t.source.start={line:e[0][2],column:e[0][3]},t.prop='';e.length;){var s=e[0][0];if(':'===s||'space'===s||'comment'===s)break;t.prop+=e.shift()[1]}for(t.raws.between='';e.length;){if(':'===(r=e.shift())[0]){t.raws.between+=r[1];break}t.raws.between+=r[1]}'_'!==t.prop[0]&&'*'!==t.prop[0]||(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesFromStart(e),this.precheckMissedSemicolon(e);for(var i=e.length-1;i>0;i--){if('!important'===(r=e[i])[1]){t.important=!0;var o=this.stringFrom(e,i);' !important'!==(o=this.spacesFromEnd(e)+o)&&(t.raws.important=o);break}if('important'===r[1]){for(var a=e.slice(0),u='',c=i;c>0;c--){var h=a[c][0];if(0===u.trim().indexOf('!')&&'space'!==h)break;u=a.pop()[1]+u}0===u.trim().indexOf('!')&&(t.important=!0,t.raws.important=u,e=a)}if('space'!==r[0]&&'comment'!==r[0])break}this.raw(t,'value',e),-1!==t.value.indexOf(':')&&this.checkMissedSemicolon(e)},t.atrule=function(e){var t=new it;t.name=e[1].slice(1),''===t.name&&this.unnamedAtrule(t,e),this.init(t,e[2],e[3]);var r=!1,n=!1,s=[];for(this.pos+=1;this.pos<this.tokens.length;){if(';'===(e=this.tokens[this.pos])[0]){t.source.end={line:e[2],column:e[3]},this.semicolon=!0;break}if('{'===e[0]){n=!0;break}if('}'===e[0]){this.end(e);break}s.push(e),this.pos+=1}this.pos===this.tokens.length&&(r=!0),t.raws.between=this.spacesFromEnd(s),s.length?(t.raws.afterName=this.spacesFromStart(s),this.raw(t,'params',s),r&&(e=s[s.length-1],t.source.end={line:e[4],column:e[5]},this.spaces=t.raws.between,t.raws.between='')):(t.raws.afterName='',t.params=''),n&&(t.nodes=[],this.current=t)},t.end=function(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||'')+this.spaces,this.spaces='',this.current.parent?(this.current.source.end={line:e[2],column:e[3]},this.current=this.current.parent):this.unexpectedClose(e)},t.endFile=function(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||'')+this.spaces},t.init=function(e,t,r){this.current.push(e),e.source={start:{line:t,column:r},input:this.input},e.raws.before=this.spaces,this.spaces='','comment'!==e.type&&(this.semicolon=!1)},t.raw=function(e,t,r){for(var n,s,i=r.length,o='',a=!0,u=0;u<i;u+=1)'comment'===(s=(n=r[u])[0])||'space'===s&&u===i-1?a=!1:o+=n[1];if(!a){var c=r.reduce(function(e,t){return e+t[1]},'');e.raws[t]={value:o,raw:c}}e[t]=o},t.spacesFromEnd=function(e){for(var t,r='';e.length&&('space'===(t=e[e.length-1][0])||'comment'===t);)r=e.pop()[1]+r;return r},t.spacesFromStart=function(e){for(var t,r='';e.length&&('space'===(t=e[0][0])||'comment'===t);)r+=e.shift()[1];return r},t.stringFrom=function(e,t){for(var r='',n=t;n<e.length;n++)r+=e[n][1];return e.splice(t,e.length-t),r},t.colon=function(e){for(var t,r,n,s=0,i=0;i<e.length;i++){if('('===(r=(t=e[i])[0]))s+=1;else if(')'===r)s-=1;else if(0===s&&':'===r){if(n){if('word'===n[0]&&'progid'===n[1])continue;return i}this.doubleColon(t)}n=t}return!1},t.unclosedBracket=function(e){throw this.input.error('Unclosed bracket',e[2],e[3])},t.unknownWord=function(e){var t=this.tokens[e];throw this.input.error('Unknown word',t[2],t[3])},t.unexpectedClose=function(e){throw this.input.error('Unexpected }',e[2],e[3])},t.unclosedBlock=function(){var e=this.current.source.start;throw this.input.error('Unclosed block',e.line,e.column)},t.doubleColon=function(e){throw this.input.error('Double colon',e[2],e[3])},t.unnamedAtrule=function(e,t){throw this.input.error('At-rule without name',t[2],t[3])},t.precheckMissedSemicolon=function(e){},t.checkMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){for(var r,n=0,s=t-1;s>=0&&('space'===(r=e[s])[0]||2!==(n+=1));s--);throw this.input.error('Missed semicolon',r[2],r[3])}},e})();function rt(e,t){if(t&&t.safe)throw new Error("Option safe was removed. Use parser: require(\"postcss-safe-parser\")");var r=new wt(e,t),n=new tt(r);try{n.tokenize(),n.loop()}catch(e){throw'CssSyntaxError'===e.name&&t&&t.from&&(/\.scss$/i.test(t.from)?e.message+="\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser":/\.less$/i.test(t.from)&&(e.message+="\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser")),e}return n.root}function nt(e){return e.map(function(e){return e.nodes&&(e.nodes=nt(e.nodes)),delete e.source,e})}var st=(function(e){function t(){return e.apply(this,arguments)||this}P(t,e);var r=t.prototype;return r.push=function(e){return e.parent=this,this.nodes.push(e),this},r.each=function(e){this.lastEach||(this.lastEach=0),this.indexes||(this.indexes={}),this.lastEach+=1;var t=this.lastEach;if(this.indexes[t]=0,this.nodes){for(var r,n;this.indexes[t]<this.nodes.length&&(r=this.indexes[t],!1!==(n=e(this.nodes[r],r)));)this.indexes[t]+=1;return delete this.indexes[t],n}},r.walk=function(e){return this.each(function(t,r){var n=e(t,r);return!1!==n&&t.walk&&(n=t.walk(e)),n})},r.walkDecls=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('decl'===r.type&&e.test(r.prop))return t(r,n)}):this.walk(function(r,n){if('decl'===r.type&&r.prop===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('decl'===e.type)return t(e,r)}))},r.walkRules=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('rule'===r.type&&e.test(r.selector))return t(r,n)}):this.walk(function(r,n){if('rule'===r.type&&r.selector===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('rule'===e.type)return t(e,r)}))},r.walkAtRules=function(e,t){return t?e instanceof RegExp?this.walk(function(r,n){if('atrule'===r.type&&e.test(r.name))return t(r,n)}):this.walk(function(r,n){if('atrule'===r.type&&r.name===e)return t(r,n)}):(t=e,this.walk(function(e,r){if('atrule'===e.type)return t(e,r)}))},r.walkComments=function(e){return this.walk(function(t,r){if('comment'===t.type)return e(t,r)})},r.append=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach(function(t){e.normalize(t,e.last).forEach(function(t){return e.nodes.push(t)})}),this},r.prepend=function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return(r=r.reverse()).forEach(function(t){var r=e.normalize(t,e.first,'prepend').reverse();for(var n in r.forEach(function(t){return e.nodes.unshift(t)}),e.indexes)e.indexes[n]=e.indexes[n]+r.length}),this},r.cleanRaws=function(t){e.prototype.cleanRaws.call(this,t),this.nodes&&this.nodes.forEach(function(e){return e.cleanRaws(t)})},r.insertBefore=function(e,t){var r,n=this,s=0===(e=this.index(e))&&'prepend',i=this.normalize(t,this.nodes[e],s).reverse();for(var o in i.forEach(function(t){return n.nodes.splice(e,0,t)}),this.indexes)r=this.indexes[o],e<=r&&(this.indexes[o]=r+i.length);return this},r.insertAfter=function(e,t){var r=this;e=this.index(e);var n,s=this.normalize(t,this.nodes[e]).reverse();for(var i in s.forEach(function(t){return r.nodes.splice(e+1,0,t)}),this.indexes)n=this.indexes[i],e<n&&(this.indexes[i]=n+s.length);return this},r.remove=function(t){return void 0!==t?(be("Container#remove is deprecated. Use Container#removeChild"),this.removeChild(t)):e.prototype.remove.call(this),this},r.removeChild=function(e){var t;for(var r in e=this.index(e),this.nodes[e].parent=void 0,this.nodes.splice(e,1),this.indexes)(t=this.indexes[r])>=e&&(this.indexes[r]=t-1);return this},r.removeAll=function(){return this.nodes.forEach(function(e){return e.parent=void 0}),this.nodes=[],this},r.replaceValues=function(e,t,r){return r||(r=t,t={}),this.walkDecls(function(n){t.props&&-1===t.props.indexOf(n.prop)||t.fast&&-1===n.value.indexOf(t.fast)||(n.value=n.value.replace(e,r))}),this},r.every=function(e){return this.nodes.every(e)},r.some=function(e){return this.nodes.some(e)},r.index=function(e){return'number'==typeof e?e:this.nodes.indexOf(e)},r.normalize=function(e,t){var r=this;if('string'==typeof e)e=nt(rt(e).nodes);else if(!Array.isArray(e))if('root'===e.type)e=e.nodes;else if(e.type)e=[e];else if(e.prop){if(void 0===e.value)throw new Error('Value field is missed in node creation');'string'!=typeof e.value&&(e.value=String(e.value)),e=[new Xe(e)]}else if(e.selector)e=[new at(e)];else if(e.name)e=[new it(e)];else{if(!e.text)throw new Error('Unknown node type in node creation');e=[new et(e)]}return e.map(function(e){return void 0===e.raws&&(e=r.rebuild(e)),e.parent&&(e=e.clone()),void 0===e.raws.before&&t&&void 0!==t.raws.before&&(e.raws.before=t.raws.before.replace(/[^\s]/g,'')),e.parent=r,e})},r.rebuild=function(e,t){var r,n=this;for(var s in'root'===e.type?r=new pt:'atrule'===e.type?r=new it:'rule'===e.type?r=new at:'decl'===e.type?r=new Xe:'comment'===e.type&&(r=new et),e)'nodes'===s?r.nodes=e.nodes.map(function(e){return n.rebuild(e,r)}):'parent'===s&&t?r.parent=t:e.hasOwnProperty(s)&&(r[s]=e[s]);return r},r.eachInside=function(e){return be("Container#eachInside is deprecated. Use Container#walk instead."),this.walk(e)},r.eachDecl=function(e,t){return be("Container#eachDecl is deprecated. Use Container#walkDecls instead."),this.walkDecls(e,t)},r.eachRule=function(e,t){return be("Container#eachRule is deprecated. Use Container#walkRules instead."),this.walkRules(e,t)},r.eachAtRule=function(e,t){return be("Container#eachAtRule is deprecated. Use Container#walkAtRules instead."),this.walkAtRules(e,t)},r.eachComment=function(e){return be("Container#eachComment is deprecated. Use Container#walkComments instead."),this.walkComments(e)},R(t,[{key:"first",get:function(){if(this.nodes)return this.nodes[0]}},{key:"last",get:function(){if(this.nodes)return this.nodes[this.nodes.length-1]}},{key:"semicolon",get:function(){return be('Node#semicolon is deprecated. Use Node#raws.semicolon'),this.raws.semicolon},set:function(e){be('Node#semicolon is deprecated. Use Node#raws.semicolon'),this.raws.semicolon=e}},{key:"after",get:function(){return be('Node#after is deprecated. Use Node#raws.after'),this.raws.after},set:function(e){be('Node#after is deprecated. Use Node#raws.after'),this.raws.after=e}}]),t})(Qe),it=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='atrule',r}P(t,e);var r=t.prototype;return r.append=function(){var t;this.nodes||(this.nodes=[]);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.prototype.append).call.apply(t,[this].concat(n))},r.prepend=function(){var t;this.nodes||(this.nodes=[]);for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.prototype.prepend).call.apply(t,[this].concat(n))},R(t,[{key:"afterName",get:function(){return be('AtRule#afterName was deprecated. Use AtRule#raws.afterName'),this.raws.afterName},set:function(e){be('AtRule#afterName was deprecated. Use AtRule#raws.afterName'),this.raws.afterName=e}},{key:"_params",get:function(){return be('AtRule#_params was deprecated. Use AtRule#raws.params'),this.raws.params},set:function(e){be('AtRule#_params was deprecated. Use AtRule#raws.params'),this.raws.params=e}}]),t})(st),ot={split:function(e,t,r){for(var n=[],s='',i=!1,o=0,a=!1,u=!1,c=0;c<e.length;c++){var h=e[c];a?u?u=!1:'\\'===h?u=!0:h===a&&(a=!1):'"'===h||"'"===h?a=h:'('===h?o+=1:')'===h?o>0&&(o-=1):0===o&&-1!==t.indexOf(h)&&(i=!0),i?(''!==s&&n.push(s.trim()),s='',i=!1):s+=h}return(r||''!==s)&&n.push(s.trim()),n},space:function(e){return ot.split(e,[' ','\n','\t'])},comma:function(e){return ot.split(e,[','],!0)}},at=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='rule',r.nodes||(r.nodes=[]),r}return P(t,e),R(t,[{key:"selectors",get:function(){return ot.comma(this.selector)},set:function(e){var t=this.selector?this.selector.match(/,\s*/):null,r=t?t[0]:","+this.raw('between','beforeOpen');this.selector=e.join(r)}},{key:"_selector",get:function(){return be('Rule#_selector is deprecated. Use Rule#raws.selector'),this.raws.selector},set:function(e){be('Rule#_selector is deprecated. Use Rule#raws.selector'),this.raws.selector=e}}]),t})(st),ut=(function(){function e(e,t){if(void 0===t&&(t={}),this.type='warning',this.text=e,t.node&&t.node.source){var r=t.node.positionBy(t);this.line=r.line,this.column=r.column}for(var n in t)this[n]=t[n]}return e.prototype.toString=function(){return this.node?this.node.error(this.text,{plugin:this.plugin,index:this.index,word:this.word}).message:this.plugin?this.plugin+": "+this.text:this.text},e})(),ct=(function(){function e(e,t,r){this.processor=e,this.messages=[],this.root=t,this.opts=r,this.css=void 0,this.map=void 0}var t=e.prototype;return t.toString=function(){return this.css},t.warn=function(e,t){void 0===t&&(t={}),t.plugin||this.lastPlugin&&this.lastPlugin.postcssPlugin&&(t.plugin=this.lastPlugin.postcssPlugin);var r=new ut(e,t);return this.messages.push(r),r},t.warnings=function(){return this.messages.filter(function(e){return'warning'===e.type})},R(e,[{key:"content",get:function(){return this.css}}]),e})();function ht(e){return'object'==typeof e&&'function'==typeof e.then}var ft=(function(){function e(t,r,n){var s;if(this.stringified=!1,this.processed=!1,'object'==typeof r&&'root'===r.type)s=r;else if(r instanceof e||r instanceof ct)s=r.root,r.map&&(void 0===n.map&&(n.map={}),n.map.inline||(n.map.inline=!1),n.map.prev=r.map);else{var i=rt;n.syntax&&(i=n.syntax.parse),n.parser&&(i=n.parser),i.parse&&(i=i.parse);try{s=i(r,n)}catch(e){this.error=e}}this.result=new ct(t,s,n)}var t=e.prototype;return t.warnings=function(){return this.sync().warnings()},t.toString=function(){return this.css},t.then=function(e,t){return this.async().then(e,t)},t.catch=function(e){return this.async().catch(e)},t.handleError=function(e,t){try{if(this.error=e,'CssSyntaxError'!==e.name||e.plugin){if(t.postcssVersion){var r=t.postcssPlugin,n=t.postcssVersion,s=this.result.processor.version,i=n.split('.'),o=s.split('.');(i[0]!==o[0]||parseInt(i[1])>parseInt(o[1]))&&be("Your current PostCSS version is "+s+", but "+r+" uses "+n+". Perhaps this is the source of the error below.")}}else e.plugin=t.postcssPlugin,e.setMessage()}catch(e){console&&console.error&&console.error(e)}},t.asyncTick=function(e,t){var r=this;if(this.plugin>=this.processor.plugins.length)return this.processed=!0,e();try{var n=this.processor.plugins[this.plugin],s=this.run(n);this.plugin+=1,ht(s)?s.then(function(){r.asyncTick(e,t)}).catch(function(e){r.handleError(e,n),r.processed=!0,t(e)}):this.asyncTick(e,t)}catch(e){this.processed=!0,t(e)}},t.async=function(){var e=this;return this.processed?new Promise(function(t,r){e.error?r(e.error):t(e.stringify())}):this.processing?this.processing:(this.processing=new Promise(function(t,r){if(e.error)return r(e.error);e.plugin=0,e.asyncTick(t,r)}).then(function(){return e.processed=!0,e.stringify()}),this.processing)},t.sync=function(){var e=this;if(this.processed)return this.result;if(this.processed=!0,this.processing)throw new Error('Use process(css).then(cb) to work with async plugins');if(this.error)throw this.error;return this.result.processor.plugins.forEach(function(t){if(ht(e.run(t)))throw new Error('Use process(css).then(cb) to work with async plugins')}),this.result},t.run=function(e){this.result.lastPlugin=e;try{return e(this.result.root,this.result)}catch(t){throw this.handleError(t,e),t}},t.stringify=function(){if(this.stringified)return this.result;this.stringified=!0,this.sync();var e=this.result.opts,t=Ze;e.syntax&&(t=e.syntax.stringify),e.stringifier&&(t=e.stringifier),t.stringify&&(t=t.stringify);var r='';return t(this.root,function(e){r+=e}),this.result.css=r,this.result},R(e,[{key:"processor",get:function(){return this.result.processor}},{key:"opts",get:function(){return this.result.opts}},{key:"css",get:function(){return this.stringify().css}},{key:"content",get:function(){return this.stringify().content}},{key:"map",get:function(){return this.stringify().map}},{key:"root",get:function(){return this.sync().root}},{key:"messages",get:function(){return this.sync().messages}}]),e})(),lt=(function(){function e(e){void 0===e&&(e=[]),this.version='5.2.0',this.plugins=this.normalize(e)}var t=e.prototype;return t.use=function(e){return this.plugins=this.plugins.concat(this.normalize([e])),this},t.process=function(e,t){return void 0===t&&(t={}),new ft(this,e,t)},t.normalize=function(e){var t=[];return e.forEach(function(e){if(e.postcss&&(e=e.postcss),'object'==typeof e&&Array.isArray(e.plugins))t=t.concat(e.plugins);else{if('function'!=typeof e)throw new Error(e+" is not a PostCSS plugin");t.push(e)}}),t},e})(),pt=(function(e){function t(t){var r;return(r=e.call(this,t)||this).type='root',r.nodes||(r.nodes=[]),r}P(t,e);var r=t.prototype;return r.removeChild=function(t){return 0===(t=this.index(t))&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[t].raws.before),e.prototype.removeChild.call(this,t)},r.normalize=function(t,r,n){var s=e.prototype.normalize.call(this,t);return r&&('prepend'===n?this.nodes.length>1?r.raws.before=this.nodes[1].raws.before:delete r.raws.before:this.first!==r&&s.forEach(function(e){e.raws.before=r.raws.before})),s},r.toResult=function(e){return void 0===e&&(e={}),new ft(new lt,this,e).stringify()},r.remove=function(e){be('Root#remove is deprecated. Use Root#removeChild'),this.removeChild(e)},r.prevMap=function(){return be('Root#prevMap is deprecated. Use Root#source.input.map'),this.source.input.map},t})(st),dt=0,wt=(function(){function e(e,t){void 0===t&&(t={}),this.css=e.toString(),"\ufeff"!==this.css[0]&&"\ufffe"!==this.css[0]||(this.css=this.css.slice(1)),t.from&&(/^\w+:\/\//.test(t.from)?this.file=t.from:this.file=path.resolve(t.from)),this.file||(dt+=1,this.id="<input css "+dt+">"),this.map&&(this.map.file=this.from)}var t=e.prototype;return t.error=function(e,t,r,n){var s;void 0===n&&(n={});var i=this.origin(t,r);return(s=i?new Je(e,i.line,i.column,i.source,i.file,n.plugin):new Je(e,t,r,this.css,this.file,n.plugin)).input={line:t,column:r,source:this.css},this.file&&(s.input.file=this.file),s},t.origin=function(e,t){if(!this.map)return!1;var r=this.map.consumer(),n=r.originalPositionFor({line:e,column:t});if(!n.source)return!1;var s={file:this.mapResolve(n.source),line:n.line,column:n.column},i=r.sourceContentFor(n.source);return i&&(s.source=i),s},t.mapResolve=function(e){return/^\w+:\/\//.test(e)?e:path.resolve(this.map.consumer().sourceRoot||'.',e)},R(e,[{key:"from",get:function(){return this.file||this.id}}]),e})(),mt=(function(e){function t(){return e.apply(this,arguments)||this}P(t,e);var r=t.prototype;return r.tokenize=function(){this.tokens=$e(this.input,{ignoreErrors:!0})},r.comment=function(e){var t=new et;this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]};var r=e[1].slice(2);if('*/'===r.slice(-2)&&(r=r.slice(0,-2)),/^\s*$/.test(r))t.text='',t.raws.left=r,t.raws.right='';else{var n=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=n[2],t.raws.left=n[1],t.raws.right=n[3]}},r.unclosedBracket=function(){},r.unknownWord=function(e){var t=this.tokens.slice(e,this.pos+1);this.spaces+=t.map(function(e){return e[1]}).join('')},r.unexpectedClose=function(){this.current.raws.after+='}'},r.doubleColon=function(){},r.unnamedAtrule=function(e){e.name=''},r.precheckMissedSemicolon=function(e){var t=this.colon(e);if(!1!==t){var r;for(r=t-1;r>=0&&'word'!==e[r][0];r--);for(r-=1;r>=0;r--)if('space'!==e[r][0]){r+=1;break}var n=e.splice(r,e.length-r);this.decl(n)}},r.checkMissedSemicolon=function(){},r.endFile=function(){for(this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||'')+this.spaces;this.current.parent;)this.current=this.current.parent,this.current.raws.after=''},t})(tt);var vt={},gt=function(e){return'function'==typeof e||'object'==typeof e&&null!==e&&!Array.isArray(e)},yt=function(e){return'__proto__'!==e&&'constructor'!==e&&'prototype'!==e};function bt(e,t,r){var n=e[r];gt(t)&&gt(n)?kt(n,t):e[r]=t}function kt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var s=0,i=r;s<i.length;s++){var o=i[s];if(gt(o))for(var a in o)yt(a)&&bt(e,o[a],a)}return e}var Ct=function(e,t,r){return void 0===r&&(r=B),e.theme!==r.theme&&e.theme||t||r.theme};function St(e){return'string'==typeof e&&!0}function At(e){return St(e)?"styled."+e:"Styled("+C(e)+")"}var xt=f.createContext(),Et=xt.Consumer;function Rt(e,t){return e?S(e)?e(t):Array.isArray(e)||'object'!=typeof e?j(8):t?N({},t,{},e):e:j(14)}var Nt=function(){return!0},Pt=(function(e){function t(){for(var t,r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return(t=e.call.apply(e,[this].concat(n))||this).attrs={},t}P(t,e);var r=t.prototype;return r.render=function(){var e=this;return f.createElement(Et,null,function(t){var r,n=e.props,s=n.$as,i=n.as,o=n.forwardedComponent,a=n.forwardedAs,u=n.forwardedRef,c=n.style,f=void 0===c?[]:c,l=_(n,["$as","as","forwardedComponent","forwardedAs","forwardedRef","style"]),p=o.defaultProps,d=o.target,w=o.shouldForwardProp,m=e.attrs.$as||e.attrs.as||s||i||d,v=e.generateAndInjectStyles(Ct(e.props,t,p)||B,e.props),g=St(m),y=e.attrs!==l?N({},l,{},e.attrs):l,b=w||g&&Nt,k={};for(r in y)'$'!==r[0]&&'as'!==r&&('forwardedAs'===r?k.as=l[r]:b&&!b(r,Nt)||(k[r]=y[r]));return k.style=[v].concat(f),u&&(k.ref=u),a&&(k.as=a),h.createElement(m,k)})},r.buildExecutionContext=function(e,t,r){var n=this,s=N({},t,{theme:e});return r.length?(this.attrs={},r.forEach(function(e){var t,r,i=e;for(r in S(i)&&(i=i(s)),i)t=i[r],n.attrs[r]=t,s[r]=t}),s):s},r.generateAndInjectStyles=function(e,t){var r=t.forwardedComponent.inlineStyle,n=this.buildExecutionContext(e,t,t.forwardedComponent.attrs);return r.generateStyleObject(n)},r.setNativeProps=function(e){void 0!==this.root&&this.root.setNativeProps(e)},t})(h.Component),_t=function(e,t){for(var r=[e[0]],n=0,s=t.length;n<s;n+=1)r.push(t[n],e[n+1]);return r};function Ot(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];return S(e)||A(e)?ge(_t(T,[e].concat(r))):0===r.length&&1===e.length&&"string"==typeof e[0]?e:ge(_t(e,r))}function It(e,t,r){if(void 0===r&&(r=B),!c.isValidElementType(t))return j(1,String(t));var n=function(){return e(t,r,Ot.apply(void 0,arguments))};return n.withConfig=function(n){return It(e,t,N({},r,{},n))},n.attrs=function(n){return It(e,t,N({},r,{attrs:Array.prototype.concat(r.attrs,n).filter(Boolean)}))},n}var Ut,Tt=t(o[8]),Bt=(function(e){return function t(r,n,s){var i=n.attrs,o=void 0===i?T:i,a=n.displayName,u=void 0===a?At(r):a,c=n.ParentComponent,h=void 0===c?Pt:c,l=!St(r),p=x(r),d=f.forwardRef(function(e,t){return f.createElement(h,N({},e,{forwardedComponent:d,forwardedRef:t}))}),m=p&&r.attrs?Array.prototype.concat(r.attrs,o).filter(Boolean):o,v=n.shouldForwardProp;return p&&r.shouldForwardProp&&(v=v?function(e,t){return r.shouldForwardProp(e,t)&&n.shouldForwardProp(e,t)}:r.shouldForwardProp),d.attrs=m,d.displayName=u,d.shouldForwardProp=v,d.inlineStyle=new e(p?r.inlineStyle.rules.concat(s):s),d.styledComponentId='StyledNativeComponent',d.target=p?r.target:r,d.withComponent=function(e){n.displayName,n.componentId;var r=N({},_(n,["displayName","componentId"]),{attrs:m,ParentComponent:h});return t(e,r,s)},Object.defineProperty(d,'defaultProps',{get:function(){return this._foldedDefaultProps},set:function(e){this._foldedDefaultProps=p?kt({},r.defaultProps,e):e}}),l&&w(d,r,{attrs:!0,displayName:!0,shouldForwardProp:!0,inlineStyle:!0,styledComponentId:!0,target:!0,withComponent:!0}),d}})((Ut=Tt.StyleSheet,(function(){function e(e){this.rules=e}return e.prototype.generateStyleObject=function(e){var t,r,n,s=ge(this.rules,e).join(''),i=y(k(b,s)>>>0);if(!vt[i]){var o=[];(r=new wt(s,t),(n=new mt(r)).tokenize(),n.loop(),n.root).each(function(e){'decl'===e.type&&o.push([e.prop,e.value])});var a=u(o,['borderRadius','borderWidth','borderColor','borderStyle']),c=Ut.create({generated:a});vt[i]=c.generated}return vt[i]},e})())),jt=function(e){return It(Bt,e)};"ActivityIndicator ActivityIndicatorIOS ART Button DatePickerIOS DrawerLayoutAndroid\n Image ImageBackground ImageEditor ImageStore KeyboardAvoidingView ListView MapView Modal NavigatorIOS\n Picker PickerIOS ProgressBarAndroid ProgressViewIOS ScrollView SegmentedControlIOS Slider\n SliderIOS SnapshotViewIOS Switch RecyclerViewBackedScrollView RefreshControl SafeAreaView StatusBar\n SwipeableListView SwitchAndroid SwitchIOS TabBarIOS Text TextInput ToastAndroid ToolbarAndroid\n Touchable TouchableHighlight TouchableNativeFeedback TouchableOpacity TouchableWithoutFeedback\n View ViewPagerAndroid WebView FlatList SectionList VirtualizedList Pressable".split(/\s+/m).forEach(function(e){return Object.defineProperty(jt,e,{enumerable:!0,configurable:!1,get:function(){return jt(Tt[e])}})}),i.ThemeConsumer=Et,i.ThemeContext=xt,i.ThemeProvider=function(e){var t=h.useContext(xt),r=h.useMemo(function(){return Rt(e.theme,t)},[e.theme,t]);return e.children?f.createElement(xt.Provider,{value:r},e.children):null},i.css=Ot,i.default=jt,i.isStyledComponent=x,i.useTheme=function(){return h.useContext(xt)},i.withTheme=function(e){var t=f.forwardRef(function(t,r){var n=h.useContext(xt),s=e.defaultProps,i=Ct(t,n,s);return f.createElement(e,N({},t,{theme:i,ref:r}))});return w(t,e),t.displayName="WithTheme("+C(e)+")",t}},598,[599,405,14,608,609,610,611,404,17]);^~~~> Task :app:copyProdReleaseBundledJs> Task :app:generateProdReleaseResValues> Task :app:generateProdReleaseResources> Task :app:mainApkListPersistenceProdRelease> Task :app:createProdReleaseCompatibleScreenManifests> Task :app:processProdReleaseManifest/home/vagrant/build/com.standardnotes/android/app/src/main/AndroidManifest.xml:10:5-94 Warning:uses-permission#android.permission.READ_PHONE_STATE was tagged at AndroidManifest.xml:10 to remove other declarations but no other declaration present/home/vagrant/build/com.standardnotes/android/app/src/main/AndroidManifest.xml:11:5-99 Warning:uses-permission#android.permission.READ_EXTERNAL_STORAGE was tagged at AndroidManifest.xml:11 to remove other declarations but no other declaration present> Task :app:mergeProdReleaseResources> Task :app:copyProdReleaseIconFonts> Task :app:processProdReleaseResources> Task :app:compileProdReleaseJavaWithJavacNote: /home/vagrant/build/com.standardnotes/android/app/src/main/java/com/standardnotes/MainApplication.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.> Task :app:compileProdReleaseSources> Task :app:prepareLintJar> Task :react-native-community_async-storage:prepareLintJarForPublish> Task :react-native-aes-crypto:prepareLintJarForPublish> Task :react-native-document-picker:prepareLintJarForPublish> Task :react-native-file-viewer:prepareLintJarForPublish> Task :react-native-fingerprint-scanner:prepareLintJarForPublish> Task :react-native-flag-secure-android:prepareLintJarForPublish> Task :react-native-fs:prepareLintJarForPublish> Task :react-native-gesture-handler:prepareLintJarForPublish> Task :react-native-keychain:prepareLintJarForPublish> Task :react-native-mail:prepareLintJarForPublish> Task :react-native-reanimated:prepareLintJarForPublish> Task :react-native-safe-area-context:prepareLintJarForPublish> Task :react-native-screens:prepareLintJarForPublish> Task :react-native-search-bar:prepareLintJarForPublish> Task :react-native-sodium:prepareLintJarForPublish> Task :react-native-vector-icons:prepareLintJarForPublish> Task :react-native-version-info:prepareLintJarForPublish> Task :react-native-webview:prepareLintJarForPublish> Task :sn-textview:prepareLintJarForPublish> Task :standard-notes-rn:prepareLintJarForPublish> Task :react-native-document-picker:bundleLibRuntimeRelease> Task :react-native-default-preference:prepareLintJarForPublish> Task :react-native-community_masked-view:prepareLintJarForPublish> Task :react-native-community_netinfo:prepareLintJarForPublish> Task :app:lintVitalProdReleaseCalling mockable JAR artifact transform to create file: /home/vagrant/.gradle/caches/transforms-2/files-2.1/43fb562836eece152ce7ca30373e78de/android.jar with input /opt/android-sdk/platforms/android-30/android.jarCalling mockable JAR artifact transform to create file: /home/vagrant/.gradle/caches/transforms-2/files-2.1/88aded3ba8a5dcc7dabb1ca639c6c45b/android.jar with input /opt/android-sdk/platforms/android-30/android.jar> Task :standard-notes-rn:bundleLibRuntimeRelease> Task :react-native-vector-icons:bundleLibRuntimeRelease> Task :sn-textview:bundleLibRuntimeRelease> Task :react-native-version-info:bundleLibRuntimeRelease> Task :react-native-webview:bundleLibRuntimeRelease> Task :react-native-sodium:bundleLibRuntimeRelease> Task :react-native-search-bar:bundleLibRuntimeRelease> Task :react-native-screens:bundleLibRuntimeRelease> Task :react-native-safe-area-context:bundleLibRuntimeRelease> Task :react-native-reanimated:bundleLibRuntimeRelease> Task :react-native-mail:bundleLibRuntimeRelease> Task :react-native-keychain:bundleLibRuntimeRelease> Task :react-native-gesture-handler:bundleLibRuntimeRelease> Task :react-native-fs:bundleLibRuntimeRelease> Task :react-native-flag-secure-android:bundleLibRuntimeRelease> Task :react-native-fingerprint-scanner:bundleLibRuntimeRelease> Task :react-native-file-viewer:bundleLibRuntimeRelease> Task :react-native-default-preference:bundleLibRuntimeRelease> Task :react-native-aes-crypto:bundleLibRuntimeRelease> Task :react-native-community_netinfo:bundleLibRuntimeRelease> Task :react-native-community_masked-view:bundleLibRuntimeRelease> Task :react-native-community_async-storage:bundleLibRuntimeRelease> Task :app:checkProdReleaseDuplicateClasses> Task :app:transformClassesWithDexBuilderForProdRelease> Task :app:processProdReleaseJavaRes NO-SOURCE> Task :react-native-aes-crypto:processReleaseJavaRes NO-SOURCE> Task :react-native-community_async-storage:processReleaseJavaRes NO-SOURCE> Task :react-native-community_async-storage:bundleLibResRelease> Task :react-native-community_masked-view:processReleaseJavaRes NO-SOURCE> Task :react-native-community_masked-view:bundleLibResRelease> Task :react-native-community_netinfo:processReleaseJavaRes NO-SOURCE> Task :react-native-community_netinfo:bundleLibResRelease> Task :react-native-default-preference:processReleaseJavaRes NO-SOURCE> Task :react-native-default-preference:bundleLibResRelease> Task :react-native-document-picker:processReleaseJavaRes NO-SOURCE> Task :react-native-document-picker:bundleLibResRelease> Task :react-native-file-viewer:processReleaseJavaRes NO-SOURCE> Task :react-native-file-viewer:bundleLibResRelease> Task :react-native-fingerprint-scanner:processReleaseJavaRes NO-SOURCE> Task :react-native-fingerprint-scanner:bundleLibResRelease> Task :react-native-flag-secure-android:processReleaseJavaRes NO-SOURCE> Task :react-native-flag-secure-android:bundleLibResRelease> Task :react-native-fs:processReleaseJavaRes NO-SOURCE> Task :react-native-gesture-handler:processReleaseJavaRes NO-SOURCE> Task :app:desugarProdReleaseFileDependencies> Task :react-native-keychain:processReleaseJavaRes NO-SOURCE> Task :react-native-gesture-handler:bundleLibResRelease> Task :react-native-mail:processReleaseJavaRes NO-SOURCE> Task :react-native-mail:bundleLibResRelease> Task :react-native-reanimated:processReleaseJavaRes NO-SOURCE> Task :react-native-reanimated:bundleLibResRelease> Task :react-native-safe-area-context:processReleaseJavaRes NO-SOURCE> Task :react-native-keychain:bundleLibResRelease> Task :react-native-screens:processReleaseJavaRes NO-SOURCE> Task :react-native-screens:bundleLibResRelease> Task :react-native-search-bar:processReleaseJavaRes NO-SOURCE> Task :react-native-aes-crypto:bundleLibResRelease> Task :react-native-sodium:processReleaseJavaRes NO-SOURCE> Task :react-native-fs:bundleLibResRelease> Task :react-native-vector-icons:processReleaseJavaRes NO-SOURCE> Task :react-native-vector-icons:bundleLibResRelease> Task :react-native-version-info:processReleaseJavaRes NO-SOURCE> Task :react-native-version-info:bundleLibResRelease> Task :react-native-webview:processReleaseJavaRes NO-SOURCE> Task :react-native-safe-area-context:bundleLibResRelease> Task :react-native-search-bar:bundleLibResRelease> Task :sn-textview:processReleaseJavaRes NO-SOURCE> Task :sn-textview:bundleLibResRelease> Task :standard-notes-rn:processReleaseJavaRes NO-SOURCE> Task :react-native-sodium:bundleLibResRelease> Task :app:signingConfigWriterProdRelease> Task :react-native-webview:bundleLibResRelease> Task :standard-notes-rn:bundleLibResRelease> Task :app:mergeProdReleaseJniLibFolders> Task :react-native-aes-crypto:mergeReleaseJniLibFolders> Task :react-native-community_async-storage:mergeReleaseJniLibFolders> Task :react-native-community_masked-view:mergeReleaseJniLibFolders> Task :react-native-aes-crypto:mergeReleaseNativeLibs> Task :react-native-aes-crypto:stripReleaseDebugSymbols> Task :react-native-aes-crypto:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-community_netinfo:mergeReleaseJniLibFolders> Task :react-native-community_async-storage:mergeReleaseNativeLibs> Task :react-native-community_async-storage:stripReleaseDebugSymbols> Task :react-native-community_async-storage:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-default-preference:mergeReleaseJniLibFolders> Task :react-native-community_netinfo:mergeReleaseNativeLibs> Task :react-native-community_netinfo:stripReleaseDebugSymbols> Task :react-native-community_masked-view:mergeReleaseNativeLibs> Task :react-native-community_masked-view:stripReleaseDebugSymbols> Task :react-native-community_masked-view:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-community_netinfo:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-document-picker:mergeReleaseJniLibFolders> Task :react-native-default-preference:mergeReleaseNativeLibs> Task :react-native-default-preference:stripReleaseDebugSymbols> Task :react-native-default-preference:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-document-picker:mergeReleaseNativeLibs> Task :react-native-document-picker:stripReleaseDebugSymbols> Task :react-native-document-picker:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-file-viewer:mergeReleaseJniLibFolders> Task :react-native-fingerprint-scanner:mergeReleaseJniLibFolders> Task :react-native-fingerprint-scanner:mergeReleaseNativeLibs> Task :react-native-fingerprint-scanner:stripReleaseDebugSymbols> Task :react-native-fingerprint-scanner:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-file-viewer:mergeReleaseNativeLibs> Task :react-native-file-viewer:stripReleaseDebugSymbols> Task :react-native-file-viewer:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-flag-secure-android:mergeReleaseJniLibFolders> Task :react-native-fs:mergeReleaseJniLibFolders> Task :react-native-gesture-handler:mergeReleaseJniLibFolders> Task :react-native-flag-secure-android:mergeReleaseNativeLibs> Task :react-native-flag-secure-android:stripReleaseDebugSymbols> Task :react-native-flag-secure-android:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-gesture-handler:mergeReleaseNativeLibs> Task :react-native-gesture-handler:stripReleaseDebugSymbols> Task :react-native-gesture-handler:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-keychain:mergeReleaseJniLibFolders> Task :react-native-mail:mergeReleaseJniLibFolders> Task :react-native-keychain:mergeReleaseNativeLibs> Task :react-native-keychain:stripReleaseDebugSymbols> Task :react-native-keychain:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-mail:mergeReleaseNativeLibs> Task :react-native-mail:stripReleaseDebugSymbols> Task :react-native-mail:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-reanimated:mergeReleaseJniLibFolders> Task :react-native-fs:mergeReleaseNativeLibs> Task :react-native-fs:stripReleaseDebugSymbols> Task :react-native-fs:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-safe-area-context:mergeReleaseJniLibFolders> Task :react-native-reanimated:mergeReleaseNativeLibs> Task :react-native-reanimated:stripReleaseDebugSymbols> Task :react-native-reanimated:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-screens:mergeReleaseJniLibFolders> Task :react-native-screens:mergeReleaseNativeLibs> Task :react-native-screens:stripReleaseDebugSymbols> Task :react-native-screens:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-search-bar:mergeReleaseJniLibFolders> Task :react-native-safe-area-context:mergeReleaseNativeLibs> Task :react-native-safe-area-context:stripReleaseDebugSymbols> Task :react-native-safe-area-context:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-search-bar:mergeReleaseNativeLibs> Task :react-native-search-bar:stripReleaseDebugSymbols> Task :react-native-search-bar:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-sodium:generateJsonModelReleaserelease|armeabi-v7a :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clangrelease|armeabi-v7a :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- worksrelease|armeabi-v7a :-- Detecting C compiler ABI inforelease|armeabi-v7a :-- Detecting C compiler ABI info - donerelease|armeabi-v7a :-- Detecting C compile featuresrelease|armeabi-v7a :-- Detecting C compile features - donerelease|armeabi-v7a :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++release|armeabi-v7a :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- worksrelease|armeabi-v7a :-- Detecting CXX compiler ABI inforelease|armeabi-v7a :-- Detecting CXX compiler ABI info - donerelease|armeabi-v7a :-- Detecting CXX compile featuresrelease|armeabi-v7a :-- Detecting CXX compile features - donerelease|armeabi-v7a :-- Configuring donerelease|armeabi-v7a :-- Generating donerelease|armeabi-v7a :-- Build files have been written to: /home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/.cxx/cmake/release/armeabi-v7arelease|arm64-v8a :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clangrelease|arm64-v8a :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- worksrelease|arm64-v8a :-- Detecting C compiler ABI inforelease|arm64-v8a :-- Detecting C compiler ABI info - donerelease|arm64-v8a :-- Detecting C compile featuresrelease|arm64-v8a :-- Detecting C compile features - donerelease|arm64-v8a :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++release|arm64-v8a :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- worksrelease|arm64-v8a :-- Detecting CXX compiler ABI inforelease|arm64-v8a :-- Detecting CXX compiler ABI info - donerelease|arm64-v8a :-- Detecting CXX compile featuresrelease|arm64-v8a :-- Detecting CXX compile features - donerelease|arm64-v8a :-- Configuring donerelease|arm64-v8a :-- Generating donerelease|arm64-v8a :-- Build files have been written to: /home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/.cxx/cmake/release/arm64-v8arelease|x86 :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clangrelease|x86 :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- worksrelease|x86 :-- Detecting C compiler ABI inforelease|x86 :-- Detecting C compiler ABI info - donerelease|x86 :-- Detecting C compile featuresrelease|x86 :-- Detecting C compile features - donerelease|x86 :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++release|x86 :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- worksrelease|x86 :-- Detecting CXX compiler ABI inforelease|x86 :-- Detecting CXX compiler ABI info - donerelease|x86 :-- Detecting CXX compile featuresrelease|x86 :-- Detecting CXX compile features - donerelease|x86 :-- Configuring donerelease|x86 :-- Generating donerelease|x86 :-- Build files have been written to: /home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/.cxx/cmake/release/x86release|x86_64 :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clangrelease|x86_64 :-- Check for working C compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- worksrelease|x86_64 :-- Detecting C compiler ABI inforelease|x86_64 :-- Detecting C compiler ABI info - donerelease|x86_64 :-- Detecting C compile featuresrelease|x86_64 :-- Detecting C compile features - donerelease|x86_64 :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++release|x86_64 :-- Check for working CXX compiler: /opt/android-sdk/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- worksrelease|x86_64 :-- Detecting CXX compiler ABI inforelease|x86_64 :-- Detecting CXX compiler ABI info - donerelease|x86_64 :-- Detecting CXX compile featuresrelease|x86_64 :-- Detecting CXX compile features - donerelease|x86_64 :-- Configuring donerelease|x86_64 :-- Generating donerelease|x86_64 :-- Build files have been written to: /home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/.cxx/cmake/release/x86_64> Task :react-native-sodium:externalNativeBuildReleaseBuild sodium-jni_armeabi-v7a[1/2] Building C object CMakeFiles/sodium-jni.dir/src/main/cpp/sodium-jni.c.o/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:167:10: warning: incompatible pointer to integer conversion returning 'unsigned char *' from a function with result type 'jchar' (aka 'unsigned short') [-Wint-conversion]return k;^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:55: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:95:42: note: passing argument to parameter 'b64' hereconst char * const b64, const size_t b64_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:71: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~~~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:96:42: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:229:36: warning: passing 'int *' to parameter of type 'size_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]ptr, j_b64_end, j_variant);^~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:96:65: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:33: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:60:35: note: passing argument to parameter 'hex' herechar *sodium_bin2hex(char * const hex, const size_t hex_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:52: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:66:39: note: passing argument to parameter 'hex' hereconst char * const hex, const size_t hex_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:68: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~~~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:67:39: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:76: warning: passing 'int *' to parameter of type 'size_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:67:62: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:36: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^~~../../../../../libsodium/libsodium-android-armv7-a/include/sodium/utils.h:89:38: note: passing argument to parameter 'b64' herechar *sodium_bin2base64(char * const b64, const size_t b64_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~11 warnings generated.[2/2] Linking C shared library ../../../../build/intermediates/cmake/release/obj/armeabi-v7a/libsodium-jni.soBuild sodium-jni_arm64-v8a[1/2] Building C object CMakeFiles/sodium-jni.dir/src/main/cpp/sodium-jni.c.o/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:167:10: warning: incompatible pointer to integer conversion returning 'unsigned char *' from a function with result type 'jchar' (aka 'unsigned short') [-Wint-conversion]return k;^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:55: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:95:42: note: passing argument to parameter 'b64' hereconst char * const b64, const size_t b64_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:71: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~~~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:96:42: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:229:36: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]ptr, j_b64_end, j_variant);^~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:96:65: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:33: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:60:35: note: passing argument to parameter 'hex' herechar *sodium_bin2hex(char * const hex, const size_t hex_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:52: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:66:39: note: passing argument to parameter 'hex' hereconst char * const hex, const size_t hex_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:68: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~~~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:67:39: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:76: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:67:62: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:36: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^~~../../../../../libsodium/libsodium-android-armv8-a/include/sodium/utils.h:89:38: note: passing argument to parameter 'b64' herechar *sodium_bin2base64(char * const b64, const size_t b64_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~11 warnings generated.[2/2] Linking C shared library ../../../../build/intermediates/cmake/release/obj/arm64-v8a/libsodium-jni.soBuild sodium-jni_x86[1/2] Building C object CMakeFiles/sodium-jni.dir/src/main/cpp/sodium-jni.c.o/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:167:10: warning: incompatible pointer to integer conversion returning 'unsigned char *' from a function with result type 'jchar' (aka 'unsigned short') [-Wint-conversion]return k;^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:55: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:95:42: note: passing argument to parameter 'b64' hereconst char * const b64, const size_t b64_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:71: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~~~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:96:42: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:229:36: warning: passing 'int *' to parameter of type 'size_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]ptr, j_b64_end, j_variant);^~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:96:65: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:33: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:60:35: note: passing argument to parameter 'hex' herechar *sodium_bin2hex(char * const hex, const size_t hex_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:52: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:66:39: note: passing argument to parameter 'hex' hereconst char * const hex, const size_t hex_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:68: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~~~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:67:39: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:76: warning: passing 'int *' to parameter of type 'size_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:67:62: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:36: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^~~../../../../../libsodium/libsodium-android-i686/include/sodium/utils.h:89:38: note: passing argument to parameter 'b64' herechar *sodium_bin2base64(char * const b64, const size_t b64_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~11 warnings generated.[2/2] Linking C shared library ../../../../build/intermediates/cmake/release/obj/x86/libsodium-jni.soBuild sodium-jni_x86_64[1/2] Building C object CMakeFiles/sodium-jni.dir/src/main/cpp/sodium-jni.c.o/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:167:10: warning: incompatible pointer to integer conversion returning 'unsigned char *' from a function with result type 'jchar' (aka 'unsigned short') [-Wint-conversion]return k;^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:55: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:95:42: note: passing argument to parameter 'b64' hereconst char * const b64, const size_t b64_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:228:71: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_base642bin(bin, j_bin_maxlen, b64, j_b64_len, ignore,^~~~~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:96:42: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:229:36: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]ptr, j_b64_end, j_variant);^~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:96:65: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:33: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:60:35: note: passing argument to parameter 'hex' herechar *sodium_bin2hex(char * const hex, const size_t hex_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:243:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2hex(hex, j_hex_maxlen, bin, j_bin_len);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:52: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:66:39: note: passing argument to parameter 'hex' hereconst char * const hex, const size_t hex_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:68: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~~~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:67:39: note: passing argument to parameter 'ignore' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:260:76: warning: incompatible pointer types passing 'int *' to parameter of type 'size_t *' (aka 'unsigned long *') [-Wincompatible-pointer-types]int result = sodium_hex2bin(bin, j_bin_maxlen, hex, j_hex_len, ignore, ptr, j_hex_end);^~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:67:62: note: passing argument to parameter 'bin_len' hereconst char * const ignore, size_t * const bin_len,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:36: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^~~../../../../../libsodium/libsodium-android-westmere/include/sodium/utils.h:89:38: note: passing argument to parameter 'b64' herechar *sodium_bin2base64(char * const b64, const size_t b64_maxlen,^/home/vagrant/build/com.standardnotes/node_modules/react-native-sodium/android/src/main/cpp/sodium-jni.c:275:9: warning: incompatible pointer to integer conversion initializing 'int' with an expression of type 'char *' [-Wint-conversion]int result = sodium_bin2base64(b64, j_b64_maxlen, bin, j_bin_len, j_variant);^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~11 warnings generated.[2/2] Linking C shared library ../../../../build/intermediates/cmake/release/obj/x86_64/libsodium-jni.so> Task :react-native-sodium:mergeReleaseJniLibFolders> Task :app:mergeProdReleaseJavaResource> Task :react-native-vector-icons:mergeReleaseJniLibFolders> Task :react-native-vector-icons:mergeReleaseNativeLibs> Task :react-native-vector-icons:stripReleaseDebugSymbols> Task :react-native-vector-icons:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-version-info:mergeReleaseJniLibFolders> Task :react-native-webview:mergeReleaseJniLibFolders> Task :sn-textview:mergeReleaseJniLibFolders> Task :react-native-sodium:mergeReleaseNativeLibs> Task :react-native-sodium:stripReleaseDebugSymbols> Task :react-native-sodium:transformNativeLibsWithIntermediateJniLibsForRelease> Task :standard-notes-rn:mergeReleaseJniLibFolders> Task :standard-notes-rn:mergeReleaseNativeLibs> Task :standard-notes-rn:stripReleaseDebugSymbols> Task :standard-notes-rn:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-version-info:mergeReleaseNativeLibs> Task :react-native-version-info:stripReleaseDebugSymbols> Task :react-native-version-info:transformNativeLibsWithIntermediateJniLibsForRelease> Task :sn-textview:mergeReleaseNativeLibs> Task :sn-textview:stripReleaseDebugSymbols> Task :sn-textview:transformNativeLibsWithIntermediateJniLibsForRelease> Task :react-native-webview:mergeReleaseNativeLibs> Task :react-native-webview:stripReleaseDebugSymbols> Task :react-native-webview:transformNativeLibsWithIntermediateJniLibsForRelease> Task :app:mergeProdReleaseNativeLibs> Task :app:stripProdReleaseDebugSymbolsSupport for ANDROID_NDK_HOME is deprecated and will be removed in the future. Use android.ndkVersion in build.gradle instead.Unable to strip library '/home/vagrant/build/com.standardnotes/android/app/build/intermediates/merged_native_libs/prodRelease/out/lib/armeabi/libconceal.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.> Task :app:mergeExtDexProdRelease> Task :app:mergeDexProdRelease> Task :app:packageProdRelease> Task :app:assembleProdReleaseDeprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.Use '--warning-mode all' to show the individual deprecation warnings.See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warningsBUILD SUCCESSFUL in 2m 50s493 actionable tasks: 493 executed2022-01-13 03:03:28,236 DEBUG: Popen(['git', 'cat-file', '--batch-check'], cwd=/home/vagrant/build/com.standardnotes, universal_newlines=False, shell=None)2022-01-13 03:03:28,308 INFO: Successfully built version 3.9.6 of com.standardnotes from 995bf591ab4a8f14ae00a061063c0ae37afa3d0e2022-01-13 03:03:29,739 DEBUG: AXML contains a RESOURCE MAP2022-01-13 03:03:29,739 DEBUG: Start of Namespace mapping: prefix 26: 'android' --> uri 54: 'http://schemas.android.com/apk/res/android'2022-01-13 03:03:29,741 DEBUG: Checking build/com.standardnotes/android/app/build/outputs/apk/prod/release/app-prod-release-unsigned.apk2022-01-13 03:03:29,753 DEBUG: AXML contains a RESOURCE MAP2022-01-13 03:03:29,753 DEBUG: Start of Namespace mapping: prefix 26: 'android' --> uri 54: 'http://schemas.android.com/apk/res/android'2022-01-13 03:03:29,794 INFO: success: com.standardnotes2022-01-13 03:03:29,795 INFO: Finished2022-01-13 03:03:29,795 INFO: 1 build succeeded